Lines Matching refs:ts

298 static int elants_i2c_calibrate(struct elants_data *ts)
300 struct i2c_client *client = ts->client;
308 ts->state = ELAN_WAIT_RECALIBRATION;
309 reinit_completion(&ts->cmd_done);
316 ret = wait_for_completion_interruptible_timeout(&ts->cmd_done,
319 ts->state = ELAN_STATE_NORMAL;
329 if (memcmp(rek_resp, ts->cmd_resp, sizeof(rek_resp))) {
332 (int)sizeof(ts->cmd_resp), ts->cmd_resp);
365 static int elants_i2c_query_hw_version(struct elants_data *ts)
367 struct i2c_client *client = ts->client;
380 ts->hw_version = elants_i2c_parse_version(resp);
381 if (ts->hw_version != 0xffff)
385 dev_err(&client->dev, "Invalid fw id: %#04x\n", ts->hw_version);
390 static int elants_i2c_query_fw_version(struct elants_data *ts)
392 struct i2c_client *client = ts->client;
405 ts->fw_version = elants_i2c_parse_version(resp);
406 if (ts->fw_version != 0x0000 && ts->fw_version != 0xffff)
413 dev_err(&client->dev, "Invalid fw ver: %#04x\n", ts->fw_version);
418 static int elants_i2c_query_test_version(struct elants_data *ts)
420 struct i2c_client *client = ts->client;
435 ts->test_version = version >> 8;
436 ts->solution_version = version & 0xff;
441 static int elants_i2c_query_bc_version(struct elants_data *ts)
443 struct i2c_client *client = ts->client;
456 ts->bc_version = version >> 8;
457 ts->iap_version = version & 0xff;
462 static int elants_i2c_query_ts_info_ektf(struct elants_data *ts)
464 struct i2c_client *client = ts->client;
496 ts->phy_x = phy_x;
497 ts->phy_y = phy_y;
500 ts->x_max = 2240 - 1;
501 ts->y_max = 1408 - 1;
506 static int elants_i2c_query_ts_info_ekth(struct elants_data *ts)
508 struct i2c_client *client = ts->client;
538 ts->major_res = resp[16];
577 ts->x_max = ELAN_TS_RESOLUTION(rows, osr);
578 ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x);
579 ts->y_max = ELAN_TS_RESOLUTION(cols, osr);
580 ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y);
581 ts->phy_x = phy_x;
582 ts->phy_y = phy_y;
603 static int elants_i2c_initialize(struct elants_data *ts)
605 struct i2c_client *client = ts->client;
634 ts->iap_mode = ELAN_IAP_OPERATIONAL;
652 error2 = elants_i2c_query_hw_version(ts);
654 error2 = elants_i2c_query_bc_version(ts);
659 error = elants_i2c_query_fw_version(ts);
661 error = elants_i2c_query_test_version(ts);
663 switch (ts->chip_id) {
666 error = elants_i2c_query_ts_info_ekth(ts);
670 error = elants_i2c_query_ts_info_ektf(ts);
677 ts->iap_mode = ELAN_IAP_RECOVERY;
721 static int elants_i2c_validate_remark_id(struct elants_data *ts,
724 struct i2c_client *client = ts->client;
752 static bool elants_i2c_should_check_remark_id(struct elants_data *ts)
754 struct i2c_client *client = ts->client;
755 const u8 bootcode_version = ts->iap_version;
787 struct elants_data *ts = i2c_get_clientdata(client);
796 bool check_remark_id = elants_i2c_should_check_remark_id(ts);
803 error = elants_i2c_validate_remark_id(ts, fw);
828 error = elants_i2c_validate_remark_id(ts, fw);
906 static int elants_i2c_fw_update(struct elants_data *ts)
908 struct i2c_client *client = ts->client;
913 fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%04x.bin", ts->hw_version);
936 ts->iap_mode == ELAN_IAP_RECOVERY);
939 ts->iap_mode = ELAN_IAP_RECOVERY;
943 error = elants_i2c_initialize(ts);
948 ts->iap_mode = ELAN_IAP_RECOVERY;
952 ts->iap_mode = ELAN_IAP_OPERATIONAL;
955 ts->state = ELAN_STATE_NORMAL;
960 elants_i2c_calibrate(ts);
970 static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf,
973 struct input_dev *input = ts->input;
983 dev_dbg(&ts->client->dev,
1006 ts->chip_id == EKTF3624) {
1017 dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n",
1022 touchscreen_report_pos(input, &ts->prop, x, y, true);
1047 static void elants_i2c_event(struct elants_data *ts, u8 *buf,
1053 dev_warn(&ts->client->dev,
1058 dev_warn(&ts->client->dev,
1062 elants_i2c_mt_event(ts, buf, packet_size);
1068 struct elants_data *ts = _dev;
1069 struct i2c_client *client = ts->client;
1074 len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf));
1082 __func__, HEADER_SIZE, ts->buf);
1084 switch (ts->state) {
1086 if (ts->buf[FW_HDR_TYPE] == CMD_HEADER_REK) {
1087 memcpy(ts->cmd_resp, ts->buf, sizeof(ts->cmd_resp));
1088 complete(&ts->cmd_done);
1089 ts->state = ELAN_STATE_NORMAL;
1094 if (ts->buf[FW_HDR_TYPE] != QUEUE_HEADER_NORMAL)
1097 ts->state = ELAN_STATE_NORMAL;
1102 switch (ts->buf[FW_HDR_TYPE]) {
1108 if (memcmp(ts->buf, wait_packet, sizeof(wait_packet))) {
1111 HEADER_SIZE, ts->buf);
1113 ts->state = ELAN_WAIT_QUEUE_HEADER;
1119 elants_i2c_event(ts, &ts->buf[HEADER_SIZE],
1120 ts->buf[FW_HDR_LENGTH]);
1132 if (ts->chip_id != EKTF3624)
1138 report_count = ts->buf[FW_HDR_COUNT];
1142 HEADER_SIZE, ts->buf);
1146 report_len = ts->buf[FW_HDR_LENGTH] / report_count;
1149 ts->chip_id == EKTF3624) {
1155 HEADER_SIZE, ts->buf);
1160 u8 *buf = ts->buf + HEADER_SIZE +
1162 elants_i2c_event(ts, buf, report_len);
1168 HEADER_SIZE, ts->buf);
1186 struct elants_data *ts = i2c_get_clientdata(client);
1189 error = mutex_lock_interruptible(&ts->sysfs_mutex);
1193 error = elants_i2c_calibrate(ts);
1195 mutex_unlock(&ts->sysfs_mutex);
1204 struct elants_data *ts = i2c_get_clientdata(client);
1207 error = mutex_lock_interruptible(&ts->sysfs_mutex);
1211 error = elants_i2c_fw_update(ts);
1214 mutex_unlock(&ts->sysfs_mutex);
1222 struct elants_data *ts = i2c_get_clientdata(client);
1225 ts->iap_mode == ELAN_IAP_OPERATIONAL ?
1277 struct elants_data *ts = i2c_get_clientdata(client);
1280 u8 *field = (u8 *)((char *)ts + attr->field_offset);
1318 static int elants_i2c_power_on(struct elants_data *ts)
1326 if (IS_ERR_OR_NULL(ts->reset_gpio))
1329 error = regulator_enable(ts->vcc33);
1331 dev_err(&ts->client->dev,
1337 error = regulator_enable(ts->vccio);
1339 dev_err(&ts->client->dev,
1342 regulator_disable(ts->vcc33);
1352 gpiod_set_value_cansleep(ts->reset_gpio, 0);
1361 struct elants_data *ts = _data;
1363 if (!IS_ERR_OR_NULL(ts->reset_gpio)) {
1368 gpiod_set_value_cansleep(ts->reset_gpio, 1);
1369 regulator_disable(ts->vccio);
1370 regulator_disable(ts->vcc33);
1411 struct elants_data *ts;
1426 ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL);
1427 if (!ts)
1430 mutex_init(&ts->sysfs_mutex);
1431 init_completion(&ts->cmd_done);
1433 ts->client = client;
1434 ts->chip_id = (enum elants_chip_id)(uintptr_t)device_get_match_data(&client->dev);
1435 i2c_set_clientdata(client, ts);
1437 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
1438 if (IS_ERR(ts->vcc33))
1439 return dev_err_probe(&client->dev, PTR_ERR(ts->vcc33),
1442 ts->vccio = devm_regulator_get(&client->dev, "vccio");
1443 if (IS_ERR(ts->vccio))
1444 return dev_err_probe(&client->dev, PTR_ERR(ts->vccio),
1447 ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
1448 if (IS_ERR(ts->reset_gpio)) {
1449 error = PTR_ERR(ts->reset_gpio);
1461 ts->keep_power_in_suspend = true;
1464 error = elants_i2c_power_on(ts);
1469 elants_i2c_power_off, ts);
1483 error = elants_i2c_initialize(ts);
1489 ts->input = devm_input_allocate_device(&client->dev);
1490 if (!ts->input) {
1495 ts->input->name = "Elan Touchscreen";
1496 ts->input->id.bustype = BUS_I2C;
1500 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
1501 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
1502 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
1503 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
1504 input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE,
1507 touchscreen_parse_properties(ts->input, true, &ts->prop);
1509 if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) {
1511 ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x);
1512 ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y);
1515 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
1516 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
1517 input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res);
1519 error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
1527 error = input_register_device(ts->input);
1546 client->name, ts);
1558 struct elants_data *ts = i2c_get_clientdata(client);
1566 if (ts->iap_mode != ELAN_IAP_OPERATIONAL)
1577 } else if (ts->keep_power_in_suspend) {
1588 elants_i2c_power_off(ts);
1597 struct elants_data *ts = i2c_get_clientdata(client);
1606 } else if (ts->keep_power_in_suspend) {
1617 elants_i2c_power_on(ts);
1618 elants_i2c_initialize(ts);
1621 ts->state = ELAN_STATE_NORMAL;