summaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/gpio.h
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2012-04-27 18:25:16 +0800
committerBob Liu <lliubbo@gmail.com>2012-05-21 14:54:34 +0800
commit45abc49d194539144b5dd510c82c03c36cbd3a58 (patch)
treec088ed9f98279ba6191721c0d9d6fb9c3724704b /arch/blackfin/include/asm/gpio.h
parent494b794808c6b1ead80590c01b08a87850cc4724 (diff)
downloadblackbird-op-linux-45abc49d194539144b5dd510c82c03c36cbd3a58.tar.gz
blackbird-op-linux-45abc49d194539144b5dd510c82c03c36cbd3a58.zip
blackfin: GPIO: Implement more GPIO APIs
Implement more GPIO APIs in case GPIOLIB is disabled. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Bob Liu <lliubbo@gmail.com>
Diffstat (limited to 'arch/blackfin/include/asm/gpio.h')
-rw-r--r--arch/blackfin/include/asm/gpio.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h
index 12d3571b5232..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,6 +245,49 @@ static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
return -EINVAL;
}
+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);
OpenPOWER on IntegriCloud