This source file includes following definitions.
- gpio_get_value
- gpio_set_value
- gpio_cansleep
- gpio_to_irq
- irq_to_gpio
- gpio_is_valid
- gpio_request
- gpio_request_one
- gpio_request_array
- gpio_free
- gpio_free_array
- gpio_direction_input
- gpio_direction_output
- gpio_set_debounce
- gpio_get_value
- gpio_set_value
- gpio_cansleep
- gpio_get_value_cansleep
- gpio_set_value_cansleep
- gpio_export
- gpio_export_link
- gpio_unexport
- gpio_to_irq
- irq_to_gpio
- devm_gpio_request
- devm_gpio_request_one
- devm_gpio_free
1
2
3
4
5
6
7
8
9
10
11
12 #ifndef __LINUX_GPIO_H
13 #define __LINUX_GPIO_H
14
15 #include <linux/errno.h>
16
17
18
19
20 #define GPIOF_DIR_OUT (0 << 0)
21 #define GPIOF_DIR_IN (1 << 0)
22
23 #define GPIOF_INIT_LOW (0 << 1)
24 #define GPIOF_INIT_HIGH (1 << 1)
25
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)
29
30
31 #define GPIOF_ACTIVE_LOW (1 << 2)
32
33
34 #define GPIOF_OPEN_DRAIN (1 << 3)
35
36
37 #define GPIOF_OPEN_SOURCE (1 << 4)
38
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)
43
44
45
46
47
48
49
50 struct gpio {
51 unsigned gpio;
52 unsigned long flags;
53 const char *label;
54 };
55
56 #ifdef CONFIG_GPIOLIB
57
58 #ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H
59 #include <asm/gpio.h>
60 #else
61
62 #include <asm-generic/gpio.h>
63
64 static inline int gpio_get_value(unsigned int gpio)
65 {
66 return __gpio_get_value(gpio);
67 }
68
69 static inline void gpio_set_value(unsigned int gpio, int value)
70 {
71 __gpio_set_value(gpio, value);
72 }
73
74 static inline int gpio_cansleep(unsigned int gpio)
75 {
76 return __gpio_cansleep(gpio);
77 }
78
79 static inline int gpio_to_irq(unsigned int gpio)
80 {
81 return __gpio_to_irq(gpio);
82 }
83
84 static inline int irq_to_gpio(unsigned int irq)
85 {
86 return -EINVAL;
87 }
88
89 #endif
90
91
92
93 struct device;
94
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);
99
100 #else
101
102 #include <linux/kernel.h>
103 #include <linux/types.h>
104 #include <linux/bug.h>
105 #include <linux/pinctrl/pinctrl.h>
106
107 struct device;
108 struct gpio_chip;
109 struct pinctrl_dev;
110
111 static inline bool gpio_is_valid(int number)
112 {
113 return false;
114 }
115
116 static inline int gpio_request(unsigned gpio, const char *label)
117 {
118 return -ENOSYS;
119 }
120
121 static inline int gpio_request_one(unsigned gpio,
122 unsigned long flags, const char *label)
123 {
124 return -ENOSYS;
125 }
126
127 static inline int gpio_request_array(const struct gpio *array, size_t num)
128 {
129 return -ENOSYS;
130 }
131
132 static inline void gpio_free(unsigned gpio)
133 {
134 might_sleep();
135
136
137 WARN_ON(1);
138 }
139
140 static inline void gpio_free_array(const struct gpio *array, size_t num)
141 {
142 might_sleep();
143
144
145 WARN_ON(1);
146 }
147
148 static inline int gpio_direction_input(unsigned gpio)
149 {
150 return -ENOSYS;
151 }
152
153 static inline int gpio_direction_output(unsigned gpio, int value)
154 {
155 return -ENOSYS;
156 }
157
158 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
159 {
160 return -ENOSYS;
161 }
162
163 static inline int gpio_get_value(unsigned gpio)
164 {
165
166 WARN_ON(1);
167 return 0;
168 }
169
170 static inline void gpio_set_value(unsigned gpio, int value)
171 {
172
173 WARN_ON(1);
174 }
175
176 static inline int gpio_cansleep(unsigned gpio)
177 {
178
179 WARN_ON(1);
180 return 0;
181 }
182
183 static inline int gpio_get_value_cansleep(unsigned gpio)
184 {
185
186 WARN_ON(1);
187 return 0;
188 }
189
190 static inline void gpio_set_value_cansleep(unsigned gpio, int value)
191 {
192
193 WARN_ON(1);
194 }
195
196 static inline int gpio_export(unsigned gpio, bool direction_may_change)
197 {
198
199 WARN_ON(1);
200 return -EINVAL;
201 }
202
203 static inline int gpio_export_link(struct device *dev, const char *name,
204 unsigned gpio)
205 {
206
207 WARN_ON(1);
208 return -EINVAL;
209 }
210
211 static inline void gpio_unexport(unsigned gpio)
212 {
213
214 WARN_ON(1);
215 }
216
217 static inline int gpio_to_irq(unsigned gpio)
218 {
219
220 WARN_ON(1);
221 return -EINVAL;
222 }
223
224 static inline int irq_to_gpio(unsigned irq)
225 {
226
227 WARN_ON(1);
228 return -EINVAL;
229 }
230
231 static inline int devm_gpio_request(struct device *dev, unsigned gpio,
232 const char *label)
233 {
234 WARN_ON(1);
235 return -EINVAL;
236 }
237
238 static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
239 unsigned long flags, const char *label)
240 {
241 WARN_ON(1);
242 return -EINVAL;
243 }
244
245 static inline void devm_gpio_free(struct device *dev, unsigned int gpio)
246 {
247 WARN_ON(1);
248 }
249
250 #endif
251
252 #endif