1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2012 Simon Budig, <simon.budig@kernelconcepts.de>
4 * Daniel Wagener <daniel.wagener@kernelconcepts.de> (M09 firmware support)
5 * Lothar Waßmann <LW@KARO-electronics.de> (DT support)
6 * Dario Binacchi <dario.binacchi@amarulasolutions.com> (regmap support)
10 * This is a driver for the EDT "Polytouch" family of touch controllers
11 * based on the FocalTech FT5x06 line of chips.
13 * Development of this driver has been sponsored by Glyn:
14 * http://www.glyn.com/Products/Displays
17 #include <linux/debugfs.h>
18 #include <linux/delay.h>
19 #include <linux/gpio/consumer.h>
20 #include <linux/i2c.h>
21 #include <linux/interrupt.h>
22 #include <linux/input.h>
23 #include <linux/input/mt.h>
24 #include <linux/input/touchscreen.h>
25 #include <linux/irq.h>
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/property.h>
29 #include <linux/ratelimit.h>
30 #include <linux/regmap.h>
31 #include <linux/regulator/consumer.h>
32 #include <linux/slab.h>
33 #include <linux/uaccess.h>
35 #include <linux/unaligned.h>
37 #define WORK_REGISTER_THRESHOLD 0x00
38 #define WORK_REGISTER_REPORT_RATE 0x08
39 #define WORK_REGISTER_GAIN 0x30
40 #define WORK_REGISTER_OFFSET 0x31
41 #define WORK_REGISTER_NUM_X 0x33
42 #define WORK_REGISTER_NUM_Y 0x34
44 #define PMOD_REGISTER_ACTIVE 0x00
45 #define PMOD_REGISTER_HIBERNATE 0x03
47 #define M09_REGISTER_THRESHOLD 0x80
48 #define M09_REGISTER_GAIN 0x92
49 #define M09_REGISTER_OFFSET 0x93
50 #define M09_REGISTER_NUM_X 0x94
51 #define M09_REGISTER_NUM_Y 0x95
53 #define M12_REGISTER_REPORT_RATE 0x88
55 #define EV_REGISTER_THRESHOLD 0x40
56 #define EV_REGISTER_GAIN 0x41
57 #define EV_REGISTER_OFFSET_Y 0x45
58 #define EV_REGISTER_OFFSET_X 0x46
60 #define NO_REGISTER 0xff
62 #define WORK_REGISTER_OPMODE 0x3c
63 #define FACTORY_REGISTER_OPMODE 0x01
64 #define PMOD_REGISTER_OPMODE 0xa5
66 #define TOUCH_EVENT_DOWN 0x00
67 #define TOUCH_EVENT_UP 0x01
68 #define TOUCH_EVENT_ON 0x02
69 #define TOUCH_EVENT_RESERVED 0x03
71 #define EDT_NAME_LEN 23
72 #define EDT_SWITCH_MODE_RETRIES 10
73 #define EDT_SWITCH_MODE_DELAY 5 /* msec */
74 #define EDT_RAW_DATA_RETRIES 100
75 #define EDT_RAW_DATA_DELAY 1000 /* usec */
77 #define EDT_DEFAULT_NUM_X 1024
78 #define EDT_DEFAULT_NUM_Y 1024
80 #define M06_REG_CMD(factory) ((factory) ? 0xf3 : 0xfc)
81 #define M06_REG_ADDR(factory, addr) ((factory) ? (addr) & 0x7f : (addr) & 0x3f)
84 EDT_PMODE_NOT_SUPPORTED
,
108 struct edt_ft5x06_ts_data
{
109 struct i2c_client
*client
;
110 struct input_dev
*input
;
111 struct touchscreen_properties prop
;
114 struct regulator
*vcc
;
115 struct regulator
*iovcc
;
117 struct gpio_desc
*reset_gpio
;
118 struct gpio_desc
*wake_gpio
;
120 struct regmap
*regmap
;
122 #if defined(CONFIG_DEBUG_FS)
123 struct dentry
*debug_dir
;
130 enum edt_pmode suspend_mode
;
137 int max_support_points
;
143 char name
[EDT_NAME_LEN
];
144 char fw_version
[EDT_NAME_LEN
];
146 struct edt_reg_addr reg_addr
;
147 enum edt_ver version
;
148 unsigned int crc_errors
;
149 unsigned int header_errors
;
152 struct edt_i2c_chip_data
{
153 int max_support_points
;
156 static const struct regmap_config edt_ft5x06_i2c_regmap_config
= {
161 static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data
*tsdata
,
167 for (i
= 0; i
< buflen
- 1; i
++)
170 if (crc
!= buf
[buflen
- 1]) {
171 tsdata
->crc_errors
++;
172 dev_err_ratelimited(&tsdata
->client
->dev
,
173 "crc error: 0x%02x expected, got 0x%02x\n",
174 crc
, buf
[buflen
- 1]);
181 static int edt_M06_i2c_read(void *context
, const void *reg_buf
, size_t reg_size
,
182 void *val_buf
, size_t val_size
)
184 struct device
*dev
= context
;
185 struct i2c_client
*i2c
= to_i2c_client(dev
);
186 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(i2c
);
187 struct i2c_msg xfer
[2];
188 bool reg_read
= false;
194 addr
= *((u8
*)reg_buf
);
201 wbuf
[2] = *((u8
*)val_buf
);
209 wbuf
[0] = M06_REG_CMD(tsdata
->factory_mode
);
210 wbuf
[1] = M06_REG_ADDR(tsdata
->factory_mode
, addr
);
211 wbuf
[1] |= tsdata
->factory_mode
? 0x80 : 0x40;
214 xfer
[0].addr
= i2c
->addr
;
219 xfer
[1].addr
= i2c
->addr
;
220 xfer
[1].flags
= I2C_M_RD
;
221 xfer
[1].len
= reg_read
? 2 : val_size
;
222 xfer
[1].buf
= reg_read
? rbuf
: val_buf
;
224 ret
= i2c_transfer(i2c
->adapter
, xfer
, 2);
233 u8
*buf
= (u8
*)val_buf
;
235 if (buf
[0] != 0xaa || buf
[1] != 0xaa ||
236 buf
[2] != val_size
) {
237 tsdata
->header_errors
++;
238 dev_err_ratelimited(dev
,
239 "Unexpected header: %02x%02x%02x\n",
240 buf
[0], buf
[1], buf
[2]);
244 if (!edt_ft5x06_ts_check_crc(tsdata
, val_buf
, val_size
))
246 } else if (reg_read
) {
249 if (!edt_ft5x06_ts_check_crc(tsdata
, wbuf
, 4))
252 *((u8
*)val_buf
) = rbuf
[0];
258 static int edt_M06_i2c_write(void *context
, const void *data
, size_t count
)
260 struct device
*dev
= context
;
261 struct i2c_client
*i2c
= to_i2c_client(dev
);
262 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(i2c
);
268 addr
= *((u8
*)data
);
269 val
= *((u8
*)data
+ 1);
271 wbuf
[0] = M06_REG_CMD(tsdata
->factory_mode
);
272 wbuf
[1] = M06_REG_ADDR(tsdata
->factory_mode
, addr
);
274 wbuf
[3] = wbuf
[0] ^ wbuf
[1] ^ wbuf
[2];
276 xfer
.addr
= i2c
->addr
;
281 ret
= i2c_transfer(i2c
->adapter
, &xfer
, 1);
292 static const struct regmap_config edt_M06_i2c_regmap_config
= {
295 .read
= edt_M06_i2c_read
,
296 .write
= edt_M06_i2c_write
,
299 static irqreturn_t
edt_ft5x06_ts_isr(int irq
, void *dev_id
)
301 struct edt_ft5x06_ts_data
*tsdata
= dev_id
;
302 struct device
*dev
= &tsdata
->client
->dev
;
304 int i
, type
, x
, y
, id
;
307 memset(rdbuf
, 0, sizeof(rdbuf
));
308 error
= regmap_bulk_read(tsdata
->regmap
, tsdata
->tdata_cmd
, rdbuf
,
311 dev_err_ratelimited(dev
, "Unable to fetch data, error: %d\n",
316 for (i
= 0; i
< tsdata
->max_support_points
; i
++) {
317 u8
*buf
= &rdbuf
[i
* tsdata
->point_len
+ tsdata
->tdata_offset
];
320 /* ignore Reserved events */
321 if (type
== TOUCH_EVENT_RESERVED
)
324 /* M06 sometimes sends bogus coordinates in TOUCH_DOWN */
325 if (tsdata
->version
== EDT_M06
&& type
== TOUCH_EVENT_DOWN
)
328 x
= get_unaligned_be16(buf
) & 0x0fff;
329 y
= get_unaligned_be16(buf
+ 2) & 0x0fff;
330 /* The FT5x26 send the y coordinate first */
331 if (tsdata
->version
== EV_FT
)
334 id
= (buf
[2] >> 4) & 0x0f;
336 input_mt_slot(tsdata
->input
, id
);
337 if (input_mt_report_slot_state(tsdata
->input
, MT_TOOL_FINGER
,
338 type
!= TOUCH_EVENT_UP
))
339 touchscreen_report_pos(tsdata
->input
, &tsdata
->prop
,
343 input_mt_report_pointer_emulation(tsdata
->input
, true);
344 input_sync(tsdata
->input
);
350 struct edt_ft5x06_attribute
{
351 struct device_attribute dattr
;
360 #define EDT_ATTR(_field, _mode, _addr_m06, _addr_m09, _addr_ev, \
361 _limit_low, _limit_high) \
362 struct edt_ft5x06_attribute edt_ft5x06_attr_##_field = { \
363 .dattr = __ATTR(_field, _mode, \
364 edt_ft5x06_setting_show, \
365 edt_ft5x06_setting_store), \
366 .field_offset = offsetof(struct edt_ft5x06_ts_data, _field), \
367 .addr_m06 = _addr_m06, \
368 .addr_m09 = _addr_m09, \
369 .addr_ev = _addr_ev, \
370 .limit_low = _limit_low, \
371 .limit_high = _limit_high, \
374 static ssize_t
edt_ft5x06_setting_show(struct device
*dev
,
375 struct device_attribute
*dattr
,
378 struct i2c_client
*client
= to_i2c_client(dev
);
379 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
380 struct edt_ft5x06_attribute
*attr
=
381 container_of(dattr
, struct edt_ft5x06_attribute
, dattr
);
382 u8
*field
= (u8
*)tsdata
+ attr
->field_offset
;
388 mutex_lock(&tsdata
->mutex
);
390 if (tsdata
->factory_mode
) {
395 switch (tsdata
->version
) {
397 addr
= attr
->addr_m06
;
403 addr
= attr
->addr_m09
;
407 addr
= attr
->addr_ev
;
415 if (addr
!= NO_REGISTER
) {
416 error
= regmap_read(tsdata
->regmap
, addr
, &val
);
418 dev_err(&tsdata
->client
->dev
,
419 "Failed to fetch attribute %s, error %d\n",
420 dattr
->attr
.name
, error
);
428 dev_warn(&tsdata
->client
->dev
,
429 "%s: read (%d) and stored value (%d) differ\n",
430 dattr
->attr
.name
, val
, *field
);
434 count
= sysfs_emit(buf
, "%d\n", val
);
436 mutex_unlock(&tsdata
->mutex
);
437 return error
?: count
;
440 static ssize_t
edt_ft5x06_setting_store(struct device
*dev
,
441 struct device_attribute
*dattr
,
442 const char *buf
, size_t count
)
444 struct i2c_client
*client
= to_i2c_client(dev
);
445 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
446 struct edt_ft5x06_attribute
*attr
=
447 container_of(dattr
, struct edt_ft5x06_attribute
, dattr
);
448 u8
*field
= (u8
*)tsdata
+ attr
->field_offset
;
453 mutex_lock(&tsdata
->mutex
);
455 if (tsdata
->factory_mode
) {
460 error
= kstrtouint(buf
, 0, &val
);
464 if (val
< attr
->limit_low
|| val
> attr
->limit_high
) {
469 switch (tsdata
->version
) {
471 addr
= attr
->addr_m06
;
477 addr
= attr
->addr_m09
;
481 addr
= attr
->addr_ev
;
489 if (addr
!= NO_REGISTER
) {
490 error
= regmap_write(tsdata
->regmap
, addr
, val
);
492 dev_err(&tsdata
->client
->dev
,
493 "Failed to update attribute %s, error: %d\n",
494 dattr
->attr
.name
, error
);
501 mutex_unlock(&tsdata
->mutex
);
502 return error
?: count
;
505 /* m06, m09: range 0-31, m12: range 0-5 */
506 static EDT_ATTR(gain
, S_IWUSR
| S_IRUGO
, WORK_REGISTER_GAIN
,
507 M09_REGISTER_GAIN
, EV_REGISTER_GAIN
, 0, 31);
508 /* m06, m09: range 0-31, m12: range 0-16 */
509 static EDT_ATTR(offset
, S_IWUSR
| S_IRUGO
, WORK_REGISTER_OFFSET
,
510 M09_REGISTER_OFFSET
, NO_REGISTER
, 0, 31);
511 /* m06, m09, m12: no supported, ev_ft: range 0-80 */
512 static EDT_ATTR(offset_x
, S_IWUSR
| S_IRUGO
, NO_REGISTER
, NO_REGISTER
,
513 EV_REGISTER_OFFSET_X
, 0, 80);
514 /* m06, m09, m12: no supported, ev_ft: range 0-80 */
515 static EDT_ATTR(offset_y
, S_IWUSR
| S_IRUGO
, NO_REGISTER
, NO_REGISTER
,
516 EV_REGISTER_OFFSET_Y
, 0, 80);
517 /* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */
518 static EDT_ATTR(threshold
, S_IWUSR
| S_IRUGO
, WORK_REGISTER_THRESHOLD
,
519 M09_REGISTER_THRESHOLD
, EV_REGISTER_THRESHOLD
, 0, 255);
520 /* m06: range 3 to 14, m12: range 1 to 255 */
521 static EDT_ATTR(report_rate
, S_IWUSR
| S_IRUGO
, WORK_REGISTER_REPORT_RATE
,
522 M12_REGISTER_REPORT_RATE
, NO_REGISTER
, 0, 255);
524 static ssize_t
model_show(struct device
*dev
, struct device_attribute
*attr
,
527 struct i2c_client
*client
= to_i2c_client(dev
);
528 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
530 return sysfs_emit(buf
, "%s\n", tsdata
->name
);
533 static DEVICE_ATTR_RO(model
);
535 static ssize_t
fw_version_show(struct device
*dev
,
536 struct device_attribute
*attr
, char *buf
)
538 struct i2c_client
*client
= to_i2c_client(dev
);
539 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
541 return sysfs_emit(buf
, "%s\n", tsdata
->fw_version
);
544 static DEVICE_ATTR_RO(fw_version
);
547 static ssize_t
header_errors_show(struct device
*dev
,
548 struct device_attribute
*attr
, char *buf
)
550 struct i2c_client
*client
= to_i2c_client(dev
);
551 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
553 return sysfs_emit(buf
, "%d\n", tsdata
->header_errors
);
556 static DEVICE_ATTR_RO(header_errors
);
559 static ssize_t
crc_errors_show(struct device
*dev
,
560 struct device_attribute
*attr
, char *buf
)
562 struct i2c_client
*client
= to_i2c_client(dev
);
563 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
565 return sysfs_emit(buf
, "%d\n", tsdata
->crc_errors
);
568 static DEVICE_ATTR_RO(crc_errors
);
570 static struct attribute
*edt_ft5x06_attrs
[] = {
571 &edt_ft5x06_attr_gain
.dattr
.attr
,
572 &edt_ft5x06_attr_offset
.dattr
.attr
,
573 &edt_ft5x06_attr_offset_x
.dattr
.attr
,
574 &edt_ft5x06_attr_offset_y
.dattr
.attr
,
575 &edt_ft5x06_attr_threshold
.dattr
.attr
,
576 &edt_ft5x06_attr_report_rate
.dattr
.attr
,
577 &dev_attr_model
.attr
,
578 &dev_attr_fw_version
.attr
,
579 &dev_attr_header_errors
.attr
,
580 &dev_attr_crc_errors
.attr
,
583 ATTRIBUTE_GROUPS(edt_ft5x06
);
585 static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data
*tsdata
)
587 struct edt_reg_addr
*reg_addr
= &tsdata
->reg_addr
;
588 struct regmap
*regmap
= tsdata
->regmap
;
590 regmap_write(regmap
, reg_addr
->reg_threshold
, tsdata
->threshold
);
591 regmap_write(regmap
, reg_addr
->reg_gain
, tsdata
->gain
);
592 if (reg_addr
->reg_offset
!= NO_REGISTER
)
593 regmap_write(regmap
, reg_addr
->reg_offset
, tsdata
->offset
);
594 if (reg_addr
->reg_offset_x
!= NO_REGISTER
)
595 regmap_write(regmap
, reg_addr
->reg_offset_x
, tsdata
->offset_x
);
596 if (reg_addr
->reg_offset_y
!= NO_REGISTER
)
597 regmap_write(regmap
, reg_addr
->reg_offset_y
, tsdata
->offset_y
);
598 if (reg_addr
->reg_report_rate
!= NO_REGISTER
)
599 regmap_write(regmap
, reg_addr
->reg_report_rate
,
600 tsdata
->report_rate
);
603 #ifdef CONFIG_DEBUG_FS
604 static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data
*tsdata
)
606 struct i2c_client
*client
= tsdata
->client
;
607 int retries
= EDT_SWITCH_MODE_RETRIES
;
611 if (tsdata
->version
!= EDT_M06
) {
612 dev_err(&client
->dev
,
613 "No factory mode support for non-M06 devices\n");
617 disable_irq(client
->irq
);
619 if (!tsdata
->raw_buffer
) {
620 tsdata
->raw_bufsize
= tsdata
->num_x
* tsdata
->num_y
*
622 tsdata
->raw_buffer
= kzalloc(tsdata
->raw_bufsize
, GFP_KERNEL
);
623 if (!tsdata
->raw_buffer
) {
629 /* mode register is 0x3c when in the work mode */
630 error
= regmap_write(tsdata
->regmap
, WORK_REGISTER_OPMODE
, 0x03);
632 dev_err(&client
->dev
,
633 "failed to switch to factory mode, error %d\n", error
);
637 tsdata
->factory_mode
= true;
639 mdelay(EDT_SWITCH_MODE_DELAY
);
640 /* mode register is 0x01 when in factory mode */
641 error
= regmap_read(tsdata
->regmap
, FACTORY_REGISTER_OPMODE
,
643 if (!error
&& val
== 0x03)
645 } while (--retries
> 0);
648 dev_err(&client
->dev
, "not in factory mode after %dms.\n",
649 EDT_SWITCH_MODE_RETRIES
* EDT_SWITCH_MODE_DELAY
);
657 kfree(tsdata
->raw_buffer
);
658 tsdata
->raw_buffer
= NULL
;
659 tsdata
->factory_mode
= false;
660 enable_irq(client
->irq
);
665 static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data
*tsdata
)
667 struct i2c_client
*client
= tsdata
->client
;
668 int retries
= EDT_SWITCH_MODE_RETRIES
;
672 /* mode register is 0x01 when in the factory mode */
673 error
= regmap_write(tsdata
->regmap
, FACTORY_REGISTER_OPMODE
, 0x1);
675 dev_err(&client
->dev
,
676 "failed to switch to work mode, error: %d\n", error
);
680 tsdata
->factory_mode
= false;
683 mdelay(EDT_SWITCH_MODE_DELAY
);
684 /* mode register is 0x01 when in factory mode */
685 error
= regmap_read(tsdata
->regmap
, WORK_REGISTER_OPMODE
, &val
);
686 if (!error
&& val
== 0x01)
688 } while (--retries
> 0);
691 dev_err(&client
->dev
, "not in work mode after %dms.\n",
692 EDT_SWITCH_MODE_RETRIES
* EDT_SWITCH_MODE_DELAY
);
693 tsdata
->factory_mode
= true;
697 kfree(tsdata
->raw_buffer
);
698 tsdata
->raw_buffer
= NULL
;
700 edt_ft5x06_restore_reg_parameters(tsdata
);
701 enable_irq(client
->irq
);
706 static int edt_ft5x06_debugfs_mode_get(void *data
, u64
*mode
)
708 struct edt_ft5x06_ts_data
*tsdata
= data
;
710 *mode
= tsdata
->factory_mode
;
715 static int edt_ft5x06_debugfs_mode_set(void *data
, u64 mode
)
717 struct edt_ft5x06_ts_data
*tsdata
= data
;
723 mutex_lock(&tsdata
->mutex
);
725 if (mode
!= tsdata
->factory_mode
) {
726 retval
= mode
? edt_ft5x06_factory_mode(tsdata
) :
727 edt_ft5x06_work_mode(tsdata
);
730 mutex_unlock(&tsdata
->mutex
);
735 DEFINE_SIMPLE_ATTRIBUTE(debugfs_mode_fops
, edt_ft5x06_debugfs_mode_get
,
736 edt_ft5x06_debugfs_mode_set
, "%llu\n");
738 static ssize_t
edt_ft5x06_debugfs_raw_data_read(struct file
*file
,
739 char __user
*buf
, size_t count
,
742 struct edt_ft5x06_ts_data
*tsdata
= file
->private_data
;
743 struct i2c_client
*client
= tsdata
->client
;
744 int retries
= EDT_RAW_DATA_RETRIES
;
751 if (*off
< 0 || *off
>= tsdata
->raw_bufsize
)
754 mutex_lock(&tsdata
->mutex
);
756 if (!tsdata
->factory_mode
|| !tsdata
->raw_buffer
) {
761 error
= regmap_write(tsdata
->regmap
, 0x08, 0x01);
763 dev_err(&client
->dev
,
764 "failed to write 0x08 register, error %d\n", error
);
769 usleep_range(EDT_RAW_DATA_DELAY
, EDT_RAW_DATA_DELAY
+ 100);
770 error
= regmap_read(tsdata
->regmap
, 0x08, &val
);
772 dev_err(&client
->dev
,
773 "failed to read 0x08 register, error %d\n",
780 } while (--retries
> 0);
783 dev_err(&client
->dev
,
784 "timed out waiting for register to settle\n");
789 rdbuf
= tsdata
->raw_buffer
;
790 colbytes
= tsdata
->num_y
* sizeof(u16
);
792 for (i
= 0; i
< tsdata
->num_x
; i
++) {
793 rdbuf
[0] = i
; /* column index */
794 error
= regmap_bulk_read(tsdata
->regmap
, 0xf5, rdbuf
, colbytes
);
801 read
= min_t(size_t, count
, tsdata
->raw_bufsize
- *off
);
802 if (copy_to_user(buf
, tsdata
->raw_buffer
+ *off
, read
)) {
809 mutex_unlock(&tsdata
->mutex
);
810 return error
?: read
;
813 static const struct file_operations debugfs_raw_data_fops
= {
815 .read
= edt_ft5x06_debugfs_raw_data_read
,
818 static void edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data
*tsdata
,
819 const char *debugfs_name
)
821 tsdata
->debug_dir
= debugfs_create_dir(debugfs_name
, NULL
);
823 debugfs_create_u16("num_x", S_IRUSR
, tsdata
->debug_dir
, &tsdata
->num_x
);
824 debugfs_create_u16("num_y", S_IRUSR
, tsdata
->debug_dir
, &tsdata
->num_y
);
826 debugfs_create_file("mode", S_IRUSR
| S_IWUSR
,
827 tsdata
->debug_dir
, tsdata
, &debugfs_mode_fops
);
828 debugfs_create_file("raw_data", S_IRUSR
,
829 tsdata
->debug_dir
, tsdata
, &debugfs_raw_data_fops
);
832 static void edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data
*tsdata
)
834 debugfs_remove_recursive(tsdata
->debug_dir
);
835 kfree(tsdata
->raw_buffer
);
840 static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data
*tsdata
)
845 static void edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data
*tsdata
,
846 const char *debugfs_name
)
850 static void edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data
*tsdata
)
854 #endif /* CONFIG_DEBUGFS */
856 static int edt_ft5x06_ts_identify(struct i2c_client
*client
,
857 struct edt_ft5x06_ts_data
*tsdata
)
859 u8 rdbuf
[EDT_NAME_LEN
];
862 char *model_name
= tsdata
->name
;
863 char *fw_version
= tsdata
->fw_version
;
865 /* see what we find if we assume it is a M06 *
866 * if we get less than EDT_NAME_LEN, we don't want
867 * to have garbage in there
869 memset(rdbuf
, 0, sizeof(rdbuf
));
870 error
= regmap_bulk_read(tsdata
->regmap
, 0xBB, rdbuf
, EDT_NAME_LEN
- 1);
874 /* Probe content for something consistent.
875 * M06 starts with a response byte, M12 gives the data directly.
876 * M09/Generic does not provide model number information.
878 if (!strncasecmp(rdbuf
+ 1, "EP0", 3)) {
879 tsdata
->version
= EDT_M06
;
881 /* remove last '$' end marker */
882 rdbuf
[EDT_NAME_LEN
- 1] = '\0';
883 if (rdbuf
[EDT_NAME_LEN
- 2] == '$')
884 rdbuf
[EDT_NAME_LEN
- 2] = '\0';
886 /* look for Model/Version separator */
887 p
= strchr(rdbuf
, '*');
890 strscpy(model_name
, rdbuf
+ 1, EDT_NAME_LEN
);
891 strscpy(fw_version
, p
? p
: "", EDT_NAME_LEN
);
893 regmap_exit(tsdata
->regmap
);
894 tsdata
->regmap
= regmap_init_i2c(client
,
895 &edt_M06_i2c_regmap_config
);
896 if (IS_ERR(tsdata
->regmap
)) {
897 dev_err(&client
->dev
, "regmap allocation failed\n");
898 return PTR_ERR(tsdata
->regmap
);
900 } else if (!strncasecmp(rdbuf
, "EP0", 3)) {
901 tsdata
->version
= EDT_M12
;
903 /* remove last '$' end marker */
904 rdbuf
[EDT_NAME_LEN
- 2] = '\0';
905 if (rdbuf
[EDT_NAME_LEN
- 3] == '$')
906 rdbuf
[EDT_NAME_LEN
- 3] = '\0';
908 /* look for Model/Version separator */
909 p
= strchr(rdbuf
, '*');
912 strscpy(model_name
, rdbuf
, EDT_NAME_LEN
);
913 strscpy(fw_version
, p
? p
: "", EDT_NAME_LEN
);
915 /* If it is not an EDT M06/M12 touchscreen, then the model
916 * detection is a bit hairy. The different ft5x06
917 * firmwares around don't reliably implement the
918 * identification registers. Well, we'll take a shot.
920 * The main difference between generic focaltec based
921 * touches and EDT M09 is that we know how to retrieve
922 * the max coordinates for the latter.
924 tsdata
->version
= GENERIC_FT
;
926 error
= regmap_bulk_read(tsdata
->regmap
, 0xA6, rdbuf
, 2);
930 strscpy(fw_version
, rdbuf
, 2);
932 error
= regmap_bulk_read(tsdata
->regmap
, 0xA8, rdbuf
, 1);
936 /* This "model identification" is not exact. Unfortunately
937 * not all firmwares for the ft5x06 put useful values in
938 * the identification registers.
941 case 0x11: /* EDT EP0110M09 */
942 case 0x35: /* EDT EP0350M09 */
943 case 0x43: /* EDT EP0430M09 */
944 case 0x50: /* EDT EP0500M09 */
945 case 0x57: /* EDT EP0570M09 */
946 case 0x70: /* EDT EP0700M09 */
947 tsdata
->version
= EDT_M09
;
948 snprintf(model_name
, EDT_NAME_LEN
, "EP0%i%i0M09",
949 rdbuf
[0] >> 4, rdbuf
[0] & 0x0F);
951 case 0xa1: /* EDT EP1010ML00 */
952 tsdata
->version
= EDT_M09
;
953 snprintf(model_name
, EDT_NAME_LEN
, "EP%i%i0ML00",
954 rdbuf
[0] >> 4, rdbuf
[0] & 0x0F);
956 case 0x5a: /* Solomon Goldentek Display */
957 snprintf(model_name
, EDT_NAME_LEN
, "GKTW50SCED1R0");
959 case 0x59: /* Evervision Display with FT5xx6 TS */
960 tsdata
->version
= EV_FT
;
961 error
= regmap_bulk_read(tsdata
->regmap
, 0x53, rdbuf
, 1);
964 strscpy(fw_version
, rdbuf
, 1);
965 snprintf(model_name
, EDT_NAME_LEN
,
966 "EVERVISION-FT5726NEi");
969 snprintf(model_name
, EDT_NAME_LEN
,
970 "generic ft5x06 (%02x)",
979 static void edt_ft5x06_ts_get_defaults(struct device
*dev
,
980 struct edt_ft5x06_ts_data
*tsdata
)
982 struct edt_reg_addr
*reg_addr
= &tsdata
->reg_addr
;
983 struct regmap
*regmap
= tsdata
->regmap
;
987 error
= device_property_read_u32(dev
, "threshold", &val
);
989 regmap_write(regmap
, reg_addr
->reg_threshold
, val
);
990 tsdata
->threshold
= val
;
993 error
= device_property_read_u32(dev
, "gain", &val
);
995 regmap_write(regmap
, reg_addr
->reg_gain
, val
);
999 error
= device_property_read_u32(dev
, "offset", &val
);
1001 if (reg_addr
->reg_offset
!= NO_REGISTER
)
1002 regmap_write(regmap
, reg_addr
->reg_offset
, val
);
1003 tsdata
->offset
= val
;
1006 error
= device_property_read_u32(dev
, "offset-x", &val
);
1008 if (reg_addr
->reg_offset_x
!= NO_REGISTER
)
1009 regmap_write(regmap
, reg_addr
->reg_offset_x
, val
);
1010 tsdata
->offset_x
= val
;
1013 error
= device_property_read_u32(dev
, "offset-y", &val
);
1015 if (reg_addr
->reg_offset_y
!= NO_REGISTER
)
1016 regmap_write(regmap
, reg_addr
->reg_offset_y
, val
);
1017 tsdata
->offset_y
= val
;
1021 static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data
*tsdata
)
1023 struct edt_reg_addr
*reg_addr
= &tsdata
->reg_addr
;
1024 struct regmap
*regmap
= tsdata
->regmap
;
1027 regmap_read(regmap
, reg_addr
->reg_threshold
, &tsdata
->threshold
);
1028 regmap_read(regmap
, reg_addr
->reg_gain
, &tsdata
->gain
);
1029 if (reg_addr
->reg_offset
!= NO_REGISTER
)
1030 regmap_read(regmap
, reg_addr
->reg_offset
, &tsdata
->offset
);
1031 if (reg_addr
->reg_offset_x
!= NO_REGISTER
)
1032 regmap_read(regmap
, reg_addr
->reg_offset_x
, &tsdata
->offset_x
);
1033 if (reg_addr
->reg_offset_y
!= NO_REGISTER
)
1034 regmap_read(regmap
, reg_addr
->reg_offset_y
, &tsdata
->offset_y
);
1035 if (reg_addr
->reg_report_rate
!= NO_REGISTER
)
1036 regmap_read(regmap
, reg_addr
->reg_report_rate
,
1037 &tsdata
->report_rate
);
1038 tsdata
->num_x
= EDT_DEFAULT_NUM_X
;
1039 if (reg_addr
->reg_num_x
!= NO_REGISTER
) {
1040 if (!regmap_read(regmap
, reg_addr
->reg_num_x
, &val
))
1041 tsdata
->num_x
= val
;
1043 tsdata
->num_y
= EDT_DEFAULT_NUM_Y
;
1044 if (reg_addr
->reg_num_y
!= NO_REGISTER
) {
1045 if (!regmap_read(regmap
, reg_addr
->reg_num_y
, &val
))
1046 tsdata
->num_y
= val
;
1050 static void edt_ft5x06_ts_set_tdata_parameters(struct edt_ft5x06_ts_data
*tsdata
)
1054 if (tsdata
->version
== EDT_M06
) {
1055 tsdata
->tdata_cmd
= 0xf9;
1056 tsdata
->tdata_offset
= 5;
1057 tsdata
->point_len
= 4;
1060 tsdata
->tdata_cmd
= 0x0;
1061 tsdata
->tdata_offset
= 3;
1062 tsdata
->point_len
= 6;
1066 tsdata
->tdata_len
= tsdata
->point_len
* tsdata
->max_support_points
+
1067 tsdata
->tdata_offset
+ crclen
;
1070 static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data
*tsdata
)
1072 struct edt_reg_addr
*reg_addr
= &tsdata
->reg_addr
;
1074 switch (tsdata
->version
) {
1076 reg_addr
->reg_threshold
= WORK_REGISTER_THRESHOLD
;
1077 reg_addr
->reg_report_rate
= WORK_REGISTER_REPORT_RATE
;
1078 reg_addr
->reg_gain
= WORK_REGISTER_GAIN
;
1079 reg_addr
->reg_offset
= WORK_REGISTER_OFFSET
;
1080 reg_addr
->reg_offset_x
= NO_REGISTER
;
1081 reg_addr
->reg_offset_y
= NO_REGISTER
;
1082 reg_addr
->reg_num_x
= WORK_REGISTER_NUM_X
;
1083 reg_addr
->reg_num_y
= WORK_REGISTER_NUM_Y
;
1088 reg_addr
->reg_threshold
= M09_REGISTER_THRESHOLD
;
1089 reg_addr
->reg_report_rate
= tsdata
->version
== EDT_M12
?
1090 M12_REGISTER_REPORT_RATE
: NO_REGISTER
;
1091 reg_addr
->reg_gain
= M09_REGISTER_GAIN
;
1092 reg_addr
->reg_offset
= M09_REGISTER_OFFSET
;
1093 reg_addr
->reg_offset_x
= NO_REGISTER
;
1094 reg_addr
->reg_offset_y
= NO_REGISTER
;
1095 reg_addr
->reg_num_x
= M09_REGISTER_NUM_X
;
1096 reg_addr
->reg_num_y
= M09_REGISTER_NUM_Y
;
1100 reg_addr
->reg_threshold
= EV_REGISTER_THRESHOLD
;
1101 reg_addr
->reg_report_rate
= NO_REGISTER
;
1102 reg_addr
->reg_gain
= EV_REGISTER_GAIN
;
1103 reg_addr
->reg_offset
= NO_REGISTER
;
1104 reg_addr
->reg_offset_x
= EV_REGISTER_OFFSET_X
;
1105 reg_addr
->reg_offset_y
= EV_REGISTER_OFFSET_Y
;
1106 reg_addr
->reg_num_x
= NO_REGISTER
;
1107 reg_addr
->reg_num_y
= NO_REGISTER
;
1111 /* this is a guesswork */
1112 reg_addr
->reg_threshold
= M09_REGISTER_THRESHOLD
;
1113 reg_addr
->reg_report_rate
= NO_REGISTER
;
1114 reg_addr
->reg_gain
= M09_REGISTER_GAIN
;
1115 reg_addr
->reg_offset
= M09_REGISTER_OFFSET
;
1116 reg_addr
->reg_offset_x
= NO_REGISTER
;
1117 reg_addr
->reg_offset_y
= NO_REGISTER
;
1118 reg_addr
->reg_num_x
= NO_REGISTER
;
1119 reg_addr
->reg_num_y
= NO_REGISTER
;
1124 static void edt_ft5x06_exit_regmap(void *arg
)
1126 struct edt_ft5x06_ts_data
*data
= arg
;
1128 if (!IS_ERR_OR_NULL(data
->regmap
))
1129 regmap_exit(data
->regmap
);
1132 static void edt_ft5x06_disable_regulators(void *arg
)
1134 struct edt_ft5x06_ts_data
*data
= arg
;
1136 regulator_disable(data
->vcc
);
1137 regulator_disable(data
->iovcc
);
1140 static int edt_ft5x06_ts_probe(struct i2c_client
*client
)
1142 const struct i2c_device_id
*id
= i2c_client_get_device_id(client
);
1143 const struct edt_i2c_chip_data
*chip_data
;
1144 struct edt_ft5x06_ts_data
*tsdata
;
1146 struct input_dev
*input
;
1147 unsigned long irq_flags
;
1151 dev_dbg(&client
->dev
, "probing for EDT FT5x06 I2C\n");
1153 tsdata
= devm_kzalloc(&client
->dev
, sizeof(*tsdata
), GFP_KERNEL
);
1155 dev_err(&client
->dev
, "failed to allocate driver data.\n");
1159 tsdata
->regmap
= regmap_init_i2c(client
, &edt_ft5x06_i2c_regmap_config
);
1160 if (IS_ERR(tsdata
->regmap
)) {
1161 dev_err(&client
->dev
, "regmap allocation failed\n");
1162 return PTR_ERR(tsdata
->regmap
);
1166 * We are not using devm_regmap_init_i2c() and instead install a
1167 * custom action because we may replace regmap with M06-specific one
1168 * and we need to make sure that it will not be released too early.
1170 error
= devm_add_action_or_reset(&client
->dev
, edt_ft5x06_exit_regmap
,
1175 chip_data
= device_get_match_data(&client
->dev
);
1177 chip_data
= (const struct edt_i2c_chip_data
*)id
->driver_data
;
1178 if (!chip_data
|| !chip_data
->max_support_points
) {
1179 dev_err(&client
->dev
, "invalid or missing chip data\n");
1183 tsdata
->max_support_points
= chip_data
->max_support_points
;
1185 tsdata
->vcc
= devm_regulator_get(&client
->dev
, "vcc");
1186 if (IS_ERR(tsdata
->vcc
))
1187 return dev_err_probe(&client
->dev
, PTR_ERR(tsdata
->vcc
),
1188 "failed to request regulator\n");
1190 tsdata
->iovcc
= devm_regulator_get(&client
->dev
, "iovcc");
1191 if (IS_ERR(tsdata
->iovcc
)) {
1192 error
= PTR_ERR(tsdata
->iovcc
);
1193 if (error
!= -EPROBE_DEFER
)
1194 dev_err(&client
->dev
,
1195 "failed to request iovcc regulator: %d\n", error
);
1199 error
= regulator_enable(tsdata
->iovcc
);
1201 dev_err(&client
->dev
, "failed to enable iovcc: %d\n", error
);
1205 /* Delay enabling VCC for > 10us (T_ivd) after IOVCC */
1206 usleep_range(10, 100);
1208 error
= regulator_enable(tsdata
->vcc
);
1210 dev_err(&client
->dev
, "failed to enable vcc: %d\n", error
);
1211 regulator_disable(tsdata
->iovcc
);
1215 error
= devm_add_action_or_reset(&client
->dev
,
1216 edt_ft5x06_disable_regulators
,
1221 tsdata
->reset_gpio
= devm_gpiod_get_optional(&client
->dev
,
1222 "reset", GPIOD_OUT_HIGH
);
1223 if (IS_ERR(tsdata
->reset_gpio
)) {
1224 error
= PTR_ERR(tsdata
->reset_gpio
);
1225 dev_err(&client
->dev
,
1226 "Failed to request GPIO reset pin, error %d\n", error
);
1230 tsdata
->wake_gpio
= devm_gpiod_get_optional(&client
->dev
,
1231 "wake", GPIOD_OUT_LOW
);
1232 if (IS_ERR(tsdata
->wake_gpio
)) {
1233 error
= PTR_ERR(tsdata
->wake_gpio
);
1234 dev_err(&client
->dev
,
1235 "Failed to request GPIO wake pin, error %d\n", error
);
1240 * Check which sleep modes we can support. Power-off requires the
1241 * reset-pin to ensure correct power-down/power-up behaviour. Start with
1242 * the EDT_PMODE_POWEROFF test since this is the deepest possible sleep
1245 if (tsdata
->reset_gpio
)
1246 tsdata
->suspend_mode
= EDT_PMODE_POWEROFF
;
1247 else if (tsdata
->wake_gpio
)
1248 tsdata
->suspend_mode
= EDT_PMODE_HIBERNATE
;
1250 tsdata
->suspend_mode
= EDT_PMODE_NOT_SUPPORTED
;
1252 if (tsdata
->wake_gpio
) {
1253 usleep_range(5000, 6000);
1254 gpiod_set_value_cansleep(tsdata
->wake_gpio
, 1);
1255 usleep_range(5000, 6000);
1258 if (tsdata
->reset_gpio
) {
1259 usleep_range(5000, 6000);
1260 gpiod_set_value_cansleep(tsdata
->reset_gpio
, 0);
1264 input
= devm_input_allocate_device(&client
->dev
);
1266 dev_err(&client
->dev
, "failed to allocate input device.\n");
1270 mutex_init(&tsdata
->mutex
);
1271 tsdata
->client
= client
;
1272 tsdata
->input
= input
;
1273 tsdata
->factory_mode
= false;
1274 i2c_set_clientdata(client
, tsdata
);
1276 error
= edt_ft5x06_ts_identify(client
, tsdata
);
1278 dev_err(&client
->dev
, "touchscreen probe failed\n");
1283 * Dummy read access. EP0700MLP1 returns bogus data on the first
1284 * register read access and ignores writes.
1286 regmap_read(tsdata
->regmap
, 0x00, &val
);
1288 edt_ft5x06_ts_set_tdata_parameters(tsdata
);
1289 edt_ft5x06_ts_set_regs(tsdata
);
1290 edt_ft5x06_ts_get_defaults(&client
->dev
, tsdata
);
1291 edt_ft5x06_ts_get_parameters(tsdata
);
1293 if (tsdata
->reg_addr
.reg_report_rate
!= NO_REGISTER
&&
1294 !device_property_read_u32(&client
->dev
,
1295 "report-rate-hz", &report_rate
)) {
1296 if (tsdata
->version
== EDT_M06
)
1297 tsdata
->report_rate
= clamp_val(report_rate
, 30, 140);
1299 tsdata
->report_rate
= clamp_val(report_rate
, 1, 255);
1301 if (report_rate
!= tsdata
->report_rate
)
1302 dev_warn(&client
->dev
,
1303 "report-rate %dHz is unsupported, use %dHz\n",
1304 report_rate
, tsdata
->report_rate
);
1306 if (tsdata
->version
== EDT_M06
)
1307 tsdata
->report_rate
/= 10;
1309 regmap_write(tsdata
->regmap
, tsdata
->reg_addr
.reg_report_rate
,
1310 tsdata
->report_rate
);
1313 dev_dbg(&client
->dev
,
1314 "Model \"%s\", Rev. \"%s\", %dx%d sensors\n",
1315 tsdata
->name
, tsdata
->fw_version
, tsdata
->num_x
, tsdata
->num_y
);
1317 input
->name
= tsdata
->name
;
1318 input
->id
.bustype
= BUS_I2C
;
1319 input
->dev
.parent
= &client
->dev
;
1321 input_set_abs_params(input
, ABS_MT_POSITION_X
,
1322 0, tsdata
->num_x
* 64 - 1, 0, 0);
1323 input_set_abs_params(input
, ABS_MT_POSITION_Y
,
1324 0, tsdata
->num_y
* 64 - 1, 0, 0);
1326 touchscreen_parse_properties(input
, true, &tsdata
->prop
);
1328 error
= input_mt_init_slots(input
, tsdata
->max_support_points
,
1331 dev_err(&client
->dev
, "Unable to init MT slots.\n");
1335 irq_flags
= irq_get_trigger_type(client
->irq
);
1336 if (irq_flags
== IRQF_TRIGGER_NONE
)
1337 irq_flags
= IRQF_TRIGGER_FALLING
;
1338 irq_flags
|= IRQF_ONESHOT
;
1340 error
= devm_request_threaded_irq(&client
->dev
, client
->irq
,
1341 NULL
, edt_ft5x06_ts_isr
, irq_flags
,
1342 client
->name
, tsdata
);
1344 dev_err(&client
->dev
, "Unable to request touchscreen IRQ.\n");
1348 error
= input_register_device(input
);
1352 edt_ft5x06_ts_prepare_debugfs(tsdata
, dev_driver_string(&client
->dev
));
1354 dev_dbg(&client
->dev
,
1355 "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
1357 tsdata
->wake_gpio
? desc_to_gpio(tsdata
->wake_gpio
) : -1,
1358 tsdata
->reset_gpio
? desc_to_gpio(tsdata
->reset_gpio
) : -1);
1363 static void edt_ft5x06_ts_remove(struct i2c_client
*client
)
1365 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
1367 edt_ft5x06_ts_teardown_debugfs(tsdata
);
1370 static int edt_ft5x06_ts_suspend(struct device
*dev
)
1372 struct i2c_client
*client
= to_i2c_client(dev
);
1373 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
1374 struct gpio_desc
*reset_gpio
= tsdata
->reset_gpio
;
1377 if (device_may_wakeup(dev
))
1380 if (tsdata
->suspend_mode
== EDT_PMODE_NOT_SUPPORTED
)
1383 /* Enter hibernate mode. */
1384 ret
= regmap_write(tsdata
->regmap
, PMOD_REGISTER_OPMODE
,
1385 PMOD_REGISTER_HIBERNATE
);
1387 dev_warn(dev
, "Failed to set hibernate mode\n");
1389 if (tsdata
->suspend_mode
== EDT_PMODE_HIBERNATE
)
1393 * Power-off according the datasheet. Cut the power may leaf the irq
1394 * line in an undefined state depending on the host pull resistor
1395 * settings. Disable the irq to avoid adjusting each host till the
1396 * device is back in a full functional state.
1398 disable_irq(tsdata
->client
->irq
);
1400 gpiod_set_value_cansleep(reset_gpio
, 1);
1401 usleep_range(1000, 2000);
1403 ret
= regulator_disable(tsdata
->vcc
);
1405 dev_warn(dev
, "Failed to disable vcc\n");
1406 ret
= regulator_disable(tsdata
->iovcc
);
1408 dev_warn(dev
, "Failed to disable iovcc\n");
1413 static int edt_ft5x06_ts_resume(struct device
*dev
)
1415 struct i2c_client
*client
= to_i2c_client(dev
);
1416 struct edt_ft5x06_ts_data
*tsdata
= i2c_get_clientdata(client
);
1419 if (device_may_wakeup(dev
))
1422 if (tsdata
->suspend_mode
== EDT_PMODE_NOT_SUPPORTED
)
1425 if (tsdata
->suspend_mode
== EDT_PMODE_POWEROFF
) {
1426 struct gpio_desc
*reset_gpio
= tsdata
->reset_gpio
;
1429 * We can't check if the regulator is a dummy or a real
1430 * regulator. So we need to specify the 5ms reset time (T_rst)
1431 * here instead of the 100us T_rtp time. We also need to wait
1432 * 300ms in case it was a real supply and the power was cutted
1433 * of. Toggle the reset pin is also a way to exit the hibernate
1436 gpiod_set_value_cansleep(reset_gpio
, 1);
1437 usleep_range(5000, 6000);
1439 ret
= regulator_enable(tsdata
->iovcc
);
1441 dev_err(dev
, "Failed to enable iovcc\n");
1445 /* Delay enabling VCC for > 10us (T_ivd) after IOVCC */
1446 usleep_range(10, 100);
1448 ret
= regulator_enable(tsdata
->vcc
);
1450 dev_err(dev
, "Failed to enable vcc\n");
1451 regulator_disable(tsdata
->iovcc
);
1455 usleep_range(1000, 2000);
1456 gpiod_set_value_cansleep(reset_gpio
, 0);
1459 edt_ft5x06_restore_reg_parameters(tsdata
);
1460 enable_irq(tsdata
->client
->irq
);
1462 if (tsdata
->factory_mode
)
1463 ret
= edt_ft5x06_factory_mode(tsdata
);
1465 struct gpio_desc
*wake_gpio
= tsdata
->wake_gpio
;
1467 gpiod_set_value_cansleep(wake_gpio
, 0);
1468 usleep_range(5000, 6000);
1469 gpiod_set_value_cansleep(wake_gpio
, 1);
1475 static DEFINE_SIMPLE_DEV_PM_OPS(edt_ft5x06_ts_pm_ops
,
1476 edt_ft5x06_ts_suspend
, edt_ft5x06_ts_resume
);
1478 static const struct edt_i2c_chip_data edt_ft5x06_data
= {
1479 .max_support_points
= 5,
1482 static const struct edt_i2c_chip_data edt_ft5452_data
= {
1483 .max_support_points
= 5,
1486 static const struct edt_i2c_chip_data edt_ft5506_data
= {
1487 .max_support_points
= 10,
1490 static const struct edt_i2c_chip_data edt_ft6236_data
= {
1491 .max_support_points
= 2,
1494 static const struct edt_i2c_chip_data edt_ft8201_data
= {
1495 .max_support_points
= 10,
1498 static const struct edt_i2c_chip_data edt_ft8719_data
= {
1499 .max_support_points
= 10,
1502 static const struct i2c_device_id edt_ft5x06_ts_id
[] = {
1503 { .name
= "edt-ft5x06", .driver_data
= (long)&edt_ft5x06_data
},
1504 { .name
= "edt-ft5506", .driver_data
= (long)&edt_ft5506_data
},
1505 { .name
= "ev-ft5726", .driver_data
= (long)&edt_ft5506_data
},
1506 { .name
= "ft5452", .driver_data
= (long)&edt_ft5452_data
},
1507 /* Note no edt- prefix for compatibility with the ft6236.c driver */
1508 { .name
= "ft6236", .driver_data
= (long)&edt_ft6236_data
},
1509 { .name
= "ft8201", .driver_data
= (long)&edt_ft8201_data
},
1510 { .name
= "ft8719", .driver_data
= (long)&edt_ft8719_data
},
1513 MODULE_DEVICE_TABLE(i2c
, edt_ft5x06_ts_id
);
1515 static const struct of_device_id edt_ft5x06_of_match
[] = {
1516 { .compatible
= "edt,edt-ft5206", .data
= &edt_ft5x06_data
},
1517 { .compatible
= "edt,edt-ft5306", .data
= &edt_ft5x06_data
},
1518 { .compatible
= "edt,edt-ft5406", .data
= &edt_ft5x06_data
},
1519 { .compatible
= "edt,edt-ft5506", .data
= &edt_ft5506_data
},
1520 { .compatible
= "evervision,ev-ft5726", .data
= &edt_ft5506_data
},
1521 { .compatible
= "focaltech,ft5426", .data
= &edt_ft5506_data
},
1522 { .compatible
= "focaltech,ft5452", .data
= &edt_ft5452_data
},
1523 /* Note focaltech vendor prefix for compatibility with ft6236.c */
1524 { .compatible
= "focaltech,ft6236", .data
= &edt_ft6236_data
},
1525 { .compatible
= "focaltech,ft8201", .data
= &edt_ft8201_data
},
1526 { .compatible
= "focaltech,ft8719", .data
= &edt_ft8719_data
},
1529 MODULE_DEVICE_TABLE(of
, edt_ft5x06_of_match
);
1531 static struct i2c_driver edt_ft5x06_ts_driver
= {
1533 .name
= "edt_ft5x06",
1534 .dev_groups
= edt_ft5x06_groups
,
1535 .of_match_table
= edt_ft5x06_of_match
,
1536 .pm
= pm_sleep_ptr(&edt_ft5x06_ts_pm_ops
),
1537 .probe_type
= PROBE_PREFER_ASYNCHRONOUS
,
1539 .id_table
= edt_ft5x06_ts_id
,
1540 .probe
= edt_ft5x06_ts_probe
,
1541 .remove
= edt_ft5x06_ts_remove
,
1544 module_i2c_driver(edt_ft5x06_ts_driver
);
1546 MODULE_AUTHOR("Simon Budig <simon.budig@kernelconcepts.de>");
1547 MODULE_DESCRIPTION("EDT FT5x06 I2C Touchscreen Driver");
1548 MODULE_LICENSE("GPL v2");