diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-06 08:22:48 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-06 08:22:48 +0100 |
commit | 2789ccd18ffe32371a41b126d5ac02f9885a015c (patch) | |
tree | ea6a27ed4ee176c4cf7788aee4f19848bec5de8b /include | |
parent | cac8f8deb4fd1cdfb64397301830a62a1649ff40 (diff) | |
parent | bcf08772662c47ff69b253c44ac2415507fb9a93 (diff) | |
download | barebox-2789ccd18ffe32371a41b126d5ac02f9885a015c.tar.gz barebox-2789ccd18ffe32371a41b126d5ac02f9885a015c.tar.xz |
Merge branch 'for-next/gpio'
Diffstat (limited to 'include')
-rw-r--r-- | include/gpio.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/include/gpio.h b/include/gpio.h index 140d53c83e..4a97521aee 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -3,6 +3,28 @@ #include <asm/gpio.h> +#define GPIOF_DIR_OUT (0 << 0) +#define GPIOF_DIR_IN (1 << 0) + +#define GPIOF_INIT_LOW (0 << 1) +#define GPIOF_INIT_HIGH (1 << 1) + +#define GPIOF_IN (GPIOF_DIR_IN) +#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW) +#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH) + +/** + * struct gpio - a structure describing a GPIO with configuration + * @gpio: the GPIO number + * @flags: GPIO configuration as specified by GPIOF_* + * @label: a literal description string of this GPIO + */ +struct gpio { + unsigned gpio; + unsigned long flags; + const char *label; +}; + #ifndef CONFIG_GPIOLIB static inline int gpio_request(unsigned gpio, const char *label) { @@ -12,9 +34,29 @@ static inline int gpio_request(unsigned gpio, const char *label) static inline void gpio_free(unsigned gpio) { } + +static inline int gpio_request_one(unsigned gpio, + unsigned long flags, const char *label) +{ + return -ENOSYS; +} + +static inline int gpio_request_array(const struct gpio *array, size_t num) +{ + return -ENOSYS; +} + +static inline void gpio_free_array(const struct gpio *array, size_t num) +{ + /* GPIO can never have been requested */ + WARN_ON(1); +} #else int gpio_request(unsigned gpio, const char *label); void gpio_free(unsigned gpio); +int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); +int gpio_request_array(const struct gpio *array, size_t num); +void gpio_free_array(const struct gpio *array, size_t num); #endif struct gpio_chip; @@ -24,6 +66,7 @@ struct gpio_ops { void (*free)(struct gpio_chip *chip, unsigned offset); int (*direction_input)(struct gpio_chip *chip, unsigned offset); int (*direction_output)(struct gpio_chip *chip, unsigned offset, int value); + int (*get_direction)(struct gpio_chip *chip, unsigned offset); int (*get)(struct gpio_chip *chip, unsigned offset); void (*set)(struct gpio_chip *chip, unsigned offset, int value); }; |