Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 7 | #ifndef _UAPI_GPIO_H_ |
| 8 | #define _UAPI_GPIO_H_ |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 9 | #include <linux/const.h> |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 10 | #include <linux/ioctl.h> |
| 11 | #include <linux/types.h> |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 12 | #define GPIO_MAX_NAME_SIZE 32 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 13 | struct gpiochip_info { |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 14 | char name[GPIO_MAX_NAME_SIZE]; |
| 15 | char label[GPIO_MAX_NAME_SIZE]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 16 | __u32 lines; |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 17 | }; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 18 | #define GPIO_V2_LINES_MAX 64 |
| 19 | #define GPIO_V2_LINE_NUM_ATTRS_MAX 10 |
| 20 | enum 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 Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 32 | GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11), |
Christopher Ferris | 80ae69d | 2022-08-02 16:32:21 -0700 | [diff] [blame] | 33 | GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12), |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 34 | }; |
| 35 | struct gpio_v2_line_values { |
| 36 | __aligned_u64 bits; |
| 37 | __aligned_u64 mask; |
| 38 | }; |
| 39 | enum 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 | }; |
| 44 | struct 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 | }; |
| 53 | struct gpio_v2_line_config_attribute { |
| 54 | struct gpio_v2_line_attribute attr; |
| 55 | __aligned_u64 mask; |
| 56 | }; |
| 57 | struct 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 | }; |
| 63 | struct 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 | }; |
| 72 | struct 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 | }; |
| 81 | enum 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 | }; |
| 86 | struct 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 | }; |
| 92 | enum gpio_v2_line_event_id { |
| 93 | GPIO_V2_LINE_EVENT_RISING_EDGE = 1, |
| 94 | GPIO_V2_LINE_EVENT_FALLING_EDGE = 2, |
| 95 | }; |
| 96 | struct 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 104 | #define GPIOLINE_FLAG_KERNEL (1UL << 0) |
| 105 | #define GPIOLINE_FLAG_IS_OUT (1UL << 1) |
| 106 | #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 107 | #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3) |
| 108 | #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 109 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 112 | struct gpioline_info { |
| 113 | __u32 line_offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 114 | __u32 flags; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 115 | char name[GPIO_MAX_NAME_SIZE]; |
| 116 | char consumer[GPIO_MAX_NAME_SIZE]; |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 117 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 118 | #define GPIOHANDLES_MAX 64 |
Christopher Ferris | af09c70 | 2020-06-01 20:29:29 -0700 | [diff] [blame] | 119 | enum { |
| 120 | GPIOLINE_CHANGED_REQUESTED = 1, |
| 121 | GPIOLINE_CHANGED_RELEASED, |
| 122 | GPIOLINE_CHANGED_CONFIG, |
| 123 | }; |
| 124 | struct gpioline_info_changed { |
| 125 | struct gpioline_info info; |
| 126 | __u64 timestamp; |
| 127 | __u32 event_type; |
| 128 | __u32 padding[5]; |
| 129 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 130 | #define GPIOHANDLE_REQUEST_INPUT (1UL << 0) |
| 131 | #define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1) |
| 132 | #define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 133 | #define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3) |
| 134 | #define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 135 | #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 Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 138 | struct gpiohandle_request { |
| 139 | __u32 lineoffsets[GPIOHANDLES_MAX]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 140 | __u32 flags; |
| 141 | __u8 default_values[GPIOHANDLES_MAX]; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 142 | char consumer_label[GPIO_MAX_NAME_SIZE]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 143 | __u32 lines; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 144 | int fd; |
| 145 | }; |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 146 | struct gpiohandle_config { |
| 147 | __u32 flags; |
| 148 | __u8 default_values[GPIOHANDLES_MAX]; |
| 149 | __u32 padding[4]; |
| 150 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 151 | struct gpiohandle_data { |
| 152 | __u8 values[GPIOHANDLES_MAX]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 153 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 154 | #define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 155 | #define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1) |
| 156 | #define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1)) |
| 157 | struct gpioevent_request { |
| 158 | __u32 lineoffset; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 159 | __u32 handleflags; |
| 160 | __u32 eventflags; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 161 | char consumer_label[GPIO_MAX_NAME_SIZE]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 162 | int fd; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 163 | }; |
| 164 | #define GPIOEVENT_EVENT_RISING_EDGE 0x01 |
| 165 | #define GPIOEVENT_EVENT_FALLING_EDGE 0x02 |
| 166 | struct gpioevent_data { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 167 | __u64 timestamp; |
| 168 | __u32 id; |
| 169 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 170 | #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info) |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 171 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 178 | #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 179 | #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request) |
| 180 | #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request) |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 181 | #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 Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 185 | #endif |