4 /* see Documentation/gpio.txt */
6 /* make these flag values available regardless of GPIO kconfig options */
7 #define GPIOF_DIR_OUT (0 << 0)
8 #define GPIOF_DIR_IN (1 << 0)
10 #define GPIOF_INIT_LOW (0 << 1)
11 #define GPIOF_INIT_HIGH (1 << 1)
13 #define GPIOF_IN (GPIOF_DIR_IN)
14 #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
15 #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
17 #ifdef CONFIG_GENERIC_GPIO
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/errno.h>
31 * Some platforms don't support the GPIO programming interface.
33 * In case some driver uses it anyway (it should normally have
34 * depended on GENERIC_GPIO), these routines help the compiler
35 * optimize out much GPIO-related code ... or trigger a runtime
36 * warning when something is wrongly called.
39 static inline bool gpio_is_valid(int number)
44 static inline int gpio_request(unsigned gpio, const char *label)
49 static inline int gpio_request_one(unsigned gpio,
50 unsigned long flags, const char *label)
55 static inline int gpio_request_array(const struct gpio *array, size_t num)
60 static inline void gpio_free(unsigned gpio)
64 /* GPIO can never have been requested */
68 static inline void gpio_free_array(const struct gpio *array, size_t num)
72 /* GPIO can never have been requested */
76 static inline int gpio_direction_input(unsigned gpio)
81 static inline int gpio_direction_output(unsigned gpio, int value)
86 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
91 static inline int gpio_get_value(unsigned gpio)
93 /* GPIO can never have been requested or set as {in,out}put */
98 static inline void gpio_set_value(unsigned gpio, int value)
100 /* GPIO can never have been requested or set as output */
104 static inline int gpio_cansleep(unsigned gpio)
106 /* GPIO can never have been requested or set as {in,out}put */
111 static inline int gpio_get_value_cansleep(unsigned gpio)
113 /* GPIO can never have been requested or set as {in,out}put */
118 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
120 /* GPIO can never have been requested or set as output */
124 static inline int gpio_export(unsigned gpio, bool direction_may_change)
126 /* GPIO can never have been requested or set as {in,out}put */
131 static inline int gpio_export_link(struct device *dev, const char *name,
134 /* GPIO can never have been exported */
139 static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
141 /* GPIO can never have been requested */
146 static inline void gpio_unexport(unsigned gpio)
148 /* GPIO can never have been exported */
152 static inline int gpio_to_irq(unsigned gpio)
154 /* GPIO can never have been requested or set as input */
159 static inline int irq_to_gpio(unsigned irq)
161 /* irq can never have been returned from gpio_to_irq() */
168 #endif /* __LINUX_GPIO_H */