[ar71xx] preliminary support for the Ubiquiti RouterStation Pro
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1110-Add-GPIO-IRQ-for-the-s3c2410-and-add-irq_to_gpio.patch
1 From 5134afd82f568f1eae133069bc9298e731546bc1 Mon Sep 17 00:00:00 2001
2 From: Holger Freyther <zecke@openmoko.org>
3 Date: Sun, 13 Apr 2008 07:25:54 +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 arch/arm/plat-s3c24xx/gpio.c | 17 +++++++++++++++++
9 drivers/input/keyboard/neo1973kbd.c | 19 ++++++-------------
10 include/asm-arm/arch-s3c2410/gpio.h | 1 +
11 include/asm-arm/arch-s3c2410/hardware.h | 2 ++
12 4 files changed, 26 insertions(+), 13 deletions(-)
13
14 diff --git a/arch/arm/plat-s3c24xx/gpio.c b/arch/arm/plat-s3c24xx/gpio.c
15 index 7cab212..dfdb33a 100644
16 --- a/arch/arm/plat-s3c24xx/gpio.c
17 +++ b/arch/arm/plat-s3c24xx/gpio.c
18 @@ -188,6 +188,23 @@ int s3c2410_gpio_getirq(unsigned int pin)
19
20 EXPORT_SYMBOL(s3c2410_gpio_getirq);
21
22 +int s3c2410_irq_to_gpio(unsigned int irq)
23 +{
24 + /* not valid interrupts */
25 + if (irq > 15 + IRQ_EINT8)
26 + return -1;
27 +
28 + if (irq < IRQ_EINT4)
29 + return (irq - IRQ_EINT0) + S3C2410_GPF0;
30 +
31 + if (irq < IRQ_EINT8)
32 + return (irq - IRQ_EINT4) + S3C2410_GPF4;
33 +
34 + return (irq - IRQ_EINT8) + S3C2410_GPG0;
35 +}
36 +
37 +EXPORT_SYMBOL(s3c2410_irq_to_gpio);
38 +
39 static void pretty_dump(u32 cfg, u32 state, u32 pull,
40 const char ** function_names_2,
41 const char ** function_names_3,
42 diff --git a/drivers/input/keyboard/neo1973kbd.c b/drivers/input/keyboard/neo1973kbd.c
43 index b413bc8..06fa8e0 100644
44 --- a/drivers/input/keyboard/neo1973kbd.c
45 +++ b/drivers/input/keyboard/neo1973kbd.c
46 @@ -28,16 +28,13 @@
47 struct neo1973kbd {
48 struct input_dev *input;
49 unsigned int suspended;
50 - int gpio_aux;
51 - int gpio_hold;
52 - int gpio_jack;
53 };
54
55 static irqreturn_t neo1973kbd_aux_irq(int irq, void *dev_id)
56 {
57 struct neo1973kbd *neo1973kbd_data = dev_id;
58
59 - int key_pressed = !gpio_get_value(neo1973kbd_data->gpio_aux);
60 + int key_pressed = !gpio_get_value(irq_to_gpio(irq));
61 input_report_key(neo1973kbd_data->input, KEY_PHONE, key_pressed);
62 input_sync(neo1973kbd_data->input);
63
64 @@ -48,7 +45,7 @@ static irqreturn_t neo1973kbd_hold_irq(int irq, void *dev_id)
65 {
66 struct neo1973kbd *neo1973kbd_data = dev_id;
67
68 - int key_pressed = gpio_get_value(neo1973kbd_data->gpio_hold);
69 + int key_pressed = gpio_get_value(irq_to_gpio(irq));
70 input_report_key(neo1973kbd_data->input, KEY_PAUSE, key_pressed);
71 input_sync(neo1973kbd_data->input);
72
73 @@ -59,7 +56,7 @@ static irqreturn_t neo1973kbd_headphone_irq(int irq, void *dev_id)
74 {
75 struct neo1973kbd *neo1973kbd_data = dev_id;
76
77 - int key_pressed = gpio_get_value(neo1973kbd_data->gpio_jack);
78 + int key_pressed = gpio_get_value(irq_to_gpio(irq));
79 input_report_switch(neo1973kbd_data->input,
80 SW_HEADPHONE_INSERT, key_pressed);
81 input_sync(neo1973kbd_data->input);
82 @@ -107,19 +104,15 @@ static int neo1973kbd_probe(struct platform_device *pdev)
83 if (pdev->resource[0].flags != 0)
84 return -EINVAL;
85
86 - neo1973kbd->gpio_aux = pdev->resource[0].start;
87 - neo1973kbd->gpio_hold = pdev->resource[1].start;
88 - neo1973kbd->gpio_jack = pdev->resource[2].start;
89 -
90 - irq_aux = gpio_to_irq(neo1973kbd->gpio_aux);
91 + irq_aux = gpio_to_irq(pdev->resource[0].start);
92 if (irq_aux < 0)
93 return -EINVAL;
94
95 - irq_hold = gpio_to_irq(neo1973kbd->gpio_hold);
96 + irq_hold = gpio_to_irq(pdev->resource[1].start);
97 if (irq_hold < 0)
98 return -EINVAL;
99
100 - irq_jack = gpio_to_irq(neo1973kbd->gpio_jack);
101 + irq_jack = gpio_to_irq(pdev->resource[2].start);
102 if (irq_jack < 0)
103 return -EINVAL;
104
105 diff --git a/include/asm-arm/arch-s3c2410/gpio.h b/include/asm-arm/arch-s3c2410/gpio.h
106 index 7583895..9c8a338 100644
107 --- a/include/asm-arm/arch-s3c2410/gpio.h
108 +++ b/include/asm-arm/arch-s3c2410/gpio.h
109 @@ -61,6 +61,7 @@ static inline int gpio_direction_output(unsigned gpio, int value)
110 #define gpio_to_irq(gpio) s3c2400_gpio_getirq(gpio)
111 #else
112 #define gpio_to_irq(gpio) s3c2410_gpio_getirq(gpio)
113 +#define irq_to_gpio(irq) s3c2410_irq_to_gpio(irq)
114 #endif
115
116 /* FIXME implement irq_to_gpio() */
117 diff --git a/include/asm-arm/arch-s3c2410/hardware.h b/include/asm-arm/arch-s3c2410/hardware.h
118 index 6dadf58..caea511 100644
119 --- a/include/asm-arm/arch-s3c2410/hardware.h
120 +++ b/include/asm-arm/arch-s3c2410/hardware.h
121 @@ -50,6 +50,8 @@ extern unsigned int s3c2410_gpio_getcfg(unsigned int pin);
122
123 extern int s3c2410_gpio_getirq(unsigned int pin);
124
125 +extern int s3c2410_irq_to_gpio(unsigned int irq);
126 +
127 #ifdef CONFIG_CPU_S3C2400
128
129 extern int s3c2400_gpio_getirq(unsigned int pin);
130 --
131 1.5.6.5
132
This page took 0.042432 seconds and 5 git commands to generate.