Lines Matching refs:ts
298 static int elants_i2c_calibrate(struct elants_data *ts) in elants_i2c_calibrate() argument
300 struct i2c_client *client = ts->client; in elants_i2c_calibrate()
308 ts->state = ELAN_WAIT_RECALIBRATION; in elants_i2c_calibrate()
309 reinit_completion(&ts->cmd_done); in elants_i2c_calibrate()
316 ret = wait_for_completion_interruptible_timeout(&ts->cmd_done, in elants_i2c_calibrate()
319 ts->state = ELAN_STATE_NORMAL; in elants_i2c_calibrate()
329 if (memcmp(rek_resp, ts->cmd_resp, sizeof(rek_resp))) { in elants_i2c_calibrate()
332 (int)sizeof(ts->cmd_resp), ts->cmd_resp); in elants_i2c_calibrate()
365 static int elants_i2c_query_hw_version(struct elants_data *ts) in elants_i2c_query_hw_version() argument
367 struct i2c_client *client = ts->client; in elants_i2c_query_hw_version()
380 ts->hw_version = elants_i2c_parse_version(resp); in elants_i2c_query_hw_version()
381 if (ts->hw_version != 0xffff) in elants_i2c_query_hw_version()
385 dev_err(&client->dev, "Invalid fw id: %#04x\n", ts->hw_version); in elants_i2c_query_hw_version()
390 static int elants_i2c_query_fw_version(struct elants_data *ts) in elants_i2c_query_fw_version() argument
392 struct i2c_client *client = ts->client; in elants_i2c_query_fw_version()
405 ts->fw_version = elants_i2c_parse_version(resp); in elants_i2c_query_fw_version()
406 if (ts->fw_version != 0x0000 && ts->fw_version != 0xffff) in elants_i2c_query_fw_version()
413 dev_err(&client->dev, "Invalid fw ver: %#04x\n", ts->fw_version); in elants_i2c_query_fw_version()
418 static int elants_i2c_query_test_version(struct elants_data *ts) in elants_i2c_query_test_version() argument
420 struct i2c_client *client = ts->client; in elants_i2c_query_test_version()
435 ts->test_version = version >> 8; in elants_i2c_query_test_version()
436 ts->solution_version = version & 0xff; in elants_i2c_query_test_version()
441 static int elants_i2c_query_bc_version(struct elants_data *ts) in elants_i2c_query_bc_version() argument
443 struct i2c_client *client = ts->client; in elants_i2c_query_bc_version()
456 ts->bc_version = version >> 8; in elants_i2c_query_bc_version()
457 ts->iap_version = version & 0xff; in elants_i2c_query_bc_version()
462 static int elants_i2c_query_ts_info_ektf(struct elants_data *ts) in elants_i2c_query_ts_info_ektf() argument
464 struct i2c_client *client = ts->client; in elants_i2c_query_ts_info_ektf()
496 ts->phy_x = phy_x; in elants_i2c_query_ts_info_ektf()
497 ts->phy_y = phy_y; in elants_i2c_query_ts_info_ektf()
500 ts->x_max = 2240 - 1; in elants_i2c_query_ts_info_ektf()
501 ts->y_max = 1408 - 1; in elants_i2c_query_ts_info_ektf()
506 static int elants_i2c_query_ts_info_ekth(struct elants_data *ts) in elants_i2c_query_ts_info_ekth() argument
508 struct i2c_client *client = ts->client; in elants_i2c_query_ts_info_ekth()
538 ts->major_res = resp[16]; in elants_i2c_query_ts_info_ekth()
577 ts->x_max = ELAN_TS_RESOLUTION(rows, osr); in elants_i2c_query_ts_info_ekth()
578 ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x); in elants_i2c_query_ts_info_ekth()
579 ts->y_max = ELAN_TS_RESOLUTION(cols, osr); in elants_i2c_query_ts_info_ekth()
580 ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y); in elants_i2c_query_ts_info_ekth()
581 ts->phy_x = phy_x; in elants_i2c_query_ts_info_ekth()
582 ts->phy_y = phy_y; in elants_i2c_query_ts_info_ekth()
603 static int elants_i2c_initialize(struct elants_data *ts) in elants_i2c_initialize() argument
605 struct i2c_client *client = ts->client; in elants_i2c_initialize()
634 ts->iap_mode = ELAN_IAP_OPERATIONAL; in elants_i2c_initialize()
652 error2 = elants_i2c_query_hw_version(ts); in elants_i2c_initialize()
654 error2 = elants_i2c_query_bc_version(ts); in elants_i2c_initialize()
659 error = elants_i2c_query_fw_version(ts); in elants_i2c_initialize()
661 error = elants_i2c_query_test_version(ts); in elants_i2c_initialize()
663 switch (ts->chip_id) { in elants_i2c_initialize()
666 error = elants_i2c_query_ts_info_ekth(ts); in elants_i2c_initialize()
670 error = elants_i2c_query_ts_info_ektf(ts); in elants_i2c_initialize()
677 ts->iap_mode = ELAN_IAP_RECOVERY; in elants_i2c_initialize()
721 static int elants_i2c_validate_remark_id(struct elants_data *ts, in elants_i2c_validate_remark_id() argument
724 struct i2c_client *client = ts->client; in elants_i2c_validate_remark_id()
752 static bool elants_i2c_should_check_remark_id(struct elants_data *ts) in elants_i2c_should_check_remark_id() argument
754 struct i2c_client *client = ts->client; in elants_i2c_should_check_remark_id()
755 const u8 bootcode_version = ts->iap_version; in elants_i2c_should_check_remark_id()
787 struct elants_data *ts = i2c_get_clientdata(client); in elants_i2c_do_update_firmware() local
796 bool check_remark_id = elants_i2c_should_check_remark_id(ts); in elants_i2c_do_update_firmware()
803 error = elants_i2c_validate_remark_id(ts, fw); in elants_i2c_do_update_firmware()
828 error = elants_i2c_validate_remark_id(ts, fw); in elants_i2c_do_update_firmware()
906 static int elants_i2c_fw_update(struct elants_data *ts) in elants_i2c_fw_update() argument
908 struct i2c_client *client = ts->client; in elants_i2c_fw_update()
913 fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%04x.bin", ts->hw_version); in elants_i2c_fw_update()
936 ts->iap_mode == ELAN_IAP_RECOVERY); in elants_i2c_fw_update()
939 ts->iap_mode = ELAN_IAP_RECOVERY; in elants_i2c_fw_update()
943 error = elants_i2c_initialize(ts); in elants_i2c_fw_update()
948 ts->iap_mode = ELAN_IAP_RECOVERY; in elants_i2c_fw_update()
952 ts->iap_mode = ELAN_IAP_OPERATIONAL; in elants_i2c_fw_update()
955 ts->state = ELAN_STATE_NORMAL; in elants_i2c_fw_update()
960 elants_i2c_calibrate(ts); in elants_i2c_fw_update()
970 static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf, in elants_i2c_mt_event() argument
973 struct input_dev *input = ts->input; in elants_i2c_mt_event()
983 dev_dbg(&ts->client->dev, in elants_i2c_mt_event()
1006 ts->chip_id == EKTF3624) { in elants_i2c_mt_event()
1017 dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n", in elants_i2c_mt_event()
1022 touchscreen_report_pos(input, &ts->prop, x, y, true); in elants_i2c_mt_event()
1047 static void elants_i2c_event(struct elants_data *ts, u8 *buf, in elants_i2c_event() argument
1053 dev_warn(&ts->client->dev, in elants_i2c_event()
1058 dev_warn(&ts->client->dev, in elants_i2c_event()
1062 elants_i2c_mt_event(ts, buf, packet_size); in elants_i2c_event()
1068 struct elants_data *ts = _dev; in elants_i2c_irq() local
1069 struct i2c_client *client = ts->client; in elants_i2c_irq()
1074 len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf)); in elants_i2c_irq()
1082 __func__, HEADER_SIZE, ts->buf); in elants_i2c_irq()
1084 switch (ts->state) { in elants_i2c_irq()
1086 if (ts->buf[FW_HDR_TYPE] == CMD_HEADER_REK) { in elants_i2c_irq()
1087 memcpy(ts->cmd_resp, ts->buf, sizeof(ts->cmd_resp)); in elants_i2c_irq()
1088 complete(&ts->cmd_done); in elants_i2c_irq()
1089 ts->state = ELAN_STATE_NORMAL; in elants_i2c_irq()
1094 if (ts->buf[FW_HDR_TYPE] != QUEUE_HEADER_NORMAL) in elants_i2c_irq()
1097 ts->state = ELAN_STATE_NORMAL; in elants_i2c_irq()
1102 switch (ts->buf[FW_HDR_TYPE]) { in elants_i2c_irq()
1108 if (memcmp(ts->buf, wait_packet, sizeof(wait_packet))) { in elants_i2c_irq()
1111 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1113 ts->state = ELAN_WAIT_QUEUE_HEADER; in elants_i2c_irq()
1119 elants_i2c_event(ts, &ts->buf[HEADER_SIZE], in elants_i2c_irq()
1120 ts->buf[FW_HDR_LENGTH]); in elants_i2c_irq()
1132 if (ts->chip_id != EKTF3624) in elants_i2c_irq()
1138 report_count = ts->buf[FW_HDR_COUNT]; in elants_i2c_irq()
1142 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1146 report_len = ts->buf[FW_HDR_LENGTH] / report_count; in elants_i2c_irq()
1149 ts->chip_id == EKTF3624) { in elants_i2c_irq()
1155 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1160 u8 *buf = ts->buf + HEADER_SIZE + in elants_i2c_irq()
1162 elants_i2c_event(ts, buf, report_len); in elants_i2c_irq()
1168 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1186 struct elants_data *ts = i2c_get_clientdata(client); in calibrate_store() local
1189 error = mutex_lock_interruptible(&ts->sysfs_mutex); in calibrate_store()
1193 error = elants_i2c_calibrate(ts); in calibrate_store()
1195 mutex_unlock(&ts->sysfs_mutex); in calibrate_store()
1204 struct elants_data *ts = i2c_get_clientdata(client); in write_update_fw() local
1207 error = mutex_lock_interruptible(&ts->sysfs_mutex); in write_update_fw()
1211 error = elants_i2c_fw_update(ts); in write_update_fw()
1214 mutex_unlock(&ts->sysfs_mutex); in write_update_fw()
1222 struct elants_data *ts = i2c_get_clientdata(client); in show_iap_mode() local
1225 ts->iap_mode == ELAN_IAP_OPERATIONAL ? in show_iap_mode()
1277 struct elants_data *ts = i2c_get_clientdata(client); in elants_version_attribute_show() local
1280 u8 *field = (u8 *)((char *)ts + attr->field_offset); in elants_version_attribute_show()
1321 static int elants_i2c_power_on(struct elants_data *ts) in elants_i2c_power_on() argument
1329 if (IS_ERR_OR_NULL(ts->reset_gpio)) in elants_i2c_power_on()
1332 gpiod_set_value_cansleep(ts->reset_gpio, 1); in elants_i2c_power_on()
1334 error = regulator_enable(ts->vcc33); in elants_i2c_power_on()
1336 dev_err(&ts->client->dev, in elants_i2c_power_on()
1342 error = regulator_enable(ts->vccio); in elants_i2c_power_on()
1344 dev_err(&ts->client->dev, in elants_i2c_power_on()
1347 regulator_disable(ts->vcc33); in elants_i2c_power_on()
1358 gpiod_set_value_cansleep(ts->reset_gpio, 0); in elants_i2c_power_on()
1369 struct elants_data *ts = _data; in elants_i2c_power_off() local
1371 if (!IS_ERR_OR_NULL(ts->reset_gpio)) { in elants_i2c_power_off()
1376 gpiod_set_value_cansleep(ts->reset_gpio, 1); in elants_i2c_power_off()
1377 regulator_disable(ts->vccio); in elants_i2c_power_off()
1378 regulator_disable(ts->vcc33); in elants_i2c_power_off()
1419 struct elants_data *ts; in elants_i2c_probe() local
1434 ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL); in elants_i2c_probe()
1435 if (!ts) in elants_i2c_probe()
1438 mutex_init(&ts->sysfs_mutex); in elants_i2c_probe()
1439 init_completion(&ts->cmd_done); in elants_i2c_probe()
1441 ts->client = client; in elants_i2c_probe()
1442 ts->chip_id = (enum elants_chip_id)(uintptr_t)device_get_match_data(&client->dev); in elants_i2c_probe()
1443 i2c_set_clientdata(client, ts); in elants_i2c_probe()
1445 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33"); in elants_i2c_probe()
1446 if (IS_ERR(ts->vcc33)) { in elants_i2c_probe()
1447 error = PTR_ERR(ts->vcc33); in elants_i2c_probe()
1455 ts->vccio = devm_regulator_get(&client->dev, "vccio"); in elants_i2c_probe()
1456 if (IS_ERR(ts->vccio)) { in elants_i2c_probe()
1457 error = PTR_ERR(ts->vccio); in elants_i2c_probe()
1465 ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW); in elants_i2c_probe()
1466 if (IS_ERR(ts->reset_gpio)) { in elants_i2c_probe()
1467 error = PTR_ERR(ts->reset_gpio); in elants_i2c_probe()
1479 ts->keep_power_in_suspend = true; in elants_i2c_probe()
1482 error = elants_i2c_power_on(ts); in elants_i2c_probe()
1487 elants_i2c_power_off, ts); in elants_i2c_probe()
1501 error = elants_i2c_initialize(ts); in elants_i2c_probe()
1507 ts->input = devm_input_allocate_device(&client->dev); in elants_i2c_probe()
1508 if (!ts->input) { in elants_i2c_probe()
1513 ts->input->name = "Elan Touchscreen"; in elants_i2c_probe()
1514 ts->input->id.bustype = BUS_I2C; in elants_i2c_probe()
1518 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0); in elants_i2c_probe()
1519 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); in elants_i2c_probe()
1520 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in elants_i2c_probe()
1521 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in elants_i2c_probe()
1522 input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE, in elants_i2c_probe()
1525 touchscreen_parse_properties(ts->input, true, &ts->prop); in elants_i2c_probe()
1527 if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) { in elants_i2c_probe()
1529 ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x); in elants_i2c_probe()
1530 ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y); in elants_i2c_probe()
1533 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); in elants_i2c_probe()
1534 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); in elants_i2c_probe()
1535 input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res); in elants_i2c_probe()
1537 error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM, in elants_i2c_probe()
1545 error = input_register_device(ts->input); in elants_i2c_probe()
1564 client->name, ts); in elants_i2c_probe()
1590 struct elants_data *ts = i2c_get_clientdata(client); in elants_i2c_suspend() local
1598 if (ts->iap_mode != ELAN_IAP_OPERATIONAL) in elants_i2c_suspend()
1608 ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); in elants_i2c_suspend()
1609 } else if (ts->keep_power_in_suspend) { in elants_i2c_suspend()
1620 elants_i2c_power_off(ts); in elants_i2c_suspend()
1629 struct elants_data *ts = i2c_get_clientdata(client); in elants_i2c_resume() local
1637 if (ts->wake_irq_enabled) in elants_i2c_resume()
1640 } else if (ts->keep_power_in_suspend) { in elants_i2c_resume()
1651 elants_i2c_power_on(ts); in elants_i2c_resume()
1652 elants_i2c_initialize(ts); in elants_i2c_resume()
1655 ts->state = ELAN_STATE_NORMAL; in elants_i2c_resume()