hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/include/uapi/linux/gpio.h
....@@ -11,21 +11,292 @@
1111 #ifndef _UAPI_GPIO_H_
1212 #define _UAPI_GPIO_H_
1313
14
+#include <linux/const.h>
1415 #include <linux/ioctl.h>
1516 #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
1624
1725 /**
1826 * struct gpiochip_info - Information about a certain GPIO chip
1927 * @name: the Linux kernel name of this GPIO chip
2028 * @label: a functional name for this GPIO chip, such as a product
21
- * number, may be NULL
29
+ * number, may be empty (i.e. label[0] == '\0')
2230 * @lines: number of GPIO lines on this chip
2331 */
2432 struct gpiochip_info {
25
- char name[32];
26
- char label[32];
33
+ char name[GPIO_MAX_NAME_SIZE];
34
+ char label[GPIO_MAX_NAME_SIZE];
2735 __u32 lines;
2836 };
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
+ */
69
+enum gpio_v2_line_flag {
70
+ GPIO_V2_LINE_FLAG_USED = _BITULL(0),
71
+ GPIO_V2_LINE_FLAG_ACTIVE_LOW = _BITULL(1),
72
+ GPIO_V2_LINE_FLAG_INPUT = _BITULL(2),
73
+ GPIO_V2_LINE_FLAG_OUTPUT = _BITULL(3),
74
+ GPIO_V2_LINE_FLAG_EDGE_RISING = _BITULL(4),
75
+ GPIO_V2_LINE_FLAG_EDGE_FALLING = _BITULL(5),
76
+ GPIO_V2_LINE_FLAG_OPEN_DRAIN = _BITULL(6),
77
+ GPIO_V2_LINE_FLAG_OPEN_SOURCE = _BITULL(7),
78
+ GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8),
79
+ GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9),
80
+ GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10),
81
+};
82
+
83
+/**
84
+ * struct gpio_v2_line_values - Values of GPIO lines
85
+ * @bits: a bitmap containing the value of the lines, set to 1 for active
86
+ * and 0 for inactive.
87
+ * @mask: a bitmap identifying the lines to get or set, with each bit
88
+ * number corresponding to the index into &struct
89
+ * gpio_v2_line_request.offsets.
90
+ */
91
+struct gpio_v2_line_values {
92
+ __aligned_u64 bits;
93
+ __aligned_u64 mask;
94
+};
95
+
96
+/**
97
+ * enum gpio_v2_line_attr_id - &struct gpio_v2_line_attribute.id values
98
+ * identifying which field of the attribute union is in use.
99
+ * @GPIO_V2_LINE_ATTR_ID_FLAGS: flags field is in use
100
+ * @GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES: values field is in use
101
+ * @GPIO_V2_LINE_ATTR_ID_DEBOUNCE: debounce_period_us field is in use
102
+ */
103
+enum gpio_v2_line_attr_id {
104
+ GPIO_V2_LINE_ATTR_ID_FLAGS = 1,
105
+ GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2,
106
+ GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3,
107
+};
108
+
109
+/**
110
+ * struct gpio_v2_line_attribute - a configurable attribute of a line
111
+ * @id: attribute identifier with value from &enum gpio_v2_line_attr_id
112
+ * @padding: reserved for future use and must be zero filled
113
+ * @flags: if id is %GPIO_V2_LINE_ATTR_ID_FLAGS, the flags for the GPIO
114
+ * line, with values from &enum gpio_v2_line_flag, such as
115
+ * %GPIO_V2_LINE_FLAG_ACTIVE_LOW, %GPIO_V2_LINE_FLAG_OUTPUT etc, added
116
+ * together. This overrides the default flags contained in the &struct
117
+ * gpio_v2_line_config for the associated line.
118
+ * @values: if id is %GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES, a bitmap
119
+ * containing the values to which the lines will be set, with each bit
120
+ * number corresponding to the index into &struct
121
+ * gpio_v2_line_request.offsets.
122
+ * @debounce_period_us: if id is %GPIO_V2_LINE_ATTR_ID_DEBOUNCE, the
123
+ * desired debounce period, in microseconds
124
+ */
125
+struct gpio_v2_line_attribute {
126
+ __u32 id;
127
+ __u32 padding;
128
+ union {
129
+ __aligned_u64 flags;
130
+ __aligned_u64 values;
131
+ __u32 debounce_period_us;
132
+ };
133
+};
134
+
135
+/**
136
+ * struct gpio_v2_line_config_attribute - a configuration attribute
137
+ * associated with one or more of the requested lines.
138
+ * @attr: the configurable attribute
139
+ * @mask: a bitmap identifying the lines to which the attribute applies,
140
+ * with each bit number corresponding to the index into &struct
141
+ * gpio_v2_line_request.offsets.
142
+ */
143
+struct gpio_v2_line_config_attribute {
144
+ struct gpio_v2_line_attribute attr;
145
+ __aligned_u64 mask;
146
+};
147
+
148
+/**
149
+ * struct gpio_v2_line_config - Configuration for GPIO lines
150
+ * @flags: flags for the GPIO lines, with values from &enum
151
+ * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW,
152
+ * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together. This is the default for
153
+ * all requested lines but may be overridden for particular lines using
154
+ * @attrs.
155
+ * @num_attrs: the number of attributes in @attrs
156
+ * @padding: reserved for future use and must be zero filled
157
+ * @attrs: the configuration attributes associated with the requested
158
+ * lines. Any attribute should only be associated with a particular line
159
+ * once. If an attribute is associated with a line multiple times then the
160
+ * first occurrence (i.e. lowest index) has precedence.
161
+ */
162
+struct gpio_v2_line_config {
163
+ __aligned_u64 flags;
164
+ __u32 num_attrs;
165
+ /* Pad to fill implicit padding and reserve space for future use. */
166
+ __u32 padding[5];
167
+ struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
168
+};
169
+
170
+/**
171
+ * struct gpio_v2_line_request - Information about a request for GPIO lines
172
+ * @offsets: an array of desired lines, specified by offset index for the
173
+ * associated GPIO chip
174
+ * @consumer: a desired consumer label for the selected GPIO lines such as
175
+ * "my-bitbanged-relay"
176
+ * @config: requested configuration for the lines.
177
+ * @num_lines: number of lines requested in this request, i.e. the number
178
+ * of valid fields in the %GPIO_V2_LINES_MAX sized arrays, set to 1 to
179
+ * request a single line
180
+ * @event_buffer_size: a suggested minimum number of line events that the
181
+ * kernel should buffer. This is only relevant if edge detection is
182
+ * enabled in the configuration. Note that this is only a suggested value
183
+ * and the kernel may allocate a larger buffer or cap the size of the
184
+ * buffer. If this field is zero then the buffer size defaults to a minimum
185
+ * of @num_lines * 16.
186
+ * @padding: reserved for future use and must be zero filled
187
+ * @fd: if successful this field will contain a valid anonymous file handle
188
+ * after a %GPIO_GET_LINE_IOCTL operation, zero or negative value means
189
+ * error
190
+ */
191
+struct gpio_v2_line_request {
192
+ __u32 offsets[GPIO_V2_LINES_MAX];
193
+ char consumer[GPIO_MAX_NAME_SIZE];
194
+ struct gpio_v2_line_config config;
195
+ __u32 num_lines;
196
+ __u32 event_buffer_size;
197
+ /* Pad to fill implicit padding and reserve space for future use. */
198
+ __u32 padding[5];
199
+ __s32 fd;
200
+};
201
+
202
+/**
203
+ * struct gpio_v2_line_info - Information about a certain GPIO line
204
+ * @name: the name of this GPIO line, such as the output pin of the line on
205
+ * the chip, a rail or a pin header name on a board, as specified by the
206
+ * GPIO chip, may be empty (i.e. name[0] == '\0')
207
+ * @consumer: a functional name for the consumer of this GPIO line as set
208
+ * by whatever is using it, will be empty if there is no current user but
209
+ * may also be empty if the consumer doesn't set this up
210
+ * @offset: the local offset on this GPIO chip, fill this in when
211
+ * requesting the line information from the kernel
212
+ * @num_attrs: the number of attributes in @attrs
213
+ * @flags: flags for the GPIO lines, with values from &enum
214
+ * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW,
215
+ * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together.
216
+ * @attrs: the configuration attributes associated with the line
217
+ * @padding: reserved for future use
218
+ */
219
+struct gpio_v2_line_info {
220
+ char name[GPIO_MAX_NAME_SIZE];
221
+ char consumer[GPIO_MAX_NAME_SIZE];
222
+ __u32 offset;
223
+ __u32 num_attrs;
224
+ __aligned_u64 flags;
225
+ struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
226
+ /* Space reserved for future use. */
227
+ __u32 padding[4];
228
+};
229
+
230
+/**
231
+ * enum gpio_v2_line_changed_type - &struct gpio_v2_line_changed.event_type
232
+ * values
233
+ * @GPIO_V2_LINE_CHANGED_REQUESTED: line has been requested
234
+ * @GPIO_V2_LINE_CHANGED_RELEASED: line has been released
235
+ * @GPIO_V2_LINE_CHANGED_CONFIG: line has been reconfigured
236
+ */
237
+enum gpio_v2_line_changed_type {
238
+ GPIO_V2_LINE_CHANGED_REQUESTED = 1,
239
+ GPIO_V2_LINE_CHANGED_RELEASED = 2,
240
+ GPIO_V2_LINE_CHANGED_CONFIG = 3,
241
+};
242
+
243
+/**
244
+ * struct gpio_v2_line_info_changed - Information about a change in status
245
+ * of a GPIO line
246
+ * @info: updated line information
247
+ * @timestamp_ns: estimate of time of status change occurrence, in nanoseconds
248
+ * @event_type: the type of change with a value from &enum
249
+ * gpio_v2_line_changed_type
250
+ * @padding: reserved for future use
251
+ */
252
+struct gpio_v2_line_info_changed {
253
+ struct gpio_v2_line_info info;
254
+ __aligned_u64 timestamp_ns;
255
+ __u32 event_type;
256
+ /* Pad struct to 64-bit boundary and reserve space for future use. */
257
+ __u32 padding[5];
258
+};
259
+
260
+/**
261
+ * enum gpio_v2_line_event_id - &struct gpio_v2_line_event.id values
262
+ * @GPIO_V2_LINE_EVENT_RISING_EDGE: event triggered by a rising edge
263
+ * @GPIO_V2_LINE_EVENT_FALLING_EDGE: event triggered by a falling edge
264
+ */
265
+enum gpio_v2_line_event_id {
266
+ GPIO_V2_LINE_EVENT_RISING_EDGE = 1,
267
+ GPIO_V2_LINE_EVENT_FALLING_EDGE = 2,
268
+};
269
+
270
+/**
271
+ * struct gpio_v2_line_event - The actual event being pushed to userspace
272
+ * @timestamp_ns: best estimate of time of event occurrence, in nanoseconds.
273
+ * The @timestamp_ns is read from %CLOCK_MONOTONIC and is intended to allow
274
+ * the accurate measurement of the time between events. It does not provide
275
+ * the wall-clock time.
276
+ * @id: event identifier with value from &enum gpio_v2_line_event_id
277
+ * @offset: the offset of the line that triggered the event
278
+ * @seqno: the sequence number for this event in the sequence of events for
279
+ * all the lines in this line request
280
+ * @line_seqno: the sequence number for this event in the sequence of
281
+ * events on this particular line
282
+ * @padding: reserved for future use
283
+ */
284
+struct gpio_v2_line_event {
285
+ __aligned_u64 timestamp_ns;
286
+ __u32 id;
287
+ __u32 offset;
288
+ __u32 seqno;
289
+ __u32 line_seqno;
290
+ /* Space reserved for future use. */
291
+ __u32 padding[6];
292
+};
293
+
294
+/*
295
+ * ABI v1
296
+ *
297
+ * This version of the ABI is deprecated.
298
+ * Use the latest version of the ABI, defined above, instead.
299
+ */
29300
30301 /* Informational flags */
31302 #define GPIOLINE_FLAG_KERNEL (1UL << 0) /* Line used by the kernel */
....@@ -33,6 +304,9 @@
33304 #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2)
34305 #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3)
35306 #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4)
307
+#define GPIOLINE_FLAG_BIAS_PULL_UP (1UL << 5)
308
+#define GPIOLINE_FLAG_BIAS_PULL_DOWN (1UL << 6)
309
+#define GPIOLINE_FLAG_BIAS_DISABLE (1UL << 7)
36310
37311 /**
38312 * struct gpioline_info - Information about a certain GPIO line
....@@ -41,20 +315,55 @@
41315 * @flags: various flags for this line
42316 * @name: the name of this GPIO line, such as the output pin of the line on the
43317 * chip, a rail or a pin header name on a board, as specified by the gpio
44
- * chip, may be NULL
318
+ * chip, may be empty (i.e. name[0] == '\0')
45319 * @consumer: a functional name for the consumer of this GPIO line as set by
46
- * whatever is using it, will be NULL if there is no current user but may
47
- * also be NULL if the consumer doesn't set this up
320
+ * whatever is using it, will be empty if there is no current user but may
321
+ * also be empty if the consumer doesn't set this up
322
+ *
323
+ * Note: This struct is part of ABI v1 and is deprecated.
324
+ * Use &struct gpio_v2_line_info instead.
48325 */
49326 struct gpioline_info {
50327 __u32 line_offset;
51328 __u32 flags;
52
- char name[32];
53
- char consumer[32];
329
+ char name[GPIO_MAX_NAME_SIZE];
330
+ char consumer[GPIO_MAX_NAME_SIZE];
54331 };
55332
56333 /* Maximum number of requested handles */
57334 #define GPIOHANDLES_MAX 64
335
+
336
+/* Possible line status change events */
337
+enum {
338
+ GPIOLINE_CHANGED_REQUESTED = 1,
339
+ GPIOLINE_CHANGED_RELEASED,
340
+ GPIOLINE_CHANGED_CONFIG,
341
+};
342
+
343
+/**
344
+ * struct gpioline_info_changed - Information about a change in status
345
+ * of a GPIO line
346
+ * @info: updated line information
347
+ * @timestamp: estimate of time of status change occurrence, in nanoseconds
348
+ * @event_type: one of %GPIOLINE_CHANGED_REQUESTED,
349
+ * %GPIOLINE_CHANGED_RELEASED and %GPIOLINE_CHANGED_CONFIG
350
+ * @padding: reserved for future use
351
+ *
352
+ * The &struct gpioline_info embedded here has 32-bit alignment on its own,
353
+ * but it works fine with 64-bit alignment too. With its 72 byte size, we can
354
+ * guarantee there are no implicit holes between it and subsequent members.
355
+ * The 20-byte padding at the end makes sure we don't add any implicit padding
356
+ * at the end of the structure on 64-bit architectures.
357
+ *
358
+ * Note: This struct is part of ABI v1 and is deprecated.
359
+ * Use &struct gpio_v2_line_info_changed instead.
360
+ */
361
+struct gpioline_info_changed {
362
+ struct gpioline_info info;
363
+ __u64 timestamp;
364
+ __u32 event_type;
365
+ __u32 padding[5]; /* for future use */
366
+};
58367
59368 /* Linerequest flags */
60369 #define GPIOHANDLE_REQUEST_INPUT (1UL << 0)
....@@ -62,19 +371,22 @@
62371 #define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2)
63372 #define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3)
64373 #define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4)
374
+#define GPIOHANDLE_REQUEST_BIAS_PULL_UP (1UL << 5)
375
+#define GPIOHANDLE_REQUEST_BIAS_PULL_DOWN (1UL << 6)
376
+#define GPIOHANDLE_REQUEST_BIAS_DISABLE (1UL << 7)
65377
66378 /**
67379 * struct gpiohandle_request - Information about a GPIO handle request
68
- * @lineoffsets: an array desired lines, specified by offset index for the
380
+ * @lineoffsets: an array of desired lines, specified by offset index for the
69381 * associated GPIO device
70382 * @flags: desired flags for the desired GPIO lines, such as
71
- * GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_ACTIVE_LOW etc, OR:ed
383
+ * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added
72384 * together. Note that even if multiple lines are requested, the same flags
73385 * must be applicable to all of them, if you want lines with individual
74386 * flags set, request them one by one. It is possible to select
75387 * a batch of input or output lines, but they must all have the same
76388 * characteristics, i.e. all inputs or all outputs, all active low etc
77
- * @default_values: if the GPIOHANDLE_REQUEST_OUTPUT is set for a requested
389
+ * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set for a requested
78390 * line, this specifies the default output value, should be 0 (low) or
79391 * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high)
80392 * @consumer_label: a desired consumer label for the selected GPIO line(s)
....@@ -82,16 +394,38 @@
82394 * @lines: number of lines requested in this request, i.e. the number of
83395 * valid fields in the above arrays, set to 1 to request a single line
84396 * @fd: if successful this field will contain a valid anonymous file handle
85
- * after a GPIO_GET_LINEHANDLE_IOCTL operation, zero or negative value
397
+ * after a %GPIO_GET_LINEHANDLE_IOCTL operation, zero or negative value
86398 * means error
399
+ *
400
+ * Note: This struct is part of ABI v1 and is deprecated.
401
+ * Use &struct gpio_v2_line_request instead.
87402 */
88403 struct gpiohandle_request {
89404 __u32 lineoffsets[GPIOHANDLES_MAX];
90405 __u32 flags;
91406 __u8 default_values[GPIOHANDLES_MAX];
92
- char consumer_label[32];
407
+ char consumer_label[GPIO_MAX_NAME_SIZE];
93408 __u32 lines;
94409 int fd;
410
+};
411
+
412
+/**
413
+ * struct gpiohandle_config - Configuration for a GPIO handle request
414
+ * @flags: updated flags for the requested GPIO lines, such as
415
+ * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added
416
+ * together
417
+ * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set in flags,
418
+ * this specifies the default output value, should be 0 (low) or
419
+ * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high)
420
+ * @padding: reserved for future use and should be zero filled
421
+ *
422
+ * Note: This struct is part of ABI v1 and is deprecated.
423
+ * Use &struct gpio_v2_line_config instead.
424
+ */
425
+struct gpiohandle_config {
426
+ __u32 flags;
427
+ __u8 default_values[GPIOHANDLES_MAX];
428
+ __u32 padding[4]; /* padding for future use */
95429 };
96430
97431 /**
....@@ -99,13 +433,13 @@
99433 * @values: when getting the state of lines this contains the current
100434 * state of a line, when setting the state of lines these should contain
101435 * the desired target state
436
+ *
437
+ * Note: This struct is part of ABI v1 and is deprecated.
438
+ * Use &struct gpio_v2_line_values instead.
102439 */
103440 struct gpiohandle_data {
104441 __u8 values[GPIOHANDLES_MAX];
105442 };
106
-
107
-#define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data)
108
-#define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data)
109443
110444 /* Eventrequest flags */
111445 #define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0)
....@@ -117,24 +451,27 @@
117451 * @lineoffset: the desired line to subscribe to events from, specified by
118452 * offset index for the associated GPIO device
119453 * @handleflags: desired handle flags for the desired GPIO line, such as
120
- * GPIOHANDLE_REQUEST_ACTIVE_LOW or GPIOHANDLE_REQUEST_OPEN_DRAIN
454
+ * %GPIOHANDLE_REQUEST_ACTIVE_LOW or %GPIOHANDLE_REQUEST_OPEN_DRAIN
121455 * @eventflags: desired flags for the desired GPIO event line, such as
122
- * GPIOEVENT_REQUEST_RISING_EDGE or GPIOEVENT_REQUEST_FALLING_EDGE
456
+ * %GPIOEVENT_REQUEST_RISING_EDGE or %GPIOEVENT_REQUEST_FALLING_EDGE
123457 * @consumer_label: a desired consumer label for the selected GPIO line(s)
124458 * such as "my-listener"
125459 * @fd: if successful this field will contain a valid anonymous file handle
126
- * after a GPIO_GET_LINEEVENT_IOCTL operation, zero or negative value
460
+ * after a %GPIO_GET_LINEEVENT_IOCTL operation, zero or negative value
127461 * means error
462
+ *
463
+ * Note: This struct is part of ABI v1 and is deprecated.
464
+ * Use &struct gpio_v2_line_request instead.
128465 */
129466 struct gpioevent_request {
130467 __u32 lineoffset;
131468 __u32 handleflags;
132469 __u32 eventflags;
133
- char consumer_label[32];
470
+ char consumer_label[GPIO_MAX_NAME_SIZE];
134471 int fd;
135472 };
136473
137
-/**
474
+/*
138475 * GPIO event types
139476 */
140477 #define GPIOEVENT_EVENT_RISING_EDGE 0x01
....@@ -144,15 +481,42 @@
144481 * struct gpioevent_data - The actual event being pushed to userspace
145482 * @timestamp: best estimate of time of event occurrence, in nanoseconds
146483 * @id: event identifier
484
+ *
485
+ * Note: This struct is part of ABI v1 and is deprecated.
486
+ * Use &struct gpio_v2_line_event instead.
147487 */
148488 struct gpioevent_data {
149489 __u64 timestamp;
150490 __u32 id;
151491 };
152492
493
+/*
494
+ * v1 and v2 ioctl()s
495
+ */
153496 #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info)
497
+#define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32)
498
+
499
+/*
500
+ * v2 ioctl()s
501
+ */
502
+#define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info)
503
+#define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info)
504
+#define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request)
505
+#define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config)
506
+#define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values)
507
+#define GPIO_V2_LINE_SET_VALUES_IOCTL _IOWR(0xB4, 0x0F, struct gpio_v2_line_values)
508
+
509
+/*
510
+ * v1 ioctl()s
511
+ *
512
+ * These ioctl()s are deprecated. Use the v2 equivalent instead.
513
+ */
154514 #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info)
155515 #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request)
156516 #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request)
517
+#define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data)
518
+#define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data)
519
+#define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config)
520
+#define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info)
157521
158522 #endif /* _UAPI_GPIO_H_ */