blob: 98d95b99261feedef45367f21695dd187a280d2d [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris106b3a82016-08-24 12:15:38 -07007#ifndef _UAPI_GPIO_H_
8#define _UAPI_GPIO_H_
Christopher Ferris32ff3f82020-12-14 13:10:04 -08009#include <linux/const.h>
Elliott Hughes8cb52b02013-11-21 13:43:23 -080010#include <linux/ioctl.h>
11#include <linux/types.h>
Christopher Ferris32ff3f82020-12-14 13:10:04 -080012#define GPIO_MAX_NAME_SIZE 32
Christopher Ferris106b3a82016-08-24 12:15:38 -070013struct gpiochip_info {
Christopher Ferris32ff3f82020-12-14 13:10:04 -080014 char name[GPIO_MAX_NAME_SIZE];
15 char label[GPIO_MAX_NAME_SIZE];
Christopher Ferris106b3a82016-08-24 12:15:38 -070016 __u32 lines;
Elliott Hughes8cb52b02013-11-21 13:43:23 -080017};
Christopher Ferris32ff3f82020-12-14 13:10:04 -080018#define GPIO_V2_LINES_MAX 64
19#define GPIO_V2_LINE_NUM_ATTRS_MAX 10
20enum gpio_v2_line_flag {
21 GPIO_V2_LINE_FLAG_USED = _BITULL(0),
22 GPIO_V2_LINE_FLAG_ACTIVE_LOW = _BITULL(1),
23 GPIO_V2_LINE_FLAG_INPUT = _BITULL(2),
24 GPIO_V2_LINE_FLAG_OUTPUT = _BITULL(3),
25 GPIO_V2_LINE_FLAG_EDGE_RISING = _BITULL(4),
26 GPIO_V2_LINE_FLAG_EDGE_FALLING = _BITULL(5),
27 GPIO_V2_LINE_FLAG_OPEN_DRAIN = _BITULL(6),
28 GPIO_V2_LINE_FLAG_OPEN_SOURCE = _BITULL(7),
29 GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8),
30 GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9),
31 GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10),
Christopher Ferris05667cd2021-02-16 16:01:34 -080032 GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11),
Christopher Ferris80ae69d2022-08-02 16:32:21 -070033 GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12),
Christopher Ferris32ff3f82020-12-14 13:10:04 -080034};
35struct gpio_v2_line_values {
36 __aligned_u64 bits;
37 __aligned_u64 mask;
38};
39enum gpio_v2_line_attr_id {
40 GPIO_V2_LINE_ATTR_ID_FLAGS = 1,
41 GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2,
42 GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3,
43};
44struct gpio_v2_line_attribute {
45 __u32 id;
46 __u32 padding;
47 union {
48 __aligned_u64 flags;
49 __aligned_u64 values;
50 __u32 debounce_period_us;
51 };
52};
53struct gpio_v2_line_config_attribute {
54 struct gpio_v2_line_attribute attr;
55 __aligned_u64 mask;
56};
57struct gpio_v2_line_config {
58 __aligned_u64 flags;
59 __u32 num_attrs;
60 __u32 padding[5];
61 struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
62};
63struct gpio_v2_line_request {
64 __u32 offsets[GPIO_V2_LINES_MAX];
65 char consumer[GPIO_MAX_NAME_SIZE];
66 struct gpio_v2_line_config config;
67 __u32 num_lines;
68 __u32 event_buffer_size;
69 __u32 padding[5];
70 __s32 fd;
71};
72struct gpio_v2_line_info {
73 char name[GPIO_MAX_NAME_SIZE];
74 char consumer[GPIO_MAX_NAME_SIZE];
75 __u32 offset;
76 __u32 num_attrs;
77 __aligned_u64 flags;
78 struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX];
79 __u32 padding[4];
80};
81enum gpio_v2_line_changed_type {
82 GPIO_V2_LINE_CHANGED_REQUESTED = 1,
83 GPIO_V2_LINE_CHANGED_RELEASED = 2,
84 GPIO_V2_LINE_CHANGED_CONFIG = 3,
85};
86struct gpio_v2_line_info_changed {
87 struct gpio_v2_line_info info;
88 __aligned_u64 timestamp_ns;
89 __u32 event_type;
90 __u32 padding[5];
91};
92enum gpio_v2_line_event_id {
93 GPIO_V2_LINE_EVENT_RISING_EDGE = 1,
94 GPIO_V2_LINE_EVENT_FALLING_EDGE = 2,
95};
96struct gpio_v2_line_event {
97 __aligned_u64 timestamp_ns;
98 __u32 id;
99 __u32 offset;
100 __u32 seqno;
101 __u32 line_seqno;
102 __u32 padding[6];
103};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700104#define GPIOLINE_FLAG_KERNEL (1UL << 0)
105#define GPIOLINE_FLAG_IS_OUT (1UL << 1)
106#define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700107#define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3)
108#define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800109#define GPIOLINE_FLAG_BIAS_PULL_UP (1UL << 5)
110#define GPIOLINE_FLAG_BIAS_PULL_DOWN (1UL << 6)
111#define GPIOLINE_FLAG_BIAS_DISABLE (1UL << 7)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700112struct gpioline_info {
113 __u32 line_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700114 __u32 flags;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800115 char name[GPIO_MAX_NAME_SIZE];
116 char consumer[GPIO_MAX_NAME_SIZE];
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800117};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800118#define GPIOHANDLES_MAX 64
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700119enum {
120 GPIOLINE_CHANGED_REQUESTED = 1,
121 GPIOLINE_CHANGED_RELEASED,
122 GPIOLINE_CHANGED_CONFIG,
123};
124struct gpioline_info_changed {
125 struct gpioline_info info;
126 __u64 timestamp;
127 __u32 event_type;
128 __u32 padding[5];
129};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800130#define GPIOHANDLE_REQUEST_INPUT (1UL << 0)
131#define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1)
132#define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800133#define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3)
134#define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800135#define GPIOHANDLE_REQUEST_BIAS_PULL_UP (1UL << 5)
136#define GPIOHANDLE_REQUEST_BIAS_PULL_DOWN (1UL << 6)
137#define GPIOHANDLE_REQUEST_BIAS_DISABLE (1UL << 7)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800138struct gpiohandle_request {
139 __u32 lineoffsets[GPIOHANDLES_MAX];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800140 __u32 flags;
141 __u8 default_values[GPIOHANDLES_MAX];
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800142 char consumer_label[GPIO_MAX_NAME_SIZE];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800143 __u32 lines;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800144 int fd;
145};
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800146struct gpiohandle_config {
147 __u32 flags;
148 __u8 default_values[GPIOHANDLES_MAX];
149 __u32 padding[4];
150};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800151struct gpiohandle_data {
152 __u8 values[GPIOHANDLES_MAX];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800153};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800154#define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800155#define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1)
156#define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1))
157struct gpioevent_request {
158 __u32 lineoffset;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800159 __u32 handleflags;
160 __u32 eventflags;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800161 char consumer_label[GPIO_MAX_NAME_SIZE];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800162 int fd;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800163};
164#define GPIOEVENT_EVENT_RISING_EDGE 0x01
165#define GPIOEVENT_EVENT_FALLING_EDGE 0x02
166struct gpioevent_data {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800167 __u64 timestamp;
168 __u32 id;
169};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700170#define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800171#define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32)
172#define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info)
173#define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info)
174#define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request)
175#define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config)
176#define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values)
177#define GPIO_V2_LINE_SET_VALUES_IOCTL _IOWR(0xB4, 0x0F, struct gpio_v2_line_values)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700178#define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800179#define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request)
180#define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800181#define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data)
182#define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data)
183#define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config)
184#define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info)
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800185#endif