aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/gpio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/gpio.h')
-rw-r--r--include/linux/gpio.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 6155ecf192b0..f07fc2d08159 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_GPIO_H 1#ifndef __LINUX_GPIO_H
2#define __LINUX_GPIO_H 2#define __LINUX_GPIO_H
3 3
4#include <linux/errno.h>
5
4/* see Documentation/gpio.txt */ 6/* see Documentation/gpio.txt */
5 7
6/* make these flag values available regardless of GPIO kconfig options */ 8/* make these flag values available regardless of GPIO kconfig options */
@@ -20,6 +22,11 @@
20/* Gpio pin is open source */ 22/* Gpio pin is open source */
21#define GPIOF_OPEN_SOURCE (1 << 3) 23#define GPIOF_OPEN_SOURCE (1 << 3)
22 24
25#define GPIOF_EXPORT (1 << 2)
26#define GPIOF_EXPORT_CHANGEABLE (1 << 3)
27#define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
28#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
29
23/** 30/**
24 * struct gpio - a structure describing a GPIO with configuration 31 * struct gpio - a structure describing a GPIO with configuration
25 * @gpio: the GPIO number 32 * @gpio: the GPIO number
@@ -33,7 +40,39 @@ struct gpio {
33}; 40};
34 41
35#ifdef CONFIG_GENERIC_GPIO 42#ifdef CONFIG_GENERIC_GPIO
43
44#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
36#include <asm/gpio.h> 45#include <asm/gpio.h>
46#else
47
48#include <asm-generic/gpio.h>
49
50static inline int gpio_get_value(unsigned int gpio)
51{
52 return __gpio_get_value(gpio);
53}
54
55static inline void gpio_set_value(unsigned int gpio, int value)
56{
57 __gpio_set_value(gpio, value);
58}
59
60static inline int gpio_cansleep(unsigned int gpio)
61{
62 return __gpio_cansleep(gpio);
63}
64
65static inline int gpio_to_irq(unsigned int gpio)
66{
67 return __gpio_to_irq(gpio);
68}
69
70static inline int irq_to_gpio(unsigned int irq)
71{
72 return -EINVAL;
73}
74
75#endif
37 76
38#else 77#else
39 78
@@ -55,12 +94,24 @@ static inline int gpio_request(unsigned gpio, const char *label)
55 return -ENOSYS; 94 return -ENOSYS;
56} 95}
57 96
97static inline int devm_gpio_request(struct device *dev, unsigned gpio,
98 const char *label)
99{
100 return -ENOSYS;
101}
102
58static inline int gpio_request_one(unsigned gpio, 103static inline int gpio_request_one(unsigned gpio,
59 unsigned long flags, const char *label) 104 unsigned long flags, const char *label)
60{ 105{
61 return -ENOSYS; 106 return -ENOSYS;
62} 107}
63 108
109static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
110 unsigned long flags, const char *label)
111{
112 return -ENOSYS;
113}
114
64static inline int gpio_request_array(const struct gpio *array, size_t num) 115static inline int gpio_request_array(const struct gpio *array, size_t num)
65{ 116{
66 return -ENOSYS; 117 return -ENOSYS;
@@ -74,6 +125,14 @@ static inline void gpio_free(unsigned gpio)
74 WARN_ON(1); 125 WARN_ON(1);
75} 126}
76 127
128static inline void devm_gpio_free(struct device *dev, unsigned gpio)
129{
130 might_sleep();
131
132 /* GPIO can never have been requested */
133 WARN_ON(1);
134}
135
77static inline void gpio_free_array(const struct gpio *array, size_t num) 136static inline void gpio_free_array(const struct gpio *array, size_t num)
78{ 137{
79 might_sleep(); 138 might_sleep();