diff options
-rw-r--r-- | arch/arm/mach-pxa/generic.c | 38 | ||||
-rw-r--r-- | include/asm-arm/arch-pxa/gpio.h | 12 |
2 files changed, 40 insertions, 10 deletions
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c index 2263a84844a1..1c34946ee16e 100644 --- a/arch/arm/mach-pxa/generic.c +++ b/arch/arm/mach-pxa/generic.c | |||
@@ -105,6 +105,44 @@ int pxa_gpio_mode(int gpio_mode) | |||
105 | 105 | ||
106 | EXPORT_SYMBOL(pxa_gpio_mode); | 106 | EXPORT_SYMBOL(pxa_gpio_mode); |
107 | 107 | ||
108 | int gpio_direction_input(unsigned gpio) | ||
109 | { | ||
110 | unsigned long flags; | ||
111 | u32 mask; | ||
112 | |||
113 | if (gpio > pxa_last_gpio) | ||
114 | return -EINVAL; | ||
115 | |||
116 | mask = GPIO_bit(gpio); | ||
117 | local_irq_save(flags); | ||
118 | GPDR(gpio) &= ~mask; | ||
119 | local_irq_restore(flags); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | EXPORT_SYMBOL(gpio_direction_input); | ||
124 | |||
125 | int gpio_direction_output(unsigned gpio, int value) | ||
126 | { | ||
127 | unsigned long flags; | ||
128 | u32 mask; | ||
129 | |||
130 | if (gpio > pxa_last_gpio) | ||
131 | return -EINVAL; | ||
132 | |||
133 | mask = GPIO_bit(gpio); | ||
134 | local_irq_save(flags); | ||
135 | if (value) | ||
136 | GPSR(gpio) = mask; | ||
137 | else | ||
138 | GPCR(gpio) = mask; | ||
139 | GPDR(gpio) |= mask; | ||
140 | local_irq_restore(flags); | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | EXPORT_SYMBOL(gpio_direction_output); | ||
145 | |||
108 | /* | 146 | /* |
109 | * Return GPIO level | 147 | * Return GPIO level |
110 | */ | 148 | */ |
diff --git a/include/asm-arm/arch-pxa/gpio.h b/include/asm-arm/arch-pxa/gpio.h index 9e99241f3edf..9dbc2dc794f7 100644 --- a/include/asm-arm/arch-pxa/gpio.h +++ b/include/asm-arm/arch-pxa/gpio.h | |||
@@ -38,16 +38,8 @@ static inline void gpio_free(unsigned gpio) | |||
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | static inline int gpio_direction_input(unsigned gpio) | 41 | extern int gpio_direction_input(unsigned gpio); |
42 | { | 42 | extern int gpio_direction_output(unsigned gpio, int value); |
43 | return pxa_gpio_mode(gpio | GPIO_IN); | ||
44 | } | ||
45 | |||
46 | static inline int gpio_direction_output(unsigned gpio, int value) | ||
47 | { | ||
48 | return pxa_gpio_mode(gpio | GPIO_OUT | | ||
49 | (value ? GPIO_DFLT_HIGH : GPIO_DFLT_LOW)); | ||
50 | } | ||
51 | 43 | ||
52 | static inline int __gpio_get_value(unsigned gpio) | 44 | static inline int __gpio_get_value(unsigned gpio) |
53 | { | 45 | { |