Lines Matching full:ts
74 int (*func)(struct ilitek_ts_data *ts, u16 cmd, u8 *inbuf, u8 *outbuf);
93 static int ilitek_i2c_write_and_read(struct ilitek_ts_data *ts, in ilitek_i2c_write_and_read() argument
98 struct i2c_client *client = ts->client; in ilitek_i2c_write_and_read()
138 static void ilitek_touch_down(struct ilitek_ts_data *ts, unsigned int id, in ilitek_touch_down() argument
141 struct input_dev *input = ts->input_dev; in ilitek_touch_down()
146 touchscreen_report_pos(input, &ts->prop, x, y, true); in ilitek_touch_down()
149 static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) in ilitek_process_and_report_v6() argument
157 struct input_dev *input = ts->input_dev; in ilitek_process_and_report_v6()
158 struct device *dev = &ts->client->dev; in ilitek_process_and_report_v6()
161 error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, buf, 64); in ilitek_process_and_report_v6()
173 if (report_max_point > ts->max_tp) { in ilitek_process_and_report_v6()
175 report_max_point, ts->max_tp); in ilitek_process_and_report_v6()
181 error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, in ilitek_process_and_report_v6()
200 if (x > ts->screen_max_x || x < ts->screen_min_x || in ilitek_process_and_report_v6()
201 y > ts->screen_max_y || y < ts->screen_min_y) { in ilitek_process_and_report_v6()
203 ts->screen_min_x, x, ts->screen_max_x, in ilitek_process_and_report_v6()
204 ts->screen_min_y, y, ts->screen_max_y); in ilitek_process_and_report_v6()
208 ilitek_touch_down(ts, id, x, y); in ilitek_process_and_report_v6()
218 static int api_protocol_set_cmd(struct ilitek_ts_data *ts, in api_protocol_set_cmd() argument
227 cmd = ts->ptl_cb_func[idx].cmd; in api_protocol_set_cmd()
228 error = ts->ptl_cb_func[idx].func(ts, cmd, inbuf, outbuf); in api_protocol_set_cmd()
235 static int api_protocol_get_ptl_ver(struct ilitek_ts_data *ts, in api_protocol_get_ptl_ver() argument
242 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 3); in api_protocol_get_ptl_ver()
246 ts->ptl.ver = get_unaligned_be16(outbuf); in api_protocol_get_ptl_ver()
247 ts->ptl.ver_major = outbuf[0]; in api_protocol_get_ptl_ver()
252 static int api_protocol_get_mcu_ver(struct ilitek_ts_data *ts, in api_protocol_get_mcu_ver() argument
259 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 32); in api_protocol_get_mcu_ver()
263 ts->mcu_ver = get_unaligned_le16(outbuf); in api_protocol_get_mcu_ver()
264 memset(ts->product_id, 0, sizeof(ts->product_id)); in api_protocol_get_mcu_ver()
265 memcpy(ts->product_id, outbuf + 6, 26); in api_protocol_get_mcu_ver()
270 static int api_protocol_get_fw_ver(struct ilitek_ts_data *ts, in api_protocol_get_fw_ver() argument
277 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); in api_protocol_get_fw_ver()
281 memcpy(ts->firmware_ver, outbuf, 8); in api_protocol_get_fw_ver()
286 static int api_protocol_get_scrn_res(struct ilitek_ts_data *ts, in api_protocol_get_scrn_res() argument
293 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); in api_protocol_get_scrn_res()
297 ts->screen_min_x = get_unaligned_le16(outbuf); in api_protocol_get_scrn_res()
298 ts->screen_min_y = get_unaligned_le16(outbuf + 2); in api_protocol_get_scrn_res()
299 ts->screen_max_x = get_unaligned_le16(outbuf + 4); in api_protocol_get_scrn_res()
300 ts->screen_max_y = get_unaligned_le16(outbuf + 6); in api_protocol_get_scrn_res()
305 static int api_protocol_get_tp_res(struct ilitek_ts_data *ts, in api_protocol_get_tp_res() argument
312 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 15); in api_protocol_get_tp_res()
316 ts->max_tp = outbuf[8]; in api_protocol_get_tp_res()
317 if (ts->max_tp > ILITEK_SUPPORT_MAX_POINT) { in api_protocol_get_tp_res()
318 dev_err(&ts->client->dev, "Invalid MAX_TP:%d from FW\n", in api_protocol_get_tp_res()
319 ts->max_tp); in api_protocol_get_tp_res()
326 static int api_protocol_get_ic_mode(struct ilitek_ts_data *ts, in api_protocol_get_ic_mode() argument
333 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 2); in api_protocol_get_ic_mode()
337 ts->ic_mode = outbuf[0]; in api_protocol_get_ic_mode()
341 static int api_protocol_set_ic_sleep(struct ilitek_ts_data *ts, in api_protocol_set_ic_sleep() argument
347 return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); in api_protocol_set_ic_sleep()
350 static int api_protocol_set_ic_wake(struct ilitek_ts_data *ts, in api_protocol_set_ic_wake() argument
356 return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); in api_protocol_set_ic_wake()
396 static void ilitek_reset(struct ilitek_ts_data *ts, int delay) in ilitek_reset() argument
398 if (ts->reset_gpio) { in ilitek_reset()
399 gpiod_set_value(ts->reset_gpio, 1); in ilitek_reset()
401 gpiod_set_value(ts->reset_gpio, 0); in ilitek_reset()
406 static int ilitek_protocol_init(struct ilitek_ts_data *ts) in ilitek_protocol_init() argument
411 ts->ptl_cb_func = ptl_func_map; in ilitek_protocol_init()
412 ts->reset_time = 600; in ilitek_protocol_init()
414 error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); in ilitek_protocol_init()
419 if (ts->ptl.ver_major == 0x3 || in ilitek_protocol_init()
420 ts->ptl.ver == BL_V1_6 || in ilitek_protocol_init()
421 ts->ptl.ver == BL_V1_7) in ilitek_protocol_init()
427 static int ilitek_read_tp_info(struct ilitek_ts_data *ts, bool boot) in ilitek_read_tp_info() argument
432 error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); in ilitek_read_tp_info()
436 error = api_protocol_set_cmd(ts, GET_MCU_VER, NULL, outbuf); in ilitek_read_tp_info()
440 error = api_protocol_set_cmd(ts, GET_FW_VER, NULL, outbuf); in ilitek_read_tp_info()
445 error = api_protocol_set_cmd(ts, GET_SCRN_RES, NULL, in ilitek_read_tp_info()
451 error = api_protocol_set_cmd(ts, GET_TP_RES, NULL, outbuf); in ilitek_read_tp_info()
455 error = api_protocol_set_cmd(ts, GET_IC_MODE, NULL, outbuf); in ilitek_read_tp_info()
462 static int ilitek_input_dev_init(struct device *dev, struct ilitek_ts_data *ts) in ilitek_input_dev_init() argument
471 ts->input_dev = input; in ilitek_input_dev_init()
478 ts->screen_min_x, ts->screen_max_x, 0, 0); in ilitek_input_dev_init()
480 ts->screen_min_y, ts->screen_max_y, 0, 0); in ilitek_input_dev_init()
482 touchscreen_parse_properties(input, true, &ts->prop); in ilitek_input_dev_init()
484 error = input_mt_init_slots(input, ts->max_tp, in ilitek_input_dev_init()
502 struct ilitek_ts_data *ts = dev_id; in ilitek_i2c_isr() local
505 error = ilitek_process_and_report_v6(ts); in ilitek_i2c_isr()
507 dev_err(&ts->client->dev, "[%s] err:%d\n", __func__, error); in ilitek_i2c_isr()
518 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in firmware_version_show() local
522 ts->firmware_ver[0], ts->firmware_ver[1], in firmware_version_show()
523 ts->firmware_ver[2], ts->firmware_ver[3], in firmware_version_show()
524 ts->firmware_ver[4], ts->firmware_ver[5], in firmware_version_show()
525 ts->firmware_ver[6], ts->firmware_ver[7]); in firmware_version_show()
533 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in product_id_show() local
536 ts->mcu_ver, ts->product_id); in product_id_show()
549 struct ilitek_ts_data *ts; in ilitek_ts_i2c_probe() local
558 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); in ilitek_ts_i2c_probe()
559 if (!ts) in ilitek_ts_i2c_probe()
562 ts->client = client; in ilitek_ts_i2c_probe()
563 i2c_set_clientdata(client, ts); in ilitek_ts_i2c_probe()
565 ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ilitek_ts_i2c_probe()
566 if (IS_ERR(ts->reset_gpio)) { in ilitek_ts_i2c_probe()
567 error = PTR_ERR(ts->reset_gpio); in ilitek_ts_i2c_probe()
572 ilitek_reset(ts, 1000); in ilitek_ts_i2c_probe()
574 error = ilitek_protocol_init(ts); in ilitek_ts_i2c_probe()
580 error = ilitek_read_tp_info(ts, true); in ilitek_ts_i2c_probe()
586 error = ilitek_input_dev_init(dev, ts); in ilitek_ts_i2c_probe()
592 error = devm_request_threaded_irq(dev, ts->client->irq, in ilitek_ts_i2c_probe()
594 "ilitek_touch_irq", ts); in ilitek_ts_i2c_probe()
606 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in ilitek_suspend() local
612 error = api_protocol_set_cmd(ts, SET_IC_SLEEP, NULL, NULL); in ilitek_suspend()
623 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in ilitek_resume() local
627 error = api_protocol_set_cmd(ts, SET_IC_WAKE, NULL, NULL); in ilitek_resume()
631 ilitek_reset(ts, ts->reset_time); in ilitek_resume()