blob: f06a97077172aefbe4b8aea628055701c9a15783 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
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 Cheng655a7c02013-10-16 16:09:24 -070023#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 Cheng655a7c02013-10-16 16:09:24 -070027#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 Cheng655a7c02013-10-16 16:09:24 -070031#define USB_RECIP_DEVICE 0x00
32#define USB_RECIP_INTERFACE 0x01
33#define USB_RECIP_ENDPOINT 0x02
34#define USB_RECIP_OTHER 0x03
Ben Cheng655a7c02013-10-16 16:09:24 -070035#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 Cheng655a7c02013-10-16 16:09:24 -070039#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 Cheng655a7c02013-10-16 16:09:24 -070043#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 Cheng655a7c02013-10-16 16:09:24 -070047#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 Cheng655a7c02013-10-16 16:09:24 -070051#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 Cheng655a7c02013-10-16 16:09:24 -070055#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 Cheng655a7c02013-10-16 16:09:24 -070059#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 Ferris106b3a82016-08-24 12:15:38 -070063#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 Ferris106b3a82016-08-24 12:15:38 -070067#define USB_REQ_SEND_VDM 24
Ben Cheng655a7c02013-10-16 16:09:24 -070068#define USB_DEVICE_SELF_POWERED 0
69#define USB_DEVICE_REMOTE_WAKEUP 1
70#define USB_DEVICE_TEST_MODE 2
Christopher Ferris106b3a82016-08-24 12:15:38 -070071#define USB_DEVICE_BATTERY 2
Ben Cheng655a7c02013-10-16 16:09:24 -070072#define USB_DEVICE_B_HNP_ENABLE 3
73#define USB_DEVICE_WUSB_DEVICE 3
74#define USB_DEVICE_A_HNP_SUPPORT 4
Christopher Ferris106b3a82016-08-24 12:15:38 -070075#define USB_DEVICE_A_ALT_HNP_SUPPORT 5
Ben Cheng655a7c02013-10-16 16:09:24 -070076#define USB_DEVICE_DEBUG_MODE 6
77#define TEST_J 1
78#define TEST_K 2
Christopher Ferris106b3a82016-08-24 12:15:38 -070079#define TEST_SE0_NAK 3
Ben Cheng655a7c02013-10-16 16:09:24 -070080#define TEST_PACKET 4
81#define TEST_FORCE_EN 5
82#define USB_DEVICE_U1_ENABLE 48
Christopher Ferris106b3a82016-08-24 12:15:38 -070083#define USB_DEVICE_U2_ENABLE 49
Ben Cheng655a7c02013-10-16 16:09:24 -070084#define USB_DEVICE_LTM_ENABLE 50
85#define USB_INTRF_FUNC_SUSPEND 0
86#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
Christopher Ferris106b3a82016-08-24 12:15:38 -070087#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
Ben Cheng655a7c02013-10-16 16:09:24 -070088#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
89#define USB_INTRF_STAT_FUNC_RW_CAP 1
90#define USB_INTRF_STAT_FUNC_RW 2
Christopher Ferris106b3a82016-08-24 12:15:38 -070091#define USB_ENDPOINT_HALT 0
Ben Cheng655a7c02013-10-16 16:09:24 -070092#define USB_DEV_STAT_U1_ENABLED 2
93#define USB_DEV_STAT_U2_ENABLED 3
94#define USB_DEV_STAT_LTM_ENABLED 4
Christopher Ferris106b3a82016-08-24 12:15:38 -070095#define USB_DEVICE_BATTERY_WAKE_MASK 40
96#define USB_DEVICE_OS_IS_PD_AWARE 41
97#define USB_DEVICE_POLICY_MODE 42
98#define USB_PORT_PR_SWAP 43
Christopher Ferris106b3a82016-08-24 12:15:38 -070099#define USB_PORT_GOTO_MIN 44
100#define USB_PORT_RETURN_POWER 45
101#define USB_PORT_ACCEPT_PD_REQUEST 46
102#define USB_PORT_REJECT_PD_REQUEST 47
Christopher Ferris106b3a82016-08-24 12:15:38 -0700103#define USB_PORT_PORT_PD_RESET 48
104#define USB_PORT_C_PORT_PD_CHANGE 49
105#define USB_PORT_CABLE_PD_RESET 50
106#define USB_DEVICE_CHARGING_POLICY 54
Christopher Ferris106b3a82016-08-24 12:15:38 -0700107struct usb_ctrlrequest {
Tao Baod7db5942015-01-28 10:07:51 -0800108 __u8 bRequestType;
109 __u8 bRequest;
110 __le16 wValue;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700111 __le16 wIndex;
Tao Baod7db5942015-01-28 10:07:51 -0800112 __le16 wLength;
113} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700114#define USB_DT_DEVICE 0x01
Christopher Ferris106b3a82016-08-24 12:15:38 -0700115#define USB_DT_CONFIG 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -0700116#define USB_DT_STRING 0x03
117#define USB_DT_INTERFACE 0x04
118#define USB_DT_ENDPOINT 0x05
Christopher Ferris106b3a82016-08-24 12:15:38 -0700119#define USB_DT_DEVICE_QUALIFIER 0x06
Ben Cheng655a7c02013-10-16 16:09:24 -0700120#define USB_DT_OTHER_SPEED_CONFIG 0x07
121#define USB_DT_INTERFACE_POWER 0x08
122#define USB_DT_OTG 0x09
Christopher Ferris106b3a82016-08-24 12:15:38 -0700123#define USB_DT_DEBUG 0x0a
Ben Cheng655a7c02013-10-16 16:09:24 -0700124#define USB_DT_INTERFACE_ASSOCIATION 0x0b
125#define USB_DT_SECURITY 0x0c
126#define USB_DT_KEY 0x0d
Christopher Ferris106b3a82016-08-24 12:15:38 -0700127#define USB_DT_ENCRYPTION_TYPE 0x0e
Ben Cheng655a7c02013-10-16 16:09:24 -0700128#define USB_DT_BOS 0x0f
129#define USB_DT_DEVICE_CAPABILITY 0x10
130#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
Christopher Ferris106b3a82016-08-24 12:15:38 -0700131#define USB_DT_WIRE_ADAPTER 0x21
Ben Cheng655a7c02013-10-16 16:09:24 -0700132#define USB_DT_RPIPE 0x22
133#define USB_DT_CS_RADIO_CONTROL 0x23
134#define USB_DT_PIPE_USAGE 0x24
Christopher Ferris106b3a82016-08-24 12:15:38 -0700135#define USB_DT_SS_ENDPOINT_COMP 0x30
136#define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
Ben Cheng655a7c02013-10-16 16:09:24 -0700137#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
138#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
139#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
140#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
Ben Cheng655a7c02013-10-16 16:09:24 -0700141#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
142struct usb_descriptor_header {
Tao Baod7db5942015-01-28 10:07:51 -0800143 __u8 bLength;
144 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800145} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700146struct usb_device_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800147 __u8 bLength;
148 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800149 __le16 bcdUSB;
150 __u8 bDeviceClass;
151 __u8 bDeviceSubClass;
152 __u8 bDeviceProtocol;
Tao Baod7db5942015-01-28 10:07:51 -0800153 __u8 bMaxPacketSize0;
154 __le16 idVendor;
155 __le16 idProduct;
156 __le16 bcdDevice;
Tao Baod7db5942015-01-28 10:07:51 -0800157 __u8 iManufacturer;
158 __u8 iProduct;
159 __u8 iSerialNumber;
160 __u8 bNumConfigurations;
Tao Baod7db5942015-01-28 10:07:51 -0800161} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700162#define USB_DT_DEVICE_SIZE 18
163#define USB_CLASS_PER_INTERFACE 0
164#define USB_CLASS_AUDIO 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700165#define USB_CLASS_COMM 2
166#define USB_CLASS_HID 3
167#define USB_CLASS_PHYSICAL 5
168#define USB_CLASS_STILL_IMAGE 6
Ben Cheng655a7c02013-10-16 16:09:24 -0700169#define USB_CLASS_PRINTER 7
170#define USB_CLASS_MASS_STORAGE 8
171#define USB_CLASS_HUB 9
172#define USB_CLASS_CDC_DATA 0x0a
Ben Cheng655a7c02013-10-16 16:09:24 -0700173#define USB_CLASS_CSCID 0x0b
174#define USB_CLASS_CONTENT_SEC 0x0d
175#define USB_CLASS_VIDEO 0x0e
176#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
Ben Cheng655a7c02013-10-16 16:09:24 -0700177#define USB_CLASS_MISC 0xef
178#define USB_CLASS_APP_SPEC 0xfe
179#define USB_CLASS_VENDOR_SPEC 0xff
180#define USB_SUBCLASS_VENDOR_SPEC 0xff
Ben Cheng655a7c02013-10-16 16:09:24 -0700181struct usb_config_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800182 __u8 bLength;
183 __u8 bDescriptorType;
184 __le16 wTotalLength;
Tao Baod7db5942015-01-28 10:07:51 -0800185 __u8 bNumInterfaces;
186 __u8 bConfigurationValue;
187 __u8 iConfiguration;
188 __u8 bmAttributes;
Tao Baod7db5942015-01-28 10:07:51 -0800189 __u8 bMaxPower;
190} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700191#define USB_DT_CONFIG_SIZE 9
192#define USB_CONFIG_ATT_ONE (1 << 7)
Ben Cheng655a7c02013-10-16 16:09:24 -0700193#define USB_CONFIG_ATT_SELFPOWER (1 << 6)
194#define USB_CONFIG_ATT_WAKEUP (1 << 5)
195#define USB_CONFIG_ATT_BATTERY (1 << 4)
196struct usb_string_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800197 __u8 bLength;
198 __u8 bDescriptorType;
199 __le16 wData[1];
200} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700201struct usb_interface_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800202 __u8 bLength;
203 __u8 bDescriptorType;
204 __u8 bInterfaceNumber;
Tao Baod7db5942015-01-28 10:07:51 -0800205 __u8 bAlternateSetting;
206 __u8 bNumEndpoints;
207 __u8 bInterfaceClass;
208 __u8 bInterfaceSubClass;
Tao Baod7db5942015-01-28 10:07:51 -0800209 __u8 bInterfaceProtocol;
210 __u8 iInterface;
211} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700212#define USB_DT_INTERFACE_SIZE 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700213struct usb_endpoint_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800214 __u8 bLength;
215 __u8 bDescriptorType;
216 __u8 bEndpointAddress;
Tao Baod7db5942015-01-28 10:07:51 -0800217 __u8 bmAttributes;
218 __le16 wMaxPacketSize;
219 __u8 bInterval;
220 __u8 bRefresh;
Tao Baod7db5942015-01-28 10:07:51 -0800221 __u8 bSynchAddress;
222} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700223#define USB_DT_ENDPOINT_SIZE 7
224#define USB_DT_ENDPOINT_AUDIO_SIZE 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700225#define USB_ENDPOINT_NUMBER_MASK 0x0f
226#define USB_ENDPOINT_DIR_MASK 0x80
227#define USB_ENDPOINT_XFERTYPE_MASK 0x03
228#define USB_ENDPOINT_XFER_CONTROL 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700229#define USB_ENDPOINT_XFER_ISOC 1
230#define USB_ENDPOINT_XFER_BULK 2
231#define USB_ENDPOINT_XFER_INT 3
232#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800233#define USB_ENDPOINT_MAXP_MASK 0x07ff
234#define USB_EP_MAXP_MULT_SHIFT 11
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800235#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT)
236#define USB_EP_MAXP_MULT(m) (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT)
Ben Cheng655a7c02013-10-16 16:09:24 -0700237#define USB_ENDPOINT_INTRTYPE 0x30
238#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
239#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
240#define USB_ENDPOINT_SYNCTYPE 0x0c
Ben Cheng655a7c02013-10-16 16:09:24 -0700241#define USB_ENDPOINT_SYNC_NONE (0 << 2)
242#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
243#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
244#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700245#define USB_ENDPOINT_USAGE_MASK 0x30
246#define USB_ENDPOINT_USAGE_DATA 0x00
247#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
248#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20
Christopher Ferris106b3a82016-08-24 12:15:38 -0700249struct usb_ssp_isoc_ep_comp_descriptor {
250 __u8 bLength;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700251 __u8 bDescriptorType;
252 __le16 wReseved;
253 __le32 dwBytesPerInterval;
254} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700255#define USB_DT_SSP_ISOC_EP_COMP_SIZE 8
Ben Cheng655a7c02013-10-16 16:09:24 -0700256struct usb_ss_ep_comp_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800257 __u8 bLength;
258 __u8 bDescriptorType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700259 __u8 bMaxBurst;
Tao Baod7db5942015-01-28 10:07:51 -0800260 __u8 bmAttributes;
261 __le16 wBytesPerInterval;
262} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700263#define USB_DT_SS_EP_COMP_SIZE 6
Ben Cheng655a7c02013-10-16 16:09:24 -0700264#define USB_SS_MULT(p) (1 + ((p) & 0x3))
Christopher Ferris106b3a82016-08-24 12:15:38 -0700265#define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7))
Ben Cheng655a7c02013-10-16 16:09:24 -0700266struct usb_qualifier_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800267 __u8 bLength;
268 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800269 __le16 bcdUSB;
270 __u8 bDeviceClass;
271 __u8 bDeviceSubClass;
272 __u8 bDeviceProtocol;
Tao Baod7db5942015-01-28 10:07:51 -0800273 __u8 bMaxPacketSize0;
274 __u8 bNumConfigurations;
275 __u8 bRESERVED;
276} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700277struct usb_otg_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800278 __u8 bLength;
279 __u8 bDescriptorType;
280 __u8 bmAttributes;
Tao Baod7db5942015-01-28 10:07:51 -0800281} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800282struct usb_otg20_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800283 __u8 bLength;
284 __u8 bDescriptorType;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800285 __u8 bmAttributes;
286 __le16 bcdOTG;
287} __attribute__((packed));
288#define USB_OTG_SRP (1 << 0)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800289#define USB_OTG_HNP (1 << 1)
290#define USB_OTG_ADP (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700291#define OTG_STS_SELECTOR 0xF000
Christopher Ferris05d08e92016-02-04 13:16:38 -0800292struct usb_debug_descriptor {
293 __u8 bLength;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800294 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800295 __u8 bDebugInEndpoint;
296 __u8 bDebugOutEndpoint;
Ben Cheng655a7c02013-10-16 16:09:24 -0700297} __attribute__((packed));
298struct usb_interface_assoc_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800299 __u8 bLength;
300 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800301 __u8 bFirstInterface;
302 __u8 bInterfaceCount;
303 __u8 bFunctionClass;
304 __u8 bFunctionSubClass;
Tao Baod7db5942015-01-28 10:07:51 -0800305 __u8 bFunctionProtocol;
306 __u8 iFunction;
307} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700308struct usb_security_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800309 __u8 bLength;
310 __u8 bDescriptorType;
311 __le16 wTotalLength;
312 __u8 bNumEncryptionTypes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700313} __attribute__((packed));
314struct usb_key_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800315 __u8 bLength;
316 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800317 __u8 tTKID[3];
318 __u8 bReserved;
319 __u8 bKeyData[0];
Ben Cheng655a7c02013-10-16 16:09:24 -0700320} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700321struct usb_encryption_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800322 __u8 bLength;
323 __u8 bDescriptorType;
324 __u8 bEncryptionType;
Ben Cheng655a7c02013-10-16 16:09:24 -0700325#define USB_ENC_TYPE_UNSECURE 0
326#define USB_ENC_TYPE_WIRED 1
327#define USB_ENC_TYPE_CCM_1 2
328#define USB_ENC_TYPE_RSA_1 3
Tao Baod7db5942015-01-28 10:07:51 -0800329 __u8 bEncryptionValue;
330 __u8 bAuthKeyIndex;
Ben Cheng655a7c02013-10-16 16:09:24 -0700331} __attribute__((packed));
332struct usb_bos_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800333 __u8 bLength;
334 __u8 bDescriptorType;
335 __le16 wTotalLength;
336 __u8 bNumDeviceCaps;
Ben Cheng655a7c02013-10-16 16:09:24 -0700337} __attribute__((packed));
338#define USB_DT_BOS_SIZE 5
339struct usb_dev_cap_header {
Tao Baod7db5942015-01-28 10:07:51 -0800340 __u8 bLength;
Tao Baod7db5942015-01-28 10:07:51 -0800341 __u8 bDescriptorType;
342 __u8 bDevCapabilityType;
Ben Cheng655a7c02013-10-16 16:09:24 -0700343} __attribute__((packed));
344#define USB_CAP_TYPE_WIRELESS_USB 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700345struct usb_wireless_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800346 __u8 bLength;
347 __u8 bDescriptorType;
348 __u8 bDevCapabilityType;
Tao Baod7db5942015-01-28 10:07:51 -0800349 __u8 bmAttributes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700350#define USB_WIRELESS_P2P_DRD (1 << 1)
351#define USB_WIRELESS_BEACON_MASK (3 << 2)
352#define USB_WIRELESS_BEACON_SELF (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700353#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
354#define USB_WIRELESS_BEACON_NONE (3 << 2)
Tao Baod7db5942015-01-28 10:07:51 -0800355 __le16 wPHYRates;
Ben Cheng655a7c02013-10-16 16:09:24 -0700356#define USB_WIRELESS_PHY_53 (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700357#define USB_WIRELESS_PHY_80 (1 << 1)
358#define USB_WIRELESS_PHY_107 (1 << 2)
359#define USB_WIRELESS_PHY_160 (1 << 3)
360#define USB_WIRELESS_PHY_200 (1 << 4)
Ben Cheng655a7c02013-10-16 16:09:24 -0700361#define USB_WIRELESS_PHY_320 (1 << 5)
362#define USB_WIRELESS_PHY_400 (1 << 6)
363#define USB_WIRELESS_PHY_480 (1 << 7)
Tao Baod7db5942015-01-28 10:07:51 -0800364 __u8 bmTFITXPowerInfo;
Tao Baod7db5942015-01-28 10:07:51 -0800365 __u8 bmFFITXPowerInfo;
366 __le16 bmBandGroup;
367 __u8 bReserved;
Ben Cheng655a7c02013-10-16 16:09:24 -0700368} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700369#define USB_CAP_TYPE_EXT 2
370struct usb_ext_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800371 __u8 bLength;
372 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800373 __u8 bDevCapabilityType;
374 __le32 bmAttributes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700375#define USB_LPM_SUPPORT (1 << 1)
376#define USB_BESL_SUPPORT (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700377#define USB_BESL_BASELINE_VALID (1 << 3)
378#define USB_BESL_DEEP_VALID (1 << 4)
379#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
380#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
Ben Cheng655a7c02013-10-16 16:09:24 -0700381} __attribute__((packed));
382#define USB_DT_USB_EXT_CAP_SIZE 7
383#define USB_SS_CAP_TYPE 3
384struct usb_ss_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800385 __u8 bLength;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700386 __u8 bDescriptorType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700387 __u8 bDevCapabilityType;
388 __u8 bmAttributes;
389#define USB_LTM_SUPPORT (1 << 1)
390 __le16 wSpeedSupported;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700391#define USB_LOW_SPEED_OPERATION (1)
392#define USB_FULL_SPEED_OPERATION (1 << 1)
393#define USB_HIGH_SPEED_OPERATION (1 << 2)
394#define USB_5GBPS_OPERATION (1 << 3)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700395 __u8 bFunctionalitySupport;
396 __u8 bU1devExitLat;
397 __le16 bU2DevExitLat;
398} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700399#define USB_DT_USB_SS_CAP_SIZE 10
400#define CONTAINER_ID_TYPE 4
401struct usb_ss_container_id_descriptor {
402 __u8 bLength;
Tao Baod7db5942015-01-28 10:07:51 -0800403 __u8 bDescriptorType;
404 __u8 bDevCapabilityType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700405 __u8 bReserved;
406 __u8 ContainerID[16];
Ben Cheng655a7c02013-10-16 16:09:24 -0700407} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700408#define USB_DT_USB_SS_CONTN_ID_SIZE 20
409#define USB_SSP_CAP_TYPE 0xa
410struct usb_ssp_cap_descriptor {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800411 __u8 bLength;
412 __u8 bDescriptorType;
413 __u8 bDevCapabilityType;
414 __u8 bReserved;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700415 __le32 bmAttributes;
416#define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0)
417#define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5)
418 __le16 wFunctionalitySupport;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700419#define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
420#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
421#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
422 __le16 wReserved;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700423 __le32 bmSublinkSpeedAttr[1];
424#define USB_SSP_SUBLINK_SPEED_SSID (0xf)
425#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
426#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700427#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
428#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
429#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
430} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700431#define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
432#define USB_PD_BATTERY_INFO_CAPABILITY 0x07
433#define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08
434#define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09
Christopher Ferris106b3a82016-08-24 12:15:38 -0700435struct usb_pd_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800436 __u8 bLength;
437 __u8 bDescriptorType;
438 __u8 bDevCapabilityType;
Tao Baod7db5942015-01-28 10:07:51 -0800439 __u8 bReserved;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800440 __le32 bmAttributes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700441#define USB_PD_CAP_BATTERY_CHARGING (1 << 1)
442#define USB_PD_CAP_USB_PD (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700443#define USB_PD_CAP_PROVIDER (1 << 3)
444#define USB_PD_CAP_CONSUMER (1 << 4)
445#define USB_PD_CAP_CHARGING_POLICY (1 << 5)
446#define USB_PD_CAP_TYPE_C_CURRENT (1 << 6)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700447#define USB_PD_CAP_PWR_AC (1 << 8)
448#define USB_PD_CAP_PWR_BAT (1 << 9)
449#define USB_PD_CAP_PWR_USE_V_BUS (1 << 14)
450 __le16 bmProviderPorts;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700451 __le16 bmConsumerPorts;
452 __le16 bcdBCVersion;
453 __le16 bcdPDVersion;
454 __le16 bcdUSBTypeCVersion;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800455} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700456struct usb_pd_cap_battery_info_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800457 __u8 bLength;
458 __u8 bDescriptorType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700459 __u8 bDevCapabilityType;
460 __u8 iBattery;
461 __u8 iSerial;
462 __u8 iManufacturer;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700463 __u8 bBatteryId;
464 __u8 bReserved;
465 __le32 dwChargedThreshold;
466 __le32 dwWeakThreshold;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700467 __le32 dwBatteryDesignCapacity;
468 __le32 dwBatteryLastFullchargeCapacity;
469} __attribute__((packed));
470struct usb_pd_cap_consumer_port_descriptor {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700471 __u8 bLength;
472 __u8 bDescriptorType;
473 __u8 bDevCapabilityType;
474 __u8 bReserved;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700475 __u8 bmCapabilities;
476#define USB_PD_CAP_CONSUMER_BC (1 << 0)
477#define USB_PD_CAP_CONSUMER_PD (1 << 1)
478#define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700479 __le16 wMinVoltage;
480 __le16 wMaxVoltage;
481 __u16 wReserved;
482 __le32 dwMaxOperatingPower;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700483 __le32 dwMaxPeakPower;
484 __le32 dwMaxPeakPowerTime;
485#define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff
486} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700487struct usb_pd_cap_provider_port_descriptor {
488 __u8 bLength;
489 __u8 bDescriptorType;
490 __u8 bDevCapabilityType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700491 __u8 bReserved1;
492 __u8 bmCapabilities;
493#define USB_PD_CAP_PROVIDER_BC (1 << 0)
494#define USB_PD_CAP_PROVIDER_PD (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700495#define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2)
496 __u8 bNumOfPDObjects;
497 __u8 bReserved2;
498 __le32 wPowerDataObject[];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700499} __attribute__((packed));
500#define USB_PTM_CAP_TYPE 0xb
501struct usb_ptm_cap_descriptor {
502 __u8 bLength;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700503 __u8 bDescriptorType;
504 __u8 bDevCapabilityType;
505} __attribute__((packed));
506#define USB_DT_USB_SSP_CAP_SIZE(ssac) (16 + ssac * 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700507struct usb_wireless_ep_comp_descriptor {
508 __u8 bLength;
509 __u8 bDescriptorType;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800510 __u8 bMaxBurst;
Tao Baod7db5942015-01-28 10:07:51 -0800511 __u8 bMaxSequence;
512 __le16 wMaxStreamDelay;
513 __le16 wOverTheAirPacketSize;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800514 __u8 bOverTheAirInterval;
Tao Baod7db5942015-01-28 10:07:51 -0800515 __u8 bmCompAttributes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700516#define USB_ENDPOINT_SWITCH_MASK 0x03
517#define USB_ENDPOINT_SWITCH_NO 0
Christopher Ferris05d08e92016-02-04 13:16:38 -0800518#define USB_ENDPOINT_SWITCH_SWITCH 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700519#define USB_ENDPOINT_SWITCH_SCALE 2
520} __attribute__((packed));
521struct usb_handshake {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800522 __u8 bMessageNumber;
Tao Baod7db5942015-01-28 10:07:51 -0800523 __u8 bStatus;
524 __u8 tTKID[3];
525 __u8 bReserved;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800526 __u8 CDID[16];
Tao Baod7db5942015-01-28 10:07:51 -0800527 __u8 nonce[16];
528 __u8 MIC[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700529} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800530struct usb_connection_context {
Tao Baod7db5942015-01-28 10:07:51 -0800531 __u8 CHID[16];
532 __u8 CDID[16];
533 __u8 CK[16];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800534} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700535enum usb_device_speed {
Tao Baod7db5942015-01-28 10:07:51 -0800536 USB_SPEED_UNKNOWN = 0,
537 USB_SPEED_LOW,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800538 USB_SPEED_FULL,
Tao Baod7db5942015-01-28 10:07:51 -0800539 USB_SPEED_HIGH,
540 USB_SPEED_WIRELESS,
541 USB_SPEED_SUPER,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700542 USB_SPEED_SUPER_PLUS,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800543};
Ben Cheng655a7c02013-10-16 16:09:24 -0700544enum usb_device_state {
Tao Baod7db5942015-01-28 10:07:51 -0800545 USB_STATE_NOTATTACHED = 0,
546 USB_STATE_ATTACHED,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800547 USB_STATE_POWERED,
Tao Baod7db5942015-01-28 10:07:51 -0800548 USB_STATE_RECONNECTING,
549 USB_STATE_UNAUTHENTICATED,
550 USB_STATE_DEFAULT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800551 USB_STATE_ADDRESS,
Tao Baod7db5942015-01-28 10:07:51 -0800552 USB_STATE_CONFIGURED,
553 USB_STATE_SUSPENDED
Ben Cheng655a7c02013-10-16 16:09:24 -0700554};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800555enum usb3_link_state {
Tao Baod7db5942015-01-28 10:07:51 -0800556 USB3_LPM_U0 = 0,
557 USB3_LPM_U1,
558 USB3_LPM_U2,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800559 USB3_LPM_U3
Ben Cheng655a7c02013-10-16 16:09:24 -0700560};
Ben Cheng655a7c02013-10-16 16:09:24 -0700561#define USB3_LPM_DISABLED 0x0
562#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
Christopher Ferris05d08e92016-02-04 13:16:38 -0800563#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
Ben Cheng655a7c02013-10-16 16:09:24 -0700564#define USB3_LPM_DEVICE_INITIATED 0xFF
Ben Cheng655a7c02013-10-16 16:09:24 -0700565struct usb_set_sel_req {
Tao Baod7db5942015-01-28 10:07:51 -0800566 __u8 u1_sel;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800567 __u8 u1_pel;
Tao Baod7db5942015-01-28 10:07:51 -0800568 __le16 u2_sel;
569 __le16 u2_pel;
570} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800571#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
Tao Baod7db5942015-01-28 10:07:51 -0800572#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
Ben Cheng655a7c02013-10-16 16:09:24 -0700573#define USB_SELF_POWER_VBUS_MAX_DRAW 100
574#endif