Lines Matching refs:ts
75 int (*func)(struct ilitek_ts_data *ts, u16 cmd, u8 *inbuf, u8 *outbuf);
94 static int ilitek_i2c_write_and_read(struct ilitek_ts_data *ts, in ilitek_i2c_write_and_read() argument
99 struct i2c_client *client = ts->client; in ilitek_i2c_write_and_read()
139 static void ilitek_touch_down(struct ilitek_ts_data *ts, unsigned int id, in ilitek_touch_down() argument
142 struct input_dev *input = ts->input_dev; in ilitek_touch_down()
147 touchscreen_report_pos(input, &ts->prop, x, y, true); in ilitek_touch_down()
150 static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) in ilitek_process_and_report_v6() argument
158 struct input_dev *input = ts->input_dev; in ilitek_process_and_report_v6()
159 struct device *dev = &ts->client->dev; in ilitek_process_and_report_v6()
162 error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, buf, 64); in ilitek_process_and_report_v6()
174 if (report_max_point > ts->max_tp) { in ilitek_process_and_report_v6()
176 report_max_point, ts->max_tp); in ilitek_process_and_report_v6()
182 error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, in ilitek_process_and_report_v6()
201 if (x > ts->screen_max_x || x < ts->screen_min_x || in ilitek_process_and_report_v6()
202 y > ts->screen_max_y || y < ts->screen_min_y) { in ilitek_process_and_report_v6()
204 ts->screen_min_x, x, ts->screen_max_x, in ilitek_process_and_report_v6()
205 ts->screen_min_y, y, ts->screen_max_y); in ilitek_process_and_report_v6()
209 ilitek_touch_down(ts, id, x, y); in ilitek_process_and_report_v6()
219 static int api_protocol_set_cmd(struct ilitek_ts_data *ts, in api_protocol_set_cmd() argument
228 cmd = ts->ptl_cb_func[idx].cmd; in api_protocol_set_cmd()
229 error = ts->ptl_cb_func[idx].func(ts, cmd, inbuf, outbuf); in api_protocol_set_cmd()
236 static int api_protocol_get_ptl_ver(struct ilitek_ts_data *ts, in api_protocol_get_ptl_ver() argument
243 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 3); in api_protocol_get_ptl_ver()
247 ts->ptl.ver = get_unaligned_be16(outbuf); in api_protocol_get_ptl_ver()
248 ts->ptl.ver_major = outbuf[0]; in api_protocol_get_ptl_ver()
253 static int api_protocol_get_mcu_ver(struct ilitek_ts_data *ts, in api_protocol_get_mcu_ver() argument
260 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 32); in api_protocol_get_mcu_ver()
264 ts->mcu_ver = get_unaligned_le16(outbuf); in api_protocol_get_mcu_ver()
265 memset(ts->product_id, 0, sizeof(ts->product_id)); in api_protocol_get_mcu_ver()
266 memcpy(ts->product_id, outbuf + 6, 26); in api_protocol_get_mcu_ver()
271 static int api_protocol_get_fw_ver(struct ilitek_ts_data *ts, in api_protocol_get_fw_ver() argument
278 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); in api_protocol_get_fw_ver()
282 memcpy(ts->firmware_ver, outbuf, 8); in api_protocol_get_fw_ver()
287 static int api_protocol_get_scrn_res(struct ilitek_ts_data *ts, in api_protocol_get_scrn_res() argument
294 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); in api_protocol_get_scrn_res()
298 ts->screen_min_x = get_unaligned_le16(outbuf); in api_protocol_get_scrn_res()
299 ts->screen_min_y = get_unaligned_le16(outbuf + 2); in api_protocol_get_scrn_res()
300 ts->screen_max_x = get_unaligned_le16(outbuf + 4); in api_protocol_get_scrn_res()
301 ts->screen_max_y = get_unaligned_le16(outbuf + 6); in api_protocol_get_scrn_res()
306 static int api_protocol_get_tp_res(struct ilitek_ts_data *ts, in api_protocol_get_tp_res() argument
313 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 15); in api_protocol_get_tp_res()
317 ts->max_tp = outbuf[8]; in api_protocol_get_tp_res()
318 if (ts->max_tp > ILITEK_SUPPORT_MAX_POINT) { in api_protocol_get_tp_res()
319 dev_err(&ts->client->dev, "Invalid MAX_TP:%d from FW\n", in api_protocol_get_tp_res()
320 ts->max_tp); in api_protocol_get_tp_res()
327 static int api_protocol_get_ic_mode(struct ilitek_ts_data *ts, in api_protocol_get_ic_mode() argument
334 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 2); in api_protocol_get_ic_mode()
338 ts->ic_mode = outbuf[0]; in api_protocol_get_ic_mode()
342 static int api_protocol_set_ic_sleep(struct ilitek_ts_data *ts, in api_protocol_set_ic_sleep() argument
348 return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); in api_protocol_set_ic_sleep()
351 static int api_protocol_set_ic_wake(struct ilitek_ts_data *ts, in api_protocol_set_ic_wake() argument
357 return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); in api_protocol_set_ic_wake()
397 static void ilitek_reset(struct ilitek_ts_data *ts, int delay) in ilitek_reset() argument
399 if (ts->reset_gpio) { in ilitek_reset()
400 gpiod_set_value(ts->reset_gpio, 1); in ilitek_reset()
402 gpiod_set_value(ts->reset_gpio, 0); in ilitek_reset()
407 static int ilitek_protocol_init(struct ilitek_ts_data *ts) in ilitek_protocol_init() argument
412 ts->ptl_cb_func = ptl_func_map; in ilitek_protocol_init()
413 ts->reset_time = 600; in ilitek_protocol_init()
415 error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); in ilitek_protocol_init()
420 if (ts->ptl.ver_major == 0x3 || in ilitek_protocol_init()
421 ts->ptl.ver == BL_V1_6 || in ilitek_protocol_init()
422 ts->ptl.ver == BL_V1_7) in ilitek_protocol_init()
428 static int ilitek_read_tp_info(struct ilitek_ts_data *ts, bool boot) in ilitek_read_tp_info() argument
433 error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); in ilitek_read_tp_info()
437 error = api_protocol_set_cmd(ts, GET_MCU_VER, NULL, outbuf); in ilitek_read_tp_info()
441 error = api_protocol_set_cmd(ts, GET_FW_VER, NULL, outbuf); in ilitek_read_tp_info()
446 error = api_protocol_set_cmd(ts, GET_SCRN_RES, NULL, in ilitek_read_tp_info()
452 error = api_protocol_set_cmd(ts, GET_TP_RES, NULL, outbuf); in ilitek_read_tp_info()
456 error = api_protocol_set_cmd(ts, GET_IC_MODE, NULL, outbuf); in ilitek_read_tp_info()
463 static int ilitek_input_dev_init(struct device *dev, struct ilitek_ts_data *ts) in ilitek_input_dev_init() argument
472 ts->input_dev = input; in ilitek_input_dev_init()
479 ts->screen_min_x, ts->screen_max_x, 0, 0); in ilitek_input_dev_init()
481 ts->screen_min_y, ts->screen_max_y, 0, 0); in ilitek_input_dev_init()
483 touchscreen_parse_properties(input, true, &ts->prop); in ilitek_input_dev_init()
485 error = input_mt_init_slots(input, ts->max_tp, in ilitek_input_dev_init()
503 struct ilitek_ts_data *ts = dev_id; in ilitek_i2c_isr() local
506 error = ilitek_process_and_report_v6(ts); in ilitek_i2c_isr()
508 dev_err(&ts->client->dev, "[%s] err:%d\n", __func__, error); in ilitek_i2c_isr()
519 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in firmware_version_show() local
523 ts->firmware_ver[0], ts->firmware_ver[1], in firmware_version_show()
524 ts->firmware_ver[2], ts->firmware_ver[3], in firmware_version_show()
525 ts->firmware_ver[4], ts->firmware_ver[5], in firmware_version_show()
526 ts->firmware_ver[6], ts->firmware_ver[7]); in firmware_version_show()
534 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in product_id_show() local
537 ts->mcu_ver, ts->product_id); in product_id_show()
553 struct ilitek_ts_data *ts; in ilitek_ts_i2c_probe() local
562 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); in ilitek_ts_i2c_probe()
563 if (!ts) in ilitek_ts_i2c_probe()
566 ts->client = client; in ilitek_ts_i2c_probe()
567 i2c_set_clientdata(client, ts); in ilitek_ts_i2c_probe()
569 ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ilitek_ts_i2c_probe()
570 if (IS_ERR(ts->reset_gpio)) { in ilitek_ts_i2c_probe()
571 error = PTR_ERR(ts->reset_gpio); in ilitek_ts_i2c_probe()
576 ilitek_reset(ts, 1000); in ilitek_ts_i2c_probe()
578 error = ilitek_protocol_init(ts); in ilitek_ts_i2c_probe()
584 error = ilitek_read_tp_info(ts, true); in ilitek_ts_i2c_probe()
590 error = ilitek_input_dev_init(dev, ts); in ilitek_ts_i2c_probe()
596 error = devm_request_threaded_irq(dev, ts->client->irq, in ilitek_ts_i2c_probe()
598 "ilitek_touch_irq", ts); in ilitek_ts_i2c_probe()
616 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in ilitek_suspend() local
622 error = api_protocol_set_cmd(ts, SET_IC_SLEEP, NULL, NULL); in ilitek_suspend()
633 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in ilitek_resume() local
637 error = api_protocol_set_cmd(ts, SET_IC_WAKE, NULL, NULL); in ilitek_resume()
641 ilitek_reset(ts, ts->reset_time); in ilitek_resume()