Lines Matching refs:ts

135 static int zforce_command(struct zforce_ts *ts, u8 cmd)  in zforce_command()  argument
137 struct i2c_client *client = ts->client; in zforce_command()
147 mutex_lock(&ts->access_mutex); in zforce_command()
149 mutex_unlock(&ts->access_mutex); in zforce_command()
158 static void zforce_reset_assert(struct zforce_ts *ts) in zforce_reset_assert() argument
160 gpiod_set_value_cansleep(ts->gpio_rst, 1); in zforce_reset_assert()
163 static void zforce_reset_deassert(struct zforce_ts *ts) in zforce_reset_deassert() argument
165 gpiod_set_value_cansleep(ts->gpio_rst, 0); in zforce_reset_deassert()
168 static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len) in zforce_send_wait() argument
170 struct i2c_client *client = ts->client; in zforce_send_wait()
173 ret = mutex_trylock(&ts->command_mutex); in zforce_send_wait()
182 ts->command_waiting = buf[2]; in zforce_send_wait()
184 mutex_lock(&ts->access_mutex); in zforce_send_wait()
186 mutex_unlock(&ts->access_mutex); in zforce_send_wait()
194 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) { in zforce_send_wait()
199 ret = ts->command_result; in zforce_send_wait()
202 mutex_unlock(&ts->command_mutex); in zforce_send_wait()
206 static int zforce_command_wait(struct zforce_ts *ts, u8 cmd) in zforce_command_wait() argument
208 struct i2c_client *client = ts->client; in zforce_command_wait()
218 ret = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_command_wait()
227 static int zforce_resolution(struct zforce_ts *ts, u16 x, u16 y) in zforce_resolution() argument
229 struct i2c_client *client = ts->client; in zforce_resolution()
236 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_resolution()
239 static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger, in zforce_scan_frequency() argument
242 struct i2c_client *client = ts->client; in zforce_scan_frequency()
252 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_scan_frequency()
255 static int zforce_setconfig(struct zforce_ts *ts, char b1) in zforce_setconfig() argument
257 struct i2c_client *client = ts->client; in zforce_setconfig()
263 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_setconfig()
266 static int zforce_start(struct zforce_ts *ts) in zforce_start() argument
268 struct i2c_client *client = ts->client; in zforce_start()
269 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_start()
274 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_start()
280 ret = zforce_resolution(ts, pdata->x_max, pdata->y_max); in zforce_start()
286 ret = zforce_scan_frequency(ts, 10, 50, 50); in zforce_start()
293 ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); in zforce_start()
300 ret = zforce_command(ts, COMMAND_DATAREQUEST); in zforce_start()
315 zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_start()
319 static int zforce_stop(struct zforce_ts *ts) in zforce_stop() argument
321 struct i2c_client *client = ts->client; in zforce_stop()
327 ret = zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_stop()
337 static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) in zforce_touch_event() argument
339 struct i2c_client *client = ts->client; in zforce_touch_event()
340 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_touch_event()
387 input_mt_slot(ts->input, point.id - 1); in zforce_touch_event()
389 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, in zforce_touch_event()
393 input_report_abs(ts->input, ABS_MT_POSITION_X, in zforce_touch_event()
395 input_report_abs(ts->input, ABS_MT_POSITION_Y, in zforce_touch_event()
397 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in zforce_touch_event()
399 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in zforce_touch_event()
401 input_report_abs(ts->input, ABS_MT_ORIENTATION, in zforce_touch_event()
407 input_mt_sync_frame(ts->input); in zforce_touch_event()
409 input_mt_report_finger_count(ts->input, num); in zforce_touch_event()
411 input_sync(ts->input); in zforce_touch_event()
416 static int zforce_read_packet(struct zforce_ts *ts, u8 *buf) in zforce_read_packet() argument
418 struct i2c_client *client = ts->client; in zforce_read_packet()
421 mutex_lock(&ts->access_mutex); in zforce_read_packet()
454 mutex_unlock(&ts->access_mutex); in zforce_read_packet()
458 static void zforce_complete(struct zforce_ts *ts, int cmd, int result) in zforce_complete() argument
460 struct i2c_client *client = ts->client; in zforce_complete()
462 if (ts->command_waiting == cmd) { in zforce_complete()
464 ts->command_result = result; in zforce_complete()
465 complete(&ts->command_done); in zforce_complete()
473 struct zforce_ts *ts = dev_id; in zforce_irq() local
474 struct i2c_client *client = ts->client; in zforce_irq()
476 if (ts->suspended && device_may_wakeup(&client->dev)) in zforce_irq()
484 struct zforce_ts *ts = dev_id; in zforce_irq_thread() local
485 struct i2c_client *client = ts->client; in zforce_irq_thread()
494 if (ts->suspended) { in zforce_irq_thread()
502 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
515 ret = zforce_read_packet(ts, payload_buffer); in zforce_irq_thread()
530 if (ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
532 zforce_touch_event(ts, &payload[RESPONSE_DATA]); in zforce_irq_thread()
536 ts->boot_complete = payload[RESPONSE_DATA]; in zforce_irq_thread()
537 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
545 zforce_complete(ts, payload[RESPONSE_ID], in zforce_irq_thread()
554 ts->version_major = (payload[RESPONSE_DATA + 1] << 8) | in zforce_irq_thread()
556 ts->version_minor = (payload[RESPONSE_DATA + 3] << 8) | in zforce_irq_thread()
558 ts->version_build = (payload[RESPONSE_DATA + 5] << 8) | in zforce_irq_thread()
560 ts->version_rev = (payload[RESPONSE_DATA + 7] << 8) | in zforce_irq_thread()
562 dev_dbg(&ts->client->dev, in zforce_irq_thread()
564 ts->version_major, ts->version_minor, in zforce_irq_thread()
565 ts->version_build, ts->version_rev); in zforce_irq_thread()
567 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
571 dev_err(&ts->client->dev, "invalid command: 0x%x\n", in zforce_irq_thread()
576 dev_err(&ts->client->dev, in zforce_irq_thread()
581 } while (gpiod_get_value_cansleep(ts->gpio_int)); in zforce_irq_thread()
583 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
593 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_open() local
595 return zforce_start(ts); in zforce_input_open()
600 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_close() local
601 struct i2c_client *client = ts->client; in zforce_input_close()
604 ret = zforce_stop(ts); in zforce_input_close()
614 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_suspend() local
615 struct input_dev *input = ts->input; in zforce_suspend()
619 ts->suspending = true; in zforce_suspend()
630 ret = zforce_start(ts); in zforce_suspend()
640 ret = zforce_stop(ts); in zforce_suspend()
647 ts->suspended = true; in zforce_suspend()
650 ts->suspending = false; in zforce_suspend()
659 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_resume() local
660 struct input_dev *input = ts->input; in zforce_resume()
665 ts->suspended = false; in zforce_resume()
674 ret = zforce_stop(ts); in zforce_resume()
683 ret = zforce_start(ts); in zforce_resume()
698 struct zforce_ts *ts = data; in zforce_reset() local
700 zforce_reset_assert(ts); in zforce_reset()
704 if (!IS_ERR(ts->reg_vdd)) in zforce_reset()
705 regulator_disable(ts->reg_vdd); in zforce_reset()
738 struct zforce_ts *ts; in zforce_probe() local
748 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL); in zforce_probe()
749 if (!ts) in zforce_probe()
752 ts->gpio_rst = devm_gpiod_get_optional(&client->dev, "reset", in zforce_probe()
754 if (IS_ERR(ts->gpio_rst)) { in zforce_probe()
755 ret = PTR_ERR(ts->gpio_rst); in zforce_probe()
761 if (ts->gpio_rst) { in zforce_probe()
762 ts->gpio_int = devm_gpiod_get_optional(&client->dev, "irq", in zforce_probe()
764 if (IS_ERR(ts->gpio_int)) { in zforce_probe()
765 ret = PTR_ERR(ts->gpio_int); in zforce_probe()
777 ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, in zforce_probe()
779 if (IS_ERR(ts->gpio_int)) { in zforce_probe()
780 ret = PTR_ERR(ts->gpio_int); in zforce_probe()
787 ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, in zforce_probe()
789 if (IS_ERR(ts->gpio_rst)) { in zforce_probe()
790 ret = PTR_ERR(ts->gpio_rst); in zforce_probe()
797 ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); in zforce_probe()
798 if (IS_ERR(ts->reg_vdd)) { in zforce_probe()
799 ret = PTR_ERR(ts->reg_vdd); in zforce_probe()
803 ret = regulator_enable(ts->reg_vdd); in zforce_probe()
814 ret = devm_add_action(&client->dev, zforce_reset, ts); in zforce_probe()
820 if (!IS_ERR(ts->reg_vdd)) in zforce_probe()
821 regulator_disable(ts->reg_vdd); in zforce_probe()
826 snprintf(ts->phys, sizeof(ts->phys), in zforce_probe()
835 mutex_init(&ts->access_mutex); in zforce_probe()
836 mutex_init(&ts->command_mutex); in zforce_probe()
838 ts->pdata = pdata; in zforce_probe()
839 ts->client = client; in zforce_probe()
840 ts->input = input_dev; in zforce_probe()
843 input_dev->phys = ts->phys; in zforce_probe()
866 input_set_drvdata(ts->input, ts); in zforce_probe()
868 init_completion(&ts->command_done); in zforce_probe()
880 input_dev->name, ts); in zforce_probe()
886 i2c_set_clientdata(client, ts); in zforce_probe()
889 zforce_reset_deassert(ts); in zforce_probe()
891 ts->command_waiting = NOTIFICATION_BOOTCOMPLETE; in zforce_probe()
892 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) in zforce_probe()
896 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_probe()
903 ret = zforce_command_wait(ts, COMMAND_STATUS); in zforce_probe()
906 zforce_stop(ts); in zforce_probe()
911 ret = zforce_stop(ts); in zforce_probe()