diff options
Diffstat (limited to 'drivers/input/touchscreen')
25 files changed, 2078 insertions, 244 deletions
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c new file mode 100644 index 000000000000..b3aebc2166ba --- /dev/null +++ b/drivers/input/touchscreen/88pm860x-ts.c | |||
@@ -0,0 +1,237 @@ | |||
1 | /* | ||
2 | * Touchscreen driver for Marvell 88PM860x | ||
3 | * | ||
4 | * Copyright (C) 2009 Marvell International Ltd. | ||
5 | * Haojian Zhuang <haojian.zhuang@marvell.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/input.h> | ||
16 | #include <linux/mfd/88pm860x.h> | ||
17 | #include <linux/slab.h> | ||
18 | |||
19 | #define MEAS_LEN (8) | ||
20 | #define ACCURATE_BIT (12) | ||
21 | |||
22 | /* touch register */ | ||
23 | #define MEAS_EN3 (0x52) | ||
24 | |||
25 | #define MEAS_TSIX_1 (0x8D) | ||
26 | #define MEAS_TSIX_2 (0x8E) | ||
27 | #define MEAS_TSIY_1 (0x8F) | ||
28 | #define MEAS_TSIY_2 (0x90) | ||
29 | #define MEAS_TSIZ1_1 (0x91) | ||
30 | #define MEAS_TSIZ1_2 (0x92) | ||
31 | #define MEAS_TSIZ2_1 (0x93) | ||
32 | #define MEAS_TSIZ2_2 (0x94) | ||
33 | |||
34 | /* bit definitions of touch */ | ||
35 | #define MEAS_PD_EN (1 << 3) | ||
36 | #define MEAS_TSIX_EN (1 << 4) | ||
37 | #define MEAS_TSIY_EN (1 << 5) | ||
38 | #define MEAS_TSIZ1_EN (1 << 6) | ||
39 | #define MEAS_TSIZ2_EN (1 << 7) | ||
40 | |||
41 | struct pm860x_touch { | ||
42 | struct input_dev *idev; | ||
43 | struct i2c_client *i2c; | ||
44 | struct pm860x_chip *chip; | ||
45 | int irq; | ||
46 | int res_x; /* resistor of Xplate */ | ||
47 | }; | ||
48 | |||
49 | static irqreturn_t pm860x_touch_handler(int irq, void *data) | ||
50 | { | ||
51 | struct pm860x_touch *touch = data; | ||
52 | struct pm860x_chip *chip = touch->chip; | ||
53 | unsigned char buf[MEAS_LEN]; | ||
54 | int x, y, pen_down; | ||
55 | int z1, z2, rt = 0; | ||
56 | int ret; | ||
57 | |||
58 | ret = pm860x_bulk_read(touch->i2c, MEAS_TSIX_1, MEAS_LEN, buf); | ||
59 | if (ret < 0) | ||
60 | goto out; | ||
61 | |||
62 | pen_down = buf[1] & (1 << 6); | ||
63 | x = ((buf[0] & 0xFF) << 4) | (buf[1] & 0x0F); | ||
64 | y = ((buf[2] & 0xFF) << 4) | (buf[3] & 0x0F); | ||
65 | z1 = ((buf[4] & 0xFF) << 4) | (buf[5] & 0x0F); | ||
66 | z2 = ((buf[6] & 0xFF) << 4) | (buf[7] & 0x0F); | ||
67 | |||
68 | if (pen_down) { | ||
69 | if ((x != 0) && (z1 != 0) && (touch->res_x != 0)) { | ||
70 | rt = z2 / z1 - 1; | ||
71 | rt = (rt * touch->res_x * x) >> ACCURATE_BIT; | ||
72 | dev_dbg(chip->dev, "z1:%d, z2:%d, rt:%d\n", | ||
73 | z1, z2, rt); | ||
74 | } | ||
75 | input_report_abs(touch->idev, ABS_X, x); | ||
76 | input_report_abs(touch->idev, ABS_Y, y); | ||
77 | input_report_abs(touch->idev, ABS_PRESSURE, rt); | ||
78 | input_report_key(touch->idev, BTN_TOUCH, 1); | ||
79 | dev_dbg(chip->dev, "pen down at [%d, %d].\n", x, y); | ||
80 | } else { | ||
81 | input_report_abs(touch->idev, ABS_PRESSURE, 0); | ||
82 | input_report_key(touch->idev, BTN_TOUCH, 0); | ||
83 | dev_dbg(chip->dev, "pen release\n"); | ||
84 | } | ||
85 | input_sync(touch->idev); | ||
86 | |||
87 | out: | ||
88 | return IRQ_HANDLED; | ||
89 | } | ||
90 | |||
91 | static int pm860x_touch_open(struct input_dev *dev) | ||
92 | { | ||
93 | struct pm860x_touch *touch = input_get_drvdata(dev); | ||
94 | int data, ret; | ||
95 | |||
96 | data = MEAS_PD_EN | MEAS_TSIX_EN | MEAS_TSIY_EN | ||
97 | | MEAS_TSIZ1_EN | MEAS_TSIZ2_EN; | ||
98 | ret = pm860x_set_bits(touch->i2c, MEAS_EN3, data, data); | ||
99 | if (ret < 0) | ||
100 | goto out; | ||
101 | return 0; | ||
102 | out: | ||
103 | return ret; | ||
104 | } | ||
105 | |||
106 | static void pm860x_touch_close(struct input_dev *dev) | ||
107 | { | ||
108 | struct pm860x_touch *touch = input_get_drvdata(dev); | ||
109 | int data; | ||
110 | |||
111 | data = MEAS_PD_EN | MEAS_TSIX_EN | MEAS_TSIY_EN | ||
112 | | MEAS_TSIZ1_EN | MEAS_TSIZ2_EN; | ||
113 | pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0); | ||
114 | } | ||
115 | |||
116 | static int __devinit pm860x_touch_probe(struct platform_device *pdev) | ||
117 | { | ||
118 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); | ||
119 | struct pm860x_platform_data *pm860x_pdata = \ | ||
120 | pdev->dev.parent->platform_data; | ||
121 | struct pm860x_touch_pdata *pdata = NULL; | ||
122 | struct pm860x_touch *touch; | ||
123 | int irq, ret; | ||
124 | |||
125 | irq = platform_get_irq(pdev, 0); | ||
126 | if (irq < 0) { | ||
127 | dev_err(&pdev->dev, "No IRQ resource!\n"); | ||
128 | return -EINVAL; | ||
129 | } | ||
130 | |||
131 | if (!pm860x_pdata) { | ||
132 | dev_err(&pdev->dev, "platform data is missing\n"); | ||
133 | return -EINVAL; | ||
134 | } | ||
135 | |||
136 | pdata = pm860x_pdata->touch; | ||
137 | if (!pdata) { | ||
138 | dev_err(&pdev->dev, "touchscreen data is missing\n"); | ||
139 | return -EINVAL; | ||
140 | } | ||
141 | |||
142 | touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL); | ||
143 | if (touch == NULL) | ||
144 | return -ENOMEM; | ||
145 | dev_set_drvdata(&pdev->dev, touch); | ||
146 | |||
147 | touch->idev = input_allocate_device(); | ||
148 | if (touch->idev == NULL) { | ||
149 | dev_err(&pdev->dev, "Failed to allocate input device!\n"); | ||
150 | ret = -ENOMEM; | ||
151 | goto out; | ||
152 | } | ||
153 | |||
154 | touch->idev->name = "88pm860x-touch"; | ||
155 | touch->idev->phys = "88pm860x/input0"; | ||
156 | touch->idev->id.bustype = BUS_I2C; | ||
157 | touch->idev->dev.parent = &pdev->dev; | ||
158 | touch->idev->open = pm860x_touch_open; | ||
159 | touch->idev->close = pm860x_touch_close; | ||
160 | touch->chip = chip; | ||
161 | touch->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; | ||
162 | touch->irq = irq + chip->irq_base; | ||
163 | touch->res_x = pdata->res_x; | ||
164 | input_set_drvdata(touch->idev, touch); | ||
165 | |||
166 | ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler, | ||
167 | IRQF_ONESHOT, "touch", touch); | ||
168 | if (ret < 0) | ||
169 | goto out_irq; | ||
170 | |||
171 | __set_bit(EV_ABS, touch->idev->evbit); | ||
172 | __set_bit(ABS_X, touch->idev->absbit); | ||
173 | __set_bit(ABS_Y, touch->idev->absbit); | ||
174 | __set_bit(ABS_PRESSURE, touch->idev->absbit); | ||
175 | __set_bit(EV_SYN, touch->idev->evbit); | ||
176 | __set_bit(EV_KEY, touch->idev->evbit); | ||
177 | __set_bit(BTN_TOUCH, touch->idev->keybit); | ||
178 | |||
179 | input_set_abs_params(touch->idev, ABS_X, 0, 1 << ACCURATE_BIT, 0, 0); | ||
180 | input_set_abs_params(touch->idev, ABS_Y, 0, 1 << ACCURATE_BIT, 0, 0); | ||
181 | input_set_abs_params(touch->idev, ABS_PRESSURE, 0, 1 << ACCURATE_BIT, | ||
182 | 0, 0); | ||
183 | |||
184 | ret = input_register_device(touch->idev); | ||
185 | if (ret < 0) { | ||
186 | dev_err(chip->dev, "Failed to register touch!\n"); | ||
187 | goto out_rg; | ||
188 | } | ||
189 | |||
190 | platform_set_drvdata(pdev, touch); | ||
191 | return 0; | ||
192 | out_rg: | ||
193 | free_irq(touch->irq, touch); | ||
194 | out_irq: | ||
195 | input_free_device(touch->idev); | ||
196 | out: | ||
197 | kfree(touch); | ||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | static int __devexit pm860x_touch_remove(struct platform_device *pdev) | ||
202 | { | ||
203 | struct pm860x_touch *touch = platform_get_drvdata(pdev); | ||
204 | |||
205 | input_unregister_device(touch->idev); | ||
206 | free_irq(touch->irq, touch); | ||
207 | platform_set_drvdata(pdev, NULL); | ||
208 | kfree(touch); | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static struct platform_driver pm860x_touch_driver = { | ||
213 | .driver = { | ||
214 | .name = "88pm860x-touch", | ||
215 | .owner = THIS_MODULE, | ||
216 | }, | ||
217 | .probe = pm860x_touch_probe, | ||
218 | .remove = __devexit_p(pm860x_touch_remove), | ||
219 | }; | ||
220 | |||
221 | static int __init pm860x_touch_init(void) | ||
222 | { | ||
223 | return platform_driver_register(&pm860x_touch_driver); | ||
224 | } | ||
225 | module_init(pm860x_touch_init); | ||
226 | |||
227 | static void __exit pm860x_touch_exit(void) | ||
228 | { | ||
229 | platform_driver_unregister(&pm860x_touch_driver); | ||
230 | } | ||
231 | module_exit(pm860x_touch_exit); | ||
232 | |||
233 | MODULE_DESCRIPTION("Touchscreen driver for Marvell Semiconductor 88PM860x"); | ||
234 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); | ||
235 | MODULE_LICENSE("GPL"); | ||
236 | MODULE_ALIAS("platform:88pm860x-touch"); | ||
237 | |||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 8cc453c85ea7..8a8fa4d2d6a8 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -11,18 +11,31 @@ menuconfig INPUT_TOUCHSCREEN | |||
11 | 11 | ||
12 | if INPUT_TOUCHSCREEN | 12 | if INPUT_TOUCHSCREEN |
13 | 13 | ||
14 | config TOUCHSCREEN_88PM860X | ||
15 | tristate "Marvell 88PM860x touchscreen" | ||
16 | depends on MFD_88PM860X | ||
17 | help | ||
18 | Say Y here if you have a 88PM860x PMIC and want to enable | ||
19 | support for the built-in touchscreen. | ||
20 | |||
21 | If unsure, say N. | ||
22 | |||
23 | To compile this driver as a module, choose M here: the | ||
24 | module will be called 88pm860x-ts. | ||
25 | |||
14 | config TOUCHSCREEN_ADS7846 | 26 | config TOUCHSCREEN_ADS7846 |
15 | tristate "ADS7846/TSC2046 and ADS7843 based touchscreens" | 27 | tristate "ADS7846/TSC2046/AD7873 and AD(S)7843 based touchscreens" |
16 | depends on SPI_MASTER | 28 | depends on SPI_MASTER |
17 | depends on HWMON = n || HWMON | 29 | depends on HWMON = n || HWMON |
18 | help | 30 | help |
19 | Say Y here if you have a touchscreen interface using the | 31 | Say Y here if you have a touchscreen interface using the |
20 | ADS7846/TSC2046 or ADS7843 controller, and your board-specific | 32 | ADS7846/TSC2046/AD7873 or ADS7843/AD7843 controller, |
21 | setup code includes that in its table of SPI devices. | 33 | and your board-specific setup code includes that in its |
34 | table of SPI devices. | ||
22 | 35 | ||
23 | If HWMON is selected, and the driver is told the reference voltage | 36 | If HWMON is selected, and the driver is told the reference voltage |
24 | on your board, you will also get hwmon interfaces for the voltage | 37 | on your board, you will also get hwmon interfaces for the voltage |
25 | (and on ads7846/tsc2046, temperature) sensors of this chip. | 38 | (and on ads7846/tsc2046/ad7873, temperature) sensors of this chip. |
26 | 39 | ||
27 | If unsure, say N (but it's safe to say "Y"). | 40 | If unsure, say N (but it's safe to say "Y"). |
28 | 41 | ||
@@ -90,7 +103,6 @@ config TOUCHSCREEN_CORGI | |||
90 | tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" | 103 | tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" |
91 | depends on PXA_SHARPSL | 104 | depends on PXA_SHARPSL |
92 | select CORGI_SSP_DEPRECATED | 105 | select CORGI_SSP_DEPRECATED |
93 | default y | ||
94 | help | 106 | help |
95 | Say Y here to enable the driver for the touchscreen on the | 107 | Say Y here to enable the driver for the touchscreen on the |
96 | Sharp SL-C7xx and SL-Cxx00 series of PDAs. | 108 | Sharp SL-C7xx and SL-Cxx00 series of PDAs. |
@@ -111,6 +123,18 @@ config TOUCHSCREEN_DA9034 | |||
111 | Say Y here to enable the support for the touchscreen found | 123 | Say Y here to enable the support for the touchscreen found |
112 | on Dialog Semiconductor DA9034 PMIC. | 124 | on Dialog Semiconductor DA9034 PMIC. |
113 | 125 | ||
126 | config TOUCHSCREEN_DYNAPRO | ||
127 | tristate "Dynapro serial touchscreen" | ||
128 | select SERIO | ||
129 | help | ||
130 | Say Y here if you have a Dynapro serial touchscreen connected to | ||
131 | your system. | ||
132 | |||
133 | If unsure, say N. | ||
134 | |||
135 | To compile this driver as a module, choose M here: the | ||
136 | module will be called dynapro. | ||
137 | |||
114 | config TOUCHSCREEN_EETI | 138 | config TOUCHSCREEN_EETI |
115 | tristate "EETI touchscreen panel support" | 139 | tristate "EETI touchscreen panel support" |
116 | depends on I2C | 140 | depends on I2C |
@@ -133,6 +157,18 @@ config TOUCHSCREEN_FUJITSU | |||
133 | To compile this driver as a module, choose M here: the | 157 | To compile this driver as a module, choose M here: the |
134 | module will be called fujitsu-ts. | 158 | module will be called fujitsu-ts. |
135 | 159 | ||
160 | config TOUCHSCREEN_S3C2410 | ||
161 | tristate "Samsung S3C2410 touchscreen input driver" | ||
162 | depends on ARCH_S3C2410 | ||
163 | select S3C24XX_ADC | ||
164 | help | ||
165 | Say Y here if you have the s3c2410 touchscreen. | ||
166 | |||
167 | If unsure, say N. | ||
168 | |||
169 | To compile this driver as a module, choose M here: the | ||
170 | module will be called s3c2410_ts. | ||
171 | |||
136 | config TOUCHSCREEN_GUNZE | 172 | config TOUCHSCREEN_GUNZE |
137 | tristate "Gunze AHL-51S touchscreen" | 173 | tristate "Gunze AHL-51S touchscreen" |
138 | select SERIO | 174 | select SERIO |
@@ -297,7 +333,7 @@ config TOUCHSCREEN_TOUCHWIN | |||
297 | 333 | ||
298 | config TOUCHSCREEN_ATMEL_TSADCC | 334 | config TOUCHSCREEN_ATMEL_TSADCC |
299 | tristate "Atmel Touchscreen Interface" | 335 | tristate "Atmel Touchscreen Interface" |
300 | depends on ARCH_AT91SAM9RL | 336 | depends on ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 |
301 | help | 337 | help |
302 | Say Y here if you have a 4-wire touchscreen connected to the | 338 | Say Y here if you have a 4-wire touchscreen connected to the |
303 | ADC Controller on your Atmel SoC (such as the AT91SAM9RL). | 339 | ADC Controller on your Atmel SoC (such as the AT91SAM9RL). |
@@ -418,6 +454,7 @@ config TOUCHSCREEN_USB_COMPOSITE | |||
418 | - IdealTEK URTC1000 | 454 | - IdealTEK URTC1000 |
419 | - GoTop Super_Q2/GogoPen/PenPower tablets | 455 | - GoTop Super_Q2/GogoPen/PenPower tablets |
420 | - JASTEC USB Touch Controller/DigiTech DTR-02U | 456 | - JASTEC USB Touch Controller/DigiTech DTR-02U |
457 | - Zytronic controllers | ||
421 | 458 | ||
422 | Have a look at <http://linux.chapter7.ch/touchkit/> for | 459 | Have a look at <http://linux.chapter7.ch/touchkit/> for |
423 | a usage description and the required user-space stuff. | 460 | a usage description and the required user-space stuff. |
@@ -425,6 +462,18 @@ config TOUCHSCREEN_USB_COMPOSITE | |||
425 | To compile this driver as a module, choose M here: the | 462 | To compile this driver as a module, choose M here: the |
426 | module will be called usbtouchscreen. | 463 | module will be called usbtouchscreen. |
427 | 464 | ||
465 | config TOUCHSCREEN_MC13783 | ||
466 | tristate "Freescale MC13783 touchscreen input driver" | ||
467 | depends on MFD_MC13783 | ||
468 | help | ||
469 | Say Y here if you have an Freescale MC13783 PMIC on your | ||
470 | board and want to use its touchscreen | ||
471 | |||
472 | If unsure, say N. | ||
473 | |||
474 | To compile this driver as a module, choose M here: the | ||
475 | module will be called mc13783_ts. | ||
476 | |||
428 | config TOUCHSCREEN_USB_EGALAX | 477 | config TOUCHSCREEN_USB_EGALAX |
429 | default y | 478 | default y |
430 | bool "eGalax, eTurboTouch CT-410/510/700 device support" if EMBEDDED | 479 | bool "eGalax, eTurboTouch CT-410/510/700 device support" if EMBEDDED |
@@ -490,6 +539,21 @@ config TOUCHSCREEN_USB_E2I | |||
490 | bool "e2i Touchscreen controller (e.g. from Mimo 740)" | 539 | bool "e2i Touchscreen controller (e.g. from Mimo 740)" |
491 | depends on TOUCHSCREEN_USB_COMPOSITE | 540 | depends on TOUCHSCREEN_USB_COMPOSITE |
492 | 541 | ||
542 | config TOUCHSCREEN_USB_ZYTRONIC | ||
543 | default y | ||
544 | bool "Zytronic controller" if EMBEDDED | ||
545 | depends on TOUCHSCREEN_USB_COMPOSITE | ||
546 | |||
547 | config TOUCHSCREEN_USB_ETT_TC5UH | ||
548 | default y | ||
549 | bool "ET&T TC5UH touchscreen controler support" if EMBEDDED | ||
550 | depends on TOUCHSCREEN_USB_COMPOSITE | ||
551 | |||
552 | config TOUCHSCREEN_USB_NEXIO | ||
553 | default y | ||
554 | bool "NEXIO/iNexio device support" if EMBEDDED | ||
555 | depends on TOUCHSCREEN_USB_COMPOSITE | ||
556 | |||
493 | config TOUCHSCREEN_TOUCHIT213 | 557 | config TOUCHSCREEN_TOUCHIT213 |
494 | tristate "Sahara TouchIT-213 touchscreen" | 558 | tristate "Sahara TouchIT-213 touchscreen" |
495 | select SERIO | 559 | select SERIO |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 15fa62cffc77..7fef7d5cca23 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -6,17 +6,20 @@ | |||
6 | 6 | ||
7 | wm97xx-ts-y := wm97xx-core.o | 7 | wm97xx-ts-y := wm97xx-core.o |
8 | 8 | ||
9 | obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o | ||
9 | obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o | 10 | obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o |
10 | obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o | 11 | obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o |
11 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o | 12 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o |
12 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o | 13 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o |
13 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o | 14 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o |
14 | obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o | 15 | obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o |
16 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o | ||
15 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o | 17 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o |
16 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o | 18 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o |
17 | obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o | 19 | obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o |
18 | obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o | 20 | obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o |
19 | obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o | 21 | obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o |
22 | obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o | ||
20 | obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o | 23 | obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o |
21 | obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o | 24 | obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o |
22 | obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o | 25 | obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o |
@@ -25,7 +28,9 @@ obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o | |||
25 | obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o | 28 | obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o |
26 | obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o | 29 | obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o |
27 | obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o | 30 | obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o |
31 | obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o | ||
28 | obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o | 32 | obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o |
33 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o | ||
29 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o | 34 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o |
30 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o | 35 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o |
31 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o | 36 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o |
@@ -41,4 +46,3 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL) += atmel-wm97xx.o | |||
41 | obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o | 46 | obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o |
42 | obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o | 47 | obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o |
43 | obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o | 48 | obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o |
44 | obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o | ||
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index eb83939c705e..0d2d7e54b465 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/spi/ad7877.h> | 46 | #include <linux/spi/ad7877.h> |
47 | #include <asm/irq.h> | 47 | #include <asm/irq.h> |
48 | 48 | ||
49 | #define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50) | 49 | #define TS_PEN_UP_TIMEOUT msecs_to_jiffies(100) |
50 | 50 | ||
51 | #define MAX_SPI_FREQ_HZ 20000000 | 51 | #define MAX_SPI_FREQ_HZ 20000000 |
52 | #define MAX_12BIT ((1<<12)-1) | 52 | #define MAX_12BIT ((1<<12)-1) |
@@ -156,9 +156,14 @@ struct ser_req { | |||
156 | u16 reset; | 156 | u16 reset; |
157 | u16 ref_on; | 157 | u16 ref_on; |
158 | u16 command; | 158 | u16 command; |
159 | u16 sample; | ||
160 | struct spi_message msg; | 159 | struct spi_message msg; |
161 | struct spi_transfer xfer[6]; | 160 | struct spi_transfer xfer[6]; |
161 | |||
162 | /* | ||
163 | * DMA (thus cache coherency maintenance) requires the | ||
164 | * transfer buffers to live in their own cache lines. | ||
165 | */ | ||
166 | u16 sample ____cacheline_aligned; | ||
162 | }; | 167 | }; |
163 | 168 | ||
164 | struct ad7877 { | 169 | struct ad7877 { |
@@ -182,8 +187,6 @@ struct ad7877 { | |||
182 | u8 averaging; | 187 | u8 averaging; |
183 | u8 pen_down_acc_interval; | 188 | u8 pen_down_acc_interval; |
184 | 189 | ||
185 | u16 conversion_data[AD7877_NR_SENSE]; | ||
186 | |||
187 | struct spi_transfer xfer[AD7877_NR_SENSE + 2]; | 190 | struct spi_transfer xfer[AD7877_NR_SENSE + 2]; |
188 | struct spi_message msg; | 191 | struct spi_message msg; |
189 | 192 | ||
@@ -195,6 +198,12 @@ struct ad7877 { | |||
195 | spinlock_t lock; | 198 | spinlock_t lock; |
196 | struct timer_list timer; /* P: lock */ | 199 | struct timer_list timer; /* P: lock */ |
197 | unsigned pending:1; /* P: lock */ | 200 | unsigned pending:1; /* P: lock */ |
201 | |||
202 | /* | ||
203 | * DMA (thus cache coherency maintenance) requires the | ||
204 | * transfer buffers to live in their own cache lines. | ||
205 | */ | ||
206 | u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned; | ||
198 | }; | 207 | }; |
199 | 208 | ||
200 | static int gpio3; | 209 | static int gpio3; |
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c index c21e6d3a8844..794d070c6900 100644 --- a/drivers/input/touchscreen/ad7879.c +++ b/drivers/input/touchscreen/ad7879.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/workqueue.h> | 47 | #include <linux/workqueue.h> |
48 | #include <linux/spi/spi.h> | 48 | #include <linux/spi/spi.h> |
49 | #include <linux/i2c.h> | 49 | #include <linux/i2c.h> |
50 | #include <linux/gpio.h> | ||
50 | 51 | ||
51 | #include <linux/spi/ad7879.h> | 52 | #include <linux/spi/ad7879.h> |
52 | 53 | ||
@@ -132,7 +133,9 @@ struct ad7879 { | |||
132 | struct input_dev *input; | 133 | struct input_dev *input; |
133 | struct work_struct work; | 134 | struct work_struct work; |
134 | struct timer_list timer; | 135 | struct timer_list timer; |
135 | 136 | #ifdef CONFIG_GPIOLIB | |
137 | struct gpio_chip gc; | ||
138 | #endif | ||
136 | struct mutex mutex; | 139 | struct mutex mutex; |
137 | unsigned disabled:1; /* P: mutex */ | 140 | unsigned disabled:1; /* P: mutex */ |
138 | 141 | ||
@@ -150,11 +153,9 @@ struct ad7879 { | |||
150 | u8 median; | 153 | u8 median; |
151 | u16 x_plate_ohms; | 154 | u16 x_plate_ohms; |
152 | u16 pressure_max; | 155 | u16 pressure_max; |
153 | u16 gpio_init; | ||
154 | u16 cmd_crtl1; | 156 | u16 cmd_crtl1; |
155 | u16 cmd_crtl2; | 157 | u16 cmd_crtl2; |
156 | u16 cmd_crtl3; | 158 | u16 cmd_crtl3; |
157 | unsigned gpio:1; | ||
158 | }; | 159 | }; |
159 | 160 | ||
160 | static int ad7879_read(bus_device *, u8); | 161 | static int ad7879_read(bus_device *, u8); |
@@ -237,24 +238,6 @@ static irqreturn_t ad7879_irq(int irq, void *handle) | |||
237 | 238 | ||
238 | static void ad7879_setup(struct ad7879 *ts) | 239 | static void ad7879_setup(struct ad7879 *ts) |
239 | { | 240 | { |
240 | ts->cmd_crtl3 = AD7879_YPLUS_BIT | | ||
241 | AD7879_XPLUS_BIT | | ||
242 | AD7879_Z2_BIT | | ||
243 | AD7879_Z1_BIT | | ||
244 | AD7879_TEMPMASK_BIT | | ||
245 | AD7879_AUXVBATMASK_BIT | | ||
246 | AD7879_GPIOALERTMASK_BIT; | ||
247 | |||
248 | ts->cmd_crtl2 = AD7879_PM(AD7879_PM_DYN) | AD7879_DFR | | ||
249 | AD7879_AVG(ts->averaging) | | ||
250 | AD7879_MFS(ts->median) | | ||
251 | AD7879_FCD(ts->first_conversion_delay) | | ||
252 | ts->gpio_init; | ||
253 | |||
254 | ts->cmd_crtl1 = AD7879_MODE_INT | AD7879_MODE_SEQ1 | | ||
255 | AD7879_ACQ(ts->acquisition_time) | | ||
256 | AD7879_TMR(ts->pen_down_acc_interval); | ||
257 | |||
258 | ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); | 241 | ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); |
259 | ad7879_write(ts->bus, AD7879_REG_CTRL3, ts->cmd_crtl3); | 242 | ad7879_write(ts->bus, AD7879_REG_CTRL3, ts->cmd_crtl3); |
260 | ad7879_write(ts->bus, AD7879_REG_CTRL1, ts->cmd_crtl1); | 243 | ad7879_write(ts->bus, AD7879_REG_CTRL1, ts->cmd_crtl1); |
@@ -324,48 +307,132 @@ static ssize_t ad7879_disable_store(struct device *dev, | |||
324 | 307 | ||
325 | static DEVICE_ATTR(disable, 0664, ad7879_disable_show, ad7879_disable_store); | 308 | static DEVICE_ATTR(disable, 0664, ad7879_disable_show, ad7879_disable_store); |
326 | 309 | ||
327 | static ssize_t ad7879_gpio_show(struct device *dev, | 310 | static struct attribute *ad7879_attributes[] = { |
328 | struct device_attribute *attr, char *buf) | 311 | &dev_attr_disable.attr, |
312 | NULL | ||
313 | }; | ||
314 | |||
315 | static const struct attribute_group ad7879_attr_group = { | ||
316 | .attrs = ad7879_attributes, | ||
317 | }; | ||
318 | |||
319 | #ifdef CONFIG_GPIOLIB | ||
320 | static int ad7879_gpio_direction_input(struct gpio_chip *chip, | ||
321 | unsigned gpio) | ||
329 | { | 322 | { |
330 | struct ad7879 *ts = dev_get_drvdata(dev); | 323 | struct ad7879 *ts = container_of(chip, struct ad7879, gc); |
324 | int err; | ||
331 | 325 | ||
332 | return sprintf(buf, "%u\n", ts->gpio); | 326 | mutex_lock(&ts->mutex); |
327 | ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIODIR | AD7879_GPIOPOL; | ||
328 | err = ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); | ||
329 | mutex_unlock(&ts->mutex); | ||
330 | |||
331 | return err; | ||
333 | } | 332 | } |
334 | 333 | ||
335 | static ssize_t ad7879_gpio_store(struct device *dev, | 334 | static int ad7879_gpio_direction_output(struct gpio_chip *chip, |
336 | struct device_attribute *attr, | 335 | unsigned gpio, int level) |
337 | const char *buf, size_t count) | ||
338 | { | 336 | { |
339 | struct ad7879 *ts = dev_get_drvdata(dev); | 337 | struct ad7879 *ts = container_of(chip, struct ad7879, gc); |
340 | unsigned long val; | 338 | int err; |
341 | int error; | ||
342 | 339 | ||
343 | error = strict_strtoul(buf, 10, &val); | 340 | mutex_lock(&ts->mutex); |
344 | if (error) | 341 | ts->cmd_crtl2 &= ~AD7879_GPIODIR; |
345 | return error; | 342 | ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIOPOL; |
343 | if (level) | ||
344 | ts->cmd_crtl2 |= AD7879_GPIO_DATA; | ||
345 | else | ||
346 | ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; | ||
347 | |||
348 | err = ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); | ||
349 | mutex_unlock(&ts->mutex); | ||
350 | |||
351 | return err; | ||
352 | } | ||
353 | |||
354 | static int ad7879_gpio_get_value(struct gpio_chip *chip, unsigned gpio) | ||
355 | { | ||
356 | struct ad7879 *ts = container_of(chip, struct ad7879, gc); | ||
357 | u16 val; | ||
346 | 358 | ||
347 | mutex_lock(&ts->mutex); | 359 | mutex_lock(&ts->mutex); |
348 | ts->gpio = !!val; | 360 | val = ad7879_read(ts->bus, AD7879_REG_CTRL2); |
349 | error = ad7879_write(ts->bus, AD7879_REG_CTRL2, | ||
350 | ts->gpio ? | ||
351 | ts->cmd_crtl2 & ~AD7879_GPIO_DATA : | ||
352 | ts->cmd_crtl2 | AD7879_GPIO_DATA); | ||
353 | mutex_unlock(&ts->mutex); | 361 | mutex_unlock(&ts->mutex); |
354 | 362 | ||
355 | return error ? : count; | 363 | return !!(val & AD7879_GPIO_DATA); |
356 | } | 364 | } |
357 | 365 | ||
358 | static DEVICE_ATTR(gpio, 0664, ad7879_gpio_show, ad7879_gpio_store); | 366 | static void ad7879_gpio_set_value(struct gpio_chip *chip, |
367 | unsigned gpio, int value) | ||
368 | { | ||
369 | struct ad7879 *ts = container_of(chip, struct ad7879, gc); | ||
359 | 370 | ||
360 | static struct attribute *ad7879_attributes[] = { | 371 | mutex_lock(&ts->mutex); |
361 | &dev_attr_disable.attr, | 372 | if (value) |
362 | &dev_attr_gpio.attr, | 373 | ts->cmd_crtl2 |= AD7879_GPIO_DATA; |
363 | NULL | 374 | else |
364 | }; | 375 | ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; |
365 | 376 | ||
366 | static const struct attribute_group ad7879_attr_group = { | 377 | ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); |
367 | .attrs = ad7879_attributes, | 378 | mutex_unlock(&ts->mutex); |
368 | }; | 379 | } |
380 | |||
381 | static int __devinit ad7879_gpio_add(struct device *dev) | ||
382 | { | ||
383 | struct ad7879 *ts = dev_get_drvdata(dev); | ||
384 | struct ad7879_platform_data *pdata = dev->platform_data; | ||
385 | int ret = 0; | ||
386 | |||
387 | if (pdata->gpio_export) { | ||
388 | ts->gc.direction_input = ad7879_gpio_direction_input; | ||
389 | ts->gc.direction_output = ad7879_gpio_direction_output; | ||
390 | ts->gc.get = ad7879_gpio_get_value; | ||
391 | ts->gc.set = ad7879_gpio_set_value; | ||
392 | ts->gc.can_sleep = 1; | ||
393 | ts->gc.base = pdata->gpio_base; | ||
394 | ts->gc.ngpio = 1; | ||
395 | ts->gc.label = "AD7879-GPIO"; | ||
396 | ts->gc.owner = THIS_MODULE; | ||
397 | ts->gc.dev = dev; | ||
398 | |||
399 | ret = gpiochip_add(&ts->gc); | ||
400 | if (ret) | ||
401 | dev_err(dev, "failed to register gpio %d\n", | ||
402 | ts->gc.base); | ||
403 | } | ||
404 | |||
405 | return ret; | ||
406 | } | ||
407 | |||
408 | /* | ||
409 | * We mark ad7879_gpio_remove inline so there is a chance the code | ||
410 | * gets discarded when not needed. We can't do __devinit/__devexit | ||
411 | * markup since it is used in both probe and remove methods. | ||
412 | */ | ||
413 | static inline void ad7879_gpio_remove(struct device *dev) | ||
414 | { | ||
415 | struct ad7879 *ts = dev_get_drvdata(dev); | ||
416 | struct ad7879_platform_data *pdata = dev->platform_data; | ||
417 | int ret; | ||
418 | |||
419 | if (pdata->gpio_export) { | ||
420 | ret = gpiochip_remove(&ts->gc); | ||
421 | if (ret) | ||
422 | dev_err(dev, "failed to remove gpio %d\n", | ||
423 | ts->gc.base); | ||
424 | } | ||
425 | } | ||
426 | #else | ||
427 | static inline int ad7879_gpio_add(struct device *dev) | ||
428 | { | ||
429 | return 0; | ||
430 | } | ||
431 | |||
432 | static inline void ad7879_gpio_remove(struct device *dev) | ||
433 | { | ||
434 | } | ||
435 | #endif | ||
369 | 436 | ||
370 | static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) | 437 | static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) |
371 | { | 438 | { |
@@ -403,12 +470,6 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) | |||
403 | ts->pen_down_acc_interval = pdata->pen_down_acc_interval; | 470 | ts->pen_down_acc_interval = pdata->pen_down_acc_interval; |
404 | ts->median = pdata->median; | 471 | ts->median = pdata->median; |
405 | 472 | ||
406 | if (pdata->gpio_output) | ||
407 | ts->gpio_init = AD7879_GPIO_EN | | ||
408 | (pdata->gpio_default ? 0 : AD7879_GPIO_DATA); | ||
409 | else | ||
410 | ts->gpio_init = AD7879_GPIO_EN | AD7879_GPIODIR; | ||
411 | |||
412 | snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&bus->dev)); | 473 | snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&bus->dev)); |
413 | 474 | ||
414 | input_dev->name = "AD7879 Touchscreen"; | 475 | input_dev->name = "AD7879 Touchscreen"; |
@@ -446,6 +507,23 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) | |||
446 | goto err_free_mem; | 507 | goto err_free_mem; |
447 | } | 508 | } |
448 | 509 | ||
510 | ts->cmd_crtl3 = AD7879_YPLUS_BIT | | ||
511 | AD7879_XPLUS_BIT | | ||
512 | AD7879_Z2_BIT | | ||
513 | AD7879_Z1_BIT | | ||
514 | AD7879_TEMPMASK_BIT | | ||
515 | AD7879_AUXVBATMASK_BIT | | ||
516 | AD7879_GPIOALERTMASK_BIT; | ||
517 | |||
518 | ts->cmd_crtl2 = AD7879_PM(AD7879_PM_DYN) | AD7879_DFR | | ||
519 | AD7879_AVG(ts->averaging) | | ||
520 | AD7879_MFS(ts->median) | | ||
521 | AD7879_FCD(ts->first_conversion_delay); | ||
522 | |||
523 | ts->cmd_crtl1 = AD7879_MODE_INT | AD7879_MODE_SEQ1 | | ||
524 | AD7879_ACQ(ts->acquisition_time) | | ||
525 | AD7879_TMR(ts->pen_down_acc_interval); | ||
526 | |||
449 | ad7879_setup(ts); | 527 | ad7879_setup(ts); |
450 | 528 | ||
451 | err = request_irq(bus->irq, ad7879_irq, | 529 | err = request_irq(bus->irq, ad7879_irq, |
@@ -460,15 +538,21 @@ static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) | |||
460 | if (err) | 538 | if (err) |
461 | goto err_free_irq; | 539 | goto err_free_irq; |
462 | 540 | ||
463 | err = input_register_device(input_dev); | 541 | err = ad7879_gpio_add(&bus->dev); |
464 | if (err) | 542 | if (err) |
465 | goto err_remove_attr; | 543 | goto err_remove_attr; |
466 | 544 | ||
545 | err = input_register_device(input_dev); | ||
546 | if (err) | ||
547 | goto err_remove_gpio; | ||
548 | |||
467 | dev_info(&bus->dev, "Rev.%d touchscreen, irq %d\n", | 549 | dev_info(&bus->dev, "Rev.%d touchscreen, irq %d\n", |
468 | revid >> 8, bus->irq); | 550 | revid >> 8, bus->irq); |
469 | 551 | ||
470 | return 0; | 552 | return 0; |
471 | 553 | ||
554 | err_remove_gpio: | ||
555 | ad7879_gpio_remove(&bus->dev); | ||
472 | err_remove_attr: | 556 | err_remove_attr: |
473 | sysfs_remove_group(&bus->dev.kobj, &ad7879_attr_group); | 557 | sysfs_remove_group(&bus->dev.kobj, &ad7879_attr_group); |
474 | err_free_irq: | 558 | err_free_irq: |
@@ -481,6 +565,7 @@ err_free_mem: | |||
481 | 565 | ||
482 | static int __devexit ad7879_destroy(bus_device *bus, struct ad7879 *ts) | 566 | static int __devexit ad7879_destroy(bus_device *bus, struct ad7879 *ts) |
483 | { | 567 | { |
568 | ad7879_gpio_remove(&bus->dev); | ||
484 | ad7879_disable(ts); | 569 | ad7879_disable(ts); |
485 | sysfs_remove_group(&ts->bus->dev.kobj, &ad7879_attr_group); | 570 | sysfs_remove_group(&ts->bus->dev.kobj, &ad7879_attr_group); |
486 | free_irq(ts->bus->irq, ts); | 571 | free_irq(ts->bus->irq, ts); |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 09c810999b92..532279cda0e4 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -27,15 +27,16 @@ | |||
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
29 | #include <linux/spi/ads7846.h> | 29 | #include <linux/spi/ads7846.h> |
30 | #include <linux/regulator/consumer.h> | ||
30 | #include <asm/irq.h> | 31 | #include <asm/irq.h> |
31 | 32 | ||
32 | |||
33 | /* | 33 | /* |
34 | * This code has been heavily tested on a Nokia 770, and lightly | 34 | * This code has been heavily tested on a Nokia 770, and lightly |
35 | * tested on other ads7846 devices (OSK/Mistral, Lubbock). | 35 | * tested on other ads7846 devices (OSK/Mistral, Lubbock, Spitz). |
36 | * TSC2046 is just newer ads7846 silicon. | 36 | * TSC2046 is just newer ads7846 silicon. |
37 | * Support for ads7843 tested on Atmel at91sam926x-EK. | 37 | * Support for ads7843 tested on Atmel at91sam926x-EK. |
38 | * Support for ads7845 has only been stubbed in. | 38 | * Support for ads7845 has only been stubbed in. |
39 | * Support for Analog Devices AD7873 and AD7843 tested. | ||
39 | * | 40 | * |
40 | * IRQ handling needs a workaround because of a shortcoming in handling | 41 | * IRQ handling needs a workaround because of a shortcoming in handling |
41 | * edge triggered IRQs on some platforms like the OMAP1/2. These | 42 | * edge triggered IRQs on some platforms like the OMAP1/2. These |
@@ -43,7 +44,7 @@ | |||
43 | * have to maintain our own SW IRQ disabled status. This should be | 44 | * have to maintain our own SW IRQ disabled status. This should be |
44 | * removed as soon as the affected platform's IRQ handling is fixed. | 45 | * removed as soon as the affected platform's IRQ handling is fixed. |
45 | * | 46 | * |
46 | * app note sbaa036 talks in more detail about accurate sampling... | 47 | * App note sbaa036 talks in more detail about accurate sampling... |
47 | * that ought to help in situations like LCDs inducing noise (which | 48 | * that ought to help in situations like LCDs inducing noise (which |
48 | * can also be helped by using synch signals) and more generally. | 49 | * can also be helped by using synch signals) and more generally. |
49 | * This driver tries to utilize the measures described in the app | 50 | * This driver tries to utilize the measures described in the app |
@@ -86,6 +87,7 @@ struct ads7846 { | |||
86 | char name[32]; | 87 | char name[32]; |
87 | 88 | ||
88 | struct spi_device *spi; | 89 | struct spi_device *spi; |
90 | struct regulator *reg; | ||
89 | 91 | ||
90 | #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) | 92 | #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) |
91 | struct attribute_group *attr_group; | 93 | struct attribute_group *attr_group; |
@@ -566,10 +568,8 @@ static void ads7846_rx(void *ads) | |||
566 | * once more the measurement | 568 | * once more the measurement |
567 | */ | 569 | */ |
568 | if (packet->tc.ignore || Rt > ts->pressure_max) { | 570 | if (packet->tc.ignore || Rt > ts->pressure_max) { |
569 | #ifdef VERBOSE | 571 | dev_vdbg(&ts->spi->dev, "ignored %d pressure %d\n", |
570 | pr_debug("%s: ignored %d pressure %d\n", | 572 | packet->tc.ignore, Rt); |
571 | dev_name(&ts->spi->dev), packet->tc.ignore, Rt); | ||
572 | #endif | ||
573 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), | 573 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
574 | HRTIMER_MODE_REL); | 574 | HRTIMER_MODE_REL); |
575 | return; | 575 | return; |
@@ -598,9 +598,7 @@ static void ads7846_rx(void *ads) | |||
598 | if (!ts->pendown) { | 598 | if (!ts->pendown) { |
599 | input_report_key(input, BTN_TOUCH, 1); | 599 | input_report_key(input, BTN_TOUCH, 1); |
600 | ts->pendown = 1; | 600 | ts->pendown = 1; |
601 | #ifdef VERBOSE | 601 | dev_vdbg(&ts->spi->dev, "DOWN\n"); |
602 | dev_dbg(&ts->spi->dev, "DOWN\n"); | ||
603 | #endif | ||
604 | } | 602 | } |
605 | 603 | ||
606 | if (ts->swap_xy) | 604 | if (ts->swap_xy) |
@@ -608,12 +606,10 @@ static void ads7846_rx(void *ads) | |||
608 | 606 | ||
609 | input_report_abs(input, ABS_X, x); | 607 | input_report_abs(input, ABS_X, x); |
610 | input_report_abs(input, ABS_Y, y); | 608 | input_report_abs(input, ABS_Y, y); |
611 | input_report_abs(input, ABS_PRESSURE, Rt); | 609 | input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt); |
612 | 610 | ||
613 | input_sync(input); | 611 | input_sync(input); |
614 | #ifdef VERBOSE | 612 | dev_vdbg(&ts->spi->dev, "%4d/%4d/%4d\n", x, y, Rt); |
615 | dev_dbg(&ts->spi->dev, "%4d/%4d/%4d\n", x, y, Rt); | ||
616 | #endif | ||
617 | } | 613 | } |
618 | 614 | ||
619 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), | 615 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
@@ -723,9 +719,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle) | |||
723 | input_sync(input); | 719 | input_sync(input); |
724 | 720 | ||
725 | ts->pendown = 0; | 721 | ts->pendown = 0; |
726 | #ifdef VERBOSE | 722 | dev_vdbg(&ts->spi->dev, "UP\n"); |
727 | dev_dbg(&ts->spi->dev, "UP\n"); | ||
728 | #endif | ||
729 | } | 723 | } |
730 | 724 | ||
731 | /* measurement cycle ended */ | 725 | /* measurement cycle ended */ |
@@ -797,6 +791,8 @@ static void ads7846_disable(struct ads7846 *ts) | |||
797 | } | 791 | } |
798 | } | 792 | } |
799 | 793 | ||
794 | regulator_disable(ts->reg); | ||
795 | |||
800 | /* we know the chip's in lowpower mode since we always | 796 | /* we know the chip's in lowpower mode since we always |
801 | * leave it that way after every request | 797 | * leave it that way after every request |
802 | */ | 798 | */ |
@@ -808,6 +804,8 @@ static void ads7846_enable(struct ads7846 *ts) | |||
808 | if (!ts->disabled) | 804 | if (!ts->disabled) |
809 | return; | 805 | return; |
810 | 806 | ||
807 | regulator_enable(ts->reg); | ||
808 | |||
811 | ts->disabled = 0; | 809 | ts->disabled = 0; |
812 | ts->irq_disabled = 0; | 810 | ts->irq_disabled = 0; |
813 | enable_irq(ts->spi->irq); | 811 | enable_irq(ts->spi->irq); |
@@ -824,6 +822,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message) | |||
824 | 822 | ||
825 | spin_unlock_irq(&ts->lock); | 823 | spin_unlock_irq(&ts->lock); |
826 | 824 | ||
825 | if (device_may_wakeup(&ts->spi->dev)) | ||
826 | enable_irq_wake(ts->spi->irq); | ||
827 | |||
827 | return 0; | 828 | return 0; |
828 | 829 | ||
829 | } | 830 | } |
@@ -832,6 +833,9 @@ static int ads7846_resume(struct spi_device *spi) | |||
832 | { | 833 | { |
833 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 834 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); |
834 | 835 | ||
836 | if (device_may_wakeup(&ts->spi->dev)) | ||
837 | disable_irq_wake(ts->spi->irq); | ||
838 | |||
835 | spin_lock_irq(&ts->lock); | 839 | spin_lock_irq(&ts->lock); |
836 | 840 | ||
837 | ts->is_suspended = 0; | 841 | ts->is_suspended = 0; |
@@ -987,6 +991,15 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
987 | 991 | ||
988 | vref = pdata->keep_vref_on; | 992 | vref = pdata->keep_vref_on; |
989 | 993 | ||
994 | if (ts->model == 7873) { | ||
995 | /* The AD7873 is almost identical to the ADS7846 | ||
996 | * keep VREF off during differential/ratiometric | ||
997 | * conversion modes | ||
998 | */ | ||
999 | ts->model = 7846; | ||
1000 | vref = 0; | ||
1001 | } | ||
1002 | |||
990 | /* set up the transfers to read touchscreen state; this assumes we | 1003 | /* set up the transfers to read touchscreen state; this assumes we |
991 | * use formula #2 for pressure, not #3. | 1004 | * use formula #2 for pressure, not #3. |
992 | */ | 1005 | */ |
@@ -1148,6 +1161,19 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1148 | 1161 | ||
1149 | ts->last_msg = m; | 1162 | ts->last_msg = m; |
1150 | 1163 | ||
1164 | ts->reg = regulator_get(&spi->dev, "vcc"); | ||
1165 | if (IS_ERR(ts->reg)) { | ||
1166 | dev_err(&spi->dev, "unable to get regulator: %ld\n", | ||
1167 | PTR_ERR(ts->reg)); | ||
1168 | goto err_free_gpio; | ||
1169 | } | ||
1170 | |||
1171 | err = regulator_enable(ts->reg); | ||
1172 | if (err) { | ||
1173 | dev_err(&spi->dev, "unable to enable regulator: %d\n", err); | ||
1174 | goto err_put_regulator; | ||
1175 | } | ||
1176 | |||
1151 | if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, | 1177 | if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, |
1152 | spi->dev.driver->name, ts)) { | 1178 | spi->dev.driver->name, ts)) { |
1153 | dev_info(&spi->dev, | 1179 | dev_info(&spi->dev, |
@@ -1157,7 +1183,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1157 | spi->dev.driver->name, ts); | 1183 | spi->dev.driver->name, ts); |
1158 | if (err) { | 1184 | if (err) { |
1159 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); | 1185 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); |
1160 | goto err_free_gpio; | 1186 | goto err_disable_regulator; |
1161 | } | 1187 | } |
1162 | } | 1188 | } |
1163 | 1189 | ||
@@ -1181,6 +1207,8 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1181 | if (err) | 1207 | if (err) |
1182 | goto err_remove_attr_group; | 1208 | goto err_remove_attr_group; |
1183 | 1209 | ||
1210 | device_init_wakeup(&spi->dev, pdata->wakeup); | ||
1211 | |||
1184 | return 0; | 1212 | return 0; |
1185 | 1213 | ||
1186 | err_remove_attr_group: | 1214 | err_remove_attr_group: |
@@ -1189,6 +1217,10 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1189 | ads784x_hwmon_unregister(spi, ts); | 1217 | ads784x_hwmon_unregister(spi, ts); |
1190 | err_free_irq: | 1218 | err_free_irq: |
1191 | free_irq(spi->irq, ts); | 1219 | free_irq(spi->irq, ts); |
1220 | err_disable_regulator: | ||
1221 | regulator_disable(ts->reg); | ||
1222 | err_put_regulator: | ||
1223 | regulator_put(ts->reg); | ||
1192 | err_free_gpio: | 1224 | err_free_gpio: |
1193 | if (ts->gpio_pendown != -1) | 1225 | if (ts->gpio_pendown != -1) |
1194 | gpio_free(ts->gpio_pendown); | 1226 | gpio_free(ts->gpio_pendown); |
@@ -1206,6 +1238,8 @@ static int __devexit ads7846_remove(struct spi_device *spi) | |||
1206 | { | 1238 | { |
1207 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 1239 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); |
1208 | 1240 | ||
1241 | device_init_wakeup(&spi->dev, false); | ||
1242 | |||
1209 | ads784x_hwmon_unregister(spi, ts); | 1243 | ads784x_hwmon_unregister(spi, ts); |
1210 | input_unregister_device(ts->input); | 1244 | input_unregister_device(ts->input); |
1211 | 1245 | ||
@@ -1217,6 +1251,9 @@ static int __devexit ads7846_remove(struct spi_device *spi) | |||
1217 | /* suspend left the IRQ disabled */ | 1251 | /* suspend left the IRQ disabled */ |
1218 | enable_irq(ts->spi->irq); | 1252 | enable_irq(ts->spi->irq); |
1219 | 1253 | ||
1254 | regulator_disable(ts->reg); | ||
1255 | regulator_put(ts->reg); | ||
1256 | |||
1220 | if (ts->gpio_pendown != -1) | 1257 | if (ts->gpio_pendown != -1) |
1221 | gpio_free(ts->gpio_pendown); | 1258 | gpio_free(ts->gpio_pendown); |
1222 | 1259 | ||
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c index 35377f583e28..fa8e56bd9094 100644 --- a/drivers/input/touchscreen/atmel-wm97xx.c +++ b/drivers/input/touchscreen/atmel-wm97xx.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
20 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #define AC97C_ICA 0x10 | 24 | #define AC97C_ICA 0x10 |
24 | #define AC97C_CBRHR 0x30 | 25 | #define AC97C_CBRHR 0x30 |
@@ -59,7 +60,7 @@ | |||
59 | #define ATMEL_WM97XX_AC97C_IRQ (29) | 60 | #define ATMEL_WM97XX_AC97C_IRQ (29) |
60 | #define ATMEL_WM97XX_GPIO_DEFAULT (32+16) /* Pin 16 on port B. */ | 61 | #define ATMEL_WM97XX_GPIO_DEFAULT (32+16) /* Pin 16 on port B. */ |
61 | #else | 62 | #else |
62 | #error Unkown CPU, this driver only supports AT32AP700X CPUs. | 63 | #error Unknown CPU, this driver only supports AT32AP700X CPUs. |
63 | #endif | 64 | #endif |
64 | 65 | ||
65 | struct continuous { | 66 | struct continuous { |
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c index 9c7fce4d74d0..3d9b5166ebe9 100644 --- a/drivers/input/touchscreen/atmel_tsadcc.c +++ b/drivers/input/touchscreen/atmel_tsadcc.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <mach/board.h> | ||
26 | #include <mach/cpu.h> | ||
25 | 27 | ||
26 | /* Register definitions based on AT91SAM9RL64 preliminary draft datasheet */ | 28 | /* Register definitions based on AT91SAM9RL64 preliminary draft datasheet */ |
27 | 29 | ||
@@ -36,7 +38,9 @@ | |||
36 | #define ATMEL_TSADCC_LOWRES (1 << 4) /* Resolution selection */ | 38 | #define ATMEL_TSADCC_LOWRES (1 << 4) /* Resolution selection */ |
37 | #define ATMEL_TSADCC_SLEEP (1 << 5) /* Sleep mode */ | 39 | #define ATMEL_TSADCC_SLEEP (1 << 5) /* Sleep mode */ |
38 | #define ATMEL_TSADCC_PENDET (1 << 6) /* Pen Detect selection */ | 40 | #define ATMEL_TSADCC_PENDET (1 << 6) /* Pen Detect selection */ |
41 | #define ATMEL_TSADCC_PRES (1 << 7) /* Pressure Measurement Selection */ | ||
39 | #define ATMEL_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */ | 42 | #define ATMEL_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */ |
43 | #define ATMEL_TSADCC_EPRESCAL (0xff << 8) /* Prescalar Rate Selection (Extended) */ | ||
40 | #define ATMEL_TSADCC_STARTUP (0x7f << 16) /* Start Up time */ | 44 | #define ATMEL_TSADCC_STARTUP (0x7f << 16) /* Start Up time */ |
41 | #define ATMEL_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */ | 45 | #define ATMEL_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */ |
42 | #define ATMEL_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */ | 46 | #define ATMEL_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */ |
@@ -84,7 +88,13 @@ | |||
84 | #define ATMEL_TSADCC_CDR4 0x40 /* Channel Data 4 */ | 88 | #define ATMEL_TSADCC_CDR4 0x40 /* Channel Data 4 */ |
85 | #define ATMEL_TSADCC_CDR5 0x44 /* Channel Data 5 */ | 89 | #define ATMEL_TSADCC_CDR5 0x44 /* Channel Data 5 */ |
86 | 90 | ||
87 | #define ADC_CLOCK 1000000 | 91 | #define ATMEL_TSADCC_XPOS 0x50 |
92 | #define ATMEL_TSADCC_Z1DAT 0x54 | ||
93 | #define ATMEL_TSADCC_Z2DAT 0x58 | ||
94 | |||
95 | #define PRESCALER_VAL(x) ((x) >> 8) | ||
96 | |||
97 | #define ADC_DEFAULT_CLOCK 100000 | ||
88 | 98 | ||
89 | struct atmel_tsadcc { | 99 | struct atmel_tsadcc { |
90 | struct input_dev *input; | 100 | struct input_dev *input; |
@@ -172,6 +182,7 @@ static int __devinit atmel_tsadcc_probe(struct platform_device *pdev) | |||
172 | struct atmel_tsadcc *ts_dev; | 182 | struct atmel_tsadcc *ts_dev; |
173 | struct input_dev *input_dev; | 183 | struct input_dev *input_dev; |
174 | struct resource *res; | 184 | struct resource *res; |
185 | struct at91_tsadcc_data *pdata = pdev->dev.platform_data; | ||
175 | int err = 0; | 186 | int err = 0; |
176 | unsigned int prsc; | 187 | unsigned int prsc; |
177 | unsigned int reg; | 188 | unsigned int reg; |
@@ -242,31 +253,49 @@ static int __devinit atmel_tsadcc_probe(struct platform_device *pdev) | |||
242 | input_dev->phys = ts_dev->phys; | 253 | input_dev->phys = ts_dev->phys; |
243 | input_dev->dev.parent = &pdev->dev; | 254 | input_dev->dev.parent = &pdev->dev; |
244 | 255 | ||
245 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 256 | __set_bit(EV_ABS, input_dev->evbit); |
246 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
247 | |||
248 | input_set_abs_params(input_dev, ABS_X, 0, 0x3FF, 0, 0); | 257 | input_set_abs_params(input_dev, ABS_X, 0, 0x3FF, 0, 0); |
249 | input_set_abs_params(input_dev, ABS_Y, 0, 0x3FF, 0, 0); | 258 | input_set_abs_params(input_dev, ABS_Y, 0, 0x3FF, 0, 0); |
250 | 259 | ||
260 | input_set_capability(input_dev, EV_KEY, BTN_TOUCH); | ||
261 | |||
251 | /* clk_enable() always returns 0, no need to check it */ | 262 | /* clk_enable() always returns 0, no need to check it */ |
252 | clk_enable(ts_dev->clk); | 263 | clk_enable(ts_dev->clk); |
253 | 264 | ||
254 | prsc = clk_get_rate(ts_dev->clk); | 265 | prsc = clk_get_rate(ts_dev->clk); |
255 | dev_info(&pdev->dev, "Master clock is set at: %d Hz\n", prsc); | 266 | dev_info(&pdev->dev, "Master clock is set at: %d Hz\n", prsc); |
256 | 267 | ||
257 | prsc = prsc / ADC_CLOCK / 2 - 1; | 268 | if (!pdata) |
269 | goto err_fail; | ||
270 | |||
271 | if (!pdata->adc_clock) | ||
272 | pdata->adc_clock = ADC_DEFAULT_CLOCK; | ||
273 | |||
274 | prsc = (prsc / (2 * pdata->adc_clock)) - 1; | ||
275 | |||
276 | /* saturate if this value is too high */ | ||
277 | if (cpu_is_at91sam9rl()) { | ||
278 | if (prsc > PRESCALER_VAL(ATMEL_TSADCC_PRESCAL)) | ||
279 | prsc = PRESCALER_VAL(ATMEL_TSADCC_PRESCAL); | ||
280 | } else { | ||
281 | if (prsc > PRESCALER_VAL(ATMEL_TSADCC_EPRESCAL)) | ||
282 | prsc = PRESCALER_VAL(ATMEL_TSADCC_EPRESCAL); | ||
283 | } | ||
284 | |||
285 | dev_info(&pdev->dev, "Prescaler is set at: %d\n", prsc); | ||
258 | 286 | ||
259 | reg = ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE | | 287 | reg = ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE | |
260 | ((0x00 << 5) & ATMEL_TSADCC_SLEEP) | /* Normal Mode */ | 288 | ((0x00 << 5) & ATMEL_TSADCC_SLEEP) | /* Normal Mode */ |
261 | ((0x01 << 6) & ATMEL_TSADCC_PENDET) | /* Enable Pen Detect */ | 289 | ((0x01 << 6) & ATMEL_TSADCC_PENDET) | /* Enable Pen Detect */ |
262 | ((prsc << 8) & ATMEL_TSADCC_PRESCAL) | /* PRESCAL */ | 290 | (prsc << 8) | |
263 | ((0x13 << 16) & ATMEL_TSADCC_STARTUP) | /* STARTUP */ | 291 | ((0x26 << 16) & ATMEL_TSADCC_STARTUP) | |
264 | ((0x0F << 28) & ATMEL_TSADCC_PENDBC); /* PENDBC */ | 292 | ((pdata->pendet_debounce << 28) & ATMEL_TSADCC_PENDBC); |
265 | 293 | ||
266 | atmel_tsadcc_write(ATMEL_TSADCC_CR, ATMEL_TSADCC_SWRST); | 294 | atmel_tsadcc_write(ATMEL_TSADCC_CR, ATMEL_TSADCC_SWRST); |
267 | atmel_tsadcc_write(ATMEL_TSADCC_MR, reg); | 295 | atmel_tsadcc_write(ATMEL_TSADCC_MR, reg); |
268 | atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE); | 296 | atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE); |
269 | atmel_tsadcc_write(ATMEL_TSADCC_TSR, (0x3 << 24) & ATMEL_TSADCC_TSSHTIM); | 297 | atmel_tsadcc_write(ATMEL_TSADCC_TSR, |
298 | (pdata->ts_sample_hold_time << 24) & ATMEL_TSADCC_TSSHTIM); | ||
270 | 299 | ||
271 | atmel_tsadcc_read(ATMEL_TSADCC_SR); | 300 | atmel_tsadcc_read(ATMEL_TSADCC_SR); |
272 | atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); | 301 | atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); |
diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c index 3ffd4c4b170c..2b72a5923c16 100644 --- a/drivers/input/touchscreen/da9034-ts.c +++ b/drivers/input/touchscreen/da9034-ts.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/input.h> | 19 | #include <linux/input.h> |
20 | #include <linux/workqueue.h> | 20 | #include <linux/workqueue.h> |
21 | #include <linux/mfd/da903x.h> | 21 | #include <linux/mfd/da903x.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #define DA9034_MANUAL_CTRL 0x50 | 24 | #define DA9034_MANUAL_CTRL 0x50 |
24 | #define DA9034_LDO_ADC_EN (1 << 4) | 25 | #define DA9034_LDO_ADC_EN (1 << 4) |
diff --git a/drivers/input/touchscreen/dynapro.c b/drivers/input/touchscreen/dynapro.c new file mode 100644 index 000000000000..455353908bdf --- /dev/null +++ b/drivers/input/touchscreen/dynapro.c | |||
@@ -0,0 +1,206 @@ | |||
1 | /* | ||
2 | * Dynapro serial touchscreen driver | ||
3 | * | ||
4 | * Copyright (c) 2009 Tias Guns | ||
5 | * Based on the inexio driver (c) Vojtech Pavlik and Dan Streetman and | ||
6 | * Richard Lemon | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License version 2 as published by | ||
13 | * the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | /* | ||
17 | * 2009/09/19 Tias Guns <tias@ulyssis.org> | ||
18 | * Copied inexio.c and edited for Dynapro protocol (from retired Xorg module) | ||
19 | */ | ||
20 | |||
21 | #include <linux/errno.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/input.h> | ||
26 | #include <linux/serio.h> | ||
27 | #include <linux/init.h> | ||
28 | |||
29 | #define DRIVER_DESC "Dynapro serial touchscreen driver" | ||
30 | |||
31 | MODULE_AUTHOR("Tias Guns <tias@ulyssis.org>"); | ||
32 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
33 | MODULE_LICENSE("GPL"); | ||
34 | |||
35 | /* | ||
36 | * Definitions & global arrays. | ||
37 | */ | ||
38 | |||
39 | #define DYNAPRO_FORMAT_TOUCH_BIT 0x40 | ||
40 | #define DYNAPRO_FORMAT_LENGTH 3 | ||
41 | #define DYNAPRO_RESPONSE_BEGIN_BYTE 0x80 | ||
42 | |||
43 | #define DYNAPRO_MIN_XC 0 | ||
44 | #define DYNAPRO_MAX_XC 0x3ff | ||
45 | #define DYNAPRO_MIN_YC 0 | ||
46 | #define DYNAPRO_MAX_YC 0x3ff | ||
47 | |||
48 | #define DYNAPRO_GET_XC(data) (data[1] | ((data[0] & 0x38) << 4)) | ||
49 | #define DYNAPRO_GET_YC(data) (data[2] | ((data[0] & 0x07) << 7)) | ||
50 | #define DYNAPRO_GET_TOUCHED(data) (DYNAPRO_FORMAT_TOUCH_BIT & data[0]) | ||
51 | |||
52 | /* | ||
53 | * Per-touchscreen data. | ||
54 | */ | ||
55 | |||
56 | struct dynapro { | ||
57 | struct input_dev *dev; | ||
58 | struct serio *serio; | ||
59 | int idx; | ||
60 | unsigned char data[DYNAPRO_FORMAT_LENGTH]; | ||
61 | char phys[32]; | ||
62 | }; | ||
63 | |||
64 | static void dynapro_process_data(struct dynapro *pdynapro) | ||
65 | { | ||
66 | struct input_dev *dev = pdynapro->dev; | ||
67 | |||
68 | if (DYNAPRO_FORMAT_LENGTH == ++pdynapro->idx) { | ||
69 | input_report_abs(dev, ABS_X, DYNAPRO_GET_XC(pdynapro->data)); | ||
70 | input_report_abs(dev, ABS_Y, DYNAPRO_GET_YC(pdynapro->data)); | ||
71 | input_report_key(dev, BTN_TOUCH, | ||
72 | DYNAPRO_GET_TOUCHED(pdynapro->data)); | ||
73 | input_sync(dev); | ||
74 | |||
75 | pdynapro->idx = 0; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | static irqreturn_t dynapro_interrupt(struct serio *serio, | ||
80 | unsigned char data, unsigned int flags) | ||
81 | { | ||
82 | struct dynapro *pdynapro = serio_get_drvdata(serio); | ||
83 | |||
84 | pdynapro->data[pdynapro->idx] = data; | ||
85 | |||
86 | if (DYNAPRO_RESPONSE_BEGIN_BYTE & pdynapro->data[0]) | ||
87 | dynapro_process_data(pdynapro); | ||
88 | else | ||
89 | dev_dbg(&serio->dev, "unknown/unsynchronized data: %x\n", | ||
90 | pdynapro->data[0]); | ||
91 | |||
92 | return IRQ_HANDLED; | ||
93 | } | ||
94 | |||
95 | static void dynapro_disconnect(struct serio *serio) | ||
96 | { | ||
97 | struct dynapro *pdynapro = serio_get_drvdata(serio); | ||
98 | |||
99 | input_get_device(pdynapro->dev); | ||
100 | input_unregister_device(pdynapro->dev); | ||
101 | serio_close(serio); | ||
102 | serio_set_drvdata(serio, NULL); | ||
103 | input_put_device(pdynapro->dev); | ||
104 | kfree(pdynapro); | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * dynapro_connect() is the routine that is called when someone adds a | ||
109 | * new serio device that supports dynapro protocol and registers it as | ||
110 | * an input device. This is usually accomplished using inputattach. | ||
111 | */ | ||
112 | |||
113 | static int dynapro_connect(struct serio *serio, struct serio_driver *drv) | ||
114 | { | ||
115 | struct dynapro *pdynapro; | ||
116 | struct input_dev *input_dev; | ||
117 | int err; | ||
118 | |||
119 | pdynapro = kzalloc(sizeof(struct dynapro), GFP_KERNEL); | ||
120 | input_dev = input_allocate_device(); | ||
121 | if (!pdynapro || !input_dev) { | ||
122 | err = -ENOMEM; | ||
123 | goto fail1; | ||
124 | } | ||
125 | |||
126 | pdynapro->serio = serio; | ||
127 | pdynapro->dev = input_dev; | ||
128 | snprintf(pdynapro->phys, sizeof(pdynapro->phys), | ||
129 | "%s/input0", serio->phys); | ||
130 | |||
131 | input_dev->name = "Dynapro Serial TouchScreen"; | ||
132 | input_dev->phys = pdynapro->phys; | ||
133 | input_dev->id.bustype = BUS_RS232; | ||
134 | input_dev->id.vendor = SERIO_DYNAPRO; | ||
135 | input_dev->id.product = 0; | ||
136 | input_dev->id.version = 0x0001; | ||
137 | input_dev->dev.parent = &serio->dev; | ||
138 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
139 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
140 | input_set_abs_params(pdynapro->dev, ABS_X, | ||
141 | DYNAPRO_MIN_XC, DYNAPRO_MAX_XC, 0, 0); | ||
142 | input_set_abs_params(pdynapro->dev, ABS_Y, | ||
143 | DYNAPRO_MIN_YC, DYNAPRO_MAX_YC, 0, 0); | ||
144 | |||
145 | serio_set_drvdata(serio, pdynapro); | ||
146 | |||
147 | err = serio_open(serio, drv); | ||
148 | if (err) | ||
149 | goto fail2; | ||
150 | |||
151 | err = input_register_device(pdynapro->dev); | ||
152 | if (err) | ||
153 | goto fail3; | ||
154 | |||
155 | return 0; | ||
156 | |||
157 | fail3: serio_close(serio); | ||
158 | fail2: serio_set_drvdata(serio, NULL); | ||
159 | fail1: input_free_device(input_dev); | ||
160 | kfree(pdynapro); | ||
161 | return err; | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * The serio driver structure. | ||
166 | */ | ||
167 | |||
168 | static struct serio_device_id dynapro_serio_ids[] = { | ||
169 | { | ||
170 | .type = SERIO_RS232, | ||
171 | .proto = SERIO_DYNAPRO, | ||
172 | .id = SERIO_ANY, | ||
173 | .extra = SERIO_ANY, | ||
174 | }, | ||
175 | { 0 } | ||
176 | }; | ||
177 | |||
178 | MODULE_DEVICE_TABLE(serio, dynapro_serio_ids); | ||
179 | |||
180 | static struct serio_driver dynapro_drv = { | ||
181 | .driver = { | ||
182 | .name = "dynapro", | ||
183 | }, | ||
184 | .description = DRIVER_DESC, | ||
185 | .id_table = dynapro_serio_ids, | ||
186 | .interrupt = dynapro_interrupt, | ||
187 | .connect = dynapro_connect, | ||
188 | .disconnect = dynapro_disconnect, | ||
189 | }; | ||
190 | |||
191 | /* | ||
192 | * The functions for inserting/removing us as a module. | ||
193 | */ | ||
194 | |||
195 | static int __init dynapro_init(void) | ||
196 | { | ||
197 | return serio_register_driver(&dynapro_drv); | ||
198 | } | ||
199 | |||
200 | static void __exit dynapro_exit(void) | ||
201 | { | ||
202 | serio_unregister_driver(&dynapro_drv); | ||
203 | } | ||
204 | |||
205 | module_init(dynapro_init); | ||
206 | module_exit(dynapro_exit); | ||
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 9029bd3f34e5..75f8b73010fa 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/timer.h> | 33 | #include <linux/timer.h> |
34 | #include <linux/gpio.h> | 34 | #include <linux/gpio.h> |
35 | #include <linux/input/eeti_ts.h> | 35 | #include <linux/input/eeti_ts.h> |
36 | #include <linux/slab.h> | ||
36 | 37 | ||
37 | static int flip_x; | 38 | static int flip_x; |
38 | module_param(flip_x, bool, 0644); | 39 | module_param(flip_x, bool, 0644); |
@@ -123,14 +124,25 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id) | |||
123 | return IRQ_HANDLED; | 124 | return IRQ_HANDLED; |
124 | } | 125 | } |
125 | 126 | ||
126 | static int eeti_ts_open(struct input_dev *dev) | 127 | static void eeti_ts_start(struct eeti_ts_priv *priv) |
127 | { | 128 | { |
128 | struct eeti_ts_priv *priv = input_get_drvdata(dev); | ||
129 | |||
130 | enable_irq(priv->irq); | 129 | enable_irq(priv->irq); |
131 | 130 | ||
132 | /* Read the events once to arm the IRQ */ | 131 | /* Read the events once to arm the IRQ */ |
133 | eeti_ts_read(&priv->work); | 132 | eeti_ts_read(&priv->work); |
133 | } | ||
134 | |||
135 | static void eeti_ts_stop(struct eeti_ts_priv *priv) | ||
136 | { | ||
137 | disable_irq(priv->irq); | ||
138 | cancel_work_sync(&priv->work); | ||
139 | } | ||
140 | |||
141 | static int eeti_ts_open(struct input_dev *dev) | ||
142 | { | ||
143 | struct eeti_ts_priv *priv = input_get_drvdata(dev); | ||
144 | |||
145 | eeti_ts_start(priv); | ||
134 | 146 | ||
135 | return 0; | 147 | return 0; |
136 | } | 148 | } |
@@ -139,8 +151,7 @@ static void eeti_ts_close(struct input_dev *dev) | |||
139 | { | 151 | { |
140 | struct eeti_ts_priv *priv = input_get_drvdata(dev); | 152 | struct eeti_ts_priv *priv = input_get_drvdata(dev); |
141 | 153 | ||
142 | disable_irq(priv->irq); | 154 | eeti_ts_stop(priv); |
143 | cancel_work_sync(&priv->work); | ||
144 | } | 155 | } |
145 | 156 | ||
146 | static int __devinit eeti_ts_probe(struct i2c_client *client, | 157 | static int __devinit eeti_ts_probe(struct i2c_client *client, |
@@ -152,10 +163,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, | |||
152 | unsigned int irq_flags; | 163 | unsigned int irq_flags; |
153 | int err = -ENOMEM; | 164 | int err = -ENOMEM; |
154 | 165 | ||
155 | /* In contrast to what's described in the datasheet, there seems | 166 | /* |
167 | * In contrast to what's described in the datasheet, there seems | ||
156 | * to be no way of probing the presence of that device using I2C | 168 | * to be no way of probing the presence of that device using I2C |
157 | * commands. So we need to blindly believe it is there, and wait | 169 | * commands. So we need to blindly believe it is there, and wait |
158 | * for interrupts to occur. */ | 170 | * for interrupts to occur. |
171 | */ | ||
159 | 172 | ||
160 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 173 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
161 | if (!priv) { | 174 | if (!priv) { |
@@ -211,9 +224,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, | |||
211 | goto err2; | 224 | goto err2; |
212 | } | 225 | } |
213 | 226 | ||
214 | /* Disable the irq for now. It will be enabled once the input device | 227 | /* |
215 | * is opened. */ | 228 | * Disable the device for now. It will be enabled once the |
216 | disable_irq(priv->irq); | 229 | * input device is opened. |
230 | */ | ||
231 | eeti_ts_stop(priv); | ||
217 | 232 | ||
218 | device_init_wakeup(&client->dev, 0); | 233 | device_init_wakeup(&client->dev, 0); |
219 | return 0; | 234 | return 0; |
@@ -234,6 +249,12 @@ static int __devexit eeti_ts_remove(struct i2c_client *client) | |||
234 | struct eeti_ts_priv *priv = i2c_get_clientdata(client); | 249 | struct eeti_ts_priv *priv = i2c_get_clientdata(client); |
235 | 250 | ||
236 | free_irq(priv->irq, priv); | 251 | free_irq(priv->irq, priv); |
252 | /* | ||
253 | * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it | ||
254 | * so that device still works if we reload the driver. | ||
255 | */ | ||
256 | enable_irq(priv->irq); | ||
257 | |||
237 | input_unregister_device(priv->input); | 258 | input_unregister_device(priv->input); |
238 | i2c_set_clientdata(client, NULL); | 259 | i2c_set_clientdata(client, NULL); |
239 | kfree(priv); | 260 | kfree(priv); |
@@ -245,6 +266,14 @@ static int __devexit eeti_ts_remove(struct i2c_client *client) | |||
245 | static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) | 266 | static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) |
246 | { | 267 | { |
247 | struct eeti_ts_priv *priv = i2c_get_clientdata(client); | 268 | struct eeti_ts_priv *priv = i2c_get_clientdata(client); |
269 | struct input_dev *input_dev = priv->input; | ||
270 | |||
271 | mutex_lock(&input_dev->mutex); | ||
272 | |||
273 | if (input_dev->users) | ||
274 | eeti_ts_stop(priv); | ||
275 | |||
276 | mutex_unlock(&input_dev->mutex); | ||
248 | 277 | ||
249 | if (device_may_wakeup(&client->dev)) | 278 | if (device_may_wakeup(&client->dev)) |
250 | enable_irq_wake(priv->irq); | 279 | enable_irq_wake(priv->irq); |
@@ -255,10 +284,18 @@ static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) | |||
255 | static int eeti_ts_resume(struct i2c_client *client) | 284 | static int eeti_ts_resume(struct i2c_client *client) |
256 | { | 285 | { |
257 | struct eeti_ts_priv *priv = i2c_get_clientdata(client); | 286 | struct eeti_ts_priv *priv = i2c_get_clientdata(client); |
287 | struct input_dev *input_dev = priv->input; | ||
258 | 288 | ||
259 | if (device_may_wakeup(&client->dev)) | 289 | if (device_may_wakeup(&client->dev)) |
260 | disable_irq_wake(priv->irq); | 290 | disable_irq_wake(priv->irq); |
261 | 291 | ||
292 | mutex_lock(&input_dev->mutex); | ||
293 | |||
294 | if (input_dev->users) | ||
295 | eeti_ts_start(priv); | ||
296 | |||
297 | mutex_unlock(&input_dev->mutex); | ||
298 | |||
262 | return 0; | 299 | return 0; |
263 | } | 300 | } |
264 | #else | 301 | #else |
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 8f38c5e55ce6..486d31ba9c09 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c | |||
@@ -72,45 +72,49 @@ static void elo_process_data_10(struct elo *elo, unsigned char data) | |||
72 | struct input_dev *dev = elo->dev; | 72 | struct input_dev *dev = elo->dev; |
73 | 73 | ||
74 | elo->data[elo->idx] = data; | 74 | elo->data[elo->idx] = data; |
75 | switch (elo->idx++) { | ||
76 | case 0: | ||
77 | elo->csum = 0xaa; | ||
78 | if (data != ELO10_LEAD_BYTE) { | ||
79 | pr_debug("elo: unsynchronized data: 0x%02x\n", data); | ||
80 | elo->idx = 0; | ||
81 | } | ||
82 | break; | ||
83 | 75 | ||
84 | case 9: | 76 | switch (elo->idx++) { |
77 | case 0: | ||
78 | elo->csum = 0xaa; | ||
79 | if (data != ELO10_LEAD_BYTE) { | ||
80 | dev_dbg(&elo->serio->dev, | ||
81 | "unsynchronized data: 0x%02x\n", data); | ||
85 | elo->idx = 0; | 82 | elo->idx = 0; |
86 | if (data != elo->csum) { | 83 | } |
87 | pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n", | 84 | break; |
88 | data, elo->csum); | 85 | |
89 | break; | 86 | case 9: |
90 | } | 87 | elo->idx = 0; |
91 | if (elo->data[1] != elo->expected_packet) { | 88 | if (data != elo->csum) { |
92 | if (elo->data[1] != ELO10_TOUCH_PACKET) | 89 | dev_dbg(&elo->serio->dev, |
93 | pr_debug("elo: unexpected packet: 0x%02x\n", | 90 | "bad checksum: 0x%02x, expected 0x%02x\n", |
94 | elo->data[1]); | 91 | data, elo->csum); |
95 | break; | 92 | break; |
96 | } | 93 | } |
97 | if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { | 94 | if (elo->data[1] != elo->expected_packet) { |
98 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); | 95 | if (elo->data[1] != ELO10_TOUCH_PACKET) |
99 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); | 96 | dev_dbg(&elo->serio->dev, |
100 | if (elo->data[2] & ELO10_PRESSURE) | 97 | "unexpected packet: 0x%02x\n", |
101 | input_report_abs(dev, ABS_PRESSURE, | 98 | elo->data[1]); |
102 | (elo->data[8] << 8) | elo->data[7]); | ||
103 | input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH); | ||
104 | input_sync(dev); | ||
105 | } else if (elo->data[1] == ELO10_ACK_PACKET) { | ||
106 | if (elo->data[2] == '0') | ||
107 | elo->expected_packet = ELO10_TOUCH_PACKET; | ||
108 | complete(&elo->cmd_done); | ||
109 | } else { | ||
110 | memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN); | ||
111 | elo->expected_packet = ELO10_ACK_PACKET; | ||
112 | } | ||
113 | break; | 99 | break; |
100 | } | ||
101 | if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { | ||
102 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); | ||
103 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); | ||
104 | if (elo->data[2] & ELO10_PRESSURE) | ||
105 | input_report_abs(dev, ABS_PRESSURE, | ||
106 | (elo->data[8] << 8) | elo->data[7]); | ||
107 | input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH); | ||
108 | input_sync(dev); | ||
109 | } else if (elo->data[1] == ELO10_ACK_PACKET) { | ||
110 | if (elo->data[2] == '0') | ||
111 | elo->expected_packet = ELO10_TOUCH_PACKET; | ||
112 | complete(&elo->cmd_done); | ||
113 | } else { | ||
114 | memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN); | ||
115 | elo->expected_packet = ELO10_ACK_PACKET; | ||
116 | } | ||
117 | break; | ||
114 | } | 118 | } |
115 | elo->csum += data; | 119 | elo->csum += data; |
116 | } | 120 | } |
@@ -123,42 +127,53 @@ static void elo_process_data_6(struct elo *elo, unsigned char data) | |||
123 | 127 | ||
124 | switch (elo->idx++) { | 128 | switch (elo->idx++) { |
125 | 129 | ||
126 | case 0: if ((data & 0xc0) != 0xc0) elo->idx = 0; break; | 130 | case 0: |
127 | case 1: if ((data & 0xc0) != 0x80) elo->idx = 0; break; | 131 | if ((data & 0xc0) != 0xc0) |
128 | case 2: if ((data & 0xc0) != 0x40) elo->idx = 0; break; | 132 | elo->idx = 0; |
129 | 133 | break; | |
130 | case 3: | ||
131 | if (data & 0xc0) { | ||
132 | elo->idx = 0; | ||
133 | break; | ||
134 | } | ||
135 | 134 | ||
136 | input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); | 135 | case 1: |
137 | input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); | 136 | if ((data & 0xc0) != 0x80) |
137 | elo->idx = 0; | ||
138 | break; | ||
138 | 139 | ||
139 | if (elo->id == 2) { | 140 | case 2: |
140 | input_report_key(dev, BTN_TOUCH, 1); | 141 | if ((data & 0xc0) != 0x40) |
141 | input_sync(dev); | 142 | elo->idx = 0; |
142 | elo->idx = 0; | 143 | break; |
143 | } | ||
144 | 144 | ||
145 | case 3: | ||
146 | if (data & 0xc0) { | ||
147 | elo->idx = 0; | ||
145 | break; | 148 | break; |
149 | } | ||
146 | 150 | ||
147 | case 4: | 151 | input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); |
148 | if (data) { | 152 | input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); |
149 | input_sync(dev); | ||
150 | elo->idx = 0; | ||
151 | } | ||
152 | break; | ||
153 | 153 | ||
154 | case 5: | 154 | if (elo->id == 2) { |
155 | if ((data & 0xf0) == 0) { | 155 | input_report_key(dev, BTN_TOUCH, 1); |
156 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); | ||
157 | input_report_key(dev, BTN_TOUCH, !!elo->data[5]); | ||
158 | } | ||
159 | input_sync(dev); | 156 | input_sync(dev); |
160 | elo->idx = 0; | 157 | elo->idx = 0; |
161 | break; | 158 | } |
159 | |||
160 | break; | ||
161 | |||
162 | case 4: | ||
163 | if (data) { | ||
164 | input_sync(dev); | ||
165 | elo->idx = 0; | ||
166 | } | ||
167 | break; | ||
168 | |||
169 | case 5: | ||
170 | if ((data & 0xf0) == 0) { | ||
171 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); | ||
172 | input_report_key(dev, BTN_TOUCH, !!elo->data[5]); | ||
173 | } | ||
174 | input_sync(dev); | ||
175 | elo->idx = 0; | ||
176 | break; | ||
162 | } | 177 | } |
163 | } | 178 | } |
164 | 179 | ||
@@ -170,17 +185,17 @@ static void elo_process_data_3(struct elo *elo, unsigned char data) | |||
170 | 185 | ||
171 | switch (elo->idx++) { | 186 | switch (elo->idx++) { |
172 | 187 | ||
173 | case 0: | 188 | case 0: |
174 | if ((data & 0x7f) != 0x01) | 189 | if ((data & 0x7f) != 0x01) |
175 | elo->idx = 0; | ||
176 | break; | ||
177 | case 2: | ||
178 | input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80)); | ||
179 | input_report_abs(dev, ABS_X, elo->data[1]); | ||
180 | input_report_abs(dev, ABS_Y, elo->data[2]); | ||
181 | input_sync(dev); | ||
182 | elo->idx = 0; | 190 | elo->idx = 0; |
183 | break; | 191 | break; |
192 | case 2: | ||
193 | input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80)); | ||
194 | input_report_abs(dev, ABS_X, elo->data[1]); | ||
195 | input_report_abs(dev, ABS_Y, elo->data[2]); | ||
196 | input_sync(dev); | ||
197 | elo->idx = 0; | ||
198 | break; | ||
184 | } | 199 | } |
185 | } | 200 | } |
186 | 201 | ||
@@ -189,19 +204,19 @@ static irqreturn_t elo_interrupt(struct serio *serio, | |||
189 | { | 204 | { |
190 | struct elo *elo = serio_get_drvdata(serio); | 205 | struct elo *elo = serio_get_drvdata(serio); |
191 | 206 | ||
192 | switch(elo->id) { | 207 | switch (elo->id) { |
193 | case 0: | 208 | case 0: |
194 | elo_process_data_10(elo, data); | 209 | elo_process_data_10(elo, data); |
195 | break; | 210 | break; |
196 | 211 | ||
197 | case 1: | 212 | case 1: |
198 | case 2: | 213 | case 2: |
199 | elo_process_data_6(elo, data); | 214 | elo_process_data_6(elo, data); |
200 | break; | 215 | break; |
201 | 216 | ||
202 | case 3: | 217 | case 3: |
203 | elo_process_data_3(elo, data); | 218 | elo_process_data_3(elo, data); |
204 | break; | 219 | break; |
205 | } | 220 | } |
206 | 221 | ||
207 | return IRQ_HANDLED; | 222 | return IRQ_HANDLED; |
@@ -261,10 +276,10 @@ static int elo_setup_10(struct elo *elo) | |||
261 | if (packet[3] & ELO10_PRESSURE) | 276 | if (packet[3] & ELO10_PRESSURE) |
262 | input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); | 277 | input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); |
263 | 278 | ||
264 | printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, " | 279 | dev_info(&elo->serio->dev, |
265 | "features: 0x%02x, controller: 0x%02x\n", | 280 | "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n", |
266 | elo_types[(packet[1] -'0') & 0x03], | 281 | elo_types[(packet[1] -'0') & 0x03], |
267 | packet[5], packet[4], packet[3], packet[7]); | 282 | packet[5], packet[4], packet[3], packet[7]); |
268 | 283 | ||
269 | return 0; | 284 | return 0; |
270 | } | 285 | } |
@@ -330,24 +345,24 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) | |||
330 | 345 | ||
331 | switch (elo->id) { | 346 | switch (elo->id) { |
332 | 347 | ||
333 | case 0: /* 10-byte protocol */ | 348 | case 0: /* 10-byte protocol */ |
334 | if (elo_setup_10(elo)) | 349 | if (elo_setup_10(elo)) |
335 | goto fail3; | 350 | goto fail3; |
336 | 351 | ||
337 | break; | 352 | break; |
338 | 353 | ||
339 | case 1: /* 6-byte protocol */ | 354 | case 1: /* 6-byte protocol */ |
340 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); | 355 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); |
341 | 356 | ||
342 | case 2: /* 4-byte protocol */ | 357 | case 2: /* 4-byte protocol */ |
343 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); | 358 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); |
344 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); | 359 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); |
345 | break; | 360 | break; |
346 | 361 | ||
347 | case 3: /* 3-byte protocol */ | 362 | case 3: /* 3-byte protocol */ |
348 | input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); | 363 | input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); |
349 | input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); | 364 | input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); |
350 | break; | 365 | break; |
351 | } | 366 | } |
352 | 367 | ||
353 | err = input_register_device(elo->dev); | 368 | err = input_register_device(elo->dev); |
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c index c8b7e8a45c4d..4b0a061811ff 100644 --- a/drivers/input/touchscreen/jornada720_ts.c +++ b/drivers/input/touchscreen/jornada720_ts.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/input.h> | 18 | #include <linux/input.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #include <mach/hardware.h> | 23 | #include <mach/hardware.h> |
23 | #include <mach/jornada720.h> | 24 | #include <mach/jornada720.h> |
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c index 8fc3b08deb3b..b6b8b1c7ecea 100644 --- a/drivers/input/touchscreen/mainstone-wm97xx.c +++ b/drivers/input/touchscreen/mainstone-wm97xx.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * | 14 | * |
15 | * Notes: | 15 | * Notes: |
16 | * This is a wm97xx extended touch driver to capture touch | 16 | * This is a wm97xx extended touch driver to capture touch |
17 | * data in a continuous manner on the Intel XScale archictecture | 17 | * data in a continuous manner on the Intel XScale architecture |
18 | * | 18 | * |
19 | * Features: | 19 | * Features: |
20 | * - codecs supported:- WM9705, WM9712, WM9713 | 20 | * - codecs supported:- WM9705, WM9712, WM9713 |
@@ -131,7 +131,7 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm) | |||
131 | /* When the AC97 queue has been drained we need to allow time | 131 | /* When the AC97 queue has been drained we need to allow time |
132 | * to buffer up samples otherwise we end up spinning polling | 132 | * to buffer up samples otherwise we end up spinning polling |
133 | * for samples. The controller can't have a suitably low | 133 | * for samples. The controller can't have a suitably low |
134 | * threashold set to use the notifications it gives. | 134 | * threshold set to use the notifications it gives. |
135 | */ | 135 | */ |
136 | schedule_timeout_uninterruptible(1); | 136 | schedule_timeout_uninterruptible(1); |
137 | 137 | ||
@@ -153,6 +153,9 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm) | |||
153 | if (pressure) | 153 | if (pressure) |
154 | p = MODR; | 154 | p = MODR; |
155 | 155 | ||
156 | dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n", | ||
157 | x, y, p); | ||
158 | |||
156 | /* are samples valid */ | 159 | /* are samples valid */ |
157 | if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || | 160 | if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || |
158 | (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || | 161 | (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || |
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c new file mode 100644 index 000000000000..c5bc62d85bb6 --- /dev/null +++ b/drivers/input/touchscreen/mc13783_ts.c | |||
@@ -0,0 +1,259 @@ | |||
1 | /* | ||
2 | * Driver for the Freescale Semiconductor MC13783 touchscreen. | ||
3 | * | ||
4 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
5 | * Copyright (C) 2009 Sascha Hauer, Pengutronix | ||
6 | * | ||
7 | * Initial development of this code was funded by | ||
8 | * Phytec Messtechnik GmbH, http://www.phytec.de/ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License version 2 as published by | ||
12 | * the Free Software Foundation. | ||
13 | */ | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/mfd/mc13783.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/input.h> | ||
19 | #include <linux/sched.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/init.h> | ||
22 | |||
23 | #define MC13783_TS_NAME "mc13783-ts" | ||
24 | |||
25 | #define DEFAULT_SAMPLE_TOLERANCE 300 | ||
26 | |||
27 | static unsigned int sample_tolerance = DEFAULT_SAMPLE_TOLERANCE; | ||
28 | module_param(sample_tolerance, uint, S_IRUGO | S_IWUSR); | ||
29 | MODULE_PARM_DESC(sample_tolerance, | ||
30 | "If the minimal and maximal value read out for one axis (out " | ||
31 | "of three) differ by this value (default: " | ||
32 | __stringify(DEFAULT_SAMPLE_TOLERANCE) ") or more, the reading " | ||
33 | "is supposed to be wrong and is discarded. Set to 0 to " | ||
34 | "disable this check."); | ||
35 | |||
36 | struct mc13783_ts_priv { | ||
37 | struct input_dev *idev; | ||
38 | struct mc13783 *mc13783; | ||
39 | struct delayed_work work; | ||
40 | struct workqueue_struct *workq; | ||
41 | unsigned int sample[4]; | ||
42 | }; | ||
43 | |||
44 | static irqreturn_t mc13783_ts_handler(int irq, void *data) | ||
45 | { | ||
46 | struct mc13783_ts_priv *priv = data; | ||
47 | |||
48 | mc13783_irq_ack(priv->mc13783, irq); | ||
49 | |||
50 | /* | ||
51 | * Kick off reading coordinates. Note that if work happens already | ||
52 | * be queued for future execution (it rearms itself) it will not | ||
53 | * be rescheduled for immediate execution here. However the rearm | ||
54 | * delay is HZ / 50 which is acceptable. | ||
55 | */ | ||
56 | queue_delayed_work(priv->workq, &priv->work, 0); | ||
57 | |||
58 | return IRQ_HANDLED; | ||
59 | } | ||
60 | |||
61 | #define sort3(a0, a1, a2) ({ \ | ||
62 | if (a0 > a1) \ | ||
63 | swap(a0, a1); \ | ||
64 | if (a1 > a2) \ | ||
65 | swap(a1, a2); \ | ||
66 | if (a0 > a1) \ | ||
67 | swap(a0, a1); \ | ||
68 | }) | ||
69 | |||
70 | static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv) | ||
71 | { | ||
72 | struct input_dev *idev = priv->idev; | ||
73 | int x0, x1, x2, y0, y1, y2; | ||
74 | int cr0, cr1; | ||
75 | |||
76 | /* | ||
77 | * the values are 10-bit wide only, but the two least significant | ||
78 | * bits are for future 12 bit use and reading yields 0 | ||
79 | */ | ||
80 | x0 = priv->sample[0] & 0xfff; | ||
81 | x1 = priv->sample[1] & 0xfff; | ||
82 | x2 = priv->sample[2] & 0xfff; | ||
83 | y0 = priv->sample[3] & 0xfff; | ||
84 | y1 = (priv->sample[0] >> 12) & 0xfff; | ||
85 | y2 = (priv->sample[1] >> 12) & 0xfff; | ||
86 | cr0 = (priv->sample[2] >> 12) & 0xfff; | ||
87 | cr1 = (priv->sample[3] >> 12) & 0xfff; | ||
88 | |||
89 | dev_dbg(&idev->dev, | ||
90 | "x: (% 4d,% 4d,% 4d) y: (% 4d, % 4d,% 4d) cr: (% 4d, % 4d)\n", | ||
91 | x0, x1, x2, y0, y1, y2, cr0, cr1); | ||
92 | |||
93 | sort3(x0, x1, x2); | ||
94 | sort3(y0, y1, y2); | ||
95 | |||
96 | cr0 = (cr0 + cr1) / 2; | ||
97 | |||
98 | if (!cr0 || !sample_tolerance || | ||
99 | (x2 - x0 < sample_tolerance && | ||
100 | y2 - y0 < sample_tolerance)) { | ||
101 | /* report the median coordinate and average pressure */ | ||
102 | if (cr0) { | ||
103 | input_report_abs(idev, ABS_X, x1); | ||
104 | input_report_abs(idev, ABS_Y, y1); | ||
105 | |||
106 | dev_dbg(&idev->dev, "report (%d, %d, %d)\n", | ||
107 | x1, y1, 0x1000 - cr0); | ||
108 | queue_delayed_work(priv->workq, &priv->work, HZ / 50); | ||
109 | } else | ||
110 | dev_dbg(&idev->dev, "report release\n"); | ||
111 | |||
112 | input_report_abs(idev, ABS_PRESSURE, | ||
113 | cr0 ? 0x1000 - cr0 : cr0); | ||
114 | input_report_key(idev, BTN_TOUCH, cr0); | ||
115 | input_sync(idev); | ||
116 | } else | ||
117 | dev_dbg(&idev->dev, "discard event\n"); | ||
118 | } | ||
119 | |||
120 | static void mc13783_ts_work(struct work_struct *work) | ||
121 | { | ||
122 | struct mc13783_ts_priv *priv = | ||
123 | container_of(work, struct mc13783_ts_priv, work.work); | ||
124 | unsigned int mode = MC13783_ADC_MODE_TS; | ||
125 | unsigned int channel = 12; | ||
126 | |||
127 | if (mc13783_adc_do_conversion(priv->mc13783, | ||
128 | mode, channel, priv->sample) == 0) | ||
129 | mc13783_ts_report_sample(priv); | ||
130 | } | ||
131 | |||
132 | static int mc13783_ts_open(struct input_dev *dev) | ||
133 | { | ||
134 | struct mc13783_ts_priv *priv = input_get_drvdata(dev); | ||
135 | int ret; | ||
136 | |||
137 | mc13783_lock(priv->mc13783); | ||
138 | |||
139 | mc13783_irq_ack(priv->mc13783, MC13783_IRQ_TS); | ||
140 | |||
141 | ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_TS, | ||
142 | mc13783_ts_handler, MC13783_TS_NAME, priv); | ||
143 | if (ret) | ||
144 | goto out; | ||
145 | |||
146 | ret = mc13783_reg_rmw(priv->mc13783, MC13783_ADC0, | ||
147 | MC13783_ADC0_TSMOD_MASK, MC13783_ADC0_TSMOD0); | ||
148 | if (ret) | ||
149 | mc13783_irq_free(priv->mc13783, MC13783_IRQ_TS, priv); | ||
150 | out: | ||
151 | mc13783_unlock(priv->mc13783); | ||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | static void mc13783_ts_close(struct input_dev *dev) | ||
156 | { | ||
157 | struct mc13783_ts_priv *priv = input_get_drvdata(dev); | ||
158 | |||
159 | mc13783_lock(priv->mc13783); | ||
160 | mc13783_reg_rmw(priv->mc13783, MC13783_ADC0, | ||
161 | MC13783_ADC0_TSMOD_MASK, 0); | ||
162 | mc13783_irq_free(priv->mc13783, MC13783_IRQ_TS, priv); | ||
163 | mc13783_unlock(priv->mc13783); | ||
164 | |||
165 | cancel_delayed_work_sync(&priv->work); | ||
166 | } | ||
167 | |||
168 | static int __init mc13783_ts_probe(struct platform_device *pdev) | ||
169 | { | ||
170 | struct mc13783_ts_priv *priv; | ||
171 | struct input_dev *idev; | ||
172 | int ret = -ENOMEM; | ||
173 | |||
174 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
175 | idev = input_allocate_device(); | ||
176 | if (!priv || !idev) | ||
177 | goto err_free_mem; | ||
178 | |||
179 | INIT_DELAYED_WORK(&priv->work, mc13783_ts_work); | ||
180 | priv->mc13783 = dev_get_drvdata(pdev->dev.parent); | ||
181 | priv->idev = idev; | ||
182 | |||
183 | /* | ||
184 | * We need separate workqueue because mc13783_adc_do_conversion | ||
185 | * uses keventd and thus would deadlock. | ||
186 | */ | ||
187 | priv->workq = create_singlethread_workqueue("mc13783_ts"); | ||
188 | if (!priv->workq) | ||
189 | goto err_free_mem; | ||
190 | |||
191 | idev->name = MC13783_TS_NAME; | ||
192 | idev->dev.parent = &pdev->dev; | ||
193 | |||
194 | idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
195 | idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
196 | input_set_abs_params(idev, ABS_X, 0, 0xfff, 0, 0); | ||
197 | input_set_abs_params(idev, ABS_Y, 0, 0xfff, 0, 0); | ||
198 | input_set_abs_params(idev, ABS_PRESSURE, 0, 0xfff, 0, 0); | ||
199 | |||
200 | idev->open = mc13783_ts_open; | ||
201 | idev->close = mc13783_ts_close; | ||
202 | |||
203 | input_set_drvdata(idev, priv); | ||
204 | |||
205 | ret = input_register_device(priv->idev); | ||
206 | if (ret) { | ||
207 | dev_err(&pdev->dev, | ||
208 | "register input device failed with %d\n", ret); | ||
209 | goto err_destroy_wq; | ||
210 | } | ||
211 | |||
212 | platform_set_drvdata(pdev, priv); | ||
213 | return 0; | ||
214 | |||
215 | err_destroy_wq: | ||
216 | destroy_workqueue(priv->workq); | ||
217 | err_free_mem: | ||
218 | input_free_device(idev); | ||
219 | kfree(priv); | ||
220 | return ret; | ||
221 | } | ||
222 | |||
223 | static int __devexit mc13783_ts_remove(struct platform_device *pdev) | ||
224 | { | ||
225 | struct mc13783_ts_priv *priv = platform_get_drvdata(pdev); | ||
226 | |||
227 | platform_set_drvdata(pdev, NULL); | ||
228 | |||
229 | destroy_workqueue(priv->workq); | ||
230 | input_unregister_device(priv->idev); | ||
231 | kfree(priv); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static struct platform_driver mc13783_ts_driver = { | ||
237 | .remove = __devexit_p(mc13783_ts_remove), | ||
238 | .driver = { | ||
239 | .owner = THIS_MODULE, | ||
240 | .name = MC13783_TS_NAME, | ||
241 | }, | ||
242 | }; | ||
243 | |||
244 | static int __init mc13783_ts_init(void) | ||
245 | { | ||
246 | return platform_driver_probe(&mc13783_ts_driver, &mc13783_ts_probe); | ||
247 | } | ||
248 | module_init(mc13783_ts_init); | ||
249 | |||
250 | static void __exit mc13783_ts_exit(void) | ||
251 | { | ||
252 | platform_driver_unregister(&mc13783_ts_driver); | ||
253 | } | ||
254 | module_exit(mc13783_ts_exit); | ||
255 | |||
256 | MODULE_DESCRIPTION("MC13783 input touchscreen driver"); | ||
257 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); | ||
258 | MODULE_LICENSE("GPL v2"); | ||
259 | MODULE_ALIAS("platform:" MC13783_TS_NAME); | ||
diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c index 4c28b89757f9..ce8ab0269f6f 100644 --- a/drivers/input/touchscreen/mcs5000_ts.c +++ b/drivers/input/touchscreen/mcs5000_ts.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/slab.h> | ||
23 | 24 | ||
24 | /* Registers */ | 25 | /* Registers */ |
25 | #define MCS5000_TS_STATUS 0x00 | 26 | #define MCS5000_TS_STATUS 0x00 |
diff --git a/drivers/input/touchscreen/migor_ts.c b/drivers/input/touchscreen/migor_ts.c index 141dd584330e..defe5dd3627c 100644 --- a/drivers/input/touchscreen/migor_ts.c +++ b/drivers/input/touchscreen/migor_ts.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/input.h> | 24 | #include <linux/input.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/slab.h> | ||
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
28 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
diff --git a/drivers/input/touchscreen/pcap_ts.c b/drivers/input/touchscreen/pcap_ts.c index 67fcd33595de..ea6ef16e59b4 100644 --- a/drivers/input/touchscreen/pcap_ts.c +++ b/drivers/input/touchscreen/pcap_ts.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/slab.h> | ||
17 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
18 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
19 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
@@ -233,7 +234,7 @@ static int pcap_ts_resume(struct device *dev) | |||
233 | return 0; | 234 | return 0; |
234 | } | 235 | } |
235 | 236 | ||
236 | static struct dev_pm_ops pcap_ts_pm_ops = { | 237 | static const struct dev_pm_ops pcap_ts_pm_ops = { |
237 | .suspend = pcap_ts_suspend, | 238 | .suspend = pcap_ts_suspend, |
238 | .resume = pcap_ts_resume, | 239 | .resume = pcap_ts_resume, |
239 | }; | 240 | }; |
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c new file mode 100644 index 000000000000..98a7d1279486 --- /dev/null +++ b/drivers/input/touchscreen/s3c2410_ts.c | |||
@@ -0,0 +1,459 @@ | |||
1 | /* | ||
2 | * Samsung S3C24XX touchscreen driver | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the term of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | * | ||
18 | * Copyright 2004 Arnaud Patard <arnaud.patard@rtp-net.org> | ||
19 | * Copyright 2008 Ben Dooks <ben-linux@fluff.org> | ||
20 | * Copyright 2009 Simtec Electronics <linux@simtec.co.uk> | ||
21 | * | ||
22 | * Additional work by Herbert Pötzl <herbert@13thfloor.at> and | ||
23 | * Harald Welte <laforge@openmoko.org> | ||
24 | */ | ||
25 | |||
26 | #include <linux/errno.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/gpio.h> | ||
30 | #include <linux/input.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/interrupt.h> | ||
34 | #include <linux/platform_device.h> | ||
35 | #include <linux/clk.h> | ||
36 | #include <linux/io.h> | ||
37 | |||
38 | #include <plat/adc.h> | ||
39 | #include <plat/regs-adc.h> | ||
40 | |||
41 | #include <mach/regs-gpio.h> | ||
42 | #include <mach/ts.h> | ||
43 | |||
44 | #define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0)) | ||
45 | |||
46 | #define INT_DOWN (0) | ||
47 | #define INT_UP (1 << 8) | ||
48 | |||
49 | #define WAIT4INT (S3C2410_ADCTSC_YM_SEN | \ | ||
50 | S3C2410_ADCTSC_YP_SEN | \ | ||
51 | S3C2410_ADCTSC_XP_SEN | \ | ||
52 | S3C2410_ADCTSC_XY_PST(3)) | ||
53 | |||
54 | #define AUTOPST (S3C2410_ADCTSC_YM_SEN | \ | ||
55 | S3C2410_ADCTSC_YP_SEN | \ | ||
56 | S3C2410_ADCTSC_XP_SEN | \ | ||
57 | S3C2410_ADCTSC_AUTO_PST | \ | ||
58 | S3C2410_ADCTSC_XY_PST(0)) | ||
59 | |||
60 | /* Per-touchscreen data. */ | ||
61 | |||
62 | /** | ||
63 | * struct s3c2410ts - driver touchscreen state. | ||
64 | * @client: The ADC client we registered with the core driver. | ||
65 | * @dev: The device we are bound to. | ||
66 | * @input: The input device we registered with the input subsystem. | ||
67 | * @clock: The clock for the adc. | ||
68 | * @io: Pointer to the IO base. | ||
69 | * @xp: The accumulated X position data. | ||
70 | * @yp: The accumulated Y position data. | ||
71 | * @irq_tc: The interrupt number for pen up/down interrupt | ||
72 | * @count: The number of samples collected. | ||
73 | * @shift: The log2 of the maximum count to read in one go. | ||
74 | */ | ||
75 | struct s3c2410ts { | ||
76 | struct s3c_adc_client *client; | ||
77 | struct device *dev; | ||
78 | struct input_dev *input; | ||
79 | struct clk *clock; | ||
80 | void __iomem *io; | ||
81 | unsigned long xp; | ||
82 | unsigned long yp; | ||
83 | int irq_tc; | ||
84 | int count; | ||
85 | int shift; | ||
86 | }; | ||
87 | |||
88 | static struct s3c2410ts ts; | ||
89 | |||
90 | /** | ||
91 | * s3c2410_ts_connect - configure gpio for s3c2410 systems | ||
92 | * | ||
93 | * Configure the GPIO for the S3C2410 system, where we have external FETs | ||
94 | * connected to the device (later systems such as the S3C2440 integrate | ||
95 | * these into the device). | ||
96 | */ | ||
97 | static inline void s3c2410_ts_connect(void) | ||
98 | { | ||
99 | s3c2410_gpio_cfgpin(S3C2410_GPG(12), S3C2410_GPG12_XMON); | ||
100 | s3c2410_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPG13_nXPON); | ||
101 | s3c2410_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPG14_YMON); | ||
102 | s3c2410_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPG15_nYPON); | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * get_down - return the down state of the pen | ||
107 | * @data0: The data read from ADCDAT0 register. | ||
108 | * @data1: The data read from ADCDAT1 register. | ||
109 | * | ||
110 | * Return non-zero if both readings show that the pen is down. | ||
111 | */ | ||
112 | static inline bool get_down(unsigned long data0, unsigned long data1) | ||
113 | { | ||
114 | /* returns true if both data values show stylus down */ | ||
115 | return (!(data0 & S3C2410_ADCDAT0_UPDOWN) && | ||
116 | !(data1 & S3C2410_ADCDAT0_UPDOWN)); | ||
117 | } | ||
118 | |||
119 | static void touch_timer_fire(unsigned long data) | ||
120 | { | ||
121 | unsigned long data0; | ||
122 | unsigned long data1; | ||
123 | bool down; | ||
124 | |||
125 | data0 = readl(ts.io + S3C2410_ADCDAT0); | ||
126 | data1 = readl(ts.io + S3C2410_ADCDAT1); | ||
127 | |||
128 | down = get_down(data0, data1); | ||
129 | |||
130 | if (down) { | ||
131 | if (ts.count == (1 << ts.shift)) { | ||
132 | ts.xp >>= ts.shift; | ||
133 | ts.yp >>= ts.shift; | ||
134 | |||
135 | dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n", | ||
136 | __func__, ts.xp, ts.yp, ts.count); | ||
137 | |||
138 | input_report_abs(ts.input, ABS_X, ts.xp); | ||
139 | input_report_abs(ts.input, ABS_Y, ts.yp); | ||
140 | |||
141 | input_report_key(ts.input, BTN_TOUCH, 1); | ||
142 | input_sync(ts.input); | ||
143 | |||
144 | ts.xp = 0; | ||
145 | ts.yp = 0; | ||
146 | ts.count = 0; | ||
147 | } | ||
148 | |||
149 | s3c_adc_start(ts.client, 0, 1 << ts.shift); | ||
150 | } else { | ||
151 | ts.xp = 0; | ||
152 | ts.yp = 0; | ||
153 | ts.count = 0; | ||
154 | |||
155 | input_report_key(ts.input, BTN_TOUCH, 0); | ||
156 | input_sync(ts.input); | ||
157 | |||
158 | writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | static DEFINE_TIMER(touch_timer, touch_timer_fire, 0, 0); | ||
163 | |||
164 | /** | ||
165 | * stylus_irq - touchscreen stylus event interrupt | ||
166 | * @irq: The interrupt number | ||
167 | * @dev_id: The device ID. | ||
168 | * | ||
169 | * Called when the IRQ_TC is fired for a pen up or down event. | ||
170 | */ | ||
171 | static irqreturn_t stylus_irq(int irq, void *dev_id) | ||
172 | { | ||
173 | unsigned long data0; | ||
174 | unsigned long data1; | ||
175 | bool down; | ||
176 | |||
177 | data0 = readl(ts.io + S3C2410_ADCDAT0); | ||
178 | data1 = readl(ts.io + S3C2410_ADCDAT1); | ||
179 | |||
180 | down = get_down(data0, data1); | ||
181 | |||
182 | /* TODO we should never get an interrupt with down set while | ||
183 | * the timer is running, but maybe we ought to verify that the | ||
184 | * timer isn't running anyways. */ | ||
185 | |||
186 | if (down) | ||
187 | s3c_adc_start(ts.client, 0, 1 << ts.shift); | ||
188 | else | ||
189 | dev_info(ts.dev, "%s: count=%d\n", __func__, ts.count); | ||
190 | |||
191 | return IRQ_HANDLED; | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * s3c24xx_ts_conversion - ADC conversion callback | ||
196 | * @client: The client that was registered with the ADC core. | ||
197 | * @data0: The reading from ADCDAT0. | ||
198 | * @data1: The reading from ADCDAT1. | ||
199 | * @left: The number of samples left. | ||
200 | * | ||
201 | * Called when a conversion has finished. | ||
202 | */ | ||
203 | static void s3c24xx_ts_conversion(struct s3c_adc_client *client, | ||
204 | unsigned data0, unsigned data1, | ||
205 | unsigned *left) | ||
206 | { | ||
207 | dev_dbg(ts.dev, "%s: %d,%d\n", __func__, data0, data1); | ||
208 | |||
209 | ts.xp += data0; | ||
210 | ts.yp += data1; | ||
211 | |||
212 | ts.count++; | ||
213 | |||
214 | /* From tests, it seems that it is unlikely to get a pen-up | ||
215 | * event during the conversion process which means we can | ||
216 | * ignore any pen-up events with less than the requisite | ||
217 | * count done. | ||
218 | * | ||
219 | * In several thousand conversions, no pen-ups where detected | ||
220 | * before count completed. | ||
221 | */ | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * s3c24xx_ts_select - ADC selection callback. | ||
226 | * @client: The client that was registered with the ADC core. | ||
227 | * @select: The reason for select. | ||
228 | * | ||
229 | * Called when the ADC core selects (or deslects) us as a client. | ||
230 | */ | ||
231 | static void s3c24xx_ts_select(struct s3c_adc_client *client, unsigned select) | ||
232 | { | ||
233 | if (select) { | ||
234 | writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, | ||
235 | ts.io + S3C2410_ADCTSC); | ||
236 | } else { | ||
237 | mod_timer(&touch_timer, jiffies+1); | ||
238 | writel(WAIT4INT | INT_UP, ts.io + S3C2410_ADCTSC); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | /** | ||
243 | * s3c2410ts_probe - device core probe entry point | ||
244 | * @pdev: The device we are being bound to. | ||
245 | * | ||
246 | * Initialise, find and allocate any resources we need to run and then | ||
247 | * register with the ADC and input systems. | ||
248 | */ | ||
249 | static int __devinit s3c2410ts_probe(struct platform_device *pdev) | ||
250 | { | ||
251 | struct s3c2410_ts_mach_info *info; | ||
252 | struct device *dev = &pdev->dev; | ||
253 | struct input_dev *input_dev; | ||
254 | struct resource *res; | ||
255 | int ret = -EINVAL; | ||
256 | |||
257 | /* Initialise input stuff */ | ||
258 | memset(&ts, 0, sizeof(struct s3c2410ts)); | ||
259 | |||
260 | ts.dev = dev; | ||
261 | |||
262 | info = pdev->dev.platform_data; | ||
263 | if (!info) { | ||
264 | dev_err(dev, "no platform data, cannot attach\n"); | ||
265 | return -EINVAL; | ||
266 | } | ||
267 | |||
268 | dev_dbg(dev, "initialising touchscreen\n"); | ||
269 | |||
270 | ts.clock = clk_get(dev, "adc"); | ||
271 | if (IS_ERR(ts.clock)) { | ||
272 | dev_err(dev, "cannot get adc clock source\n"); | ||
273 | return -ENOENT; | ||
274 | } | ||
275 | |||
276 | clk_enable(ts.clock); | ||
277 | dev_dbg(dev, "got and enabled clocks\n"); | ||
278 | |||
279 | ts.irq_tc = ret = platform_get_irq(pdev, 0); | ||
280 | if (ret < 0) { | ||
281 | dev_err(dev, "no resource for interrupt\n"); | ||
282 | goto err_clk; | ||
283 | } | ||
284 | |||
285 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
286 | if (!res) { | ||
287 | dev_err(dev, "no resource for registers\n"); | ||
288 | ret = -ENOENT; | ||
289 | goto err_clk; | ||
290 | } | ||
291 | |||
292 | ts.io = ioremap(res->start, resource_size(res)); | ||
293 | if (ts.io == NULL) { | ||
294 | dev_err(dev, "cannot map registers\n"); | ||
295 | ret = -ENOMEM; | ||
296 | goto err_clk; | ||
297 | } | ||
298 | |||
299 | /* Configure the touchscreen external FETs on the S3C2410 */ | ||
300 | if (!platform_get_device_id(pdev)->driver_data) | ||
301 | s3c2410_ts_connect(); | ||
302 | |||
303 | ts.client = s3c_adc_register(pdev, s3c24xx_ts_select, | ||
304 | s3c24xx_ts_conversion, 1); | ||
305 | if (IS_ERR(ts.client)) { | ||
306 | dev_err(dev, "failed to register adc client\n"); | ||
307 | ret = PTR_ERR(ts.client); | ||
308 | goto err_iomap; | ||
309 | } | ||
310 | |||
311 | /* Initialise registers */ | ||
312 | if ((info->delay & 0xffff) > 0) | ||
313 | writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY); | ||
314 | |||
315 | writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); | ||
316 | |||
317 | input_dev = input_allocate_device(); | ||
318 | if (!input_dev) { | ||
319 | dev_err(dev, "Unable to allocate the input device !!\n"); | ||
320 | ret = -ENOMEM; | ||
321 | goto err_iomap; | ||
322 | } | ||
323 | |||
324 | ts.input = input_dev; | ||
325 | ts.input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
326 | ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
327 | input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); | ||
328 | input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); | ||
329 | |||
330 | ts.input->name = "S3C24XX TouchScreen"; | ||
331 | ts.input->id.bustype = BUS_HOST; | ||
332 | ts.input->id.vendor = 0xDEAD; | ||
333 | ts.input->id.product = 0xBEEF; | ||
334 | ts.input->id.version = 0x0102; | ||
335 | |||
336 | ts.shift = info->oversampling_shift; | ||
337 | |||
338 | ret = request_irq(ts.irq_tc, stylus_irq, IRQF_DISABLED, | ||
339 | "s3c2410_ts_pen", ts.input); | ||
340 | if (ret) { | ||
341 | dev_err(dev, "cannot get TC interrupt\n"); | ||
342 | goto err_inputdev; | ||
343 | } | ||
344 | |||
345 | dev_info(dev, "driver attached, registering input device\n"); | ||
346 | |||
347 | /* All went ok, so register to the input system */ | ||
348 | ret = input_register_device(ts.input); | ||
349 | if (ret < 0) { | ||
350 | dev_err(dev, "failed to register input device\n"); | ||
351 | ret = -EIO; | ||
352 | goto err_tcirq; | ||
353 | } | ||
354 | |||
355 | return 0; | ||
356 | |||
357 | err_tcirq: | ||
358 | free_irq(ts.irq_tc, ts.input); | ||
359 | err_inputdev: | ||
360 | input_unregister_device(ts.input); | ||
361 | err_iomap: | ||
362 | iounmap(ts.io); | ||
363 | err_clk: | ||
364 | del_timer_sync(&touch_timer); | ||
365 | clk_put(ts.clock); | ||
366 | return ret; | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * s3c2410ts_remove - device core removal entry point | ||
371 | * @pdev: The device we are being removed from. | ||
372 | * | ||
373 | * Free up our state ready to be removed. | ||
374 | */ | ||
375 | static int __devexit s3c2410ts_remove(struct platform_device *pdev) | ||
376 | { | ||
377 | free_irq(ts.irq_tc, ts.input); | ||
378 | del_timer_sync(&touch_timer); | ||
379 | |||
380 | clk_disable(ts.clock); | ||
381 | clk_put(ts.clock); | ||
382 | |||
383 | input_unregister_device(ts.input); | ||
384 | iounmap(ts.io); | ||
385 | |||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | #ifdef CONFIG_PM | ||
390 | static int s3c2410ts_suspend(struct device *dev) | ||
391 | { | ||
392 | writel(TSC_SLEEP, ts.io + S3C2410_ADCTSC); | ||
393 | disable_irq(ts.irq_tc); | ||
394 | clk_disable(ts.clock); | ||
395 | |||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | static int s3c2410ts_resume(struct device *dev) | ||
400 | { | ||
401 | struct platform_device *pdev = to_platform_device(dev); | ||
402 | struct s3c2410_ts_mach_info *info = pdev->dev.platform_data; | ||
403 | |||
404 | clk_enable(ts.clock); | ||
405 | enable_irq(ts.irq_tc); | ||
406 | |||
407 | /* Initialise registers */ | ||
408 | if ((info->delay & 0xffff) > 0) | ||
409 | writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY); | ||
410 | |||
411 | writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); | ||
412 | |||
413 | return 0; | ||
414 | } | ||
415 | |||
416 | static struct dev_pm_ops s3c_ts_pmops = { | ||
417 | .suspend = s3c2410ts_suspend, | ||
418 | .resume = s3c2410ts_resume, | ||
419 | }; | ||
420 | #endif | ||
421 | |||
422 | static struct platform_device_id s3cts_driver_ids[] = { | ||
423 | { "s3c2410-ts", 0 }, | ||
424 | { "s3c2440-ts", 1 }, | ||
425 | { } | ||
426 | }; | ||
427 | MODULE_DEVICE_TABLE(platform, s3cts_driver_ids); | ||
428 | |||
429 | static struct platform_driver s3c_ts_driver = { | ||
430 | .driver = { | ||
431 | .name = "s3c24xx-ts", | ||
432 | .owner = THIS_MODULE, | ||
433 | #ifdef CONFIG_PM | ||
434 | .pm = &s3c_ts_pmops, | ||
435 | #endif | ||
436 | }, | ||
437 | .id_table = s3cts_driver_ids, | ||
438 | .probe = s3c2410ts_probe, | ||
439 | .remove = __devexit_p(s3c2410ts_remove), | ||
440 | }; | ||
441 | |||
442 | static int __init s3c2410ts_init(void) | ||
443 | { | ||
444 | return platform_driver_register(&s3c_ts_driver); | ||
445 | } | ||
446 | |||
447 | static void __exit s3c2410ts_exit(void) | ||
448 | { | ||
449 | platform_driver_unregister(&s3c_ts_driver); | ||
450 | } | ||
451 | |||
452 | module_init(s3c2410ts_init); | ||
453 | module_exit(s3c2410ts_exit); | ||
454 | |||
455 | MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>, " | ||
456 | "Ben Dooks <ben@simtec.co.uk>, " | ||
457 | "Simtec Electronics <linux@simtec.co.uk>"); | ||
458 | MODULE_DESCRIPTION("S3C24XX Touchscreen driver"); | ||
459 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c index 7ef0d1420d3c..be23780e8a3e 100644 --- a/drivers/input/touchscreen/tsc2007.c +++ b/drivers/input/touchscreen/tsc2007.c | |||
@@ -358,7 +358,7 @@ static int __devexit tsc2007_remove(struct i2c_client *client) | |||
358 | return 0; | 358 | return 0; |
359 | } | 359 | } |
360 | 360 | ||
361 | static struct i2c_device_id tsc2007_idtable[] = { | 361 | static const struct i2c_device_id tsc2007_idtable[] = { |
362 | { "tsc2007", 0 }, | 362 | { "tsc2007", 0 }, |
363 | { } | 363 | { } |
364 | }; | 364 | }; |
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c index 095f84b1f56e..028a5363eea1 100644 --- a/drivers/input/touchscreen/ucb1400_ts.c +++ b/drivers/input/touchscreen/ucb1400_ts.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/suspend.h> | 28 | #include <linux/suspend.h> |
29 | #include <linux/slab.h> | ||
30 | #include <linux/kthread.h> | 29 | #include <linux/kthread.h> |
31 | #include <linux/freezer.h> | 30 | #include <linux/freezer.h> |
32 | #include <linux/ucb1400.h> | 31 | #include <linux/ucb1400.h> |
@@ -355,10 +354,13 @@ static int ucb1400_ts_probe(struct platform_device *dev) | |||
355 | goto err; | 354 | goto err; |
356 | } | 355 | } |
357 | 356 | ||
358 | error = ucb1400_ts_detect_irq(ucb); | 357 | /* Only in case the IRQ line wasn't supplied, try detecting it */ |
359 | if (error) { | 358 | if (ucb->irq < 0) { |
360 | printk(KERN_ERR "UCB1400: IRQ probe failed\n"); | 359 | error = ucb1400_ts_detect_irq(ucb); |
361 | goto err_free_devs; | 360 | if (error) { |
361 | printk(KERN_ERR "UCB1400: IRQ probe failed\n"); | ||
362 | goto err_free_devs; | ||
363 | } | ||
362 | } | 364 | } |
363 | 365 | ||
364 | init_waitqueue_head(&ucb->ts_wait); | 366 | init_waitqueue_head(&ucb->ts_wait); |
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 68ece5801a58..99330bbdbac7 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c | |||
@@ -14,6 +14,8 @@ | |||
14 | * - General Touch | 14 | * - General Touch |
15 | * - GoTop Super_Q2/GogoPen/PenPower tablets | 15 | * - GoTop Super_Q2/GogoPen/PenPower tablets |
16 | * - JASTEC USB touch controller/DigiTech DTR-02U | 16 | * - JASTEC USB touch controller/DigiTech DTR-02U |
17 | * - Zytronic capacitive touchscreen | ||
18 | * - NEXIO/iNexio | ||
17 | * | 19 | * |
18 | * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> | 20 | * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> |
19 | * Copyright (C) by Todd E. Johnson (mtouchusb.c) | 21 | * Copyright (C) by Todd E. Johnson (mtouchusb.c) |
@@ -73,6 +75,15 @@ struct usbtouch_device_info { | |||
73 | int min_press, max_press; | 75 | int min_press, max_press; |
74 | int rept_size; | 76 | int rept_size; |
75 | 77 | ||
78 | /* | ||
79 | * Always service the USB devices irq not just when the input device is | ||
80 | * open. This is useful when devices have a watchdog which prevents us | ||
81 | * from periodically polling the device. Leave this unset unless your | ||
82 | * touchscreen device requires it, as it does consume more of the USB | ||
83 | * bandwidth. | ||
84 | */ | ||
85 | bool irq_always; | ||
86 | |||
76 | void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len); | 87 | void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len); |
77 | 88 | ||
78 | /* | 89 | /* |
@@ -85,6 +96,7 @@ struct usbtouch_device_info { | |||
85 | 96 | ||
86 | int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); | 97 | int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); |
87 | int (*init) (struct usbtouch_usb *usbtouch); | 98 | int (*init) (struct usbtouch_usb *usbtouch); |
99 | void (*exit) (struct usbtouch_usb *usbtouch); | ||
88 | }; | 100 | }; |
89 | 101 | ||
90 | /* a usbtouch device */ | 102 | /* a usbtouch device */ |
@@ -94,11 +106,12 @@ struct usbtouch_usb { | |||
94 | unsigned char *buffer; | 106 | unsigned char *buffer; |
95 | int buf_len; | 107 | int buf_len; |
96 | struct urb *irq; | 108 | struct urb *irq; |
97 | struct usb_device *udev; | 109 | struct usb_interface *interface; |
98 | struct input_dev *input; | 110 | struct input_dev *input; |
99 | struct usbtouch_device_info *type; | 111 | struct usbtouch_device_info *type; |
100 | char name[128]; | 112 | char name[128]; |
101 | char phys[64]; | 113 | char phys[64]; |
114 | void *priv; | ||
102 | 115 | ||
103 | int x, y; | 116 | int x, y; |
104 | int touch, press; | 117 | int touch, press; |
@@ -121,6 +134,9 @@ enum { | |||
121 | DEVTYPE_GOTOP, | 134 | DEVTYPE_GOTOP, |
122 | DEVTYPE_JASTEC, | 135 | DEVTYPE_JASTEC, |
123 | DEVTYPE_E2I, | 136 | DEVTYPE_E2I, |
137 | DEVTYPE_ZYTRONIC, | ||
138 | DEVTYPE_TC5UH, | ||
139 | DEVTYPE_NEXIO, | ||
124 | }; | 140 | }; |
125 | 141 | ||
126 | #define USB_DEVICE_HID_CLASS(vend, prod) \ | 142 | #define USB_DEVICE_HID_CLASS(vend, prod) \ |
@@ -132,7 +148,7 @@ enum { | |||
132 | .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ | 148 | .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ |
133 | .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE | 149 | .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE |
134 | 150 | ||
135 | static struct usb_device_id usbtouch_devices[] = { | 151 | static const struct usb_device_id usbtouch_devices[] = { |
136 | #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX | 152 | #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX |
137 | /* ignore the HID capable devices, handled by usbhid */ | 153 | /* ignore the HID capable devices, handled by usbhid */ |
138 | {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, | 154 | {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, |
@@ -201,6 +217,23 @@ static struct usb_device_id usbtouch_devices[] = { | |||
201 | #ifdef CONFIG_TOUCHSCREEN_USB_E2I | 217 | #ifdef CONFIG_TOUCHSCREEN_USB_E2I |
202 | {USB_DEVICE(0x1ac7, 0x0001), .driver_info = DEVTYPE_E2I}, | 218 | {USB_DEVICE(0x1ac7, 0x0001), .driver_info = DEVTYPE_E2I}, |
203 | #endif | 219 | #endif |
220 | |||
221 | #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC | ||
222 | {USB_DEVICE(0x14c8, 0x0003), .driver_info = DEVTYPE_ZYTRONIC}, | ||
223 | #endif | ||
224 | |||
225 | #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH | ||
226 | {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH}, | ||
227 | #endif | ||
228 | |||
229 | #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO | ||
230 | /* data interface only */ | ||
231 | {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00), | ||
232 | .driver_info = DEVTYPE_NEXIO}, | ||
233 | {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00), | ||
234 | .driver_info = DEVTYPE_NEXIO}, | ||
235 | #endif | ||
236 | |||
204 | {} | 237 | {} |
205 | }; | 238 | }; |
206 | 239 | ||
@@ -213,8 +246,9 @@ static struct usb_device_id usbtouch_devices[] = { | |||
213 | static int e2i_init(struct usbtouch_usb *usbtouch) | 246 | static int e2i_init(struct usbtouch_usb *usbtouch) |
214 | { | 247 | { |
215 | int ret; | 248 | int ret; |
249 | struct usb_device *udev = interface_to_usbdev(usbtouch->interface); | ||
216 | 250 | ||
217 | ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), | 251 | ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
218 | 0x01, 0x02, 0x0000, 0x0081, | 252 | 0x01, 0x02, 0x0000, 0x0081, |
219 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 253 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
220 | 254 | ||
@@ -323,8 +357,9 @@ static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | |||
323 | static int mtouch_init(struct usbtouch_usb *usbtouch) | 357 | static int mtouch_init(struct usbtouch_usb *usbtouch) |
324 | { | 358 | { |
325 | int ret, i; | 359 | int ret, i; |
360 | struct usb_device *udev = interface_to_usbdev(usbtouch->interface); | ||
326 | 361 | ||
327 | ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), | 362 | ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
328 | MTOUCHUSB_RESET, | 363 | MTOUCHUSB_RESET, |
329 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 364 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
330 | 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); | 365 | 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
@@ -335,7 +370,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch) | |||
335 | msleep(150); | 370 | msleep(150); |
336 | 371 | ||
337 | for (i = 0; i < 3; i++) { | 372 | for (i = 0; i < 3; i++) { |
338 | ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), | 373 | ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
339 | MTOUCHUSB_ASYNC_REPORT, | 374 | MTOUCHUSB_ASYNC_REPORT, |
340 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 375 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
341 | 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); | 376 | 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); |
@@ -468,7 +503,7 @@ static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | |||
468 | 503 | ||
469 | static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) | 504 | static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) |
470 | { | 505 | { |
471 | struct usb_device *dev = usbtouch->udev; | 506 | struct usb_device *dev = interface_to_usbdev(usbtouch->interface); |
472 | int ret = -ENOMEM; | 507 | int ret = -ENOMEM; |
473 | unsigned char *buf; | 508 | unsigned char *buf; |
474 | 509 | ||
@@ -538,6 +573,19 @@ static int irtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | |||
538 | } | 573 | } |
539 | #endif | 574 | #endif |
540 | 575 | ||
576 | /***************************************************************************** | ||
577 | * ET&T TC5UH part | ||
578 | */ | ||
579 | #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH | ||
580 | static int tc5uh_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | ||
581 | { | ||
582 | dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1]; | ||
583 | dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3]; | ||
584 | dev->touch = pkt[0] & 0x01; | ||
585 | |||
586 | return 1; | ||
587 | } | ||
588 | #endif | ||
541 | 589 | ||
542 | /***************************************************************************** | 590 | /***************************************************************************** |
543 | * IdealTEK URTC1000 Part | 591 | * IdealTEK URTC1000 Part |
@@ -584,8 +632,8 @@ static int idealtek_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | |||
584 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH | 632 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH |
585 | static int general_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | 633 | static int general_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
586 | { | 634 | { |
587 | dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1] ; | 635 | dev->x = (pkt[2] << 8) | pkt[1]; |
588 | dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3] ; | 636 | dev->y = (pkt[4] << 8) | pkt[3]; |
589 | dev->press = pkt[5] & 0xff; | 637 | dev->press = pkt[5] & 0xff; |
590 | dev->touch = pkt[0] & 0x01; | 638 | dev->touch = pkt[0] & 0x01; |
591 | 639 | ||
@@ -621,6 +669,262 @@ static int jastec_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | |||
621 | } | 669 | } |
622 | #endif | 670 | #endif |
623 | 671 | ||
672 | /***************************************************************************** | ||
673 | * Zytronic Part | ||
674 | */ | ||
675 | #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC | ||
676 | static int zytronic_read_data(struct usbtouch_usb *dev, unsigned char *pkt) | ||
677 | { | ||
678 | switch (pkt[0]) { | ||
679 | case 0x3A: /* command response */ | ||
680 | dbg("%s: Command response %d", __func__, pkt[1]); | ||
681 | break; | ||
682 | |||
683 | case 0xC0: /* down */ | ||
684 | dev->x = (pkt[1] & 0x7f) | ((pkt[2] & 0x07) << 7); | ||
685 | dev->y = (pkt[3] & 0x7f) | ((pkt[4] & 0x07) << 7); | ||
686 | dev->touch = 1; | ||
687 | dbg("%s: down %d,%d", __func__, dev->x, dev->y); | ||
688 | return 1; | ||
689 | |||
690 | case 0x80: /* up */ | ||
691 | dev->x = (pkt[1] & 0x7f) | ((pkt[2] & 0x07) << 7); | ||
692 | dev->y = (pkt[3] & 0x7f) | ((pkt[4] & 0x07) << 7); | ||
693 | dev->touch = 0; | ||
694 | dbg("%s: up %d,%d", __func__, dev->x, dev->y); | ||
695 | return 1; | ||
696 | |||
697 | default: | ||
698 | dbg("%s: Unknown return %d", __func__, pkt[0]); | ||
699 | break; | ||
700 | } | ||
701 | |||
702 | return 0; | ||
703 | } | ||
704 | #endif | ||
705 | |||
706 | /***************************************************************************** | ||
707 | * NEXIO Part | ||
708 | */ | ||
709 | #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO | ||
710 | |||
711 | #define NEXIO_TIMEOUT 5000 | ||
712 | #define NEXIO_BUFSIZE 1024 | ||
713 | #define NEXIO_THRESHOLD 50 | ||
714 | |||
715 | struct nexio_priv { | ||
716 | struct urb *ack; | ||
717 | unsigned char *ack_buf; | ||
718 | }; | ||
719 | |||
720 | struct nexio_touch_packet { | ||
721 | u8 flags; /* 0xe1 = touch, 0xe1 = release */ | ||
722 | __be16 data_len; /* total bytes of touch data */ | ||
723 | __be16 x_len; /* bytes for X axis */ | ||
724 | __be16 y_len; /* bytes for Y axis */ | ||
725 | u8 data[]; | ||
726 | } __attribute__ ((packed)); | ||
727 | |||
728 | static unsigned char nexio_ack_pkt[2] = { 0xaa, 0x02 }; | ||
729 | static unsigned char nexio_init_pkt[4] = { 0x82, 0x04, 0x0a, 0x0f }; | ||
730 | |||
731 | static void nexio_ack_complete(struct urb *urb) | ||
732 | { | ||
733 | } | ||
734 | |||
735 | static int nexio_init(struct usbtouch_usb *usbtouch) | ||
736 | { | ||
737 | struct usb_device *dev = interface_to_usbdev(usbtouch->interface); | ||
738 | struct usb_host_interface *interface = usbtouch->interface->cur_altsetting; | ||
739 | struct nexio_priv *priv; | ||
740 | int ret = -ENOMEM; | ||
741 | int actual_len, i; | ||
742 | unsigned char *buf; | ||
743 | char *firmware_ver = NULL, *device_name = NULL; | ||
744 | int input_ep = 0, output_ep = 0; | ||
745 | |||
746 | /* find first input and output endpoint */ | ||
747 | for (i = 0; i < interface->desc.bNumEndpoints; i++) { | ||
748 | if (!input_ep && | ||
749 | usb_endpoint_dir_in(&interface->endpoint[i].desc)) | ||
750 | input_ep = interface->endpoint[i].desc.bEndpointAddress; | ||
751 | if (!output_ep && | ||
752 | usb_endpoint_dir_out(&interface->endpoint[i].desc)) | ||
753 | output_ep = interface->endpoint[i].desc.bEndpointAddress; | ||
754 | } | ||
755 | if (!input_ep || !output_ep) | ||
756 | return -ENXIO; | ||
757 | |||
758 | buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL); | ||
759 | if (!buf) | ||
760 | goto out_buf; | ||
761 | |||
762 | /* two empty reads */ | ||
763 | for (i = 0; i < 2; i++) { | ||
764 | ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep), | ||
765 | buf, NEXIO_BUFSIZE, &actual_len, | ||
766 | NEXIO_TIMEOUT); | ||
767 | if (ret < 0) | ||
768 | goto out_buf; | ||
769 | } | ||
770 | |||
771 | /* send init command */ | ||
772 | memcpy(buf, nexio_init_pkt, sizeof(nexio_init_pkt)); | ||
773 | ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, output_ep), | ||
774 | buf, sizeof(nexio_init_pkt), &actual_len, | ||
775 | NEXIO_TIMEOUT); | ||
776 | if (ret < 0) | ||
777 | goto out_buf; | ||
778 | |||
779 | /* read replies */ | ||
780 | for (i = 0; i < 3; i++) { | ||
781 | memset(buf, 0, NEXIO_BUFSIZE); | ||
782 | ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep), | ||
783 | buf, NEXIO_BUFSIZE, &actual_len, | ||
784 | NEXIO_TIMEOUT); | ||
785 | if (ret < 0 || actual_len < 1 || buf[1] != actual_len) | ||
786 | continue; | ||
787 | switch (buf[0]) { | ||
788 | case 0x83: /* firmware version */ | ||
789 | if (!firmware_ver) | ||
790 | firmware_ver = kstrdup(&buf[2], GFP_KERNEL); | ||
791 | break; | ||
792 | case 0x84: /* device name */ | ||
793 | if (!device_name) | ||
794 | device_name = kstrdup(&buf[2], GFP_KERNEL); | ||
795 | break; | ||
796 | } | ||
797 | } | ||
798 | |||
799 | printk(KERN_INFO "Nexio device: %s, firmware version: %s\n", | ||
800 | device_name, firmware_ver); | ||
801 | |||
802 | kfree(firmware_ver); | ||
803 | kfree(device_name); | ||
804 | |||
805 | /* prepare ACK URB */ | ||
806 | ret = -ENOMEM; | ||
807 | |||
808 | usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); | ||
809 | if (!usbtouch->priv) | ||
810 | goto out_buf; | ||
811 | |||
812 | priv = usbtouch->priv; | ||
813 | |||
814 | priv->ack_buf = kmalloc(sizeof(nexio_ack_pkt), GFP_KERNEL); | ||
815 | if (!priv->ack_buf) | ||
816 | goto err_priv; | ||
817 | |||
818 | memcpy(priv->ack_buf, nexio_ack_pkt, sizeof(nexio_ack_pkt)); | ||
819 | |||
820 | priv->ack = usb_alloc_urb(0, GFP_KERNEL); | ||
821 | if (!priv->ack) { | ||
822 | dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__); | ||
823 | goto err_ack_buf; | ||
824 | } | ||
825 | |||
826 | usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep), | ||
827 | priv->ack_buf, sizeof(nexio_ack_pkt), | ||
828 | nexio_ack_complete, usbtouch); | ||
829 | ret = 0; | ||
830 | goto out_buf; | ||
831 | |||
832 | err_ack_buf: | ||
833 | kfree(priv->ack_buf); | ||
834 | err_priv: | ||
835 | kfree(priv); | ||
836 | out_buf: | ||
837 | kfree(buf); | ||
838 | return ret; | ||
839 | } | ||
840 | |||
841 | static void nexio_exit(struct usbtouch_usb *usbtouch) | ||
842 | { | ||
843 | struct nexio_priv *priv = usbtouch->priv; | ||
844 | |||
845 | usb_kill_urb(priv->ack); | ||
846 | usb_free_urb(priv->ack); | ||
847 | kfree(priv->ack_buf); | ||
848 | kfree(priv); | ||
849 | } | ||
850 | |||
851 | static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) | ||
852 | { | ||
853 | int x, y, begin_x, begin_y, end_x, end_y, w, h, ret; | ||
854 | struct nexio_touch_packet *packet = (void *) pkt; | ||
855 | struct nexio_priv *priv = usbtouch->priv; | ||
856 | |||
857 | /* got touch data? */ | ||
858 | if ((pkt[0] & 0xe0) != 0xe0) | ||
859 | return 0; | ||
860 | |||
861 | /* send ACK */ | ||
862 | ret = usb_submit_urb(priv->ack, GFP_ATOMIC); | ||
863 | |||
864 | if (!usbtouch->type->max_xc) { | ||
865 | usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len); | ||
866 | input_set_abs_params(usbtouch->input, ABS_X, 0, | ||
867 | 2 * be16_to_cpu(packet->x_len), 0, 0); | ||
868 | usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len); | ||
869 | input_set_abs_params(usbtouch->input, ABS_Y, 0, | ||
870 | 2 * be16_to_cpu(packet->y_len), 0, 0); | ||
871 | } | ||
872 | /* | ||
873 | * The device reports state of IR sensors on X and Y axes. | ||
874 | * Each byte represents "darkness" percentage (0-100) of one element. | ||
875 | * 17" touchscreen reports only 64 x 52 bytes so the resolution is low. | ||
876 | * This also means that there's a limited multi-touch capability but | ||
877 | * it's disabled (and untested) here as there's no X driver for that. | ||
878 | */ | ||
879 | begin_x = end_x = begin_y = end_y = -1; | ||
880 | for (x = 0; x < be16_to_cpu(packet->x_len); x++) { | ||
881 | if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) { | ||
882 | begin_x = x; | ||
883 | continue; | ||
884 | } | ||
885 | if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) { | ||
886 | end_x = x - 1; | ||
887 | for (y = be16_to_cpu(packet->x_len); | ||
888 | y < be16_to_cpu(packet->data_len); y++) { | ||
889 | if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) { | ||
890 | begin_y = y - be16_to_cpu(packet->x_len); | ||
891 | continue; | ||
892 | } | ||
893 | if (end_y == -1 && | ||
894 | begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) { | ||
895 | end_y = y - 1 - be16_to_cpu(packet->x_len); | ||
896 | w = end_x - begin_x; | ||
897 | h = end_y - begin_y; | ||
898 | #if 0 | ||
899 | /* multi-touch */ | ||
900 | input_report_abs(usbtouch->input, | ||
901 | ABS_MT_TOUCH_MAJOR, max(w,h)); | ||
902 | input_report_abs(usbtouch->input, | ||
903 | ABS_MT_TOUCH_MINOR, min(x,h)); | ||
904 | input_report_abs(usbtouch->input, | ||
905 | ABS_MT_POSITION_X, 2*begin_x+w); | ||
906 | input_report_abs(usbtouch->input, | ||
907 | ABS_MT_POSITION_Y, 2*begin_y+h); | ||
908 | input_report_abs(usbtouch->input, | ||
909 | ABS_MT_ORIENTATION, w > h); | ||
910 | input_mt_sync(usbtouch->input); | ||
911 | #endif | ||
912 | /* single touch */ | ||
913 | usbtouch->x = 2 * begin_x + w; | ||
914 | usbtouch->y = 2 * begin_y + h; | ||
915 | usbtouch->touch = packet->flags & 0x01; | ||
916 | begin_y = end_y = -1; | ||
917 | return 1; | ||
918 | } | ||
919 | } | ||
920 | begin_x = end_x = -1; | ||
921 | } | ||
922 | |||
923 | } | ||
924 | return 0; | ||
925 | } | ||
926 | #endif | ||
927 | |||
624 | 928 | ||
625 | /***************************************************************************** | 929 | /***************************************************************************** |
626 | * the different device descriptors | 930 | * the different device descriptors |
@@ -742,9 +1046,9 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { | |||
742 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH | 1046 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH |
743 | [DEVTYPE_GENERAL_TOUCH] = { | 1047 | [DEVTYPE_GENERAL_TOUCH] = { |
744 | .min_xc = 0x0, | 1048 | .min_xc = 0x0, |
745 | .max_xc = 0x0500, | 1049 | .max_xc = 0x7fff, |
746 | .min_yc = 0x0, | 1050 | .min_yc = 0x0, |
747 | .max_yc = 0x0500, | 1051 | .max_yc = 0x7fff, |
748 | .rept_size = 7, | 1052 | .rept_size = 7, |
749 | .read_data = general_touch_read_data, | 1053 | .read_data = general_touch_read_data, |
750 | }, | 1054 | }, |
@@ -783,6 +1087,39 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { | |||
783 | .read_data = e2i_read_data, | 1087 | .read_data = e2i_read_data, |
784 | }, | 1088 | }, |
785 | #endif | 1089 | #endif |
1090 | |||
1091 | #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC | ||
1092 | [DEVTYPE_ZYTRONIC] = { | ||
1093 | .min_xc = 0x0, | ||
1094 | .max_xc = 0x03ff, | ||
1095 | .min_yc = 0x0, | ||
1096 | .max_yc = 0x03ff, | ||
1097 | .rept_size = 5, | ||
1098 | .read_data = zytronic_read_data, | ||
1099 | .irq_always = true, | ||
1100 | }, | ||
1101 | #endif | ||
1102 | |||
1103 | #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH | ||
1104 | [DEVTYPE_TC5UH] = { | ||
1105 | .min_xc = 0x0, | ||
1106 | .max_xc = 0x0fff, | ||
1107 | .min_yc = 0x0, | ||
1108 | .max_yc = 0x0fff, | ||
1109 | .rept_size = 5, | ||
1110 | .read_data = tc5uh_read_data, | ||
1111 | }, | ||
1112 | #endif | ||
1113 | |||
1114 | #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO | ||
1115 | [DEVTYPE_NEXIO] = { | ||
1116 | .rept_size = 128, | ||
1117 | .irq_always = true, | ||
1118 | .read_data = nexio_read_data, | ||
1119 | .init = nexio_init, | ||
1120 | .exit = nexio_exit, | ||
1121 | }, | ||
1122 | #endif | ||
786 | }; | 1123 | }; |
787 | 1124 | ||
788 | 1125 | ||
@@ -908,6 +1245,7 @@ static void usbtouch_irq(struct urb *urb) | |||
908 | case -ECONNRESET: | 1245 | case -ECONNRESET: |
909 | case -ENOENT: | 1246 | case -ENOENT: |
910 | case -ESHUTDOWN: | 1247 | case -ESHUTDOWN: |
1248 | case -EPIPE: | ||
911 | /* this urb is terminated, clean up */ | 1249 | /* this urb is terminated, clean up */ |
912 | dbg("%s - urb shutting down with status: %d", | 1250 | dbg("%s - urb shutting down with status: %d", |
913 | __func__, urb->status); | 1251 | __func__, urb->status); |
@@ -931,10 +1269,12 @@ static int usbtouch_open(struct input_dev *input) | |||
931 | { | 1269 | { |
932 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); | 1270 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); |
933 | 1271 | ||
934 | usbtouch->irq->dev = usbtouch->udev; | 1272 | usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface); |
935 | 1273 | ||
936 | if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) | 1274 | if (!usbtouch->type->irq_always) { |
937 | return -EIO; | 1275 | if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) |
1276 | return -EIO; | ||
1277 | } | ||
938 | 1278 | ||
939 | return 0; | 1279 | return 0; |
940 | } | 1280 | } |
@@ -943,7 +1283,8 @@ static void usbtouch_close(struct input_dev *input) | |||
943 | { | 1283 | { |
944 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); | 1284 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); |
945 | 1285 | ||
946 | usb_kill_urb(usbtouch->irq); | 1286 | if (!usbtouch->type->irq_always) |
1287 | usb_kill_urb(usbtouch->irq); | ||
947 | } | 1288 | } |
948 | 1289 | ||
949 | 1290 | ||
@@ -955,13 +1296,23 @@ static void usbtouch_free_buffers(struct usb_device *udev, | |||
955 | kfree(usbtouch->buffer); | 1296 | kfree(usbtouch->buffer); |
956 | } | 1297 | } |
957 | 1298 | ||
1299 | static struct usb_endpoint_descriptor * | ||
1300 | usbtouch_get_input_endpoint(struct usb_host_interface *interface) | ||
1301 | { | ||
1302 | int i; | ||
1303 | |||
1304 | for (i = 0; i < interface->desc.bNumEndpoints; i++) | ||
1305 | if (usb_endpoint_dir_in(&interface->endpoint[i].desc)) | ||
1306 | return &interface->endpoint[i].desc; | ||
1307 | |||
1308 | return NULL; | ||
1309 | } | ||
958 | 1310 | ||
959 | static int usbtouch_probe(struct usb_interface *intf, | 1311 | static int usbtouch_probe(struct usb_interface *intf, |
960 | const struct usb_device_id *id) | 1312 | const struct usb_device_id *id) |
961 | { | 1313 | { |
962 | struct usbtouch_usb *usbtouch; | 1314 | struct usbtouch_usb *usbtouch; |
963 | struct input_dev *input_dev; | 1315 | struct input_dev *input_dev; |
964 | struct usb_host_interface *interface; | ||
965 | struct usb_endpoint_descriptor *endpoint; | 1316 | struct usb_endpoint_descriptor *endpoint; |
966 | struct usb_device *udev = interface_to_usbdev(intf); | 1317 | struct usb_device *udev = interface_to_usbdev(intf); |
967 | struct usbtouch_device_info *type; | 1318 | struct usbtouch_device_info *type; |
@@ -971,8 +1322,9 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
971 | if (id->driver_info == DEVTYPE_IGNORE) | 1322 | if (id->driver_info == DEVTYPE_IGNORE) |
972 | return -ENODEV; | 1323 | return -ENODEV; |
973 | 1324 | ||
974 | interface = intf->cur_altsetting; | 1325 | endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting); |
975 | endpoint = &interface->endpoint[0].desc; | 1326 | if (!endpoint) |
1327 | return -ENXIO; | ||
976 | 1328 | ||
977 | usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); | 1329 | usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); |
978 | input_dev = input_allocate_device(); | 1330 | input_dev = input_allocate_device(); |
@@ -1001,7 +1353,7 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
1001 | goto out_free_buffers; | 1353 | goto out_free_buffers; |
1002 | } | 1354 | } |
1003 | 1355 | ||
1004 | usbtouch->udev = udev; | 1356 | usbtouch->interface = intf; |
1005 | usbtouch->input = input_dev; | 1357 | usbtouch->input = input_dev; |
1006 | 1358 | ||
1007 | if (udev->manufacturer) | 1359 | if (udev->manufacturer) |
@@ -1040,12 +1392,18 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
1040 | input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, | 1392 | input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, |
1041 | type->max_press, 0, 0); | 1393 | type->max_press, 0, 0); |
1042 | 1394 | ||
1043 | usb_fill_int_urb(usbtouch->irq, usbtouch->udev, | 1395 | if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) |
1044 | usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress), | 1396 | usb_fill_int_urb(usbtouch->irq, udev, |
1397 | usb_rcvintpipe(udev, endpoint->bEndpointAddress), | ||
1045 | usbtouch->data, type->rept_size, | 1398 | usbtouch->data, type->rept_size, |
1046 | usbtouch_irq, usbtouch, endpoint->bInterval); | 1399 | usbtouch_irq, usbtouch, endpoint->bInterval); |
1400 | else | ||
1401 | usb_fill_bulk_urb(usbtouch->irq, udev, | ||
1402 | usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), | ||
1403 | usbtouch->data, type->rept_size, | ||
1404 | usbtouch_irq, usbtouch); | ||
1047 | 1405 | ||
1048 | usbtouch->irq->dev = usbtouch->udev; | 1406 | usbtouch->irq->dev = udev; |
1049 | usbtouch->irq->transfer_dma = usbtouch->data_dma; | 1407 | usbtouch->irq->transfer_dma = usbtouch->data_dma; |
1050 | usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 1408 | usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
1051 | 1409 | ||
@@ -1054,20 +1412,37 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
1054 | err = type->init(usbtouch); | 1412 | err = type->init(usbtouch); |
1055 | if (err) { | 1413 | if (err) { |
1056 | dbg("%s - type->init() failed, err: %d", __func__, err); | 1414 | dbg("%s - type->init() failed, err: %d", __func__, err); |
1057 | goto out_free_buffers; | 1415 | goto out_free_urb; |
1058 | } | 1416 | } |
1059 | } | 1417 | } |
1060 | 1418 | ||
1061 | err = input_register_device(usbtouch->input); | 1419 | err = input_register_device(usbtouch->input); |
1062 | if (err) { | 1420 | if (err) { |
1063 | dbg("%s - input_register_device failed, err: %d", __func__, err); | 1421 | dbg("%s - input_register_device failed, err: %d", __func__, err); |
1064 | goto out_free_buffers; | 1422 | goto out_do_exit; |
1065 | } | 1423 | } |
1066 | 1424 | ||
1067 | usb_set_intfdata(intf, usbtouch); | 1425 | usb_set_intfdata(intf, usbtouch); |
1068 | 1426 | ||
1427 | if (usbtouch->type->irq_always) { | ||
1428 | err = usb_submit_urb(usbtouch->irq, GFP_KERNEL); | ||
1429 | if (err) { | ||
1430 | err("%s - usb_submit_urb failed with result: %d", | ||
1431 | __func__, err); | ||
1432 | goto out_unregister_input; | ||
1433 | } | ||
1434 | } | ||
1435 | |||
1069 | return 0; | 1436 | return 0; |
1070 | 1437 | ||
1438 | out_unregister_input: | ||
1439 | input_unregister_device(input_dev); | ||
1440 | input_dev = NULL; | ||
1441 | out_do_exit: | ||
1442 | if (type->exit) | ||
1443 | type->exit(usbtouch); | ||
1444 | out_free_urb: | ||
1445 | usb_free_urb(usbtouch->irq); | ||
1071 | out_free_buffers: | 1446 | out_free_buffers: |
1072 | usbtouch_free_buffers(udev, usbtouch); | 1447 | usbtouch_free_buffers(udev, usbtouch); |
1073 | out_free: | 1448 | out_free: |
@@ -1087,9 +1462,11 @@ static void usbtouch_disconnect(struct usb_interface *intf) | |||
1087 | 1462 | ||
1088 | dbg("%s - usbtouch is initialized, cleaning up", __func__); | 1463 | dbg("%s - usbtouch is initialized, cleaning up", __func__); |
1089 | usb_set_intfdata(intf, NULL); | 1464 | usb_set_intfdata(intf, NULL); |
1090 | usb_kill_urb(usbtouch->irq); | 1465 | /* this will stop IO via close */ |
1091 | input_unregister_device(usbtouch->input); | 1466 | input_unregister_device(usbtouch->input); |
1092 | usb_free_urb(usbtouch->irq); | 1467 | usb_free_urb(usbtouch->irq); |
1468 | if (usbtouch->type->exit) | ||
1469 | usbtouch->type->exit(usbtouch); | ||
1093 | usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch); | 1470 | usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch); |
1094 | kfree(usbtouch); | 1471 | kfree(usbtouch); |
1095 | } | 1472 | } |
diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c index 6ccbdbbf33fe..cc18265be1a8 100644 --- a/drivers/input/touchscreen/w90p910_ts.c +++ b/drivers/input/touchscreen/w90p910_ts.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
17 | #include <linux/input.h> | 17 | #include <linux/input.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/slab.h> | ||
19 | 20 | ||
20 | /* ADC controller bit defines */ | 21 | /* ADC controller bit defines */ |
21 | #define ADC_DELAY 0xf00 | 22 | #define ADC_DELAY 0xf00 |
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index f944918466e5..5109bf3dd858 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/wm97xx.h> | 48 | #include <linux/wm97xx.h> |
49 | #include <linux/uaccess.h> | 49 | #include <linux/uaccess.h> |
50 | #include <linux/io.h> | 50 | #include <linux/io.h> |
51 | #include <linux/slab.h> | ||
51 | 52 | ||
52 | #define TS_NAME "wm97xx" | 53 | #define TS_NAME "wm97xx" |
53 | #define WM_CORE_VERSION "1.00" | 54 | #define WM_CORE_VERSION "1.00" |
diff --git a/drivers/input/touchscreen/zylonite-wm97xx.c b/drivers/input/touchscreen/zylonite-wm97xx.c index 41e4359c277c..048849867643 100644 --- a/drivers/input/touchscreen/zylonite-wm97xx.c +++ b/drivers/input/touchscreen/zylonite-wm97xx.c | |||
@@ -96,7 +96,7 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm) | |||
96 | /* When the AC97 queue has been drained we need to allow time | 96 | /* When the AC97 queue has been drained we need to allow time |
97 | * to buffer up samples otherwise we end up spinning polling | 97 | * to buffer up samples otherwise we end up spinning polling |
98 | * for samples. The controller can't have a suitably low | 98 | * for samples. The controller can't have a suitably low |
99 | * threashold set to use the notifications it gives. | 99 | * threshold set to use the notifications it gives. |
100 | */ | 100 | */ |
101 | msleep(1); | 101 | msleep(1); |
102 | 102 | ||
@@ -118,6 +118,9 @@ static int wm97xx_acc_pen_down(struct wm97xx *wm) | |||
118 | if (pressure) | 118 | if (pressure) |
119 | p = MODR; | 119 | p = MODR; |
120 | 120 | ||
121 | dev_dbg(wm->dev, "Raw coordinates: x=%x, y=%x, p=%x\n", | ||
122 | x, y, p); | ||
123 | |||
121 | /* are samples valid */ | 124 | /* are samples valid */ |
122 | if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || | 125 | if ((x & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_X || |
123 | (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || | 126 | (y & WM97XX_ADCSRC_MASK) != WM97XX_ADCSEL_Y || |