Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | *** To edit the content of this header, modify the corresponding |
| 11 | *** source file (e.g. under external/kernel-headers/original/) then |
| 12 | *** run bionic/libc/kernel/tools/update_all.py |
| 13 | *** |
| 14 | *** Any manual change here will be lost the next time this script will |
| 15 | *** be run. You've been warned! |
| 16 | *** |
| 17 | **************************************************************************** |
| 18 | ****************************************************************************/ |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 19 | #ifndef _UAPI_GPIO_H_ |
| 20 | #define _UAPI_GPIO_H_ |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 21 | #include <linux/const.h> |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 22 | #include <linux/ioctl.h> |
| 23 | #include <linux/types.h> |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 24 | #define GPIO_MAX_NAME_SIZE 32 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 25 | struct gpiochip_info { |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 26 | char name[GPIO_MAX_NAME_SIZE]; |
| 27 | char label[GPIO_MAX_NAME_SIZE]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 28 | __u32 lines; |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 29 | }; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 30 | #define GPIO_V2_LINES_MAX 64 |
| 31 | #define GPIO_V2_LINE_NUM_ATTRS_MAX 10 |
| 32 | enum gpio_v2_line_flag { |
| 33 | GPIO_V2_LINE_FLAG_USED = _BITULL(0), |
| 34 | GPIO_V2_LINE_FLAG_ACTIVE_LOW = _BITULL(1), |
| 35 | GPIO_V2_LINE_FLAG_INPUT = _BITULL(2), |
| 36 | GPIO_V2_LINE_FLAG_OUTPUT = _BITULL(3), |
| 37 | GPIO_V2_LINE_FLAG_EDGE_RISING = _BITULL(4), |
| 38 | GPIO_V2_LINE_FLAG_EDGE_FALLING = _BITULL(5), |
| 39 | GPIO_V2_LINE_FLAG_OPEN_DRAIN = _BITULL(6), |
| 40 | GPIO_V2_LINE_FLAG_OPEN_SOURCE = _BITULL(7), |
| 41 | GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8), |
| 42 | GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9), |
| 43 | GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10), |
| 44 | }; |
| 45 | struct gpio_v2_line_values { |
| 46 | __aligned_u64 bits; |
| 47 | __aligned_u64 mask; |
| 48 | }; |
| 49 | enum gpio_v2_line_attr_id { |
| 50 | GPIO_V2_LINE_ATTR_ID_FLAGS = 1, |
| 51 | GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2, |
| 52 | GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3, |
| 53 | }; |
| 54 | struct gpio_v2_line_attribute { |
| 55 | __u32 id; |
| 56 | __u32 padding; |
| 57 | union { |
| 58 | __aligned_u64 flags; |
| 59 | __aligned_u64 values; |
| 60 | __u32 debounce_period_us; |
| 61 | }; |
| 62 | }; |
| 63 | struct gpio_v2_line_config_attribute { |
| 64 | struct gpio_v2_line_attribute attr; |
| 65 | __aligned_u64 mask; |
| 66 | }; |
| 67 | struct gpio_v2_line_config { |
| 68 | __aligned_u64 flags; |
| 69 | __u32 num_attrs; |
| 70 | __u32 padding[5]; |
| 71 | struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; |
| 72 | }; |
| 73 | struct gpio_v2_line_request { |
| 74 | __u32 offsets[GPIO_V2_LINES_MAX]; |
| 75 | char consumer[GPIO_MAX_NAME_SIZE]; |
| 76 | struct gpio_v2_line_config config; |
| 77 | __u32 num_lines; |
| 78 | __u32 event_buffer_size; |
| 79 | __u32 padding[5]; |
| 80 | __s32 fd; |
| 81 | }; |
| 82 | struct gpio_v2_line_info { |
| 83 | char name[GPIO_MAX_NAME_SIZE]; |
| 84 | char consumer[GPIO_MAX_NAME_SIZE]; |
| 85 | __u32 offset; |
| 86 | __u32 num_attrs; |
| 87 | __aligned_u64 flags; |
| 88 | struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; |
| 89 | __u32 padding[4]; |
| 90 | }; |
| 91 | enum gpio_v2_line_changed_type { |
| 92 | GPIO_V2_LINE_CHANGED_REQUESTED = 1, |
| 93 | GPIO_V2_LINE_CHANGED_RELEASED = 2, |
| 94 | GPIO_V2_LINE_CHANGED_CONFIG = 3, |
| 95 | }; |
| 96 | struct gpio_v2_line_info_changed { |
| 97 | struct gpio_v2_line_info info; |
| 98 | __aligned_u64 timestamp_ns; |
| 99 | __u32 event_type; |
| 100 | __u32 padding[5]; |
| 101 | }; |
| 102 | enum gpio_v2_line_event_id { |
| 103 | GPIO_V2_LINE_EVENT_RISING_EDGE = 1, |
| 104 | GPIO_V2_LINE_EVENT_FALLING_EDGE = 2, |
| 105 | }; |
| 106 | struct gpio_v2_line_event { |
| 107 | __aligned_u64 timestamp_ns; |
| 108 | __u32 id; |
| 109 | __u32 offset; |
| 110 | __u32 seqno; |
| 111 | __u32 line_seqno; |
| 112 | __u32 padding[6]; |
| 113 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 114 | #define GPIOLINE_FLAG_KERNEL (1UL << 0) |
| 115 | #define GPIOLINE_FLAG_IS_OUT (1UL << 1) |
| 116 | #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 117 | #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3) |
| 118 | #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 119 | #define GPIOLINE_FLAG_BIAS_PULL_UP (1UL << 5) |
| 120 | #define GPIOLINE_FLAG_BIAS_PULL_DOWN (1UL << 6) |
| 121 | #define GPIOLINE_FLAG_BIAS_DISABLE (1UL << 7) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 122 | struct gpioline_info { |
| 123 | __u32 line_offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 124 | __u32 flags; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 125 | char name[GPIO_MAX_NAME_SIZE]; |
| 126 | char consumer[GPIO_MAX_NAME_SIZE]; |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 127 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 128 | #define GPIOHANDLES_MAX 64 |
Christopher Ferris | af09c70 | 2020-06-01 20:29:29 -0700 | [diff] [blame] | 129 | enum { |
| 130 | GPIOLINE_CHANGED_REQUESTED = 1, |
| 131 | GPIOLINE_CHANGED_RELEASED, |
| 132 | GPIOLINE_CHANGED_CONFIG, |
| 133 | }; |
| 134 | struct gpioline_info_changed { |
| 135 | struct gpioline_info info; |
| 136 | __u64 timestamp; |
| 137 | __u32 event_type; |
| 138 | __u32 padding[5]; |
| 139 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 140 | #define GPIOHANDLE_REQUEST_INPUT (1UL << 0) |
| 141 | #define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1) |
| 142 | #define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 143 | #define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3) |
| 144 | #define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 145 | #define GPIOHANDLE_REQUEST_BIAS_PULL_UP (1UL << 5) |
| 146 | #define GPIOHANDLE_REQUEST_BIAS_PULL_DOWN (1UL << 6) |
| 147 | #define GPIOHANDLE_REQUEST_BIAS_DISABLE (1UL << 7) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 148 | struct gpiohandle_request { |
| 149 | __u32 lineoffsets[GPIOHANDLES_MAX]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 150 | __u32 flags; |
| 151 | __u8 default_values[GPIOHANDLES_MAX]; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 152 | char consumer_label[GPIO_MAX_NAME_SIZE]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 153 | __u32 lines; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 154 | int fd; |
| 155 | }; |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 156 | struct gpiohandle_config { |
| 157 | __u32 flags; |
| 158 | __u8 default_values[GPIOHANDLES_MAX]; |
| 159 | __u32 padding[4]; |
| 160 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 161 | struct gpiohandle_data { |
| 162 | __u8 values[GPIOHANDLES_MAX]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 163 | }; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 164 | #define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 165 | #define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1) |
| 166 | #define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1)) |
| 167 | struct gpioevent_request { |
| 168 | __u32 lineoffset; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 169 | __u32 handleflags; |
| 170 | __u32 eventflags; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 171 | char consumer_label[GPIO_MAX_NAME_SIZE]; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 172 | int fd; |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 173 | }; |
| 174 | #define GPIOEVENT_EVENT_RISING_EDGE 0x01 |
| 175 | #define GPIOEVENT_EVENT_FALLING_EDGE 0x02 |
| 176 | struct gpioevent_data { |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 177 | __u64 timestamp; |
| 178 | __u32 id; |
| 179 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 180 | #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info) |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 181 | #define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32) |
| 182 | #define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info) |
| 183 | #define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info) |
| 184 | #define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request) |
| 185 | #define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config) |
| 186 | #define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values) |
| 187 | #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] | 188 | #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info) |
Christopher Ferris | 49f525c | 2016-12-12 14:55:36 -0800 | [diff] [blame] | 189 | #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request) |
| 190 | #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request) |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 191 | #define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data) |
| 192 | #define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data) |
| 193 | #define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config) |
| 194 | #define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info) |
Elliott Hughes | 8cb52b0 | 2013-11-21 13:43:23 -0800 | [diff] [blame] | 195 | #endif |