[ar71xx] remove duplicated includes
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1050-s3c2410-qt2410-buttons.patch.patch
1 From 9deba66bfaf3a3293436e405830a666df8f36ed6 Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Sun, 13 Apr 2008 07:23:49 +0100
4 Subject: [PATCH] s3c2410-qt2410-buttons.patch
5
6 ---
7 arch/arm/mach-s3c2410/mach-qt2410.c | 18 +++
8 drivers/input/keyboard/Kconfig | 5 +
9 drivers/input/keyboard/Makefile | 1 +
10 drivers/input/keyboard/qt2410kbd.c | 233 +++++++++++++++++++++++++++++++++++
11 4 files changed, 257 insertions(+), 0 deletions(-)
12 create mode 100644 drivers/input/keyboard/qt2410kbd.c
13
14 diff --git a/arch/arm/mach-s3c2410/mach-qt2410.c b/arch/arm/mach-s3c2410/mach-qt2410.c
15 index 6f7b56d..daf94cd 100644
16 --- a/arch/arm/mach-s3c2410/mach-qt2410.c
17 +++ b/arch/arm/mach-s3c2410/mach-qt2410.c
18 @@ -321,6 +321,24 @@ static int __init qt2410_tft_setup(char *str)
19
20 __setup("tft=", qt2410_tft_setup);
21
22 +static struct resource qt2410_button_resources[] = {
23 + [0] = {
24 + .start = S3C2410_GPF0,
25 + .end = S3C2410_GPF0,
26 + },
27 + [1] = {
28 + .start = S3C2410_GPF2,
29 + .end = S3C2410_GPF2,
30 + },
31 +};
32 +
33 +struct platform_device qt2410_button_dev = {
34 + .name ="qt2410-button",
35 + .num_resources = ARRAY_SIZE(qt2410_button_resources),
36 + .resource = qt2410_button_resources,
37 +};
38 +
39 +
40 static void __init qt2410_map_io(void)
41 {
42 s3c24xx_init_io(qt2410_iodesc, ARRAY_SIZE(qt2410_iodesc));
43 diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
44 index 3b9990e..a61ca45 100644
45 --- a/drivers/input/keyboard/Kconfig
46 +++ b/drivers/input/keyboard/Kconfig
47 @@ -304,5 +304,10 @@ config KEYBOARD_NEO1973
48 To compile this driver as a module, choose M here: the
49 module will be called neo1973kbd.
50
51 +config KEYBOARD_QT2410
52 + tristate "QT2410 buttons"
53 + depends on MACH_QT2410
54 + default y
55 +
56
57 endif
58 diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
59 index 68ecfc5..34bfc33 100644
60 --- a/drivers/input/keyboard/Makefile
61 +++ b/drivers/input/keyboard/Makefile
62 @@ -15,6 +15,7 @@ obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
63 obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
64 obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
65 obj-$(CONFIG_KEYBOARD_NEO1973) += neo1973kbd.o
66 +obj-$(CONFIG_KEYBOARD_QT2410) += qt2410kbd.o
67 obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
68 obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
69 obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
70 diff --git a/drivers/input/keyboard/qt2410kbd.c b/drivers/input/keyboard/qt2410kbd.c
71 new file mode 100644
72 index 0000000..4d497a3
73 --- /dev/null
74 +++ b/drivers/input/keyboard/qt2410kbd.c
75 @@ -0,0 +1,233 @@
76 +/*
77 + * Keyboard driver for Armzone QT2410
78 + *
79 + * (C) 2006 by OpenMoko, Inc.
80 + * Author: Harald Welte <laforge@openmoko.org>
81 + * All rights reserved.
82 + *
83 + * This program is free software; you can redistribute it and/or modify
84 + * it under the terms of the GNU General Public License version 2 as
85 + * published by the Free Software Foundation.
86 + *
87 + */
88 +
89 +#include <linux/delay.h>
90 +#include <linux/platform_device.h>
91 +#include <linux/init.h>
92 +#include <linux/input.h>
93 +#include <linux/interrupt.h>
94 +#include <linux/jiffies.h>
95 +#include <linux/module.h>
96 +#include <linux/slab.h>
97 +
98 +#include <asm/hardware.h>
99 +#include <asm/arch/gta01.h>
100 +
101 +struct gta01kbd {
102 + struct input_dev *input;
103 + unsigned int suspended;
104 + unsigned long suspend_jiffies;
105 +};
106 +
107 +static irqreturn_t gta01kbd_interrupt(int irq, void *dev_id)
108 +{
109 + struct gta01kbd *gta01kbd_data = dev_id;
110 +
111 + /* FIXME: use GPIO from platform_dev resources */
112 + if (s3c2410_gpio_getpin(S3C2410_GPF0))
113 + input_report_key(gta01kbd_data->input, KEY_PHONE, 1);
114 + else
115 + input_report_key(gta01kbd_data->input, KEY_PHONE, 0);
116 +
117 + input_sync(gta01kbd_data->input);
118 +
119 + return IRQ_HANDLED;
120 +}
121 +
122 +
123 +#ifdef CONFIG_PM
124 +static int gta01kbd_suspend(struct platform_device *dev, pm_message_t state)
125 +{
126 + struct gta01kbd *gta01kbd = platform_get_drvdata(dev);
127 +
128 + gta01kbd->suspended = 1;
129 +
130 + return 0;
131 +}
132 +
133 +static int gta01kbd_resume(struct platform_device *dev)
134 +{
135 + struct gta01kbd *gta01kbd = platform_get_drvdata(dev);
136 +
137 + gta01kbd->suspended = 0;
138 +
139 + return 0;
140 +}
141 +#else
142 +#define gta01kbd_suspend NULL
143 +#define gta01kbd_resume NULL
144 +#endif
145 +
146 +static int gta01kbd_probe(struct platform_device *pdev)
147 +{
148 + struct gta01kbd *gta01kbd;
149 + struct input_dev *input_dev;
150 + int irq_911;
151 + int rc = 0;
152 +
153 + gta01kbd = kzalloc(sizeof(struct gta01kbd), GFP_KERNEL);
154 + if (!gta01kbd) {
155 + rc = -ENOMEM;
156 + goto bail;
157 + }
158 + input_dev = input_allocate_device();
159 + if (!gta01kbd || !input_dev) {
160 + rc = -ENOMEM;
161 + goto bail_free;
162 + }
163 +
164 + if (pdev->resource[0].flags != 0) {\
165 + rc = -EINVAL;
166 + goto bail_free_dev;
167 + }
168 +
169 + irq_911 = s3c2410_gpio_getirq(pdev->resource[0].start);
170 + if (irq_911 < 0) {
171 + rc = -EINVAL;
172 + goto bail_free_dev;
173 + }
174 +
175 + platform_set_drvdata(pdev, gta01kbd);
176 +
177 + gta01kbd->input = input_dev;
178 +
179 +#if 0
180 + spin_lock_init(&gta01kbd->lock);
181 + /* Init Keyboard rescan timer */
182 + init_timer(&corgikbd->timer);
183 + corgikbd->timer.function = corgikbd_timer_callback;
184 + corgikbd->timer.data = (unsigned long) corgikbd;
185 +
186 + /* Init Hinge Timer */
187 + init_timer(&corgikbd->htimer);
188 + corgikbd->htimer.function = corgikbd_hinge_timer;
189 + corgikbd->htimer.data = (unsigned long) corgikbd;
190 +
191 + corgikbd->suspend_jiffies=jiffies;
192 +
193 + memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode));
194 +#endif
195 +
196 + input_dev->name = "QT2410 Buttons";
197 + input_dev->phys = "qt2410kbd/input0";
198 + input_dev->id.bustype = BUS_HOST;
199 + input_dev->id.vendor = 0x0001;
200 + input_dev->id.product = 0x0001;
201 + input_dev->id.version = 0x0100;
202 + input_dev->cdev.dev = &pdev->dev;
203 + input_dev->private = gta01kbd;
204 +
205 + input_dev->evbit[0] = BIT(EV_KEY);
206 +#if 0
207 + input_dev->keycode = gta01kbd->keycode;
208 + input_dev->keycodesize = sizeof(unsigned char);
209 + input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode);
210 +
211 + for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++)
212 + set_bit(corgikbd->keycode[i], input_dev->keybit);
213 + clear_bit(0, input_dev->keybit);
214 + set_bit(SW_LID, input_dev->swbit);
215 + set_bit(SW_TABLET_MODE, input_dev->swbit);
216 + set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
217 +#endif
218 +
219 + rc = input_register_device(gta01kbd->input);
220 + if (rc)
221 + goto bail_free_dev;
222 +
223 + s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPF0_EINT0);
224 + if (request_irq(irq_911, gta01kbd_interrupt,
225 + IRQF_DISABLED | IRQF_TRIGGER_RISING |
226 + IRQF_TRIGGER_FALLING, "qt2410kbd_eint0", gta01kbd))
227 + printk(KERN_WARNING "gta01kbd: Can't get IRQ\n");
228 + enable_irq_wake(irq_911);
229 +
230 + /* FIXME: headphone insert */
231 +
232 +#if 0
233 + mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
234 +
235 + /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
236 + for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) {
237 + pxa_gpio_mode(CORGI_GPIO_KEY_SENSE(i) | GPIO_IN);
238 + if (request_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd_interrupt,
239 + SA_INTERRUPT | SA_TRIGGER_RISING,
240 + "corgikbd", corgikbd))
241 + printk(KERN_WARNING "corgikbd: Can't get IRQ: %d!\n", i);
242 + }
243 +
244 + /* Set Strobe lines as outputs - set high */
245 + for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
246 + pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
247 +
248 + /* Setup the headphone jack as an input */
249 + pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
250 +#endif
251 +
252 + return 0;
253 +
254 +bail_free_dev:
255 + input_free_device(input_dev);
256 +bail_free:
257 + kfree(gta01kbd);
258 +bail:
259 + return rc;
260 +}
261 +
262 +static int gta01kbd_remove(struct platform_device *pdev)
263 +{
264 + struct gta01kbd *gta01kbd = platform_get_drvdata(pdev);
265 +
266 + free_irq(s3c2410_gpio_getirq(pdev->resource[0].start), gta01kbd);
267 +#if 0
268 + int i;
269 +
270 + for (i = 0; i < CORGI_KEY_SENSE_NUM; i++)
271 + free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd);
272 +
273 + del_timer_sync(&corgikbd->htimer);
274 + del_timer_sync(&corgikbd->timer);
275 +#endif
276 + input_unregister_device(gta01kbd->input);
277 +
278 + kfree(gta01kbd);
279 +
280 + return 0;
281 +}
282 +
283 +static struct platform_driver gta01kbd_driver = {
284 + .probe = gta01kbd_probe,
285 + .remove = gta01kbd_remove,
286 + .suspend = gta01kbd_suspend,
287 + .resume = gta01kbd_resume,
288 + .driver = {
289 + .name = "qt2410-button",
290 + },
291 +};
292 +
293 +static int __devinit gta01kbd_init(void)
294 +{
295 + return platform_driver_register(&gta01kbd_driver);
296 +}
297 +
298 +static void __exit gta01kbd_exit(void)
299 +{
300 + platform_driver_unregister(&gta01kbd_driver);
301 +}
302 +
303 +module_init(gta01kbd_init);
304 +module_exit(gta01kbd_exit);
305 +
306 +MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
307 +MODULE_DESCRIPTION("Armzone QT2410 Buttons Driver");
308 +MODULE_LICENSE("GPL");
309 --
310 1.5.6.5
311
This page took 0.058459 seconds and 5 git commands to generate.