diff options
-rw-r--r-- | drivers/input/keyboard/Kconfig | 10 | ||||
-rw-r--r-- | drivers/input/keyboard/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/keyboard/jornada720_kbd.c | 181 |
3 files changed, 192 insertions, 0 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 1881900f24c8..18303f2bbafd 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -219,6 +219,16 @@ config KEYBOARD_HP6XX | |||
219 | To compile this driver as a module, choose M here: the | 219 | To compile this driver as a module, choose M here: the |
220 | module will be called jornada680_kbd. | 220 | module will be called jornada680_kbd. |
221 | 221 | ||
222 | config KEYBOARD_HP7XX | ||
223 | tristate "HP Jornada 7XX Keyboard Driver" | ||
224 | depends on SA1100_JORNADA720_SSP && SA1100_SSP | ||
225 | help | ||
226 | Say Y here to add support for the HP Jornada 7xx (710/720/728) | ||
227 | onboard keyboard. | ||
228 | |||
229 | To compile this driver as a module, choose M here: the | ||
230 | module will be called jornada720_kbd. | ||
231 | |||
222 | config KEYBOARD_OMAP | 232 | config KEYBOARD_OMAP |
223 | tristate "TI OMAP keypad support" | 233 | tristate "TI OMAP keypad support" |
224 | depends on (ARCH_OMAP1 || ARCH_OMAP2) | 234 | depends on (ARCH_OMAP1 || ARCH_OMAP2) |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 7ecd2b05a28a..4cc7dc947db1 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -22,4 +22,5 @@ obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keyboard.o | |||
22 | obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o | 22 | obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o |
23 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o | 23 | obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o |
24 | obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o | 24 | obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o |
25 | obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o | ||
25 | 26 | ||
diff --git a/drivers/input/keyboard/jornada720_kbd.c b/drivers/input/keyboard/jornada720_kbd.c new file mode 100644 index 000000000000..dd8a037f7281 --- /dev/null +++ b/drivers/input/keyboard/jornada720_kbd.c | |||
@@ -0,0 +1,181 @@ | |||
1 | /* | ||
2 | * drivers/input/keyboard/jornada720_kbd.c | ||
3 | * | ||
4 | * HP Jornada 720 keyboard platform driver | ||
5 | * | ||
6 | * Copyright (C) 2006/2007 Kristoffer Ericson <Kristoffer.Ericson@Gmail.com> | ||
7 | * | ||
8 | * Copyright (C) 2006 jornada 720 kbd driver by | ||
9 | Filip Zyzniewsk <Filip.Zyzniewski@tefnet.plX | ||
10 | * based on (C) 2004 jornada 720 kbd driver by | ||
11 | Alex Lange <chicken@handhelds.org> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License version 2 as | ||
15 | * published by the Free Software Foundation. | ||
16 | * | ||
17 | */ | ||
18 | #include <linux/device.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/input.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | #include <asm/arch/jornada720.h> | ||
29 | #include <asm/hardware.h> | ||
30 | |||
31 | MODULE_AUTHOR("Kristoffer Ericson <Kristoffer.Ericson@gmail.com>"); | ||
32 | MODULE_DESCRIPTION("HP Jornada 710/720/728 keyboard driver"); | ||
33 | MODULE_LICENSE("GPLv2"); | ||
34 | |||
35 | static unsigned short jornada_std_keymap[128] = { /* ROW */ | ||
36 | 0, KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, /* #1 */ | ||
37 | KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_MUTE, /* -> */ | ||
38 | 0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, /* #2 */ | ||
39 | KEY_0, KEY_MINUS, KEY_EQUAL,0, 0, 0, /* -> */ | ||
40 | 0, KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_U, KEY_I, KEY_O, /* #3 */ | ||
41 | KEY_P, KEY_BACKSLASH, KEY_BACKSPACE, 0, 0, 0, /* -> */ | ||
42 | 0, KEY_A, KEY_S, KEY_D, KEY_F, KEY_G, KEY_H, KEY_J, KEY_K, KEY_L, /* #4 */ | ||
43 | KEY_SEMICOLON, KEY_LEFTBRACE, KEY_RIGHTBRACE, 0, 0, 0, /* -> */ | ||
44 | 0, KEY_Z, KEY_X, KEY_C, KEY_V, KEY_B, KEY_N, KEY_M, KEY_COMMA, /* #5 */ | ||
45 | KEY_DOT, KEY_KPMINUS, KEY_APOSTROPHE, KEY_ENTER, 0, 0,0, /* -> */ | ||
46 | 0, KEY_TAB, 0, KEY_LEFTSHIFT, 0, KEY_APOSTROPHE, 0, 0, 0, 0, /* #6 */ | ||
47 | KEY_UP, 0, KEY_RIGHTSHIFT, 0, 0, 0,0, 0, 0, 0, 0, KEY_LEFTALT, KEY_GRAVE, /* -> */ | ||
48 | 0, 0, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0,0, KEY_KPASTERISK, /* -> */ | ||
49 | KEY_LEFTCTRL, 0, KEY_SPACE, 0, 0, 0, KEY_SLASH, KEY_DELETE, 0, 0, /* -> */ | ||
50 | 0, 0, 0, KEY_POWER, /* -> */ | ||
51 | }; | ||
52 | |||
53 | struct jornadakbd { | ||
54 | unsigned short keymap[ARRAY_SIZE(jornada_std_keymap)]; | ||
55 | struct input_dev *input; | ||
56 | }; | ||
57 | |||
58 | static irqreturn_t jornada720_kbd_interrupt(int irq, void *dev_id) | ||
59 | { | ||
60 | struct platform_device *pdev = dev_id; | ||
61 | struct jornadakbd *jornadakbd = platform_get_drvdata(pdev); | ||
62 | u8 count, kbd_data; | ||
63 | |||
64 | /* startup ssp with spinlock */ | ||
65 | jornada_ssp_start(); | ||
66 | |||
67 | if (jornada_ssp_inout(GETSCANKEYCODE) != TXDUMMY) { | ||
68 | printk(KERN_DEBUG | ||
69 | "jornada720_kbd: " | ||
70 | "GetKeycode command failed with ETIMEDOUT, " | ||
71 | "flushed bus\n"); | ||
72 | } else { | ||
73 | /* How many keycodes are waiting for us? */ | ||
74 | count = jornada_ssp_byte(TXDUMMY); | ||
75 | |||
76 | /* Lets drag them out one at a time */ | ||
77 | while (count--) { | ||
78 | /* Exchange TxDummy for location (keymap[kbddata]) */ | ||
79 | kbd_data = jornada_ssp_byte(TXDUMMY); | ||
80 | |||
81 | input_report_key(jornadakbd->input, | ||
82 | jornadakbd->keymap[kbd_data & 0x7f], | ||
83 | !(kbd_data & 0x80)); | ||
84 | input_sync(jornadakbd->input); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | /* release spinlock and turn off ssp */ | ||
89 | jornada_ssp_end(); | ||
90 | |||
91 | return IRQ_HANDLED; | ||
92 | }; | ||
93 | |||
94 | static int __devinit jornada720_kbd_probe(struct platform_device *pdev) | ||
95 | { | ||
96 | struct jornadakbd *jornadakbd; | ||
97 | struct input_dev *input_dev; | ||
98 | int i, err; | ||
99 | |||
100 | jornadakbd = kzalloc(sizeof(struct jornadakbd), GFP_KERNEL); | ||
101 | input_dev = input_allocate_device(); | ||
102 | if (!jornadakbd || !input_dev) { | ||
103 | err = -ENOMEM; | ||
104 | goto fail1; | ||
105 | } | ||
106 | |||
107 | platform_set_drvdata(pdev, jornadakbd); | ||
108 | |||
109 | memcpy(jornadakbd->keymap, jornada_std_keymap, | ||
110 | sizeof(jornada_std_keymap)); | ||
111 | jornadakbd->input = input_dev; | ||
112 | |||
113 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
114 | input_dev->name = "HP Jornada 720 keyboard"; | ||
115 | input_dev->phys = "jornadakbd/input0"; | ||
116 | input_dev->keycode = jornadakbd->keymap; | ||
117 | input_dev->keycodesize = sizeof(unsigned short); | ||
118 | input_dev->keycodemax = ARRAY_SIZE(jornada_std_keymap); | ||
119 | input_dev->id.bustype = BUS_HOST; | ||
120 | input_dev->dev.parent = &pdev->dev; | ||
121 | |||
122 | for (i = 0; i < ARRAY_SIZE(jornadakbd->keymap); i++) | ||
123 | __set_bit(jornadakbd->keymap[i], input_dev->keybit); | ||
124 | __clear_bit(KEY_RESERVED, input_dev->keybit); | ||
125 | |||
126 | err = request_irq(IRQ_GPIO0, | ||
127 | jornada720_kbd_interrupt, | ||
128 | IRQF_DISABLED | IRQF_TRIGGER_FALLING, | ||
129 | "jornadakbd", pdev); | ||
130 | if (err) { | ||
131 | printk(KERN_INFO "jornadakbd720_kbd: Unable to grab IRQ\n"); | ||
132 | goto fail1; | ||
133 | } | ||
134 | |||
135 | err = input_register_device(jornadakbd->input); | ||
136 | if (err) | ||
137 | goto fail2; | ||
138 | |||
139 | return 0; | ||
140 | |||
141 | fail2: /* IRQ, DEVICE, MEMORY */ | ||
142 | free_irq(IRQ_GPIO0, pdev); | ||
143 | fail1: /* DEVICE, MEMORY */ | ||
144 | platform_set_drvdata(pdev, NULL); | ||
145 | input_free_device(input_dev); | ||
146 | kfree(jornadakbd); | ||
147 | return err; | ||
148 | }; | ||
149 | |||
150 | static int __devexit jornada720_kbd_remove(struct platform_device *pdev) | ||
151 | { | ||
152 | struct jornadakbd *jornadakbd = platform_get_drvdata(pdev); | ||
153 | |||
154 | free_irq(IRQ_GPIO0, pdev); | ||
155 | platform_set_drvdata(pdev, NULL); | ||
156 | input_unregister_device(jornadakbd->input); | ||
157 | kfree(jornadakbd); | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static struct platform_driver jornada720_kbd_driver = { | ||
163 | .driver = { | ||
164 | .name = "jornada720_kbd", | ||
165 | }, | ||
166 | .probe = jornada720_kbd_probe, | ||
167 | .remove = __devexit_p(jornada720_kbd_remove), | ||
168 | }; | ||
169 | |||
170 | static int __init jornada720_kbd_init(void) | ||
171 | { | ||
172 | return platform_driver_register(&jornada720_kbd_driver); | ||
173 | } | ||
174 | |||
175 | static void __exit jornada720_kbd_exit(void) | ||
176 | { | ||
177 | platform_driver_unregister(&jornada720_kbd_driver); | ||
178 | } | ||
179 | |||
180 | module_init(jornada720_kbd_init); | ||
181 | module_exit(jornada720_kbd_exit); | ||