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 ****************************************************************************/ 19 #ifndef _UAPI_GPIO_H_ 20 #define _UAPI_GPIO_H_ 21 #include <linux/const.h> 22 #include <linux/ioctl.h> 23 #include <linux/types.h> 24 #define GPIO_MAX_NAME_SIZE 32 25 struct gpiochip_info { 26 char name[GPIO_MAX_NAME_SIZE]; 27 char label[GPIO_MAX_NAME_SIZE]; 28 __u32 lines; 29 }; 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 GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11), 45 GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12), 46 }; 47 struct gpio_v2_line_values { 48 __aligned_u64 bits; 49 __aligned_u64 mask; 50 }; 51 enum gpio_v2_line_attr_id { 52 GPIO_V2_LINE_ATTR_ID_FLAGS = 1, 53 GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES = 2, 54 GPIO_V2_LINE_ATTR_ID_DEBOUNCE = 3, 55 }; 56 struct gpio_v2_line_attribute { 57 __u32 id; 58 __u32 padding; 59 union { 60 __aligned_u64 flags; 61 __aligned_u64 values; 62 __u32 debounce_period_us; 63 }; 64 }; 65 struct gpio_v2_line_config_attribute { 66 struct gpio_v2_line_attribute attr; 67 __aligned_u64 mask; 68 }; 69 struct gpio_v2_line_config { 70 __aligned_u64 flags; 71 __u32 num_attrs; 72 __u32 padding[5]; 73 struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; 74 }; 75 struct gpio_v2_line_request { 76 __u32 offsets[GPIO_V2_LINES_MAX]; 77 char consumer[GPIO_MAX_NAME_SIZE]; 78 struct gpio_v2_line_config config; 79 __u32 num_lines; 80 __u32 event_buffer_size; 81 __u32 padding[5]; 82 __s32 fd; 83 }; 84 struct gpio_v2_line_info { 85 char name[GPIO_MAX_NAME_SIZE]; 86 char consumer[GPIO_MAX_NAME_SIZE]; 87 __u32 offset; 88 __u32 num_attrs; 89 __aligned_u64 flags; 90 struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; 91 __u32 padding[4]; 92 }; 93 enum gpio_v2_line_changed_type { 94 GPIO_V2_LINE_CHANGED_REQUESTED = 1, 95 GPIO_V2_LINE_CHANGED_RELEASED = 2, 96 GPIO_V2_LINE_CHANGED_CONFIG = 3, 97 }; 98 struct gpio_v2_line_info_changed { 99 struct gpio_v2_line_info info; 100 __aligned_u64 timestamp_ns; 101 __u32 event_type; 102 __u32 padding[5]; 103 }; 104 enum gpio_v2_line_event_id { 105 GPIO_V2_LINE_EVENT_RISING_EDGE = 1, 106 GPIO_V2_LINE_EVENT_FALLING_EDGE = 2, 107 }; 108 struct gpio_v2_line_event { 109 __aligned_u64 timestamp_ns; 110 __u32 id; 111 __u32 offset; 112 __u32 seqno; 113 __u32 line_seqno; 114 __u32 padding[6]; 115 }; 116 #define GPIOLINE_FLAG_KERNEL (1UL << 0) 117 #define GPIOLINE_FLAG_IS_OUT (1UL << 1) 118 #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2) 119 #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3) 120 #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4) 121 #define GPIOLINE_FLAG_BIAS_PULL_UP (1UL << 5) 122 #define GPIOLINE_FLAG_BIAS_PULL_DOWN (1UL << 6) 123 #define GPIOLINE_FLAG_BIAS_DISABLE (1UL << 7) 124 struct gpioline_info { 125 __u32 line_offset; 126 __u32 flags; 127 char name[GPIO_MAX_NAME_SIZE]; 128 char consumer[GPIO_MAX_NAME_SIZE]; 129 }; 130 #define GPIOHANDLES_MAX 64 131 enum { 132 GPIOLINE_CHANGED_REQUESTED = 1, 133 GPIOLINE_CHANGED_RELEASED, 134 GPIOLINE_CHANGED_CONFIG, 135 }; 136 struct gpioline_info_changed { 137 struct gpioline_info info; 138 __u64 timestamp; 139 __u32 event_type; 140 __u32 padding[5]; 141 }; 142 #define GPIOHANDLE_REQUEST_INPUT (1UL << 0) 143 #define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1) 144 #define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2) 145 #define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3) 146 #define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4) 147 #define GPIOHANDLE_REQUEST_BIAS_PULL_UP (1UL << 5) 148 #define GPIOHANDLE_REQUEST_BIAS_PULL_DOWN (1UL << 6) 149 #define GPIOHANDLE_REQUEST_BIAS_DISABLE (1UL << 7) 150 struct gpiohandle_request { 151 __u32 lineoffsets[GPIOHANDLES_MAX]; 152 __u32 flags; 153 __u8 default_values[GPIOHANDLES_MAX]; 154 char consumer_label[GPIO_MAX_NAME_SIZE]; 155 __u32 lines; 156 int fd; 157 }; 158 struct gpiohandle_config { 159 __u32 flags; 160 __u8 default_values[GPIOHANDLES_MAX]; 161 __u32 padding[4]; 162 }; 163 struct gpiohandle_data { 164 __u8 values[GPIOHANDLES_MAX]; 165 }; 166 #define GPIOEVENT_REQUEST_RISING_EDGE (1UL << 0) 167 #define GPIOEVENT_REQUEST_FALLING_EDGE (1UL << 1) 168 #define GPIOEVENT_REQUEST_BOTH_EDGES ((1UL << 0) | (1UL << 1)) 169 struct gpioevent_request { 170 __u32 lineoffset; 171 __u32 handleflags; 172 __u32 eventflags; 173 char consumer_label[GPIO_MAX_NAME_SIZE]; 174 int fd; 175 }; 176 #define GPIOEVENT_EVENT_RISING_EDGE 0x01 177 #define GPIOEVENT_EVENT_FALLING_EDGE 0x02 178 struct gpioevent_data { 179 __u64 timestamp; 180 __u32 id; 181 }; 182 #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info) 183 #define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32) 184 #define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info) 185 #define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info) 186 #define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request) 187 #define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config) 188 #define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values) 189 #define GPIO_V2_LINE_SET_VALUES_IOCTL _IOWR(0xB4, 0x0F, struct gpio_v2_line_values) 190 #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info) 191 #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request) 192 #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request) 193 #define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data) 194 #define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data) 195 #define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config) 196 #define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info) 197 #endif 198