Lines Matching refs:ts

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