]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/gpio.h
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 #define GPIOF_EXPORT (1 << 2)
24 #define GPIOF_EXPORT_CHANGEABLE (1 << 3)
25 #define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
26 #define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
29 * struct gpio - a structure describing a GPIO with configuration
30 * @gpio: the GPIO number
31 * @flags: GPIO configuration as specified by GPIOF_*
32 * @label: a literal description string of this GPIO
40 #ifdef CONFIG_GENERIC_GPIO
45 #include <linux/kernel.h>
46 #include <linux/types.h>
47 #include <linux/errno.h>
48 #include <linux/bug.h>
53 static inline bool gpio_is_valid(int number
)
58 static inline int gpio_request(unsigned gpio
, const char *label
)
63 static inline int gpio_request_one(unsigned gpio
,
64 unsigned long flags
, const char *label
)
69 static inline int gpio_request_array(const struct gpio
*array
, size_t num
)
74 static inline void gpio_free(unsigned gpio
)
78 /* GPIO can never have been requested */
82 static inline void gpio_free_array(const struct gpio
*array
, size_t num
)
86 /* GPIO can never have been requested */
90 static inline int gpio_direction_input(unsigned gpio
)
95 static inline int gpio_direction_output(unsigned gpio
, int value
)
100 static inline int gpio_set_debounce(unsigned gpio
, unsigned debounce
)
105 static inline int gpio_get_value(unsigned gpio
)
107 /* GPIO can never have been requested or set as {in,out}put */
112 static inline void gpio_set_value(unsigned gpio
, int value
)
114 /* GPIO can never have been requested or set as output */
118 static inline int gpio_cansleep(unsigned gpio
)
120 /* GPIO can never have been requested or set as {in,out}put */
125 static inline int gpio_get_value_cansleep(unsigned gpio
)
127 /* GPIO can never have been requested or set as {in,out}put */
132 static inline void gpio_set_value_cansleep(unsigned gpio
, int value
)
134 /* GPIO can never have been requested or set as output */
138 static inline int gpio_export(unsigned gpio
, bool direction_may_change
)
140 /* GPIO can never have been requested or set as {in,out}put */
145 static inline int gpio_export_link(struct device
*dev
, const char *name
,
148 /* GPIO can never have been exported */
153 static inline int gpio_sysfs_set_active_low(unsigned gpio
, int value
)
155 /* GPIO can never have been requested */
160 static inline void gpio_unexport(unsigned gpio
)
162 /* GPIO can never have been exported */
166 static inline int gpio_to_irq(unsigned gpio
)
168 /* GPIO can never have been requested or set as input */
173 static inline int irq_to_gpio(unsigned irq
)
175 /* irq can never have been returned from gpio_to_irq() */
182 #endif /* __LINUX_GPIO_H */