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 /* Gpio pin is open drain */
18 #define GPIOF_OPEN_DRAIN (1 << 2)
20 /* Gpio pin is open source */
21 #define GPIOF_OPEN_SOURCE (1 << 3)
23 #ifdef CONFIG_GENERIC_GPIO
28 #include <linux/kernel.h>
29 #include <linux/types.h>
30 #include <linux/errno.h>
37 * Some platforms don't support the GPIO programming interface.
39 * In case some driver uses it anyway (it should normally have
40 * depended on GENERIC_GPIO), these routines help the compiler
41 * optimize out much GPIO-related code ... or trigger a runtime
42 * warning when something is wrongly called.
45 static inline bool gpio_is_valid(int number)
50 static inline int gpio_request(unsigned gpio, const char *label)
55 static inline int gpio_request_one(unsigned gpio,
56 unsigned long flags, const char *label)
61 static inline int gpio_request_array(const struct gpio *array, size_t num)
66 static inline void gpio_free(unsigned gpio)
70 /* GPIO can never have been requested */
74 static inline void gpio_free_array(const struct gpio *array, size_t num)
78 /* GPIO can never have been requested */
82 static inline int gpio_direction_input(unsigned gpio)
87 static inline int gpio_direction_output(unsigned gpio, int value)
92 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
97 static inline int gpio_get_value(unsigned gpio)
99 /* GPIO can never have been requested or set as {in,out}put */
104 static inline void gpio_set_value(unsigned gpio, int value)
106 /* GPIO can never have been requested or set as output */
110 static inline int gpio_cansleep(unsigned gpio)
112 /* GPIO can never have been requested or set as {in,out}put */
117 static inline int gpio_get_value_cansleep(unsigned gpio)
119 /* GPIO can never have been requested or set as {in,out}put */
124 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
126 /* GPIO can never have been requested or set as output */
130 static inline int gpio_export(unsigned gpio, bool direction_may_change)
132 /* GPIO can never have been requested or set as {in,out}put */
137 static inline int gpio_export_link(struct device *dev, const char *name,
140 /* GPIO can never have been exported */
145 static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
147 /* GPIO can never have been requested */
152 static inline void gpio_unexport(unsigned gpio)
154 /* GPIO can never have been exported */
158 static inline int gpio_to_irq(unsigned gpio)
160 /* GPIO can never have been requested or set as input */
165 static inline int irq_to_gpio(unsigned irq)
167 /* irq can never have been returned from gpio_to_irq() */
174 #endif /* __LINUX_GPIO_H */