Lines Matching refs:ts

143 static int zforce_command(struct zforce_ts *ts, u8 cmd)  in zforce_command()  argument
145 struct i2c_client *client = ts->client; in zforce_command()
155 mutex_lock(&ts->access_mutex); in zforce_command()
157 mutex_unlock(&ts->access_mutex); in zforce_command()
166 static void zforce_reset_assert(struct zforce_ts *ts) in zforce_reset_assert() argument
168 gpiod_set_value_cansleep(ts->gpio_rst, 1); in zforce_reset_assert()
171 static void zforce_reset_deassert(struct zforce_ts *ts) in zforce_reset_deassert() argument
173 gpiod_set_value_cansleep(ts->gpio_rst, 0); in zforce_reset_deassert()
176 static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len) in zforce_send_wait() argument
178 struct i2c_client *client = ts->client; in zforce_send_wait()
181 ret = mutex_trylock(&ts->command_mutex); in zforce_send_wait()
190 ts->command_waiting = buf[2]; in zforce_send_wait()
192 mutex_lock(&ts->access_mutex); in zforce_send_wait()
194 mutex_unlock(&ts->access_mutex); in zforce_send_wait()
202 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) { in zforce_send_wait()
207 ret = ts->command_result; in zforce_send_wait()
210 mutex_unlock(&ts->command_mutex); in zforce_send_wait()
214 static int zforce_command_wait(struct zforce_ts *ts, u8 cmd) in zforce_command_wait() argument
216 struct i2c_client *client = ts->client; in zforce_command_wait()
226 ret = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_command_wait()
235 static int zforce_resolution(struct zforce_ts *ts, u16 x, u16 y) in zforce_resolution() argument
237 struct i2c_client *client = ts->client; in zforce_resolution()
244 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_resolution()
247 static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger, in zforce_scan_frequency() argument
250 struct i2c_client *client = ts->client; in zforce_scan_frequency()
260 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_scan_frequency()
263 static int zforce_setconfig(struct zforce_ts *ts, char b1) in zforce_setconfig() argument
265 struct i2c_client *client = ts->client; in zforce_setconfig()
271 return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf)); in zforce_setconfig()
274 static int zforce_start(struct zforce_ts *ts) in zforce_start() argument
276 struct i2c_client *client = ts->client; in zforce_start()
277 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_start()
282 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_start()
288 ret = zforce_resolution(ts, pdata->x_max, pdata->y_max); in zforce_start()
294 ret = zforce_scan_frequency(ts, 10, 50, 50); in zforce_start()
301 ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH); in zforce_start()
308 ret = zforce_command(ts, COMMAND_DATAREQUEST); in zforce_start()
323 zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_start()
327 static int zforce_stop(struct zforce_ts *ts) in zforce_stop() argument
329 struct i2c_client *client = ts->client; in zforce_stop()
335 ret = zforce_command_wait(ts, COMMAND_DEACTIVATE); in zforce_stop()
345 static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) in zforce_touch_event() argument
347 struct i2c_client *client = ts->client; in zforce_touch_event()
348 const struct zforce_ts_platdata *pdata = ts->pdata; in zforce_touch_event()
395 input_mt_slot(ts->input, point.id - 1); in zforce_touch_event()
397 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, in zforce_touch_event()
401 input_report_abs(ts->input, ABS_MT_POSITION_X, in zforce_touch_event()
403 input_report_abs(ts->input, ABS_MT_POSITION_Y, in zforce_touch_event()
405 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, in zforce_touch_event()
407 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, in zforce_touch_event()
409 input_report_abs(ts->input, ABS_MT_ORIENTATION, in zforce_touch_event()
415 input_mt_sync_frame(ts->input); in zforce_touch_event()
417 input_mt_report_finger_count(ts->input, num); in zforce_touch_event()
419 input_sync(ts->input); in zforce_touch_event()
424 static int zforce_read_packet(struct zforce_ts *ts, u8 *buf) in zforce_read_packet() argument
426 struct i2c_client *client = ts->client; in zforce_read_packet()
429 mutex_lock(&ts->access_mutex); in zforce_read_packet()
462 mutex_unlock(&ts->access_mutex); in zforce_read_packet()
466 static void zforce_complete(struct zforce_ts *ts, int cmd, int result) in zforce_complete() argument
468 struct i2c_client *client = ts->client; in zforce_complete()
470 if (ts->command_waiting == cmd) { in zforce_complete()
472 ts->command_result = result; in zforce_complete()
473 complete(&ts->command_done); in zforce_complete()
481 struct zforce_ts *ts = dev_id; in zforce_irq() local
482 struct i2c_client *client = ts->client; in zforce_irq()
484 if (ts->suspended && device_may_wakeup(&client->dev)) in zforce_irq()
492 struct zforce_ts *ts = dev_id; in zforce_irq_thread() local
493 struct i2c_client *client = ts->client; in zforce_irq_thread()
502 if (ts->suspended) { in zforce_irq_thread()
510 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
523 ret = zforce_read_packet(ts, payload_buffer); in zforce_irq_thread()
538 if (ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
540 zforce_touch_event(ts, &payload[RESPONSE_DATA]); in zforce_irq_thread()
544 ts->boot_complete = payload[RESPONSE_DATA]; in zforce_irq_thread()
545 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
553 zforce_complete(ts, payload[RESPONSE_ID], in zforce_irq_thread()
562 ts->version_major = (payload[RESPONSE_DATA + 1] << 8) | in zforce_irq_thread()
564 ts->version_minor = (payload[RESPONSE_DATA + 3] << 8) | in zforce_irq_thread()
566 ts->version_build = (payload[RESPONSE_DATA + 5] << 8) | in zforce_irq_thread()
568 ts->version_rev = (payload[RESPONSE_DATA + 7] << 8) | in zforce_irq_thread()
570 dev_dbg(&ts->client->dev, in zforce_irq_thread()
572 ts->version_major, ts->version_minor, in zforce_irq_thread()
573 ts->version_build, ts->version_rev); in zforce_irq_thread()
575 zforce_complete(ts, payload[RESPONSE_ID], 0); in zforce_irq_thread()
579 dev_err(&ts->client->dev, "invalid command: 0x%x\n", in zforce_irq_thread()
584 dev_err(&ts->client->dev, in zforce_irq_thread()
589 } while (gpiod_get_value_cansleep(ts->gpio_int)); in zforce_irq_thread()
591 if (!ts->suspending && device_may_wakeup(&client->dev)) in zforce_irq_thread()
601 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_open() local
603 return zforce_start(ts); in zforce_input_open()
608 struct zforce_ts *ts = input_get_drvdata(dev); in zforce_input_close() local
609 struct i2c_client *client = ts->client; in zforce_input_close()
612 ret = zforce_stop(ts); in zforce_input_close()
622 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_suspend() local
623 struct input_dev *input = ts->input; in zforce_suspend()
627 ts->suspending = true; in zforce_suspend()
638 ret = zforce_start(ts); in zforce_suspend()
648 ret = zforce_stop(ts); in zforce_suspend()
655 ts->suspended = true; in zforce_suspend()
658 ts->suspending = false; in zforce_suspend()
667 struct zforce_ts *ts = i2c_get_clientdata(client); in zforce_resume() local
668 struct input_dev *input = ts->input; in zforce_resume()
673 ts->suspended = false; in zforce_resume()
682 ret = zforce_stop(ts); in zforce_resume()
691 ret = zforce_start(ts); in zforce_resume()
706 struct zforce_ts *ts = data; in zforce_reset() local
708 zforce_reset_assert(ts); in zforce_reset()
712 if (!IS_ERR(ts->reg_vdd)) in zforce_reset()
713 regulator_disable(ts->reg_vdd); in zforce_reset()
747 struct zforce_ts *ts; in zforce_probe() local
757 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL); in zforce_probe()
758 if (!ts) in zforce_probe()
761 ts->gpio_rst = devm_gpiod_get_optional(&client->dev, "reset", in zforce_probe()
763 if (IS_ERR(ts->gpio_rst)) { in zforce_probe()
764 ret = PTR_ERR(ts->gpio_rst); in zforce_probe()
770 if (ts->gpio_rst) { in zforce_probe()
771 ts->gpio_int = devm_gpiod_get_optional(&client->dev, "irq", in zforce_probe()
773 if (IS_ERR(ts->gpio_int)) { in zforce_probe()
774 ret = PTR_ERR(ts->gpio_int); in zforce_probe()
786 ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, in zforce_probe()
788 if (IS_ERR(ts->gpio_int)) { in zforce_probe()
789 ret = PTR_ERR(ts->gpio_int); in zforce_probe()
796 ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, in zforce_probe()
798 if (IS_ERR(ts->gpio_rst)) { in zforce_probe()
799 ret = PTR_ERR(ts->gpio_rst); in zforce_probe()
806 ts->reg_vdd = devm_regulator_get_optional(&client->dev, "vdd"); in zforce_probe()
807 if (IS_ERR(ts->reg_vdd)) { in zforce_probe()
808 ret = PTR_ERR(ts->reg_vdd); in zforce_probe()
812 ret = regulator_enable(ts->reg_vdd); in zforce_probe()
823 ret = devm_add_action(&client->dev, zforce_reset, ts); in zforce_probe()
829 if (!IS_ERR(ts->reg_vdd)) in zforce_probe()
830 regulator_disable(ts->reg_vdd); in zforce_probe()
835 snprintf(ts->phys, sizeof(ts->phys), in zforce_probe()
844 mutex_init(&ts->access_mutex); in zforce_probe()
845 mutex_init(&ts->command_mutex); in zforce_probe()
847 ts->pdata = pdata; in zforce_probe()
848 ts->client = client; in zforce_probe()
849 ts->input = input_dev; in zforce_probe()
852 input_dev->phys = ts->phys; in zforce_probe()
875 input_set_drvdata(ts->input, ts); in zforce_probe()
877 init_completion(&ts->command_done); in zforce_probe()
889 input_dev->name, ts); in zforce_probe()
895 i2c_set_clientdata(client, ts); in zforce_probe()
898 zforce_reset_deassert(ts); in zforce_probe()
900 ts->command_waiting = NOTIFICATION_BOOTCOMPLETE; in zforce_probe()
901 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) in zforce_probe()
905 ret = zforce_command_wait(ts, COMMAND_INITIALIZE); in zforce_probe()
912 ret = zforce_command_wait(ts, COMMAND_STATUS); in zforce_probe()
915 zforce_stop(ts); in zforce_probe()
920 ret = zforce_stop(ts); in zforce_probe()