diff options
Diffstat (limited to 'arch/blackfin/include/asm/gpio.h')
-rw-r--r-- | arch/blackfin/include/asm/gpio.h | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index 5a25856381ff..3d84d96f7c2c 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h @@ -26,6 +26,7 @@ #ifndef __ASSEMBLY__ #include <linux/compiler.h> +#include <linux/gpio.h> /*********************************************************** * @@ -244,16 +245,69 @@ static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) return -EINVAL; } -static inline int gpio_get_value(unsigned gpio) +static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) +{ + int err; + + err = bfin_gpio_request(gpio, label); + if (err) + return err; + + if (flags & GPIOF_DIR_IN) + err = bfin_gpio_direction_input(gpio); + else + err = bfin_gpio_direction_output(gpio, + (flags & GPIOF_INIT_HIGH) ? 1 : 0); + + if (err) + bfin_gpio_free(gpio); + + return err; +} + +static inline int gpio_request_array(const struct gpio *array, size_t num) +{ + int i, err; + + for (i = 0; i < num; i++, array++) { + err = gpio_request_one(array->gpio, array->flags, array->label); + if (err) + goto err_free; + } + return 0; + +err_free: + while (i--) + bfin_gpio_free((--array)->gpio); + return err; +} + +static inline void gpio_free_array(const struct gpio *array, size_t num) +{ + while (num--) + bfin_gpio_free((array++)->gpio); +} + +static inline int __gpio_get_value(unsigned gpio) { return bfin_gpio_get_value(gpio); } -static inline void gpio_set_value(unsigned gpio, int value) +static inline void __gpio_set_value(unsigned gpio, int value) { return bfin_gpio_set_value(gpio, value); } +static inline int gpio_get_value(unsigned gpio) +{ + return __gpio_get_value(gpio); +} + +static inline void gpio_set_value(unsigned gpio, int value) +{ + return __gpio_set_value(gpio, value); +} + static inline int gpio_to_irq(unsigned gpio) { if (likely(gpio < MAX_BLACKFIN_GPIOS)) |