gpio: remove broken irq_to_gpio() interface
[deliverable/linux.git] / include / linux / gpio.h
1 #ifndef __LINUX_GPIO_H
2 #define __LINUX_GPIO_H
3
4 #include <linux/errno.h>
5
6 /* see Documentation/gpio/gpio-legacy.txt */
7
8 /* make these flag values available regardless of GPIO kconfig options */
9 #define GPIOF_DIR_OUT (0 << 0)
10 #define GPIOF_DIR_IN (1 << 0)
11
12 #define GPIOF_INIT_LOW (0 << 1)
13 #define GPIOF_INIT_HIGH (1 << 1)
14
15 #define GPIOF_IN (GPIOF_DIR_IN)
16 #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
17 #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
18
19 /* Gpio pin is active-low */
20 #define GPIOF_ACTIVE_LOW (1 << 2)
21
22 /* Gpio pin is open drain */
23 #define GPIOF_OPEN_DRAIN (1 << 3)
24
25 /* Gpio pin is open source */
26 #define GPIOF_OPEN_SOURCE (1 << 4)
27
28 #define GPIOF_EXPORT (1 << 5)
29 #define GPIOF_EXPORT_CHANGEABLE (1 << 6)
30 #define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
31 #define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
32
33 /**
34 * struct gpio - a structure describing a GPIO with configuration
35 * @gpio: the GPIO number
36 * @flags: GPIO configuration as specified by GPIOF_*
37 * @label: a literal description string of this GPIO
38 */
39 struct gpio {
40 unsigned gpio;
41 unsigned long flags;
42 const char *label;
43 };
44
45 #ifdef CONFIG_GPIOLIB
46
47 #ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
48 #include <asm/gpio.h>
49 #else
50
51 #include <asm-generic/gpio.h>
52
53 static inline int gpio_get_value(unsigned int gpio)
54 {
55 return __gpio_get_value(gpio);
56 }
57
58 static inline void gpio_set_value(unsigned int gpio, int value)
59 {
60 __gpio_set_value(gpio, value);
61 }
62
63 static inline int gpio_cansleep(unsigned int gpio)
64 {
65 return __gpio_cansleep(gpio);
66 }
67
68 static inline int gpio_to_irq(unsigned int gpio)
69 {
70 return __gpio_to_irq(gpio);
71 }
72
73 #endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */
74
75 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
76
77 struct device;
78
79 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
80 int devm_gpio_request_one(struct device *dev, unsigned gpio,
81 unsigned long flags, const char *label);
82 void devm_gpio_free(struct device *dev, unsigned int gpio);
83
84 #else /* ! CONFIG_GPIOLIB */
85
86 #include <linux/kernel.h>
87 #include <linux/types.h>
88 #include <linux/bug.h>
89 #include <linux/pinctrl/pinctrl.h>
90
91 struct device;
92 struct gpio_chip;
93
94 static inline bool gpio_is_valid(int number)
95 {
96 return false;
97 }
98
99 static inline int gpio_request(unsigned gpio, const char *label)
100 {
101 return -ENOSYS;
102 }
103
104 static inline int gpio_request_one(unsigned gpio,
105 unsigned long flags, const char *label)
106 {
107 return -ENOSYS;
108 }
109
110 static inline int gpio_request_array(const struct gpio *array, size_t num)
111 {
112 return -ENOSYS;
113 }
114
115 static inline void gpio_free(unsigned gpio)
116 {
117 might_sleep();
118
119 /* GPIO can never have been requested */
120 WARN_ON(1);
121 }
122
123 static inline void gpio_free_array(const struct gpio *array, size_t num)
124 {
125 might_sleep();
126
127 /* GPIO can never have been requested */
128 WARN_ON(1);
129 }
130
131 static inline int gpio_direction_input(unsigned gpio)
132 {
133 return -ENOSYS;
134 }
135
136 static inline int gpio_direction_output(unsigned gpio, int value)
137 {
138 return -ENOSYS;
139 }
140
141 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
142 {
143 return -ENOSYS;
144 }
145
146 static inline int gpio_get_value(unsigned gpio)
147 {
148 /* GPIO can never have been requested or set as {in,out}put */
149 WARN_ON(1);
150 return 0;
151 }
152
153 static inline void gpio_set_value(unsigned gpio, int value)
154 {
155 /* GPIO can never have been requested or set as output */
156 WARN_ON(1);
157 }
158
159 static inline int gpio_cansleep(unsigned gpio)
160 {
161 /* GPIO can never have been requested or set as {in,out}put */
162 WARN_ON(1);
163 return 0;
164 }
165
166 static inline int gpio_get_value_cansleep(unsigned gpio)
167 {
168 /* GPIO can never have been requested or set as {in,out}put */
169 WARN_ON(1);
170 return 0;
171 }
172
173 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
174 {
175 /* GPIO can never have been requested or set as output */
176 WARN_ON(1);
177 }
178
179 static inline int gpio_export(unsigned gpio, bool direction_may_change)
180 {
181 /* GPIO can never have been requested or set as {in,out}put */
182 WARN_ON(1);
183 return -EINVAL;
184 }
185
186 static inline int gpio_export_link(struct device *dev, const char *name,
187 unsigned gpio)
188 {
189 /* GPIO can never have been exported */
190 WARN_ON(1);
191 return -EINVAL;
192 }
193
194 static inline void gpio_unexport(unsigned gpio)
195 {
196 /* GPIO can never have been exported */
197 WARN_ON(1);
198 }
199
200 static inline int gpio_to_irq(unsigned gpio)
201 {
202 /* GPIO can never have been requested or set as input */
203 WARN_ON(1);
204 return -EINVAL;
205 }
206
207 static inline int gpiochip_lock_as_irq(struct gpio_chip *chip,
208 unsigned int offset)
209 {
210 WARN_ON(1);
211 return -EINVAL;
212 }
213
214 static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip,
215 unsigned int offset)
216 {
217 WARN_ON(1);
218 }
219
220 static inline int
221 gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
222 unsigned int gpio_offset, unsigned int pin_offset,
223 unsigned int npins)
224 {
225 WARN_ON(1);
226 return -EINVAL;
227 }
228
229 static inline int
230 gpiochip_add_pingroup_range(struct gpio_chip *chip,
231 struct pinctrl_dev *pctldev,
232 unsigned int gpio_offset, const char *pin_group)
233 {
234 WARN_ON(1);
235 return -EINVAL;
236 }
237
238 static inline void
239 gpiochip_remove_pin_ranges(struct gpio_chip *chip)
240 {
241 WARN_ON(1);
242 }
243
244 static inline int devm_gpio_request(struct device *dev, unsigned gpio,
245 const char *label)
246 {
247 WARN_ON(1);
248 return -EINVAL;
249 }
250
251 static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
252 unsigned long flags, const char *label)
253 {
254 WARN_ON(1);
255 return -EINVAL;
256 }
257
258 static inline void devm_gpio_free(struct device *dev, unsigned int gpio)
259 {
260 WARN_ON(1);
261 }
262
263 #endif /* ! CONFIG_GPIOLIB */
264
265 #endif /* __LINUX_GPIO_H */
This page took 0.041209 seconds and 6 git commands to generate.