aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-02-12 03:53:13 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:34 -0500
commita31c4eea2127ee52b5c7c1befada4664963ad030 (patch)
treedc459f1ddba26772c9faa26ac8cdef0c41afd300 /arch/arm
parent3c729f1ecd23b86a2d6b211d646f57f9da8dfeb1 (diff)
[PATCH] AT91 GPIO wrappers
This is a first cut at making the AT91 code use the generic GPIO calls. Note that the original AT91 GPIO calls merged the "mux pin as GPIO" and "set GPIO direction" functionality into one API call, contrary to what's specified as a cross-platform portable model. So this involved a few non-inlinable functions. [akpm@osdl.org: cleanups] Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-at91rm9200/gpio.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/arm/mach-at91rm9200/gpio.c b/arch/arm/mach-at91rm9200/gpio.c
index af22659c8a28..15eb5b6b29f2 100644
--- a/arch/arm/mach-at91rm9200/gpio.c
+++ b/arch/arm/mach-at91rm9200/gpio.c
@@ -65,6 +65,24 @@ static inline unsigned pin_to_mask(unsigned pin)
65 65
66 66
67/* 67/*
68 * mux the pin to the "GPIO" peripheral role.
69 */
70int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup)
71{
72 void __iomem *pio = pin_to_controller(pin);
73 unsigned mask = pin_to_mask(pin);
74
75 if (!pio)
76 return -EINVAL;
77 __raw_writel(mask, pio + PIO_IDR);
78 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
79 __raw_writel(mask, pio + PIO_PER);
80 return 0;
81}
82EXPORT_SYMBOL(at91_set_GPIO_periph);
83
84
85/*
68 * mux the pin to the "A" internal peripheral role. 86 * mux the pin to the "A" internal peripheral role.
69 */ 87 */
70int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup) 88int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup)
@@ -181,6 +199,36 @@ EXPORT_SYMBOL(at91_set_multi_drive);
181 199
182/*--------------------------------------------------------------------------*/ 200/*--------------------------------------------------------------------------*/
183 201
202/* new-style GPIO calls; these expect at91_set_GPIO_periph to have been
203 * called, and maybe at91_set_multi_drive() for putout pins.
204 */
205
206int gpio_direction_input(unsigned pin)
207{
208 void __iomem *pio = pin_to_controller(pin);
209 unsigned mask = pin_to_mask(pin);
210
211 if (!pio || !(__raw_readl(pio + PIO_PSR) & mask))
212 return -EINVAL;
213 __raw_writel(mask, pio + PIO_OER);
214 return 0;
215}
216EXPORT_SYMBOL(gpio_direction_input);
217
218int gpio_direction_output(unsigned pin)
219{
220 void __iomem *pio = pin_to_controller(pin);
221 unsigned mask = pin_to_mask(pin);
222
223 if (!pio || !(__raw_readl(pio + PIO_PSR) & mask))
224 return -EINVAL;
225 __raw_writel(mask, pio + PIO_OER);
226 return 0;
227}
228EXPORT_SYMBOL(gpio_direction_output);
229
230/*--------------------------------------------------------------------------*/
231
184/* 232/*
185 * assuming the pin is muxed as a gpio output, set its value. 233 * assuming the pin is muxed as a gpio output, set its value.
186 */ 234 */