diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-04-10 08:31:47 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-04-10 10:31:37 -0400 |
commit | 45528e38173e7d8c03821850e8fd1ddbf16f2b3d (patch) | |
tree | 96ed1a1e340bb28e47d8b4b9e1de4b42e0d12bd6 /arch/arm/mach-sa1100 | |
parent | c353faa4b2abd8d5142640b880532c97a0807460 (diff) |
[ARM] 4961/1: gpiolib support for SA-1100 architecture
This adds gpiolib support for the SA-1100 arch:
- Move all GPIO API functions from generic.c into gpio.c
- Convert all gpio functions into gpiolib callbacks.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-sa1100')
-rw-r--r-- | arch/arm/mach-sa1100/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/generic.c | 31 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/generic.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/gpio.c | 65 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/irq.c | 2 |
5 files changed, 69 insertions, 32 deletions
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile index 7a61e8d33ab7..8e0244631d65 100644 --- a/arch/arm/mach-sa1100/Makefile +++ b/arch/arm/mach-sa1100/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | # Common support | 5 | # Common support |
6 | obj-y := clock.o generic.o irq.o dma.o time.o #nmi-oopser.o | 6 | obj-y := clock.o generic.o gpio.o irq.o dma.o time.o #nmi-oopser.o |
7 | obj-m := | 7 | obj-m := |
8 | obj-n := | 8 | obj-n := |
9 | obj- := | 9 | obj- := |
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 5c84c604ed86..0c2fa1c4fb4c 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c | |||
@@ -139,37 +139,6 @@ unsigned long long sched_clock(void) | |||
139 | return v; | 139 | return v; |
140 | } | 140 | } |
141 | 141 | ||
142 | int gpio_direction_input(unsigned gpio) | ||
143 | { | ||
144 | unsigned long flags; | ||
145 | |||
146 | if (gpio > GPIO_MAX) | ||
147 | return -EINVAL; | ||
148 | |||
149 | local_irq_save(flags); | ||
150 | GPDR &= ~GPIO_GPIO(gpio); | ||
151 | local_irq_restore(flags); | ||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | EXPORT_SYMBOL(gpio_direction_input); | ||
156 | |||
157 | int gpio_direction_output(unsigned gpio, int value) | ||
158 | { | ||
159 | unsigned long flags; | ||
160 | |||
161 | if (gpio > GPIO_MAX) | ||
162 | return -EINVAL; | ||
163 | |||
164 | local_irq_save(flags); | ||
165 | gpio_set_value(gpio, value); | ||
166 | GPDR |= GPIO_GPIO(gpio); | ||
167 | local_irq_restore(flags); | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | EXPORT_SYMBOL(gpio_direction_output); | ||
172 | |||
173 | /* | 142 | /* |
174 | * Default power-off for SA1100 | 143 | * Default power-off for SA1100 |
175 | */ | 144 | */ |
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h index f085d68e568e..793c2e6c991f 100644 --- a/arch/arm/mach-sa1100/generic.h +++ b/arch/arm/mach-sa1100/generic.h | |||
@@ -9,6 +9,7 @@ struct sys_timer; | |||
9 | extern struct sys_timer sa1100_timer; | 9 | extern struct sys_timer sa1100_timer; |
10 | extern void __init sa1100_map_io(void); | 10 | extern void __init sa1100_map_io(void); |
11 | extern void __init sa1100_init_irq(void); | 11 | extern void __init sa1100_init_irq(void); |
12 | extern void __init sa1100_init_gpio(void); | ||
12 | 13 | ||
13 | #define SET_BANK(__nr,__start,__size) \ | 14 | #define SET_BANK(__nr,__start,__size) \ |
14 | mi->bank[__nr].start = (__start), \ | 15 | mi->bank[__nr].start = (__start), \ |
diff --git a/arch/arm/mach-sa1100/gpio.c b/arch/arm/mach-sa1100/gpio.c new file mode 100644 index 000000000000..372f1f4f54a1 --- /dev/null +++ b/arch/arm/mach-sa1100/gpio.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/gpio.c | ||
3 | * | ||
4 | * Generic SA-1100 GPIO handling | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/init.h> | ||
12 | #include <linux/module.h> | ||
13 | |||
14 | #include <asm/gpio.h> | ||
15 | #include <asm/hardware.h> | ||
16 | #include "generic.h" | ||
17 | |||
18 | static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
19 | { | ||
20 | return GPLR & GPIO_GPIO(offset); | ||
21 | } | ||
22 | |||
23 | static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
24 | { | ||
25 | if (value) | ||
26 | GPSR = GPIO_GPIO(offset); | ||
27 | else | ||
28 | GPCR = GPIO_GPIO(offset); | ||
29 | } | ||
30 | |||
31 | static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset) | ||
32 | { | ||
33 | unsigned long flags; | ||
34 | |||
35 | local_irq_save(flags); | ||
36 | GPDR &= ~GPIO_GPIO(offset); | ||
37 | local_irq_restore(flags); | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value) | ||
42 | { | ||
43 | unsigned long flags; | ||
44 | |||
45 | local_irq_save(flags); | ||
46 | sa1100_gpio_set(chip, offset, value); | ||
47 | GPDR |= GPIO_GPIO(offset); | ||
48 | local_irq_restore(flags); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | static struct gpio_chip sa1100_gpio_chip = { | ||
53 | .label = "gpio", | ||
54 | .direction_input = sa1100_direction_input, | ||
55 | .direction_output = sa1100_direction_output, | ||
56 | .set = sa1100_gpio_set, | ||
57 | .get = sa1100_gpio_get, | ||
58 | .base = 0, | ||
59 | .ngpio = GPIO_MAX + 1, | ||
60 | }; | ||
61 | |||
62 | void __init sa1100_init_gpio(void) | ||
63 | { | ||
64 | gpiochip_add(&sa1100_gpio_chip); | ||
65 | } | ||
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c index 3dc17d7bf38e..fa0403af7eec 100644 --- a/arch/arm/mach-sa1100/irq.c +++ b/arch/arm/mach-sa1100/irq.c | |||
@@ -347,4 +347,6 @@ void __init sa1100_init_irq(void) | |||
347 | */ | 347 | */ |
348 | set_irq_chip(IRQ_GPIO11_27, &sa1100_normal_chip); | 348 | set_irq_chip(IRQ_GPIO11_27, &sa1100_normal_chip); |
349 | set_irq_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler); | 349 | set_irq_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler); |
350 | |||
351 | sa1100_init_gpio(); | ||
350 | } | 352 | } |