Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [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 | ****************************************************************************/ |
| 19 | #ifndef _UAPI__LINUX_USB_CH9_H |
| 20 | #define _UAPI__LINUX_USB_CH9_H |
| 21 | #include <linux/types.h> |
| 22 | #include <asm/byteorder.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 23 | #define USB_DIR_OUT 0 |
| 24 | #define USB_DIR_IN 0x80 |
| 25 | #define USB_TYPE_MASK (0x03 << 5) |
| 26 | #define USB_TYPE_STANDARD (0x00 << 5) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 27 | #define USB_TYPE_CLASS (0x01 << 5) |
| 28 | #define USB_TYPE_VENDOR (0x02 << 5) |
| 29 | #define USB_TYPE_RESERVED (0x03 << 5) |
| 30 | #define USB_RECIP_MASK 0x1f |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 31 | #define USB_RECIP_DEVICE 0x00 |
| 32 | #define USB_RECIP_INTERFACE 0x01 |
| 33 | #define USB_RECIP_ENDPOINT 0x02 |
| 34 | #define USB_RECIP_OTHER 0x03 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 35 | #define USB_RECIP_PORT 0x04 |
| 36 | #define USB_RECIP_RPIPE 0x05 |
| 37 | #define USB_REQ_GET_STATUS 0x00 |
| 38 | #define USB_REQ_CLEAR_FEATURE 0x01 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 39 | #define USB_REQ_SET_FEATURE 0x03 |
| 40 | #define USB_REQ_SET_ADDRESS 0x05 |
| 41 | #define USB_REQ_GET_DESCRIPTOR 0x06 |
| 42 | #define USB_REQ_SET_DESCRIPTOR 0x07 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 43 | #define USB_REQ_GET_CONFIGURATION 0x08 |
| 44 | #define USB_REQ_SET_CONFIGURATION 0x09 |
| 45 | #define USB_REQ_GET_INTERFACE 0x0A |
| 46 | #define USB_REQ_SET_INTERFACE 0x0B |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 47 | #define USB_REQ_SYNCH_FRAME 0x0C |
| 48 | #define USB_REQ_SET_SEL 0x30 |
| 49 | #define USB_REQ_SET_ISOCH_DELAY 0x31 |
| 50 | #define USB_REQ_SET_ENCRYPTION 0x0D |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 51 | #define USB_REQ_GET_ENCRYPTION 0x0E |
| 52 | #define USB_REQ_RPIPE_ABORT 0x0E |
| 53 | #define USB_REQ_SET_HANDSHAKE 0x0F |
| 54 | #define USB_REQ_RPIPE_RESET 0x0F |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 55 | #define USB_REQ_GET_HANDSHAKE 0x10 |
| 56 | #define USB_REQ_SET_CONNECTION 0x11 |
| 57 | #define USB_REQ_SET_SECURITY_DATA 0x12 |
| 58 | #define USB_REQ_GET_SECURITY_DATA 0x13 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 59 | #define USB_REQ_SET_WUSB_DATA 0x14 |
| 60 | #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 |
| 61 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 |
| 62 | #define USB_REQ_SET_INTERFACE_DS 0x17 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 63 | #define USB_REQ_GET_PARTNER_PDO 20 |
| 64 | #define USB_REQ_GET_BATTERY_STATUS 21 |
| 65 | #define USB_REQ_SET_PDO 22 |
| 66 | #define USB_REQ_GET_VDM 23 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 67 | #define USB_REQ_SEND_VDM 24 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 68 | #define USB_DEVICE_SELF_POWERED 0 |
| 69 | #define USB_DEVICE_REMOTE_WAKEUP 1 |
| 70 | #define USB_DEVICE_TEST_MODE 2 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 71 | #define USB_DEVICE_BATTERY 2 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 72 | #define USB_DEVICE_B_HNP_ENABLE 3 |
| 73 | #define USB_DEVICE_WUSB_DEVICE 3 |
| 74 | #define USB_DEVICE_A_HNP_SUPPORT 4 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 75 | #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 76 | #define USB_DEVICE_DEBUG_MODE 6 |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 77 | #define USB_TEST_J 1 |
| 78 | #define USB_TEST_K 2 |
| 79 | #define USB_TEST_SE0_NAK 3 |
| 80 | #define USB_TEST_PACKET 4 |
| 81 | #define USB_TEST_FORCE_ENABLE 5 |
Christopher Ferris | 934ec94 | 2018-01-31 15:29:16 -0800 | [diff] [blame] | 82 | #define USB_STATUS_TYPE_STANDARD 0 |
| 83 | #define USB_STATUS_TYPE_PTM 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 84 | #define USB_DEVICE_U1_ENABLE 48 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 85 | #define USB_DEVICE_U2_ENABLE 49 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 86 | #define USB_DEVICE_LTM_ENABLE 50 |
| 87 | #define USB_INTRF_FUNC_SUSPEND 0 |
| 88 | #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 89 | #define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0)) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 90 | #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1)) |
| 91 | #define USB_INTRF_STAT_FUNC_RW_CAP 1 |
| 92 | #define USB_INTRF_STAT_FUNC_RW 2 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 93 | #define USB_ENDPOINT_HALT 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 94 | #define USB_DEV_STAT_U1_ENABLED 2 |
| 95 | #define USB_DEV_STAT_U2_ENABLED 3 |
| 96 | #define USB_DEV_STAT_LTM_ENABLED 4 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 97 | #define USB_DEVICE_BATTERY_WAKE_MASK 40 |
| 98 | #define USB_DEVICE_OS_IS_PD_AWARE 41 |
| 99 | #define USB_DEVICE_POLICY_MODE 42 |
| 100 | #define USB_PORT_PR_SWAP 43 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 101 | #define USB_PORT_GOTO_MIN 44 |
| 102 | #define USB_PORT_RETURN_POWER 45 |
| 103 | #define USB_PORT_ACCEPT_PD_REQUEST 46 |
| 104 | #define USB_PORT_REJECT_PD_REQUEST 47 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 105 | #define USB_PORT_PORT_PD_RESET 48 |
| 106 | #define USB_PORT_C_PORT_PD_CHANGE 49 |
| 107 | #define USB_PORT_CABLE_PD_RESET 50 |
| 108 | #define USB_DEVICE_CHARGING_POLICY 54 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 109 | struct usb_ctrlrequest { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 110 | __u8 bRequestType; |
| 111 | __u8 bRequest; |
| 112 | __le16 wValue; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 113 | __le16 wIndex; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 114 | __le16 wLength; |
| 115 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 116 | #define USB_DT_DEVICE 0x01 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 117 | #define USB_DT_CONFIG 0x02 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 118 | #define USB_DT_STRING 0x03 |
| 119 | #define USB_DT_INTERFACE 0x04 |
| 120 | #define USB_DT_ENDPOINT 0x05 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 121 | #define USB_DT_DEVICE_QUALIFIER 0x06 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 122 | #define USB_DT_OTHER_SPEED_CONFIG 0x07 |
| 123 | #define USB_DT_INTERFACE_POWER 0x08 |
| 124 | #define USB_DT_OTG 0x09 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 125 | #define USB_DT_DEBUG 0x0a |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 126 | #define USB_DT_INTERFACE_ASSOCIATION 0x0b |
| 127 | #define USB_DT_SECURITY 0x0c |
| 128 | #define USB_DT_KEY 0x0d |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 129 | #define USB_DT_ENCRYPTION_TYPE 0x0e |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 130 | #define USB_DT_BOS 0x0f |
| 131 | #define USB_DT_DEVICE_CAPABILITY 0x10 |
| 132 | #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 133 | #define USB_DT_WIRE_ADAPTER 0x21 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 134 | #define USB_DT_RPIPE 0x22 |
| 135 | #define USB_DT_CS_RADIO_CONTROL 0x23 |
| 136 | #define USB_DT_PIPE_USAGE 0x24 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 137 | #define USB_DT_SS_ENDPOINT_COMP 0x30 |
| 138 | #define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 139 | #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) |
| 140 | #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) |
| 141 | #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) |
| 142 | #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 143 | #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) |
| 144 | struct usb_descriptor_header { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 145 | __u8 bLength; |
| 146 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 147 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 148 | struct usb_device_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 149 | __u8 bLength; |
| 150 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 151 | __le16 bcdUSB; |
| 152 | __u8 bDeviceClass; |
| 153 | __u8 bDeviceSubClass; |
| 154 | __u8 bDeviceProtocol; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 155 | __u8 bMaxPacketSize0; |
| 156 | __le16 idVendor; |
| 157 | __le16 idProduct; |
| 158 | __le16 bcdDevice; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 159 | __u8 iManufacturer; |
| 160 | __u8 iProduct; |
| 161 | __u8 iSerialNumber; |
| 162 | __u8 bNumConfigurations; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 163 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 164 | #define USB_DT_DEVICE_SIZE 18 |
| 165 | #define USB_CLASS_PER_INTERFACE 0 |
| 166 | #define USB_CLASS_AUDIO 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 167 | #define USB_CLASS_COMM 2 |
| 168 | #define USB_CLASS_HID 3 |
| 169 | #define USB_CLASS_PHYSICAL 5 |
| 170 | #define USB_CLASS_STILL_IMAGE 6 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 171 | #define USB_CLASS_PRINTER 7 |
| 172 | #define USB_CLASS_MASS_STORAGE 8 |
| 173 | #define USB_CLASS_HUB 9 |
| 174 | #define USB_CLASS_CDC_DATA 0x0a |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 175 | #define USB_CLASS_CSCID 0x0b |
| 176 | #define USB_CLASS_CONTENT_SEC 0x0d |
| 177 | #define USB_CLASS_VIDEO 0x0e |
| 178 | #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 179 | #define USB_CLASS_PERSONAL_HEALTHCARE 0x0f |
| 180 | #define USB_CLASS_AUDIO_VIDEO 0x10 |
| 181 | #define USB_CLASS_BILLBOARD 0x11 |
| 182 | #define USB_CLASS_USB_TYPE_C_BRIDGE 0x12 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 183 | #define USB_CLASS_MISC 0xef |
| 184 | #define USB_CLASS_APP_SPEC 0xfe |
| 185 | #define USB_CLASS_VENDOR_SPEC 0xff |
| 186 | #define USB_SUBCLASS_VENDOR_SPEC 0xff |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 187 | struct usb_config_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 188 | __u8 bLength; |
| 189 | __u8 bDescriptorType; |
| 190 | __le16 wTotalLength; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 191 | __u8 bNumInterfaces; |
| 192 | __u8 bConfigurationValue; |
| 193 | __u8 iConfiguration; |
| 194 | __u8 bmAttributes; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 195 | __u8 bMaxPower; |
| 196 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 197 | #define USB_DT_CONFIG_SIZE 9 |
| 198 | #define USB_CONFIG_ATT_ONE (1 << 7) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 199 | #define USB_CONFIG_ATT_SELFPOWER (1 << 6) |
| 200 | #define USB_CONFIG_ATT_WAKEUP (1 << 5) |
| 201 | #define USB_CONFIG_ATT_BATTERY (1 << 4) |
Christopher Ferris | 25c18d4 | 2020-10-14 17:42:58 -0700 | [diff] [blame] | 202 | #define USB_MAX_STRING_LEN 126 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 203 | struct usb_string_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 204 | __u8 bLength; |
| 205 | __u8 bDescriptorType; |
| 206 | __le16 wData[1]; |
| 207 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 208 | struct usb_interface_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 209 | __u8 bLength; |
| 210 | __u8 bDescriptorType; |
| 211 | __u8 bInterfaceNumber; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 212 | __u8 bAlternateSetting; |
| 213 | __u8 bNumEndpoints; |
| 214 | __u8 bInterfaceClass; |
| 215 | __u8 bInterfaceSubClass; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 216 | __u8 bInterfaceProtocol; |
| 217 | __u8 iInterface; |
| 218 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 219 | #define USB_DT_INTERFACE_SIZE 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 220 | struct usb_endpoint_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 221 | __u8 bLength; |
| 222 | __u8 bDescriptorType; |
| 223 | __u8 bEndpointAddress; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 224 | __u8 bmAttributes; |
| 225 | __le16 wMaxPacketSize; |
| 226 | __u8 bInterval; |
| 227 | __u8 bRefresh; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 228 | __u8 bSynchAddress; |
| 229 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 230 | #define USB_DT_ENDPOINT_SIZE 7 |
| 231 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 232 | #define USB_ENDPOINT_NUMBER_MASK 0x0f |
| 233 | #define USB_ENDPOINT_DIR_MASK 0x80 |
| 234 | #define USB_ENDPOINT_XFERTYPE_MASK 0x03 |
| 235 | #define USB_ENDPOINT_XFER_CONTROL 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 236 | #define USB_ENDPOINT_XFER_ISOC 1 |
| 237 | #define USB_ENDPOINT_XFER_BULK 2 |
| 238 | #define USB_ENDPOINT_XFER_INT 3 |
| 239 | #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 |
Christopher Ferris | 48af7cb | 2017-02-21 12:35:09 -0800 | [diff] [blame] | 240 | #define USB_ENDPOINT_MAXP_MASK 0x07ff |
| 241 | #define USB_EP_MAXP_MULT_SHIFT 11 |
Christopher Ferris | 48af7cb | 2017-02-21 12:35:09 -0800 | [diff] [blame] | 242 | #define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT) |
| 243 | #define USB_EP_MAXP_MULT(m) (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 244 | #define USB_ENDPOINT_INTRTYPE 0x30 |
| 245 | #define USB_ENDPOINT_INTR_PERIODIC (0 << 4) |
| 246 | #define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4) |
| 247 | #define USB_ENDPOINT_SYNCTYPE 0x0c |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 248 | #define USB_ENDPOINT_SYNC_NONE (0 << 2) |
| 249 | #define USB_ENDPOINT_SYNC_ASYNC (1 << 2) |
| 250 | #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) |
| 251 | #define USB_ENDPOINT_SYNC_SYNC (3 << 2) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 252 | #define USB_ENDPOINT_USAGE_MASK 0x30 |
| 253 | #define USB_ENDPOINT_USAGE_DATA 0x00 |
| 254 | #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 |
| 255 | #define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 256 | struct usb_ssp_isoc_ep_comp_descriptor { |
| 257 | __u8 bLength; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 258 | __u8 bDescriptorType; |
| 259 | __le16 wReseved; |
| 260 | __le32 dwBytesPerInterval; |
| 261 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 262 | #define USB_DT_SSP_ISOC_EP_COMP_SIZE 8 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 263 | struct usb_ss_ep_comp_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 264 | __u8 bLength; |
| 265 | __u8 bDescriptorType; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 266 | __u8 bMaxBurst; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 267 | __u8 bmAttributes; |
| 268 | __le16 wBytesPerInterval; |
| 269 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 270 | #define USB_DT_SS_EP_COMP_SIZE 6 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 271 | #define USB_SS_MULT(p) (1 + ((p) & 0x3)) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 272 | #define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7)) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 273 | struct usb_qualifier_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 274 | __u8 bLength; |
| 275 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 276 | __le16 bcdUSB; |
| 277 | __u8 bDeviceClass; |
| 278 | __u8 bDeviceSubClass; |
| 279 | __u8 bDeviceProtocol; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 280 | __u8 bMaxPacketSize0; |
| 281 | __u8 bNumConfigurations; |
| 282 | __u8 bRESERVED; |
| 283 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 284 | struct usb_otg_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 285 | __u8 bLength; |
| 286 | __u8 bDescriptorType; |
| 287 | __u8 bmAttributes; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 288 | } __attribute__((packed)); |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 289 | struct usb_otg20_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 290 | __u8 bLength; |
| 291 | __u8 bDescriptorType; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 292 | __u8 bmAttributes; |
| 293 | __le16 bcdOTG; |
| 294 | } __attribute__((packed)); |
| 295 | #define USB_OTG_SRP (1 << 0) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 296 | #define USB_OTG_HNP (1 << 1) |
| 297 | #define USB_OTG_ADP (1 << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 298 | #define OTG_STS_SELECTOR 0xF000 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 299 | struct usb_debug_descriptor { |
| 300 | __u8 bLength; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 301 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 302 | __u8 bDebugInEndpoint; |
| 303 | __u8 bDebugOutEndpoint; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 304 | } __attribute__((packed)); |
| 305 | struct usb_interface_assoc_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 306 | __u8 bLength; |
| 307 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 308 | __u8 bFirstInterface; |
| 309 | __u8 bInterfaceCount; |
| 310 | __u8 bFunctionClass; |
| 311 | __u8 bFunctionSubClass; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 312 | __u8 bFunctionProtocol; |
| 313 | __u8 iFunction; |
| 314 | } __attribute__((packed)); |
Christopher Ferris | 1308ad3 | 2017-11-14 17:32:13 -0800 | [diff] [blame] | 315 | #define USB_DT_INTERFACE_ASSOCIATION_SIZE 8 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 316 | struct usb_security_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 317 | __u8 bLength; |
| 318 | __u8 bDescriptorType; |
| 319 | __le16 wTotalLength; |
| 320 | __u8 bNumEncryptionTypes; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 321 | } __attribute__((packed)); |
| 322 | struct usb_key_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 323 | __u8 bLength; |
| 324 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 325 | __u8 tTKID[3]; |
| 326 | __u8 bReserved; |
| 327 | __u8 bKeyData[0]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 328 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 329 | struct usb_encryption_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 330 | __u8 bLength; |
| 331 | __u8 bDescriptorType; |
| 332 | __u8 bEncryptionType; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 333 | #define USB_ENC_TYPE_UNSECURE 0 |
| 334 | #define USB_ENC_TYPE_WIRED 1 |
| 335 | #define USB_ENC_TYPE_CCM_1 2 |
| 336 | #define USB_ENC_TYPE_RSA_1 3 |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 337 | __u8 bEncryptionValue; |
| 338 | __u8 bAuthKeyIndex; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 339 | } __attribute__((packed)); |
| 340 | struct usb_bos_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 341 | __u8 bLength; |
| 342 | __u8 bDescriptorType; |
| 343 | __le16 wTotalLength; |
| 344 | __u8 bNumDeviceCaps; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 345 | } __attribute__((packed)); |
| 346 | #define USB_DT_BOS_SIZE 5 |
| 347 | struct usb_dev_cap_header { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 348 | __u8 bLength; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 349 | __u8 bDescriptorType; |
| 350 | __u8 bDevCapabilityType; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 351 | } __attribute__((packed)); |
| 352 | #define USB_CAP_TYPE_WIRELESS_USB 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 353 | struct usb_wireless_cap_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 354 | __u8 bLength; |
| 355 | __u8 bDescriptorType; |
| 356 | __u8 bDevCapabilityType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 357 | __u8 bmAttributes; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 358 | #define USB_WIRELESS_P2P_DRD (1 << 1) |
| 359 | #define USB_WIRELESS_BEACON_MASK (3 << 2) |
| 360 | #define USB_WIRELESS_BEACON_SELF (1 << 2) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 361 | #define USB_WIRELESS_BEACON_DIRECTED (2 << 2) |
| 362 | #define USB_WIRELESS_BEACON_NONE (3 << 2) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 363 | __le16 wPHYRates; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 364 | #define USB_WIRELESS_PHY_53 (1 << 0) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 365 | #define USB_WIRELESS_PHY_80 (1 << 1) |
| 366 | #define USB_WIRELESS_PHY_107 (1 << 2) |
| 367 | #define USB_WIRELESS_PHY_160 (1 << 3) |
| 368 | #define USB_WIRELESS_PHY_200 (1 << 4) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 369 | #define USB_WIRELESS_PHY_320 (1 << 5) |
| 370 | #define USB_WIRELESS_PHY_400 (1 << 6) |
| 371 | #define USB_WIRELESS_PHY_480 (1 << 7) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 372 | __u8 bmTFITXPowerInfo; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 373 | __u8 bmFFITXPowerInfo; |
| 374 | __le16 bmBandGroup; |
| 375 | __u8 bReserved; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 376 | } __attribute__((packed)); |
Christopher Ferris | 934ec94 | 2018-01-31 15:29:16 -0800 | [diff] [blame] | 377 | #define USB_DT_USB_WIRELESS_CAP_SIZE 11 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 378 | #define USB_CAP_TYPE_EXT 2 |
| 379 | struct usb_ext_cap_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 380 | __u8 bLength; |
| 381 | __u8 bDescriptorType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 382 | __u8 bDevCapabilityType; |
| 383 | __le32 bmAttributes; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 384 | #define USB_LPM_SUPPORT (1 << 1) |
| 385 | #define USB_BESL_SUPPORT (1 << 2) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 386 | #define USB_BESL_BASELINE_VALID (1 << 3) |
| 387 | #define USB_BESL_DEEP_VALID (1 << 4) |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 388 | #define USB_SET_BESL_BASELINE(p) (((p) & 0xf) << 8) |
| 389 | #define USB_SET_BESL_DEEP(p) (((p) & 0xf) << 12) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 390 | #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) |
| 391 | #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 392 | } __attribute__((packed)); |
| 393 | #define USB_DT_USB_EXT_CAP_SIZE 7 |
| 394 | #define USB_SS_CAP_TYPE 3 |
| 395 | struct usb_ss_cap_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 396 | __u8 bLength; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 397 | __u8 bDescriptorType; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 398 | __u8 bDevCapabilityType; |
| 399 | __u8 bmAttributes; |
| 400 | #define USB_LTM_SUPPORT (1 << 1) |
| 401 | __le16 wSpeedSupported; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 402 | #define USB_LOW_SPEED_OPERATION (1) |
| 403 | #define USB_FULL_SPEED_OPERATION (1 << 1) |
| 404 | #define USB_HIGH_SPEED_OPERATION (1 << 2) |
| 405 | #define USB_5GBPS_OPERATION (1 << 3) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 406 | __u8 bFunctionalitySupport; |
| 407 | __u8 bU1devExitLat; |
| 408 | __le16 bU2DevExitLat; |
| 409 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 410 | #define USB_DT_USB_SS_CAP_SIZE 10 |
| 411 | #define CONTAINER_ID_TYPE 4 |
| 412 | struct usb_ss_container_id_descriptor { |
| 413 | __u8 bLength; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 414 | __u8 bDescriptorType; |
| 415 | __u8 bDevCapabilityType; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 416 | __u8 bReserved; |
| 417 | __u8 ContainerID[16]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 418 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 419 | #define USB_DT_USB_SS_CONTN_ID_SIZE 20 |
| 420 | #define USB_SSP_CAP_TYPE 0xa |
| 421 | struct usb_ssp_cap_descriptor { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 422 | __u8 bLength; |
| 423 | __u8 bDescriptorType; |
| 424 | __u8 bDevCapabilityType; |
| 425 | __u8 bReserved; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 426 | __le32 bmAttributes; |
| 427 | #define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0) |
| 428 | #define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5) |
| 429 | __le16 wFunctionalitySupport; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 430 | #define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf) |
| 431 | #define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8) |
| 432 | #define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12) |
| 433 | __le16 wReserved; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 434 | __le32 bmSublinkSpeedAttr[1]; |
| 435 | #define USB_SSP_SUBLINK_SPEED_SSID (0xf) |
| 436 | #define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4) |
| 437 | #define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 438 | #define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8) |
| 439 | #define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14) |
| 440 | #define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16) |
| 441 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 442 | #define USB_PD_POWER_DELIVERY_CAPABILITY 0x06 |
| 443 | #define USB_PD_BATTERY_INFO_CAPABILITY 0x07 |
| 444 | #define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08 |
| 445 | #define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 446 | struct usb_pd_cap_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 447 | __u8 bLength; |
| 448 | __u8 bDescriptorType; |
| 449 | __u8 bDevCapabilityType; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 450 | __u8 bReserved; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 451 | __le32 bmAttributes; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 452 | #define USB_PD_CAP_BATTERY_CHARGING (1 << 1) |
| 453 | #define USB_PD_CAP_USB_PD (1 << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 454 | #define USB_PD_CAP_PROVIDER (1 << 3) |
| 455 | #define USB_PD_CAP_CONSUMER (1 << 4) |
| 456 | #define USB_PD_CAP_CHARGING_POLICY (1 << 5) |
| 457 | #define USB_PD_CAP_TYPE_C_CURRENT (1 << 6) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 458 | #define USB_PD_CAP_PWR_AC (1 << 8) |
| 459 | #define USB_PD_CAP_PWR_BAT (1 << 9) |
| 460 | #define USB_PD_CAP_PWR_USE_V_BUS (1 << 14) |
| 461 | __le16 bmProviderPorts; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 462 | __le16 bmConsumerPorts; |
| 463 | __le16 bcdBCVersion; |
| 464 | __le16 bcdPDVersion; |
| 465 | __le16 bcdUSBTypeCVersion; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 466 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 467 | struct usb_pd_cap_battery_info_descriptor { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 468 | __u8 bLength; |
| 469 | __u8 bDescriptorType; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 470 | __u8 bDevCapabilityType; |
| 471 | __u8 iBattery; |
| 472 | __u8 iSerial; |
| 473 | __u8 iManufacturer; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 474 | __u8 bBatteryId; |
| 475 | __u8 bReserved; |
| 476 | __le32 dwChargedThreshold; |
| 477 | __le32 dwWeakThreshold; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 478 | __le32 dwBatteryDesignCapacity; |
| 479 | __le32 dwBatteryLastFullchargeCapacity; |
| 480 | } __attribute__((packed)); |
| 481 | struct usb_pd_cap_consumer_port_descriptor { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 482 | __u8 bLength; |
| 483 | __u8 bDescriptorType; |
| 484 | __u8 bDevCapabilityType; |
| 485 | __u8 bReserved; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 486 | __u8 bmCapabilities; |
| 487 | #define USB_PD_CAP_CONSUMER_BC (1 << 0) |
| 488 | #define USB_PD_CAP_CONSUMER_PD (1 << 1) |
| 489 | #define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 490 | __le16 wMinVoltage; |
| 491 | __le16 wMaxVoltage; |
| 492 | __u16 wReserved; |
| 493 | __le32 dwMaxOperatingPower; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 494 | __le32 dwMaxPeakPower; |
| 495 | __le32 dwMaxPeakPowerTime; |
| 496 | #define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff |
| 497 | } __attribute__((packed)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 498 | struct usb_pd_cap_provider_port_descriptor { |
| 499 | __u8 bLength; |
| 500 | __u8 bDescriptorType; |
| 501 | __u8 bDevCapabilityType; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 502 | __u8 bReserved1; |
| 503 | __u8 bmCapabilities; |
| 504 | #define USB_PD_CAP_PROVIDER_BC (1 << 0) |
| 505 | #define USB_PD_CAP_PROVIDER_PD (1 << 1) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 506 | #define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2) |
| 507 | __u8 bNumOfPDObjects; |
| 508 | __u8 bReserved2; |
| 509 | __le32 wPowerDataObject[]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 510 | } __attribute__((packed)); |
| 511 | #define USB_PTM_CAP_TYPE 0xb |
| 512 | struct usb_ptm_cap_descriptor { |
| 513 | __u8 bLength; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 514 | __u8 bDescriptorType; |
| 515 | __u8 bDevCapabilityType; |
| 516 | } __attribute__((packed)); |
Christopher Ferris | 934ec94 | 2018-01-31 15:29:16 -0800 | [diff] [blame] | 517 | #define USB_DT_USB_PTM_ID_SIZE 3 |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 518 | #define USB_DT_USB_SSP_CAP_SIZE(ssac) (12 + (ssac + 1) * 4) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 519 | struct usb_wireless_ep_comp_descriptor { |
| 520 | __u8 bLength; |
| 521 | __u8 bDescriptorType; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 522 | __u8 bMaxBurst; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 523 | __u8 bMaxSequence; |
| 524 | __le16 wMaxStreamDelay; |
| 525 | __le16 wOverTheAirPacketSize; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 526 | __u8 bOverTheAirInterval; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 527 | __u8 bmCompAttributes; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 528 | #define USB_ENDPOINT_SWITCH_MASK 0x03 |
| 529 | #define USB_ENDPOINT_SWITCH_NO 0 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 530 | #define USB_ENDPOINT_SWITCH_SWITCH 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 531 | #define USB_ENDPOINT_SWITCH_SCALE 2 |
| 532 | } __attribute__((packed)); |
| 533 | struct usb_handshake { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 534 | __u8 bMessageNumber; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 535 | __u8 bStatus; |
| 536 | __u8 tTKID[3]; |
| 537 | __u8 bReserved; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 538 | __u8 CDID[16]; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 539 | __u8 nonce[16]; |
| 540 | __u8 MIC[8]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 541 | } __attribute__((packed)); |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 542 | struct usb_connection_context { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 543 | __u8 CHID[16]; |
| 544 | __u8 CDID[16]; |
| 545 | __u8 CK[16]; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 546 | } __attribute__((packed)); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 547 | enum usb_device_speed { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 548 | USB_SPEED_UNKNOWN = 0, |
| 549 | USB_SPEED_LOW, |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 550 | USB_SPEED_FULL, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 551 | USB_SPEED_HIGH, |
| 552 | USB_SPEED_WIRELESS, |
| 553 | USB_SPEED_SUPER, |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 554 | USB_SPEED_SUPER_PLUS, |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 555 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 556 | enum usb_device_state { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 557 | USB_STATE_NOTATTACHED = 0, |
| 558 | USB_STATE_ATTACHED, |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 559 | USB_STATE_POWERED, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 560 | USB_STATE_RECONNECTING, |
| 561 | USB_STATE_UNAUTHENTICATED, |
| 562 | USB_STATE_DEFAULT, |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 563 | USB_STATE_ADDRESS, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 564 | USB_STATE_CONFIGURED, |
| 565 | USB_STATE_SUSPENDED |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 566 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 567 | enum usb3_link_state { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 568 | USB3_LPM_U0 = 0, |
| 569 | USB3_LPM_U1, |
| 570 | USB3_LPM_U2, |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 571 | USB3_LPM_U3 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 572 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 573 | #define USB3_LPM_DISABLED 0x0 |
| 574 | #define USB3_LPM_U1_MAX_TIMEOUT 0x7F |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 575 | #define USB3_LPM_U2_MAX_TIMEOUT 0xFE |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 576 | #define USB3_LPM_DEVICE_INITIATED 0xFF |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 577 | struct usb_set_sel_req { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 578 | __u8 u1_sel; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 579 | __u8 u1_pel; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 580 | __le16 u2_sel; |
| 581 | __le16 u2_pel; |
| 582 | } __attribute__((packed)); |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 583 | #define USB3_LPM_MAX_U1_SEL_PEL 0xFF |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 584 | #define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 585 | #define USB_SELF_POWER_VBUS_MAX_DRAW 100 |
| 586 | #endif |