Lines Matching full:ts

137 static int zforce_command(struct zforce_ts *ts, u8 cmd)  in zforce_command()  argument
139 struct i2c_client *client = ts->client; in zforce_command()
149 mutex_lock(&ts->access_mutex); in zforce_command()
151 mutex_unlock(&ts->access_mutex); in zforce_command()
160 static void zforce_reset_assert(struct zforce_ts *ts) in zforce_reset_assert() argument
162 gpiod_set_value_cansleep(ts->gpio_rst, 1); in zforce_reset_assert()
165 static void zforce_reset_deassert(struct zforce_ts *ts) in zforce_reset_deassert() argument
167 gpiod_set_value_cansleep(ts->gpio_rst, 0); in zforce_reset_deassert()
170 static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len) in zforce_send_wait() argument
172 struct i2c_client *client = ts->client; in zforce_send_wait()
175 ret = mutex_trylock(&ts->command_mutex); in zforce_send_wait()
184 ts->command_waiting = buf[2]; in zforce_send_wait()
186 mutex_lock(&ts->access_mutex); in zforce_send_wait()
188 mutex_unlock(&ts->access_mutex); in zforce_send_wait()
196 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) { in zforce_send_wait()
201 ret = ts->command_result; in zforce_send_wait()
204 mutex_unlock(&ts->command_mutex); in zforce_send_wait()
208 static int zforce_command_wait(struct zforce_ts *ts, u8 cmd) in zforce_command_wait() argument
210 struct i2c_client *client = ts->client; in zforce_command_wait()
220 ret = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_command_wait()
229 static int zforce_resolution(struct zforce_ts *ts, u16 x, u16 y) in zforce_resolution() argument
231 struct i2c_client *client = ts->client; in zforce_resolution()
238 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_resolution()
241 static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger, in zforce_scan_frequency() argument
244 struct i2c_client *client = ts->client; in zforce_scan_frequency()
254 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_scan_frequency()
257 static int zforce_setconfig(struct zforce_ts *ts, char b1) in zforce_setconfig() argument
259 struct i2c_client *client = ts->client; in zforce_setconfig()
265 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_setconfig()
268 static int zforce_start(struct zforce_ts *ts) in zforce_start() argument
270 struct i2c_client *client = ts->client; in zforce_start()
275 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_start()
281 ret = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y); in zforce_start()
287 ret = zforce_scan_frequency(ts, 10, 50, 50); in zforce_start()
294 ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); in zforce_start()
301 ret = zforce_command(ts, COMMAND_DATAREQUEST); in zforce_start()
316 zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_start()
320 static int zforce_stop(struct zforce_ts *ts) in zforce_stop() argument
322 struct i2c_client *client = ts->client; in zforce_stop()
328 ret = zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_stop()
338 static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) in zforce_touch_event() argument
340 struct i2c_client *client = ts->client; in zforce_touch_event()
358 if (point.coord_x > ts->prop.max_x || in zforce_touch_event()
359 point.coord_y > ts->prop.max_y) { 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 touchscreen_report_pos(ts->input, &ts->prop, in zforce_touch_event()
396 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in zforce_touch_event()
398 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in zforce_touch_event()
400 input_report_abs(ts->input, ABS_MT_ORIENTATION, in zforce_touch_event()
406 input_mt_sync_frame(ts->input); in zforce_touch_event()
408 input_mt_report_finger_count(ts->input, num); in zforce_touch_event()
410 input_sync(ts->input); in zforce_touch_event()
415 static int zforce_read_packet(struct zforce_ts *ts, u8 *buf) in zforce_read_packet() argument
417 struct i2c_client *client = ts->client; in zforce_read_packet()
420 mutex_lock(&ts->access_mutex); in zforce_read_packet()
453 mutex_unlock(&ts->access_mutex); in zforce_read_packet()
457 static void zforce_complete(struct zforce_ts *ts, int cmd, int result) in zforce_complete() argument
459 struct i2c_client *client = ts->client; in zforce_complete()
461 if (ts->command_waiting == cmd) { in zforce_complete()
463 ts->command_result = result; in zforce_complete()
464 complete(&ts->command_done); in zforce_complete()
472 struct zforce_ts *ts = dev_id; in zforce_irq() local
473 struct i2c_client *client = ts->client; in zforce_irq()
475 if (ts->suspended && device_may_wakeup(&client->dev)) in zforce_irq()
483 struct zforce_ts *ts = dev_id; in zforce_irq_thread() local
484 struct i2c_client *client = ts->client; in zforce_irq_thread()
493 if (ts->suspended) { in zforce_irq_thread()
501 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
514 ret = zforce_read_packet(ts, payload_buffer); in zforce_irq_thread()
529 if (ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
531 zforce_touch_event(ts, &payload[RESPONSE_DATA]); in zforce_irq_thread()
535 ts->boot_complete = payload[RESPONSE_DATA]; in zforce_irq_thread()
536 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
544 zforce_complete(ts, payload[RESPONSE_ID], in zforce_irq_thread()
553 ts->version_major = (payload[RESPONSE_DATA + 1] << 8) | in zforce_irq_thread()
555 ts->version_minor = (payload[RESPONSE_DATA + 3] << 8) | in zforce_irq_thread()
557 ts->version_build = (payload[RESPONSE_DATA + 5] << 8) | in zforce_irq_thread()
559 ts->version_rev = (payload[RESPONSE_DATA + 7] << 8) | in zforce_irq_thread()
561 dev_dbg(&ts->client->dev, in zforce_irq_thread()
563 ts->version_major, ts->version_minor, in zforce_irq_thread()
564 ts->version_build, ts->version_rev); in zforce_irq_thread()
566 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
570 dev_err(&ts->client->dev, "invalid command: 0x%x\n", in zforce_irq_thread()
575 dev_err(&ts->client->dev, in zforce_irq_thread()
580 } while (gpiod_get_value_cansleep(ts->gpio_int)); in zforce_irq_thread()
582 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
592 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_open() local
594 return zforce_start(ts); in zforce_input_open()
599 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_close() local
600 struct i2c_client *client = ts->client; in zforce_input_close()
603 ret = zforce_stop(ts); in zforce_input_close()
613 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_suspend() local
614 struct input_dev *input = ts->input; in zforce_suspend()
618 ts->suspending = true; in zforce_suspend()
629 ret = zforce_start(ts); in zforce_suspend()
639 ret = zforce_stop(ts); in zforce_suspend()
646 ts->suspended = true; in zforce_suspend()
649 ts->suspending = false; in zforce_suspend()
658 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_resume() local
659 struct input_dev *input = ts->input; in zforce_resume()
664 ts->suspended = false; in zforce_resume()
673 ret = zforce_stop(ts); in zforce_resume()
682 ret = zforce_start(ts); in zforce_resume()
697 struct zforce_ts *ts = data; in zforce_reset() local
699 zforce_reset_assert(ts); in zforce_reset()
703 if (!IS_ERR(ts->reg_vdd)) in zforce_reset()
704 regulator_disable(ts->reg_vdd); in zforce_reset()
730 struct zforce_ts *ts; in zforce_probe() local
740 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL); in zforce_probe()
741 if (!ts) in zforce_probe()
744 ts->gpio_rst = devm_gpiod_get_optional(&client->dev, "reset", in zforce_probe()
746 if (IS_ERR(ts->gpio_rst)) { in zforce_probe()
747 ret = PTR_ERR(ts->gpio_rst); in zforce_probe()
753 if (ts->gpio_rst) { in zforce_probe()
754 ts->gpio_int = devm_gpiod_get_optional(&client->dev, "irq", in zforce_probe()
756 if (IS_ERR(ts->gpio_int)) { in zforce_probe()
757 ret = PTR_ERR(ts->gpio_int); in zforce_probe()
769 ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, in zforce_probe()
771 if (IS_ERR(ts->gpio_int)) { in zforce_probe()
772 ret = PTR_ERR(ts->gpio_int); in zforce_probe()
779 ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, in zforce_probe()
781 if (IS_ERR(ts->gpio_rst)) { in zforce_probe()
782 ret = PTR_ERR(ts->gpio_rst); in zforce_probe()
789 ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); in zforce_probe()
790 if (IS_ERR(ts->reg_vdd)) { in zforce_probe()
791 ret = PTR_ERR(ts->reg_vdd); in zforce_probe()
795 ret = regulator_enable(ts->reg_vdd); in zforce_probe()
806 ret = devm_add_action(&client->dev, zforce_reset, ts); in zforce_probe()
812 if (!IS_ERR(ts->reg_vdd)) in zforce_probe()
813 regulator_disable(ts->reg_vdd); in zforce_probe()
818 snprintf(ts->phys, sizeof(ts->phys), in zforce_probe()
827 mutex_init(&ts->access_mutex); in zforce_probe()
828 mutex_init(&ts->command_mutex); in zforce_probe()
830 ts->pdata = pdata; in zforce_probe()
831 ts->client = client; in zforce_probe()
832 ts->input = input_dev; in zforce_probe()
835 input_dev->phys = ts->phys; in zforce_probe()
851 touchscreen_parse_properties(input_dev, true, &ts->prop); in zforce_probe()
852 if (ts->prop.max_x == 0 || ts->prop.max_y == 0) { in zforce_probe()
864 input_set_drvdata(ts->input, ts); in zforce_probe()
866 init_completion(&ts->command_done); in zforce_probe()
878 input_dev->name, ts); in zforce_probe()
884 i2c_set_clientdata(client, ts); in zforce_probe()
887 zforce_reset_deassert(ts); in zforce_probe()
889 ts->command_waiting = NOTIFICATION_BOOTCOMPLETE; in zforce_probe()
890 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) in zforce_probe()
894 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_probe()
901 ret = zforce_command_wait(ts, COMMAND_STATUS); in zforce_probe()
904 zforce_stop(ts); in zforce_probe()
909 ret = zforce_stop(ts); in zforce_probe()
926 { "zforce-ts", 0 },
941 .name = "zforce-ts",