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