• Home
  • Raw
  • Download

Lines Matching refs:ts

282 static int elants_i2c_calibrate(struct elants_data *ts)  in elants_i2c_calibrate()  argument
284 struct i2c_client *client = ts->client; in elants_i2c_calibrate()
292 ts->state = ELAN_WAIT_RECALIBRATION; in elants_i2c_calibrate()
293 reinit_completion(&ts->cmd_done); in elants_i2c_calibrate()
300 ret = wait_for_completion_interruptible_timeout(&ts->cmd_done, in elants_i2c_calibrate()
303 ts->state = ELAN_STATE_NORMAL; in elants_i2c_calibrate()
313 if (memcmp(rek_resp, ts->cmd_resp, sizeof(rek_resp))) { in elants_i2c_calibrate()
316 (int)sizeof(ts->cmd_resp), ts->cmd_resp); in elants_i2c_calibrate()
349 static int elants_i2c_query_hw_version(struct elants_data *ts) in elants_i2c_query_hw_version() argument
351 struct i2c_client *client = ts->client; in elants_i2c_query_hw_version()
364 ts->hw_version = elants_i2c_parse_version(resp); in elants_i2c_query_hw_version()
365 if (ts->hw_version != 0xffff) in elants_i2c_query_hw_version()
369 dev_err(&client->dev, "Invalid fw id: %#04x\n", ts->hw_version); in elants_i2c_query_hw_version()
374 static int elants_i2c_query_fw_version(struct elants_data *ts) in elants_i2c_query_fw_version() argument
376 struct i2c_client *client = ts->client; in elants_i2c_query_fw_version()
389 ts->fw_version = elants_i2c_parse_version(resp); in elants_i2c_query_fw_version()
390 if (ts->fw_version != 0x0000 && ts->fw_version != 0xffff) in elants_i2c_query_fw_version()
397 dev_err(&client->dev, "Invalid fw ver: %#04x\n", ts->fw_version); in elants_i2c_query_fw_version()
402 static int elants_i2c_query_test_version(struct elants_data *ts) in elants_i2c_query_test_version() argument
404 struct i2c_client *client = ts->client; in elants_i2c_query_test_version()
419 ts->test_version = version >> 8; in elants_i2c_query_test_version()
420 ts->solution_version = version & 0xff; in elants_i2c_query_test_version()
425 static int elants_i2c_query_bc_version(struct elants_data *ts) in elants_i2c_query_bc_version() argument
427 struct i2c_client *client = ts->client; in elants_i2c_query_bc_version()
440 ts->bc_version = version >> 8; in elants_i2c_query_bc_version()
441 ts->iap_version = version & 0xff; in elants_i2c_query_bc_version()
446 static int elants_i2c_query_ts_info(struct elants_data *ts) in elants_i2c_query_ts_info() argument
448 struct i2c_client *client = ts->client; in elants_i2c_query_ts_info()
478 ts->major_res = resp[16]; in elants_i2c_query_ts_info()
517 ts->x_max = ELAN_TS_RESOLUTION(rows, osr); in elants_i2c_query_ts_info()
518 ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x); in elants_i2c_query_ts_info()
519 ts->y_max = ELAN_TS_RESOLUTION(cols, osr); in elants_i2c_query_ts_info()
520 ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y); in elants_i2c_query_ts_info()
541 static int elants_i2c_initialize(struct elants_data *ts) in elants_i2c_initialize() argument
543 struct i2c_client *client = ts->client; in elants_i2c_initialize()
572 ts->iap_mode = ELAN_IAP_OPERATIONAL; in elants_i2c_initialize()
590 error2 = elants_i2c_query_hw_version(ts); in elants_i2c_initialize()
592 error2 = elants_i2c_query_bc_version(ts); in elants_i2c_initialize()
597 error = elants_i2c_query_fw_version(ts); in elants_i2c_initialize()
599 error = elants_i2c_query_test_version(ts); in elants_i2c_initialize()
601 error = elants_i2c_query_ts_info(ts); in elants_i2c_initialize()
604 ts->iap_mode = ELAN_IAP_RECOVERY; in elants_i2c_initialize()
648 static int elants_i2c_validate_remark_id(struct elants_data *ts, in elants_i2c_validate_remark_id() argument
651 struct i2c_client *client = ts->client; in elants_i2c_validate_remark_id()
679 static bool elants_i2c_should_check_remark_id(struct elants_data *ts) in elants_i2c_should_check_remark_id() argument
681 struct i2c_client *client = ts->client; in elants_i2c_should_check_remark_id()
682 const u8 bootcode_version = ts->iap_version; in elants_i2c_should_check_remark_id()
714 struct elants_data *ts = i2c_get_clientdata(client); in elants_i2c_do_update_firmware() local
723 bool check_remark_id = elants_i2c_should_check_remark_id(ts); in elants_i2c_do_update_firmware()
730 error = elants_i2c_validate_remark_id(ts, fw); in elants_i2c_do_update_firmware()
755 error = elants_i2c_validate_remark_id(ts, fw); in elants_i2c_do_update_firmware()
833 static int elants_i2c_fw_update(struct elants_data *ts) in elants_i2c_fw_update() argument
835 struct i2c_client *client = ts->client; in elants_i2c_fw_update()
840 fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%04x.bin", ts->hw_version); in elants_i2c_fw_update()
863 ts->iap_mode == ELAN_IAP_RECOVERY); in elants_i2c_fw_update()
866 ts->iap_mode = ELAN_IAP_RECOVERY; in elants_i2c_fw_update()
870 error = elants_i2c_initialize(ts); in elants_i2c_fw_update()
875 ts->iap_mode = ELAN_IAP_RECOVERY; in elants_i2c_fw_update()
879 ts->iap_mode = ELAN_IAP_OPERATIONAL; in elants_i2c_fw_update()
882 ts->state = ELAN_STATE_NORMAL; in elants_i2c_fw_update()
887 elants_i2c_calibrate(ts); in elants_i2c_fw_update()
897 static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) in elants_i2c_mt_event() argument
899 struct input_dev *input = ts->input; in elants_i2c_mt_event()
909 dev_dbg(&ts->client->dev, in elants_i2c_mt_event()
927 dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n", in elants_i2c_mt_event()
932 touchscreen_report_pos(input, &ts->prop, x, y, true); in elants_i2c_mt_event()
957 static void elants_i2c_event(struct elants_data *ts, u8 *buf) in elants_i2c_event() argument
962 dev_warn(&ts->client->dev, in elants_i2c_event()
967 dev_warn(&ts->client->dev, in elants_i2c_event()
971 elants_i2c_mt_event(ts, buf); in elants_i2c_event()
977 struct elants_data *ts = _dev; in elants_i2c_irq() local
978 struct i2c_client *client = ts->client; in elants_i2c_irq()
983 len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf)); in elants_i2c_irq()
991 __func__, HEADER_SIZE, ts->buf); in elants_i2c_irq()
993 switch (ts->state) { in elants_i2c_irq()
995 if (ts->buf[FW_HDR_TYPE] == CMD_HEADER_REK) { in elants_i2c_irq()
996 memcpy(ts->cmd_resp, ts->buf, sizeof(ts->cmd_resp)); in elants_i2c_irq()
997 complete(&ts->cmd_done); in elants_i2c_irq()
998 ts->state = ELAN_STATE_NORMAL; in elants_i2c_irq()
1003 if (ts->buf[FW_HDR_TYPE] != QUEUE_HEADER_NORMAL) in elants_i2c_irq()
1006 ts->state = ELAN_STATE_NORMAL; in elants_i2c_irq()
1011 switch (ts->buf[FW_HDR_TYPE]) { in elants_i2c_irq()
1018 if (memcmp(ts->buf, wait_packet, sizeof(wait_packet))) { in elants_i2c_irq()
1021 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1023 ts->state = ELAN_WAIT_QUEUE_HEADER; in elants_i2c_irq()
1029 elants_i2c_event(ts, &ts->buf[HEADER_SIZE]); in elants_i2c_irq()
1033 report_count = ts->buf[FW_HDR_COUNT]; in elants_i2c_irq()
1037 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1041 report_len = ts->buf[FW_HDR_LENGTH] / report_count; in elants_i2c_irq()
1045 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1050 u8 *buf = ts->buf + HEADER_SIZE + in elants_i2c_irq()
1052 elants_i2c_event(ts, buf); in elants_i2c_irq()
1058 HEADER_SIZE, ts->buf); in elants_i2c_irq()
1076 struct elants_data *ts = i2c_get_clientdata(client); in calibrate_store() local
1079 error = mutex_lock_interruptible(&ts->sysfs_mutex); in calibrate_store()
1083 error = elants_i2c_calibrate(ts); in calibrate_store()
1085 mutex_unlock(&ts->sysfs_mutex); in calibrate_store()
1094 struct elants_data *ts = i2c_get_clientdata(client); in write_update_fw() local
1097 error = mutex_lock_interruptible(&ts->sysfs_mutex); in write_update_fw()
1101 error = elants_i2c_fw_update(ts); in write_update_fw()
1104 mutex_unlock(&ts->sysfs_mutex); in write_update_fw()
1112 struct elants_data *ts = i2c_get_clientdata(client); in show_iap_mode() local
1115 ts->iap_mode == ELAN_IAP_OPERATIONAL ? in show_iap_mode()
1167 struct elants_data *ts = i2c_get_clientdata(client); in elants_version_attribute_show() local
1170 u8 *field = (u8 *)((char *)ts + attr->field_offset); in elants_version_attribute_show()
1211 static int elants_i2c_power_on(struct elants_data *ts) in elants_i2c_power_on() argument
1219 if (IS_ERR_OR_NULL(ts->reset_gpio)) in elants_i2c_power_on()
1222 gpiod_set_value_cansleep(ts->reset_gpio, 1); in elants_i2c_power_on()
1224 error = regulator_enable(ts->vcc33); in elants_i2c_power_on()
1226 dev_err(&ts->client->dev, in elants_i2c_power_on()
1232 error = regulator_enable(ts->vccio); in elants_i2c_power_on()
1234 dev_err(&ts->client->dev, in elants_i2c_power_on()
1237 regulator_disable(ts->vcc33); in elants_i2c_power_on()
1248 gpiod_set_value_cansleep(ts->reset_gpio, 0); in elants_i2c_power_on()
1259 struct elants_data *ts = _data; in elants_i2c_power_off() local
1261 if (!IS_ERR_OR_NULL(ts->reset_gpio)) { in elants_i2c_power_off()
1266 gpiod_set_value_cansleep(ts->reset_gpio, 1); in elants_i2c_power_off()
1267 regulator_disable(ts->vccio); in elants_i2c_power_off()
1268 regulator_disable(ts->vcc33); in elants_i2c_power_off()
1310 struct elants_data *ts; in elants_i2c_probe() local
1325 ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL); in elants_i2c_probe()
1326 if (!ts) in elants_i2c_probe()
1329 mutex_init(&ts->sysfs_mutex); in elants_i2c_probe()
1330 init_completion(&ts->cmd_done); in elants_i2c_probe()
1332 ts->client = client; in elants_i2c_probe()
1333 i2c_set_clientdata(client, ts); in elants_i2c_probe()
1335 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33"); in elants_i2c_probe()
1336 if (IS_ERR(ts->vcc33)) { in elants_i2c_probe()
1337 error = PTR_ERR(ts->vcc33); in elants_i2c_probe()
1345 ts->vccio = devm_regulator_get(&client->dev, "vccio"); in elants_i2c_probe()
1346 if (IS_ERR(ts->vccio)) { in elants_i2c_probe()
1347 error = PTR_ERR(ts->vccio); in elants_i2c_probe()
1355 ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW); in elants_i2c_probe()
1356 if (IS_ERR(ts->reset_gpio)) { in elants_i2c_probe()
1357 error = PTR_ERR(ts->reset_gpio); in elants_i2c_probe()
1369 ts->keep_power_in_suspend = true; in elants_i2c_probe()
1372 error = elants_i2c_power_on(ts); in elants_i2c_probe()
1376 error = devm_add_action(&client->dev, elants_i2c_power_off, ts); in elants_i2c_probe()
1380 elants_i2c_power_off(ts); in elants_i2c_probe()
1391 error = elants_i2c_initialize(ts); in elants_i2c_probe()
1397 ts->input = devm_input_allocate_device(&client->dev); in elants_i2c_probe()
1398 if (!ts->input) { in elants_i2c_probe()
1403 ts->input->name = "Elan Touchscreen"; in elants_i2c_probe()
1404 ts->input->id.bustype = BUS_I2C; in elants_i2c_probe()
1408 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0); in elants_i2c_probe()
1409 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); in elants_i2c_probe()
1410 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in elants_i2c_probe()
1411 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in elants_i2c_probe()
1412 input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE, in elants_i2c_probe()
1414 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); in elants_i2c_probe()
1415 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); in elants_i2c_probe()
1416 if (ts->major_res > 0) in elants_i2c_probe()
1417 input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res); in elants_i2c_probe()
1419 touchscreen_parse_properties(ts->input, true, &ts->prop); in elants_i2c_probe()
1421 error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM, in elants_i2c_probe()
1429 error = input_register_device(ts->input); in elants_i2c_probe()
1448 client->name, ts); in elants_i2c_probe()
1474 struct elants_data *ts = i2c_get_clientdata(client); in elants_i2c_suspend() local
1480 if (ts->iap_mode != ELAN_IAP_OPERATIONAL) in elants_i2c_suspend()
1490 ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); in elants_i2c_suspend()
1491 } else if (ts->keep_power_in_suspend) { in elants_i2c_suspend()
1502 elants_i2c_power_off(ts); in elants_i2c_suspend()
1511 struct elants_data *ts = i2c_get_clientdata(client); in elants_i2c_resume() local
1517 if (ts->wake_irq_enabled) in elants_i2c_resume()
1520 } else if (ts->keep_power_in_suspend) { in elants_i2c_resume()
1531 elants_i2c_power_on(ts); in elants_i2c_resume()
1532 elants_i2c_initialize(ts); in elants_i2c_resume()
1535 ts->state = ELAN_STATE_NORMAL; in elants_i2c_resume()