drm/panfrost: Remove set but not used variable 'bo'
[linux/fpc-iii.git] / include / linux / gpio.h
blob2157717c213683e62680720e9b66c232239c10a6
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * <linux/gpio.h>
5 * This is the LEGACY GPIO bulk include file, including legacy APIs. It is
6 * used for GPIO drivers still referencing the global GPIO numberspace,
7 * and should not be included in new code.
9 * If you're implementing a GPIO driver, only include <linux/gpio/driver.h>
10 * If you're implementing a GPIO consumer, only include <linux/gpio/consumer.h>
12 #ifndef __LINUX_GPIO_H
13 #define __LINUX_GPIO_H
15 #include <linux/errno.h>
17 /* see Documentation/driver-api/gpio/legacy.rst */
19 /* make these flag values available regardless of GPIO kconfig options */
20 #define GPIOF_DIR_OUT (0 << 0)
21 #define GPIOF_DIR_IN (1 << 0)
23 #define GPIOF_INIT_LOW (0 << 1)
24 #define GPIOF_INIT_HIGH (1 << 1)
26 #define GPIOF_IN (GPIOF_DIR_IN)
27 #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
28 #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
30 /* Gpio pin is active-low */
31 #define GPIOF_ACTIVE_LOW (1 << 2)
33 /* Gpio pin is open drain */
34 #define GPIOF_OPEN_DRAIN (1 << 3)
36 /* Gpio pin is open source */
37 #define GPIOF_OPEN_SOURCE (1 << 4)
39 #define GPIOF_EXPORT (1 << 5)
40 #define GPIOF_EXPORT_CHANGEABLE (1 << 6)
41 #define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
42 #define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
44 /**
45 * struct gpio - a structure describing a GPIO with configuration
46 * @gpio: the GPIO number
47 * @flags: GPIO configuration as specified by GPIOF_*
48 * @label: a literal description string of this GPIO
50 struct gpio {
51 unsigned gpio;
52 unsigned long flags;
53 const char *label;
56 #ifdef CONFIG_GPIOLIB
58 #ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
59 #include <asm/gpio.h>
60 #else
62 #include <asm-generic/gpio.h>
64 static inline int gpio_get_value(unsigned int gpio)
66 return __gpio_get_value(gpio);
69 static inline void gpio_set_value(unsigned int gpio, int value)
71 __gpio_set_value(gpio, value);
74 static inline int gpio_cansleep(unsigned int gpio)
76 return __gpio_cansleep(gpio);
79 static inline int gpio_to_irq(unsigned int gpio)
81 return __gpio_to_irq(gpio);
84 static inline int irq_to_gpio(unsigned int irq)
86 return -EINVAL;
89 #endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */
91 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
93 struct device;
95 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
96 int devm_gpio_request_one(struct device *dev, unsigned gpio,
97 unsigned long flags, const char *label);
98 void devm_gpio_free(struct device *dev, unsigned int gpio);
100 #else /* ! CONFIG_GPIOLIB */
102 #include <linux/kernel.h>
103 #include <linux/types.h>
104 #include <linux/bug.h>
105 #include <linux/pinctrl/pinctrl.h>
107 struct device;
108 struct gpio_chip;
109 struct pinctrl_dev;
111 static inline bool gpio_is_valid(int number)
113 return false;
116 static inline int gpio_request(unsigned gpio, const char *label)
118 return -ENOSYS;
121 static inline int gpio_request_one(unsigned gpio,
122 unsigned long flags, const char *label)
124 return -ENOSYS;
127 static inline int gpio_request_array(const struct gpio *array, size_t num)
129 return -ENOSYS;
132 static inline void gpio_free(unsigned gpio)
134 might_sleep();
136 /* GPIO can never have been requested */
137 WARN_ON(1);
140 static inline void gpio_free_array(const struct gpio *array, size_t num)
142 might_sleep();
144 /* GPIO can never have been requested */
145 WARN_ON(1);
148 static inline int gpio_direction_input(unsigned gpio)
150 return -ENOSYS;
153 static inline int gpio_direction_output(unsigned gpio, int value)
155 return -ENOSYS;
158 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
160 return -ENOSYS;
163 static inline int gpio_get_value(unsigned gpio)
165 /* GPIO can never have been requested or set as {in,out}put */
166 WARN_ON(1);
167 return 0;
170 static inline void gpio_set_value(unsigned gpio, int value)
172 /* GPIO can never have been requested or set as output */
173 WARN_ON(1);
176 static inline int gpio_cansleep(unsigned gpio)
178 /* GPIO can never have been requested or set as {in,out}put */
179 WARN_ON(1);
180 return 0;
183 static inline int gpio_get_value_cansleep(unsigned gpio)
185 /* GPIO can never have been requested or set as {in,out}put */
186 WARN_ON(1);
187 return 0;
190 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
192 /* GPIO can never have been requested or set as output */
193 WARN_ON(1);
196 static inline int gpio_export(unsigned gpio, bool direction_may_change)
198 /* GPIO can never have been requested or set as {in,out}put */
199 WARN_ON(1);
200 return -EINVAL;
203 static inline int gpio_export_link(struct device *dev, const char *name,
204 unsigned gpio)
206 /* GPIO can never have been exported */
207 WARN_ON(1);
208 return -EINVAL;
211 static inline void gpio_unexport(unsigned gpio)
213 /* GPIO can never have been exported */
214 WARN_ON(1);
217 static inline int gpio_to_irq(unsigned gpio)
219 /* GPIO can never have been requested or set as input */
220 WARN_ON(1);
221 return -EINVAL;
224 static inline int irq_to_gpio(unsigned irq)
226 /* irq can never have been returned from gpio_to_irq() */
227 WARN_ON(1);
228 return -EINVAL;
231 static inline int devm_gpio_request(struct device *dev, unsigned gpio,
232 const char *label)
234 WARN_ON(1);
235 return -EINVAL;
238 static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
239 unsigned long flags, const char *label)
241 WARN_ON(1);
242 return -EINVAL;
245 static inline void devm_gpio_free(struct device *dev, unsigned int gpio)
247 WARN_ON(1);
250 #endif /* ! CONFIG_GPIOLIB */
252 #endif /* __LINUX_GPIO_H */