summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2013-11-22 00:11:24 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2013-11-22 10:59:04 +0100
commitbcf08772662c47ff69b253c44ac2415507fb9a93 (patch)
tree945f0eb8700af0a19452243aa8dd774f511f1b35 /include
parent6339a419e91ec16afe02cb9270c487778129aa3c (diff)
downloadbarebox-bcf08772662c47ff69b253c44ac2415507fb9a93.tar.gz
barebox-bcf08772662c47ff69b253c44ac2415507fb9a93.tar.xz
gpiolib: import gpio_request_array() from linux 3.7
Also import related functions gpio_request_one() and gpio_free_array(). This commit imports code from linux 3.7 as the more recent linux kernel versions use gpiolib descriptors, see this commit for details: commit 372e722ea4dd4ca11c3d04845e11cbc15f32144c Author: Alexandre Courbot <acourbot@nvidia.com> Date: Sun Feb 3 01:29:29 2013 +0900 gpiolib: use descriptors internally Make sure gpiolib works internally with descriptors and (chip, offset) pairs instead of using the global integer namespace. This prepares the ground for the removal of the global gpio_desc[] array and the introduction of the descriptor-based GPIO API. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/gpio.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/gpio.h b/include/gpio.h
index f33b43550c..4a97521aee 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -6,6 +6,25 @@
#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)
{
@@ -15,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;