diff options
Diffstat (limited to 'drivers/input/keyboard/spitzkbd.c')
-rw-r--r-- | drivers/input/keyboard/spitzkbd.c | 496 |
1 files changed, 0 insertions, 496 deletions
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c deleted file mode 100644 index 13967422658c..000000000000 --- 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"); | ||