1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2012-2013 MundoReader S.L.
4 * Author: Heiko Stuebner <heiko@sntech.de>
6 * based in parts on Nook zforce driver
8 * Copyright (C) 2010 Barnes & Noble, Inc.
9 * Author: Pieter Truter<ptruter@intrinsyc.com>
12 #include <linux/module.h>
13 #include <linux/hrtimer.h>
14 #include <linux/slab.h>
15 #include <linux/input.h>
16 #include <linux/interrupt.h>
17 #include <linux/i2c.h>
18 #include <linux/delay.h>
19 #include <linux/gpio/consumer.h>
20 #include <linux/device.h>
21 #include <linux/sysfs.h>
22 #include <linux/input/mt.h>
23 #include <linux/input/touchscreen.h>
24 #include <linux/platform_data/zforce_ts.h>
25 #include <linux/regulator/consumer.h>
28 #define WAIT_TIMEOUT msecs_to_jiffies(1000)
30 #define FRAME_START 0xee
31 #define FRAME_MAXSIZE 257
33 /* Offsets of the different parts of the payload the controller sends */
34 #define PAYLOAD_HEADER 0
35 #define PAYLOAD_LENGTH 1
36 #define PAYLOAD_BODY 2
38 /* Response offsets */
40 #define RESPONSE_DATA 1
43 #define COMMAND_DEACTIVATE 0x00
44 #define COMMAND_INITIALIZE 0x01
45 #define COMMAND_RESOLUTION 0x02
46 #define COMMAND_SETCONFIG 0x03
47 #define COMMAND_DATAREQUEST 0x04
48 #define COMMAND_SCANFREQ 0x08
49 #define COMMAND_STATUS 0X1e
52 * Responses the controller sends as a result of
55 #define RESPONSE_DEACTIVATE 0x00
56 #define RESPONSE_INITIALIZE 0x01
57 #define RESPONSE_RESOLUTION 0x02
58 #define RESPONSE_SETCONFIG 0x03
59 #define RESPONSE_SCANFREQ 0x08
60 #define RESPONSE_STATUS 0X1e
63 * Notifications are sent by the touch controller without
64 * being requested by the driver and include for example
67 #define NOTIFICATION_TOUCH 0x04
68 #define NOTIFICATION_BOOTCOMPLETE 0x07
69 #define NOTIFICATION_OVERRUN 0x25
70 #define NOTIFICATION_PROXIMITY 0x26
71 #define NOTIFICATION_INVALID_COMMAND 0xfe
73 #define ZFORCE_REPORT_POINTS 2
74 #define ZFORCE_MAX_AREA 0xff
80 #define SETCONFIG_DUALTOUCH (1 << 0)
95 * @client the i2c_client
96 * @input the input device
97 * @suspending in the process of going to suspend (don't emit wakeup
98 * events for commands executed to suspend the device)
99 * @suspended device suspended
100 * @access_mutex serialize i2c-access, to keep multipart reads together
101 * @command_done completion to wait for the command result
102 * @command_mutex serialize commands sent to the ic
103 * @command_waiting the id of the command that is currently waiting
105 * @command_result returned result of the command
108 struct i2c_client *client;
109 struct input_dev *input;
110 struct touchscreen_properties prop;
111 const struct zforce_ts_platdata *pdata;
114 struct regulator *reg_vdd;
116 struct gpio_desc *gpio_int;
117 struct gpio_desc *gpio_rst;
123 /* Firmware version information */
129 struct mutex access_mutex;
131 struct completion command_done;
132 struct mutex command_mutex;
137 static int zforce_command(struct zforce_ts *ts, u8 cmd)
139 struct i2c_client *client = ts->client;
143 dev_dbg(&client->dev, "%s: 0x%x\n", __func__, cmd);
145 buf[0] = FRAME_START;
146 buf[1] = 1; /* data size, command only */
149 mutex_lock(&ts->access_mutex);
150 ret = i2c_master_send(client, &buf[0], ARRAY_SIZE(buf));
151 mutex_unlock(&ts->access_mutex);
153 dev_err(&client->dev, "i2c send data request error: %d\n", ret);
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);
177 dev_err(&client->dev, "already waiting for a command\n");
181 dev_dbg(&client->dev, "sending %d bytes for command 0x%x\n",
184 ts->command_waiting = buf[2];
186 mutex_lock(&ts->access_mutex);
187 ret = i2c_master_send(client, buf, len);
188 mutex_unlock(&ts->access_mutex);
190 dev_err(&client->dev, "i2c send data request error: %d\n", ret);
194 dev_dbg(&client->dev, "waiting for result for command 0x%x\n", buf[2]);
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;
214 dev_dbg(&client->dev, "%s: 0x%x\n", __func__, cmd);
216 buf[0] = FRAME_START;
217 buf[1] = 1; /* data size, command only */
220 ret = zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
222 dev_err(&client->dev, "i2c send data request error: %d\n", ret);
229 static int zforce_resolution(struct zforce_ts *ts, u16 x, u16 y)
231 struct i2c_client *client = ts->client;
232 char buf[7] = { FRAME_START, 5, COMMAND_RESOLUTION,
233 (x & 0xff), ((x >> 8) & 0xff),
234 (y & 0xff), ((y >> 8) & 0xff) };
236 dev_dbg(&client->dev, "set resolution to (%d,%d)\n", x, y);
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;
245 char buf[9] = { FRAME_START, 7, COMMAND_SCANFREQ,
246 (idle & 0xff), ((idle >> 8) & 0xff),
247 (finger & 0xff), ((finger >> 8) & 0xff),
248 (stylus & 0xff), ((stylus >> 8) & 0xff) };
250 dev_dbg(&client->dev,
251 "set scan frequency to (idle: %d, finger: %d, stylus: %d)\n",
252 idle, finger, stylus);
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;
260 char buf[7] = { FRAME_START, 5, COMMAND_SETCONFIG,
263 dev_dbg(&client->dev, "set config to (%d)\n", b1);
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;
273 dev_dbg(&client->dev, "starting device\n");
275 ret = zforce_command_wait(ts, COMMAND_INITIALIZE);
277 dev_err(&client->dev, "Unable to initialize, %d\n", ret);
281 ret = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y);
283 dev_err(&client->dev, "Unable to set resolution, %d\n", ret);
287 ret = zforce_scan_frequency(ts, 10, 50, 50);
289 dev_err(&client->dev, "Unable to set scan frequency, %d\n",
294 ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH);
296 dev_err(&client->dev, "Unable to set config\n");
300 /* start sending touch events */
301 ret = zforce_command(ts, COMMAND_DATAREQUEST);
303 dev_err(&client->dev, "Unable to request data\n");
308 * Per NN, initial cal. take max. of 200msec.
309 * Allow time to complete this calibration
316 zforce_command_wait(ts, COMMAND_DEACTIVATE);
320 static int zforce_stop(struct zforce_ts *ts)
322 struct i2c_client *client = ts->client;
325 dev_dbg(&client->dev, "stopping device\n");
327 /* Deactivates touch sensing and puts the device into sleep. */
328 ret = zforce_command_wait(ts, COMMAND_DEACTIVATE);
330 dev_err(&client->dev, "could not deactivate device, %d\n",
338 static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
340 struct i2c_client *client = ts->client;
341 struct zforce_point point;
342 int count, i, num = 0;
345 if (count > ZFORCE_REPORT_POINTS) {
346 dev_warn(&client->dev,
347 "too many coordinates %d, expected max %d\n",
348 count, ZFORCE_REPORT_POINTS);
349 count = ZFORCE_REPORT_POINTS;
352 for (i = 0; i < count; i++) {
354 payload[9 * i + 2] << 8 | payload[9 * i + 1];
356 payload[9 * i + 4] << 8 | payload[9 * i + 3];
358 if (point.coord_x > ts->prop.max_x ||
359 point.coord_y > ts->prop.max_y) {
360 dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
361 point.coord_x, point.coord_y);
362 point.coord_x = point.coord_y = 0;
365 point.state = payload[9 * i + 5] & 0x0f;
366 point.id = (payload[9 * i + 5] & 0xf0) >> 4;
368 /* determine touch major, minor and orientation */
369 point.area_major = max(payload[9 * i + 6],
371 point.area_minor = min(payload[9 * i + 6],
373 point.orientation = payload[9 * i + 6] > payload[9 * i + 7];
375 point.pressure = payload[9 * i + 8];
376 point.prblty = payload[9 * i + 9];
378 dev_dbg(&client->dev,
379 "point %d/%d: state %d, id %d, pressure %d, prblty %d, x %d, y %d, amajor %d, aminor %d, ori %d\n",
380 i, count, point.state, point.id,
381 point.pressure, point.prblty,
382 point.coord_x, point.coord_y,
383 point.area_major, point.area_minor,
386 /* the zforce id starts with "1", so needs to be decreased */
387 input_mt_slot(ts->input, point.id - 1);
389 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER,
390 point.state != STATE_UP);
392 if (point.state != STATE_UP) {
393 touchscreen_report_pos(ts->input, &ts->prop,
394 point.coord_x, point.coord_y,
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);
422 /* read 2 byte message header */
423 ret = i2c_master_recv(client, buf, 2);
425 dev_err(&client->dev, "error reading header: %d\n", ret);
429 if (buf[PAYLOAD_HEADER] != FRAME_START) {
430 dev_err(&client->dev, "invalid frame start: %d\n", buf[0]);
435 if (buf[PAYLOAD_LENGTH] == 0) {
436 dev_err(&client->dev, "invalid payload length: %d\n",
437 buf[PAYLOAD_LENGTH]);
442 /* read the message */
443 ret = i2c_master_recv(client, &buf[PAYLOAD_BODY], buf[PAYLOAD_LENGTH]);
445 dev_err(&client->dev, "error reading payload: %d\n", ret);
449 dev_dbg(&client->dev, "read %d bytes for response command 0x%x\n",
450 buf[PAYLOAD_LENGTH], buf[PAYLOAD_BODY]);
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) {
462 dev_dbg(&client->dev, "completing command 0x%x\n", cmd);
463 ts->command_result = result;
464 complete(&ts->command_done);
466 dev_dbg(&client->dev, "command %d not for us\n", cmd);
470 static irqreturn_t zforce_irq(int irq, void *dev_id)
472 struct zforce_ts *ts = dev_id;
473 struct i2c_client *client = ts->client;
475 if (ts->suspended && device_may_wakeup(&client->dev))
476 pm_wakeup_event(&client->dev, 500);
478 return IRQ_WAKE_THREAD;
481 static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
483 struct zforce_ts *ts = dev_id;
484 struct i2c_client *client = ts->client;
486 u8 payload_buffer[FRAME_MAXSIZE];
490 * When still suspended, return.
491 * Due to the level-interrupt we will get re-triggered later.
498 dev_dbg(&client->dev, "handling interrupt\n");
500 /* Don't emit wakeup events from commands run by zforce_suspend */
501 if (!ts->suspending && device_may_wakeup(&client->dev))
502 pm_stay_awake(&client->dev);
505 * Run at least once and exit the loop if
506 * - the optional interrupt GPIO isn't specified
507 * (there is only one packet read per ISR invocation, then)
509 * - the GPIO isn't active any more
510 * (packet read until the level GPIO indicates that there is
514 ret = zforce_read_packet(ts, payload_buffer);
516 dev_err(&client->dev,
517 "could not read packet, ret: %d\n", ret);
521 payload = &payload_buffer[PAYLOAD_BODY];
523 switch (payload[RESPONSE_ID]) {
524 case NOTIFICATION_TOUCH:
526 * Always report touch-events received while
527 * suspending, when being a wakeup source
529 if (ts->suspending && device_may_wakeup(&client->dev))
530 pm_wakeup_event(&client->dev, 500);
531 zforce_touch_event(ts, &payload[RESPONSE_DATA]);
534 case NOTIFICATION_BOOTCOMPLETE:
535 ts->boot_complete = payload[RESPONSE_DATA];
536 zforce_complete(ts, payload[RESPONSE_ID], 0);
539 case RESPONSE_INITIALIZE:
540 case RESPONSE_DEACTIVATE:
541 case RESPONSE_SETCONFIG:
542 case RESPONSE_RESOLUTION:
543 case RESPONSE_SCANFREQ:
544 zforce_complete(ts, payload[RESPONSE_ID],
545 payload[RESPONSE_DATA]);
548 case RESPONSE_STATUS:
550 * Version Payload Results
551 * [2:major] [2:minor] [2:build] [2:rev]
553 ts->version_major = (payload[RESPONSE_DATA + 1] << 8) |
554 payload[RESPONSE_DATA];
555 ts->version_minor = (payload[RESPONSE_DATA + 3] << 8) |
556 payload[RESPONSE_DATA + 2];
557 ts->version_build = (payload[RESPONSE_DATA + 5] << 8) |
558 payload[RESPONSE_DATA + 4];
559 ts->version_rev = (payload[RESPONSE_DATA + 7] << 8) |
560 payload[RESPONSE_DATA + 6];
561 dev_dbg(&ts->client->dev,
562 "Firmware Version %04x:%04x %04x:%04x\n",
563 ts->version_major, ts->version_minor,
564 ts->version_build, ts->version_rev);
566 zforce_complete(ts, payload[RESPONSE_ID], 0);
569 case NOTIFICATION_INVALID_COMMAND:
570 dev_err(&ts->client->dev, "invalid command: 0x%x\n",
571 payload[RESPONSE_DATA]);
575 dev_err(&ts->client->dev,
576 "unrecognized response id: 0x%x\n",
577 payload[RESPONSE_ID]);
580 } while (gpiod_get_value_cansleep(ts->gpio_int));
582 if (!ts->suspending && device_may_wakeup(&client->dev))
583 pm_relax(&client->dev);
585 dev_dbg(&client->dev, "finished interrupt\n");
590 static int zforce_input_open(struct input_dev *dev)
592 struct zforce_ts *ts = input_get_drvdata(dev);
594 return zforce_start(ts);
597 static void zforce_input_close(struct input_dev *dev)
599 struct zforce_ts *ts = input_get_drvdata(dev);
600 struct i2c_client *client = ts->client;
603 ret = zforce_stop(ts);
605 dev_warn(&client->dev, "stopping zforce failed\n");
610 static int zforce_suspend(struct device *dev)
612 struct i2c_client *client = to_i2c_client(dev);
613 struct zforce_ts *ts = i2c_get_clientdata(client);
614 struct input_dev *input = ts->input;
617 mutex_lock(&input->mutex);
618 ts->suspending = true;
621 * When configured as a wakeup source device should always wake
622 * the system, therefore start device if necessary.
624 if (device_may_wakeup(&client->dev)) {
625 dev_dbg(&client->dev, "suspend while being a wakeup source\n");
627 /* Need to start device, if not open, to be a wakeup source. */
628 if (!input_device_enabled(input)) {
629 ret = zforce_start(ts);
634 enable_irq_wake(client->irq);
635 } else if (input_device_enabled(input)) {
636 dev_dbg(&client->dev,
637 "suspend without being a wakeup source\n");
639 ret = zforce_stop(ts);
643 disable_irq(client->irq);
646 ts->suspended = true;
649 ts->suspending = false;
650 mutex_unlock(&input->mutex);
655 static int zforce_resume(struct device *dev)
657 struct i2c_client *client = to_i2c_client(dev);
658 struct zforce_ts *ts = i2c_get_clientdata(client);
659 struct input_dev *input = ts->input;
662 mutex_lock(&input->mutex);
664 ts->suspended = false;
666 if (device_may_wakeup(&client->dev)) {
667 dev_dbg(&client->dev, "resume from being a wakeup source\n");
669 disable_irq_wake(client->irq);
671 /* need to stop device if it was not open on suspend */
672 if (!input_device_enabled(input)) {
673 ret = zforce_stop(ts);
677 } else if (input_device_enabled(input)) {
678 dev_dbg(&client->dev, "resume without being a wakeup source\n");
680 enable_irq(client->irq);
682 ret = zforce_start(ts);
688 mutex_unlock(&input->mutex);
693 static DEFINE_SIMPLE_DEV_PM_OPS(zforce_pm_ops, zforce_suspend, zforce_resume);
695 static void zforce_reset(void *data)
697 struct zforce_ts *ts = data;
699 zforce_reset_assert(ts);
703 if (!IS_ERR(ts->reg_vdd))
704 regulator_disable(ts->reg_vdd);
707 static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
709 struct zforce_ts_platdata *pdata;
710 struct device_node *np = dev->of_node;
713 return ERR_PTR(-ENOENT);
715 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
717 dev_err(dev, "failed to allocate platform data\n");
718 return ERR_PTR(-ENOMEM);
721 of_property_read_u32(np, "x-size", &pdata->x_max);
722 of_property_read_u32(np, "y-size", &pdata->y_max);
727 static int zforce_probe(struct i2c_client *client)
729 const struct zforce_ts_platdata *pdata = dev_get_platdata(&client->dev);
730 struct zforce_ts *ts;
731 struct input_dev *input_dev;
735 pdata = zforce_parse_dt(&client->dev);
737 return PTR_ERR(pdata);
740 ts = devm_kzalloc(&client->dev, sizeof(struct zforce_ts), GFP_KERNEL);
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);
748 dev_err(&client->dev,
749 "failed to request reset GPIO: %d\n", ret);
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);
758 dev_err(&client->dev,
759 "failed to request interrupt GPIO: %d\n", ret);
764 * Deprecated GPIO handling for compatibility
765 * with legacy binding.
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);
773 dev_err(&client->dev,
774 "failed to request interrupt GPIO: %d\n", ret);
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);
783 dev_err(&client->dev,
784 "failed to request reset GPIO: %d\n", ret);
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);
792 if (ret == -EPROBE_DEFER)
795 ret = regulator_enable(ts->reg_vdd);
800 * according to datasheet add 100us grace time after regular
801 * regulator enable delay.
806 ret = devm_add_action(&client->dev, zforce_reset, ts);
808 dev_err(&client->dev, "failed to register reset action, %d\n",
811 /* hereafter the regulator will be disabled by the action */
812 if (!IS_ERR(ts->reg_vdd))
813 regulator_disable(ts->reg_vdd);
818 snprintf(ts->phys, sizeof(ts->phys),
819 "%s/input0", dev_name(&client->dev));
821 input_dev = devm_input_allocate_device(&client->dev);
823 dev_err(&client->dev, "could not allocate input device\n");
827 mutex_init(&ts->access_mutex);
828 mutex_init(&ts->command_mutex);
832 ts->input = input_dev;
834 input_dev->name = "Neonode zForce touchscreen";
835 input_dev->phys = ts->phys;
836 input_dev->id.bustype = BUS_I2C;
838 input_dev->open = zforce_input_open;
839 input_dev->close = zforce_input_close;
841 __set_bit(EV_KEY, input_dev->evbit);
842 __set_bit(EV_SYN, input_dev->evbit);
843 __set_bit(EV_ABS, input_dev->evbit);
845 /* For multi touch */
846 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
848 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
851 touchscreen_parse_properties(input_dev, true, &ts->prop);
852 if (ts->prop.max_x == 0 || ts->prop.max_y == 0) {
853 dev_err(&client->dev, "no size specified\n");
857 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
858 ZFORCE_MAX_AREA, 0, 0);
859 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0,
860 ZFORCE_MAX_AREA, 0, 0);
861 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
862 input_mt_init_slots(input_dev, ZFORCE_REPORT_POINTS, INPUT_MT_DIRECT);
864 input_set_drvdata(ts->input, ts);
866 init_completion(&ts->command_done);
869 * The zforce pulls the interrupt low when it has data ready.
870 * After it is triggered the isr thread runs until all the available
871 * packets have been read and the interrupt is high again.
872 * Therefore we can trigger the interrupt anytime it is low and do
873 * not need to limit it to the interrupt edge.
875 ret = devm_request_threaded_irq(&client->dev, client->irq,
876 zforce_irq, zforce_irq_thread,
877 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
878 input_dev->name, ts);
880 dev_err(&client->dev, "irq %d request failed\n", client->irq);
884 i2c_set_clientdata(client, ts);
886 /* let the controller boot */
887 zforce_reset_deassert(ts);
889 ts->command_waiting = NOTIFICATION_BOOTCOMPLETE;
890 if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0)
891 dev_warn(&client->dev, "bootcomplete timed out\n");
893 /* need to start device to get version information */
894 ret = zforce_command_wait(ts, COMMAND_INITIALIZE);
896 dev_err(&client->dev, "unable to initialize, %d\n", ret);
900 /* this gets the firmware version among other information */
901 ret = zforce_command_wait(ts, COMMAND_STATUS);
903 dev_err(&client->dev, "couldn't get status, %d\n", ret);
908 /* stop device and put it into sleep until it is opened */
909 ret = zforce_stop(ts);
913 device_set_wakeup_capable(&client->dev, true);
915 ret = input_register_device(input_dev);
917 dev_err(&client->dev, "could not register input device, %d\n",
925 static struct i2c_device_id zforce_idtable[] = {
929 MODULE_DEVICE_TABLE(i2c, zforce_idtable);
932 static const struct of_device_id zforce_dt_idtable[] = {
933 { .compatible = "neonode,zforce" },
936 MODULE_DEVICE_TABLE(of, zforce_dt_idtable);
939 static struct i2c_driver zforce_driver = {
942 .pm = pm_sleep_ptr(&zforce_pm_ops),
943 .of_match_table = of_match_ptr(zforce_dt_idtable),
945 .probe = zforce_probe,
946 .id_table = zforce_idtable,
949 module_i2c_driver(zforce_driver);
951 MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
952 MODULE_DESCRIPTION("zForce TouchScreen Driver");
953 MODULE_LICENSE("GPL");