diff options
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 28 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 2 | ||||
-rw-r--r-- | drivers/input/touchscreen/corgi_ts.c | 385 | ||||
-rw-r--r-- | drivers/input/touchscreen/hampshire.c | 205 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc2007.c | 2 |
5 files changed, 220 insertions, 402 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 8a8fa4d2d6a8..cc471983ac0e 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -99,22 +99,6 @@ config TOUCHSCREEN_BITSY | |||
99 | To compile this driver as a module, choose M here: the | 99 | To compile this driver as a module, choose M here: the |
100 | module will be called h3600_ts_input. | 100 | module will be called h3600_ts_input. |
101 | 101 | ||
102 | config TOUCHSCREEN_CORGI | ||
103 | tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)" | ||
104 | depends on PXA_SHARPSL | ||
105 | select CORGI_SSP_DEPRECATED | ||
106 | help | ||
107 | Say Y here to enable the driver for the touchscreen on the | ||
108 | Sharp SL-C7xx and SL-Cxx00 series of PDAs. | ||
109 | |||
110 | If unsure, say N. | ||
111 | |||
112 | To compile this driver as a module, choose M here: the | ||
113 | module will be called corgi_ts. | ||
114 | |||
115 | NOTE: this driver is deprecated, try enable SPI and generic | ||
116 | ADS7846-based touchscreen driver. | ||
117 | |||
118 | config TOUCHSCREEN_DA9034 | 102 | config TOUCHSCREEN_DA9034 |
119 | tristate "Touchscreen support for Dialog Semiconductor DA9034" | 103 | tristate "Touchscreen support for Dialog Semiconductor DA9034" |
120 | depends on PMIC_DA903X | 104 | depends on PMIC_DA903X |
@@ -135,6 +119,18 @@ config TOUCHSCREEN_DYNAPRO | |||
135 | To compile this driver as a module, choose M here: the | 119 | To compile this driver as a module, choose M here: the |
136 | module will be called dynapro. | 120 | module will be called dynapro. |
137 | 121 | ||
122 | config TOUCHSCREEN_HAMPSHIRE | ||
123 | tristate "Hampshire serial touchscreen" | ||
124 | select SERIO | ||
125 | help | ||
126 | Say Y here if you have a Hampshire serial touchscreen connected to | ||
127 | your system. | ||
128 | |||
129 | If unsure, say N. | ||
130 | |||
131 | To compile this driver as a module, choose M here: the | ||
132 | module will be called hampshire. | ||
133 | |||
138 | config TOUCHSCREEN_EETI | 134 | config TOUCHSCREEN_EETI |
139 | tristate "EETI touchscreen panel support" | 135 | tristate "EETI touchscreen panel support" |
140 | depends on I2C | 136 | depends on I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 7fef7d5cca23..8ad36eef90a2 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -12,8 +12,8 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o | |||
12 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o | 12 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o |
13 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o | 13 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o |
14 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o | 14 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o |
15 | obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o | ||
16 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o | 15 | obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o |
16 | obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o | ||
17 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o | 17 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o |
18 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o | 18 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o |
19 | obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o | 19 | obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o |
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c deleted file mode 100644 index 94a1919d439d..000000000000 --- a/drivers/input/touchscreen/corgi_ts.c +++ /dev/null | |||
@@ -1,385 +0,0 @@ | |||
1 | /* | ||
2 | * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models | ||
3 | * | ||
4 | * Copyright (c) 2004-2005 Richard Purdie | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | |||
13 | #include <linux/delay.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/input.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/irq.h> | ||
21 | |||
22 | #include <mach/sharpsl.h> | ||
23 | #include <mach/hardware.h> | ||
24 | #include <mach/pxa2xx-gpio.h> | ||
25 | |||
26 | |||
27 | #define PWR_MODE_ACTIVE 0 | ||
28 | #define PWR_MODE_SUSPEND 1 | ||
29 | |||
30 | #define X_AXIS_MAX 3830 | ||
31 | #define X_AXIS_MIN 150 | ||
32 | #define Y_AXIS_MAX 3830 | ||
33 | #define Y_AXIS_MIN 190 | ||
34 | #define PRESSURE_MIN 0 | ||
35 | #define PRESSURE_MAX 15000 | ||
36 | |||
37 | struct ts_event { | ||
38 | short pressure; | ||
39 | short x; | ||
40 | short y; | ||
41 | }; | ||
42 | |||
43 | struct corgi_ts { | ||
44 | struct input_dev *input; | ||
45 | struct timer_list timer; | ||
46 | struct ts_event tc; | ||
47 | int pendown; | ||
48 | int power_mode; | ||
49 | int irq_gpio; | ||
50 | struct corgits_machinfo *machinfo; | ||
51 | }; | ||
52 | |||
53 | #ifdef CONFIG_PXA25x | ||
54 | #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) | ||
55 | #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) | ||
56 | #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) | ||
57 | #endif | ||
58 | #ifdef CONFIG_PXA27x | ||
59 | #define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a)) | ||
60 | #define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x)) | ||
61 | #define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x)) | ||
62 | #endif | ||
63 | |||
64 | /* ADS7846 Touch Screen Controller bit definitions */ | ||
65 | #define ADSCTRL_PD0 (1u << 0) /* PD0 */ | ||
66 | #define ADSCTRL_PD1 (1u << 1) /* PD1 */ | ||
67 | #define ADSCTRL_DFR (1u << 2) /* SER/DFR */ | ||
68 | #define ADSCTRL_MOD (1u << 3) /* Mode */ | ||
69 | #define ADSCTRL_ADR_SH 4 /* Address setting */ | ||
70 | #define ADSCTRL_STS (1u << 7) /* Start Bit */ | ||
71 | |||
72 | /* External Functions */ | ||
73 | extern unsigned int get_clk_frequency_khz(int info); | ||
74 | |||
75 | static unsigned long calc_waittime(struct corgi_ts *corgi_ts) | ||
76 | { | ||
77 | unsigned long hsync_invperiod = corgi_ts->machinfo->get_hsync_invperiod(); | ||
78 | |||
79 | if (hsync_invperiod) | ||
80 | return get_clk_frequency_khz(0)*1000/hsync_invperiod; | ||
81 | else | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend, | ||
86 | unsigned int address, unsigned long wait_time) | ||
87 | { | ||
88 | unsigned long timer1 = 0, timer2, pmnc = 0; | ||
89 | int pos = 0; | ||
90 | |||
91 | if (wait_time && doSend) { | ||
92 | PMNC_GET(pmnc); | ||
93 | if (!(pmnc & 0x01)) | ||
94 | PMNC_SET(0x01); | ||
95 | |||
96 | /* polling HSync */ | ||
97 | corgi_ts->machinfo->wait_hsync(); | ||
98 | /* get CCNT */ | ||
99 | CCNT(timer1); | ||
100 | } | ||
101 | |||
102 | if (doRecive) | ||
103 | pos = corgi_ssp_ads7846_get(); | ||
104 | |||
105 | if (doSend) { | ||
106 | int cmd = ADSCTRL_PD0 | ADSCTRL_PD1 | (address << ADSCTRL_ADR_SH) | ADSCTRL_STS; | ||
107 | /* dummy command */ | ||
108 | corgi_ssp_ads7846_put(cmd); | ||
109 | corgi_ssp_ads7846_get(); | ||
110 | |||
111 | if (wait_time) { | ||
112 | /* Wait after HSync */ | ||
113 | CCNT(timer2); | ||
114 | if (timer2-timer1 > wait_time) { | ||
115 | /* too slow - timeout, try again */ | ||
116 | corgi_ts->machinfo->wait_hsync(); | ||
117 | /* get CCNT */ | ||
118 | CCNT(timer1); | ||
119 | /* Wait after HSync */ | ||
120 | CCNT(timer2); | ||
121 | } | ||
122 | while (timer2 - timer1 < wait_time) | ||
123 | CCNT(timer2); | ||
124 | } | ||
125 | corgi_ssp_ads7846_put(cmd); | ||
126 | if (wait_time && !(pmnc & 0x01)) | ||
127 | PMNC_SET(pmnc); | ||
128 | } | ||
129 | return pos; | ||
130 | } | ||
131 | |||
132 | static int read_xydata(struct corgi_ts *corgi_ts) | ||
133 | { | ||
134 | unsigned int x, y, z1, z2; | ||
135 | unsigned long flags, wait_time; | ||
136 | |||
137 | /* critical section */ | ||
138 | local_irq_save(flags); | ||
139 | corgi_ssp_ads7846_lock(); | ||
140 | wait_time = calc_waittime(corgi_ts); | ||
141 | |||
142 | /* Y-axis */ | ||
143 | sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time); | ||
144 | |||
145 | /* Y-axis */ | ||
146 | sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time); | ||
147 | |||
148 | /* X-axis */ | ||
149 | y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time); | ||
150 | |||
151 | /* Z1 */ | ||
152 | x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time); | ||
153 | |||
154 | /* Z2 */ | ||
155 | z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time); | ||
156 | z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time); | ||
157 | |||
158 | /* Power-Down Enable */ | ||
159 | corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
160 | corgi_ssp_ads7846_get(); | ||
161 | |||
162 | corgi_ssp_ads7846_unlock(); | ||
163 | local_irq_restore(flags); | ||
164 | |||
165 | if (x== 0 || y == 0 || z1 == 0 || (x * (z2 - z1) / z1) >= 15000) { | ||
166 | corgi_ts->tc.pressure = 0; | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | corgi_ts->tc.x = x; | ||
171 | corgi_ts->tc.y = y; | ||
172 | corgi_ts->tc.pressure = (x * (z2 - z1)) / z1; | ||
173 | return 1; | ||
174 | } | ||
175 | |||
176 | static void new_data(struct corgi_ts *corgi_ts) | ||
177 | { | ||
178 | struct input_dev *dev = corgi_ts->input; | ||
179 | |||
180 | if (corgi_ts->power_mode != PWR_MODE_ACTIVE) | ||
181 | return; | ||
182 | |||
183 | if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) | ||
184 | return; | ||
185 | |||
186 | input_report_abs(dev, ABS_X, corgi_ts->tc.x); | ||
187 | input_report_abs(dev, ABS_Y, corgi_ts->tc.y); | ||
188 | input_report_abs(dev, ABS_PRESSURE, corgi_ts->tc.pressure); | ||
189 | input_report_key(dev, BTN_TOUCH, corgi_ts->pendown); | ||
190 | input_sync(dev); | ||
191 | } | ||
192 | |||
193 | static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer) | ||
194 | { | ||
195 | if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) { | ||
196 | /* Disable Interrupt */ | ||
197 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_NONE); | ||
198 | if (read_xydata(corgi_ts)) { | ||
199 | corgi_ts->pendown = 1; | ||
200 | new_data(corgi_ts); | ||
201 | } | ||
202 | mod_timer(&corgi_ts->timer, jiffies + HZ / 100); | ||
203 | } else { | ||
204 | if (corgi_ts->pendown == 1 || corgi_ts->pendown == 2) { | ||
205 | mod_timer(&corgi_ts->timer, jiffies + HZ / 100); | ||
206 | corgi_ts->pendown++; | ||
207 | return; | ||
208 | } | ||
209 | |||
210 | if (corgi_ts->pendown) { | ||
211 | corgi_ts->tc.pressure = 0; | ||
212 | new_data(corgi_ts); | ||
213 | } | ||
214 | |||
215 | /* Enable Falling Edge */ | ||
216 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING); | ||
217 | corgi_ts->pendown = 0; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | static void corgi_ts_timer(unsigned long data) | ||
222 | { | ||
223 | struct corgi_ts *corgits_data = (struct corgi_ts *) data; | ||
224 | |||
225 | ts_interrupt_main(corgits_data, 1); | ||
226 | } | ||
227 | |||
228 | static irqreturn_t ts_interrupt(int irq, void *dev_id) | ||
229 | { | ||
230 | struct corgi_ts *corgits_data = dev_id; | ||
231 | |||
232 | ts_interrupt_main(corgits_data, 0); | ||
233 | return IRQ_HANDLED; | ||
234 | } | ||
235 | |||
236 | #ifdef CONFIG_PM | ||
237 | static int corgits_suspend(struct platform_device *dev, pm_message_t state) | ||
238 | { | ||
239 | struct corgi_ts *corgi_ts = platform_get_drvdata(dev); | ||
240 | |||
241 | if (corgi_ts->pendown) { | ||
242 | del_timer_sync(&corgi_ts->timer); | ||
243 | corgi_ts->tc.pressure = 0; | ||
244 | new_data(corgi_ts); | ||
245 | corgi_ts->pendown = 0; | ||
246 | } | ||
247 | corgi_ts->power_mode = PWR_MODE_SUSPEND; | ||
248 | |||
249 | corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static int corgits_resume(struct platform_device *dev) | ||
255 | { | ||
256 | struct corgi_ts *corgi_ts = platform_get_drvdata(dev); | ||
257 | |||
258 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
259 | /* Enable Falling Edge */ | ||
260 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING); | ||
261 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
262 | |||
263 | return 0; | ||
264 | } | ||
265 | #else | ||
266 | #define corgits_suspend NULL | ||
267 | #define corgits_resume NULL | ||
268 | #endif | ||
269 | |||
270 | static int __devinit corgits_probe(struct platform_device *pdev) | ||
271 | { | ||
272 | struct corgi_ts *corgi_ts; | ||
273 | struct input_dev *input_dev; | ||
274 | int err = -ENOMEM; | ||
275 | |||
276 | corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL); | ||
277 | input_dev = input_allocate_device(); | ||
278 | if (!corgi_ts || !input_dev) | ||
279 | goto fail1; | ||
280 | |||
281 | platform_set_drvdata(pdev, corgi_ts); | ||
282 | |||
283 | corgi_ts->machinfo = pdev->dev.platform_data; | ||
284 | corgi_ts->irq_gpio = platform_get_irq(pdev, 0); | ||
285 | |||
286 | if (corgi_ts->irq_gpio < 0) { | ||
287 | err = -ENODEV; | ||
288 | goto fail1; | ||
289 | } | ||
290 | |||
291 | corgi_ts->input = input_dev; | ||
292 | |||
293 | init_timer(&corgi_ts->timer); | ||
294 | corgi_ts->timer.data = (unsigned long) corgi_ts; | ||
295 | corgi_ts->timer.function = corgi_ts_timer; | ||
296 | |||
297 | input_dev->name = "Corgi Touchscreen"; | ||
298 | input_dev->phys = "corgits/input0"; | ||
299 | input_dev->id.bustype = BUS_HOST; | ||
300 | input_dev->id.vendor = 0x0001; | ||
301 | input_dev->id.product = 0x0002; | ||
302 | input_dev->id.version = 0x0100; | ||
303 | input_dev->dev.parent = &pdev->dev; | ||
304 | |||
305 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
306 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
307 | input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); | ||
308 | input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); | ||
309 | input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); | ||
310 | |||
311 | pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN); | ||
312 | |||
313 | /* Initiaize ADS7846 Difference Reference mode */ | ||
314 | corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
315 | mdelay(5); | ||
316 | corgi_ssp_ads7846_putget((3u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
317 | mdelay(5); | ||
318 | corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
319 | mdelay(5); | ||
320 | corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS); | ||
321 | mdelay(5); | ||
322 | |||
323 | if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) { | ||
324 | err = -EBUSY; | ||
325 | goto fail1; | ||
326 | } | ||
327 | |||
328 | err = input_register_device(corgi_ts->input); | ||
329 | if (err) | ||
330 | goto fail2; | ||
331 | |||
332 | corgi_ts->power_mode = PWR_MODE_ACTIVE; | ||
333 | |||
334 | /* Enable Falling Edge */ | ||
335 | set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING); | ||
336 | |||
337 | return 0; | ||
338 | |||
339 | fail2: free_irq(corgi_ts->irq_gpio, corgi_ts); | ||
340 | fail1: input_free_device(input_dev); | ||
341 | kfree(corgi_ts); | ||
342 | return err; | ||
343 | } | ||
344 | |||
345 | static int __devexit corgits_remove(struct platform_device *pdev) | ||
346 | { | ||
347 | struct corgi_ts *corgi_ts = platform_get_drvdata(pdev); | ||
348 | |||
349 | free_irq(corgi_ts->irq_gpio, corgi_ts); | ||
350 | del_timer_sync(&corgi_ts->timer); | ||
351 | corgi_ts->machinfo->put_hsync(); | ||
352 | input_unregister_device(corgi_ts->input); | ||
353 | kfree(corgi_ts); | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static struct platform_driver corgits_driver = { | ||
359 | .probe = corgits_probe, | ||
360 | .remove = __devexit_p(corgits_remove), | ||
361 | .suspend = corgits_suspend, | ||
362 | .resume = corgits_resume, | ||
363 | .driver = { | ||
364 | .name = "corgi-ts", | ||
365 | .owner = THIS_MODULE, | ||
366 | }, | ||
367 | }; | ||
368 | |||
369 | static int __init corgits_init(void) | ||
370 | { | ||
371 | return platform_driver_register(&corgits_driver); | ||
372 | } | ||
373 | |||
374 | static void __exit corgits_exit(void) | ||
375 | { | ||
376 | platform_driver_unregister(&corgits_driver); | ||
377 | } | ||
378 | |||
379 | module_init(corgits_init); | ||
380 | module_exit(corgits_exit); | ||
381 | |||
382 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
383 | MODULE_DESCRIPTION("Corgi TouchScreen Driver"); | ||
384 | MODULE_LICENSE("GPL"); | ||
385 | MODULE_ALIAS("platform:corgi-ts"); | ||
diff --git a/drivers/input/touchscreen/hampshire.c b/drivers/input/touchscreen/hampshire.c new file mode 100644 index 000000000000..2da6cc31bb21 --- /dev/null +++ b/drivers/input/touchscreen/hampshire.c | |||
@@ -0,0 +1,205 @@ | |||
1 | /* | ||
2 | * Hampshire serial touchscreen driver | ||
3 | * | ||
4 | * Copyright (c) 2010 Adam Bennett | ||
5 | * Based on the dynapro driver (c) Tias Guns | ||
6 | * | ||
7 | */ | ||
8 | |||
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 | |||
15 | /* | ||
16 | * 2010/04/08 Adam Bennett <abennett72@gmail.com> | ||
17 | * Copied dynapro.c and edited for Hampshire 4-byte protocol | ||
18 | */ | ||
19 | |||
20 | #include <linux/errno.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/input.h> | ||
25 | #include <linux/serio.h> | ||
26 | #include <linux/init.h> | ||
27 | |||
28 | #define DRIVER_DESC "Hampshire serial touchscreen driver" | ||
29 | |||
30 | MODULE_AUTHOR("Adam Bennett <abennett72@gmail.com>"); | ||
31 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
32 | MODULE_LICENSE("GPL"); | ||
33 | |||
34 | /* | ||
35 | * Definitions & global arrays. | ||
36 | */ | ||
37 | |||
38 | #define HAMPSHIRE_FORMAT_TOUCH_BIT 0x40 | ||
39 | #define HAMPSHIRE_FORMAT_LENGTH 4 | ||
40 | #define HAMPSHIRE_RESPONSE_BEGIN_BYTE 0x80 | ||
41 | |||
42 | #define HAMPSHIRE_MIN_XC 0 | ||
43 | #define HAMPSHIRE_MAX_XC 0x1000 | ||
44 | #define HAMPSHIRE_MIN_YC 0 | ||
45 | #define HAMPSHIRE_MAX_YC 0x1000 | ||
46 | |||
47 | #define HAMPSHIRE_GET_XC(data) (((data[3] & 0x0c) >> 2) | (data[1] << 2) | ((data[0] & 0x38) << 6)) | ||
48 | #define HAMPSHIRE_GET_YC(data) ((data[3] & 0x03) | (data[2] << 2) | ((data[0] & 0x07) << 9)) | ||
49 | #define HAMPSHIRE_GET_TOUCHED(data) (HAMPSHIRE_FORMAT_TOUCH_BIT & data[0]) | ||
50 | |||
51 | /* | ||
52 | * Per-touchscreen data. | ||
53 | */ | ||
54 | |||
55 | struct hampshire { | ||
56 | struct input_dev *dev; | ||
57 | struct serio *serio; | ||
58 | int idx; | ||
59 | unsigned char data[HAMPSHIRE_FORMAT_LENGTH]; | ||
60 | char phys[32]; | ||
61 | }; | ||
62 | |||
63 | static void hampshire_process_data(struct hampshire *phampshire) | ||
64 | { | ||
65 | struct input_dev *dev = phampshire->dev; | ||
66 | |||
67 | if (HAMPSHIRE_FORMAT_LENGTH == ++phampshire->idx) { | ||
68 | input_report_abs(dev, ABS_X, HAMPSHIRE_GET_XC(phampshire->data)); | ||
69 | input_report_abs(dev, ABS_Y, HAMPSHIRE_GET_YC(phampshire->data)); | ||
70 | input_report_key(dev, BTN_TOUCH, | ||
71 | HAMPSHIRE_GET_TOUCHED(phampshire->data)); | ||
72 | input_sync(dev); | ||
73 | |||
74 | phampshire->idx = 0; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | static irqreturn_t hampshire_interrupt(struct serio *serio, | ||
79 | unsigned char data, unsigned int flags) | ||
80 | { | ||
81 | struct hampshire *phampshire = serio_get_drvdata(serio); | ||
82 | |||
83 | phampshire->data[phampshire->idx] = data; | ||
84 | |||
85 | if (HAMPSHIRE_RESPONSE_BEGIN_BYTE & phampshire->data[0]) | ||
86 | hampshire_process_data(phampshire); | ||
87 | else | ||
88 | dev_dbg(&serio->dev, "unknown/unsynchronized data: %x\n", | ||
89 | phampshire->data[0]); | ||
90 | |||
91 | return IRQ_HANDLED; | ||
92 | } | ||
93 | |||
94 | static void hampshire_disconnect(struct serio *serio) | ||
95 | { | ||
96 | struct hampshire *phampshire = serio_get_drvdata(serio); | ||
97 | |||
98 | input_get_device(phampshire->dev); | ||
99 | input_unregister_device(phampshire->dev); | ||
100 | serio_close(serio); | ||
101 | serio_set_drvdata(serio, NULL); | ||
102 | input_put_device(phampshire->dev); | ||
103 | kfree(phampshire); | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * hampshire_connect() is the routine that is called when someone adds a | ||
108 | * new serio device that supports hampshire protocol and registers it as | ||
109 | * an input device. This is usually accomplished using inputattach. | ||
110 | */ | ||
111 | |||
112 | static int hampshire_connect(struct serio *serio, struct serio_driver *drv) | ||
113 | { | ||
114 | struct hampshire *phampshire; | ||
115 | struct input_dev *input_dev; | ||
116 | int err; | ||
117 | |||
118 | phampshire = kzalloc(sizeof(struct hampshire), GFP_KERNEL); | ||
119 | input_dev = input_allocate_device(); | ||
120 | if (!phampshire || !input_dev) { | ||
121 | err = -ENOMEM; | ||
122 | goto fail1; | ||
123 | } | ||
124 | |||
125 | phampshire->serio = serio; | ||
126 | phampshire->dev = input_dev; | ||
127 | snprintf(phampshire->phys, sizeof(phampshire->phys), | ||
128 | "%s/input0", serio->phys); | ||
129 | |||
130 | input_dev->name = "Hampshire Serial TouchScreen"; | ||
131 | input_dev->phys = phampshire->phys; | ||
132 | input_dev->id.bustype = BUS_RS232; | ||
133 | input_dev->id.vendor = SERIO_HAMPSHIRE; | ||
134 | input_dev->id.product = 0; | ||
135 | input_dev->id.version = 0x0001; | ||
136 | input_dev->dev.parent = &serio->dev; | ||
137 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
138 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
139 | input_set_abs_params(phampshire->dev, ABS_X, | ||
140 | HAMPSHIRE_MIN_XC, HAMPSHIRE_MAX_XC, 0, 0); | ||
141 | input_set_abs_params(phampshire->dev, ABS_Y, | ||
142 | HAMPSHIRE_MIN_YC, HAMPSHIRE_MAX_YC, 0, 0); | ||
143 | |||
144 | serio_set_drvdata(serio, phampshire); | ||
145 | |||
146 | err = serio_open(serio, drv); | ||
147 | if (err) | ||
148 | goto fail2; | ||
149 | |||
150 | err = input_register_device(phampshire->dev); | ||
151 | if (err) | ||
152 | goto fail3; | ||
153 | |||
154 | return 0; | ||
155 | |||
156 | fail3: serio_close(serio); | ||
157 | fail2: serio_set_drvdata(serio, NULL); | ||
158 | fail1: input_free_device(input_dev); | ||
159 | kfree(phampshire); | ||
160 | return err; | ||
161 | } | ||
162 | |||
163 | /* | ||
164 | * The serio driver structure. | ||
165 | */ | ||
166 | |||
167 | static struct serio_device_id hampshire_serio_ids[] = { | ||
168 | { | ||
169 | .type = SERIO_RS232, | ||
170 | .proto = SERIO_HAMPSHIRE, | ||
171 | .id = SERIO_ANY, | ||
172 | .extra = SERIO_ANY, | ||
173 | }, | ||
174 | { 0 } | ||
175 | }; | ||
176 | |||
177 | MODULE_DEVICE_TABLE(serio, hampshire_serio_ids); | ||
178 | |||
179 | static struct serio_driver hampshire_drv = { | ||
180 | .driver = { | ||
181 | .name = "hampshire", | ||
182 | }, | ||
183 | .description = DRIVER_DESC, | ||
184 | .id_table = hampshire_serio_ids, | ||
185 | .interrupt = hampshire_interrupt, | ||
186 | .connect = hampshire_connect, | ||
187 | .disconnect = hampshire_disconnect, | ||
188 | }; | ||
189 | |||
190 | /* | ||
191 | * The functions for inserting/removing us as a module. | ||
192 | */ | ||
193 | |||
194 | static int __init hampshire_init(void) | ||
195 | { | ||
196 | return serio_register_driver(&hampshire_drv); | ||
197 | } | ||
198 | |||
199 | static void __exit hampshire_exit(void) | ||
200 | { | ||
201 | serio_unregister_driver(&hampshire_drv); | ||
202 | } | ||
203 | |||
204 | module_init(hampshire_init); | ||
205 | module_exit(hampshire_exit); | ||
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c index be23780e8a3e..769b479fcaa6 100644 --- a/drivers/input/touchscreen/tsc2007.c +++ b/drivers/input/touchscreen/tsc2007.c | |||
@@ -347,6 +347,8 @@ static int __devexit tsc2007_remove(struct i2c_client *client) | |||
347 | struct tsc2007 *ts = i2c_get_clientdata(client); | 347 | struct tsc2007 *ts = i2c_get_clientdata(client); |
348 | struct tsc2007_platform_data *pdata = client->dev.platform_data; | 348 | struct tsc2007_platform_data *pdata = client->dev.platform_data; |
349 | 349 | ||
350 | i2c_set_clientdata(client, NULL); | ||
351 | |||
350 | tsc2007_free_irq(ts); | 352 | tsc2007_free_irq(ts); |
351 | 353 | ||
352 | if (pdata->exit_platform_hw) | 354 | if (pdata->exit_platform_hw) |