add support for target 3c24xx (more known as Openmoko GTA02 "Freerunner") and merge...
[openwrt/openwrt.git] / target / linux / s3c24xx / patches / 0100-Add-GPIO-IRQ-for-the-s3c2410-and-add-irq_to_gpio.patch
1 From d0342f6cc0388862a8e62b4b77f1c4c011385e9a Mon Sep 17 00:00:00 2001
2 From: Holger Freyther <zecke@openmoko.org>
3 Date: Fri, 25 Jul 2008 23:06:03 +0100
4 Subject: [PATCH] Add GPIO -> IRQ for the s3c2410 and add irq_to_gpio to the gpio.h of the Samsung SoC
5
6 Use this irq_to_gpio in the neo1973 keyboard driver
7 ---
8 drivers/input/keyboard/neo1973kbd.c | 19 ++++++-------------
9 include/asm-arm/arch-s3c2410/gpio.h | 5 ++---
10 2 files changed, 8 insertions(+), 16 deletions(-)
11
12 diff --git a/drivers/input/keyboard/neo1973kbd.c b/drivers/input/keyboard/neo1973kbd.c
13 index b413bc8..06fa8e0 100644
14 --- a/drivers/input/keyboard/neo1973kbd.c
15 +++ b/drivers/input/keyboard/neo1973kbd.c
16 @@ -28,16 +28,13 @@
17 struct neo1973kbd {
18 struct input_dev *input;
19 unsigned int suspended;
20 - int gpio_aux;
21 - int gpio_hold;
22 - int gpio_jack;
23 };
24
25 static irqreturn_t neo1973kbd_aux_irq(int irq, void *dev_id)
26 {
27 struct neo1973kbd *neo1973kbd_data = dev_id;
28
29 - int key_pressed = !gpio_get_value(neo1973kbd_data->gpio_aux);
30 + int key_pressed = !gpio_get_value(irq_to_gpio(irq));
31 input_report_key(neo1973kbd_data->input, KEY_PHONE, key_pressed);
32 input_sync(neo1973kbd_data->input);
33
34 @@ -48,7 +45,7 @@ static irqreturn_t neo1973kbd_hold_irq(int irq, void *dev_id)
35 {
36 struct neo1973kbd *neo1973kbd_data = dev_id;
37
38 - int key_pressed = gpio_get_value(neo1973kbd_data->gpio_hold);
39 + int key_pressed = gpio_get_value(irq_to_gpio(irq));
40 input_report_key(neo1973kbd_data->input, KEY_PAUSE, key_pressed);
41 input_sync(neo1973kbd_data->input);
42
43 @@ -59,7 +56,7 @@ static irqreturn_t neo1973kbd_headphone_irq(int irq, void *dev_id)
44 {
45 struct neo1973kbd *neo1973kbd_data = dev_id;
46
47 - int key_pressed = gpio_get_value(neo1973kbd_data->gpio_jack);
48 + int key_pressed = gpio_get_value(irq_to_gpio(irq));
49 input_report_switch(neo1973kbd_data->input,
50 SW_HEADPHONE_INSERT, key_pressed);
51 input_sync(neo1973kbd_data->input);
52 @@ -107,19 +104,15 @@ static int neo1973kbd_probe(struct platform_device *pdev)
53 if (pdev->resource[0].flags != 0)
54 return -EINVAL;
55
56 - neo1973kbd->gpio_aux = pdev->resource[0].start;
57 - neo1973kbd->gpio_hold = pdev->resource[1].start;
58 - neo1973kbd->gpio_jack = pdev->resource[2].start;
59 -
60 - irq_aux = gpio_to_irq(neo1973kbd->gpio_aux);
61 + irq_aux = gpio_to_irq(pdev->resource[0].start);
62 if (irq_aux < 0)
63 return -EINVAL;
64
65 - irq_hold = gpio_to_irq(neo1973kbd->gpio_hold);
66 + irq_hold = gpio_to_irq(pdev->resource[1].start);
67 if (irq_hold < 0)
68 return -EINVAL;
69
70 - irq_jack = gpio_to_irq(neo1973kbd->gpio_jack);
71 + irq_jack = gpio_to_irq(pdev->resource[2].start);
72 if (irq_jack < 0)
73 return -EINVAL;
74
75 diff --git a/include/asm-arm/arch-s3c2410/gpio.h b/include/asm-arm/arch-s3c2410/gpio.h
76 index 7583895..1b96c4e 100644
77 --- a/include/asm-arm/arch-s3c2410/gpio.h
78 +++ b/include/asm-arm/arch-s3c2410/gpio.h
79 @@ -61,8 +61,7 @@ static inline int gpio_direction_output(unsigned gpio, int value)
80 #define gpio_to_irq(gpio) s3c2400_gpio_getirq(gpio)
81 #else
82 #define gpio_to_irq(gpio) s3c2410_gpio_getirq(gpio)
83 +#define irq_to_gpio(irq) s3c2410_irq_to_gpio(irq)
84 #endif
85 -
86 -/* FIXME implement irq_to_gpio() */
87 -
88 #endif
89 +#include <asm-generic/gpio.h>
90 --
91 1.5.6.3
92