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
6 Use this irq_to_gpio in the neo1973 keyboard driver
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(-)
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)
20 EXPORT_SYMBOL(s3c2410_gpio_getirq);
22 +int s3c2410_irq_to_gpio(unsigned int irq)
24 + /* not valid interrupts */
25 + if (irq > 15 + IRQ_EINT8)
28 + if (irq < IRQ_EINT4)
29 + return (irq - IRQ_EINT0) + S3C2410_GPF0;
31 + if (irq < IRQ_EINT8)
32 + return (irq - IRQ_EINT4) + S3C2410_GPF4;
34 + return (irq - IRQ_EINT8) + S3C2410_GPG0;
37 +EXPORT_SYMBOL(s3c2410_irq_to_gpio);
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
48 struct input_dev *input;
49 unsigned int suspended;
55 static irqreturn_t neo1973kbd_aux_irq(int irq, void *dev_id)
57 struct neo1973kbd *neo1973kbd_data = dev_id;
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);
64 @@ -48,7 +45,7 @@ static irqreturn_t neo1973kbd_hold_irq(int irq, void *dev_id)
66 struct neo1973kbd *neo1973kbd_data = dev_id;
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);
73 @@ -59,7 +56,7 @@ static irqreturn_t neo1973kbd_headphone_irq(int irq, void *dev_id)
75 struct neo1973kbd *neo1973kbd_data = dev_id;
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)
86 - neo1973kbd->gpio_aux = pdev->resource[0].start;
87 - neo1973kbd->gpio_hold = pdev->resource[1].start;
88 - neo1973kbd->gpio_jack = pdev->resource[2].start;
90 - irq_aux = gpio_to_irq(neo1973kbd->gpio_aux);
91 + irq_aux = gpio_to_irq(pdev->resource[0].start);
95 - irq_hold = gpio_to_irq(neo1973kbd->gpio_hold);
96 + irq_hold = gpio_to_irq(pdev->resource[1].start);
100 - irq_jack = gpio_to_irq(neo1973kbd->gpio_jack);
101 + irq_jack = gpio_to_irq(pdev->resource[2].start);
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)
112 #define gpio_to_irq(gpio) s3c2410_gpio_getirq(gpio)
113 +#define irq_to_gpio(irq) s3c2410_irq_to_gpio(irq)
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);
123 extern int s3c2410_gpio_getirq(unsigned int pin);
125 +extern int s3c2410_irq_to_gpio(unsigned int irq);
127 #ifdef CONFIG_CPU_S3C2400
129 extern int s3c2400_gpio_getirq(unsigned int pin);