X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=arch%2Farm%2Fmach-at91%2Fgpio.c;h=44211a0af19a805fd81a0d1a5783f07ed4db958f;hb=0ce3c83a9c22f59937b86c80b478dfbffe54dbab;hp=9b7495cd555d4b029c2a2e46315d7a560a2388d0;hpb=f69eda00d4e9808f0ddc88826278f93512cd2c98;p=pandora-kernel.git diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index 9b7495cd555d..44211a0af19a 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c @@ -64,6 +64,24 @@ static inline unsigned pin_to_mask(unsigned pin) */ +/* + * mux the pin to the "GPIO" peripheral role. + */ +int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup) +{ + void __iomem *pio = pin_to_controller(pin); + unsigned mask = pin_to_mask(pin); + + if (!pio) + return -EINVAL; + __raw_writel(mask, pio + PIO_IDR); + __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); + __raw_writel(mask, pio + PIO_PER); + return 0; +} +EXPORT_SYMBOL(at91_set_GPIO_periph); + + /* * mux the pin to the "A" internal peripheral role. */ @@ -181,6 +199,36 @@ EXPORT_SYMBOL(at91_set_multi_drive); /*--------------------------------------------------------------------------*/ +/* new-style GPIO calls; these expect at91_set_GPIO_periph to have been + * called, and maybe at91_set_multi_drive() for putout pins. + */ + +int gpio_direction_input(unsigned pin) +{ + void __iomem *pio = pin_to_controller(pin); + unsigned mask = pin_to_mask(pin); + + if (!pio || !(__raw_readl(pio + PIO_PSR) & mask)) + return -EINVAL; + __raw_writel(mask, pio + PIO_ODR); + return 0; +} +EXPORT_SYMBOL(gpio_direction_input); + +int gpio_direction_output(unsigned pin) +{ + void __iomem *pio = pin_to_controller(pin); + unsigned mask = pin_to_mask(pin); + + if (!pio || !(__raw_readl(pio + PIO_PSR) & mask)) + return -EINVAL; + __raw_writel(mask, pio + PIO_OER); + return 0; +} +EXPORT_SYMBOL(gpio_direction_output); + +/*--------------------------------------------------------------------------*/ + /* * assuming the pin is muxed as a gpio output, set its value. */