aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/Kconfig11
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/spitzkbd.c478
-rw-r--r--drivers/input/touchscreen/Kconfig6
-rw-r--r--drivers/input/touchscreen/corgi_ts.c70
5 files changed, 535 insertions, 31 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index e55dee390775..444f7756fee6 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -132,6 +132,17 @@ config KEYBOARD_CORGI
132 To compile this driver as a module, choose M here: the 132 To compile this driver as a module, choose M here: the
133 module will be called corgikbd. 133 module will be called corgikbd.
134 134
135config KEYBOARD_SPITZ
136 tristate "Spitz keyboard"
137 depends on PXA_SHARPSL
138 default y
139 help
140 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000,
141 SL-C3000 and Sl-C3100 series of PDAs.
142
143 To compile this driver as a module, choose M here: the
144 module will be called spitzkbd.
145
135config KEYBOARD_MAPLE 146config KEYBOARD_MAPLE
136 tristate "Maple bus keyboard" 147 tristate "Maple bus keyboard"
137 depends on SH_DREAMCAST && MAPLE 148 depends on SH_DREAMCAST && MAPLE
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index b02eeceea3c3..9ce0b87f2fac 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o
14obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 14obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
15obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o 15obj-$(CONFIG_KEYBOARD_98KBD) += 98kbd.o
16obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o 16obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
17obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
17obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
18obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
19 20
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
new file mode 100644
index 000000000000..1714045a182b
--- /dev/null
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -0,0 +1,478 @@
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/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#include <asm/irq.h>
23
24#include <asm/arch/spitz.h>
25#include <asm/arch/hardware.h>
26#include <asm/arch/pxa-regs.h>
27
28#define KB_ROWS 7
29#define KB_COLS 11
30#define KB_ROWMASK(r) (1 << (r))
31#define SCANCODE(r,c) (((r)<<4) + (c) + 1)
32#define NR_SCANCODES ((KB_ROWS<<4) + 1)
33
34#define HINGE_SCAN_INTERVAL (150) /* ms */
35
36#define SPITZ_KEY_CALENDER KEY_F1
37#define SPITZ_KEY_ADDRESS KEY_F2
38#define SPITZ_KEY_FN KEY_F3
39#define SPITZ_KEY_CANCEL KEY_F4
40#define SPITZ_KEY_EXOK KEY_F5
41#define SPITZ_KEY_EXCANCEL KEY_F6
42#define SPITZ_KEY_EXJOGDOWN KEY_F7
43#define SPITZ_KEY_EXJOGUP KEY_F8
44#define SPITZ_KEY_JAP1 KEY_LEFTALT
45#define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
46#define SPITZ_KEY_SYNC KEY_F9
47#define SPITZ_KEY_MAIL KEY_F10
48#define SPITZ_KEY_OK KEY_F11
49#define SPITZ_KEY_MENU KEY_F12
50
51static unsigned char spitzkbd_keycode[NR_SCANCODES] = {
52 0, /* 0 */
53 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 */
54 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 */
55 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 */
56 SPITZ_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, /* 49-64 */
57 SPITZ_KEY_ADDRESS, 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 */
58 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 */
59 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 */
60};
61
62static int spitz_strobes[] = {
63 SPITZ_GPIO_KEY_STROBE0,
64 SPITZ_GPIO_KEY_STROBE1,
65 SPITZ_GPIO_KEY_STROBE2,
66 SPITZ_GPIO_KEY_STROBE3,
67 SPITZ_GPIO_KEY_STROBE4,
68 SPITZ_GPIO_KEY_STROBE5,
69 SPITZ_GPIO_KEY_STROBE6,
70 SPITZ_GPIO_KEY_STROBE7,
71 SPITZ_GPIO_KEY_STROBE8,
72 SPITZ_GPIO_KEY_STROBE9,
73 SPITZ_GPIO_KEY_STROBE10,
74};
75
76static int spitz_senses[] = {
77 SPITZ_GPIO_KEY_SENSE0,
78 SPITZ_GPIO_KEY_SENSE1,
79 SPITZ_GPIO_KEY_SENSE2,
80 SPITZ_GPIO_KEY_SENSE3,
81 SPITZ_GPIO_KEY_SENSE4,
82 SPITZ_GPIO_KEY_SENSE5,
83 SPITZ_GPIO_KEY_SENSE6,
84};
85
86struct spitzkbd {
87 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)];
88 struct input_dev input;
89 char phys[32];
90
91 spinlock_t lock;
92 struct timer_list timer;
93 struct timer_list htimer;
94
95 unsigned int suspended;
96 unsigned long suspend_jiffies;
97};
98
99#define KB_DISCHARGE_DELAY 10
100#define KB_ACTIVATE_DELAY 10
101
102/* Helper functions for reading the keyboard matrix
103 * Note: We should really be using pxa_gpio_mode to alter GPDR but it
104 * requires a function call per GPIO bit which is excessive
105 * when we need to access 11 bits at once, multiple times.
106 * These functions must be called within local_irq_save()/local_irq_restore()
107 * or similar.
108 */
109static inline void spitzkbd_discharge_all(void)
110{
111 /* STROBE All HiZ */
112 GPCR0 = SPITZ_GPIO_G0_STROBE_BIT;
113 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
114 GPCR1 = SPITZ_GPIO_G1_STROBE_BIT;
115 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
116 GPCR2 = SPITZ_GPIO_G2_STROBE_BIT;
117 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
118 GPCR3 = SPITZ_GPIO_G3_STROBE_BIT;
119 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
120}
121
122static inline void spitzkbd_activate_all(void)
123{
124 /* STROBE ALL -> High */
125 GPSR0 = SPITZ_GPIO_G0_STROBE_BIT;
126 GPDR0 |= SPITZ_GPIO_G0_STROBE_BIT;
127 GPSR1 = SPITZ_GPIO_G1_STROBE_BIT;
128 GPDR1 |= SPITZ_GPIO_G1_STROBE_BIT;
129 GPSR2 = SPITZ_GPIO_G2_STROBE_BIT;
130 GPDR2 |= SPITZ_GPIO_G2_STROBE_BIT;
131 GPSR3 = SPITZ_GPIO_G3_STROBE_BIT;
132 GPDR3 |= SPITZ_GPIO_G3_STROBE_BIT;
133
134 udelay(KB_DISCHARGE_DELAY);
135
136 /* Clear any interrupts we may have triggered when altering the GPIO lines */
137 GEDR0 = SPITZ_GPIO_G0_SENSE_BIT;
138 GEDR1 = SPITZ_GPIO_G1_SENSE_BIT;
139 GEDR2 = SPITZ_GPIO_G2_SENSE_BIT;
140 GEDR3 = SPITZ_GPIO_G3_SENSE_BIT;
141}
142
143static inline void spitzkbd_activate_col(int col)
144{
145 int gpio = spitz_strobes[col];
146 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
147 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
148 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
149 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
150 GPSR(gpio) = GPIO_bit(gpio);
151 GPDR(gpio) |= GPIO_bit(gpio);
152}
153
154static inline void spitzkbd_reset_col(int col)
155{
156 int gpio = spitz_strobes[col];
157 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
158 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
159 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
160 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
161 GPCR(gpio) = GPIO_bit(gpio);
162 GPDR(gpio) |= GPIO_bit(gpio);
163}
164
165static inline int spitzkbd_get_row_status(int col)
166{
167 return ((GPLR0 >> 12) & 0x01) | ((GPLR0 >> 16) & 0x02)
168 | ((GPLR2 >> 25) & 0x04) | ((GPLR1 << 1) & 0x08)
169 | ((GPLR1 >> 0) & 0x10) | ((GPLR1 >> 1) & 0x60);
170}
171
172/*
173 * The spitz keyboard only generates interrupts when a key is pressed.
174 * When a key is pressed, we enable a timer which then scans the
175 * keyboard to detect when the key is released.
176 */
177
178/* Scan the hardware keyboard and push any changes up through the input layer */
179static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs *regs)
180{
181 unsigned int row, col, rowd;
182 unsigned long flags;
183 unsigned int num_pressed, pwrkey = ((GPLR(SPITZ_GPIO_ON_KEY) & GPIO_bit(SPITZ_GPIO_ON_KEY)) != 0);
184
185 if (spitzkbd_data->suspended)
186 return;
187
188 spin_lock_irqsave(&spitzkbd_data->lock, flags);
189
190 if (regs)
191 input_regs(&spitzkbd_data->input, regs);
192
193 num_pressed = 0;
194 for (col = 0; col < KB_COLS; col++) {
195 /*
196 * Discharge the output driver capacitatance
197 * in the keyboard matrix. (Yes it is significant..)
198 */
199
200 spitzkbd_discharge_all();
201 udelay(KB_DISCHARGE_DELAY);
202
203 spitzkbd_activate_col(col);
204 udelay(KB_ACTIVATE_DELAY);
205
206 rowd = spitzkbd_get_row_status(col);
207 for (row = 0; row < KB_ROWS; row++) {
208 unsigned int scancode, pressed;
209
210 scancode = SCANCODE(row, col);
211 pressed = rowd & KB_ROWMASK(row);
212
213 input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);
214
215 if (pressed)
216 num_pressed++;
217 }
218 spitzkbd_reset_col(col);
219 }
220
221 spitzkbd_activate_all();
222
223 input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
224 input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey);
225
226 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) {
227 input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
228 spitzkbd_data->suspend_jiffies = jiffies;
229 }
230
231 input_sync(&spitzkbd_data->input);
232
233 /* if any keys are pressed, enable the timer */
234 if (num_pressed)
235 mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(100));
236
237 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
238}
239
240/*
241 * spitz keyboard interrupt handler.
242 */
243static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
244{
245 struct spitzkbd *spitzkbd_data = dev_id;
246
247 if (!timer_pending(&spitzkbd_data->timer)) {
248 /** wait chattering delay **/
249 udelay(20);
250 spitzkbd_scankeyboard(spitzkbd_data, regs);
251 }
252
253 return IRQ_HANDLED;
254}
255
256/*
257 * spitz timer checking for released keys
258 */
259static void spitzkbd_timer_callback(unsigned long data)
260{
261 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
262 spitzkbd_scankeyboard(spitzkbd_data, NULL);
263}
264
265/*
266 * The hinge switches generate an interrupt.
267 * We debounce the switches and pass them to the input system.
268 */
269
270static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id, struct pt_regs *regs)
271{
272 struct spitzkbd *spitzkbd_data = dev_id;
273
274 if (!timer_pending(&spitzkbd_data->htimer))
275 mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
276
277 return IRQ_HANDLED;
278}
279
280#define HINGE_STABLE_COUNT 2
281static int sharpsl_hinge_state;
282static int hinge_count;
283
284static void spitzkbd_hinge_timer(unsigned long data)
285{
286 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
287 unsigned long state;
288 unsigned long flags;
289
290 state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB));
291 if (state != sharpsl_hinge_state) {
292 hinge_count = 0;
293 sharpsl_hinge_state = state;
294 } else if (hinge_count < HINGE_STABLE_COUNT) {
295 hinge_count++;
296 }
297
298 if (hinge_count >= HINGE_STABLE_COUNT) {
299 spin_lock_irqsave(&spitzkbd_data->lock, flags);
300
301 input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
302 input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
303 input_sync(&spitzkbd_data->input);
304
305 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
306 } else {
307 mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
308 }
309}
310
311#ifdef CONFIG_PM
312static int spitzkbd_suspend(struct device *dev, pm_message_t state, uint32_t level)
313{
314 if (level == SUSPEND_POWER_DOWN) {
315 int i;
316 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
317 spitzkbd->suspended = 1;
318
319 /* Set Strobe lines as inputs - *except* strobe line 0 leave this
320 enabled so we can detect a power button press for resume */
321 for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++)
322 pxa_gpio_mode(spitz_strobes[i] | GPIO_IN);
323 }
324 return 0;
325}
326
327static int spitzkbd_resume(struct device *dev, uint32_t level)
328{
329 if (level == RESUME_POWER_ON) {
330 int i;
331 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
332
333 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
334 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
335
336 /* Upon resume, ignore the suspend key for a short while */
337 spitzkbd->suspend_jiffies = jiffies;
338 spitzkbd->suspended = 0;
339 }
340 return 0;
341}
342#else
343#define spitzkbd_suspend NULL
344#define spitzkbd_resume NULL
345#endif
346
347static int __init spitzkbd_probe(struct device *dev)
348{
349 int i;
350 struct spitzkbd *spitzkbd;
351
352 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
353 if (!spitzkbd)
354 return -ENOMEM;
355
356 dev_set_drvdata(dev,spitzkbd);
357 strcpy(spitzkbd->phys, "spitzkbd/input0");
358
359 spin_lock_init(&spitzkbd->lock);
360
361 /* Init Keyboard rescan timer */
362 init_timer(&spitzkbd->timer);
363 spitzkbd->timer.function = spitzkbd_timer_callback;
364 spitzkbd->timer.data = (unsigned long) spitzkbd;
365
366 /* Init Hinge Timer */
367 init_timer(&spitzkbd->htimer);
368 spitzkbd->htimer.function = spitzkbd_hinge_timer;
369 spitzkbd->htimer.data = (unsigned long) spitzkbd;
370
371 spitzkbd->suspend_jiffies=jiffies;
372
373 init_input_dev(&spitzkbd->input);
374 spitzkbd->input.private = spitzkbd;
375 spitzkbd->input.name = "Spitz Keyboard";
376 spitzkbd->input.dev = dev;
377 spitzkbd->input.phys = spitzkbd->phys;
378 spitzkbd->input.id.bustype = BUS_HOST;
379 spitzkbd->input.id.vendor = 0x0001;
380 spitzkbd->input.id.product = 0x0001;
381 spitzkbd->input.id.version = 0x0100;
382 spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
383 spitzkbd->input.keycode = spitzkbd->keycode;
384 spitzkbd->input.keycodesize = sizeof(unsigned char);
385 spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode);
386
387 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode));
388 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
389 set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit);
390 clear_bit(0, spitzkbd->input.keybit);
391 set_bit(SW_0, spitzkbd->input.swbit);
392 set_bit(SW_1, spitzkbd->input.swbit);
393
394 input_register_device(&spitzkbd->input);
395 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
396
397 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
398 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) {
399 pxa_gpio_mode(spitz_senses[i] | GPIO_IN);
400 if (request_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd_interrupt,
401 SA_INTERRUPT, "Spitzkbd Sense", spitzkbd))
402 printk(KERN_WARNING "spitzkbd: Can't get Sense IRQ: %d!\n", i);
403 else
404 set_irq_type(IRQ_GPIO(spitz_senses[i]),IRQT_RISING);
405 }
406
407 /* Set Strobe lines as outputs - set high */
408 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
409 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
410
411 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
412 pxa_gpio_mode(SPITZ_GPIO_ON_KEY | GPIO_IN);
413 pxa_gpio_mode(SPITZ_GPIO_SWA | GPIO_IN);
414 pxa_gpio_mode(SPITZ_GPIO_SWB | GPIO_IN);
415
416 request_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd_interrupt, SA_INTERRUPT, "Spitzkbd Sync", spitzkbd);
417 request_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd_interrupt, SA_INTERRUPT, "Spitzkbd PwrOn", spitzkbd);
418 request_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd_hinge_isr, SA_INTERRUPT, "Spitzkbd SWA", spitzkbd);
419 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, SA_INTERRUPT, "Spitzkbd SWB", spitzkbd);
420
421 set_irq_type(SPITZ_IRQ_GPIO_SYNC, IRQT_BOTHEDGE);
422 set_irq_type(SPITZ_IRQ_GPIO_ON_KEY, IRQT_BOTHEDGE);
423 set_irq_type(SPITZ_IRQ_GPIO_SWA, IRQT_BOTHEDGE);
424 set_irq_type(SPITZ_IRQ_GPIO_SWB, IRQT_BOTHEDGE);
425
426 printk(KERN_INFO "input: Spitz Keyboard Registered\n");
427
428 return 0;
429}
430
431static int spitzkbd_remove(struct device *dev)
432{
433 int i;
434 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
435
436 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++)
437 free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd);
438
439 free_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd);
440 free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd);
441 free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd);
442 free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd);
443
444 del_timer_sync(&spitzkbd->htimer);
445 del_timer_sync(&spitzkbd->timer);
446
447 input_unregister_device(&spitzkbd->input);
448
449 kfree(spitzkbd);
450
451 return 0;
452}
453
454static struct device_driver spitzkbd_driver = {
455 .name = "spitz-keyboard",
456 .bus = &platform_bus_type,
457 .probe = spitzkbd_probe,
458 .remove = spitzkbd_remove,
459 .suspend = spitzkbd_suspend,
460 .resume = spitzkbd_resume,
461};
462
463static int __devinit spitzkbd_init(void)
464{
465 return driver_register(&spitzkbd_driver);
466}
467
468static void __exit spitzkbd_exit(void)
469{
470 driver_unregister(&spitzkbd_driver);
471}
472
473module_init(spitzkbd_init);
474module_exit(spitzkbd_exit);
475
476MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
477MODULE_DESCRIPTION("Spitz Keyboard Driver");
478MODULE_LICENSE("GPLv2");
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0489af5a80c9..21d55ed4b88a 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -24,17 +24,17 @@ config TOUCHSCREEN_BITSY
24 module will be called h3600_ts_input. 24 module will be called h3600_ts_input.
25 25
26config TOUCHSCREEN_CORGI 26config TOUCHSCREEN_CORGI
27 tristate "Corgi touchscreen (for Sharp SL-C7xx)" 27 tristate "SharpSL (Corgi and Spitz series) touchscreen driver"
28 depends on PXA_SHARPSL 28 depends on PXA_SHARPSL
29 default y 29 default y
30 help 30 help
31 Say Y here to enable the driver for the touchscreen on the 31 Say Y here to enable the driver for the touchscreen on the
32 Sharp SL-C7xx series of PDAs. 32 Sharp SL-C7xx and SL-Cxx00 series of PDAs.
33 33
34 If unsure, say N. 34 If unsure, say N.
35 35
36 To compile this driver as a module, choose M here: the 36 To compile this driver as a module, choose M here: the
37 module will be called ads7846_ts. 37 module will be called corgi_ts.
38 38
39config TOUCHSCREEN_GUNZE 39config TOUCHSCREEN_GUNZE
40 tristate "Gunze AHL-51S touchscreen" 40 tristate "Gunze AHL-51S touchscreen"
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 5d19261b884f..4c7fbe550365 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Touchscreen driver for Sharp Corgi models (SL-C7xx) 2 * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models
3 * 3 *
4 * Copyright (c) 2004-2005 Richard Purdie 4 * Copyright (c) 2004-2005 Richard Purdie
5 * 5 *
@@ -19,7 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <asm/irq.h> 20#include <asm/irq.h>
21 21
22#include <asm/arch/corgi.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/arch/hardware.h> 23#include <asm/arch/hardware.h>
24#include <asm/arch/pxa-regs.h> 24#include <asm/arch/pxa-regs.h>
25 25
@@ -47,15 +47,20 @@ struct corgi_ts {
47 struct ts_event tc; 47 struct ts_event tc;
48 int pendown; 48 int pendown;
49 int power_mode; 49 int power_mode;
50 int irq_gpio;
51 struct corgits_machinfo *machinfo;
50}; 52};
51 53
52#define STATUS_HSYNC (GPLR(CORGI_GPIO_HSYNC) & GPIO_bit(CORGI_GPIO_HSYNC)) 54#ifdef CONFIG_PXA25x
53
54#define SyncHS() while((STATUS_HSYNC) == 0); while((STATUS_HSYNC) != 0);
55#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a)) 55#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a))
56#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x)) 56#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x))
57#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x)) 57#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x))
58 58#endif
59#ifdef CONFIG_PXA27x
60#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
61#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x))
62#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x))
63#endif
59 64
60/* ADS7846 Touch Screen Controller bit definitions */ 65/* ADS7846 Touch Screen Controller bit definitions */
61#define ADSCTRL_PD0 (1u << 0) /* PD0 */ 66#define ADSCTRL_PD0 (1u << 0) /* PD0 */
@@ -66,12 +71,11 @@ struct corgi_ts {
66#define ADSCTRL_STS (1u << 7) /* Start Bit */ 71#define ADSCTRL_STS (1u << 7) /* Start Bit */
67 72
68/* External Functions */ 73/* External Functions */
69extern unsigned long w100fb_get_hsynclen(struct device *dev);
70extern unsigned int get_clk_frequency_khz(int info); 74extern unsigned int get_clk_frequency_khz(int info);
71 75
72static unsigned long calc_waittime(void) 76static unsigned long calc_waittime(struct corgi_ts *corgi_ts)
73{ 77{
74 unsigned long hsync_len = w100fb_get_hsynclen(&corgifb_device.dev); 78 unsigned long hsync_len = corgi_ts->machinfo->get_hsync_len();
75 79
76 if (hsync_len) 80 if (hsync_len)
77 return get_clk_frequency_khz(0)*1000/hsync_len; 81 return get_clk_frequency_khz(0)*1000/hsync_len;
@@ -79,7 +83,8 @@ static unsigned long calc_waittime(void)
79 return 0; 83 return 0;
80} 84}
81 85
82static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int address, unsigned long wait_time) 86static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend,
87 unsigned int address, unsigned long wait_time)
83{ 88{
84 unsigned long timer1 = 0, timer2, pmnc = 0; 89 unsigned long timer1 = 0, timer2, pmnc = 0;
85 int pos = 0; 90 int pos = 0;
@@ -90,7 +95,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add
90 PMNC_SET(0x01); 95 PMNC_SET(0x01);
91 96
92 /* polling HSync */ 97 /* polling HSync */
93 SyncHS(); 98 corgi_ts->machinfo->wait_hsync();
94 /* get CCNT */ 99 /* get CCNT */
95 CCNT(timer1); 100 CCNT(timer1);
96 } 101 }
@@ -109,7 +114,7 @@ static int sync_receive_data_send_cmd(int doRecive, int doSend, unsigned int add
109 CCNT(timer2); 114 CCNT(timer2);
110 if (timer2-timer1 > wait_time) { 115 if (timer2-timer1 > wait_time) {
111 /* too slow - timeout, try again */ 116 /* too slow - timeout, try again */
112 SyncHS(); 117 corgi_ts->machinfo->wait_hsync();
113 /* get OSCR */ 118 /* get OSCR */
114 CCNT(timer1); 119 CCNT(timer1);
115 /* Wait after HSync */ 120 /* Wait after HSync */
@@ -133,23 +138,23 @@ static int read_xydata(struct corgi_ts *corgi_ts)
133 /* critical section */ 138 /* critical section */
134 local_irq_save(flags); 139 local_irq_save(flags);
135 corgi_ssp_ads7846_lock(); 140 corgi_ssp_ads7846_lock();
136 wait_time=calc_waittime(); 141 wait_time = calc_waittime(corgi_ts);
137 142
138 /* Y-axis */ 143 /* Y-axis */
139 sync_receive_data_send_cmd(0, 1, 1u, wait_time); 144 sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time);
140 145
141 /* Y-axis */ 146 /* Y-axis */
142 sync_receive_data_send_cmd(1, 1, 1u, wait_time); 147 sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time);
143 148
144 /* X-axis */ 149 /* X-axis */
145 y = sync_receive_data_send_cmd(1, 1, 5u, wait_time); 150 y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time);
146 151
147 /* Z1 */ 152 /* Z1 */
148 x = sync_receive_data_send_cmd(1, 1, 3u, wait_time); 153 x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time);
149 154
150 /* Z2 */ 155 /* Z2 */
151 z1 = sync_receive_data_send_cmd(1, 1, 4u, wait_time); 156 z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time);
152 z2 = sync_receive_data_send_cmd(1, 0, 4u, wait_time); 157 z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time);
153 158
154 /* Power-Down Enable */ 159 /* Power-Down Enable */
155 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 160 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
@@ -189,9 +194,9 @@ static void new_data(struct corgi_ts *corgi_ts, struct pt_regs *regs)
189 194
190static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) 195static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs)
191{ 196{
192 if ((GPLR(CORGI_GPIO_TP_INT) & GPIO_bit(CORGI_GPIO_TP_INT)) == 0) { 197 if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) {
193 /* Disable Interrupt */ 198 /* Disable Interrupt */
194 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_NOEDGE); 199 set_irq_type(corgi_ts->irq_gpio, IRQT_NOEDGE);
195 if (read_xydata(corgi_ts)) { 200 if (read_xydata(corgi_ts)) {
196 corgi_ts->pendown = 1; 201 corgi_ts->pendown = 1;
197 new_data(corgi_ts, regs); 202 new_data(corgi_ts, regs);
@@ -210,7 +215,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_
210 } 215 }
211 216
212 /* Enable Falling Edge */ 217 /* Enable Falling Edge */
213 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 218 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
214 corgi_ts->pendown = 0; 219 corgi_ts->pendown = 0;
215 } 220 }
216} 221}
@@ -254,7 +259,7 @@ static int corgits_resume(struct device *dev, uint32_t level)
254 259
255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 260 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
256 /* Enable Falling Edge */ 261 /* Enable Falling Edge */
257 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 262 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
258 corgi_ts->power_mode = PWR_MODE_ACTIVE; 263 corgi_ts->power_mode = PWR_MODE_ACTIVE;
259 } 264 }
260 return 0; 265 return 0;
@@ -267,6 +272,7 @@ static int corgits_resume(struct device *dev, uint32_t level)
267static int __init corgits_probe(struct device *dev) 272static int __init corgits_probe(struct device *dev)
268{ 273{
269 struct corgi_ts *corgi_ts; 274 struct corgi_ts *corgi_ts;
275 struct platform_device *pdev = to_platform_device(dev);
270 276
271 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL))) 277 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL)))
272 return -ENOMEM; 278 return -ENOMEM;
@@ -275,6 +281,14 @@ static int __init corgits_probe(struct device *dev)
275 281
276 memset(corgi_ts, 0, sizeof(struct corgi_ts)); 282 memset(corgi_ts, 0, sizeof(struct corgi_ts));
277 283
284 corgi_ts->machinfo = dev->platform_data;
285 corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
286
287 if (corgi_ts->irq_gpio < 0) {
288 kfree(corgi_ts);
289 return -ENODEV;
290 }
291
278 init_input_dev(&corgi_ts->input); 292 init_input_dev(&corgi_ts->input);
279 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 293 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
280 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 294 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
@@ -293,8 +307,7 @@ static int __init corgits_probe(struct device *dev)
293 corgi_ts->input.id.product = 0x0002; 307 corgi_ts->input.id.product = 0x0002;
294 corgi_ts->input.id.version = 0x0100; 308 corgi_ts->input.id.version = 0x0100;
295 309
296 pxa_gpio_mode(CORGI_GPIO_TP_INT | GPIO_IN); 310 pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN);
297 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
298 311
299 /* Initiaize ADS7846 Difference Reference mode */ 312 /* Initiaize ADS7846 Difference Reference mode */
300 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 313 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
@@ -313,14 +326,14 @@ static int __init corgits_probe(struct device *dev)
313 input_register_device(&corgi_ts->input); 326 input_register_device(&corgi_ts->input);
314 corgi_ts->power_mode = PWR_MODE_ACTIVE; 327 corgi_ts->power_mode = PWR_MODE_ACTIVE;
315 328
316 if (request_irq(CORGI_IRQ_GPIO_TP_INT, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { 329 if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) {
317 input_unregister_device(&corgi_ts->input); 330 input_unregister_device(&corgi_ts->input);
318 kfree(corgi_ts); 331 kfree(corgi_ts);
319 return -EBUSY; 332 return -EBUSY;
320 } 333 }
321 334
322 /* Enable Falling Edge */ 335 /* Enable Falling Edge */
323 set_irq_type(CORGI_IRQ_GPIO_TP_INT, IRQT_FALLING); 336 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
324 337
325 printk(KERN_INFO "input: Corgi Touchscreen Registered\n"); 338 printk(KERN_INFO "input: Corgi Touchscreen Registered\n");
326 339
@@ -331,8 +344,9 @@ static int corgits_remove(struct device *dev)
331{ 344{
332 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 345 struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
333 346
334 free_irq(CORGI_IRQ_GPIO_TP_INT, NULL); 347 free_irq(corgi_ts->irq_gpio, NULL);
335 del_timer_sync(&corgi_ts->timer); 348 del_timer_sync(&corgi_ts->timer);
349 corgi_ts->machinfo->put_hsync();
336 input_unregister_device(&corgi_ts->input); 350 input_unregister_device(&corgi_ts->input);
337 kfree(corgi_ts); 351 kfree(corgi_ts);
338 return 0; 352 return 0;