diff options
-rw-r--r-- | arch/arm/mach-sa1100/generic.c | 30 | ||||
-rw-r--r-- | include/asm-arm/arch-sa1100/gpio.h | 34 |
2 files changed, 44 insertions, 20 deletions
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index e510295c2580..192a5a26cf2b 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c | |||
@@ -138,6 +138,36 @@ unsigned long long sched_clock(void) | |||
138 | return v; | 138 | return v; |
139 | } | 139 | } |
140 | 140 | ||
141 | int gpio_direction_input(unsigned gpio) | ||
142 | { | ||
143 | unsigned long flags; | ||
144 | |||
145 | if (gpio > GPIO_MAX) | ||
146 | return -EINVAL; | ||
147 | |||
148 | local_irq_save(flags); | ||
149 | GPDR &= ~GPIO_GPIO(gpio); | ||
150 | local_irq_restore(flags); | ||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | EXPORT_SYMBOL(gpio_direction_input); | ||
155 | |||
156 | int gpio_direction_output(unsigned gpio) | ||
157 | { | ||
158 | unsigned long flags; | ||
159 | |||
160 | if (gpio > GPIO_MAX) | ||
161 | return -EINVAL; | ||
162 | |||
163 | local_irq_save(flags); | ||
164 | GPDR |= GPIO_GPIO(gpio); | ||
165 | local_irq_restore(flags); | ||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | EXPORT_SYMBOL(gpio_direction_output); | ||
170 | |||
141 | /* | 171 | /* |
142 | * Default power-off for SA1100 | 172 | * Default power-off for SA1100 |
143 | */ | 173 | */ |
diff --git a/include/asm-arm/arch-sa1100/gpio.h b/include/asm-arm/arch-sa1100/gpio.h index a331fe3f6e48..da7575b0e5d0 100644 --- a/include/asm-arm/arch-sa1100/gpio.h +++ b/include/asm-arm/arch-sa1100/gpio.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * linux/include/asm-arm/arch-pxa/gpio.h | 2 | * linux/include/asm-arm/arch-sa1100/gpio.h |
3 | * | 3 | * |
4 | * SA1100 GPIO wrappers for arch-neutral GPIO calls | 4 | * SA1100 GPIO wrappers for arch-neutral GPIO calls |
5 | * | 5 | * |
@@ -24,11 +24,8 @@ | |||
24 | #ifndef __ASM_ARCH_SA1100_GPIO_H | 24 | #ifndef __ASM_ARCH_SA1100_GPIO_H |
25 | #define __ASM_ARCH_SA1100_GPIO_H | 25 | #define __ASM_ARCH_SA1100_GPIO_H |
26 | 26 | ||
27 | #include <asm/arch/SA-1100.h> | 27 | #include <asm/hardware.h> |
28 | #include <asm/arch/irqs.h> | 28 | #include <asm/irq.h> |
29 | #include <asm/arch/hardware.h> | ||
30 | |||
31 | #include <asm/errno.h> | ||
32 | 29 | ||
33 | static inline int gpio_request(unsigned gpio, const char *label) | 30 | static inline int gpio_request(unsigned gpio, const char *label) |
34 | { | 31 | { |
@@ -40,26 +37,23 @@ static inline void gpio_free(unsigned gpio) | |||
40 | return; | 37 | return; |
41 | } | 38 | } |
42 | 39 | ||
43 | static inline int gpio_direction_input(unsigned gpio) | 40 | extern int gpio_direction_input(unsigned gpio); |
41 | extern int gpio_direction_output(unsigned gpio); | ||
42 | |||
43 | |||
44 | static inline int gpio_get_value(unsigned gpio) | ||
44 | { | 45 | { |
45 | if (gpio > GPIO_MAX) | 46 | return GPLR & GPIO_GPIO(gpio); |
46 | return -EINVAL; | ||
47 | GPDR = (GPDR_In << gpio) 0 | ||
48 | } | 47 | } |
49 | 48 | ||
50 | static inline int gpio_direction_output(unsigned gpio) | 49 | static inline void gpio_set_value(unsigned gpio, int value) |
51 | { | 50 | { |
52 | if (gpio > GPIO_MAX) | 51 | if (value) |
53 | return -EINVAL; | 52 | GPSR = GPIO_GPIO(gpio); |
54 | GPDR = (GPDR_Out << gpio) 0 | 53 | else |
54 | GPCR = GPIO_GPIO(gpio); | ||
55 | } | 55 | } |
56 | 56 | ||
57 | #define gpio_get_value(gpio) \ | ||
58 | (GPLR & GPIO_GPIO(gpio)) | ||
59 | |||
60 | #define gpio_set_value(gpio,value) \ | ||
61 | ((value) ? (GPSR = GPIO_GPIO(gpio)) : (GPCR(gpio) = GPIO_GPIO(gpio))) | ||
62 | |||
63 | #include <asm-generic/gpio.h> /* cansleep wrappers */ | 57 | #include <asm-generic/gpio.h> /* cansleep wrappers */ |
64 | 58 | ||
65 | static inline unsigned gpio_to_irq(unsigned gpio) | 59 | static inline unsigned gpio_to_irq(unsigned gpio) |