diff options
author | Arnd Bergmann <arnd@arndb.de> | 2014-03-28 03:52:36 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-03-28 04:10:11 -0400 |
commit | e545ef39e06e7b1df2ef9ddbbf665b74c4e1878a (patch) | |
tree | 44a245210306f0cd664bc2c3c1a03e479163d864 | |
parent | 9732e5b0bf87a1b0457be1c5d38262babc4cd2ae (diff) |
Input: remove obsolete tnetv107x drivers
The tnetv107x platform is getting removed, so the touchscreen
and keypad drivers for this platform will no longer be needed
either.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Sekhar Nori <nsekhar@ti.com>
Acked-by: Kevin Hilman <khilman@linaro.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/keyboard/Kconfig | 10 | ||||
-rw-r--r-- | drivers/input/keyboard/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/keyboard/tnetv107x-keypad.c | 329 | ||||
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 9 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/tnetv107x-ts.c | 384 |
6 files changed, 0 insertions, 734 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index a673c9f3a0b9..935dcaf16646 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -595,16 +595,6 @@ config KEYBOARD_TC3589X | |||
595 | To compile this driver as a module, choose M here: the | 595 | To compile this driver as a module, choose M here: the |
596 | module will be called tc3589x-keypad. | 596 | module will be called tc3589x-keypad. |
597 | 597 | ||
598 | config KEYBOARD_TNETV107X | ||
599 | tristate "TI TNETV107X keypad support" | ||
600 | depends on ARCH_DAVINCI_TNETV107X | ||
601 | select INPUT_MATRIXKMAP | ||
602 | help | ||
603 | Say Y here if you want to use the TNETV107X keypad. | ||
604 | |||
605 | To compile this driver as a module, choose M here: the | ||
606 | module will be called tnetv107x-keypad. | ||
607 | |||
608 | config KEYBOARD_TWL4030 | 598 | config KEYBOARD_TWL4030 |
609 | tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" | 599 | tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" |
610 | depends on TWL4030_CORE | 600 | depends on TWL4030_CORE |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index a699b6172303..81014d94a0c1 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -53,7 +53,6 @@ obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o | |||
53 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o | 53 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o |
54 | obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o | 54 | obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o |
55 | obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o | 55 | obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o |
56 | obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o | ||
57 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o | 56 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o |
58 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | 57 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o |
59 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o | 58 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o |
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c deleted file mode 100644 index 086511c2121b..000000000000 --- a/drivers/input/keyboard/tnetv107x-keypad.c +++ /dev/null | |||
@@ -1,329 +0,0 @@ | |||
1 | /* | ||
2 | * Texas Instruments TNETV107X Keypad Driver | ||
3 | * | ||
4 | * Copyright (C) 2010 Texas Instruments | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation version 2. | ||
9 | * | ||
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
11 | * kind, whether express or implied; without even the implied warranty | ||
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <linux/clk.h> | ||
26 | #include <linux/input/matrix_keypad.h> | ||
27 | #include <linux/module.h> | ||
28 | |||
29 | #define BITS(x) (BIT(x) - 1) | ||
30 | |||
31 | #define KEYPAD_ROWS 9 | ||
32 | #define KEYPAD_COLS 9 | ||
33 | |||
34 | #define DEBOUNCE_MIN 0x400ul | ||
35 | #define DEBOUNCE_MAX 0x3ffffffful | ||
36 | |||
37 | struct keypad_regs { | ||
38 | u32 rev; | ||
39 | u32 mode; | ||
40 | u32 mask; | ||
41 | u32 pol; | ||
42 | u32 dclock; | ||
43 | u32 rclock; | ||
44 | u32 stable_cnt; | ||
45 | u32 in_en; | ||
46 | u32 out; | ||
47 | u32 out_en; | ||
48 | u32 in; | ||
49 | u32 lock; | ||
50 | u32 pres[3]; | ||
51 | }; | ||
52 | |||
53 | #define keypad_read(kp, reg) __raw_readl(&(kp)->regs->reg) | ||
54 | #define keypad_write(kp, reg, val) __raw_writel(val, &(kp)->regs->reg) | ||
55 | |||
56 | struct keypad_data { | ||
57 | struct input_dev *input_dev; | ||
58 | struct resource *res; | ||
59 | struct keypad_regs __iomem *regs; | ||
60 | struct clk *clk; | ||
61 | struct device *dev; | ||
62 | spinlock_t lock; | ||
63 | int irq_press; | ||
64 | int irq_release; | ||
65 | int rows, cols, row_shift; | ||
66 | int debounce_ms, active_low; | ||
67 | u32 prev_keys[3]; | ||
68 | unsigned short keycodes[]; | ||
69 | }; | ||
70 | |||
71 | static irqreturn_t keypad_irq(int irq, void *data) | ||
72 | { | ||
73 | struct keypad_data *kp = data; | ||
74 | int i, bit, val, row, col, code; | ||
75 | unsigned long flags; | ||
76 | u32 curr_keys[3]; | ||
77 | u32 change; | ||
78 | |||
79 | spin_lock_irqsave(&kp->lock, flags); | ||
80 | |||
81 | memset(curr_keys, 0, sizeof(curr_keys)); | ||
82 | if (irq == kp->irq_press) | ||
83 | for (i = 0; i < 3; i++) | ||
84 | curr_keys[i] = keypad_read(kp, pres[i]); | ||
85 | |||
86 | for (i = 0; i < 3; i++) { | ||
87 | change = curr_keys[i] ^ kp->prev_keys[i]; | ||
88 | |||
89 | while (change) { | ||
90 | bit = fls(change) - 1; | ||
91 | change ^= BIT(bit); | ||
92 | val = curr_keys[i] & BIT(bit); | ||
93 | bit += i * 32; | ||
94 | row = bit / KEYPAD_COLS; | ||
95 | col = bit % KEYPAD_COLS; | ||
96 | |||
97 | code = MATRIX_SCAN_CODE(row, col, kp->row_shift); | ||
98 | input_event(kp->input_dev, EV_MSC, MSC_SCAN, code); | ||
99 | input_report_key(kp->input_dev, kp->keycodes[code], | ||
100 | val); | ||
101 | } | ||
102 | } | ||
103 | input_sync(kp->input_dev); | ||
104 | memcpy(kp->prev_keys, curr_keys, sizeof(curr_keys)); | ||
105 | |||
106 | if (irq == kp->irq_press) | ||
107 | keypad_write(kp, lock, 0); /* Allow hardware updates */ | ||
108 | |||
109 | spin_unlock_irqrestore(&kp->lock, flags); | ||
110 | |||
111 | return IRQ_HANDLED; | ||
112 | } | ||
113 | |||
114 | static int keypad_start(struct input_dev *dev) | ||
115 | { | ||
116 | struct keypad_data *kp = input_get_drvdata(dev); | ||
117 | unsigned long mask, debounce, clk_rate_khz; | ||
118 | unsigned long flags; | ||
119 | |||
120 | clk_enable(kp->clk); | ||
121 | clk_rate_khz = clk_get_rate(kp->clk) / 1000; | ||
122 | |||
123 | spin_lock_irqsave(&kp->lock, flags); | ||
124 | |||
125 | /* Initialize device registers */ | ||
126 | keypad_write(kp, mode, 0); | ||
127 | |||
128 | mask = BITS(kp->rows) << KEYPAD_COLS; | ||
129 | mask |= BITS(kp->cols); | ||
130 | keypad_write(kp, mask, ~mask); | ||
131 | |||
132 | keypad_write(kp, pol, kp->active_low ? 0 : 0x3ffff); | ||
133 | keypad_write(kp, stable_cnt, 3); | ||
134 | |||
135 | debounce = kp->debounce_ms * clk_rate_khz; | ||
136 | debounce = clamp(debounce, DEBOUNCE_MIN, DEBOUNCE_MAX); | ||
137 | keypad_write(kp, dclock, debounce); | ||
138 | keypad_write(kp, rclock, 4 * debounce); | ||
139 | |||
140 | keypad_write(kp, in_en, 1); | ||
141 | |||
142 | spin_unlock_irqrestore(&kp->lock, flags); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | static void keypad_stop(struct input_dev *dev) | ||
148 | { | ||
149 | struct keypad_data *kp = input_get_drvdata(dev); | ||
150 | |||
151 | synchronize_irq(kp->irq_press); | ||
152 | synchronize_irq(kp->irq_release); | ||
153 | clk_disable(kp->clk); | ||
154 | } | ||
155 | |||
156 | static int keypad_probe(struct platform_device *pdev) | ||
157 | { | ||
158 | const struct matrix_keypad_platform_data *pdata; | ||
159 | const struct matrix_keymap_data *keymap_data; | ||
160 | struct device *dev = &pdev->dev; | ||
161 | struct keypad_data *kp; | ||
162 | int error = 0, sz, row_shift; | ||
163 | u32 rev = 0; | ||
164 | |||
165 | pdata = dev_get_platdata(&pdev->dev); | ||
166 | if (!pdata) { | ||
167 | dev_err(dev, "cannot find device data\n"); | ||
168 | return -EINVAL; | ||
169 | } | ||
170 | |||
171 | keymap_data = pdata->keymap_data; | ||
172 | if (!keymap_data) { | ||
173 | dev_err(dev, "cannot find keymap data\n"); | ||
174 | return -EINVAL; | ||
175 | } | ||
176 | |||
177 | row_shift = get_count_order(pdata->num_col_gpios); | ||
178 | sz = offsetof(struct keypad_data, keycodes); | ||
179 | sz += (pdata->num_row_gpios << row_shift) * sizeof(kp->keycodes[0]); | ||
180 | kp = kzalloc(sz, GFP_KERNEL); | ||
181 | if (!kp) { | ||
182 | dev_err(dev, "cannot allocate device info\n"); | ||
183 | return -ENOMEM; | ||
184 | } | ||
185 | |||
186 | kp->dev = dev; | ||
187 | kp->rows = pdata->num_row_gpios; | ||
188 | kp->cols = pdata->num_col_gpios; | ||
189 | kp->row_shift = row_shift; | ||
190 | platform_set_drvdata(pdev, kp); | ||
191 | spin_lock_init(&kp->lock); | ||
192 | |||
193 | kp->irq_press = platform_get_irq_byname(pdev, "press"); | ||
194 | kp->irq_release = platform_get_irq_byname(pdev, "release"); | ||
195 | if (kp->irq_press < 0 || kp->irq_release < 0) { | ||
196 | dev_err(dev, "cannot determine device interrupts\n"); | ||
197 | error = -ENODEV; | ||
198 | goto error_res; | ||
199 | } | ||
200 | |||
201 | kp->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
202 | if (!kp->res) { | ||
203 | dev_err(dev, "cannot determine register area\n"); | ||
204 | error = -ENODEV; | ||
205 | goto error_res; | ||
206 | } | ||
207 | |||
208 | if (!request_mem_region(kp->res->start, resource_size(kp->res), | ||
209 | pdev->name)) { | ||
210 | dev_err(dev, "cannot claim register memory\n"); | ||
211 | kp->res = NULL; | ||
212 | error = -EINVAL; | ||
213 | goto error_res; | ||
214 | } | ||
215 | |||
216 | kp->regs = ioremap(kp->res->start, resource_size(kp->res)); | ||
217 | if (!kp->regs) { | ||
218 | dev_err(dev, "cannot map register memory\n"); | ||
219 | error = -ENOMEM; | ||
220 | goto error_map; | ||
221 | } | ||
222 | |||
223 | kp->clk = clk_get(dev, NULL); | ||
224 | if (IS_ERR(kp->clk)) { | ||
225 | dev_err(dev, "cannot claim device clock\n"); | ||
226 | error = PTR_ERR(kp->clk); | ||
227 | goto error_clk; | ||
228 | } | ||
229 | |||
230 | error = request_threaded_irq(kp->irq_press, NULL, keypad_irq, | ||
231 | IRQF_ONESHOT, dev_name(dev), kp); | ||
232 | if (error < 0) { | ||
233 | dev_err(kp->dev, "Could not allocate keypad press key irq\n"); | ||
234 | goto error_irq_press; | ||
235 | } | ||
236 | |||
237 | error = request_threaded_irq(kp->irq_release, NULL, keypad_irq, | ||
238 | IRQF_ONESHOT, dev_name(dev), kp); | ||
239 | if (error < 0) { | ||
240 | dev_err(kp->dev, "Could not allocate keypad release key irq\n"); | ||
241 | goto error_irq_release; | ||
242 | } | ||
243 | |||
244 | kp->input_dev = input_allocate_device(); | ||
245 | if (!kp->input_dev) { | ||
246 | dev_err(dev, "cannot allocate input device\n"); | ||
247 | error = -ENOMEM; | ||
248 | goto error_input; | ||
249 | } | ||
250 | |||
251 | kp->input_dev->name = pdev->name; | ||
252 | kp->input_dev->dev.parent = &pdev->dev; | ||
253 | kp->input_dev->open = keypad_start; | ||
254 | kp->input_dev->close = keypad_stop; | ||
255 | |||
256 | clk_enable(kp->clk); | ||
257 | rev = keypad_read(kp, rev); | ||
258 | kp->input_dev->id.bustype = BUS_HOST; | ||
259 | kp->input_dev->id.product = ((rev >> 8) & 0x07); | ||
260 | kp->input_dev->id.version = ((rev >> 16) & 0xfff); | ||
261 | clk_disable(kp->clk); | ||
262 | |||
263 | error = matrix_keypad_build_keymap(keymap_data, NULL, | ||
264 | kp->rows, kp->cols, | ||
265 | kp->keycodes, kp->input_dev); | ||
266 | if (error) { | ||
267 | dev_err(dev, "Failed to build keymap\n"); | ||
268 | goto error_reg; | ||
269 | } | ||
270 | |||
271 | if (!pdata->no_autorepeat) | ||
272 | kp->input_dev->evbit[0] |= BIT_MASK(EV_REP); | ||
273 | input_set_capability(kp->input_dev, EV_MSC, MSC_SCAN); | ||
274 | |||
275 | input_set_drvdata(kp->input_dev, kp); | ||
276 | |||
277 | error = input_register_device(kp->input_dev); | ||
278 | if (error < 0) { | ||
279 | dev_err(dev, "Could not register input device\n"); | ||
280 | goto error_reg; | ||
281 | } | ||
282 | |||
283 | return 0; | ||
284 | |||
285 | |||
286 | error_reg: | ||
287 | input_free_device(kp->input_dev); | ||
288 | error_input: | ||
289 | free_irq(kp->irq_release, kp); | ||
290 | error_irq_release: | ||
291 | free_irq(kp->irq_press, kp); | ||
292 | error_irq_press: | ||
293 | clk_put(kp->clk); | ||
294 | error_clk: | ||
295 | iounmap(kp->regs); | ||
296 | error_map: | ||
297 | release_mem_region(kp->res->start, resource_size(kp->res)); | ||
298 | error_res: | ||
299 | kfree(kp); | ||
300 | return error; | ||
301 | } | ||
302 | |||
303 | static int keypad_remove(struct platform_device *pdev) | ||
304 | { | ||
305 | struct keypad_data *kp = platform_get_drvdata(pdev); | ||
306 | |||
307 | free_irq(kp->irq_press, kp); | ||
308 | free_irq(kp->irq_release, kp); | ||
309 | input_unregister_device(kp->input_dev); | ||
310 | clk_put(kp->clk); | ||
311 | iounmap(kp->regs); | ||
312 | release_mem_region(kp->res->start, resource_size(kp->res)); | ||
313 | kfree(kp); | ||
314 | |||
315 | return 0; | ||
316 | } | ||
317 | |||
318 | static struct platform_driver keypad_driver = { | ||
319 | .probe = keypad_probe, | ||
320 | .remove = keypad_remove, | ||
321 | .driver.name = "tnetv107x-keypad", | ||
322 | .driver.owner = THIS_MODULE, | ||
323 | }; | ||
324 | module_platform_driver(keypad_driver); | ||
325 | |||
326 | MODULE_AUTHOR("Cyril Chemparathy"); | ||
327 | MODULE_DESCRIPTION("TNETV107X Keypad Driver"); | ||
328 | MODULE_ALIAS("platform:tnetv107x-keypad"); | ||
329 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 07e9e82029d1..68edc9db2c64 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -514,15 +514,6 @@ config TOUCHSCREEN_MIGOR | |||
514 | To compile this driver as a module, choose M here: the | 514 | To compile this driver as a module, choose M here: the |
515 | module will be called migor_ts. | 515 | module will be called migor_ts. |
516 | 516 | ||
517 | config TOUCHSCREEN_TNETV107X | ||
518 | tristate "TI TNETV107X touchscreen support" | ||
519 | depends on ARCH_DAVINCI_TNETV107X | ||
520 | help | ||
521 | Say Y here if you want to use the TNETV107X touchscreen. | ||
522 | |||
523 | To compile this driver as a module, choose M here: the | ||
524 | module will be called tnetv107x-ts. | ||
525 | |||
526 | config TOUCHSCREEN_TOUCHRIGHT | 517 | config TOUCHSCREEN_TOUCHRIGHT |
527 | tristate "Touchright serial touchscreen" | 518 | tristate "Touchright serial touchscreen" |
528 | select SERIO | 519 | select SERIO |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 62801f213346..4bc954b7c7c3 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -56,7 +56,6 @@ obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o | |||
56 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o | 56 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o |
57 | obj-$(CONFIG_TOUCHSCREEN_SUR40) += sur40.o | 57 | obj-$(CONFIG_TOUCHSCREEN_SUR40) += sur40.o |
58 | obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o | 58 | obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o |
59 | obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o | ||
60 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o | 59 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o |
61 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o | 60 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o |
62 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o | 61 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o |
diff --git a/drivers/input/touchscreen/tnetv107x-ts.c b/drivers/input/touchscreen/tnetv107x-ts.c deleted file mode 100644 index c47827a26e3c..000000000000 --- a/drivers/input/touchscreen/tnetv107x-ts.c +++ /dev/null | |||
@@ -1,384 +0,0 @@ | |||
1 | /* | ||
2 | * Texas Instruments TNETV107X Touchscreen Driver | ||
3 | * | ||
4 | * Copyright (C) 2010 Texas Instruments | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation version 2. | ||
9 | * | ||
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
11 | * kind, whether express or implied; without even the implied warranty | ||
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/err.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/input.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/ctype.h> | ||
26 | #include <linux/io.h> | ||
27 | #include <linux/clk.h> | ||
28 | |||
29 | #include <mach/tnetv107x.h> | ||
30 | |||
31 | #define TSC_PENUP_POLL (HZ / 5) | ||
32 | #define IDLE_TIMEOUT 100 /* msec */ | ||
33 | |||
34 | /* | ||
35 | * The first and last samples of a touch interval are usually garbage and need | ||
36 | * to be filtered out with these devices. The following definitions control | ||
37 | * the number of samples skipped. | ||
38 | */ | ||
39 | #define TSC_HEAD_SKIP 1 | ||
40 | #define TSC_TAIL_SKIP 1 | ||
41 | #define TSC_SKIP (TSC_HEAD_SKIP + TSC_TAIL_SKIP + 1) | ||
42 | #define TSC_SAMPLES (TSC_SKIP + 1) | ||
43 | |||
44 | /* Register Offsets */ | ||
45 | struct tsc_regs { | ||
46 | u32 rev; | ||
47 | u32 tscm; | ||
48 | u32 bwcm; | ||
49 | u32 swc; | ||
50 | u32 adcchnl; | ||
51 | u32 adcdata; | ||
52 | u32 chval[4]; | ||
53 | }; | ||
54 | |||
55 | /* TSC Mode Configuration Register (tscm) bits */ | ||
56 | #define WMODE BIT(0) | ||
57 | #define TSKIND BIT(1) | ||
58 | #define ZMEASURE_EN BIT(2) | ||
59 | #define IDLE BIT(3) | ||
60 | #define TSC_EN BIT(4) | ||
61 | #define STOP BIT(5) | ||
62 | #define ONE_SHOT BIT(6) | ||
63 | #define SINGLE BIT(7) | ||
64 | #define AVG BIT(8) | ||
65 | #define AVGNUM(x) (((x) & 0x03) << 9) | ||
66 | #define PVSTC(x) (((x) & 0x07) << 11) | ||
67 | #define PON BIT(14) | ||
68 | #define PONBG BIT(15) | ||
69 | #define AFERST BIT(16) | ||
70 | |||
71 | /* ADC DATA Capture Register bits */ | ||
72 | #define DATA_VALID BIT(16) | ||
73 | |||
74 | /* Register Access Macros */ | ||
75 | #define tsc_read(ts, reg) __raw_readl(&(ts)->regs->reg) | ||
76 | #define tsc_write(ts, reg, val) __raw_writel(val, &(ts)->regs->reg); | ||
77 | #define tsc_set_bits(ts, reg, val) \ | ||
78 | tsc_write(ts, reg, tsc_read(ts, reg) | (val)) | ||
79 | #define tsc_clr_bits(ts, reg, val) \ | ||
80 | tsc_write(ts, reg, tsc_read(ts, reg) & ~(val)) | ||
81 | |||
82 | struct sample { | ||
83 | int x, y, p; | ||
84 | }; | ||
85 | |||
86 | struct tsc_data { | ||
87 | struct input_dev *input_dev; | ||
88 | struct resource *res; | ||
89 | struct tsc_regs __iomem *regs; | ||
90 | struct timer_list timer; | ||
91 | spinlock_t lock; | ||
92 | struct clk *clk; | ||
93 | struct device *dev; | ||
94 | int sample_count; | ||
95 | struct sample samples[TSC_SAMPLES]; | ||
96 | int tsc_irq; | ||
97 | }; | ||
98 | |||
99 | static int tsc_read_sample(struct tsc_data *ts, struct sample* sample) | ||
100 | { | ||
101 | int x, y, z1, z2, t, p = 0; | ||
102 | u32 val; | ||
103 | |||
104 | val = tsc_read(ts, chval[0]); | ||
105 | if (val & DATA_VALID) | ||
106 | x = val & 0xffff; | ||
107 | else | ||
108 | return -EINVAL; | ||
109 | |||
110 | y = tsc_read(ts, chval[1]) & 0xffff; | ||
111 | z1 = tsc_read(ts, chval[2]) & 0xffff; | ||
112 | z2 = tsc_read(ts, chval[3]) & 0xffff; | ||
113 | |||
114 | if (z1) { | ||
115 | t = ((600 * x) * (z2 - z1)); | ||
116 | p = t / (u32) (z1 << 12); | ||
117 | if (p < 0) | ||
118 | p = 0; | ||
119 | } | ||
120 | |||
121 | sample->x = x; | ||
122 | sample->y = y; | ||
123 | sample->p = p; | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static void tsc_poll(unsigned long data) | ||
129 | { | ||
130 | struct tsc_data *ts = (struct tsc_data *)data; | ||
131 | unsigned long flags; | ||
132 | int i, val, x, y, p; | ||
133 | |||
134 | spin_lock_irqsave(&ts->lock, flags); | ||
135 | |||
136 | if (ts->sample_count >= TSC_SKIP) { | ||
137 | input_report_abs(ts->input_dev, ABS_PRESSURE, 0); | ||
138 | input_report_key(ts->input_dev, BTN_TOUCH, 0); | ||
139 | input_sync(ts->input_dev); | ||
140 | } else if (ts->sample_count > 0) { | ||
141 | /* | ||
142 | * A touch event lasted less than our skip count. Salvage and | ||
143 | * report anyway. | ||
144 | */ | ||
145 | for (i = 0, val = 0; i < ts->sample_count; i++) | ||
146 | val += ts->samples[i].x; | ||
147 | x = val / ts->sample_count; | ||
148 | |||
149 | for (i = 0, val = 0; i < ts->sample_count; i++) | ||
150 | val += ts->samples[i].y; | ||
151 | y = val / ts->sample_count; | ||
152 | |||
153 | for (i = 0, val = 0; i < ts->sample_count; i++) | ||
154 | val += ts->samples[i].p; | ||
155 | p = val / ts->sample_count; | ||
156 | |||
157 | input_report_abs(ts->input_dev, ABS_X, x); | ||
158 | input_report_abs(ts->input_dev, ABS_Y, y); | ||
159 | input_report_abs(ts->input_dev, ABS_PRESSURE, p); | ||
160 | input_report_key(ts->input_dev, BTN_TOUCH, 1); | ||
161 | input_sync(ts->input_dev); | ||
162 | } | ||
163 | |||
164 | ts->sample_count = 0; | ||
165 | |||
166 | spin_unlock_irqrestore(&ts->lock, flags); | ||
167 | } | ||
168 | |||
169 | static irqreturn_t tsc_irq(int irq, void *dev_id) | ||
170 | { | ||
171 | struct tsc_data *ts = (struct tsc_data *)dev_id; | ||
172 | struct sample *sample; | ||
173 | int index; | ||
174 | |||
175 | spin_lock(&ts->lock); | ||
176 | |||
177 | index = ts->sample_count % TSC_SAMPLES; | ||
178 | sample = &ts->samples[index]; | ||
179 | if (tsc_read_sample(ts, sample) < 0) | ||
180 | goto out; | ||
181 | |||
182 | if (++ts->sample_count >= TSC_SKIP) { | ||
183 | index = (ts->sample_count - TSC_TAIL_SKIP - 1) % TSC_SAMPLES; | ||
184 | sample = &ts->samples[index]; | ||
185 | |||
186 | input_report_abs(ts->input_dev, ABS_X, sample->x); | ||
187 | input_report_abs(ts->input_dev, ABS_Y, sample->y); | ||
188 | input_report_abs(ts->input_dev, ABS_PRESSURE, sample->p); | ||
189 | if (ts->sample_count == TSC_SKIP) | ||
190 | input_report_key(ts->input_dev, BTN_TOUCH, 1); | ||
191 | input_sync(ts->input_dev); | ||
192 | } | ||
193 | mod_timer(&ts->timer, jiffies + TSC_PENUP_POLL); | ||
194 | out: | ||
195 | spin_unlock(&ts->lock); | ||
196 | return IRQ_HANDLED; | ||
197 | } | ||
198 | |||
199 | static int tsc_start(struct input_dev *dev) | ||
200 | { | ||
201 | struct tsc_data *ts = input_get_drvdata(dev); | ||
202 | unsigned long timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT); | ||
203 | u32 val; | ||
204 | |||
205 | clk_enable(ts->clk); | ||
206 | |||
207 | /* Go to idle mode, before any initialization */ | ||
208 | while (time_after(timeout, jiffies)) { | ||
209 | if (tsc_read(ts, tscm) & IDLE) | ||
210 | break; | ||
211 | } | ||
212 | |||
213 | if (time_before(timeout, jiffies)) { | ||
214 | dev_warn(ts->dev, "timeout waiting for idle\n"); | ||
215 | clk_disable(ts->clk); | ||
216 | return -EIO; | ||
217 | } | ||
218 | |||
219 | /* Configure TSC Control register*/ | ||
220 | val = (PONBG | PON | PVSTC(4) | ONE_SHOT | ZMEASURE_EN); | ||
221 | tsc_write(ts, tscm, val); | ||
222 | |||
223 | /* Bring TSC out of reset: Clear AFE reset bit */ | ||
224 | val &= ~(AFERST); | ||
225 | tsc_write(ts, tscm, val); | ||
226 | |||
227 | /* Configure all pins for hardware control*/ | ||
228 | tsc_write(ts, bwcm, 0); | ||
229 | |||
230 | /* Finally enable the TSC */ | ||
231 | tsc_set_bits(ts, tscm, TSC_EN); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static void tsc_stop(struct input_dev *dev) | ||
237 | { | ||
238 | struct tsc_data *ts = input_get_drvdata(dev); | ||
239 | |||
240 | tsc_clr_bits(ts, tscm, TSC_EN); | ||
241 | synchronize_irq(ts->tsc_irq); | ||
242 | del_timer_sync(&ts->timer); | ||
243 | clk_disable(ts->clk); | ||
244 | } | ||
245 | |||
246 | static int tsc_probe(struct platform_device *pdev) | ||
247 | { | ||
248 | struct device *dev = &pdev->dev; | ||
249 | struct tsc_data *ts; | ||
250 | int error = 0; | ||
251 | u32 rev = 0; | ||
252 | |||
253 | ts = kzalloc(sizeof(struct tsc_data), GFP_KERNEL); | ||
254 | if (!ts) { | ||
255 | dev_err(dev, "cannot allocate device info\n"); | ||
256 | return -ENOMEM; | ||
257 | } | ||
258 | |||
259 | ts->dev = dev; | ||
260 | spin_lock_init(&ts->lock); | ||
261 | setup_timer(&ts->timer, tsc_poll, (unsigned long)ts); | ||
262 | platform_set_drvdata(pdev, ts); | ||
263 | |||
264 | ts->tsc_irq = platform_get_irq(pdev, 0); | ||
265 | if (ts->tsc_irq < 0) { | ||
266 | dev_err(dev, "cannot determine device interrupt\n"); | ||
267 | error = -ENODEV; | ||
268 | goto error_res; | ||
269 | } | ||
270 | |||
271 | ts->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
272 | if (!ts->res) { | ||
273 | dev_err(dev, "cannot determine register area\n"); | ||
274 | error = -ENODEV; | ||
275 | goto error_res; | ||
276 | } | ||
277 | |||
278 | if (!request_mem_region(ts->res->start, resource_size(ts->res), | ||
279 | pdev->name)) { | ||
280 | dev_err(dev, "cannot claim register memory\n"); | ||
281 | ts->res = NULL; | ||
282 | error = -EINVAL; | ||
283 | goto error_res; | ||
284 | } | ||
285 | |||
286 | ts->regs = ioremap(ts->res->start, resource_size(ts->res)); | ||
287 | if (!ts->regs) { | ||
288 | dev_err(dev, "cannot map register memory\n"); | ||
289 | error = -ENOMEM; | ||
290 | goto error_map; | ||
291 | } | ||
292 | |||
293 | ts->clk = clk_get(dev, NULL); | ||
294 | if (IS_ERR(ts->clk)) { | ||
295 | dev_err(dev, "cannot claim device clock\n"); | ||
296 | error = PTR_ERR(ts->clk); | ||
297 | goto error_clk; | ||
298 | } | ||
299 | |||
300 | error = request_threaded_irq(ts->tsc_irq, NULL, tsc_irq, IRQF_ONESHOT, | ||
301 | dev_name(dev), ts); | ||
302 | if (error < 0) { | ||
303 | dev_err(ts->dev, "Could not allocate ts irq\n"); | ||
304 | goto error_irq; | ||
305 | } | ||
306 | |||
307 | ts->input_dev = input_allocate_device(); | ||
308 | if (!ts->input_dev) { | ||
309 | dev_err(dev, "cannot allocate input device\n"); | ||
310 | error = -ENOMEM; | ||
311 | goto error_input; | ||
312 | } | ||
313 | input_set_drvdata(ts->input_dev, ts); | ||
314 | |||
315 | ts->input_dev->name = pdev->name; | ||
316 | ts->input_dev->id.bustype = BUS_HOST; | ||
317 | ts->input_dev->dev.parent = &pdev->dev; | ||
318 | ts->input_dev->open = tsc_start; | ||
319 | ts->input_dev->close = tsc_stop; | ||
320 | |||
321 | clk_enable(ts->clk); | ||
322 | rev = tsc_read(ts, rev); | ||
323 | ts->input_dev->id.product = ((rev >> 8) & 0x07); | ||
324 | ts->input_dev->id.version = ((rev >> 16) & 0xfff); | ||
325 | clk_disable(ts->clk); | ||
326 | |||
327 | __set_bit(EV_KEY, ts->input_dev->evbit); | ||
328 | __set_bit(EV_ABS, ts->input_dev->evbit); | ||
329 | __set_bit(BTN_TOUCH, ts->input_dev->keybit); | ||
330 | |||
331 | input_set_abs_params(ts->input_dev, ABS_X, 0, 0xffff, 5, 0); | ||
332 | input_set_abs_params(ts->input_dev, ABS_Y, 0, 0xffff, 5, 0); | ||
333 | input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 4095, 128, 0); | ||
334 | |||
335 | error = input_register_device(ts->input_dev); | ||
336 | if (error < 0) { | ||
337 | dev_err(dev, "failed input device registration\n"); | ||
338 | goto error_reg; | ||
339 | } | ||
340 | |||
341 | return 0; | ||
342 | |||
343 | error_reg: | ||
344 | input_free_device(ts->input_dev); | ||
345 | error_input: | ||
346 | free_irq(ts->tsc_irq, ts); | ||
347 | error_irq: | ||
348 | clk_put(ts->clk); | ||
349 | error_clk: | ||
350 | iounmap(ts->regs); | ||
351 | error_map: | ||
352 | release_mem_region(ts->res->start, resource_size(ts->res)); | ||
353 | error_res: | ||
354 | kfree(ts); | ||
355 | |||
356 | return error; | ||
357 | } | ||
358 | |||
359 | static int tsc_remove(struct platform_device *pdev) | ||
360 | { | ||
361 | struct tsc_data *ts = platform_get_drvdata(pdev); | ||
362 | |||
363 | input_unregister_device(ts->input_dev); | ||
364 | free_irq(ts->tsc_irq, ts); | ||
365 | clk_put(ts->clk); | ||
366 | iounmap(ts->regs); | ||
367 | release_mem_region(ts->res->start, resource_size(ts->res)); | ||
368 | kfree(ts); | ||
369 | |||
370 | return 0; | ||
371 | } | ||
372 | |||
373 | static struct platform_driver tsc_driver = { | ||
374 | .probe = tsc_probe, | ||
375 | .remove = tsc_remove, | ||
376 | .driver.name = "tnetv107x-ts", | ||
377 | .driver.owner = THIS_MODULE, | ||
378 | }; | ||
379 | module_platform_driver(tsc_driver); | ||
380 | |||
381 | MODULE_AUTHOR("Cyril Chemparathy"); | ||
382 | MODULE_DESCRIPTION("TNETV107X Touchscreen Driver"); | ||
383 | MODULE_ALIAS("platform:tnetv107x-ts"); | ||
384 | MODULE_LICENSE("GPL"); | ||