1 // SPDX-License-Identifier: GPL-2.0-only
3 * Elan Microelectronics touch panels with I2C interface
5 * Copyright (C) 2014 Elan Microelectronics Corporation.
8 * This code is partly based on hid-multitouch.c:
12 * Copyright (c) 2010-2012 Ecole Nationale de l'Aviation Civile, France
14 * This code is partly based on i2c-hid.c:
17 * Copyright (c) 2012 Ecole Nationale de l'Aviation Civile, France
18 * Copyright (c) 2012 Red Hat, Inc
22 #include <linux/bits.h>
23 #include <linux/module.h>
24 #include <linux/input.h>
25 #include <linux/interrupt.h>
26 #include <linux/irq.h>
27 #include <linux/platform_device.h>
28 #include <linux/async.h>
29 #include <linux/i2c.h>
30 #include <linux/delay.h>
31 #include <linux/uaccess.h>
32 #include <linux/buffer_head.h>
33 #include <linux/slab.h>
34 #include <linux/firmware.h>
35 #include <linux/input/mt.h>
36 #include <linux/input/touchscreen.h>
37 #include <linux/acpi.h>
39 #include <linux/gpio/consumer.h>
40 #include <linux/regulator/consumer.h>
41 #include <linux/uuid.h>
42 #include <asm/unaligned.h>
44 /* Device, Driver information */
45 #define DEVICE_NAME "elants_i2c"
47 /* Convert from rows or columns into resolution */
48 #define ELAN_TS_RESOLUTION(n, m) (((n) - 1) * (m))
53 #define FW_HDR_COUNT 1
54 #define FW_HDR_LENGTH 2
56 /* Buffer mode Queue Header information */
57 #define QUEUE_HEADER_SINGLE 0x62
58 #define QUEUE_HEADER_NORMAL 0X63
59 #define QUEUE_HEADER_WAIT 0x64
60 #define QUEUE_HEADER_NORMAL2 0x66
62 /* Command header definition */
63 #define CMD_HEADER_WRITE 0x54
64 #define CMD_HEADER_READ 0x53
65 #define CMD_HEADER_6B_READ 0x5B
66 #define CMD_HEADER_ROM_READ 0x96
67 #define CMD_HEADER_RESP 0x52
68 #define CMD_HEADER_6B_RESP 0x9B
69 #define CMD_HEADER_ROM_RESP 0x95
70 #define CMD_HEADER_HELLO 0x55
71 #define CMD_HEADER_REK 0x66
73 /* FW position data */
74 #define PACKET_SIZE_OLD 40
75 #define PACKET_SIZE 55
76 #define MAX_CONTACT_NUM 10
77 #define FW_POS_HEADER 0
78 #define FW_POS_STATE 1
79 #define FW_POS_TOTAL 2
81 #define FW_POS_TOOL_TYPE 33
82 #define FW_POS_CHECKSUM 34
83 #define FW_POS_WIDTH 35
84 #define FW_POS_PRESSURE 45
86 #define HEADER_REPORT_10_FINGER 0x62
88 /* Header (4 bytes) plus 3 full 10-finger packets */
89 #define MAX_PACKET_SIZE 169
91 #define BOOT_TIME_DELAY_MS 50
93 /* FW read command, 0x53 0x?? 0x0, 0x01 */
94 #define E_ELAN_INFO_FW_VER 0x00
95 #define E_ELAN_INFO_BC_VER 0x10
96 #define E_ELAN_INFO_X_RES 0x60
97 #define E_ELAN_INFO_Y_RES 0x63
98 #define E_ELAN_INFO_REK 0xD0
99 #define E_ELAN_INFO_TEST_VER 0xE0
100 #define E_ELAN_INFO_FW_ID 0xF0
101 #define E_INFO_OSR 0xD6
102 #define E_INFO_PHY_SCAN 0xD7
103 #define E_INFO_PHY_DRIVER 0xD8
105 /* FW write command, 0x54 0x?? 0x0, 0x01 */
106 #define E_POWER_STATE_SLEEP 0x50
107 #define E_POWER_STATE_RESUME 0x58
109 #define MAX_RETRIES 3
110 #define MAX_FW_UPDATE_RETRIES 30
112 #define ELAN_FW_PAGESIZE 132
114 /* calibration timeout definition */
115 #define ELAN_CALI_TIMEOUT_MSEC 12000
117 #define ELAN_POWERON_DELAY_USEC 500
118 #define ELAN_RESET_DELAY_MSEC 20
120 /* FW boot code version */
121 #define BC_VER_H_BYTE_FOR_EKTH3900x1_I2C 0x72
122 #define BC_VER_H_BYTE_FOR_EKTH3900x2_I2C 0x82
123 #define BC_VER_H_BYTE_FOR_EKTH3900x3_I2C 0x92
124 #define BC_VER_H_BYTE_FOR_EKTH5312x1_I2C 0x6D
125 #define BC_VER_H_BYTE_FOR_EKTH5312x2_I2C 0x6E
126 #define BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C 0x77
127 #define BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C 0x78
128 #define BC_VER_H_BYTE_FOR_EKTH5312x1_I2C_USB 0x67
129 #define BC_VER_H_BYTE_FOR_EKTH5312x2_I2C_USB 0x68
130 #define BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C_USB 0x74
131 #define BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C_USB 0x75
133 enum elants_chip_id {
140 ELAN_WAIT_QUEUE_HEADER,
141 ELAN_WAIT_RECALIBRATION,
144 enum elants_iap_mode {
145 ELAN_IAP_OPERATIONAL,
149 /* struct elants_data - represents state of Elan touchscreen device */
151 struct i2c_client *client;
152 struct input_dev *input;
154 struct regulator *vcc33;
155 struct regulator *vccio;
156 struct gpio_desc *reset_gpio;
165 unsigned int x_res; /* resolution in units/mm */
171 struct touchscreen_properties prop;
173 enum elants_state state;
174 enum elants_chip_id chip_id;
175 enum elants_iap_mode iap_mode;
177 /* Guards against concurrent access to the device via sysfs */
178 struct mutex sysfs_mutex;
180 u8 cmd_resp[HEADER_SIZE];
181 struct completion cmd_done;
183 bool wake_irq_enabled;
184 bool keep_power_in_suspend;
186 /* Must be last to be used for DMA operations */
187 u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned;
190 static int elants_i2c_send(struct i2c_client *client,
191 const void *data, size_t size)
195 ret = i2c_master_send(client, data, size);
202 dev_err(&client->dev, "%s failed (%*ph): %d\n",
203 __func__, (int)size, data, ret);
208 static int elants_i2c_read(struct i2c_client *client, void *data, size_t size)
212 ret = i2c_master_recv(client, data, size);
219 dev_err(&client->dev, "%s failed: %d\n", __func__, ret);
224 static int elants_i2c_execute_command(struct i2c_client *client,
225 const u8 *cmd, size_t cmd_size,
226 u8 *resp, size_t resp_size,
227 int retries, const char *cmd_name)
229 struct i2c_msg msgs[2];
231 u8 expected_response;
234 case CMD_HEADER_READ:
235 expected_response = CMD_HEADER_RESP;
238 case CMD_HEADER_6B_READ:
239 expected_response = CMD_HEADER_6B_RESP;
242 case CMD_HEADER_ROM_READ:
243 expected_response = CMD_HEADER_ROM_RESP;
247 dev_err(&client->dev, "(%s): invalid command: %*ph\n",
248 cmd_name, (int)cmd_size, cmd);
253 msgs[0].addr = client->addr;
254 msgs[0].flags = client->flags & I2C_M_TEN;
255 msgs[0].len = cmd_size;
256 msgs[0].buf = (u8 *)cmd;
258 msgs[1].addr = client->addr;
259 msgs[1].flags = (client->flags & I2C_M_TEN) | I2C_M_RD;
260 msgs[1].flags |= I2C_M_RD;
261 msgs[1].len = resp_size;
264 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
267 dev_dbg(&client->dev,
268 "(%s) I2C transfer failed: %pe (retrying)\n",
269 cmd_name, ERR_PTR(ret));
273 dev_err(&client->dev,
274 "(%s) I2C transfer failed: %pe\n",
275 cmd_name, ERR_PTR(ret));
279 if (ret != ARRAY_SIZE(msgs) ||
280 resp[FW_HDR_TYPE] != expected_response) {
282 dev_dbg(&client->dev,
283 "(%s) unexpected response: %*ph (retrying)\n",
284 cmd_name, ret, resp);
288 dev_err(&client->dev,
289 "(%s) unexpected response: %*ph\n",
290 cmd_name, ret, resp);
298 static int elants_i2c_calibrate(struct elants_data *ts)
300 struct i2c_client *client = ts->client;
302 static const u8 w_flashkey[] = { CMD_HEADER_WRITE, 0xC0, 0xE1, 0x5A };
303 static const u8 rek[] = { CMD_HEADER_WRITE, 0x29, 0x00, 0x01 };
304 static const u8 rek_resp[] = { CMD_HEADER_REK, 0x66, 0x66, 0x66 };
306 disable_irq(client->irq);
308 ts->state = ELAN_WAIT_RECALIBRATION;
309 reinit_completion(&ts->cmd_done);
311 elants_i2c_send(client, w_flashkey, sizeof(w_flashkey));
312 elants_i2c_send(client, rek, sizeof(rek));
314 enable_irq(client->irq);
316 ret = wait_for_completion_interruptible_timeout(&ts->cmd_done,
317 msecs_to_jiffies(ELAN_CALI_TIMEOUT_MSEC));
319 ts->state = ELAN_STATE_NORMAL;
322 error = ret < 0 ? ret : -ETIMEDOUT;
323 dev_err(&client->dev,
324 "error while waiting for calibration to complete: %d\n",
329 if (memcmp(rek_resp, ts->cmd_resp, sizeof(rek_resp))) {
330 dev_err(&client->dev,
331 "unexpected calibration response: %*ph\n",
332 (int)sizeof(ts->cmd_resp), ts->cmd_resp);
339 static int elants_i2c_sw_reset(struct i2c_client *client)
341 const u8 soft_rst_cmd[] = { 0x77, 0x77, 0x77, 0x77 };
344 error = elants_i2c_send(client, soft_rst_cmd,
345 sizeof(soft_rst_cmd));
347 dev_err(&client->dev, "software reset failed: %d\n", error);
352 * We should wait at least 10 msec (but no more than 40) before
353 * sending fastboot or IAP command to the device.
360 static u16 elants_i2c_parse_version(u8 *buf)
362 return get_unaligned_be32(buf) >> 4;
365 static int elants_i2c_query_hw_version(struct elants_data *ts)
367 struct i2c_client *client = ts->client;
368 int retry_cnt = MAX_RETRIES;
369 const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_FW_ID, 0x00, 0x01 };
370 u8 resp[HEADER_SIZE];
373 while (retry_cnt--) {
374 error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
375 resp, sizeof(resp), 1,
380 ts->hw_version = elants_i2c_parse_version(resp);
381 if (ts->hw_version != 0xffff)
385 dev_err(&client->dev, "Invalid fw id: %#04x\n", ts->hw_version);
390 static int elants_i2c_query_fw_version(struct elants_data *ts)
392 struct i2c_client *client = ts->client;
393 int retry_cnt = MAX_RETRIES;
394 const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_FW_VER, 0x00, 0x01 };
395 u8 resp[HEADER_SIZE];
398 while (retry_cnt--) {
399 error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
400 resp, sizeof(resp), 1,
405 ts->fw_version = elants_i2c_parse_version(resp);
406 if (ts->fw_version != 0x0000 && ts->fw_version != 0xffff)
409 dev_dbg(&client->dev, "(read fw version) resp %*phC\n",
410 (int)sizeof(resp), resp);
413 dev_err(&client->dev, "Invalid fw ver: %#04x\n", ts->fw_version);
418 static int elants_i2c_query_test_version(struct elants_data *ts)
420 struct i2c_client *client = ts->client;
423 const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_TEST_VER, 0x00, 0x01 };
424 u8 resp[HEADER_SIZE];
426 error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
427 resp, sizeof(resp), MAX_RETRIES,
428 "read test version");
430 dev_err(&client->dev, "Failed to read test version\n");
434 version = elants_i2c_parse_version(resp);
435 ts->test_version = version >> 8;
436 ts->solution_version = version & 0xff;
441 static int elants_i2c_query_bc_version(struct elants_data *ts)
443 struct i2c_client *client = ts->client;
444 const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_BC_VER, 0x00, 0x01 };
445 u8 resp[HEADER_SIZE];
449 error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
450 resp, sizeof(resp), 1,
455 version = elants_i2c_parse_version(resp);
456 ts->bc_version = version >> 8;
457 ts->iap_version = version & 0xff;
462 static int elants_i2c_query_ts_info_ektf(struct elants_data *ts)
464 struct i2c_client *client = ts->client;
468 const u8 get_xres_cmd[] = {
469 CMD_HEADER_READ, E_ELAN_INFO_X_RES, 0x00, 0x00
471 const u8 get_yres_cmd[] = {
472 CMD_HEADER_READ, E_ELAN_INFO_Y_RES, 0x00, 0x00
475 /* Get X/Y size in mm */
476 error = elants_i2c_execute_command(client, get_xres_cmd,
477 sizeof(get_xres_cmd),
478 resp, sizeof(resp), 1,
483 phy_x = resp[2] | ((resp[3] & 0xF0) << 4);
485 error = elants_i2c_execute_command(client, get_yres_cmd,
486 sizeof(get_yres_cmd),
487 resp, sizeof(resp), 1,
492 phy_y = resp[2] | ((resp[3] & 0xF0) << 4);
494 dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y);
499 /* eKTF doesn't report max size, set it to default values */
500 ts->x_max = 2240 - 1;
501 ts->y_max = 1408 - 1;
506 static int elants_i2c_query_ts_info_ekth(struct elants_data *ts)
508 struct i2c_client *client = ts->client;
511 u16 phy_x, phy_y, rows, cols, osr;
512 const u8 get_resolution_cmd[] = {
513 CMD_HEADER_6B_READ, 0x00, 0x00, 0x00, 0x00, 0x00
515 const u8 get_osr_cmd[] = {
516 CMD_HEADER_READ, E_INFO_OSR, 0x00, 0x01
518 const u8 get_physical_scan_cmd[] = {
519 CMD_HEADER_READ, E_INFO_PHY_SCAN, 0x00, 0x01
521 const u8 get_physical_drive_cmd[] = {
522 CMD_HEADER_READ, E_INFO_PHY_DRIVER, 0x00, 0x01
525 /* Get trace number */
526 error = elants_i2c_execute_command(client,
528 sizeof(get_resolution_cmd),
529 resp, sizeof(resp), 1,
534 rows = resp[2] + resp[6] + resp[10];
535 cols = resp[3] + resp[7] + resp[11];
537 /* Get report resolution value of ABS_MT_TOUCH_MAJOR */
538 ts->major_res = resp[16];
540 /* Process mm_to_pixel information */
541 error = elants_i2c_execute_command(client,
542 get_osr_cmd, sizeof(get_osr_cmd),
543 resp, sizeof(resp), 1, "get osr");
549 error = elants_i2c_execute_command(client,
550 get_physical_scan_cmd,
551 sizeof(get_physical_scan_cmd),
552 resp, sizeof(resp), 1,
553 "get physical scan");
557 phy_x = get_unaligned_be16(&resp[2]);
559 error = elants_i2c_execute_command(client,
560 get_physical_drive_cmd,
561 sizeof(get_physical_drive_cmd),
562 resp, sizeof(resp), 1,
563 "get physical drive");
567 phy_y = get_unaligned_be16(&resp[2]);
569 dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y);
571 if (rows == 0 || cols == 0 || osr == 0) {
572 dev_warn(&client->dev,
573 "invalid trace number data: %d, %d, %d\n",
576 /* translate trace number to TS resolution */
577 ts->x_max = ELAN_TS_RESOLUTION(rows, osr);
578 ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x);
579 ts->y_max = ELAN_TS_RESOLUTION(cols, osr);
580 ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y);
588 static int elants_i2c_fastboot(struct i2c_client *client)
590 const u8 boot_cmd[] = { 0x4D, 0x61, 0x69, 0x6E };
593 error = elants_i2c_send(client, boot_cmd, sizeof(boot_cmd));
595 dev_err(&client->dev, "boot failed: %d\n", error);
599 dev_dbg(&client->dev, "boot success -- 0x%x\n", client->addr);
603 static int elants_i2c_initialize(struct elants_data *ts)
605 struct i2c_client *client = ts->client;
606 int error, error2, retry_cnt;
607 const u8 hello_packet[] = { 0x55, 0x55, 0x55, 0x55 };
608 const u8 recov_packet[] = { 0x55, 0x55, 0x80, 0x80 };
611 for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
612 error = elants_i2c_sw_reset(client);
614 /* Continue initializing if it's the last try */
615 if (retry_cnt < MAX_RETRIES - 1)
619 error = elants_i2c_fastboot(client);
621 /* Continue initializing if it's the last try */
622 if (retry_cnt < MAX_RETRIES - 1)
626 /* Wait for Hello packet */
627 msleep(BOOT_TIME_DELAY_MS);
629 error = elants_i2c_read(client, buf, sizeof(buf));
631 dev_err(&client->dev,
632 "failed to read 'hello' packet: %d\n", error);
633 } else if (!memcmp(buf, hello_packet, sizeof(hello_packet))) {
634 ts->iap_mode = ELAN_IAP_OPERATIONAL;
636 } else if (!memcmp(buf, recov_packet, sizeof(recov_packet))) {
638 * Setting error code will mark device
639 * in recovery mode below.
645 dev_err(&client->dev,
646 "invalid 'hello' packet: %*ph\n",
647 (int)sizeof(buf), buf);
651 /* hw version is available even if device in recovery state */
652 error2 = elants_i2c_query_hw_version(ts);
654 error2 = elants_i2c_query_bc_version(ts);
659 error = elants_i2c_query_fw_version(ts);
661 error = elants_i2c_query_test_version(ts);
663 switch (ts->chip_id) {
666 error = elants_i2c_query_ts_info_ekth(ts);
670 error = elants_i2c_query_ts_info_ektf(ts);
677 ts->iap_mode = ELAN_IAP_RECOVERY;
683 * Firmware update interface.
686 static int elants_i2c_fw_write_page(struct i2c_client *client,
689 const u8 ack_ok[] = { 0xaa, 0xaa };
694 for (retry = 0; retry < MAX_FW_UPDATE_RETRIES; retry++) {
695 error = elants_i2c_send(client, page, ELAN_FW_PAGESIZE);
697 dev_err(&client->dev,
698 "IAP Write Page failed: %d\n", error);
702 error = elants_i2c_read(client, buf, 2);
704 dev_err(&client->dev,
705 "IAP Ack read failed: %d\n", error);
709 if (!memcmp(buf, ack_ok, sizeof(ack_ok)))
713 dev_err(&client->dev,
714 "IAP Get Ack Error [%02x:%02x]\n",
721 static int elants_i2c_validate_remark_id(struct elants_data *ts,
722 const struct firmware *fw)
724 struct i2c_client *client = ts->client;
726 const u8 cmd[] = { CMD_HEADER_ROM_READ, 0x80, 0x1F, 0x00, 0x00, 0x21 };
728 u16 ts_remark_id = 0;
729 u16 fw_remark_id = 0;
731 /* Compare TS Remark ID and FW Remark ID */
732 error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
734 1, "read Remark ID");
738 ts_remark_id = get_unaligned_be16(&resp[3]);
740 fw_remark_id = get_unaligned_le16(&fw->data[fw->size - 4]);
742 if (fw_remark_id != ts_remark_id) {
743 dev_err(&client->dev,
744 "Remark ID Mismatched: ts_remark_id=0x%04x, fw_remark_id=0x%04x.\n",
745 ts_remark_id, fw_remark_id);
752 static bool elants_i2c_should_check_remark_id(struct elants_data *ts)
754 struct i2c_client *client = ts->client;
755 const u8 bootcode_version = ts->iap_version;
758 /* I2C eKTH3900 and eKTH5312 are NOT support Remark ID */
759 if ((bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x1_I2C) ||
760 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x2_I2C) ||
761 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH3900x3_I2C) ||
762 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x1_I2C) ||
763 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x2_I2C) ||
764 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C) ||
765 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C) ||
766 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x1_I2C_USB) ||
767 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312x2_I2C_USB) ||
768 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx1_I2C_USB) ||
769 (bootcode_version == BC_VER_H_BYTE_FOR_EKTH5312cx2_I2C_USB)) {
770 dev_dbg(&client->dev,
771 "eKTH3900/eKTH5312(0x%02x) are not support remark id\n",
774 } else if (bootcode_version >= 0x60) {
783 static int elants_i2c_do_update_firmware(struct i2c_client *client,
784 const struct firmware *fw,
787 struct elants_data *ts = i2c_get_clientdata(client);
788 const u8 enter_iap[] = { 0x45, 0x49, 0x41, 0x50 };
789 const u8 enter_iap2[] = { 0x54, 0x00, 0x12, 0x34 };
790 const u8 iap_ack[] = { 0x55, 0xaa, 0x33, 0xcc };
791 const u8 close_idle[] = { 0x54, 0x2c, 0x01, 0x01 };
794 int page, n_fw_pages;
796 bool check_remark_id = elants_i2c_should_check_remark_id(ts);
798 /* Recovery mode detection! */
800 dev_dbg(&client->dev, "Recovery mode procedure\n");
802 if (check_remark_id) {
803 error = elants_i2c_validate_remark_id(ts, fw);
808 error = elants_i2c_send(client, enter_iap2, sizeof(enter_iap2));
810 dev_err(&client->dev, "failed to enter IAP mode: %d\n",
815 /* Start IAP Procedure */
816 dev_dbg(&client->dev, "Normal IAP procedure\n");
818 /* Close idle mode */
819 error = elants_i2c_send(client, close_idle, sizeof(close_idle));
821 dev_err(&client->dev, "Failed close idle: %d\n", error);
824 elants_i2c_sw_reset(client);
827 if (check_remark_id) {
828 error = elants_i2c_validate_remark_id(ts, fw);
833 error = elants_i2c_send(client, enter_iap, sizeof(enter_iap));
835 dev_err(&client->dev, "failed to enter IAP mode: %d\n",
843 /* check IAP state */
844 error = elants_i2c_read(client, buf, 4);
846 dev_err(&client->dev,
847 "failed to read IAP acknowledgement: %d\n",
852 if (memcmp(buf, iap_ack, sizeof(iap_ack))) {
853 dev_err(&client->dev,
854 "failed to enter IAP: %*ph (expected %*ph)\n",
855 (int)sizeof(buf), buf, (int)sizeof(iap_ack), iap_ack);
859 dev_info(&client->dev, "successfully entered IAP mode");
861 send_id = client->addr;
862 error = elants_i2c_send(client, &send_id, 1);
864 dev_err(&client->dev, "sending dummy byte failed: %d\n",
869 /* Clear the last page of Master */
870 error = elants_i2c_send(client, fw->data, ELAN_FW_PAGESIZE);
872 dev_err(&client->dev, "clearing of the last page failed: %d\n",
877 error = elants_i2c_read(client, buf, 2);
879 dev_err(&client->dev,
880 "failed to read ACK for clearing the last page: %d\n",
885 n_fw_pages = fw->size / ELAN_FW_PAGESIZE;
886 dev_dbg(&client->dev, "IAP Pages = %d\n", n_fw_pages);
888 for (page = 0; page < n_fw_pages; page++) {
889 error = elants_i2c_fw_write_page(client,
890 fw->data + page * ELAN_FW_PAGESIZE);
892 dev_err(&client->dev,
893 "failed to write FW page %d: %d\n",
899 /* Old iap needs to wait 200ms for WDT and rest is for hello packets */
902 dev_info(&client->dev, "firmware update completed\n");
906 static int elants_i2c_fw_update(struct elants_data *ts)
908 struct i2c_client *client = ts->client;
909 const struct firmware *fw;
913 fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%04x.bin", ts->hw_version);
917 dev_info(&client->dev, "requesting fw name = %s\n", fw_name);
918 error = request_firmware(&fw, fw_name, &client->dev);
921 dev_err(&client->dev, "failed to request firmware: %d\n",
926 if (fw->size % ELAN_FW_PAGESIZE) {
927 dev_err(&client->dev, "invalid firmware length: %zu\n",
933 disable_irq(client->irq);
935 error = elants_i2c_do_update_firmware(client, fw,
936 ts->iap_mode == ELAN_IAP_RECOVERY);
938 dev_err(&client->dev, "firmware update failed: %d\n", error);
939 ts->iap_mode = ELAN_IAP_RECOVERY;
943 error = elants_i2c_initialize(ts);
945 dev_err(&client->dev,
946 "failed to initialize device after firmware update: %d\n",
948 ts->iap_mode = ELAN_IAP_RECOVERY;
952 ts->iap_mode = ELAN_IAP_OPERATIONAL;
955 ts->state = ELAN_STATE_NORMAL;
956 enable_irq(client->irq);
960 elants_i2c_calibrate(ts);
962 release_firmware(fw);
970 static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf,
973 struct input_dev *input = ts->input;
974 unsigned int n_fingers;
975 unsigned int tool_type;
979 n_fingers = buf[FW_POS_STATE + 1] & 0x0f;
980 finger_state = ((buf[FW_POS_STATE + 1] & 0x30) << 4) |
983 dev_dbg(&ts->client->dev,
984 "n_fingers: %u, state: %04x\n", n_fingers, finger_state);
986 /* Note: all fingers have the same tool type */
987 tool_type = buf[FW_POS_TOOL_TYPE] & BIT(0) ?
988 MT_TOOL_FINGER : MT_TOOL_PALM;
990 for (i = 0; i < MAX_CONTACT_NUM && n_fingers; i++) {
991 if (finger_state & 1) {
992 unsigned int x, y, p, w;
995 pos = &buf[FW_POS_XY + i * 3];
996 x = (((u16)pos[0] & 0xf0) << 4) | pos[1];
997 y = (((u16)pos[0] & 0x0f) << 8) | pos[2];
1000 * eKTF3624 may have use "old" touch-report format,
1001 * depending on a device and TS firmware version.
1002 * For example, ASUS Transformer devices use the "old"
1003 * format, while ASUS Nexus 7 uses the "new" formant.
1005 if (packet_size == PACKET_SIZE_OLD &&
1006 ts->chip_id == EKTF3624) {
1007 w = buf[FW_POS_WIDTH + i / 2];
1013 p = buf[FW_POS_PRESSURE + i];
1014 w = buf[FW_POS_WIDTH + i];
1017 dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n",
1020 input_mt_slot(input, i);
1021 input_mt_report_slot_state(input, tool_type, true);
1022 touchscreen_report_pos(input, &ts->prop, x, y, true);
1023 input_event(input, EV_ABS, ABS_MT_PRESSURE, p);
1024 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, w);
1032 input_mt_sync_frame(input);
1036 static u8 elants_i2c_calculate_checksum(u8 *buf)
1041 for (i = 0; i < FW_POS_CHECKSUM; i++)
1047 static void elants_i2c_event(struct elants_data *ts, u8 *buf,
1050 u8 checksum = elants_i2c_calculate_checksum(buf);
1052 if (unlikely(buf[FW_POS_CHECKSUM] != checksum))
1053 dev_warn(&ts->client->dev,
1054 "%s: invalid checksum for packet %02x: %02x vs. %02x\n",
1055 __func__, buf[FW_POS_HEADER],
1056 checksum, buf[FW_POS_CHECKSUM]);
1057 else if (unlikely(buf[FW_POS_HEADER] != HEADER_REPORT_10_FINGER))
1058 dev_warn(&ts->client->dev,
1059 "%s: unknown packet type: %02x\n",
1060 __func__, buf[FW_POS_HEADER]);
1062 elants_i2c_mt_event(ts, buf, packet_size);
1065 static irqreturn_t elants_i2c_irq(int irq, void *_dev)
1067 const u8 wait_packet[] = { 0x64, 0x64, 0x64, 0x64 };
1068 struct elants_data *ts = _dev;
1069 struct i2c_client *client = ts->client;
1070 int report_count, report_len;
1074 len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf));
1076 dev_err(&client->dev, "%s: failed to read data: %d\n",
1081 dev_dbg(&client->dev, "%s: packet %*ph\n",
1082 __func__, HEADER_SIZE, ts->buf);
1084 switch (ts->state) {
1085 case ELAN_WAIT_RECALIBRATION:
1086 if (ts->buf[FW_HDR_TYPE] == CMD_HEADER_REK) {
1087 memcpy(ts->cmd_resp, ts->buf, sizeof(ts->cmd_resp));
1088 complete(&ts->cmd_done);
1089 ts->state = ELAN_STATE_NORMAL;
1093 case ELAN_WAIT_QUEUE_HEADER:
1094 if (ts->buf[FW_HDR_TYPE] != QUEUE_HEADER_NORMAL)
1097 ts->state = ELAN_STATE_NORMAL;
1100 case ELAN_STATE_NORMAL:
1102 switch (ts->buf[FW_HDR_TYPE]) {
1103 case CMD_HEADER_HELLO:
1104 case CMD_HEADER_RESP:
1107 case QUEUE_HEADER_WAIT:
1108 if (memcmp(ts->buf, wait_packet, sizeof(wait_packet))) {
1109 dev_err(&client->dev,
1110 "invalid wait packet %*ph\n",
1111 HEADER_SIZE, ts->buf);
1113 ts->state = ELAN_WAIT_QUEUE_HEADER;
1118 case QUEUE_HEADER_SINGLE:
1119 elants_i2c_event(ts, &ts->buf[HEADER_SIZE],
1120 ts->buf[FW_HDR_LENGTH]);
1123 case QUEUE_HEADER_NORMAL2: /* CMD_HEADER_REK */
1125 * Depending on firmware version, eKTF3624 touchscreens
1126 * may utilize one of these opcodes for the touch events:
1127 * 0x63 (NORMAL) and 0x66 (NORMAL2). The 0x63 is used by
1128 * older firmware version and differs from 0x66 such that
1129 * touch pressure value needs to be adjusted. The 0x66
1130 * opcode of newer firmware is equal to 0x63 of eKTH3500.
1132 if (ts->chip_id != EKTF3624)
1137 case QUEUE_HEADER_NORMAL:
1138 report_count = ts->buf[FW_HDR_COUNT];
1139 if (report_count == 0 || report_count > 3) {
1140 dev_err(&client->dev,
1141 "bad report count: %*ph\n",
1142 HEADER_SIZE, ts->buf);
1146 report_len = ts->buf[FW_HDR_LENGTH] / report_count;
1148 if (report_len == PACKET_SIZE_OLD &&
1149 ts->chip_id == EKTF3624) {
1150 dev_dbg_once(&client->dev,
1151 "using old report format\n");
1152 } else if (report_len != PACKET_SIZE) {
1153 dev_err(&client->dev,
1154 "mismatching report length: %*ph\n",
1155 HEADER_SIZE, ts->buf);
1159 for (i = 0; i < report_count; i++) {
1160 u8 *buf = ts->buf + HEADER_SIZE +
1162 elants_i2c_event(ts, buf, report_len);
1167 dev_err(&client->dev, "unknown packet %*ph\n",
1168 HEADER_SIZE, ts->buf);
1181 static ssize_t calibrate_store(struct device *dev,
1182 struct device_attribute *attr,
1183 const char *buf, size_t count)
1185 struct i2c_client *client = to_i2c_client(dev);
1186 struct elants_data *ts = i2c_get_clientdata(client);
1189 error = mutex_lock_interruptible(&ts->sysfs_mutex);
1193 error = elants_i2c_calibrate(ts);
1195 mutex_unlock(&ts->sysfs_mutex);
1196 return error ?: count;
1199 static ssize_t write_update_fw(struct device *dev,
1200 struct device_attribute *attr,
1201 const char *buf, size_t count)
1203 struct i2c_client *client = to_i2c_client(dev);
1204 struct elants_data *ts = i2c_get_clientdata(client);
1207 error = mutex_lock_interruptible(&ts->sysfs_mutex);
1211 error = elants_i2c_fw_update(ts);
1212 dev_dbg(dev, "firmware update result: %d\n", error);
1214 mutex_unlock(&ts->sysfs_mutex);
1215 return error ?: count;
1218 static ssize_t show_iap_mode(struct device *dev,
1219 struct device_attribute *attr, char *buf)
1221 struct i2c_client *client = to_i2c_client(dev);
1222 struct elants_data *ts = i2c_get_clientdata(client);
1224 return sprintf(buf, "%s\n",
1225 ts->iap_mode == ELAN_IAP_OPERATIONAL ?
1226 "Normal" : "Recovery");
1229 static ssize_t show_calibration_count(struct device *dev,
1230 struct device_attribute *attr, char *buf)
1232 struct i2c_client *client = to_i2c_client(dev);
1233 const u8 cmd[] = { CMD_HEADER_READ, E_ELAN_INFO_REK, 0x00, 0x01 };
1234 u8 resp[HEADER_SIZE];
1238 error = elants_i2c_execute_command(client, cmd, sizeof(cmd),
1239 resp, sizeof(resp), 1,
1242 return sprintf(buf, "%d\n", error);
1244 rek_count = get_unaligned_be16(&resp[2]);
1245 return sprintf(buf, "0x%04x\n", rek_count);
1248 static DEVICE_ATTR_WO(calibrate);
1249 static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
1250 static DEVICE_ATTR(calibration_count, S_IRUGO, show_calibration_count, NULL);
1251 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
1253 struct elants_version_attribute {
1254 struct device_attribute dattr;
1255 size_t field_offset;
1259 #define __ELANTS_FIELD_SIZE(_field) \
1260 sizeof(((struct elants_data *)NULL)->_field)
1261 #define __ELANTS_VERIFY_SIZE(_field) \
1262 (BUILD_BUG_ON_ZERO(__ELANTS_FIELD_SIZE(_field) > 2) + \
1263 __ELANTS_FIELD_SIZE(_field))
1264 #define ELANTS_VERSION_ATTR(_field) \
1265 struct elants_version_attribute elants_ver_attr_##_field = { \
1266 .dattr = __ATTR(_field, S_IRUGO, \
1267 elants_version_attribute_show, NULL), \
1268 .field_offset = offsetof(struct elants_data, _field), \
1269 .field_size = __ELANTS_VERIFY_SIZE(_field), \
1272 static ssize_t elants_version_attribute_show(struct device *dev,
1273 struct device_attribute *dattr,
1276 struct i2c_client *client = to_i2c_client(dev);
1277 struct elants_data *ts = i2c_get_clientdata(client);
1278 struct elants_version_attribute *attr =
1279 container_of(dattr, struct elants_version_attribute, dattr);
1280 u8 *field = (u8 *)((char *)ts + attr->field_offset);
1281 unsigned int fmt_size;
1284 if (attr->field_size == 1) {
1286 fmt_size = 2; /* 2 HEX digits */
1288 val = *(u16 *)field;
1289 fmt_size = 4; /* 4 HEX digits */
1292 return sprintf(buf, "%0*x\n", fmt_size, val);
1295 static ELANTS_VERSION_ATTR(fw_version);
1296 static ELANTS_VERSION_ATTR(hw_version);
1297 static ELANTS_VERSION_ATTR(test_version);
1298 static ELANTS_VERSION_ATTR(solution_version);
1299 static ELANTS_VERSION_ATTR(bc_version);
1300 static ELANTS_VERSION_ATTR(iap_version);
1302 static struct attribute *elants_attributes[] = {
1303 &dev_attr_calibrate.attr,
1304 &dev_attr_update_fw.attr,
1305 &dev_attr_iap_mode.attr,
1306 &dev_attr_calibration_count.attr,
1308 &elants_ver_attr_fw_version.dattr.attr,
1309 &elants_ver_attr_hw_version.dattr.attr,
1310 &elants_ver_attr_test_version.dattr.attr,
1311 &elants_ver_attr_solution_version.dattr.attr,
1312 &elants_ver_attr_bc_version.dattr.attr,
1313 &elants_ver_attr_iap_version.dattr.attr,
1317 static const struct attribute_group elants_attribute_group = {
1318 .attrs = elants_attributes,
1321 static int elants_i2c_power_on(struct elants_data *ts)
1326 * If we do not have reset gpio assume platform firmware
1327 * controls regulators and does power them on for us.
1329 if (IS_ERR_OR_NULL(ts->reset_gpio))
1332 gpiod_set_value_cansleep(ts->reset_gpio, 1);
1334 error = regulator_enable(ts->vcc33);
1336 dev_err(&ts->client->dev,
1337 "failed to enable vcc33 regulator: %d\n",
1339 goto release_reset_gpio;
1342 error = regulator_enable(ts->vccio);
1344 dev_err(&ts->client->dev,
1345 "failed to enable vccio regulator: %d\n",
1347 regulator_disable(ts->vcc33);
1348 goto release_reset_gpio;
1352 * We need to wait a bit after powering on controller before
1353 * we are allowed to release reset GPIO.
1355 udelay(ELAN_POWERON_DELAY_USEC);
1358 gpiod_set_value_cansleep(ts->reset_gpio, 0);
1362 msleep(ELAN_RESET_DELAY_MSEC);
1367 static void elants_i2c_power_off(void *_data)
1369 struct elants_data *ts = _data;
1371 if (!IS_ERR_OR_NULL(ts->reset_gpio)) {
1373 * Activate reset gpio to prevent leakage through the
1374 * pin once we shut off power to the controller.
1376 gpiod_set_value_cansleep(ts->reset_gpio, 1);
1377 regulator_disable(ts->vccio);
1378 regulator_disable(ts->vcc33);
1383 static const struct acpi_device_id i2c_hid_ids[] = {
1389 static const guid_t i2c_hid_guid =
1390 GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
1391 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
1393 static bool elants_acpi_is_hid_device(struct device *dev)
1395 acpi_handle handle = ACPI_HANDLE(dev);
1396 union acpi_object *obj;
1398 if (acpi_match_device_ids(ACPI_COMPANION(dev), i2c_hid_ids))
1401 obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL, ACPI_TYPE_INTEGER);
1410 static bool elants_acpi_is_hid_device(struct device *dev)
1416 static int elants_i2c_probe(struct i2c_client *client)
1418 union i2c_smbus_data dummy;
1419 struct elants_data *ts;
1420 unsigned long irqflags;
1423 /* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */
1424 if (elants_acpi_is_hid_device(&client->dev)) {
1425 dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n");
1429 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
1430 dev_err(&client->dev, "I2C check functionality error\n");
1434 ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL);
1438 mutex_init(&ts->sysfs_mutex);
1439 init_completion(&ts->cmd_done);
1441 ts->client = client;
1442 ts->chip_id = (enum elants_chip_id)(uintptr_t)device_get_match_data(&client->dev);
1443 i2c_set_clientdata(client, ts);
1445 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
1446 if (IS_ERR(ts->vcc33)) {
1447 error = PTR_ERR(ts->vcc33);
1448 if (error != -EPROBE_DEFER)
1449 dev_err(&client->dev,
1450 "Failed to get 'vcc33' regulator: %d\n",
1455 ts->vccio = devm_regulator_get(&client->dev, "vccio");
1456 if (IS_ERR(ts->vccio)) {
1457 error = PTR_ERR(ts->vccio);
1458 if (error != -EPROBE_DEFER)
1459 dev_err(&client->dev,
1460 "Failed to get 'vccio' regulator: %d\n",
1465 ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);
1466 if (IS_ERR(ts->reset_gpio)) {
1467 error = PTR_ERR(ts->reset_gpio);
1469 if (error == -EPROBE_DEFER)
1472 if (error != -ENOENT && error != -ENOSYS) {
1473 dev_err(&client->dev,
1474 "failed to get reset gpio: %d\n",
1479 ts->keep_power_in_suspend = true;
1482 error = elants_i2c_power_on(ts);
1486 error = devm_add_action_or_reset(&client->dev,
1487 elants_i2c_power_off, ts);
1489 dev_err(&client->dev,
1490 "failed to install power off action: %d\n", error);
1494 /* Make sure there is something at this address */
1495 if (i2c_smbus_xfer(client->adapter, client->addr, 0,
1496 I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) {
1497 dev_err(&client->dev, "nothing at this address\n");
1501 error = elants_i2c_initialize(ts);
1503 dev_err(&client->dev, "failed to initialize: %d\n", error);
1507 ts->input = devm_input_allocate_device(&client->dev);
1509 dev_err(&client->dev, "Failed to allocate input device\n");
1513 ts->input->name = "Elan Touchscreen";
1514 ts->input->id.bustype = BUS_I2C;
1516 /* Multitouch input params setup */
1518 input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
1519 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
1520 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
1521 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
1522 input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE,
1523 0, MT_TOOL_PALM, 0, 0);
1525 touchscreen_parse_properties(ts->input, true, &ts->prop);
1527 if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) {
1528 /* calculate resolution from size */
1529 ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x);
1530 ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y);
1533 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
1534 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
1535 input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res);
1537 error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
1538 INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
1540 dev_err(&client->dev,
1541 "failed to initialize MT slots: %d\n", error);
1545 error = input_register_device(ts->input);
1547 dev_err(&client->dev,
1548 "unable to register input device: %d\n", error);
1553 * Platform code (ACPI, DTS) should normally set up interrupt
1554 * for us, but in case it did not let's fall back to using falling
1555 * edge to be compatible with older Chromebooks.
1557 irqflags = irq_get_trigger_type(client->irq);
1559 irqflags = IRQF_TRIGGER_FALLING;
1561 error = devm_request_threaded_irq(&client->dev, client->irq,
1562 NULL, elants_i2c_irq,
1563 irqflags | IRQF_ONESHOT,
1566 dev_err(&client->dev, "Failed to register interrupt\n");
1571 * Systems using device tree should set up wakeup via DTS,
1572 * the rest will configure device as wakeup source by default.
1574 if (!client->dev.of_node)
1575 device_init_wakeup(&client->dev, true);
1577 error = devm_device_add_group(&client->dev, &elants_attribute_group);
1579 dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
1587 static int __maybe_unused elants_i2c_suspend(struct device *dev)
1589 struct i2c_client *client = to_i2c_client(dev);
1590 struct elants_data *ts = i2c_get_clientdata(client);
1591 const u8 set_sleep_cmd[] = {
1592 CMD_HEADER_WRITE, E_POWER_STATE_SLEEP, 0x00, 0x01
1597 /* Command not support in IAP recovery mode */
1598 if (ts->iap_mode != ELAN_IAP_OPERATIONAL)
1601 disable_irq(client->irq);
1603 if (device_may_wakeup(dev)) {
1605 * The device will automatically enter idle mode
1606 * that has reduced power consumption.
1608 ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0);
1609 } else if (ts->keep_power_in_suspend) {
1610 for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
1611 error = elants_i2c_send(client, set_sleep_cmd,
1612 sizeof(set_sleep_cmd));
1616 dev_err(&client->dev,
1617 "suspend command failed: %d\n", error);
1620 elants_i2c_power_off(ts);
1626 static int __maybe_unused elants_i2c_resume(struct device *dev)
1628 struct i2c_client *client = to_i2c_client(dev);
1629 struct elants_data *ts = i2c_get_clientdata(client);
1630 const u8 set_active_cmd[] = {
1631 CMD_HEADER_WRITE, E_POWER_STATE_RESUME, 0x00, 0x01
1636 if (device_may_wakeup(dev)) {
1637 if (ts->wake_irq_enabled)
1638 disable_irq_wake(client->irq);
1639 elants_i2c_sw_reset(client);
1640 } else if (ts->keep_power_in_suspend) {
1641 for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
1642 error = elants_i2c_send(client, set_active_cmd,
1643 sizeof(set_active_cmd));
1647 dev_err(&client->dev,
1648 "resume command failed: %d\n", error);
1651 elants_i2c_power_on(ts);
1652 elants_i2c_initialize(ts);
1655 ts->state = ELAN_STATE_NORMAL;
1656 enable_irq(client->irq);
1661 static SIMPLE_DEV_PM_OPS(elants_i2c_pm_ops,
1662 elants_i2c_suspend, elants_i2c_resume);
1664 static const struct i2c_device_id elants_i2c_id[] = {
1665 { DEVICE_NAME, EKTH3500 },
1666 { "ekth3500", EKTH3500 },
1667 { "ektf3624", EKTF3624 },
1670 MODULE_DEVICE_TABLE(i2c, elants_i2c_id);
1673 static const struct acpi_device_id elants_acpi_id[] = {
1674 { "ELAN0001", EKTH3500 },
1677 MODULE_DEVICE_TABLE(acpi, elants_acpi_id);
1681 static const struct of_device_id elants_of_match[] = {
1682 { .compatible = "elan,ekth3500", .data = (void *)EKTH3500 },
1683 { .compatible = "elan,ektf3624", .data = (void *)EKTF3624 },
1686 MODULE_DEVICE_TABLE(of, elants_of_match);
1689 static struct i2c_driver elants_i2c_driver = {
1690 .probe_new = elants_i2c_probe,
1691 .id_table = elants_i2c_id,
1693 .name = DEVICE_NAME,
1694 .pm = &elants_i2c_pm_ops,
1695 .acpi_match_table = ACPI_PTR(elants_acpi_id),
1696 .of_match_table = of_match_ptr(elants_of_match),
1697 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
1700 module_i2c_driver(elants_i2c_driver);
1703 MODULE_DESCRIPTION("Elan I2c Touchscreen driver");
1704 MODULE_LICENSE("GPL");