Lines Matching refs:ts
73 int (*func)(struct ilitek_ts_data *ts, u16 cmd, u8 *inbuf, u8 *outbuf);
92 static int ilitek_i2c_write_and_read(struct ilitek_ts_data *ts, in ilitek_i2c_write_and_read() argument
97 struct i2c_client *client = ts->client; in ilitek_i2c_write_and_read()
137 static void ilitek_touch_down(struct ilitek_ts_data *ts, unsigned int id, in ilitek_touch_down() argument
140 struct input_dev *input = ts->input_dev; in ilitek_touch_down()
145 touchscreen_report_pos(input, &ts->prop, x, y, true); in ilitek_touch_down()
148 static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts) in ilitek_process_and_report_v6() argument
156 struct input_dev *input = ts->input_dev; in ilitek_process_and_report_v6()
157 struct device *dev = &ts->client->dev; in ilitek_process_and_report_v6()
160 error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, buf, 64); in ilitek_process_and_report_v6()
167 if (report_max_point > ts->max_tp) { in ilitek_process_and_report_v6()
169 report_max_point, ts->max_tp); in ilitek_process_and_report_v6()
176 error = ilitek_i2c_write_and_read(ts, NULL, 0, 0, in ilitek_process_and_report_v6()
195 if (x > ts->screen_max_x || x < ts->screen_min_x || in ilitek_process_and_report_v6()
196 y > ts->screen_max_y || y < ts->screen_min_y) { in ilitek_process_and_report_v6()
198 ts->screen_min_x, x, ts->screen_max_x, in ilitek_process_and_report_v6()
199 ts->screen_min_y, y, ts->screen_max_y); in ilitek_process_and_report_v6()
203 ilitek_touch_down(ts, id, x, y); in ilitek_process_and_report_v6()
213 static int api_protocol_set_cmd(struct ilitek_ts_data *ts, in api_protocol_set_cmd() argument
222 cmd = ts->ptl_cb_func[idx].cmd; in api_protocol_set_cmd()
223 error = ts->ptl_cb_func[idx].func(ts, cmd, inbuf, outbuf); in api_protocol_set_cmd()
230 static int api_protocol_get_ptl_ver(struct ilitek_ts_data *ts, in api_protocol_get_ptl_ver() argument
237 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 3); in api_protocol_get_ptl_ver()
241 ts->ptl.ver = get_unaligned_be16(outbuf); in api_protocol_get_ptl_ver()
242 ts->ptl.ver_major = outbuf[0]; in api_protocol_get_ptl_ver()
247 static int api_protocol_get_mcu_ver(struct ilitek_ts_data *ts, in api_protocol_get_mcu_ver() argument
254 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 32); in api_protocol_get_mcu_ver()
258 ts->mcu_ver = get_unaligned_le16(outbuf); in api_protocol_get_mcu_ver()
259 memset(ts->product_id, 0, sizeof(ts->product_id)); in api_protocol_get_mcu_ver()
260 memcpy(ts->product_id, outbuf + 6, 26); in api_protocol_get_mcu_ver()
265 static int api_protocol_get_fw_ver(struct ilitek_ts_data *ts, in api_protocol_get_fw_ver() argument
272 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); in api_protocol_get_fw_ver()
276 memcpy(ts->firmware_ver, outbuf, 8); in api_protocol_get_fw_ver()
281 static int api_protocol_get_scrn_res(struct ilitek_ts_data *ts, in api_protocol_get_scrn_res() argument
288 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 8); in api_protocol_get_scrn_res()
292 ts->screen_min_x = get_unaligned_le16(outbuf); in api_protocol_get_scrn_res()
293 ts->screen_min_y = get_unaligned_le16(outbuf + 2); in api_protocol_get_scrn_res()
294 ts->screen_max_x = get_unaligned_le16(outbuf + 4); in api_protocol_get_scrn_res()
295 ts->screen_max_y = get_unaligned_le16(outbuf + 6); in api_protocol_get_scrn_res()
300 static int api_protocol_get_tp_res(struct ilitek_ts_data *ts, in api_protocol_get_tp_res() argument
307 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 15); in api_protocol_get_tp_res()
311 ts->max_tp = outbuf[8]; in api_protocol_get_tp_res()
312 if (ts->max_tp > ILITEK_SUPPORT_MAX_POINT) { in api_protocol_get_tp_res()
313 dev_err(&ts->client->dev, "Invalid MAX_TP:%d from FW\n", in api_protocol_get_tp_res()
314 ts->max_tp); in api_protocol_get_tp_res()
321 static int api_protocol_get_ic_mode(struct ilitek_ts_data *ts, in api_protocol_get_ic_mode() argument
328 error = ilitek_i2c_write_and_read(ts, buf, 1, 5, outbuf, 2); in api_protocol_get_ic_mode()
332 ts->ic_mode = outbuf[0]; in api_protocol_get_ic_mode()
336 static int api_protocol_set_ic_sleep(struct ilitek_ts_data *ts, in api_protocol_set_ic_sleep() argument
342 return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); in api_protocol_set_ic_sleep()
345 static int api_protocol_set_ic_wake(struct ilitek_ts_data *ts, in api_protocol_set_ic_wake() argument
351 return ilitek_i2c_write_and_read(ts, buf, 1, 0, NULL, 0); in api_protocol_set_ic_wake()
391 static void ilitek_reset(struct ilitek_ts_data *ts, int delay) in ilitek_reset() argument
393 if (ts->reset_gpio) { in ilitek_reset()
394 gpiod_set_value(ts->reset_gpio, 1); in ilitek_reset()
396 gpiod_set_value(ts->reset_gpio, 0); in ilitek_reset()
401 static int ilitek_protocol_init(struct ilitek_ts_data *ts) in ilitek_protocol_init() argument
406 ts->ptl_cb_func = ptl_func_map; in ilitek_protocol_init()
407 ts->reset_time = 600; in ilitek_protocol_init()
409 error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); in ilitek_protocol_init()
414 if (ts->ptl.ver_major == 0x3 || in ilitek_protocol_init()
415 ts->ptl.ver == BL_V1_6 || in ilitek_protocol_init()
416 ts->ptl.ver == BL_V1_7) in ilitek_protocol_init()
422 static int ilitek_read_tp_info(struct ilitek_ts_data *ts, bool boot) in ilitek_read_tp_info() argument
427 error = api_protocol_set_cmd(ts, GET_PTL_VER, NULL, outbuf); in ilitek_read_tp_info()
431 error = api_protocol_set_cmd(ts, GET_MCU_VER, NULL, outbuf); in ilitek_read_tp_info()
435 error = api_protocol_set_cmd(ts, GET_FW_VER, NULL, outbuf); in ilitek_read_tp_info()
440 error = api_protocol_set_cmd(ts, GET_SCRN_RES, NULL, in ilitek_read_tp_info()
446 error = api_protocol_set_cmd(ts, GET_TP_RES, NULL, outbuf); in ilitek_read_tp_info()
450 error = api_protocol_set_cmd(ts, GET_IC_MODE, NULL, outbuf); in ilitek_read_tp_info()
457 static int ilitek_input_dev_init(struct device *dev, struct ilitek_ts_data *ts) in ilitek_input_dev_init() argument
466 ts->input_dev = input; in ilitek_input_dev_init()
473 ts->screen_min_x, ts->screen_max_x, 0, 0); in ilitek_input_dev_init()
475 ts->screen_min_y, ts->screen_max_y, 0, 0); in ilitek_input_dev_init()
477 touchscreen_parse_properties(input, true, &ts->prop); in ilitek_input_dev_init()
479 error = input_mt_init_slots(input, ts->max_tp, in ilitek_input_dev_init()
497 struct ilitek_ts_data *ts = dev_id; in ilitek_i2c_isr() local
500 error = ilitek_process_and_report_v6(ts); in ilitek_i2c_isr()
502 dev_err(&ts->client->dev, "[%s] err:%d\n", __func__, error); in ilitek_i2c_isr()
513 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in firmware_version_show() local
517 ts->firmware_ver[0], ts->firmware_ver[1], in firmware_version_show()
518 ts->firmware_ver[2], ts->firmware_ver[3], in firmware_version_show()
519 ts->firmware_ver[4], ts->firmware_ver[5], in firmware_version_show()
520 ts->firmware_ver[6], ts->firmware_ver[7]); in firmware_version_show()
528 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in product_id_show() local
531 ts->mcu_ver, ts->product_id); in product_id_show()
548 struct ilitek_ts_data *ts; in ilitek_ts_i2c_probe() local
557 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); in ilitek_ts_i2c_probe()
558 if (!ts) in ilitek_ts_i2c_probe()
561 ts->client = client; in ilitek_ts_i2c_probe()
562 i2c_set_clientdata(client, ts); in ilitek_ts_i2c_probe()
564 ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ilitek_ts_i2c_probe()
565 if (IS_ERR(ts->reset_gpio)) { in ilitek_ts_i2c_probe()
566 error = PTR_ERR(ts->reset_gpio); in ilitek_ts_i2c_probe()
571 ilitek_reset(ts, 1000); in ilitek_ts_i2c_probe()
573 error = ilitek_protocol_init(ts); in ilitek_ts_i2c_probe()
579 error = ilitek_read_tp_info(ts, true); in ilitek_ts_i2c_probe()
585 error = ilitek_input_dev_init(dev, ts); in ilitek_ts_i2c_probe()
591 error = devm_request_threaded_irq(dev, ts->client->irq, in ilitek_ts_i2c_probe()
593 "ilitek_touch_irq", ts); in ilitek_ts_i2c_probe()
611 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in ilitek_suspend() local
617 error = api_protocol_set_cmd(ts, SET_IC_SLEEP, NULL, NULL); in ilitek_suspend()
628 struct ilitek_ts_data *ts = i2c_get_clientdata(client); in ilitek_resume() local
632 error = api_protocol_set_cmd(ts, SET_IC_WAKE, NULL, NULL); in ilitek_resume()
636 ilitek_reset(ts, ts->reset_time); in ilitek_resume()