diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-19 14:37:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-19 14:37:22 -0400 |
commit | 1d3c6ff44ad4b5f113602e153026a338f0f9b3ff (patch) | |
tree | 1e1f2932634fc6d0e4acfe68496c1c727b83a13e /drivers/input | |
parent | 7c7cbaf5b82c418cd3b1dcf718f71d0e6057e639 (diff) | |
parent | 717e7c2672e37253a4d3aa70e4716b5b0a658761 (diff) |
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (224 commits)
ARM: remove 'select GENERIC_TIME'
ARM: 6136/1: ARCH_REQUIRE_GPIOLIB selects GENERIC_GPIO
ARM: 6074/1: oprofile: convert from sysdev to platform device
ARM: 6073/1: oprofile: remove old files and update KConfig
ARM: 6072/1: oprofile: use perf-events framework as backend
ARM: 6071/1: perf-events: allow modules to query the number of hardware counters
ARM: 6070/1: perf-events: add support for xscale PMUs
ARM: 6069/1: perf-events: use numeric ID to identify PMU
ARM: 6064/1: pmu: register IRQs at runtime
ARM: Optionally allow ARMv6 to use 'normal, bufferable' memory for DMA
ARM: 6134/1: Handle instruction cache maintenance fault properly
ARM: nwfpe: allow debugging output to be configured at runtime
ARM: rename mach_cpu_disable() to platform_cpu_disable()
ARM: 6132/1: PL330: Add common core driver
ARM: 6094/1: Extend cache-l2x0 to support the 16-way PL310
ARM: Move memory mapping into mmu.c
ARM: Ensure meminfo is sorted prior to sanity_check_meminfo
ARM: Remove useless linux/bootmem.h includes
ARM: convert /proc/cpu/aligment to seq_file
arm: use asm-generic/scatterlist.h
...
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/Kconfig | 48 | ||||
-rw-r--r-- | drivers/input/keyboard/Makefile | 3 | ||||
-rw-r--r-- | drivers/input/keyboard/corgikbd.c | 414 | ||||
-rw-r--r-- | drivers/input/keyboard/spitzkbd.c | 496 | ||||
-rw-r--r-- | drivers/input/keyboard/tosakbd.c | 431 | ||||
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 16 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/corgi_ts.c | 385 |
8 files changed, 0 insertions, 1794 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 64c102355f5..a8293388d01 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -143,19 +143,6 @@ config KEYBOARD_BFIN | |||
143 | To compile this driver as a module, choose M here: the | 143 | To compile this driver as a module, choose M here: the |
144 | module will be called bf54x-keys. | 144 | module will be called bf54x-keys. |
145 | 145 | ||
146 | config KEYBOARD_CORGI | ||
147 | tristate "Corgi keyboard (deprecated)" | ||
148 | depends on PXA_SHARPSL | ||
149 | help | ||
150 | Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx | ||
151 | series of PDAs. | ||
152 | |||
153 | This driver is now deprecated, use generic GPIO based matrix | ||
154 | keyboard driver instead. | ||
155 | |||
156 | To compile this driver as a module, choose M here: the | ||
157 | module will be called corgikbd. | ||
158 | |||
159 | config KEYBOARD_LKKBD | 146 | config KEYBOARD_LKKBD |
160 | tristate "DECstation/VAXstation LK201/LK401 keyboard" | 147 | tristate "DECstation/VAXstation LK201/LK401 keyboard" |
161 | select SERIO | 148 | select SERIO |
@@ -339,19 +326,6 @@ config KEYBOARD_PXA930_ROTARY | |||
339 | To compile this driver as a module, choose M here: the | 326 | To compile this driver as a module, choose M here: the |
340 | module will be called pxa930_rotary. | 327 | module will be called pxa930_rotary. |
341 | 328 | ||
342 | config KEYBOARD_SPITZ | ||
343 | tristate "Spitz keyboard (deprecated)" | ||
344 | depends on PXA_SHARPSL | ||
345 | help | ||
346 | Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000, | ||
347 | SL-C3000 and Sl-C3100 series of PDAs. | ||
348 | |||
349 | This driver is now deprecated, use generic GPIO based matrix | ||
350 | keyboard driver instead. | ||
351 | |||
352 | To compile this driver as a module, choose M here: the | ||
353 | module will be called spitzkbd. | ||
354 | |||
355 | config KEYBOARD_STOWAWAY | 329 | config KEYBOARD_STOWAWAY |
356 | tristate "Stowaway keyboard" | 330 | tristate "Stowaway keyboard" |
357 | select SERIO | 331 | select SERIO |
@@ -414,28 +388,6 @@ config KEYBOARD_TWL4030 | |||
414 | To compile this driver as a module, choose M here: the | 388 | To compile this driver as a module, choose M here: the |
415 | module will be called twl4030_keypad. | 389 | module will be called twl4030_keypad. |
416 | 390 | ||
417 | config KEYBOARD_TOSA | ||
418 | tristate "Tosa keyboard (deprecated)" | ||
419 | depends on MACH_TOSA | ||
420 | help | ||
421 | Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa) | ||
422 | |||
423 | This driver is now deprecated, use generic GPIO based matrix | ||
424 | keyboard driver instead. | ||
425 | |||
426 | To compile this driver as a module, choose M here: the | ||
427 | module will be called tosakbd. | ||
428 | |||
429 | config KEYBOARD_TOSA_USE_EXT_KEYCODES | ||
430 | bool "Tosa keyboard: use extended keycodes" | ||
431 | depends on KEYBOARD_TOSA | ||
432 | help | ||
433 | Say Y here to enable the tosa keyboard driver to generate extended | ||
434 | (>= 127) keycodes. Be aware, that they can't be correctly interpreted | ||
435 | by either console keyboard driver or by Kdrive keybd driver. | ||
436 | |||
437 | Say Y only if you know, what you are doing! | ||
438 | |||
439 | config KEYBOARD_XTKBD | 391 | config KEYBOARD_XTKBD |
440 | tristate "XT keyboard" | 392 | tristate "XT keyboard" |
441 | select SERIO | 393 | select SERIO |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 706c6b5ed5f..9a74127e4d1 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -11,7 +11,6 @@ obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o | |||
11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o | 11 | obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o |
12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o | 12 | obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o |
13 | obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o | 13 | obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o |
14 | obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o | ||
15 | obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o | 14 | obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o |
16 | obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o | 15 | obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o |
17 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o | 16 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o |
@@ -33,10 +32,8 @@ obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o | |||
33 | obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o | 32 | obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o |
34 | obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o | 33 | obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o |
35 | obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o | 34 | obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o |
36 | obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o | ||
37 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o | 35 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o |
38 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o | 36 | obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o |
39 | obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o | ||
40 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o | 37 | obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o |
41 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | 38 | obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o |
42 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o | 39 | obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c deleted file mode 100644 index 634af6a8e6b..00000000000 --- a/drivers/input/keyboard/corgikbd.c +++ /dev/null | |||
@@ -1,414 +0,0 @@ | |||
1 | /* | ||
2 | * Keyboard driver for Sharp Corgi models (SL-C7xx) | ||
3 | * | ||
4 | * Copyright (c) 2004-2005 Richard Purdie | ||
5 | * | ||
6 | * Based on xtkbd.c/locomkbd.c | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/jiffies.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <mach/corgi.h> | ||
24 | #include <mach/pxa2xx-gpio.h> | ||
25 | #include <asm/hardware/scoop.h> | ||
26 | |||
27 | #define KB_ROWS 8 | ||
28 | #define KB_COLS 12 | ||
29 | #define KB_ROWMASK(r) (1 << (r)) | ||
30 | #define SCANCODE(r,c) ( ((r)<<4) + (c) + 1 ) | ||
31 | /* zero code, 124 scancodes */ | ||
32 | #define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 ) | ||
33 | |||
34 | #define SCAN_INTERVAL (50) /* ms */ | ||
35 | #define HINGE_SCAN_INTERVAL (250) /* ms */ | ||
36 | |||
37 | #define CORGI_KEY_CALENDER KEY_F1 | ||
38 | #define CORGI_KEY_ADDRESS KEY_F2 | ||
39 | #define CORGI_KEY_FN KEY_F3 | ||
40 | #define CORGI_KEY_CANCEL KEY_F4 | ||
41 | #define CORGI_KEY_OFF KEY_SUSPEND | ||
42 | #define CORGI_KEY_EXOK KEY_F5 | ||
43 | #define CORGI_KEY_EXCANCEL KEY_F6 | ||
44 | #define CORGI_KEY_EXJOGDOWN KEY_F7 | ||
45 | #define CORGI_KEY_EXJOGUP KEY_F8 | ||
46 | #define CORGI_KEY_JAP1 KEY_LEFTCTRL | ||
47 | #define CORGI_KEY_JAP2 KEY_LEFTALT | ||
48 | #define CORGI_KEY_MAIL KEY_F10 | ||
49 | #define CORGI_KEY_OK KEY_F11 | ||
50 | #define CORGI_KEY_MENU KEY_F12 | ||
51 | |||
52 | static unsigned char corgikbd_keycode[NR_SCANCODES] = { | ||
53 | 0, /* 0 */ | ||
54 | 0, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, 0, 0, 0, 0, 0, 0, 0, /* 1-16 */ | ||
55 | 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, 0, 0, 0, 0, 0, 0, 0, /* 17-32 */ | ||
56 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ | ||
57 | CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ | ||
58 | CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */ | ||
59 | CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ | ||
60 | KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ | ||
61 | CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */ | ||
62 | }; | ||
63 | |||
64 | |||
65 | struct corgikbd { | ||
66 | unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; | ||
67 | struct input_dev *input; | ||
68 | |||
69 | spinlock_t lock; | ||
70 | struct timer_list timer; | ||
71 | struct timer_list htimer; | ||
72 | |||
73 | unsigned int suspended; | ||
74 | unsigned long suspend_jiffies; | ||
75 | }; | ||
76 | |||
77 | #define KB_DISCHARGE_DELAY 10 | ||
78 | #define KB_ACTIVATE_DELAY 10 | ||
79 | |||
80 | /* Helper functions for reading the keyboard matrix | ||
81 | * Note: We should really be using the generic gpio functions to alter | ||
82 | * GPDR but it requires a function call per GPIO bit which is | ||
83 | * excessive when we need to access 12 bits at once, multiple times. | ||
84 | * These functions must be called within local_irq_save()/local_irq_restore() | ||
85 | * or similar. | ||
86 | */ | ||
87 | static inline void corgikbd_discharge_all(void) | ||
88 | { | ||
89 | /* STROBE All HiZ */ | ||
90 | GPCR2 = CORGI_GPIO_ALL_STROBE_BIT; | ||
91 | GPDR2 &= ~CORGI_GPIO_ALL_STROBE_BIT; | ||
92 | } | ||
93 | |||
94 | static inline void corgikbd_activate_all(void) | ||
95 | { | ||
96 | /* STROBE ALL -> High */ | ||
97 | GPSR2 = CORGI_GPIO_ALL_STROBE_BIT; | ||
98 | GPDR2 |= CORGI_GPIO_ALL_STROBE_BIT; | ||
99 | |||
100 | udelay(KB_DISCHARGE_DELAY); | ||
101 | |||
102 | /* Clear any interrupts we may have triggered when altering the GPIO lines */ | ||
103 | GEDR1 = CORGI_GPIO_HIGH_SENSE_BIT; | ||
104 | GEDR2 = CORGI_GPIO_LOW_SENSE_BIT; | ||
105 | } | ||
106 | |||
107 | static inline void corgikbd_activate_col(int col) | ||
108 | { | ||
109 | /* STROBE col -> High, not col -> HiZ */ | ||
110 | GPSR2 = CORGI_GPIO_STROBE_BIT(col); | ||
111 | GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col); | ||
112 | } | ||
113 | |||
114 | static inline void corgikbd_reset_col(int col) | ||
115 | { | ||
116 | /* STROBE col -> Low */ | ||
117 | GPCR2 = CORGI_GPIO_STROBE_BIT(col); | ||
118 | /* STROBE col -> out, not col -> HiZ */ | ||
119 | GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col); | ||
120 | } | ||
121 | |||
122 | #define GET_ROWS_STATUS(c) (((GPLR1 & CORGI_GPIO_HIGH_SENSE_BIT) >> CORGI_GPIO_HIGH_SENSE_RSHIFT) | ((GPLR2 & CORGI_GPIO_LOW_SENSE_BIT) << CORGI_GPIO_LOW_SENSE_LSHIFT)) | ||
123 | |||
124 | /* | ||
125 | * The corgi keyboard only generates interrupts when a key is pressed. | ||
126 | * When a key is pressed, we enable a timer which then scans the | ||
127 | * keyboard to detect when the key is released. | ||
128 | */ | ||
129 | |||
130 | /* Scan the hardware keyboard and push any changes up through the input layer */ | ||
131 | static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data) | ||
132 | { | ||
133 | unsigned int row, col, rowd; | ||
134 | unsigned long flags; | ||
135 | unsigned int num_pressed; | ||
136 | |||
137 | if (corgikbd_data->suspended) | ||
138 | return; | ||
139 | |||
140 | spin_lock_irqsave(&corgikbd_data->lock, flags); | ||
141 | |||
142 | num_pressed = 0; | ||
143 | for (col = 0; col < KB_COLS; col++) { | ||
144 | /* | ||
145 | * Discharge the output driver capacitatance | ||
146 | * in the keyboard matrix. (Yes it is significant..) | ||
147 | */ | ||
148 | |||
149 | corgikbd_discharge_all(); | ||
150 | udelay(KB_DISCHARGE_DELAY); | ||
151 | |||
152 | corgikbd_activate_col(col); | ||
153 | udelay(KB_ACTIVATE_DELAY); | ||
154 | |||
155 | rowd = GET_ROWS_STATUS(col); | ||
156 | for (row = 0; row < KB_ROWS; row++) { | ||
157 | unsigned int scancode, pressed; | ||
158 | |||
159 | scancode = SCANCODE(row, col); | ||
160 | pressed = rowd & KB_ROWMASK(row); | ||
161 | |||
162 | input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); | ||
163 | |||
164 | if (pressed) | ||
165 | num_pressed++; | ||
166 | |||
167 | if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) | ||
168 | && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { | ||
169 | input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); | ||
170 | corgikbd_data->suspend_jiffies=jiffies; | ||
171 | } | ||
172 | } | ||
173 | corgikbd_reset_col(col); | ||
174 | } | ||
175 | |||
176 | corgikbd_activate_all(); | ||
177 | |||
178 | input_sync(corgikbd_data->input); | ||
179 | |||
180 | /* if any keys are pressed, enable the timer */ | ||
181 | if (num_pressed) | ||
182 | mod_timer(&corgikbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL)); | ||
183 | |||
184 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | ||
185 | } | ||
186 | |||
187 | /* | ||
188 | * corgi keyboard interrupt handler. | ||
189 | */ | ||
190 | static irqreturn_t corgikbd_interrupt(int irq, void *dev_id) | ||
191 | { | ||
192 | struct corgikbd *corgikbd_data = dev_id; | ||
193 | |||
194 | if (!timer_pending(&corgikbd_data->timer)) { | ||
195 | /** wait chattering delay **/ | ||
196 | udelay(20); | ||
197 | corgikbd_scankeyboard(corgikbd_data); | ||
198 | } | ||
199 | |||
200 | return IRQ_HANDLED; | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * corgi timer checking for released keys | ||
205 | */ | ||
206 | static void corgikbd_timer_callback(unsigned long data) | ||
207 | { | ||
208 | struct corgikbd *corgikbd_data = (struct corgikbd *) data; | ||
209 | corgikbd_scankeyboard(corgikbd_data); | ||
210 | } | ||
211 | |||
212 | /* | ||
213 | * The hinge switches generate no interrupt so they need to be | ||
214 | * monitored by a timer. | ||
215 | * | ||
216 | * We debounce the switches and pass them to the input system. | ||
217 | * | ||
218 | * gprr == 0x00 - Keyboard with Landscape Screen | ||
219 | * 0x08 - No Keyboard with Portrait Screen | ||
220 | * 0x0c - Keyboard and Screen Closed | ||
221 | */ | ||
222 | |||
223 | #define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x)) | ||
224 | #define HINGE_STABLE_COUNT 2 | ||
225 | static int sharpsl_hinge_state; | ||
226 | static int hinge_count; | ||
227 | |||
228 | static void corgikbd_hinge_timer(unsigned long data) | ||
229 | { | ||
230 | struct corgikbd *corgikbd_data = (struct corgikbd *) data; | ||
231 | unsigned long gprr; | ||
232 | unsigned long flags; | ||
233 | |||
234 | gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB); | ||
235 | gprr |= (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0); | ||
236 | if (gprr != sharpsl_hinge_state) { | ||
237 | hinge_count = 0; | ||
238 | sharpsl_hinge_state = gprr; | ||
239 | } else if (hinge_count < HINGE_STABLE_COUNT) { | ||
240 | hinge_count++; | ||
241 | if (hinge_count >= HINGE_STABLE_COUNT) { | ||
242 | spin_lock_irqsave(&corgikbd_data->lock, flags); | ||
243 | |||
244 | input_report_switch(corgikbd_data->input, SW_LID, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); | ||
245 | input_report_switch(corgikbd_data->input, SW_TABLET_MODE, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); | ||
246 | input_report_switch(corgikbd_data->input, SW_HEADPHONE_INSERT, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0)); | ||
247 | input_sync(corgikbd_data->input); | ||
248 | |||
249 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | ||
250 | } | ||
251 | } | ||
252 | mod_timer(&corgikbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
253 | } | ||
254 | |||
255 | #ifdef CONFIG_PM | ||
256 | static int corgikbd_suspend(struct platform_device *dev, pm_message_t state) | ||
257 | { | ||
258 | int i; | ||
259 | struct corgikbd *corgikbd = platform_get_drvdata(dev); | ||
260 | |||
261 | corgikbd->suspended = 1; | ||
262 | /* strobe 0 is the power key so this can't be made an input for | ||
263 | powersaving therefore i = 1 */ | ||
264 | for (i = 1; i < CORGI_KEY_STROBE_NUM; i++) | ||
265 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_IN); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static int corgikbd_resume(struct platform_device *dev) | ||
271 | { | ||
272 | int i; | ||
273 | struct corgikbd *corgikbd = platform_get_drvdata(dev); | ||
274 | |||
275 | for (i = 1; i < CORGI_KEY_STROBE_NUM; i++) | ||
276 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); | ||
277 | |||
278 | /* Upon resume, ignore the suspend key for a short while */ | ||
279 | corgikbd->suspend_jiffies=jiffies; | ||
280 | corgikbd->suspended = 0; | ||
281 | |||
282 | return 0; | ||
283 | } | ||
284 | #else | ||
285 | #define corgikbd_suspend NULL | ||
286 | #define corgikbd_resume NULL | ||
287 | #endif | ||
288 | |||
289 | static int __devinit corgikbd_probe(struct platform_device *pdev) | ||
290 | { | ||
291 | struct corgikbd *corgikbd; | ||
292 | struct input_dev *input_dev; | ||
293 | int i, err = -ENOMEM; | ||
294 | |||
295 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); | ||
296 | input_dev = input_allocate_device(); | ||
297 | if (!corgikbd || !input_dev) | ||
298 | goto fail; | ||
299 | |||
300 | platform_set_drvdata(pdev, corgikbd); | ||
301 | |||
302 | corgikbd->input = input_dev; | ||
303 | spin_lock_init(&corgikbd->lock); | ||
304 | |||
305 | /* Init Keyboard rescan timer */ | ||
306 | init_timer(&corgikbd->timer); | ||
307 | corgikbd->timer.function = corgikbd_timer_callback; | ||
308 | corgikbd->timer.data = (unsigned long) corgikbd; | ||
309 | |||
310 | /* Init Hinge Timer */ | ||
311 | init_timer(&corgikbd->htimer); | ||
312 | corgikbd->htimer.function = corgikbd_hinge_timer; | ||
313 | corgikbd->htimer.data = (unsigned long) corgikbd; | ||
314 | |||
315 | corgikbd->suspend_jiffies=jiffies; | ||
316 | |||
317 | memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); | ||
318 | |||
319 | input_dev->name = "Corgi Keyboard"; | ||
320 | input_dev->phys = "corgikbd/input0"; | ||
321 | input_dev->id.bustype = BUS_HOST; | ||
322 | input_dev->id.vendor = 0x0001; | ||
323 | input_dev->id.product = 0x0001; | ||
324 | input_dev->id.version = 0x0100; | ||
325 | input_dev->dev.parent = &pdev->dev; | ||
326 | |||
327 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | | ||
328 | BIT_MASK(EV_PWR) | BIT_MASK(EV_SW); | ||
329 | input_dev->keycode = corgikbd->keycode; | ||
330 | input_dev->keycodesize = sizeof(unsigned char); | ||
331 | input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode); | ||
332 | |||
333 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) | ||
334 | set_bit(corgikbd->keycode[i], input_dev->keybit); | ||
335 | clear_bit(0, input_dev->keybit); | ||
336 | set_bit(SW_LID, input_dev->swbit); | ||
337 | set_bit(SW_TABLET_MODE, input_dev->swbit); | ||
338 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); | ||
339 | |||
340 | err = input_register_device(corgikbd->input); | ||
341 | if (err) | ||
342 | goto fail; | ||
343 | |||
344 | mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
345 | |||
346 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | ||
347 | for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) { | ||
348 | pxa_gpio_mode(CORGI_GPIO_KEY_SENSE(i) | GPIO_IN); | ||
349 | if (request_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd_interrupt, | ||
350 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | ||
351 | "corgikbd", corgikbd)) | ||
352 | printk(KERN_WARNING "corgikbd: Can't get IRQ: %d!\n", i); | ||
353 | } | ||
354 | |||
355 | /* Set Strobe lines as outputs - set high */ | ||
356 | for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) | ||
357 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); | ||
358 | |||
359 | /* Setup the headphone jack as an input */ | ||
360 | pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN); | ||
361 | |||
362 | return 0; | ||
363 | |||
364 | fail: input_free_device(input_dev); | ||
365 | kfree(corgikbd); | ||
366 | return err; | ||
367 | } | ||
368 | |||
369 | static int __devexit corgikbd_remove(struct platform_device *pdev) | ||
370 | { | ||
371 | int i; | ||
372 | struct corgikbd *corgikbd = platform_get_drvdata(pdev); | ||
373 | |||
374 | for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) | ||
375 | free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd); | ||
376 | |||
377 | del_timer_sync(&corgikbd->htimer); | ||
378 | del_timer_sync(&corgikbd->timer); | ||
379 | |||
380 | input_unregister_device(corgikbd->input); | ||
381 | |||
382 | kfree(corgikbd); | ||
383 | |||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static struct platform_driver corgikbd_driver = { | ||
388 | .probe = corgikbd_probe, | ||
389 | .remove = __devexit_p(corgikbd_remove), | ||
390 | .suspend = corgikbd_suspend, | ||
391 | .resume = corgikbd_resume, | ||
392 | .driver = { | ||
393 | .name = "corgi-keyboard", | ||
394 | .owner = THIS_MODULE, | ||
395 | }, | ||
396 | }; | ||
397 | |||
398 | static int __init corgikbd_init(void) | ||
399 | { | ||
400 | return platform_driver_register(&corgikbd_driver); | ||
401 | } | ||
402 | |||
403 | static void __exit corgikbd_exit(void) | ||
404 | { | ||
405 | platform_driver_unregister(&corgikbd_driver); | ||
406 | } | ||
407 | |||
408 | module_init(corgikbd_init); | ||
409 | module_exit(corgikbd_exit); | ||
410 | |||
411 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
412 | MODULE_DESCRIPTION("Corgi Keyboard Driver"); | ||
413 | MODULE_LICENSE("GPL v2"); | ||
414 | MODULE_ALIAS("platform:corgi-keyboard"); | ||
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c deleted file mode 100644 index 13967422658..00000000000 --- a/drivers/input/keyboard/spitzkbd.c +++ /dev/null | |||
@@ -1,496 +0,0 @@ | |||
1 | /* | ||
2 | * Keyboard driver for Sharp Spitz, Borzoi and Akita (SL-Cxx00 series) | ||
3 | * | ||
4 | * Copyright (c) 2005 Richard Purdie | ||
5 | * | ||
6 | * Based on corgikbd.c | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/delay.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/jiffies.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <mach/spitz.h> | ||
24 | #include <mach/pxa2xx-gpio.h> | ||
25 | |||
26 | #define KB_ROWS 7 | ||
27 | #define KB_COLS 11 | ||
28 | #define KB_ROWMASK(r) (1 << (r)) | ||
29 | #define SCANCODE(r,c) (((r)<<4) + (c) + 1) | ||
30 | #define NR_SCANCODES ((KB_ROWS<<4) + 1) | ||
31 | |||
32 | #define SCAN_INTERVAL (50) /* ms */ | ||
33 | #define HINGE_SCAN_INTERVAL (150) /* ms */ | ||
34 | |||
35 | #define SPITZ_KEY_CALENDER KEY_F1 | ||
36 | #define SPITZ_KEY_ADDRESS KEY_F2 | ||
37 | #define SPITZ_KEY_FN KEY_F3 | ||
38 | #define SPITZ_KEY_CANCEL KEY_F4 | ||
39 | #define SPITZ_KEY_EXOK KEY_F5 | ||
40 | #define SPITZ_KEY_EXCANCEL KEY_F6 | ||
41 | #define SPITZ_KEY_EXJOGDOWN KEY_F7 | ||
42 | #define SPITZ_KEY_EXJOGUP KEY_F8 | ||
43 | #define SPITZ_KEY_JAP1 KEY_LEFTALT | ||
44 | #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL | ||
45 | #define SPITZ_KEY_SYNC KEY_F9 | ||
46 | #define SPITZ_KEY_MAIL KEY_F10 | ||
47 | #define SPITZ_KEY_OK KEY_F11 | ||
48 | #define SPITZ_KEY_MENU KEY_F12 | ||
49 | |||
50 | static unsigned char spitzkbd_keycode[NR_SCANCODES] = { | ||
51 | 0, /* 0 */ | ||
52 | KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */ | ||
53 | 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */ | ||
54 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ | ||
55 | SPITZ_KEY_ADDRESS, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ | ||
56 | SPITZ_KEY_CALENDER, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */ | ||
57 | SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */ | ||
58 | KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */ | ||
59 | }; | ||
60 | |||
61 | static int spitz_strobes[] = { | ||
62 | SPITZ_GPIO_KEY_STROBE0, | ||
63 | SPITZ_GPIO_KEY_STROBE1, | ||
64 | SPITZ_GPIO_KEY_STROBE2, | ||
65 | SPITZ_GPIO_KEY_STROBE3, | ||
66 | SPITZ_GPIO_KEY_STROBE4, | ||
67 | SPITZ_GPIO_KEY_STROBE5, | ||
68 | SPITZ_GPIO_KEY_STROBE6, | ||
69 | SPITZ_GPIO_KEY_STROBE7, | ||
70 | SPITZ_GPIO_KEY_STROBE8, | ||
71 | SPITZ_GPIO_KEY_STROBE9, | ||
72 | SPITZ_GPIO_KEY_STROBE10, | ||
73 | }; | ||
74 | |||
75 | static int spitz_senses[] = { | ||
76 | SPITZ_GPIO_KEY_SENSE0, | ||
77 | SPITZ_GPIO_KEY_SENSE1, | ||
78 | SPITZ_GPIO_KEY_SENSE2, | ||
79 | SPITZ_GPIO_KEY_SENSE3, | ||
80 | SPITZ_GPIO_KEY_SENSE4, | ||
81 | SPITZ_GPIO_KEY_SENSE5, | ||
82 | SPITZ_GPIO_KEY_SENSE6, | ||
83 | }; | ||
84 | |||
85 | struct spitzkbd { | ||
86 | unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; | ||
87 | struct input_dev *input; | ||
88 | char phys[32]; | ||
89 | |||
90 | spinlock_t lock; | ||
91 | struct timer_list timer; | ||
92 | struct timer_list htimer; | ||
93 | |||
94 | unsigned int suspended; | ||
95 | unsigned long suspend_jiffies; | ||
96 | }; | ||
97 | |||
98 | #define KB_DISCHARGE_DELAY 10 | ||
99 | #define KB_ACTIVATE_DELAY 10 | ||
100 | |||
101 | /* Helper functions for reading the keyboard matrix | ||
102 | * Note: We should really be using the generic gpio functions to alter | ||
103 | * GPDR but it requires a function call per GPIO bit which is | ||
104 | * excessive when we need to access 11 bits at once, multiple times. | ||
105 | * These functions must be called within local_irq_save()/local_irq_restore() | ||
106 | * or similar. | ||
107 | */ | ||
108 | static inline void spitzkbd_discharge_all(void) | ||
109 | { | ||
110 | /* STROBE All HiZ */ | ||
111 | GPCR0 = SPITZ_GPIO_G0_STROBE_BIT; | ||
112 | GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; | ||
113 | GPCR1 = SPITZ_GPIO_G1_STROBE_BIT; | ||
114 | GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; | ||
115 | GPCR2 = SPITZ_GPIO_G2_STROBE_BIT; | ||
116 | GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; | ||
117 | GPCR3 = SPITZ_GPIO_G3_STROBE_BIT; | ||
118 | GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; | ||
119 | } | ||
120 | |||
121 | static inline void spitzkbd_activate_all(void) | ||
122 | { | ||
123 | /* STROBE ALL -> High */ | ||
124 | GPSR0 = SPITZ_GPIO_G0_STROBE_BIT; | ||
125 | GPDR0 |= SPITZ_GPIO_G0_STROBE_BIT; | ||
126 | GPSR1 = SPITZ_GPIO_G1_STROBE_BIT; | ||
127 | GPDR1 |= SPITZ_GPIO_G1_STROBE_BIT; | ||
128 | GPSR2 = SPITZ_GPIO_G2_STROBE_BIT; | ||
129 | GPDR2 |= SPITZ_GPIO_G2_STROBE_BIT; | ||
130 | GPSR3 = SPITZ_GPIO_G3_STROBE_BIT; | ||
131 | GPDR3 |= SPITZ_GPIO_G3_STROBE_BIT; | ||
132 | |||
133 | udelay(KB_DISCHARGE_DELAY); | ||
134 | |||
135 | /* Clear any interrupts we may have triggered when altering the GPIO lines */ | ||
136 | GEDR0 = SPITZ_GPIO_G0_SENSE_BIT; | ||
137 | GEDR1 = SPITZ_GPIO_G1_SENSE_BIT; | ||
138 | GEDR2 = SPITZ_GPIO_G2_SENSE_BIT; | ||
139 | GEDR3 = SPITZ_GPIO_G3_SENSE_BIT; | ||
140 | } | ||
141 | |||
142 | static inline void spitzkbd_activate_col(int col) | ||
143 | { | ||
144 | int gpio = spitz_strobes[col]; | ||
145 | GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; | ||
146 | GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; | ||
147 | GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; | ||
148 | GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; | ||
149 | GPSR(gpio) = GPIO_bit(gpio); | ||
150 | GPDR(gpio) |= GPIO_bit(gpio); | ||
151 | } | ||
152 | |||
153 | static inline void spitzkbd_reset_col(int col) | ||
154 | { | ||
155 | int gpio = spitz_strobes[col]; | ||
156 | GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; | ||
157 | GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; | ||
158 | GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; | ||
159 | GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; | ||
160 | GPCR(gpio) = GPIO_bit(gpio); | ||
161 | GPDR(gpio) |= GPIO_bit(gpio); | ||
162 | } | ||
163 | |||
164 | static inline int spitzkbd_get_row_status(int col) | ||
165 | { | ||
166 | return ((GPLR0 >> 12) & 0x01) | ((GPLR0 >> 16) & 0x02) | ||
167 | | ((GPLR2 >> 25) & 0x04) | ((GPLR1 << 1) & 0x08) | ||
168 | | ((GPLR1 >> 0) & 0x10) | ((GPLR1 >> 1) & 0x60); | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * The spitz keyboard only generates interrupts when a key is pressed. | ||
173 | * When a key is pressed, we enable a timer which then scans the | ||
174 | * keyboard to detect when the key is released. | ||
175 | */ | ||
176 | |||
177 | /* Scan the hardware keyboard and push any changes up through the input layer */ | ||
178 | static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data) | ||
179 | { | ||
180 | unsigned int row, col, rowd; | ||
181 | unsigned long flags; | ||
182 | unsigned int num_pressed, pwrkey = ((GPLR(SPITZ_GPIO_ON_KEY) & GPIO_bit(SPITZ_GPIO_ON_KEY)) != 0); | ||
183 | |||
184 | if (spitzkbd_data->suspended) | ||
185 | return; | ||
186 | |||
187 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | ||
188 | |||
189 | num_pressed = 0; | ||
190 | for (col = 0; col < KB_COLS; col++) { | ||
191 | /* | ||
192 | * Discharge the output driver capacitatance | ||
193 | * in the keyboard matrix. (Yes it is significant..) | ||
194 | */ | ||
195 | |||
196 | spitzkbd_discharge_all(); | ||
197 | udelay(KB_DISCHARGE_DELAY); | ||
198 | |||
199 | spitzkbd_activate_col(col); | ||
200 | udelay(KB_ACTIVATE_DELAY); | ||
201 | |||
202 | rowd = spitzkbd_get_row_status(col); | ||
203 | for (row = 0; row < KB_ROWS; row++) { | ||
204 | unsigned int scancode, pressed; | ||
205 | |||
206 | scancode = SCANCODE(row, col); | ||
207 | pressed = rowd & KB_ROWMASK(row); | ||
208 | |||
209 | input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); | ||
210 | |||
211 | if (pressed) | ||
212 | num_pressed++; | ||
213 | } | ||
214 | spitzkbd_reset_col(col); | ||
215 | } | ||
216 | |||
217 | spitzkbd_activate_all(); | ||
218 | |||
219 | input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); | ||
220 | input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey); | ||
221 | |||
222 | if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { | ||
223 | input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); | ||
224 | spitzkbd_data->suspend_jiffies = jiffies; | ||
225 | } | ||
226 | |||
227 | input_sync(spitzkbd_data->input); | ||
228 | |||
229 | /* if any keys are pressed, enable the timer */ | ||
230 | if (num_pressed) | ||
231 | mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL)); | ||
232 | |||
233 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); | ||
234 | } | ||
235 | |||
236 | /* | ||
237 | * spitz keyboard interrupt handler. | ||
238 | */ | ||
239 | static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id) | ||
240 | { | ||
241 | struct spitzkbd *spitzkbd_data = dev_id; | ||
242 | |||
243 | if (!timer_pending(&spitzkbd_data->timer)) { | ||
244 | /** wait chattering delay **/ | ||
245 | udelay(20); | ||
246 | spitzkbd_scankeyboard(spitzkbd_data); | ||
247 | } | ||
248 | |||
249 | return IRQ_HANDLED; | ||
250 | } | ||
251 | |||
252 | /* | ||
253 | * spitz timer checking for released keys | ||
254 | */ | ||
255 | static void spitzkbd_timer_callback(unsigned long data) | ||
256 | { | ||
257 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; | ||
258 | |||
259 | spitzkbd_scankeyboard(spitzkbd_data); | ||
260 | } | ||
261 | |||
262 | /* | ||
263 | * The hinge switches generate an interrupt. | ||
264 | * We debounce the switches and pass them to the input system. | ||
265 | */ | ||
266 | |||
267 | static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id) | ||
268 | { | ||
269 | struct spitzkbd *spitzkbd_data = dev_id; | ||
270 | |||
271 | if (!timer_pending(&spitzkbd_data->htimer)) | ||
272 | mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
273 | |||
274 | return IRQ_HANDLED; | ||
275 | } | ||
276 | |||
277 | #define HINGE_STABLE_COUNT 2 | ||
278 | static int sharpsl_hinge_state; | ||
279 | static int hinge_count; | ||
280 | |||
281 | static void spitzkbd_hinge_timer(unsigned long data) | ||
282 | { | ||
283 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; | ||
284 | unsigned long state; | ||
285 | unsigned long flags; | ||
286 | |||
287 | state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB)); | ||
288 | state |= (GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)); | ||
289 | if (state != sharpsl_hinge_state) { | ||
290 | hinge_count = 0; | ||
291 | sharpsl_hinge_state = state; | ||
292 | } else if (hinge_count < HINGE_STABLE_COUNT) { | ||
293 | hinge_count++; | ||
294 | } | ||
295 | |||
296 | if (hinge_count >= HINGE_STABLE_COUNT) { | ||
297 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | ||
298 | |||
299 | input_report_switch(spitzkbd_data->input, SW_LID, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); | ||
300 | input_report_switch(spitzkbd_data->input, SW_TABLET_MODE, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); | ||
301 | input_report_switch(spitzkbd_data->input, SW_HEADPHONE_INSERT, ((GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)) != 0)); | ||
302 | input_sync(spitzkbd_data->input); | ||
303 | |||
304 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); | ||
305 | } else { | ||
306 | mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | #ifdef CONFIG_PM | ||
311 | static int spitzkbd_suspend(struct platform_device *dev, pm_message_t state) | ||
312 | { | ||
313 | int i; | ||
314 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); | ||
315 | spitzkbd->suspended = 1; | ||
316 | |||
317 | /* Set Strobe lines as inputs - *except* strobe line 0 leave this | ||
318 | enabled so we can detect a power button press for resume */ | ||
319 | for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++) | ||
320 | pxa_gpio_mode(spitz_strobes[i] | GPIO_IN); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static int spitzkbd_resume(struct platform_device *dev) | ||
326 | { | ||
327 | int i; | ||
328 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); | ||
329 | |||
330 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) | ||
331 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); | ||
332 | |||
333 | /* Upon resume, ignore the suspend key for a short while */ | ||
334 | spitzkbd->suspend_jiffies = jiffies; | ||
335 | spitzkbd->suspended = 0; | ||
336 | |||
337 | return 0; | ||
338 | } | ||
339 | #else | ||
340 | #define spitzkbd_suspend NULL | ||
341 | #define spitzkbd_resume NULL | ||
342 | #endif | ||
343 | |||
344 | static int __devinit spitzkbd_probe(struct platform_device *dev) | ||
345 | { | ||
346 | struct spitzkbd *spitzkbd; | ||
347 | struct input_dev *input_dev; | ||
348 | int i, err = -ENOMEM; | ||
349 | |||
350 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); | ||
351 | input_dev = input_allocate_device(); | ||
352 | if (!spitzkbd || !input_dev) | ||
353 | goto fail; | ||
354 | |||
355 | platform_set_drvdata(dev, spitzkbd); | ||
356 | strcpy(spitzkbd->phys, "spitzkbd/input0"); | ||
357 | |||
358 | spin_lock_init(&spitzkbd->lock); | ||
359 | |||
360 | /* Init Keyboard rescan timer */ | ||
361 | init_timer(&spitzkbd->timer); | ||
362 | spitzkbd->timer.function = spitzkbd_timer_callback; | ||
363 | spitzkbd->timer.data = (unsigned long) spitzkbd; | ||
364 | |||
365 | /* Init Hinge Timer */ | ||
366 | init_timer(&spitzkbd->htimer); | ||
367 | spitzkbd->htimer.function = spitzkbd_hinge_timer; | ||
368 | spitzkbd->htimer.data = (unsigned long) spitzkbd; | ||
369 | |||
370 | spitzkbd->suspend_jiffies = jiffies; | ||
371 | |||
372 | spitzkbd->input = input_dev; | ||
373 | |||
374 | input_dev->name = "Spitz Keyboard"; | ||
375 | input_dev->phys = spitzkbd->phys; | ||
376 | input_dev->dev.parent = &dev->dev; | ||
377 | |||
378 | input_dev->id.bustype = BUS_HOST; | ||
379 | input_dev->id.vendor = 0x0001; | ||
380 | input_dev->id.product = 0x0001; | ||
381 | input_dev->id.version = 0x0100; | ||
382 | |||
383 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | | ||
384 | BIT_MASK(EV_PWR) | BIT_MASK(EV_SW); | ||
385 | input_dev->keycode = spitzkbd->keycode; | ||
386 | input_dev->keycodesize = sizeof(unsigned char); | ||
387 | input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode); | ||
388 | |||
389 | memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); | ||
390 | for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) | ||
391 | set_bit(spitzkbd->keycode[i], input_dev->keybit); | ||
392 | clear_bit(0, input_dev->keybit); | ||
393 | set_bit(KEY_SUSPEND, input_dev->keybit); | ||
394 | set_bit(SW_LID, input_dev->swbit); | ||
395 | set_bit(SW_TABLET_MODE, input_dev->swbit); | ||
396 | set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); | ||
397 | |||
398 | err = input_register_device(input_dev); | ||
399 | if (err) | ||
400 | goto fail; | ||
401 | |||
402 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | ||
403 | |||
404 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | ||
405 | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) { | ||
406 | pxa_gpio_mode(spitz_senses[i] | GPIO_IN); | ||
407 | if (request_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd_interrupt, | ||
408 | IRQF_DISABLED|IRQF_TRIGGER_RISING, | ||
409 | "Spitzkbd Sense", spitzkbd)) | ||
410 | printk(KERN_WARNING "spitzkbd: Can't get Sense IRQ: %d!\n", i); | ||
411 | } | ||
412 | |||
413 | /* Set Strobe lines as outputs - set high */ | ||
414 | for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) | ||
415 | pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); | ||
416 | |||
417 | pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); | ||
418 | pxa_gpio_mode(SPITZ_GPIO_ON_KEY | GPIO_IN); | ||
419 | pxa_gpio_mode(SPITZ_GPIO_SWA | GPIO_IN); | ||
420 | pxa_gpio_mode(SPITZ_GPIO_SWB | GPIO_IN); | ||
421 | |||
422 | request_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd_interrupt, | ||
423 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
424 | "Spitzkbd Sync", spitzkbd); | ||
425 | request_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd_interrupt, | ||
426 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
427 | "Spitzkbd PwrOn", spitzkbd); | ||
428 | request_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd_hinge_isr, | ||
429 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
430 | "Spitzkbd SWA", spitzkbd); | ||
431 | request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, | ||
432 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
433 | "Spitzkbd SWB", spitzkbd); | ||
434 | request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, | ||
435 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
436 | "Spitzkbd HP", spitzkbd); | ||
437 | |||
438 | return 0; | ||
439 | |||
440 | fail: input_free_device(input_dev); | ||
441 | kfree(spitzkbd); | ||
442 | return err; | ||
443 | } | ||
444 | |||
445 | static int __devexit spitzkbd_remove(struct platform_device *dev) | ||
446 | { | ||
447 | int i; | ||
448 | struct spitzkbd *spitzkbd = platform_get_drvdata(dev); | ||
449 | |||
450 | for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) | ||
451 | free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd); | ||
452 | |||
453 | free_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd); | ||
454 | free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd); | ||
455 | free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd); | ||
456 | free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd); | ||
457 | free_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd); | ||
458 | |||
459 | del_timer_sync(&spitzkbd->htimer); | ||
460 | del_timer_sync(&spitzkbd->timer); | ||
461 | |||
462 | input_unregister_device(spitzkbd->input); | ||
463 | |||
464 | kfree(spitzkbd); | ||
465 | |||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static struct platform_driver spitzkbd_driver = { | ||
470 | .probe = spitzkbd_probe, | ||
471 | .remove = __devexit_p(spitzkbd_remove), | ||
472 | .suspend = spitzkbd_suspend, | ||
473 | .resume = spitzkbd_resume, | ||
474 | .driver = { | ||
475 | .name = "spitz-keyboard", | ||
476 | .owner = THIS_MODULE, | ||
477 | }, | ||
478 | }; | ||
479 | |||
480 | static int __init spitzkbd_init(void) | ||
481 | { | ||
482 | return platform_driver_register(&spitzkbd_driver); | ||
483 | } | ||
484 | |||
485 | static void __exit spitzkbd_exit(void) | ||
486 | { | ||
487 | platform_driver_unregister(&spitzkbd_driver); | ||
488 | } | ||
489 | |||
490 | module_init(spitzkbd_init); | ||
491 | module_exit(spitzkbd_exit); | ||
492 | |||
493 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | ||
494 | MODULE_DESCRIPTION("Spitz Keyboard Driver"); | ||
495 | MODULE_LICENSE("GPL v2"); | ||
496 | MODULE_ALIAS("platform:spitz-keyboard"); | ||
diff --git a/drivers/input/keyboard/tosakbd.c b/drivers/input/keyboard/tosakbd.c deleted file mode 100644 index 3910f269cfc..00000000000 --- a/drivers/input/keyboard/tosakbd.c +++ /dev/null | |||
@@ -1,431 +0,0 @@ | |||
1 | /* | ||
2 | * Keyboard driver for Sharp Tosa models (SL-6000x) | ||
3 | * | ||
4 | * Copyright (c) 2005 Dirk Opfer | ||
5 | * Copyright (c) 2007 Dmitry Baryshkov | ||
6 | * | ||
7 | * Based on xtkbd.c/locomkbd.c/corgikbd.c | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/input.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #include <mach/gpio.h> | ||
24 | #include <mach/tosa.h> | ||
25 | |||
26 | #define KB_ROWMASK(r) (1 << (r)) | ||
27 | #define SCANCODE(r, c) (((r)<<4) + (c) + 1) | ||
28 | #define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1 | ||
29 | |||
30 | #define SCAN_INTERVAL (HZ/10) | ||
31 | |||
32 | #define KB_DISCHARGE_DELAY 10 | ||
33 | #define KB_ACTIVATE_DELAY 10 | ||
34 | |||
35 | static unsigned short tosakbd_keycode[NR_SCANCODES] = { | ||
36 | 0, | ||
37 | 0, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P, | ||
38 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
39 | KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA, | ||
40 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
41 | KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT, | ||
42 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
43 | KEY_Z, KEY_C, KEY_V, KEY_J, TOSA_KEY_ADDRESSBOOK, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK, | ||
44 | KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0, | ||
45 | KEY_S, KEY_R, KEY_B, KEY_N, TOSA_KEY_CALENDAR, TOSA_KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT, | ||
46 | 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, | ||
47 | KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0, | ||
48 | 0, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0, | ||
49 | KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, TOSA_KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT, | ||
50 | 0, 0, 0, | ||
51 | }; | ||
52 | |||
53 | struct tosakbd { | ||
54 | unsigned short keycode[ARRAY_SIZE(tosakbd_keycode)]; | ||
55 | struct input_dev *input; | ||
56 | bool suspended; | ||
57 | spinlock_t lock; /* protect kbd scanning */ | ||
58 | struct timer_list timer; | ||
59 | }; | ||
60 | |||
61 | |||
62 | /* Helper functions for reading the keyboard matrix | ||
63 | * Note: We should really be using the generic gpio functions to alter | ||
64 | * GPDR but it requires a function call per GPIO bit which is | ||
65 | * excessive when we need to access 12 bits at once, multiple times. | ||
66 | * These functions must be called within local_irq_save()/local_irq_restore() | ||
67 | * or similar. | ||
68 | */ | ||
69 | #define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT) | ||
70 | |||
71 | static inline void tosakbd_discharge_all(void) | ||
72 | { | ||
73 | /* STROBE All HiZ */ | ||
74 | GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT; | ||
75 | GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT; | ||
76 | GPCR2 = TOSA_GPIO_LOW_STROBE_BIT; | ||
77 | GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT; | ||
78 | } | ||
79 | |||
80 | static inline void tosakbd_activate_all(void) | ||
81 | { | ||
82 | /* STROBE ALL -> High */ | ||
83 | GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT; | ||
84 | GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT; | ||
85 | GPSR2 = TOSA_GPIO_LOW_STROBE_BIT; | ||
86 | GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT; | ||
87 | |||
88 | udelay(KB_DISCHARGE_DELAY); | ||
89 | |||
90 | /* STATE CLEAR */ | ||
91 | GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT; | ||
92 | } | ||
93 | |||
94 | static inline void tosakbd_activate_col(int col) | ||
95 | { | ||
96 | if (col <= 5) { | ||
97 | /* STROBE col -> High, not col -> HiZ */ | ||
98 | GPSR1 = TOSA_GPIO_STROBE_BIT(col); | ||
99 | GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
100 | } else { | ||
101 | /* STROBE col -> High, not col -> HiZ */ | ||
102 | GPSR2 = TOSA_GPIO_STROBE_BIT(col); | ||
103 | GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | static inline void tosakbd_reset_col(int col) | ||
108 | { | ||
109 | if (col <= 5) { | ||
110 | /* STROBE col -> Low */ | ||
111 | GPCR1 = TOSA_GPIO_STROBE_BIT(col); | ||
112 | /* STROBE col -> out, not col -> HiZ */ | ||
113 | GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
114 | } else { | ||
115 | /* STROBE col -> Low */ | ||
116 | GPCR2 = TOSA_GPIO_STROBE_BIT(col); | ||
117 | /* STROBE col -> out, not col -> HiZ */ | ||
118 | GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col); | ||
119 | } | ||
120 | } | ||
121 | /* | ||
122 | * The tosa keyboard only generates interrupts when a key is pressed. | ||
123 | * So when a key is pressed, we enable a timer. This timer scans the | ||
124 | * keyboard, and this is how we detect when the key is released. | ||
125 | */ | ||
126 | |||
127 | /* Scan the hardware keyboard and push any changes up through the input layer */ | ||
128 | static void tosakbd_scankeyboard(struct platform_device *dev) | ||
129 | { | ||
130 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
131 | unsigned int row, col, rowd; | ||
132 | unsigned long flags; | ||
133 | unsigned int num_pressed = 0; | ||
134 | |||
135 | spin_lock_irqsave(&tosakbd->lock, flags); | ||
136 | |||
137 | if (tosakbd->suspended) | ||
138 | goto out; | ||
139 | |||
140 | for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) { | ||
141 | /* | ||
142 | * Discharge the output driver capacitatance | ||
143 | * in the keyboard matrix. (Yes it is significant..) | ||
144 | */ | ||
145 | tosakbd_discharge_all(); | ||
146 | udelay(KB_DISCHARGE_DELAY); | ||
147 | |||
148 | tosakbd_activate_col(col); | ||
149 | udelay(KB_ACTIVATE_DELAY); | ||
150 | |||
151 | rowd = GET_ROWS_STATUS(col); | ||
152 | |||
153 | for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) { | ||
154 | unsigned int scancode, pressed; | ||
155 | scancode = SCANCODE(row, col); | ||
156 | pressed = rowd & KB_ROWMASK(row); | ||
157 | |||
158 | if (pressed && !tosakbd->keycode[scancode]) | ||
159 | dev_warn(&dev->dev, | ||
160 | "unhandled scancode: 0x%02x\n", | ||
161 | scancode); | ||
162 | |||
163 | input_report_key(tosakbd->input, | ||
164 | tosakbd->keycode[scancode], | ||
165 | pressed); | ||
166 | if (pressed) | ||
167 | num_pressed++; | ||
168 | } | ||
169 | |||
170 | tosakbd_reset_col(col); | ||
171 | } | ||
172 | |||
173 | tosakbd_activate_all(); | ||
174 | |||
175 | input_sync(tosakbd->input); | ||
176 | |||
177 | /* if any keys are pressed, enable the timer */ | ||
178 | if (num_pressed) | ||
179 | mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL); | ||
180 | |||
181 | out: | ||
182 | spin_unlock_irqrestore(&tosakbd->lock, flags); | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * tosa keyboard interrupt handler. | ||
187 | */ | ||
188 | static irqreturn_t tosakbd_interrupt(int irq, void *__dev) | ||
189 | { | ||
190 | struct platform_device *dev = __dev; | ||
191 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
192 | |||
193 | if (!timer_pending(&tosakbd->timer)) { | ||
194 | /** wait chattering delay **/ | ||
195 | udelay(20); | ||
196 | tosakbd_scankeyboard(dev); | ||
197 | } | ||
198 | |||
199 | return IRQ_HANDLED; | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * tosa timer checking for released keys | ||
204 | */ | ||
205 | static void tosakbd_timer_callback(unsigned long __dev) | ||
206 | { | ||
207 | struct platform_device *dev = (struct platform_device *)__dev; | ||
208 | |||
209 | tosakbd_scankeyboard(dev); | ||
210 | } | ||
211 | |||
212 | #ifdef CONFIG_PM | ||
213 | static int tosakbd_suspend(struct platform_device *dev, pm_message_t state) | ||
214 | { | ||
215 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
216 | unsigned long flags; | ||
217 | |||
218 | spin_lock_irqsave(&tosakbd->lock, flags); | ||
219 | tosakbd->suspended = true; | ||
220 | spin_unlock_irqrestore(&tosakbd->lock, flags); | ||
221 | |||
222 | del_timer_sync(&tosakbd->timer); | ||
223 | |||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | static int tosakbd_resume(struct platform_device *dev) | ||
228 | { | ||
229 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
230 | |||
231 | tosakbd->suspended = false; | ||
232 | tosakbd_scankeyboard(dev); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | #else | ||
237 | #define tosakbd_suspend NULL | ||
238 | #define tosakbd_resume NULL | ||
239 | #endif | ||
240 | |||
241 | static int __devinit tosakbd_probe(struct platform_device *pdev) { | ||
242 | |||
243 | int i; | ||
244 | struct tosakbd *tosakbd; | ||
245 | struct input_dev *input_dev; | ||
246 | int error; | ||
247 | |||
248 | tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL); | ||
249 | if (!tosakbd) | ||
250 | return -ENOMEM; | ||
251 | |||
252 | input_dev = input_allocate_device(); | ||
253 | if (!input_dev) { | ||
254 | kfree(tosakbd); | ||
255 | return -ENOMEM; | ||
256 | } | ||
257 | |||
258 | platform_set_drvdata(pdev, tosakbd); | ||
259 | |||
260 | spin_lock_init(&tosakbd->lock); | ||
261 | |||
262 | /* Init Keyboard rescan timer */ | ||
263 | init_timer(&tosakbd->timer); | ||
264 | tosakbd->timer.function = tosakbd_timer_callback; | ||
265 | tosakbd->timer.data = (unsigned long) pdev; | ||
266 | |||
267 | tosakbd->input = input_dev; | ||
268 | |||
269 | input_set_drvdata(input_dev, tosakbd); | ||
270 | input_dev->name = "Tosa Keyboard"; | ||
271 | input_dev->phys = "tosakbd/input0"; | ||
272 | input_dev->dev.parent = &pdev->dev; | ||
273 | |||
274 | input_dev->id.bustype = BUS_HOST; | ||
275 | input_dev->id.vendor = 0x0001; | ||
276 | input_dev->id.product = 0x0001; | ||
277 | input_dev->id.version = 0x0100; | ||
278 | |||
279 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
280 | input_dev->keycode = tosakbd->keycode; | ||
281 | input_dev->keycodesize = sizeof(tosakbd->keycode[0]); | ||
282 | input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode); | ||
283 | |||
284 | memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode)); | ||
285 | |||
286 | for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++) | ||
287 | __set_bit(tosakbd->keycode[i], input_dev->keybit); | ||
288 | __clear_bit(KEY_RESERVED, input_dev->keybit); | ||
289 | |||
290 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | ||
291 | for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) { | ||
292 | int gpio = TOSA_GPIO_KEY_SENSE(i); | ||
293 | int irq; | ||
294 | error = gpio_request(gpio, "tosakbd"); | ||
295 | if (error < 0) { | ||
296 | printk(KERN_ERR "tosakbd: failed to request GPIO %d, " | ||
297 | " error %d\n", gpio, error); | ||
298 | goto fail; | ||
299 | } | ||
300 | |||
301 | error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i)); | ||
302 | if (error < 0) { | ||
303 | printk(KERN_ERR "tosakbd: failed to configure input" | ||
304 | " direction for GPIO %d, error %d\n", | ||
305 | gpio, error); | ||
306 | gpio_free(gpio); | ||
307 | goto fail; | ||
308 | } | ||
309 | |||
310 | irq = gpio_to_irq(gpio); | ||
311 | if (irq < 0) { | ||
312 | error = irq; | ||
313 | printk(KERN_ERR "gpio-keys: Unable to get irq number" | ||
314 | " for GPIO %d, error %d\n", | ||
315 | gpio, error); | ||
316 | gpio_free(gpio); | ||
317 | goto fail; | ||
318 | } | ||
319 | |||
320 | error = request_irq(irq, tosakbd_interrupt, | ||
321 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | ||
322 | "tosakbd", pdev); | ||
323 | |||
324 | if (error) { | ||
325 | printk("tosakbd: Can't get IRQ: %d: error %d!\n", | ||
326 | irq, error); | ||
327 | gpio_free(gpio); | ||
328 | goto fail; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | /* Set Strobe lines as outputs - set high */ | ||
333 | for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) { | ||
334 | int gpio = TOSA_GPIO_KEY_STROBE(i); | ||
335 | error = gpio_request(gpio, "tosakbd"); | ||
336 | if (error < 0) { | ||
337 | printk(KERN_ERR "tosakbd: failed to request GPIO %d, " | ||
338 | " error %d\n", gpio, error); | ||
339 | goto fail2; | ||
340 | } | ||
341 | |||
342 | error = gpio_direction_output(gpio, 1); | ||
343 | if (error < 0) { | ||
344 | printk(KERN_ERR "tosakbd: failed to configure input" | ||
345 | " direction for GPIO %d, error %d\n", | ||
346 | gpio, error); | ||
347 | gpio_free(gpio); | ||
348 | goto fail2; | ||
349 | } | ||
350 | |||
351 | } | ||
352 | |||
353 | error = input_register_device(input_dev); | ||
354 | if (error) { | ||
355 | printk(KERN_ERR "tosakbd: Unable to register input device, " | ||
356 | "error: %d\n", error); | ||
357 | goto fail2; | ||
358 | } | ||
359 | |||
360 | printk(KERN_INFO "input: Tosa Keyboard Registered\n"); | ||
361 | |||
362 | return 0; | ||
363 | |||
364 | fail2: | ||
365 | while (--i >= 0) | ||
366 | gpio_free(TOSA_GPIO_KEY_STROBE(i)); | ||
367 | |||
368 | i = TOSA_KEY_SENSE_NUM; | ||
369 | fail: | ||
370 | while (--i >= 0) { | ||
371 | free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev); | ||
372 | gpio_free(TOSA_GPIO_KEY_SENSE(i)); | ||
373 | } | ||
374 | |||
375 | platform_set_drvdata(pdev, NULL); | ||
376 | input_free_device(input_dev); | ||
377 | kfree(tosakbd); | ||
378 | |||
379 | return error; | ||
380 | } | ||
381 | |||
382 | static int __devexit tosakbd_remove(struct platform_device *dev) | ||
383 | { | ||
384 | int i; | ||
385 | struct tosakbd *tosakbd = platform_get_drvdata(dev); | ||
386 | |||
387 | for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) | ||
388 | gpio_free(TOSA_GPIO_KEY_STROBE(i)); | ||
389 | |||
390 | for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) { | ||
391 | free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev); | ||
392 | gpio_free(TOSA_GPIO_KEY_SENSE(i)); | ||
393 | } | ||
394 | |||
395 | del_timer_sync(&tosakbd->timer); | ||
396 | |||
397 | input_unregister_device(tosakbd->input); | ||
398 | |||
399 | kfree(tosakbd); | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static struct platform_driver tosakbd_driver = { | ||
405 | .probe = tosakbd_probe, | ||
406 | .remove = __devexit_p(tosakbd_remove), | ||
407 | .suspend = tosakbd_suspend, | ||
408 | .resume = tosakbd_resume, | ||
409 | .driver = { | ||
410 | .name = "tosa-keyboard", | ||
411 | .owner = THIS_MODULE, | ||
412 | }, | ||
413 | }; | ||
414 | |||
415 | static int __devinit tosakbd_init(void) | ||
416 | { | ||
417 | return platform_driver_register(&tosakbd_driver); | ||
418 | } | ||
419 | |||
420 | static void __exit tosakbd_exit(void) | ||
421 | { | ||
422 | platform_driver_unregister(&tosakbd_driver); | ||
423 | } | ||
424 | |||
425 | module_init(tosakbd_init); | ||
426 | module_exit(tosakbd_exit); | ||
427 | |||
428 | MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>"); | ||
429 | MODULE_DESCRIPTION("Tosa Keyboard Driver"); | ||
430 | MODULE_LICENSE("GPL v2"); | ||
431 | MODULE_ALIAS("platform:tosa-keyboard"); | ||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 8a8fa4d2d6a..3d1ade2e519 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 |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 7fef7d5cca2..41145d074de 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -12,7 +12,6 @@ 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 |
17 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o | 16 | obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o |
18 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o | 17 | obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o |
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c deleted file mode 100644 index 94a1919d439..00000000000 --- 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"); | ||