2 * Driver for Goodix Touchscreens
4 * Copyright (c) 2014 Red Hat Inc.
5 * Copyright (c) 2015 K. Merker <merker@debian.org>
7 * This code is based on gt9xx.c authored by andrew@goodix.com:
9 * 2010 - 2012 Goodix Technology.
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; version 2 of the License.
18 #include <linux/kernel.h>
19 #include <linux/dmi.h>
20 #include <linux/firmware.h>
21 #include <linux/gpio/consumer.h>
22 #include <linux/i2c.h>
23 #include <linux/input.h>
24 #include <linux/input/mt.h>
25 #include <linux/input/touchscreen.h>
26 #include <linux/module.h>
27 #include <linux/delay.h>
28 #include <linux/irq.h>
29 #include <linux/interrupt.h>
30 #include <linux/slab.h>
31 #include <linux/acpi.h>
33 #include <asm/unaligned.h>
35 struct goodix_ts_data;
37 struct goodix_chip_data {
40 int (*check_config)(struct goodix_ts_data *, const struct firmware *);
43 struct goodix_ts_data {
44 struct i2c_client *client;
45 struct input_dev *input_dev;
46 const struct goodix_chip_data *chip;
47 struct touchscreen_properties prop;
48 unsigned int max_touch_num;
49 unsigned int int_trigger_type;
50 struct gpio_desc *gpiod_int;
51 struct gpio_desc *gpiod_rst;
55 struct completion firmware_loading_complete;
56 unsigned long irq_flags;
59 #define GOODIX_GPIO_INT_NAME "irq"
60 #define GOODIX_GPIO_RST_NAME "reset"
62 #define GOODIX_MAX_HEIGHT 4096
63 #define GOODIX_MAX_WIDTH 4096
64 #define GOODIX_INT_TRIGGER 1
65 #define GOODIX_CONTACT_SIZE 8
66 #define GOODIX_MAX_CONTACTS 10
68 #define GOODIX_CONFIG_MAX_LENGTH 240
69 #define GOODIX_CONFIG_911_LENGTH 186
70 #define GOODIX_CONFIG_967_LENGTH 228
72 /* Register defines */
73 #define GOODIX_REG_COMMAND 0x8040
74 #define GOODIX_CMD_SCREEN_OFF 0x05
76 #define GOODIX_READ_COOR_ADDR 0x814E
77 #define GOODIX_GT1X_REG_CONFIG_DATA 0x8050
78 #define GOODIX_GT9X_REG_CONFIG_DATA 0x8047
79 #define GOODIX_REG_ID 0x8140
81 #define GOODIX_BUFFER_STATUS_READY BIT(7)
82 #define GOODIX_BUFFER_STATUS_TIMEOUT 20
84 #define RESOLUTION_LOC 1
85 #define MAX_CONTACTS_LOC 5
88 static int goodix_check_cfg_8(struct goodix_ts_data *ts,
89 const struct firmware *cfg);
90 static int goodix_check_cfg_16(struct goodix_ts_data *ts,
91 const struct firmware *cfg);
93 static const struct goodix_chip_data gt1x_chip_data = {
94 .config_addr = GOODIX_GT1X_REG_CONFIG_DATA,
95 .config_len = GOODIX_CONFIG_MAX_LENGTH,
96 .check_config = goodix_check_cfg_16,
99 static const struct goodix_chip_data gt911_chip_data = {
100 .config_addr = GOODIX_GT9X_REG_CONFIG_DATA,
101 .config_len = GOODIX_CONFIG_911_LENGTH,
102 .check_config = goodix_check_cfg_8,
105 static const struct goodix_chip_data gt967_chip_data = {
106 .config_addr = GOODIX_GT9X_REG_CONFIG_DATA,
107 .config_len = GOODIX_CONFIG_967_LENGTH,
108 .check_config = goodix_check_cfg_8,
111 static const struct goodix_chip_data gt9x_chip_data = {
112 .config_addr = GOODIX_GT9X_REG_CONFIG_DATA,
113 .config_len = GOODIX_CONFIG_MAX_LENGTH,
114 .check_config = goodix_check_cfg_8,
117 static const unsigned long goodix_irq_flags[] = {
118 IRQ_TYPE_EDGE_RISING,
119 IRQ_TYPE_EDGE_FALLING,
125 * Those tablets have their coordinates origin at the bottom right
126 * of the tablet, as if rotated 180 degrees
128 static const struct dmi_system_id rotated_screen[] = {
129 #if defined(CONFIG_DMI) && defined(CONFIG_X86)
131 .ident = "Teclast X89",
133 /* tPAD is too generic, also match on bios date */
134 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
135 DMI_MATCH(DMI_BOARD_NAME, "tPAD"),
136 DMI_MATCH(DMI_BIOS_DATE, "12/19/2014"),
140 .ident = "Teclast X98 Pro",
143 * Only match BIOS date, because the manufacturers
144 * BIOS does not report the board name at all
147 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
148 DMI_MATCH(DMI_BIOS_DATE, "10/28/2015"),
152 .ident = "WinBook TW100",
154 DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
155 DMI_MATCH(DMI_PRODUCT_NAME, "TW100")
159 .ident = "WinBook TW700",
161 DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
162 DMI_MATCH(DMI_PRODUCT_NAME, "TW700")
170 * goodix_i2c_read - read data from a register of the i2c slave device.
172 * @client: i2c device.
173 * @reg: the register to read from.
174 * @buf: raw write data buffer.
175 * @len: length of the buffer to write
177 static int goodix_i2c_read(struct i2c_client *client,
178 u16 reg, u8 *buf, int len)
180 struct i2c_msg msgs[2];
181 __be16 wbuf = cpu_to_be16(reg);
185 msgs[0].addr = client->addr;
187 msgs[0].buf = (u8 *)&wbuf;
189 msgs[1].flags = I2C_M_RD;
190 msgs[1].addr = client->addr;
194 ret = i2c_transfer(client->adapter, msgs, 2);
195 return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);
199 * goodix_i2c_write - write data to a register of the i2c slave device.
201 * @client: i2c device.
202 * @reg: the register to write to.
203 * @buf: raw data buffer to write.
204 * @len: length of the buffer to write
206 static int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf,
213 addr_buf = kmalloc(len + 2, GFP_KERNEL);
217 addr_buf[0] = reg >> 8;
218 addr_buf[1] = reg & 0xFF;
219 memcpy(&addr_buf[2], buf, len);
222 msg.addr = client->addr;
226 ret = i2c_transfer(client->adapter, &msg, 1);
228 return ret < 0 ? ret : (ret != 1 ? -EIO : 0);
231 static int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value)
233 return goodix_i2c_write(client, reg, &value, sizeof(value));
236 static const struct goodix_chip_data *goodix_get_chip_data(u16 id)
240 return >1x_chip_data;
247 return >911_chip_data;
251 return >967_chip_data;
254 return >9x_chip_data;
258 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
260 unsigned long max_timeout;
265 * The 'buffer status' bit, which indicates that the data is valid, is
266 * not set as soon as the interrupt is raised, but slightly after.
267 * This takes around 10 ms to happen, so we poll for 20 ms.
269 max_timeout = jiffies + msecs_to_jiffies(GOODIX_BUFFER_STATUS_TIMEOUT);
271 error = goodix_i2c_read(ts->client, GOODIX_READ_COOR_ADDR,
272 data, GOODIX_CONTACT_SIZE + 1);
274 dev_err(&ts->client->dev, "I2C transfer error: %d\n",
279 if (data[0] & GOODIX_BUFFER_STATUS_READY) {
280 touch_num = data[0] & 0x0f;
281 if (touch_num > ts->max_touch_num)
285 data += 1 + GOODIX_CONTACT_SIZE;
286 error = goodix_i2c_read(ts->client,
287 GOODIX_READ_COOR_ADDR +
288 1 + GOODIX_CONTACT_SIZE,
290 GOODIX_CONTACT_SIZE *
299 usleep_range(1000, 2000); /* Poll every 1 - 2 ms */
300 } while (time_before(jiffies, max_timeout));
303 * The Goodix panel will send spurious interrupts after a
304 * 'finger up' event, which will always cause a timeout.
309 static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
311 int id = coor_data[0] & 0x0F;
312 int input_x = get_unaligned_le16(&coor_data[1]);
313 int input_y = get_unaligned_le16(&coor_data[3]);
314 int input_w = get_unaligned_le16(&coor_data[5]);
316 input_mt_slot(ts->input_dev, id);
317 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
318 touchscreen_report_pos(ts->input_dev, &ts->prop,
319 input_x, input_y, true);
320 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w);
321 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w);
325 * goodix_process_events - Process incoming events
327 * @ts: our goodix_ts_data pointer
329 * Called when the IRQ is triggered. Read the current device state, and push
330 * the input events to the user space.
332 static void goodix_process_events(struct goodix_ts_data *ts)
334 u8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
338 touch_num = goodix_ts_read_input_report(ts, point_data);
343 * Bit 4 of the first byte reports the status of the capacitive
344 * Windows/Home button.
346 input_report_key(ts->input_dev, KEY_LEFTMETA, point_data[0] & BIT(4));
348 for (i = 0; i < touch_num; i++)
349 goodix_ts_report_touch(ts,
350 &point_data[1 + GOODIX_CONTACT_SIZE * i]);
352 input_mt_sync_frame(ts->input_dev);
353 input_sync(ts->input_dev);
357 * goodix_ts_irq_handler - The IRQ handler
359 * @irq: interrupt number.
360 * @dev_id: private data pointer.
362 static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
364 struct goodix_ts_data *ts = dev_id;
366 goodix_process_events(ts);
368 if (goodix_i2c_write_u8(ts->client, GOODIX_READ_COOR_ADDR, 0) < 0)
369 dev_err(&ts->client->dev, "I2C write end_cmd error\n");
374 static void goodix_free_irq(struct goodix_ts_data *ts)
376 devm_free_irq(&ts->client->dev, ts->client->irq, ts);
379 static int goodix_request_irq(struct goodix_ts_data *ts)
381 return devm_request_threaded_irq(&ts->client->dev, ts->client->irq,
382 NULL, goodix_ts_irq_handler,
383 ts->irq_flags, ts->client->name, ts);
386 static int goodix_check_cfg_8(struct goodix_ts_data *ts,
387 const struct firmware *cfg)
389 int i, raw_cfg_len = cfg->size - 2;
392 for (i = 0; i < raw_cfg_len; i++)
393 check_sum += cfg->data[i];
394 check_sum = (~check_sum) + 1;
395 if (check_sum != cfg->data[raw_cfg_len]) {
396 dev_err(&ts->client->dev,
397 "The checksum of the config fw is not correct");
401 if (cfg->data[raw_cfg_len + 1] != 1) {
402 dev_err(&ts->client->dev,
403 "Config fw must have Config_Fresh register set");
410 static int goodix_check_cfg_16(struct goodix_ts_data *ts,
411 const struct firmware *cfg)
413 int i, raw_cfg_len = cfg->size - 3;
416 for (i = 0; i < raw_cfg_len; i += 2)
417 check_sum += get_unaligned_be16(&cfg->data[i]);
418 check_sum = (~check_sum) + 1;
419 if (check_sum != get_unaligned_be16(&cfg->data[raw_cfg_len])) {
420 dev_err(&ts->client->dev,
421 "The checksum of the config fw is not correct");
425 if (cfg->data[raw_cfg_len + 2] != 1) {
426 dev_err(&ts->client->dev,
427 "Config fw must have Config_Fresh register set");
435 * goodix_check_cfg - Checks if config fw is valid
437 * @ts: goodix_ts_data pointer
438 * @cfg: firmware config data
440 static int goodix_check_cfg(struct goodix_ts_data *ts,
441 const struct firmware *cfg)
443 if (cfg->size > GOODIX_CONFIG_MAX_LENGTH) {
444 dev_err(&ts->client->dev,
445 "The length of the config fw is not correct");
449 return ts->chip->check_config(ts, cfg);
453 * goodix_send_cfg - Write fw config to device
455 * @ts: goodix_ts_data pointer
456 * @cfg: config firmware to write to device
458 static int goodix_send_cfg(struct goodix_ts_data *ts,
459 const struct firmware *cfg)
463 error = goodix_check_cfg(ts, cfg);
467 error = goodix_i2c_write(ts->client, ts->chip->config_addr, cfg->data,
470 dev_err(&ts->client->dev, "Failed to write config data: %d",
474 dev_dbg(&ts->client->dev, "Config sent successfully.");
476 /* Let the firmware reconfigure itself, so sleep for 10ms */
477 usleep_range(10000, 11000);
482 static int goodix_int_sync(struct goodix_ts_data *ts)
486 error = gpiod_direction_output(ts->gpiod_int, 0);
490 msleep(50); /* T5: 50ms */
492 error = gpiod_direction_input(ts->gpiod_int);
500 * goodix_reset - Reset device during power on
502 * @ts: goodix_ts_data pointer
504 static int goodix_reset(struct goodix_ts_data *ts)
508 /* begin select I2C slave addr */
509 error = gpiod_direction_output(ts->gpiod_rst, 0);
513 msleep(20); /* T2: > 10ms */
515 /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */
516 error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14);
520 usleep_range(100, 2000); /* T3: > 100us */
522 error = gpiod_direction_output(ts->gpiod_rst, 1);
526 usleep_range(6000, 10000); /* T4: > 5ms */
528 /* end select I2C slave addr */
529 error = gpiod_direction_input(ts->gpiod_rst);
533 error = goodix_int_sync(ts);
541 * goodix_get_gpio_config - Get GPIO config from ACPI/DT
543 * @ts: goodix_ts_data pointer
545 static int goodix_get_gpio_config(struct goodix_ts_data *ts)
549 struct gpio_desc *gpiod;
553 dev = &ts->client->dev;
555 /* Get the interrupt GPIO pin number */
556 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN);
558 error = PTR_ERR(gpiod);
559 if (error != -EPROBE_DEFER)
560 dev_dbg(dev, "Failed to get %s GPIO: %d\n",
561 GOODIX_GPIO_INT_NAME, error);
565 ts->gpiod_int = gpiod;
567 /* Get the reset line GPIO pin number */
568 gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, GPIOD_IN);
570 error = PTR_ERR(gpiod);
571 if (error != -EPROBE_DEFER)
572 dev_dbg(dev, "Failed to get %s GPIO: %d\n",
573 GOODIX_GPIO_RST_NAME, error);
577 ts->gpiod_rst = gpiod;
583 * goodix_read_config - Read the embedded configuration of the panel
585 * @ts: our goodix_ts_data pointer
587 * Must be called during probe
589 static void goodix_read_config(struct goodix_ts_data *ts)
591 u8 config[GOODIX_CONFIG_MAX_LENGTH];
595 error = goodix_i2c_read(ts->client, ts->chip->config_addr,
596 config, ts->chip->config_len);
598 dev_warn(&ts->client->dev, "Error reading config: %d\n",
600 ts->int_trigger_type = GOODIX_INT_TRIGGER;
601 ts->max_touch_num = GOODIX_MAX_CONTACTS;
605 ts->int_trigger_type = config[TRIGGER_LOC] & 0x03;
606 ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f;
608 x_max = get_unaligned_le16(&config[RESOLUTION_LOC]);
609 y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]);
610 if (x_max && y_max) {
611 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_X, x_max - 1);
612 input_abs_set_max(ts->input_dev, ABS_MT_POSITION_Y, y_max - 1);
617 * goodix_read_version - Read goodix touchscreen version
619 * @ts: our goodix_ts_data pointer
621 static int goodix_read_version(struct goodix_ts_data *ts)
627 error = goodix_i2c_read(ts->client, GOODIX_REG_ID, buf, sizeof(buf));
629 dev_err(&ts->client->dev, "read version failed: %d\n", error);
633 memcpy(id_str, buf, 4);
635 if (kstrtou16(id_str, 10, &ts->id))
638 ts->version = get_unaligned_le16(&buf[4]);
640 dev_info(&ts->client->dev, "ID %d, version: %04x\n", ts->id,
647 * goodix_i2c_test - I2C test function to check if the device answers.
649 * @client: the i2c client
651 static int goodix_i2c_test(struct i2c_client *client)
657 while (retry++ < 2) {
658 error = goodix_i2c_read(client, GOODIX_REG_ID,
663 dev_err(&client->dev, "i2c test failed attempt %d: %d\n",
672 * goodix_configure_dev - Finish device initialization
674 * @ts: our goodix_ts_data pointer
676 * Must be called from probe to finish initialization of the device.
677 * Contains the common initialization code for both devices that
678 * declare gpio pins and devices that do not. It is either called
679 * directly from probe or from request_firmware_wait callback.
681 static int goodix_configure_dev(struct goodix_ts_data *ts)
685 ts->int_trigger_type = GOODIX_INT_TRIGGER;
686 ts->max_touch_num = GOODIX_MAX_CONTACTS;
688 ts->input_dev = devm_input_allocate_device(&ts->client->dev);
689 if (!ts->input_dev) {
690 dev_err(&ts->client->dev, "Failed to allocate input device.");
694 ts->input_dev->name = "Goodix Capacitive TouchScreen";
695 ts->input_dev->phys = "input/ts";
696 ts->input_dev->id.bustype = BUS_I2C;
697 ts->input_dev->id.vendor = 0x0416;
698 ts->input_dev->id.product = ts->id;
699 ts->input_dev->id.version = ts->version;
701 /* Capacitive Windows/Home button on some devices */
702 input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA);
704 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X);
705 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y);
706 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
707 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
709 /* Read configuration and apply touchscreen parameters */
710 goodix_read_config(ts);
712 /* Try overriding touchscreen parameters via device properties */
713 touchscreen_parse_properties(ts->input_dev, true, &ts->prop);
715 if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) {
716 dev_err(&ts->client->dev, "Invalid config, using defaults\n");
717 ts->prop.max_x = GOODIX_MAX_WIDTH - 1;
718 ts->prop.max_y = GOODIX_MAX_HEIGHT - 1;
719 ts->max_touch_num = GOODIX_MAX_CONTACTS;
720 input_abs_set_max(ts->input_dev,
721 ABS_MT_POSITION_X, ts->prop.max_x);
722 input_abs_set_max(ts->input_dev,
723 ABS_MT_POSITION_Y, ts->prop.max_y);
726 if (dmi_check_system(rotated_screen)) {
727 ts->prop.invert_x = true;
728 ts->prop.invert_y = true;
729 dev_dbg(&ts->client->dev,
730 "Applying '180 degrees rotated screen' quirk\n");
733 error = input_mt_init_slots(ts->input_dev, ts->max_touch_num,
734 INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
736 dev_err(&ts->client->dev,
737 "Failed to initialize MT slots: %d", error);
741 error = input_register_device(ts->input_dev);
743 dev_err(&ts->client->dev,
744 "Failed to register input device: %d", error);
748 ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT;
749 error = goodix_request_irq(ts);
751 dev_err(&ts->client->dev, "request IRQ failed: %d\n", error);
759 * goodix_config_cb - Callback to finish device init
761 * @ts: our goodix_ts_data pointer
763 * request_firmware_wait callback that finishes
764 * initialization of the device.
766 static void goodix_config_cb(const struct firmware *cfg, void *ctx)
768 struct goodix_ts_data *ts = ctx;
772 /* send device configuration to the firmware */
773 error = goodix_send_cfg(ts, cfg);
775 goto err_release_cfg;
778 goodix_configure_dev(ts);
781 release_firmware(cfg);
782 complete_all(&ts->firmware_loading_complete);
785 static int goodix_ts_probe(struct i2c_client *client,
786 const struct i2c_device_id *id)
788 struct goodix_ts_data *ts;
791 dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr);
793 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
794 dev_err(&client->dev, "I2C check functionality failed.\n");
798 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
803 i2c_set_clientdata(client, ts);
804 init_completion(&ts->firmware_loading_complete);
806 error = goodix_get_gpio_config(ts);
810 if (ts->gpiod_int && ts->gpiod_rst) {
811 /* reset the controller */
812 error = goodix_reset(ts);
814 dev_err(&client->dev, "Controller reset failed.\n");
819 error = goodix_i2c_test(client);
821 dev_err(&client->dev, "I2C communication failure: %d\n", error);
825 error = goodix_read_version(ts);
827 dev_err(&client->dev, "Read version failed.\n");
831 ts->chip = goodix_get_chip_data(ts->id);
833 if (ts->gpiod_int && ts->gpiod_rst) {
834 /* update device config */
835 ts->cfg_name = devm_kasprintf(&client->dev, GFP_KERNEL,
836 "/*(DEBLOBBED)*/", ts->id);
840 error = reject_firmware_nowait(THIS_MODULE, true, ts->cfg_name,
841 &client->dev, GFP_KERNEL, ts,
844 dev_err(&client->dev,
845 "Failed to invoke firmware loader: %d\n",
852 error = goodix_configure_dev(ts);
860 static int goodix_ts_remove(struct i2c_client *client)
862 struct goodix_ts_data *ts = i2c_get_clientdata(client);
864 if (ts->gpiod_int && ts->gpiod_rst)
865 wait_for_completion(&ts->firmware_loading_complete);
870 static int __maybe_unused goodix_suspend(struct device *dev)
872 struct i2c_client *client = to_i2c_client(dev);
873 struct goodix_ts_data *ts = i2c_get_clientdata(client);
876 /* We need gpio pins to suspend/resume */
877 if (!ts->gpiod_int || !ts->gpiod_rst) {
878 disable_irq(client->irq);
882 wait_for_completion(&ts->firmware_loading_complete);
884 /* Free IRQ as IRQ pin is used as output in the suspend sequence */
887 /* Output LOW on the INT pin for 5 ms */
888 error = gpiod_direction_output(ts->gpiod_int, 0);
890 goodix_request_irq(ts);
894 usleep_range(5000, 6000);
896 error = goodix_i2c_write_u8(ts->client, GOODIX_REG_COMMAND,
897 GOODIX_CMD_SCREEN_OFF);
899 dev_err(&ts->client->dev, "Screen off command failed\n");
900 gpiod_direction_input(ts->gpiod_int);
901 goodix_request_irq(ts);
906 * The datasheet specifies that the interval between sending screen-off
907 * command and wake-up should be longer than 58 ms. To avoid waking up
908 * sooner, delay 58ms here.
914 static int __maybe_unused goodix_resume(struct device *dev)
916 struct i2c_client *client = to_i2c_client(dev);
917 struct goodix_ts_data *ts = i2c_get_clientdata(client);
920 if (!ts->gpiod_int || !ts->gpiod_rst) {
921 enable_irq(client->irq);
926 * Exit sleep mode by outputting HIGH level to INT pin
929 error = gpiod_direction_output(ts->gpiod_int, 1);
933 usleep_range(2000, 5000);
935 error = goodix_int_sync(ts);
939 error = goodix_request_irq(ts);
946 static SIMPLE_DEV_PM_OPS(goodix_pm_ops, goodix_suspend, goodix_resume);
948 static const struct i2c_device_id goodix_ts_id[] = {
949 { "GDIX1001:00", 0 },
952 MODULE_DEVICE_TABLE(i2c, goodix_ts_id);
955 static const struct acpi_device_id goodix_acpi_match[] = {
960 MODULE_DEVICE_TABLE(acpi, goodix_acpi_match);
964 static const struct of_device_id goodix_of_match[] = {
965 { .compatible = "goodix,gt1151" },
966 { .compatible = "goodix,gt911" },
967 { .compatible = "goodix,gt9110" },
968 { .compatible = "goodix,gt912" },
969 { .compatible = "goodix,gt927" },
970 { .compatible = "goodix,gt9271" },
971 { .compatible = "goodix,gt928" },
972 { .compatible = "goodix,gt967" },
975 MODULE_DEVICE_TABLE(of, goodix_of_match);
978 static struct i2c_driver goodix_ts_driver = {
979 .probe = goodix_ts_probe,
980 .remove = goodix_ts_remove,
981 .id_table = goodix_ts_id,
984 .acpi_match_table = ACPI_PTR(goodix_acpi_match),
985 .of_match_table = of_match_ptr(goodix_of_match),
986 .pm = &goodix_pm_ops,
989 module_i2c_driver(goodix_ts_driver);
991 MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
992 MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>");
993 MODULE_DESCRIPTION("Goodix touchscreen driver");
994 MODULE_LICENSE("GPL v2");