Merge branch 'common/intc-extension' into sh-latest
[cascardo/linux.git] / include / linux / gpio.h
1 #ifndef __LINUX_GPIO_H
2 #define __LINUX_GPIO_H
3
4 /* see Documentation/gpio.txt */
5
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)
9
10 #define GPIOF_INIT_LOW  (0 << 1)
11 #define GPIOF_INIT_HIGH (1 << 1)
12
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)
16
17 /**
18  * struct gpio - a structure describing a GPIO with configuration
19  * @gpio:       the GPIO number
20  * @flags:      GPIO configuration as specified by GPIOF_*
21  * @label:      a literal description string of this GPIO
22  */
23 struct gpio {
24         unsigned        gpio;
25         unsigned long   flags;
26         const char      *label;
27 };
28
29 #ifdef CONFIG_GENERIC_GPIO
30 #include <asm/gpio.h>
31
32 #else
33
34 #include <linux/kernel.h>
35 #include <linux/types.h>
36 #include <linux/errno.h>
37 #include <linux/bug.h>
38
39 struct device;
40 struct gpio_chip;
41
42 static inline bool gpio_is_valid(int number)
43 {
44         return false;
45 }
46
47 static inline int gpio_request(unsigned gpio, const char *label)
48 {
49         return -ENOSYS;
50 }
51
52 static inline int gpio_request_one(unsigned gpio,
53                                         unsigned long flags, const char *label)
54 {
55         return -ENOSYS;
56 }
57
58 static inline int gpio_request_array(const struct gpio *array, size_t num)
59 {
60         return -ENOSYS;
61 }
62
63 static inline void gpio_free(unsigned gpio)
64 {
65         might_sleep();
66
67         /* GPIO can never have been requested */
68         WARN_ON(1);
69 }
70
71 static inline void gpio_free_array(const struct gpio *array, size_t num)
72 {
73         might_sleep();
74
75         /* GPIO can never have been requested */
76         WARN_ON(1);
77 }
78
79 static inline int gpio_direction_input(unsigned gpio)
80 {
81         return -ENOSYS;
82 }
83
84 static inline int gpio_direction_output(unsigned gpio, int value)
85 {
86         return -ENOSYS;
87 }
88
89 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
90 {
91         return -ENOSYS;
92 }
93
94 static inline int gpio_get_value(unsigned gpio)
95 {
96         /* GPIO can never have been requested or set as {in,out}put */
97         WARN_ON(1);
98         return 0;
99 }
100
101 static inline void gpio_set_value(unsigned gpio, int value)
102 {
103         /* GPIO can never have been requested or set as output */
104         WARN_ON(1);
105 }
106
107 static inline int gpio_cansleep(unsigned gpio)
108 {
109         /* GPIO can never have been requested or set as {in,out}put */
110         WARN_ON(1);
111         return 0;
112 }
113
114 static inline int gpio_get_value_cansleep(unsigned gpio)
115 {
116         /* GPIO can never have been requested or set as {in,out}put */
117         WARN_ON(1);
118         return 0;
119 }
120
121 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
122 {
123         /* GPIO can never have been requested or set as output */
124         WARN_ON(1);
125 }
126
127 static inline int gpio_export(unsigned gpio, bool direction_may_change)
128 {
129         /* GPIO can never have been requested or set as {in,out}put */
130         WARN_ON(1);
131         return -EINVAL;
132 }
133
134 static inline int gpio_export_link(struct device *dev, const char *name,
135                                 unsigned gpio)
136 {
137         /* GPIO can never have been exported */
138         WARN_ON(1);
139         return -EINVAL;
140 }
141
142 static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
143 {
144         /* GPIO can never have been requested */
145         WARN_ON(1);
146         return -EINVAL;
147 }
148
149 static inline void gpio_unexport(unsigned gpio)
150 {
151         /* GPIO can never have been exported */
152         WARN_ON(1);
153 }
154
155 static inline int gpio_to_irq(unsigned gpio)
156 {
157         /* GPIO can never have been requested or set as input */
158         WARN_ON(1);
159         return -EINVAL;
160 }
161
162 static inline int irq_to_gpio(unsigned irq)
163 {
164         /* irq can never have been returned from gpio_to_irq() */
165         WARN_ON(1);
166         return -EINVAL;
167 }
168
169 #endif
170
171 #endif /* __LINUX_GPIO_H */