diff options
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-at91rm9200/gpio.c | 48 |
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 | */ | ||
70 | int __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 | } | ||
82 | EXPORT_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 | */ |
70 | int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup) | 88 | int __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 | |||
206 | int 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 | } | ||
216 | EXPORT_SYMBOL(gpio_direction_input); | ||
217 | |||
218 | int 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 | } | ||
228 | EXPORT_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 | */ |