Lines Matching refs:ts
189 static int goodix_firmware_upload(struct goodix_ts_data *ts) in goodix_firmware_upload() argument
196 snprintf(fw_name, sizeof(fw_name), "goodix/%s", ts->firmware_name); in goodix_firmware_upload()
198 error = request_firmware(&fw, fw_name, &ts->client->dev); in goodix_firmware_upload()
200 dev_err(&ts->client->dev, "Firmware request error %d\n", error); in goodix_firmware_upload()
204 error = goodix_firmware_verify(&ts->client->dev, fw); in goodix_firmware_upload()
208 error = goodix_reset_no_int_sync(ts); in goodix_firmware_upload()
212 error = goodix_enter_upload_mode(ts->client); in goodix_firmware_upload()
217 error = goodix_i2c_write_u8(ts->client, in goodix_firmware_upload()
223 error = goodix_i2c_write(ts->client, GOODIX_FW_UPLOAD_ADDRESS, in goodix_firmware_upload()
229 error = goodix_i2c_write_u8(ts->client, in goodix_firmware_upload()
235 error = goodix_i2c_write(ts->client, GOODIX_FW_UPLOAD_ADDRESS, in goodix_firmware_upload()
241 error = goodix_i2c_write_u8(ts->client, in goodix_firmware_upload()
247 error = goodix_i2c_write(ts->client, GOODIX_FW_UPLOAD_ADDRESS, in goodix_firmware_upload()
252 error = goodix_start_firmware(ts->client); in goodix_firmware_upload()
256 error = goodix_int_sync(ts); in goodix_firmware_upload()
262 static int goodix_prepare_bak_ref(struct goodix_ts_data *ts) in goodix_prepare_bak_ref() argument
266 if (ts->bak_ref) in goodix_prepare_bak_ref()
269 have_key = (ts->config[GOODIX_CFG_LOC_HAVE_KEY] & 0x01); in goodix_prepare_bak_ref()
271 driver_num = (ts->config[GOODIX_CFG_LOC_DRVA_NUM] & 0x1f) + in goodix_prepare_bak_ref()
272 (ts->config[GOODIX_CFG_LOC_DRVB_NUM] & 0x1f); in goodix_prepare_bak_ref()
276 sensor_num = (ts->config[GOODIX_CFG_LOC_SENS_NUM] & 0x0f) + in goodix_prepare_bak_ref()
277 ((ts->config[GOODIX_CFG_LOC_SENS_NUM] >> 4) & 0x0f); in goodix_prepare_bak_ref()
279 dev_dbg(&ts->client->dev, "Drv %d Sen %d Key %d\n", in goodix_prepare_bak_ref()
282 ts->bak_ref_len = (driver_num * (sensor_num - 2) + 2) * 2; in goodix_prepare_bak_ref()
284 ts->bak_ref = devm_kzalloc(&ts->client->dev, in goodix_prepare_bak_ref()
285 ts->bak_ref_len, GFP_KERNEL); in goodix_prepare_bak_ref()
286 if (!ts->bak_ref) in goodix_prepare_bak_ref()
304 ts->bak_ref[ts->bak_ref_len - 1] = 1; in goodix_prepare_bak_ref()
309 static int goodix_send_main_clock(struct goodix_ts_data *ts) in goodix_send_main_clock() argument
315 device_property_read_u32(&ts->client->dev, in goodix_send_main_clock()
319 ts->main_clk[i] = main_clk; in goodix_send_main_clock()
324 ts->main_clk[GOODIX_MAIN_CLK_LEN - 1] = 256 - checksum; in goodix_send_main_clock()
326 return goodix_i2c_write(ts->client, GOODIX_REG_MAIN_CLK, in goodix_send_main_clock()
327 ts->main_clk, GOODIX_MAIN_CLK_LEN); in goodix_send_main_clock()
330 int goodix_firmware_check(struct goodix_ts_data *ts) in goodix_firmware_check() argument
332 device_property_read_string(&ts->client->dev, in goodix_firmware_check()
333 "firmware-name", &ts->firmware_name); in goodix_firmware_check()
334 if (!ts->firmware_name) in goodix_firmware_check()
337 if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_NONE) { in goodix_firmware_check()
338 dev_err(&ts->client->dev, "Error no IRQ-pin access method, cannot upload fw.\n"); in goodix_firmware_check()
342 dev_info(&ts->client->dev, "Touchscreen controller needs fw-upload\n"); in goodix_firmware_check()
343 ts->load_cfg_from_disk = true; in goodix_firmware_check()
345 return goodix_firmware_upload(ts); in goodix_firmware_check()
348 bool goodix_handle_fw_request(struct goodix_ts_data *ts) in goodix_handle_fw_request() argument
353 error = goodix_i2c_read(ts->client, GOODIX_REG_REQUEST, &val, 1); in goodix_handle_fw_request()
365 error = goodix_send_cfg(ts, ts->config, ts->chip->config_len); in goodix_handle_fw_request()
371 error = goodix_prepare_bak_ref(ts); in goodix_handle_fw_request()
375 error = goodix_i2c_write(ts->client, GOODIX_REG_BAK_REF, in goodix_handle_fw_request()
376 ts->bak_ref, ts->bak_ref_len); in goodix_handle_fw_request()
382 error = goodix_firmware_upload(ts); in goodix_handle_fw_request()
388 error = goodix_send_main_clock(ts); in goodix_handle_fw_request()
397 dev_err_ratelimited(&ts->client->dev, "Unknown Request: 0x%02x\n", val); in goodix_handle_fw_request()
401 goodix_i2c_write_u8(ts->client, in goodix_handle_fw_request()
406 void goodix_save_bak_ref(struct goodix_ts_data *ts) in goodix_save_bak_ref() argument
411 if (!ts->firmware_name) in goodix_save_bak_ref()
414 error = goodix_i2c_read(ts->client, GOODIX_REG_STATUS, &val, 1); in goodix_save_bak_ref()
421 error = goodix_i2c_read(ts->client, GOODIX_REG_BAK_REF, in goodix_save_bak_ref()
422 ts->bak_ref, ts->bak_ref_len); in goodix_save_bak_ref()
424 memset(ts->bak_ref, 0, ts->bak_ref_len); in goodix_save_bak_ref()
425 ts->bak_ref[ts->bak_ref_len - 1] = 1; in goodix_save_bak_ref()