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