1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ |
2 | /* |
3 | * <linux/gpio.h> - userspace ABI for the GPIO character devices |
4 | * |
5 | * Copyright (C) 2016 Linus Walleij |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify it |
8 | * under the terms of the GNU General Public License version 2 as published by |
9 | * the Free Software Foundation. |
10 | */ |
11 | #ifndef _UAPI_GPIO_H_ |
12 | #define _UAPI_GPIO_H_ |
13 | |
14 | #include <linux/const.h> |
15 | #include <linux/ioctl.h> |
16 | #include <linux/types.h> |
17 | |
18 | /* |
19 | * The maximum size of name and label arrays. |
20 | * |
21 | * Must be a multiple of 8 to ensure 32/64-bit alignment of structs. |
22 | */ |
23 | #define GPIO_MAX_NAME_SIZE 32 |
24 | |
25 | /** |
26 | * struct gpiochip_info - Information about a certain GPIO chip |
27 | * @name: the Linux kernel name of this GPIO chip |
28 | * @label: a functional name for this GPIO chip, such as a product |
29 | * number, may be empty (i.e. label[0] == '\0') |
30 | * @lines: number of GPIO lines on this chip |
31 | */ |
32 | struct gpiochip_info { |
33 | char name[GPIO_MAX_NAME_SIZE]; |
34 | char label[GPIO_MAX_NAME_SIZE]; |
35 | __u32 lines; |
36 | }; |
37 | |
38 | /* |
39 | * Maximum number of requested lines. |
40 | * |
41 | * Must be no greater than 64, as bitmaps are restricted here to 64-bits |
42 | * for simplicity, and a multiple of 2 to ensure 32/64-bit alignment of |
43 | * structs. |
44 | */ |
45 | #define GPIO_V2_LINES_MAX 64 |
46 | |
47 | /* |
48 | * The maximum number of configuration attributes associated with a line |
49 | * request. |
50 | */ |
51 | #define GPIO_V2_LINE_NUM_ATTRS_MAX 10 |
52 | |
53 | /** |
54 | * enum gpio_v2_line_flag - &struct gpio_v2_line_attribute.flags values |
55 | * @GPIO_V2_LINE_FLAG_USED: line is not available for request |
56 | * @GPIO_V2_LINE_FLAG_ACTIVE_LOW: line active state is physical low |
57 | * @GPIO_V2_LINE_FLAG_INPUT: line is an input |
58 | * @GPIO_V2_LINE_FLAG_OUTPUT: line is an output |
59 | * @GPIO_V2_LINE_FLAG_EDGE_RISING: line detects rising (inactive to active) |
60 | * edges |
61 | * @GPIO_V2_LINE_FLAG_EDGE_FALLING: line detects falling (active to |
62 | * inactive) edges |
63 | * @GPIO_V2_LINE_FLAG_OPEN_DRAIN: line is an open drain output |
64 | * @GPIO_V2_LINE_FLAG_OPEN_SOURCE: line is an open source output |
65 | * @GPIO_V2_LINE_FLAG_BIAS_PULL_UP: line has pull-up bias enabled |
66 | * @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled |
67 | * @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled |
68 | * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps |
69 | * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE: line events contain timestamps from |
70 | * hardware timestamp engine |
71 | */ |
72 | enum gpio_v2_line_flag { |
73 | GPIO_V2_LINE_FLAG_USED = _BITULL(0), |
74 | GPIO_V2_LINE_FLAG_ACTIVE_LOW = _BITULL(1), |
75 | GPIO_V2_LINE_FLAG_INPUT = _BITULL(2), |
76 | GPIO_V2_LINE_FLAG_OUTPUT = _BITULL(3), |
77 | GPIO_V2_LINE_FLAG_EDGE_RISING = _BITULL(4), |
78 | GPIO_V2_LINE_FLAG_EDGE_FALLING = _BITULL(5), |
79 | GPIO_V2_LINE_FLAG_OPEN_DRAIN = _BITULL(6), |
80 | GPIO_V2_LINE_FLAG_OPEN_SOURCE = _BITULL(7), |
81 | GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8), |
82 | GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9), |
83 | GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10), |
84 | GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11), |
85 | GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12), |
86 | }; |
87 | |
88 | /** |
89 | * struct gpio_v2_line_values - Values of GPIO lines |
90 | * @bits: a bitmap containing the value of the lines, set to 1 for active |
91 | * and 0 for inactive. |
92 | * @mask: a bitmap identifying the lines to get or set, with each bit |
93 | * number corresponding to the index into &struct |
94 | * gpio_v2_line_request.offsets. |
95 | */ |
96 | struct gpio_v2_line_values { |
97 | __aligned_u64 bits; |
98 | __aligned_u64 mask; |
99 | }; |
100 | |
101 | /** |
102 | * enum gpio_v2_line_attr_id - &struct gpio_v2_line_attribute.id values |
103 | * identifying which field of the attribute union is in use. |
104 | * @GPIO_V2_LINE_ATTR_ID_FLAGS: flags field is in use |
105 | * @GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES: values field is in use |
106 | * @GPIO_V2_LINE_ATTR_ID_DEBOUNCE: debounce_period_us field is in use |
107 | */ |
108 | enum gpio_v2_line_attr_id { |
109 | GPIO_V2_LINE_ATTR_ID_FLAGS = 1, |
110 | GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2, |
111 | GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3, |
112 | }; |
113 | |
114 | /** |
115 | * struct gpio_v2_line_attribute - a configurable attribute of a line |
116 | * @id: attribute identifier with value from &enum gpio_v2_line_attr_id |
117 | * @padding: reserved for future use and must be zero filled |
118 | * @flags: if id is %GPIO_V2_LINE_ATTR_ID_FLAGS, the flags for the GPIO |
119 | * line, with values from &enum gpio_v2_line_flag, such as |
120 | * %GPIO_V2_LINE_FLAG_ACTIVE_LOW, %GPIO_V2_LINE_FLAG_OUTPUT etc, added |
121 | * together. This overrides the default flags contained in the &struct |
122 | * gpio_v2_line_config for the associated line. |
123 | * @values: if id is %GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES, a bitmap |
124 | * containing the values to which the lines will be set, with each bit |
125 | * number corresponding to the index into &struct |
126 | * gpio_v2_line_request.offsets. |
127 | * @debounce_period_us: if id is %GPIO_V2_LINE_ATTR_ID_DEBOUNCE, the |
128 | * desired debounce period, in microseconds |
129 | */ |
130 | struct gpio_v2_line_attribute { |
131 | __u32 id; |
132 | __u32 padding; |
133 | union { |
134 | __aligned_u64 flags; |
135 | __aligned_u64 values; |
136 | __u32 debounce_period_us; |
137 | }; |
138 | }; |
139 | |
140 | /** |
141 | * struct gpio_v2_line_config_attribute - a configuration attribute |
142 | * associated with one or more of the requested lines. |
143 | * @attr: the configurable attribute |
144 | * @mask: a bitmap identifying the lines to which the attribute applies, |
145 | * with each bit number corresponding to the index into &struct |
146 | * gpio_v2_line_request.offsets. |
147 | */ |
148 | struct gpio_v2_line_config_attribute { |
149 | struct gpio_v2_line_attribute attr; |
150 | __aligned_u64 mask; |
151 | }; |
152 | |
153 | /** |
154 | * struct gpio_v2_line_config - Configuration for GPIO lines |
155 | * @flags: flags for the GPIO lines, with values from &enum |
156 | * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW, |
157 | * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together. This is the default for |
158 | * all requested lines but may be overridden for particular lines using |
159 | * @attrs. |
160 | * @num_attrs: the number of attributes in @attrs |
161 | * @padding: reserved for future use and must be zero filled |
162 | * @attrs: the configuration attributes associated with the requested |
163 | * lines. Any attribute should only be associated with a particular line |
164 | * once. If an attribute is associated with a line multiple times then the |
165 | * first occurrence (i.e. lowest index) has precedence. |
166 | */ |
167 | struct gpio_v2_line_config { |
168 | __aligned_u64 flags; |
169 | __u32 num_attrs; |
170 | /* Pad to fill implicit padding and reserve space for future use. */ |
171 | __u32 padding[5]; |
172 | struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; |
173 | }; |
174 | |
175 | /** |
176 | * struct gpio_v2_line_request - Information about a request for GPIO lines |
177 | * @offsets: an array of desired lines, specified by offset index for the |
178 | * associated GPIO chip |
179 | * @consumer: a desired consumer label for the selected GPIO lines such as |
180 | * "my-bitbanged-relay" |
181 | * @config: requested configuration for the lines. |
182 | * @num_lines: number of lines requested in this request, i.e. the number |
183 | * of valid fields in the %GPIO_V2_LINES_MAX sized arrays, set to 1 to |
184 | * request a single line |
185 | * @event_buffer_size: a suggested minimum number of line events that the |
186 | * kernel should buffer. This is only relevant if edge detection is |
187 | * enabled in the configuration. Note that this is only a suggested value |
188 | * and the kernel may allocate a larger buffer or cap the size of the |
189 | * buffer. If this field is zero then the buffer size defaults to a minimum |
190 | * of @num_lines * 16. |
191 | * @padding: reserved for future use and must be zero filled |
192 | * @fd: if successful this field will contain a valid anonymous file handle |
193 | * after a %GPIO_GET_LINE_IOCTL operation, zero or negative value means |
194 | * error |
195 | */ |
196 | struct gpio_v2_line_request { |
197 | __u32 offsets[GPIO_V2_LINES_MAX]; |
198 | char consumer[GPIO_MAX_NAME_SIZE]; |
199 | struct gpio_v2_line_config config; |
200 | __u32 num_lines; |
201 | __u32 event_buffer_size; |
202 | /* Pad to fill implicit padding and reserve space for future use. */ |
203 | __u32 padding[5]; |
204 | __s32 fd; |
205 | }; |
206 | |
207 | /** |
208 | * struct gpio_v2_line_info - Information about a certain GPIO line |
209 | * @name: the name of this GPIO line, such as the output pin of the line on |
210 | * the chip, a rail or a pin header name on a board, as specified by the |
211 | * GPIO chip, may be empty (i.e. name[0] == '\0') |
212 | * @consumer: a functional name for the consumer of this GPIO line as set |
213 | * by whatever is using it, will be empty if there is no current user but |
214 | * may also be empty if the consumer doesn't set this up |
215 | * @offset: the local offset on this GPIO chip, fill this in when |
216 | * requesting the line information from the kernel |
217 | * @num_attrs: the number of attributes in @attrs |
218 | * @flags: flags for this GPIO line, with values from &enum |
219 | * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW, |
220 | * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together. |
221 | * @attrs: the configuration attributes associated with the line |
222 | * @padding: reserved for future use |
223 | */ |
224 | struct gpio_v2_line_info { |
225 | char name[GPIO_MAX_NAME_SIZE]; |
226 | char consumer[GPIO_MAX_NAME_SIZE]; |
227 | __u32 offset; |
228 | __u32 num_attrs; |
229 | __aligned_u64 flags; |
230 | struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; |
231 | /* Space reserved for future use. */ |
232 | __u32 padding[4]; |
233 | }; |
234 | |
235 | /** |
236 | * enum gpio_v2_line_changed_type - &struct gpio_v2_line_changed.event_type |
237 | * values |
238 | * @GPIO_V2_LINE_CHANGED_REQUESTED: line has been requested |
239 | * @GPIO_V2_LINE_CHANGED_RELEASED: line has been released |
240 | * @GPIO_V2_LINE_CHANGED_CONFIG: line has been reconfigured |
241 | */ |
242 | enum gpio_v2_line_changed_type { |
243 | GPIO_V2_LINE_CHANGED_REQUESTED = 1, |
244 | GPIO_V2_LINE_CHANGED_RELEASED = 2, |
245 | GPIO_V2_LINE_CHANGED_CONFIG = 3, |
246 | }; |
247 | |
248 | /** |
249 | * struct gpio_v2_line_info_changed - Information about a change in status |
250 | * of a GPIO line |
251 | * @info: updated line information |
252 | * @timestamp_ns: estimate of time of status change occurrence, in nanoseconds |
253 | * @event_type: the type of change with a value from &enum |
254 | * gpio_v2_line_changed_type |
255 | * @padding: reserved for future use |
256 | */ |
257 | struct gpio_v2_line_info_changed { |
258 | struct gpio_v2_line_info info; |
259 | __aligned_u64 timestamp_ns; |
260 | __u32 event_type; |
261 | /* Pad struct to 64-bit boundary and reserve space for future use. */ |
262 | __u32 padding[5]; |
263 | }; |
264 | |
265 | /** |
266 | * enum gpio_v2_line_event_id - &struct gpio_v2_line_event.id values |
267 | * @GPIO_V2_LINE_EVENT_RISING_EDGE: event triggered by a rising edge |
268 | * @GPIO_V2_LINE_EVENT_FALLING_EDGE: event triggered by a falling edge |
269 | */ |
270 | enum gpio_v2_line_event_id { |
271 | GPIO_V2_LINE_EVENT_RISING_EDGE = 1, |
272 | GPIO_V2_LINE_EVENT_FALLING_EDGE = 2, |
273 | }; |
274 | |
275 | /** |
276 | * struct gpio_v2_line_event - The actual event being pushed to userspace |
277 | * @timestamp_ns: best estimate of time of event occurrence, in nanoseconds. |
278 | * @id: event identifier with value from &enum gpio_v2_line_event_id |
279 | * @offset: the offset of the line that triggered the event |
280 | * @seqno: the sequence number for this event in the sequence of events for |
281 | * all the lines in this line request |
282 | * @line_seqno: the sequence number for this event in the sequence of |
283 | * events on this particular line |
284 | * @padding: reserved for future use |
285 | * |
286 | * By default the @timestamp_ns is read from %CLOCK_MONOTONIC and is |
287 | * intended to allow the accurate measurement of the time between events. |
288 | * It does not provide the wall-clock time. |
289 | * |
290 | * If the %GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME flag is set then the |
291 | * @timestamp_ns is read from %CLOCK_REALTIME. |
292 | */ |
293 | struct gpio_v2_line_event { |
294 | __aligned_u64 timestamp_ns; |
295 | __u32 id; |
296 | __u32 offset; |
297 | __u32 seqno; |
298 | __u32 line_seqno; |
299 | /* Space reserved for future use. */ |
300 | __u32 padding[6]; |
301 | }; |
302 | |
303 | /* |
304 | * ABI v1 |
305 | * |
306 | * This version of the ABI is deprecated. |
307 | * Use the latest version of the ABI, defined above, instead. |
308 | */ |
309 | |
310 | /* Informational flags */ |
311 | #define GPIOLINE_FLAG_KERNEL (1UL << 0) /* Line used by the kernel */ |
312 | #define GPIOLINE_FLAG_IS_OUT (1UL << 1) |
313 | #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2) |
314 | #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3) |
315 | #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4) |
316 | #define GPIOLINE_FLAG_BIAS_PULL_UP (1UL << 5) |
317 | #define GPIOLINE_FLAG_BIAS_PULL_DOWN (1UL << 6) |
318 | #define GPIOLINE_FLAG_BIAS_DISABLE (1UL << 7) |
319 | |
320 | /** |
321 | * struct gpioline_info - Information about a certain GPIO line |
322 | * @line_offset: the local offset on this GPIO device, fill this in when |
323 | * requesting the line information from the kernel |
324 | * @flags: various flags for this line |
325 | * @name: the name of this GPIO line, such as the output pin of the line on the |
326 | * chip, a rail or a pin header name on a board, as specified by the gpio |
327 | * chip, may be empty (i.e. name[0] == '\0') |
328 | * @consumer: a functional name for the consumer of this GPIO line as set by |
329 | * whatever is using it, will be empty if there is no current user but may |
330 | * also be empty if the consumer doesn't set this up |
331 | * |
332 | * Note: This struct is part of ABI v1 and is deprecated. |
333 | * Use &struct gpio_v2_line_info instead. |
334 | */ |
335 | struct gpioline_info { |
336 | __u32 line_offset; |
337 | __u32 flags; |
338 | char name[GPIO_MAX_NAME_SIZE]; |
339 | char consumer[GPIO_MAX_NAME_SIZE]; |
340 | }; |
341 | |
342 | /* Maximum number of requested handles */ |
343 | #define GPIOHANDLES_MAX 64 |
344 | |
345 | /* Possible line status change events */ |
346 | enum { |
347 | GPIOLINE_CHANGED_REQUESTED = 1, |
348 | GPIOLINE_CHANGED_RELEASED, |
349 | GPIOLINE_CHANGED_CONFIG, |
350 | }; |
351 | |
352 | /** |
353 | * struct gpioline_info_changed - Information about a change in status |
354 | * of a GPIO line |
355 | * @info: updated line information |
356 | * @timestamp: estimate of time of status change occurrence, in nanoseconds |
357 | * @event_type: one of %GPIOLINE_CHANGED_REQUESTED, |
358 | * %GPIOLINE_CHANGED_RELEASED and %GPIOLINE_CHANGED_CONFIG |
359 | * @padding: reserved for future use |
360 | * |
361 | * The &struct gpioline_info embedded here has 32-bit alignment on its own, |
362 | * but it works fine with 64-bit alignment too. With its 72 byte size, we can |
363 | * guarantee there are no implicit holes between it and subsequent members. |
364 | * The 20-byte padding at the end makes sure we don't add any implicit padding |
365 | * at the end of the structure on 64-bit architectures. |
366 | * |
367 | * Note: This struct is part of ABI v1 and is deprecated. |
368 | * Use &struct gpio_v2_line_info_changed instead. |
369 | */ |
370 | struct gpioline_info_changed { |
371 | struct gpioline_info info; |
372 | __u64 timestamp; |
373 | __u32 event_type; |
374 | __u32 padding[5]; /* for future use */ |
375 | }; |
376 | |
377 | /* Linerequest flags */ |
378 | #define GPIOHANDLE_REQUEST_INPUT (1UL << 0) |
379 | #define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1) |
380 | #define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2) |
381 | #define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3) |
382 | #define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4) |
383 | #define GPIOHANDLE_REQUEST_BIAS_PULL_UP (1UL << 5) |
384 | #define GPIOHANDLE_REQUEST_BIAS_PULL_DOWN (1UL << 6) |
385 | #define GPIOHANDLE_REQUEST_BIAS_DISABLE (1UL << 7) |
386 | |
387 | /** |
388 | * struct gpiohandle_request - Information about a GPIO handle request |
389 | * @lineoffsets: an array of desired lines, specified by offset index for the |
390 | * associated GPIO device |
391 | * @flags: desired flags for the desired GPIO lines, such as |
392 | * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added |
393 | * together. Note that even if multiple lines are requested, the same flags |
394 | * must be applicable to all of them, if you want lines with individual |
395 | * flags set, request them one by one. It is possible to select |
396 | * a batch of input or output lines, but they must all have the same |
397 | * characteristics, i.e. all inputs or all outputs, all active low etc |
398 | * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set for a requested |
399 | * line, this specifies the default output value, should be 0 (low) or |
400 | * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high) |
401 | * @consumer_label: a desired consumer label for the selected GPIO line(s) |
402 | * such as "my-bitbanged-relay" |
403 | * @lines: number of lines requested in this request, i.e. the number of |
404 | * valid fields in the above arrays, set to 1 to request a single line |
405 | * @fd: if successful this field will contain a valid anonymous file handle |
406 | * after a %GPIO_GET_LINEHANDLE_IOCTL operation, zero or negative value |
407 | * means error |
408 | * |
409 | * Note: This struct is part of ABI v1 and is deprecated. |
410 | * Use &struct gpio_v2_line_request instead. |
411 | */ |
412 | struct gpiohandle_request { |
413 | __u32 lineoffsets[GPIOHANDLES_MAX]; |
414 | __u32 flags; |
415 | __u8 default_values[GPIOHANDLES_MAX]; |
416 | char consumer_label[GPIO_MAX_NAME_SIZE]; |
417 | __u32 lines; |
418 | int fd; |
419 | }; |
420 | |
421 | /** |
422 | * struct gpiohandle_config - Configuration for a GPIO handle request |
423 | * @flags: updated flags for the requested GPIO lines, such as |
424 | * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added |
425 | * together |
426 | * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set in flags, |
427 | * this specifies the default output value, should be 0 (low) or |
428 | * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high) |
429 | * @padding: reserved for future use and should be zero filled |
430 | * |
431 | * Note: This struct is part of ABI v1 and is deprecated. |
432 | * Use &struct gpio_v2_line_config instead. |
433 | */ |
434 | struct gpiohandle_config { |
435 | __u32 flags; |
436 | __u8 default_values[GPIOHANDLES_MAX]; |
437 | __u32 padding[4]; /* padding for future use */ |
438 | }; |
439 | |
440 | /** |
441 | * struct gpiohandle_data - Information of values on a GPIO handle |
442 | * @values: when getting the state of lines this contains the current |
443 | * state of a line, when setting the state of lines these should contain |
444 | * the desired target state |
445 | * |
446 | * Note: This struct is part of ABI v1 and is deprecated. |
447 | * Use &struct gpio_v2_line_values instead. |
448 | */ |
449 | struct gpiohandle_data { |
450 | __u8 values[GPIOHANDLES_MAX]; |
451 | }; |
452 | |
453 | /* Eventrequest flags */ |
454 | #define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0) |
455 | #define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1) |
456 | #define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1)) |
457 | |
458 | /** |
459 | * struct gpioevent_request - Information about a GPIO event request |
460 | * @lineoffset: the desired line to subscribe to events from, specified by |
461 | * offset index for the associated GPIO device |
462 | * @handleflags: desired handle flags for the desired GPIO line, such as |
463 | * %GPIOHANDLE_REQUEST_ACTIVE_LOW or %GPIOHANDLE_REQUEST_OPEN_DRAIN |
464 | * @eventflags: desired flags for the desired GPIO event line, such as |
465 | * %GPIOEVENT_REQUEST_RISING_EDGE or %GPIOEVENT_REQUEST_FALLING_EDGE |
466 | * @consumer_label: a desired consumer label for the selected GPIO line(s) |
467 | * such as "my-listener" |
468 | * @fd: if successful this field will contain a valid anonymous file handle |
469 | * after a %GPIO_GET_LINEEVENT_IOCTL operation, zero or negative value |
470 | * means error |
471 | * |
472 | * Note: This struct is part of ABI v1 and is deprecated. |
473 | * Use &struct gpio_v2_line_request instead. |
474 | */ |
475 | struct gpioevent_request { |
476 | __u32 lineoffset; |
477 | __u32 handleflags; |
478 | __u32 eventflags; |
479 | char consumer_label[GPIO_MAX_NAME_SIZE]; |
480 | int fd; |
481 | }; |
482 | |
483 | /* |
484 | * GPIO event types |
485 | */ |
486 | #define GPIOEVENT_EVENT_RISING_EDGE 0x01 |
487 | #define GPIOEVENT_EVENT_FALLING_EDGE 0x02 |
488 | |
489 | /** |
490 | * struct gpioevent_data - The actual event being pushed to userspace |
491 | * @timestamp: best estimate of time of event occurrence, in nanoseconds |
492 | * @id: event identifier |
493 | * |
494 | * Note: This struct is part of ABI v1 and is deprecated. |
495 | * Use &struct gpio_v2_line_event instead. |
496 | */ |
497 | struct gpioevent_data { |
498 | __u64 timestamp; |
499 | __u32 id; |
500 | }; |
501 | |
502 | /* |
503 | * v1 and v2 ioctl()s |
504 | */ |
505 | #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info) |
506 | #define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32) |
507 | |
508 | /* |
509 | * v2 ioctl()s |
510 | */ |
511 | #define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info) |
512 | #define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info) |
513 | #define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request) |
514 | #define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config) |
515 | #define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values) |
516 | #define GPIO_V2_LINE_SET_VALUES_IOCTL _IOWR(0xB4, 0x0F, struct gpio_v2_line_values) |
517 | |
518 | /* |
519 | * v1 ioctl()s |
520 | * |
521 | * These ioctl()s are deprecated. Use the v2 equivalent instead. |
522 | */ |
523 | #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info) |
524 | #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request) |
525 | #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request) |
526 | #define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data) |
527 | #define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data) |
528 | #define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config) |
529 | #define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info) |
530 | |
531 | #endif /* _UAPI_GPIO_H_ */ |
532 | |