blob: 7239c314c9e9bf398620ee98a11461b9050987ea [file] [log] [blame]
Simon Budig43c4d132012-07-24 23:29:36 -07001/*
2 * Copyright (C) 2012 Simon Budig, <simon.budig@kernelconcepts.de>
Lothar Waßmannfd335ab2014-03-28 09:31:14 -07003 * Daniel Wagener <daniel.wagener@kernelconcepts.de> (M09 firmware support)
Lothar Waßmanndac90dc22014-03-28 09:23:02 -07004 * Lothar Waßmann <LW@KARO-electronics.de> (DT support)
Simon Budig43c4d132012-07-24 23:29:36 -07005 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/*
21 * This is a driver for the EDT "Polytouch" family of touch controllers
22 * based on the FocalTech FT5x06 line of chips.
23 *
24 * Development of this driver has been sponsored by Glyn:
25 * http://www.glyn.com/Products/Displays
26 */
27
28#include <linux/module.h>
29#include <linux/ratelimit.h>
Dmitry Torokhovf0bef752015-09-12 10:11:09 -070030#include <linux/irq.h>
Simon Budig43c4d132012-07-24 23:29:36 -070031#include <linux/interrupt.h>
32#include <linux/input.h>
33#include <linux/i2c.h>
34#include <linux/uaccess.h>
35#include <linux/delay.h>
36#include <linux/debugfs.h>
37#include <linux/slab.h>
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -070038#include <linux/gpio/consumer.h>
Simon Budig43c4d132012-07-24 23:29:36 -070039#include <linux/input/mt.h>
Maxime Ripard2c005592015-03-21 20:18:06 -070040#include <linux/input/touchscreen.h>
Simon Budig43c4d132012-07-24 23:29:36 -070041
42#define MAX_SUPPORT_POINTS 5
43
44#define WORK_REGISTER_THRESHOLD 0x00
45#define WORK_REGISTER_REPORT_RATE 0x08
46#define WORK_REGISTER_GAIN 0x30
47#define WORK_REGISTER_OFFSET 0x31
48#define WORK_REGISTER_NUM_X 0x33
49#define WORK_REGISTER_NUM_Y 0x34
50
Lothar Waßmannfd335ab2014-03-28 09:31:14 -070051#define M09_REGISTER_THRESHOLD 0x80
52#define M09_REGISTER_GAIN 0x92
53#define M09_REGISTER_OFFSET 0x93
54#define M09_REGISTER_NUM_X 0x94
55#define M09_REGISTER_NUM_Y 0x95
56
57#define NO_REGISTER 0xff
58
Simon Budig43c4d132012-07-24 23:29:36 -070059#define WORK_REGISTER_OPMODE 0x3c
60#define FACTORY_REGISTER_OPMODE 0x01
61
62#define TOUCH_EVENT_DOWN 0x00
63#define TOUCH_EVENT_UP 0x01
64#define TOUCH_EVENT_ON 0x02
65#define TOUCH_EVENT_RESERVED 0x03
66
67#define EDT_NAME_LEN 23
68#define EDT_SWITCH_MODE_RETRIES 10
69#define EDT_SWITCH_MODE_DELAY 5 /* msec */
70#define EDT_RAW_DATA_RETRIES 100
71#define EDT_RAW_DATA_DELAY 1 /* msec */
72
Lothar Waßmannfd335ab2014-03-28 09:31:14 -070073enum edt_ver {
74 M06,
75 M09,
76};
77
78struct edt_reg_addr {
79 int reg_threshold;
80 int reg_report_rate;
81 int reg_gain;
82 int reg_offset;
83 int reg_num_x;
84 int reg_num_y;
85};
86
Simon Budig43c4d132012-07-24 23:29:36 -070087struct edt_ft5x06_ts_data {
88 struct i2c_client *client;
89 struct input_dev *input;
90 u16 num_x;
91 u16 num_y;
92
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -070093 struct gpio_desc *reset_gpio;
94 struct gpio_desc *wake_gpio;
Lothar Waßmanndac90dc22014-03-28 09:23:02 -070095
Simon Budig43c4d132012-07-24 23:29:36 -070096#if defined(CONFIG_DEBUG_FS)
97 struct dentry *debug_dir;
98 u8 *raw_buffer;
99 size_t raw_bufsize;
100#endif
101
102 struct mutex mutex;
103 bool factory_mode;
104 int threshold;
105 int gain;
106 int offset;
107 int report_rate;
108
109 char name[EDT_NAME_LEN];
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700110
111 struct edt_reg_addr reg_addr;
112 enum edt_ver version;
Simon Budig43c4d132012-07-24 23:29:36 -0700113};
114
115static int edt_ft5x06_ts_readwrite(struct i2c_client *client,
116 u16 wr_len, u8 *wr_buf,
117 u16 rd_len, u8 *rd_buf)
118{
119 struct i2c_msg wrmsg[2];
120 int i = 0;
121 int ret;
122
123 if (wr_len) {
124 wrmsg[i].addr = client->addr;
125 wrmsg[i].flags = 0;
126 wrmsg[i].len = wr_len;
127 wrmsg[i].buf = wr_buf;
128 i++;
129 }
130 if (rd_len) {
131 wrmsg[i].addr = client->addr;
132 wrmsg[i].flags = I2C_M_RD;
133 wrmsg[i].len = rd_len;
134 wrmsg[i].buf = rd_buf;
135 i++;
136 }
137
138 ret = i2c_transfer(client->adapter, wrmsg, i);
139 if (ret < 0)
140 return ret;
141 if (ret != i)
142 return -EIO;
143
144 return 0;
145}
146
147static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata,
148 u8 *buf, int buflen)
149{
150 int i;
151 u8 crc = 0;
152
153 for (i = 0; i < buflen - 1; i++)
154 crc ^= buf[i];
155
156 if (crc != buf[buflen-1]) {
157 dev_err_ratelimited(&tsdata->client->dev,
158 "crc error: 0x%02x expected, got 0x%02x\n",
159 crc, buf[buflen-1]);
160 return false;
161 }
162
163 return true;
164}
165
166static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
167{
168 struct edt_ft5x06_ts_data *tsdata = dev_id;
169 struct device *dev = &tsdata->client->dev;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700170 u8 cmd;
171 u8 rdbuf[29];
Simon Budig43c4d132012-07-24 23:29:36 -0700172 int i, type, x, y, id;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700173 int offset, tplen, datalen;
Simon Budig43c4d132012-07-24 23:29:36 -0700174 int error;
175
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700176 switch (tsdata->version) {
177 case M06:
178 cmd = 0xf9; /* tell the controller to send touch data */
179 offset = 5; /* where the actual touch data starts */
180 tplen = 4; /* data comes in so called frames */
181 datalen = 26; /* how much bytes to listen for */
182 break;
183
184 case M09:
185 cmd = 0x02;
186 offset = 1;
187 tplen = 6;
188 datalen = 29;
189 break;
190
191 default:
192 goto out;
193 }
194
Simon Budig43c4d132012-07-24 23:29:36 -0700195 memset(rdbuf, 0, sizeof(rdbuf));
196
197 error = edt_ft5x06_ts_readwrite(tsdata->client,
198 sizeof(cmd), &cmd,
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700199 datalen, rdbuf);
Simon Budig43c4d132012-07-24 23:29:36 -0700200 if (error) {
201 dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n",
202 error);
203 goto out;
204 }
205
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700206 /* M09 does not send header or CRC */
207 if (tsdata->version == M06) {
208 if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa ||
209 rdbuf[2] != datalen) {
210 dev_err_ratelimited(dev,
211 "Unexpected header: %02x%02x%02x!\n",
212 rdbuf[0], rdbuf[1], rdbuf[2]);
213 goto out;
214 }
215
216 if (!edt_ft5x06_ts_check_crc(tsdata, rdbuf, datalen))
217 goto out;
Simon Budig43c4d132012-07-24 23:29:36 -0700218 }
219
Simon Budig43c4d132012-07-24 23:29:36 -0700220 for (i = 0; i < MAX_SUPPORT_POINTS; i++) {
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700221 u8 *buf = &rdbuf[i * tplen + offset];
Simon Budig43c4d132012-07-24 23:29:36 -0700222 bool down;
223
224 type = buf[0] >> 6;
225 /* ignore Reserved events */
226 if (type == TOUCH_EVENT_RESERVED)
227 continue;
228
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700229 /* M06 sometimes sends bogus coordinates in TOUCH_DOWN */
230 if (tsdata->version == M06 && type == TOUCH_EVENT_DOWN)
Lothar Waßmannee3e9462014-03-28 09:28:17 -0700231 continue;
232
Simon Budig43c4d132012-07-24 23:29:36 -0700233 x = ((buf[0] << 8) | buf[1]) & 0x0fff;
234 y = ((buf[2] << 8) | buf[3]) & 0x0fff;
235 id = (buf[2] >> 4) & 0x0f;
Lothar Waßmann1730d812014-03-28 09:20:08 -0700236 down = type != TOUCH_EVENT_UP;
Simon Budig43c4d132012-07-24 23:29:36 -0700237
238 input_mt_slot(tsdata->input, id);
239 input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down);
240
241 if (!down)
242 continue;
243
244 input_report_abs(tsdata->input, ABS_MT_POSITION_X, x);
245 input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y);
246 }
247
248 input_mt_report_pointer_emulation(tsdata->input, true);
249 input_sync(tsdata->input);
250
251out:
252 return IRQ_HANDLED;
253}
254
255static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata,
256 u8 addr, u8 value)
257{
258 u8 wrbuf[4];
259
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700260 switch (tsdata->version) {
261 case M06:
262 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc;
263 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700264 wrbuf[2] = value;
265 wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2];
266 return edt_ft5x06_ts_readwrite(tsdata->client, 4,
267 wrbuf, 0, NULL);
268 case M09:
269 wrbuf[0] = addr;
270 wrbuf[1] = value;
Simon Budig43c4d132012-07-24 23:29:36 -0700271
Robert Woerlecc071ac2014-06-07 22:20:23 -0700272 return edt_ft5x06_ts_readwrite(tsdata->client, 2,
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700273 wrbuf, 0, NULL);
274
275 default:
276 return -EINVAL;
277 }
Simon Budig43c4d132012-07-24 23:29:36 -0700278}
279
280static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata,
281 u8 addr)
282{
283 u8 wrbuf[2], rdbuf[2];
284 int error;
285
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700286 switch (tsdata->version) {
287 case M06:
288 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc;
289 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f;
290 wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40;
Simon Budig43c4d132012-07-24 23:29:36 -0700291
Dan Carpentere2c3ecf2014-04-03 09:17:05 -0700292 error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2,
293 rdbuf);
294 if (error)
295 return error;
Simon Budig43c4d132012-07-24 23:29:36 -0700296
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700297 if ((wrbuf[0] ^ wrbuf[1] ^ rdbuf[0]) != rdbuf[1]) {
298 dev_err(&tsdata->client->dev,
299 "crc error: 0x%02x expected, got 0x%02x\n",
300 wrbuf[0] ^ wrbuf[1] ^ rdbuf[0],
301 rdbuf[1]);
302 return -EIO;
303 }
304 break;
305
306 case M09:
307 wrbuf[0] = addr;
308 error = edt_ft5x06_ts_readwrite(tsdata->client, 1,
309 wrbuf, 1, rdbuf);
310 if (error)
311 return error;
312 break;
313
314 default:
315 return -EINVAL;
Simon Budig43c4d132012-07-24 23:29:36 -0700316 }
317
318 return rdbuf[0];
319}
320
321struct edt_ft5x06_attribute {
322 struct device_attribute dattr;
323 size_t field_offset;
324 u8 limit_low;
325 u8 limit_high;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700326 u8 addr_m06;
327 u8 addr_m09;
Simon Budig43c4d132012-07-24 23:29:36 -0700328};
329
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700330#define EDT_ATTR(_field, _mode, _addr_m06, _addr_m09, \
331 _limit_low, _limit_high) \
Simon Budig43c4d132012-07-24 23:29:36 -0700332 struct edt_ft5x06_attribute edt_ft5x06_attr_##_field = { \
333 .dattr = __ATTR(_field, _mode, \
334 edt_ft5x06_setting_show, \
335 edt_ft5x06_setting_store), \
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700336 .field_offset = offsetof(struct edt_ft5x06_ts_data, _field), \
337 .addr_m06 = _addr_m06, \
338 .addr_m09 = _addr_m09, \
Simon Budig43c4d132012-07-24 23:29:36 -0700339 .limit_low = _limit_low, \
340 .limit_high = _limit_high, \
Simon Budig43c4d132012-07-24 23:29:36 -0700341 }
342
343static ssize_t edt_ft5x06_setting_show(struct device *dev,
344 struct device_attribute *dattr,
345 char *buf)
346{
347 struct i2c_client *client = to_i2c_client(dev);
348 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
349 struct edt_ft5x06_attribute *attr =
350 container_of(dattr, struct edt_ft5x06_attribute, dattr);
Lothar Waßmann1730d812014-03-28 09:20:08 -0700351 u8 *field = (u8 *)tsdata + attr->field_offset;
Simon Budig43c4d132012-07-24 23:29:36 -0700352 int val;
353 size_t count = 0;
354 int error = 0;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700355 u8 addr;
Simon Budig43c4d132012-07-24 23:29:36 -0700356
357 mutex_lock(&tsdata->mutex);
358
359 if (tsdata->factory_mode) {
360 error = -EIO;
361 goto out;
362 }
363
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700364 switch (tsdata->version) {
365 case M06:
366 addr = attr->addr_m06;
367 break;
368
369 case M09:
370 addr = attr->addr_m09;
371 break;
372
373 default:
374 error = -ENODEV;
Simon Budig43c4d132012-07-24 23:29:36 -0700375 goto out;
376 }
377
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700378 if (addr != NO_REGISTER) {
379 val = edt_ft5x06_register_read(tsdata, addr);
380 if (val < 0) {
381 error = val;
382 dev_err(&tsdata->client->dev,
383 "Failed to fetch attribute %s, error %d\n",
384 dattr->attr.name, error);
385 goto out;
386 }
387 } else {
388 val = *field;
389 }
390
Simon Budig43c4d132012-07-24 23:29:36 -0700391 if (val != *field) {
392 dev_warn(&tsdata->client->dev,
393 "%s: read (%d) and stored value (%d) differ\n",
394 dattr->attr.name, val, *field);
395 *field = val;
396 }
397
398 count = scnprintf(buf, PAGE_SIZE, "%d\n", val);
399out:
400 mutex_unlock(&tsdata->mutex);
401 return error ?: count;
402}
403
404static ssize_t edt_ft5x06_setting_store(struct device *dev,
405 struct device_attribute *dattr,
406 const char *buf, size_t count)
407{
408 struct i2c_client *client = to_i2c_client(dev);
409 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
410 struct edt_ft5x06_attribute *attr =
411 container_of(dattr, struct edt_ft5x06_attribute, dattr);
Lothar Waßmann1730d812014-03-28 09:20:08 -0700412 u8 *field = (u8 *)tsdata + attr->field_offset;
Simon Budig43c4d132012-07-24 23:29:36 -0700413 unsigned int val;
414 int error;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700415 u8 addr;
Simon Budig43c4d132012-07-24 23:29:36 -0700416
417 mutex_lock(&tsdata->mutex);
418
419 if (tsdata->factory_mode) {
420 error = -EIO;
421 goto out;
422 }
423
424 error = kstrtouint(buf, 0, &val);
425 if (error)
426 goto out;
427
428 if (val < attr->limit_low || val > attr->limit_high) {
429 error = -ERANGE;
430 goto out;
431 }
432
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700433 switch (tsdata->version) {
434 case M06:
435 addr = attr->addr_m06;
436 break;
437
438 case M09:
439 addr = attr->addr_m09;
440 break;
441
442 default:
443 error = -ENODEV;
Simon Budig43c4d132012-07-24 23:29:36 -0700444 goto out;
445 }
446
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700447 if (addr != NO_REGISTER) {
448 error = edt_ft5x06_register_write(tsdata, addr, val);
449 if (error) {
450 dev_err(&tsdata->client->dev,
451 "Failed to update attribute %s, error: %d\n",
452 dattr->attr.name, error);
453 goto out;
454 }
455 }
Simon Budig43c4d132012-07-24 23:29:36 -0700456 *field = val;
457
458out:
459 mutex_unlock(&tsdata->mutex);
460 return error ?: count;
461}
462
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700463static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN,
464 M09_REGISTER_GAIN, 0, 31);
465static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET,
466 M09_REGISTER_OFFSET, 0, 31);
467static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD,
468 M09_REGISTER_THRESHOLD, 20, 80);
469static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE,
470 NO_REGISTER, 3, 14);
Simon Budig43c4d132012-07-24 23:29:36 -0700471
472static struct attribute *edt_ft5x06_attrs[] = {
473 &edt_ft5x06_attr_gain.dattr.attr,
474 &edt_ft5x06_attr_offset.dattr.attr,
475 &edt_ft5x06_attr_threshold.dattr.attr,
476 &edt_ft5x06_attr_report_rate.dattr.attr,
477 NULL
478};
479
480static const struct attribute_group edt_ft5x06_attr_group = {
481 .attrs = edt_ft5x06_attrs,
482};
483
484#ifdef CONFIG_DEBUG_FS
485static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
486{
487 struct i2c_client *client = tsdata->client;
488 int retries = EDT_SWITCH_MODE_RETRIES;
489 int ret;
490 int error;
491
492 disable_irq(client->irq);
493
494 if (!tsdata->raw_buffer) {
495 tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y *
496 sizeof(u16);
497 tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL);
498 if (!tsdata->raw_buffer) {
499 error = -ENOMEM;
500 goto err_out;
501 }
502 }
503
504 /* mode register is 0x3c when in the work mode */
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700505 if (tsdata->version == M09)
506 goto m09_out;
507
Simon Budig43c4d132012-07-24 23:29:36 -0700508 error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03);
509 if (error) {
510 dev_err(&client->dev,
511 "failed to switch to factory mode, error %d\n", error);
512 goto err_out;
513 }
514
515 tsdata->factory_mode = true;
516 do {
517 mdelay(EDT_SWITCH_MODE_DELAY);
518 /* mode register is 0x01 when in factory mode */
519 ret = edt_ft5x06_register_read(tsdata, FACTORY_REGISTER_OPMODE);
520 if (ret == 0x03)
521 break;
522 } while (--retries > 0);
523
524 if (retries == 0) {
525 dev_err(&client->dev, "not in factory mode after %dms.\n",
526 EDT_SWITCH_MODE_RETRIES * EDT_SWITCH_MODE_DELAY);
527 error = -EIO;
528 goto err_out;
529 }
530
531 return 0;
532
533err_out:
534 kfree(tsdata->raw_buffer);
535 tsdata->raw_buffer = NULL;
536 tsdata->factory_mode = false;
537 enable_irq(client->irq);
538
539 return error;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700540
541m09_out:
542 dev_err(&client->dev, "No factory mode support for M09\n");
543 return -EINVAL;
544
Simon Budig43c4d132012-07-24 23:29:36 -0700545}
546
547static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
548{
549 struct i2c_client *client = tsdata->client;
550 int retries = EDT_SWITCH_MODE_RETRIES;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700551 struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
Simon Budig43c4d132012-07-24 23:29:36 -0700552 int ret;
553 int error;
554
555 /* mode register is 0x01 when in the factory mode */
556 error = edt_ft5x06_register_write(tsdata, FACTORY_REGISTER_OPMODE, 0x1);
557 if (error) {
558 dev_err(&client->dev,
559 "failed to switch to work mode, error: %d\n", error);
560 return error;
561 }
562
563 tsdata->factory_mode = false;
564
565 do {
566 mdelay(EDT_SWITCH_MODE_DELAY);
567 /* mode register is 0x01 when in factory mode */
568 ret = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OPMODE);
569 if (ret == 0x01)
570 break;
571 } while (--retries > 0);
572
573 if (retries == 0) {
574 dev_err(&client->dev, "not in work mode after %dms.\n",
575 EDT_SWITCH_MODE_RETRIES * EDT_SWITCH_MODE_DELAY);
576 tsdata->factory_mode = true;
577 return -EIO;
578 }
579
Sachin Kamat8efcc502013-03-28 01:14:42 -0700580 kfree(tsdata->raw_buffer);
Simon Budig43c4d132012-07-24 23:29:36 -0700581 tsdata->raw_buffer = NULL;
582
583 /* restore parameters */
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700584 edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
Simon Budig43c4d132012-07-24 23:29:36 -0700585 tsdata->threshold);
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700586 edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
Simon Budig43c4d132012-07-24 23:29:36 -0700587 tsdata->gain);
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700588 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
Simon Budig43c4d132012-07-24 23:29:36 -0700589 tsdata->offset);
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700590 if (reg_addr->reg_report_rate)
591 edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
Simon Budig43c4d132012-07-24 23:29:36 -0700592 tsdata->report_rate);
593
594 enable_irq(client->irq);
595
596 return 0;
597}
598
599static int edt_ft5x06_debugfs_mode_get(void *data, u64 *mode)
600{
601 struct edt_ft5x06_ts_data *tsdata = data;
602
603 *mode = tsdata->factory_mode;
604
605 return 0;
606};
607
608static int edt_ft5x06_debugfs_mode_set(void *data, u64 mode)
609{
610 struct edt_ft5x06_ts_data *tsdata = data;
611 int retval = 0;
612
613 if (mode > 1)
614 return -ERANGE;
615
616 mutex_lock(&tsdata->mutex);
617
618 if (mode != tsdata->factory_mode) {
619 retval = mode ? edt_ft5x06_factory_mode(tsdata) :
Lothar Waßmann1730d812014-03-28 09:20:08 -0700620 edt_ft5x06_work_mode(tsdata);
Simon Budig43c4d132012-07-24 23:29:36 -0700621 }
622
623 mutex_unlock(&tsdata->mutex);
624
625 return retval;
626};
627
628DEFINE_SIMPLE_ATTRIBUTE(debugfs_mode_fops, edt_ft5x06_debugfs_mode_get,
629 edt_ft5x06_debugfs_mode_set, "%llu\n");
630
Simon Budig43c4d132012-07-24 23:29:36 -0700631static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
632 char __user *buf, size_t count, loff_t *off)
633{
634 struct edt_ft5x06_ts_data *tsdata = file->private_data;
635 struct i2c_client *client = tsdata->client;
636 int retries = EDT_RAW_DATA_RETRIES;
637 int val, i, error;
638 size_t read = 0;
639 int colbytes;
640 char wrbuf[3];
641 u8 *rdbuf;
642
643 if (*off < 0 || *off >= tsdata->raw_bufsize)
644 return 0;
645
646 mutex_lock(&tsdata->mutex);
647
648 if (!tsdata->factory_mode || !tsdata->raw_buffer) {
649 error = -EIO;
650 goto out;
651 }
652
653 error = edt_ft5x06_register_write(tsdata, 0x08, 0x01);
654 if (error) {
655 dev_dbg(&client->dev,
656 "failed to write 0x08 register, error %d\n", error);
657 goto out;
658 }
659
660 do {
661 msleep(EDT_RAW_DATA_DELAY);
662 val = edt_ft5x06_register_read(tsdata, 0x08);
663 if (val < 1)
664 break;
665 } while (--retries > 0);
666
667 if (val < 0) {
668 error = val;
669 dev_dbg(&client->dev,
670 "failed to read 0x08 register, error %d\n", error);
671 goto out;
672 }
673
674 if (retries == 0) {
675 dev_dbg(&client->dev,
676 "timed out waiting for register to settle\n");
677 error = -ETIMEDOUT;
678 goto out;
679 }
680
681 rdbuf = tsdata->raw_buffer;
682 colbytes = tsdata->num_y * sizeof(u16);
683
684 wrbuf[0] = 0xf5;
685 wrbuf[1] = 0x0e;
686 for (i = 0; i < tsdata->num_x; i++) {
687 wrbuf[2] = i; /* column index */
688 error = edt_ft5x06_ts_readwrite(tsdata->client,
689 sizeof(wrbuf), wrbuf,
690 colbytes, rdbuf);
691 if (error)
692 goto out;
693
694 rdbuf += colbytes;
695 }
696
697 read = min_t(size_t, count, tsdata->raw_bufsize - *off);
Axel Lin35b1da42012-09-19 15:56:23 -0700698 if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) {
699 error = -EFAULT;
700 goto out;
701 }
702
703 *off += read;
Simon Budig43c4d132012-07-24 23:29:36 -0700704out:
705 mutex_unlock(&tsdata->mutex);
706 return error ?: read;
707};
708
Simon Budig43c4d132012-07-24 23:29:36 -0700709static const struct file_operations debugfs_raw_data_fops = {
Wei Yongjunf6c0df62012-10-17 23:55:54 -0700710 .open = simple_open,
Simon Budig43c4d132012-07-24 23:29:36 -0700711 .read = edt_ft5x06_debugfs_raw_data_read,
712};
713
Bill Pemberton5298cc42012-11-23 21:38:25 -0800714static void
Simon Budig43c4d132012-07-24 23:29:36 -0700715edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
716 const char *debugfs_name)
717{
718 tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL);
719 if (!tsdata->debug_dir)
720 return;
721
722 debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x);
723 debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y);
724
725 debugfs_create_file("mode", S_IRUSR | S_IWUSR,
726 tsdata->debug_dir, tsdata, &debugfs_mode_fops);
727 debugfs_create_file("raw_data", S_IRUSR,
728 tsdata->debug_dir, tsdata, &debugfs_raw_data_fops);
729}
730
Bill Pembertone2619cf2012-11-23 21:50:47 -0800731static void
Simon Budig43c4d132012-07-24 23:29:36 -0700732edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
733{
Fabian Frederickf69c6ec2014-07-09 09:45:57 -0700734 debugfs_remove_recursive(tsdata->debug_dir);
Guenter Roecka1d0fa72012-08-21 22:01:45 -0700735 kfree(tsdata->raw_buffer);
Simon Budig43c4d132012-07-24 23:29:36 -0700736}
737
738#else
739
740static inline void
741edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
742 const char *debugfs_name)
743{
744}
745
746static inline void
747edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
748{
749}
750
751#endif /* CONFIG_DEBUGFS */
752
Bill Pemberton5298cc42012-11-23 21:38:25 -0800753static int edt_ft5x06_ts_identify(struct i2c_client *client,
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700754 struct edt_ft5x06_ts_data *tsdata,
755 char *fw_version)
Simon Budig43c4d132012-07-24 23:29:36 -0700756{
757 u8 rdbuf[EDT_NAME_LEN];
758 char *p;
759 int error;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700760 char *model_name = tsdata->name;
Simon Budig43c4d132012-07-24 23:29:36 -0700761
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700762 /* see what we find if we assume it is a M06 *
763 * if we get less than EDT_NAME_LEN, we don't want
764 * to have garbage in there
765 */
766 memset(rdbuf, 0, sizeof(rdbuf));
Simon Budig43c4d132012-07-24 23:29:36 -0700767 error = edt_ft5x06_ts_readwrite(client, 1, "\xbb",
768 EDT_NAME_LEN - 1, rdbuf);
769 if (error)
770 return error;
771
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700772 /* if we find something consistent, stay with that assumption
773 * at least M09 won't send 3 bytes here
774 */
Rasmus Villemoes0f3ae5b2014-10-13 15:54:48 -0700775 if (!(strncasecmp(rdbuf + 1, "EP0", 3))) {
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700776 tsdata->version = M06;
Simon Budig43c4d132012-07-24 23:29:36 -0700777
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700778 /* remove last '$' end marker */
779 rdbuf[EDT_NAME_LEN - 1] = '\0';
780 if (rdbuf[EDT_NAME_LEN - 2] == '$')
781 rdbuf[EDT_NAME_LEN - 2] = '\0';
Simon Budig43c4d132012-07-24 23:29:36 -0700782
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700783 /* look for Model/Version separator */
784 p = strchr(rdbuf, '*');
785 if (p)
786 *p++ = '\0';
787 strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN);
788 strlcpy(fw_version, p ? p : "", EDT_NAME_LEN);
789 } else {
790 /* since there are only two versions around (M06, M09) */
791 tsdata->version = M09;
792
793 error = edt_ft5x06_ts_readwrite(client, 1, "\xA6",
794 2, rdbuf);
795 if (error)
796 return error;
797
798 strlcpy(fw_version, rdbuf, 2);
799
800 error = edt_ft5x06_ts_readwrite(client, 1, "\xA8",
801 1, rdbuf);
802 if (error)
803 return error;
804
805 snprintf(model_name, EDT_NAME_LEN, "EP0%i%i0M09",
806 rdbuf[0] >> 4, rdbuf[0] & 0x0F);
807 }
Simon Budig43c4d132012-07-24 23:29:36 -0700808
809 return 0;
810}
811
Dmitry Torokhov2e23b7a2015-09-12 09:54:15 -0700812static void edt_ft5x06_ts_get_defaults(struct device *dev,
Dmitry Torokhov22ddbac2015-09-12 09:37:03 -0700813 struct edt_ft5x06_ts_data *tsdata)
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700814{
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700815 struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
Dmitry Torokhov2e23b7a2015-09-12 09:54:15 -0700816 u32 val;
817 int error;
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700818
Dmitry Torokhov2e23b7a2015-09-12 09:54:15 -0700819 error = device_property_read_u32(dev, "threshold", &val);
820 if (!error)
821 reg_addr->reg_threshold = val;
822
823 error = device_property_read_u32(dev, "gain", &val);
824 if (!error)
825 reg_addr->reg_gain = val;
826
827 error = device_property_read_u32(dev, "offset", &val);
828 if (!error)
829 reg_addr->reg_offset = val;
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700830}
831
Bill Pemberton5298cc42012-11-23 21:38:25 -0800832static void
Simon Budig43c4d132012-07-24 23:29:36 -0700833edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata)
834{
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700835 struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
836
Simon Budig43c4d132012-07-24 23:29:36 -0700837 tsdata->threshold = edt_ft5x06_register_read(tsdata,
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700838 reg_addr->reg_threshold);
839 tsdata->gain = edt_ft5x06_register_read(tsdata, reg_addr->reg_gain);
840 tsdata->offset = edt_ft5x06_register_read(tsdata, reg_addr->reg_offset);
841 if (reg_addr->reg_report_rate != NO_REGISTER)
842 tsdata->report_rate = edt_ft5x06_register_read(tsdata,
843 reg_addr->reg_report_rate);
844 tsdata->num_x = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_x);
845 tsdata->num_y = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_y);
846}
847
848static void
849edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
850{
851 struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
852
853 switch (tsdata->version) {
854 case M06:
855 reg_addr->reg_threshold = WORK_REGISTER_THRESHOLD;
856 reg_addr->reg_report_rate = WORK_REGISTER_REPORT_RATE;
857 reg_addr->reg_gain = WORK_REGISTER_GAIN;
858 reg_addr->reg_offset = WORK_REGISTER_OFFSET;
859 reg_addr->reg_num_x = WORK_REGISTER_NUM_X;
860 reg_addr->reg_num_y = WORK_REGISTER_NUM_Y;
861 break;
862
863 case M09:
864 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD;
865 reg_addr->reg_gain = M09_REGISTER_GAIN;
866 reg_addr->reg_offset = M09_REGISTER_OFFSET;
867 reg_addr->reg_num_x = M09_REGISTER_NUM_X;
868 reg_addr->reg_num_y = M09_REGISTER_NUM_Y;
869 break;
870 }
Simon Budig43c4d132012-07-24 23:29:36 -0700871}
872
Bill Pemberton5298cc42012-11-23 21:38:25 -0800873static int edt_ft5x06_ts_probe(struct i2c_client *client,
Simon Budig43c4d132012-07-24 23:29:36 -0700874 const struct i2c_device_id *id)
875{
Simon Budig43c4d132012-07-24 23:29:36 -0700876 struct edt_ft5x06_ts_data *tsdata;
877 struct input_dev *input;
Dmitry Torokhovf0bef752015-09-12 10:11:09 -0700878 unsigned long irq_flags;
Simon Budig43c4d132012-07-24 23:29:36 -0700879 int error;
880 char fw_version[EDT_NAME_LEN];
881
882 dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
883
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800884 tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL);
885 if (!tsdata) {
Simon Budig43c4d132012-07-24 23:29:36 -0700886 dev_err(&client->dev, "failed to allocate driver data.\n");
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800887 return -ENOMEM;
888 }
889
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -0700890 tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev,
891 "reset", GPIOD_OUT_HIGH);
892 if (IS_ERR(tsdata->reset_gpio)) {
893 error = PTR_ERR(tsdata->reset_gpio);
894 dev_err(&client->dev,
895 "Failed to request GPIO reset pin, error %d\n", error);
896 return error;
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700897 }
898
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -0700899 tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev,
900 "wake", GPIOD_OUT_LOW);
901 if (IS_ERR(tsdata->wake_gpio)) {
902 error = PTR_ERR(tsdata->wake_gpio);
903 dev_err(&client->dev,
904 "Failed to request GPIO wake pin, error %d\n", error);
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700905 return error;
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -0700906 }
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700907
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -0700908 if (tsdata->wake_gpio) {
909 usleep_range(5000, 6000);
910 gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
911 }
912
913 if (tsdata->reset_gpio) {
914 usleep_range(5000, 6000);
915 gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
916 msleep(300);
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700917 }
918
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800919 input = devm_input_allocate_device(&client->dev);
920 if (!input) {
921 dev_err(&client->dev, "failed to allocate input device.\n");
922 return -ENOMEM;
Simon Budig43c4d132012-07-24 23:29:36 -0700923 }
924
925 mutex_init(&tsdata->mutex);
926 tsdata->client = client;
927 tsdata->input = input;
928 tsdata->factory_mode = false;
929
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700930 error = edt_ft5x06_ts_identify(client, tsdata, fw_version);
Simon Budig43c4d132012-07-24 23:29:36 -0700931 if (error) {
932 dev_err(&client->dev, "touchscreen probe failed\n");
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800933 return error;
Simon Budig43c4d132012-07-24 23:29:36 -0700934 }
935
Lothar Waßmannfd335ab2014-03-28 09:31:14 -0700936 edt_ft5x06_ts_set_regs(tsdata);
Dmitry Torokhov2e23b7a2015-09-12 09:54:15 -0700937 edt_ft5x06_ts_get_defaults(&client->dev, tsdata);
Simon Budig43c4d132012-07-24 23:29:36 -0700938 edt_ft5x06_ts_get_parameters(tsdata);
939
940 dev_dbg(&client->dev,
941 "Model \"%s\", Rev. \"%s\", %dx%d sensors\n",
942 tsdata->name, fw_version, tsdata->num_x, tsdata->num_y);
943
944 input->name = tsdata->name;
945 input->id.bustype = BUS_I2C;
946 input->dev.parent = &client->dev;
947
Simon Budig43c4d132012-07-24 23:29:36 -0700948 input_set_abs_params(input, ABS_MT_POSITION_X,
949 0, tsdata->num_x * 64 - 1, 0, 0);
950 input_set_abs_params(input, ABS_MT_POSITION_Y,
951 0, tsdata->num_y * 64 - 1, 0, 0);
Maxime Ripard2c005592015-03-21 20:18:06 -0700952
Dmitry Torokhov22ddbac2015-09-12 09:37:03 -0700953 touchscreen_parse_properties(input, true);
Maxime Ripard2c005592015-03-21 20:18:06 -0700954
Dmitry Torokhov38e1b722015-06-01 10:41:11 -0700955 error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT);
Simon Budig43c4d132012-07-24 23:29:36 -0700956 if (error) {
957 dev_err(&client->dev, "Unable to init MT slots.\n");
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800958 return error;
Simon Budig43c4d132012-07-24 23:29:36 -0700959 }
960
961 input_set_drvdata(input, tsdata);
962 i2c_set_clientdata(client, tsdata);
963
Dmitry Torokhovf0bef752015-09-12 10:11:09 -0700964 irq_flags = irq_get_trigger_type(client->irq);
965 if (irq_flags == IRQF_TRIGGER_NONE)
966 irq_flags = IRQF_TRIGGER_FALLING;
967 irq_flags |= IRQF_ONESHOT;
968
969 error = devm_request_threaded_irq(&client->dev, client->irq,
970 NULL, edt_ft5x06_ts_isr, irq_flags,
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700971 client->name, tsdata);
Simon Budig43c4d132012-07-24 23:29:36 -0700972 if (error) {
973 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800974 return error;
Simon Budig43c4d132012-07-24 23:29:36 -0700975 }
976
977 error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group);
978 if (error)
Lothar Waßmann02300bd2014-01-16 16:26:55 -0800979 return error;
Simon Budig43c4d132012-07-24 23:29:36 -0700980
981 error = input_register_device(input);
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700982 if (error)
983 goto err_remove_attrs;
Simon Budig43c4d132012-07-24 23:29:36 -0700984
985 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
986 device_init_wakeup(&client->dev, 1);
987
988 dev_dbg(&client->dev,
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700989 "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
Franklin S Cooper Jr13c23cd2015-09-11 17:30:34 -0700990 client->irq, desc_to_gpio(tsdata->wake_gpio),
991 desc_to_gpio(tsdata->reset_gpio));
Simon Budig43c4d132012-07-24 23:29:36 -0700992
993 return 0;
Lothar Waßmanndac90dc22014-03-28 09:23:02 -0700994
995err_remove_attrs:
996 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
997 return error;
Simon Budig43c4d132012-07-24 23:29:36 -0700998}
999
Bill Pembertone2619cf2012-11-23 21:50:47 -08001000static int edt_ft5x06_ts_remove(struct i2c_client *client)
Simon Budig43c4d132012-07-24 23:29:36 -07001001{
Simon Budig43c4d132012-07-24 23:29:36 -07001002 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
1003
1004 edt_ft5x06_ts_teardown_debugfs(tsdata);
1005 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
1006
Simon Budig43c4d132012-07-24 23:29:36 -07001007 return 0;
1008}
1009
Jingoo Han02b6a582014-11-02 00:04:14 -07001010static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev)
Simon Budig43c4d132012-07-24 23:29:36 -07001011{
1012 struct i2c_client *client = to_i2c_client(dev);
1013
1014 if (device_may_wakeup(dev))
1015 enable_irq_wake(client->irq);
1016
1017 return 0;
1018}
1019
Jingoo Han02b6a582014-11-02 00:04:14 -07001020static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev)
Simon Budig43c4d132012-07-24 23:29:36 -07001021{
1022 struct i2c_client *client = to_i2c_client(dev);
1023
1024 if (device_may_wakeup(dev))
1025 disable_irq_wake(client->irq);
1026
1027 return 0;
1028}
Simon Budig43c4d132012-07-24 23:29:36 -07001029
1030static SIMPLE_DEV_PM_OPS(edt_ft5x06_ts_pm_ops,
1031 edt_ft5x06_ts_suspend, edt_ft5x06_ts_resume);
1032
1033static const struct i2c_device_id edt_ft5x06_ts_id[] = {
Lothar Waßmann1730d812014-03-28 09:20:08 -07001034 { "edt-ft5x06", 0, },
1035 { /* sentinel */ }
Simon Budig43c4d132012-07-24 23:29:36 -07001036};
1037MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id);
1038
Lothar Waßmanndac90dc22014-03-28 09:23:02 -07001039#ifdef CONFIG_OF
1040static const struct of_device_id edt_ft5x06_of_match[] = {
1041 { .compatible = "edt,edt-ft5206", },
1042 { .compatible = "edt,edt-ft5306", },
1043 { .compatible = "edt,edt-ft5406", },
1044 { /* sentinel */ }
1045};
1046MODULE_DEVICE_TABLE(of, edt_ft5x06_of_match);
1047#endif
1048
Simon Budig43c4d132012-07-24 23:29:36 -07001049static struct i2c_driver edt_ft5x06_ts_driver = {
1050 .driver = {
Simon Budig43c4d132012-07-24 23:29:36 -07001051 .name = "edt_ft5x06",
Lothar Waßmanndac90dc22014-03-28 09:23:02 -07001052 .of_match_table = of_match_ptr(edt_ft5x06_of_match),
Simon Budig43c4d132012-07-24 23:29:36 -07001053 .pm = &edt_ft5x06_ts_pm_ops,
1054 },
1055 .id_table = edt_ft5x06_ts_id,
1056 .probe = edt_ft5x06_ts_probe,
Bill Pemberton1cb0aa82012-11-23 21:27:39 -08001057 .remove = edt_ft5x06_ts_remove,
Simon Budig43c4d132012-07-24 23:29:36 -07001058};
1059
1060module_i2c_driver(edt_ft5x06_ts_driver);
1061
1062MODULE_AUTHOR("Simon Budig <simon.budig@kernelconcepts.de>");
1063MODULE_DESCRIPTION("EDT FT5x06 I2C Touchscreen Driver");
1064MODULE_LICENSE("GPL");