blob: dd66991fddffda5dff1212d7dcbfc796d2529607 [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
Christopher Ferris25c18d42020-10-14 17:42:58 -070077#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 Ferris934ec942018-01-31 15:29:16 -080082#define USB_STATUS_TYPE_STANDARD 0
83#define USB_STATUS_TYPE_PTM 1
Ben Cheng655a7c02013-10-16 16:09:24 -070084#define USB_DEVICE_U1_ENABLE 48
Christopher Ferris106b3a82016-08-24 12:15:38 -070085#define USB_DEVICE_U2_ENABLE 49
Ben Cheng655a7c02013-10-16 16:09:24 -070086#define USB_DEVICE_LTM_ENABLE 50
87#define USB_INTRF_FUNC_SUSPEND 0
88#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
Christopher Ferris106b3a82016-08-24 12:15:38 -070089#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
Ben Cheng655a7c02013-10-16 16:09:24 -070090#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 Ferris106b3a82016-08-24 12:15:38 -070093#define USB_ENDPOINT_HALT 0
Ben Cheng655a7c02013-10-16 16:09:24 -070094#define USB_DEV_STAT_U1_ENABLED 2
95#define USB_DEV_STAT_U2_ENABLED 3
96#define USB_DEV_STAT_LTM_ENABLED 4
Christopher Ferris106b3a82016-08-24 12:15:38 -070097#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 Ferris106b3a82016-08-24 12:15:38 -0700101#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 Ferris106b3a82016-08-24 12:15:38 -0700105#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 Ferris106b3a82016-08-24 12:15:38 -0700109struct usb_ctrlrequest {
Tao Baod7db5942015-01-28 10:07:51 -0800110 __u8 bRequestType;
111 __u8 bRequest;
112 __le16 wValue;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700113 __le16 wIndex;
Tao Baod7db5942015-01-28 10:07:51 -0800114 __le16 wLength;
115} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700116#define USB_DT_DEVICE 0x01
Christopher Ferris106b3a82016-08-24 12:15:38 -0700117#define USB_DT_CONFIG 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -0700118#define USB_DT_STRING 0x03
119#define USB_DT_INTERFACE 0x04
120#define USB_DT_ENDPOINT 0x05
Christopher Ferris106b3a82016-08-24 12:15:38 -0700121#define USB_DT_DEVICE_QUALIFIER 0x06
Ben Cheng655a7c02013-10-16 16:09:24 -0700122#define USB_DT_OTHER_SPEED_CONFIG 0x07
123#define USB_DT_INTERFACE_POWER 0x08
124#define USB_DT_OTG 0x09
Christopher Ferris106b3a82016-08-24 12:15:38 -0700125#define USB_DT_DEBUG 0x0a
Ben Cheng655a7c02013-10-16 16:09:24 -0700126#define USB_DT_INTERFACE_ASSOCIATION 0x0b
127#define USB_DT_SECURITY 0x0c
128#define USB_DT_KEY 0x0d
Christopher Ferris106b3a82016-08-24 12:15:38 -0700129#define USB_DT_ENCRYPTION_TYPE 0x0e
Ben Cheng655a7c02013-10-16 16:09:24 -0700130#define USB_DT_BOS 0x0f
131#define USB_DT_DEVICE_CAPABILITY 0x10
132#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
Christopher Ferris106b3a82016-08-24 12:15:38 -0700133#define USB_DT_WIRE_ADAPTER 0x21
Ben Cheng655a7c02013-10-16 16:09:24 -0700134#define USB_DT_RPIPE 0x22
135#define USB_DT_CS_RADIO_CONTROL 0x23
136#define USB_DT_PIPE_USAGE 0x24
Christopher Ferris106b3a82016-08-24 12:15:38 -0700137#define USB_DT_SS_ENDPOINT_COMP 0x30
138#define USB_DT_SSP_ISOC_ENDPOINT_COMP 0x31
Ben Cheng655a7c02013-10-16 16:09:24 -0700139#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 Cheng655a7c02013-10-16 16:09:24 -0700143#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
144struct usb_descriptor_header {
Tao Baod7db5942015-01-28 10:07:51 -0800145 __u8 bLength;
146 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800147} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700148struct usb_device_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800149 __u8 bLength;
150 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800151 __le16 bcdUSB;
152 __u8 bDeviceClass;
153 __u8 bDeviceSubClass;
154 __u8 bDeviceProtocol;
Tao Baod7db5942015-01-28 10:07:51 -0800155 __u8 bMaxPacketSize0;
156 __le16 idVendor;
157 __le16 idProduct;
158 __le16 bcdDevice;
Tao Baod7db5942015-01-28 10:07:51 -0800159 __u8 iManufacturer;
160 __u8 iProduct;
161 __u8 iSerialNumber;
162 __u8 bNumConfigurations;
Tao Baod7db5942015-01-28 10:07:51 -0800163} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700164#define USB_DT_DEVICE_SIZE 18
165#define USB_CLASS_PER_INTERFACE 0
166#define USB_CLASS_AUDIO 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700167#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 Cheng655a7c02013-10-16 16:09:24 -0700171#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 Cheng655a7c02013-10-16 16:09:24 -0700175#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 Ferris25c18d42020-10-14 17:42:58 -0700179#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 Cheng655a7c02013-10-16 16:09:24 -0700183#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 Cheng655a7c02013-10-16 16:09:24 -0700187struct usb_config_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800188 __u8 bLength;
189 __u8 bDescriptorType;
190 __le16 wTotalLength;
Tao Baod7db5942015-01-28 10:07:51 -0800191 __u8 bNumInterfaces;
192 __u8 bConfigurationValue;
193 __u8 iConfiguration;
194 __u8 bmAttributes;
Tao Baod7db5942015-01-28 10:07:51 -0800195 __u8 bMaxPower;
196} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700197#define USB_DT_CONFIG_SIZE 9
198#define USB_CONFIG_ATT_ONE (1 << 7)
Ben Cheng655a7c02013-10-16 16:09:24 -0700199#define USB_CONFIG_ATT_SELFPOWER (1 << 6)
200#define USB_CONFIG_ATT_WAKEUP (1 << 5)
201#define USB_CONFIG_ATT_BATTERY (1 << 4)
Christopher Ferris25c18d42020-10-14 17:42:58 -0700202#define USB_MAX_STRING_LEN 126
Ben Cheng655a7c02013-10-16 16:09:24 -0700203struct usb_string_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800204 __u8 bLength;
205 __u8 bDescriptorType;
Christopher Ferris8666d042023-09-06 14:55:31 -0700206 union {
207 __le16 legacy_padding;
208 __DECLARE_FLEX_ARRAY(__le16, wData);
209 };
Tao Baod7db5942015-01-28 10:07:51 -0800210} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700211struct usb_interface_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800212 __u8 bLength;
213 __u8 bDescriptorType;
214 __u8 bInterfaceNumber;
Tao Baod7db5942015-01-28 10:07:51 -0800215 __u8 bAlternateSetting;
216 __u8 bNumEndpoints;
217 __u8 bInterfaceClass;
218 __u8 bInterfaceSubClass;
Tao Baod7db5942015-01-28 10:07:51 -0800219 __u8 bInterfaceProtocol;
220 __u8 iInterface;
221} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700222#define USB_DT_INTERFACE_SIZE 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700223struct usb_endpoint_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800224 __u8 bLength;
225 __u8 bDescriptorType;
226 __u8 bEndpointAddress;
Tao Baod7db5942015-01-28 10:07:51 -0800227 __u8 bmAttributes;
228 __le16 wMaxPacketSize;
229 __u8 bInterval;
230 __u8 bRefresh;
Tao Baod7db5942015-01-28 10:07:51 -0800231 __u8 bSynchAddress;
232} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700233#define USB_DT_ENDPOINT_SIZE 7
234#define USB_DT_ENDPOINT_AUDIO_SIZE 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700235#define USB_ENDPOINT_NUMBER_MASK 0x0f
236#define USB_ENDPOINT_DIR_MASK 0x80
237#define USB_ENDPOINT_XFERTYPE_MASK 0x03
238#define USB_ENDPOINT_XFER_CONTROL 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700239#define USB_ENDPOINT_XFER_ISOC 1
240#define USB_ENDPOINT_XFER_BULK 2
241#define USB_ENDPOINT_XFER_INT 3
242#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800243#define USB_ENDPOINT_MAXP_MASK 0x07ff
244#define USB_EP_MAXP_MULT_SHIFT 11
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800245#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT)
246#define USB_EP_MAXP_MULT(m) (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT)
Ben Cheng655a7c02013-10-16 16:09:24 -0700247#define USB_ENDPOINT_INTRTYPE 0x30
248#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
249#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
250#define USB_ENDPOINT_SYNCTYPE 0x0c
Ben Cheng655a7c02013-10-16 16:09:24 -0700251#define USB_ENDPOINT_SYNC_NONE (0 << 2)
252#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
253#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
254#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700255#define USB_ENDPOINT_USAGE_MASK 0x30
256#define USB_ENDPOINT_USAGE_DATA 0x00
257#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
258#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20
Christopher Ferris106b3a82016-08-24 12:15:38 -0700259struct usb_ssp_isoc_ep_comp_descriptor {
260 __u8 bLength;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700261 __u8 bDescriptorType;
262 __le16 wReseved;
263 __le32 dwBytesPerInterval;
264} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700265#define USB_DT_SSP_ISOC_EP_COMP_SIZE 8
Ben Cheng655a7c02013-10-16 16:09:24 -0700266struct usb_ss_ep_comp_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800267 __u8 bLength;
268 __u8 bDescriptorType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700269 __u8 bMaxBurst;
Tao Baod7db5942015-01-28 10:07:51 -0800270 __u8 bmAttributes;
271 __le16 wBytesPerInterval;
272} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700273#define USB_DT_SS_EP_COMP_SIZE 6
Ben Cheng655a7c02013-10-16 16:09:24 -0700274#define USB_SS_MULT(p) (1 + ((p) & 0x3))
Christopher Ferris106b3a82016-08-24 12:15:38 -0700275#define USB_SS_SSP_ISOC_COMP(p) ((p) & (1 << 7))
Ben Cheng655a7c02013-10-16 16:09:24 -0700276struct usb_qualifier_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800277 __u8 bLength;
278 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800279 __le16 bcdUSB;
280 __u8 bDeviceClass;
281 __u8 bDeviceSubClass;
282 __u8 bDeviceProtocol;
Tao Baod7db5942015-01-28 10:07:51 -0800283 __u8 bMaxPacketSize0;
284 __u8 bNumConfigurations;
285 __u8 bRESERVED;
286} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700287struct usb_otg_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800288 __u8 bLength;
289 __u8 bDescriptorType;
290 __u8 bmAttributes;
Tao Baod7db5942015-01-28 10:07:51 -0800291} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800292struct usb_otg20_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800293 __u8 bLength;
294 __u8 bDescriptorType;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800295 __u8 bmAttributes;
296 __le16 bcdOTG;
297} __attribute__((packed));
298#define USB_OTG_SRP (1 << 0)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800299#define USB_OTG_HNP (1 << 1)
300#define USB_OTG_ADP (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700301#define OTG_STS_SELECTOR 0xF000
Christopher Ferris05d08e92016-02-04 13:16:38 -0800302struct usb_debug_descriptor {
303 __u8 bLength;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800304 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800305 __u8 bDebugInEndpoint;
306 __u8 bDebugOutEndpoint;
Ben Cheng655a7c02013-10-16 16:09:24 -0700307} __attribute__((packed));
308struct usb_interface_assoc_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800309 __u8 bLength;
310 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800311 __u8 bFirstInterface;
312 __u8 bInterfaceCount;
313 __u8 bFunctionClass;
314 __u8 bFunctionSubClass;
Tao Baod7db5942015-01-28 10:07:51 -0800315 __u8 bFunctionProtocol;
316 __u8 iFunction;
317} __attribute__((packed));
Christopher Ferris1308ad32017-11-14 17:32:13 -0800318#define USB_DT_INTERFACE_ASSOCIATION_SIZE 8
Ben Cheng655a7c02013-10-16 16:09:24 -0700319struct usb_security_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800320 __u8 bLength;
321 __u8 bDescriptorType;
322 __le16 wTotalLength;
323 __u8 bNumEncryptionTypes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700324} __attribute__((packed));
325struct usb_key_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800326 __u8 bLength;
327 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800328 __u8 tTKID[3];
329 __u8 bReserved;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700330 __u8 bKeyData[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700331} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700332struct usb_encryption_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800333 __u8 bLength;
334 __u8 bDescriptorType;
335 __u8 bEncryptionType;
Ben Cheng655a7c02013-10-16 16:09:24 -0700336#define USB_ENC_TYPE_UNSECURE 0
337#define USB_ENC_TYPE_WIRED 1
338#define USB_ENC_TYPE_CCM_1 2
339#define USB_ENC_TYPE_RSA_1 3
Tao Baod7db5942015-01-28 10:07:51 -0800340 __u8 bEncryptionValue;
341 __u8 bAuthKeyIndex;
Ben Cheng655a7c02013-10-16 16:09:24 -0700342} __attribute__((packed));
343struct usb_bos_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800344 __u8 bLength;
345 __u8 bDescriptorType;
346 __le16 wTotalLength;
347 __u8 bNumDeviceCaps;
Ben Cheng655a7c02013-10-16 16:09:24 -0700348} __attribute__((packed));
349#define USB_DT_BOS_SIZE 5
350struct usb_dev_cap_header {
Tao Baod7db5942015-01-28 10:07:51 -0800351 __u8 bLength;
Tao Baod7db5942015-01-28 10:07:51 -0800352 __u8 bDescriptorType;
353 __u8 bDevCapabilityType;
Ben Cheng655a7c02013-10-16 16:09:24 -0700354} __attribute__((packed));
355#define USB_CAP_TYPE_WIRELESS_USB 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700356struct usb_wireless_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800357 __u8 bLength;
358 __u8 bDescriptorType;
359 __u8 bDevCapabilityType;
Tao Baod7db5942015-01-28 10:07:51 -0800360 __u8 bmAttributes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700361#define USB_WIRELESS_P2P_DRD (1 << 1)
362#define USB_WIRELESS_BEACON_MASK (3 << 2)
363#define USB_WIRELESS_BEACON_SELF (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700364#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
365#define USB_WIRELESS_BEACON_NONE (3 << 2)
Tao Baod7db5942015-01-28 10:07:51 -0800366 __le16 wPHYRates;
Ben Cheng655a7c02013-10-16 16:09:24 -0700367#define USB_WIRELESS_PHY_53 (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700368#define USB_WIRELESS_PHY_80 (1 << 1)
369#define USB_WIRELESS_PHY_107 (1 << 2)
370#define USB_WIRELESS_PHY_160 (1 << 3)
371#define USB_WIRELESS_PHY_200 (1 << 4)
Ben Cheng655a7c02013-10-16 16:09:24 -0700372#define USB_WIRELESS_PHY_320 (1 << 5)
373#define USB_WIRELESS_PHY_400 (1 << 6)
374#define USB_WIRELESS_PHY_480 (1 << 7)
Tao Baod7db5942015-01-28 10:07:51 -0800375 __u8 bmTFITXPowerInfo;
Tao Baod7db5942015-01-28 10:07:51 -0800376 __u8 bmFFITXPowerInfo;
377 __le16 bmBandGroup;
378 __u8 bReserved;
Ben Cheng655a7c02013-10-16 16:09:24 -0700379} __attribute__((packed));
Christopher Ferris934ec942018-01-31 15:29:16 -0800380#define USB_DT_USB_WIRELESS_CAP_SIZE 11
Ben Cheng655a7c02013-10-16 16:09:24 -0700381#define USB_CAP_TYPE_EXT 2
382struct usb_ext_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800383 __u8 bLength;
384 __u8 bDescriptorType;
Tao Baod7db5942015-01-28 10:07:51 -0800385 __u8 bDevCapabilityType;
386 __le32 bmAttributes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700387#define USB_LPM_SUPPORT (1 << 1)
388#define USB_BESL_SUPPORT (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700389#define USB_BESL_BASELINE_VALID (1 << 3)
390#define USB_BESL_DEEP_VALID (1 << 4)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800391#define USB_SET_BESL_BASELINE(p) (((p) & 0xf) << 8)
392#define USB_SET_BESL_DEEP(p) (((p) & 0xf) << 12)
Ben Cheng655a7c02013-10-16 16:09:24 -0700393#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
394#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
Ben Cheng655a7c02013-10-16 16:09:24 -0700395} __attribute__((packed));
396#define USB_DT_USB_EXT_CAP_SIZE 7
397#define USB_SS_CAP_TYPE 3
398struct usb_ss_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800399 __u8 bLength;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700400 __u8 bDescriptorType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700401 __u8 bDevCapabilityType;
402 __u8 bmAttributes;
403#define USB_LTM_SUPPORT (1 << 1)
404 __le16 wSpeedSupported;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700405#define USB_LOW_SPEED_OPERATION (1)
406#define USB_FULL_SPEED_OPERATION (1 << 1)
407#define USB_HIGH_SPEED_OPERATION (1 << 2)
408#define USB_5GBPS_OPERATION (1 << 3)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700409 __u8 bFunctionalitySupport;
410 __u8 bU1devExitLat;
411 __le16 bU2DevExitLat;
412} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700413#define USB_DT_USB_SS_CAP_SIZE 10
414#define CONTAINER_ID_TYPE 4
415struct usb_ss_container_id_descriptor {
416 __u8 bLength;
Tao Baod7db5942015-01-28 10:07:51 -0800417 __u8 bDescriptorType;
418 __u8 bDevCapabilityType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700419 __u8 bReserved;
420 __u8 ContainerID[16];
Ben Cheng655a7c02013-10-16 16:09:24 -0700421} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700422#define USB_DT_USB_SS_CONTN_ID_SIZE 20
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000423#define USB_PLAT_DEV_CAP_TYPE 5
424struct usb_plat_dev_cap_descriptor {
425 __u8 bLength;
426 __u8 bDescriptorType;
427 __u8 bDevCapabilityType;
428 __u8 bReserved;
429 __u8 UUID[16];
430 __u8 CapabilityData[];
431} __attribute__((packed));
432#define USB_DT_USB_PLAT_DEV_CAP_SIZE(capability_data_size) (20 + capability_data_size)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700433#define USB_SSP_CAP_TYPE 0xa
434struct usb_ssp_cap_descriptor {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800435 __u8 bLength;
436 __u8 bDescriptorType;
437 __u8 bDevCapabilityType;
438 __u8 bReserved;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700439 __le32 bmAttributes;
440#define USB_SSP_SUBLINK_SPEED_ATTRIBS (0x1f << 0)
441#define USB_SSP_SUBLINK_SPEED_IDS (0xf << 5)
442 __le16 wFunctionalitySupport;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700443#define USB_SSP_MIN_SUBLINK_SPEED_ATTRIBUTE_ID (0xf)
444#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
445#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
446 __le16 wReserved;
Christopher Ferris8666d042023-09-06 14:55:31 -0700447 union {
448 __le32 legacy_padding;
449 __DECLARE_FLEX_ARRAY(__le32, bmSublinkSpeedAttr);
450 };
Christopher Ferris106b3a82016-08-24 12:15:38 -0700451#define USB_SSP_SUBLINK_SPEED_SSID (0xf)
452#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700453#define USB_SSP_SUBLINK_SPEED_LSE_BPS 0
454#define USB_SSP_SUBLINK_SPEED_LSE_KBPS 1
455#define USB_SSP_SUBLINK_SPEED_LSE_MBPS 2
456#define USB_SSP_SUBLINK_SPEED_LSE_GBPS 3
Christopher Ferris106b3a82016-08-24 12:15:38 -0700457#define USB_SSP_SUBLINK_SPEED_ST (0x3 << 6)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700458#define USB_SSP_SUBLINK_SPEED_ST_SYM_RX 0
459#define USB_SSP_SUBLINK_SPEED_ST_ASYM_RX 1
460#define USB_SSP_SUBLINK_SPEED_ST_SYM_TX 2
461#define USB_SSP_SUBLINK_SPEED_ST_ASYM_TX 3
Christopher Ferris106b3a82016-08-24 12:15:38 -0700462#define USB_SSP_SUBLINK_SPEED_RSVD (0x3f << 8)
463#define USB_SSP_SUBLINK_SPEED_LP (0x3 << 14)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700464#define USB_SSP_SUBLINK_SPEED_LP_SS 0
465#define USB_SSP_SUBLINK_SPEED_LP_SSP 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700466#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16)
467} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700468#define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
469#define USB_PD_BATTERY_INFO_CAPABILITY 0x07
470#define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08
471#define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09
Christopher Ferris106b3a82016-08-24 12:15:38 -0700472struct usb_pd_cap_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800473 __u8 bLength;
474 __u8 bDescriptorType;
475 __u8 bDevCapabilityType;
Tao Baod7db5942015-01-28 10:07:51 -0800476 __u8 bReserved;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800477 __le32 bmAttributes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700478#define USB_PD_CAP_BATTERY_CHARGING (1 << 1)
479#define USB_PD_CAP_USB_PD (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700480#define USB_PD_CAP_PROVIDER (1 << 3)
481#define USB_PD_CAP_CONSUMER (1 << 4)
482#define USB_PD_CAP_CHARGING_POLICY (1 << 5)
483#define USB_PD_CAP_TYPE_C_CURRENT (1 << 6)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700484#define USB_PD_CAP_PWR_AC (1 << 8)
485#define USB_PD_CAP_PWR_BAT (1 << 9)
486#define USB_PD_CAP_PWR_USE_V_BUS (1 << 14)
487 __le16 bmProviderPorts;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700488 __le16 bmConsumerPorts;
489 __le16 bcdBCVersion;
490 __le16 bcdPDVersion;
491 __le16 bcdUSBTypeCVersion;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800492} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700493struct usb_pd_cap_battery_info_descriptor {
Tao Baod7db5942015-01-28 10:07:51 -0800494 __u8 bLength;
495 __u8 bDescriptorType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700496 __u8 bDevCapabilityType;
497 __u8 iBattery;
498 __u8 iSerial;
499 __u8 iManufacturer;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700500 __u8 bBatteryId;
501 __u8 bReserved;
502 __le32 dwChargedThreshold;
503 __le32 dwWeakThreshold;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700504 __le32 dwBatteryDesignCapacity;
505 __le32 dwBatteryLastFullchargeCapacity;
506} __attribute__((packed));
507struct usb_pd_cap_consumer_port_descriptor {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700508 __u8 bLength;
509 __u8 bDescriptorType;
510 __u8 bDevCapabilityType;
511 __u8 bReserved;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700512 __u8 bmCapabilities;
513#define USB_PD_CAP_CONSUMER_BC (1 << 0)
514#define USB_PD_CAP_CONSUMER_PD (1 << 1)
515#define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700516 __le16 wMinVoltage;
517 __le16 wMaxVoltage;
518 __u16 wReserved;
519 __le32 dwMaxOperatingPower;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700520 __le32 dwMaxPeakPower;
521 __le32 dwMaxPeakPowerTime;
522#define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff
523} __attribute__((packed));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700524struct usb_pd_cap_provider_port_descriptor {
525 __u8 bLength;
526 __u8 bDescriptorType;
527 __u8 bDevCapabilityType;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700528 __u8 bReserved1;
529 __u8 bmCapabilities;
530#define USB_PD_CAP_PROVIDER_BC (1 << 0)
531#define USB_PD_CAP_PROVIDER_PD (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700532#define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2)
533 __u8 bNumOfPDObjects;
534 __u8 bReserved2;
535 __le32 wPowerDataObject[];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700536} __attribute__((packed));
537#define USB_PTM_CAP_TYPE 0xb
538struct usb_ptm_cap_descriptor {
539 __u8 bLength;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700540 __u8 bDescriptorType;
541 __u8 bDevCapabilityType;
542} __attribute__((packed));
Christopher Ferris934ec942018-01-31 15:29:16 -0800543#define USB_DT_USB_PTM_ID_SIZE 3
Christopher Ferris76a1d452018-06-27 14:12:29 -0700544#define USB_DT_USB_SSP_CAP_SIZE(ssac) (12 + (ssac + 1) * 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700545struct usb_wireless_ep_comp_descriptor {
546 __u8 bLength;
547 __u8 bDescriptorType;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800548 __u8 bMaxBurst;
Tao Baod7db5942015-01-28 10:07:51 -0800549 __u8 bMaxSequence;
550 __le16 wMaxStreamDelay;
551 __le16 wOverTheAirPacketSize;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800552 __u8 bOverTheAirInterval;
Tao Baod7db5942015-01-28 10:07:51 -0800553 __u8 bmCompAttributes;
Ben Cheng655a7c02013-10-16 16:09:24 -0700554#define USB_ENDPOINT_SWITCH_MASK 0x03
555#define USB_ENDPOINT_SWITCH_NO 0
Christopher Ferris05d08e92016-02-04 13:16:38 -0800556#define USB_ENDPOINT_SWITCH_SWITCH 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700557#define USB_ENDPOINT_SWITCH_SCALE 2
558} __attribute__((packed));
559struct usb_handshake {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800560 __u8 bMessageNumber;
Tao Baod7db5942015-01-28 10:07:51 -0800561 __u8 bStatus;
562 __u8 tTKID[3];
563 __u8 bReserved;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800564 __u8 CDID[16];
Tao Baod7db5942015-01-28 10:07:51 -0800565 __u8 nonce[16];
566 __u8 MIC[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700567} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800568struct usb_connection_context {
Tao Baod7db5942015-01-28 10:07:51 -0800569 __u8 CHID[16];
570 __u8 CDID[16];
571 __u8 CK[16];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800572} __attribute__((packed));
Ben Cheng655a7c02013-10-16 16:09:24 -0700573enum usb_device_speed {
Tao Baod7db5942015-01-28 10:07:51 -0800574 USB_SPEED_UNKNOWN = 0,
575 USB_SPEED_LOW,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800576 USB_SPEED_FULL,
Tao Baod7db5942015-01-28 10:07:51 -0800577 USB_SPEED_HIGH,
578 USB_SPEED_WIRELESS,
579 USB_SPEED_SUPER,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700580 USB_SPEED_SUPER_PLUS,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800581};
Ben Cheng655a7c02013-10-16 16:09:24 -0700582enum usb_device_state {
Tao Baod7db5942015-01-28 10:07:51 -0800583 USB_STATE_NOTATTACHED = 0,
584 USB_STATE_ATTACHED,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800585 USB_STATE_POWERED,
Tao Baod7db5942015-01-28 10:07:51 -0800586 USB_STATE_RECONNECTING,
587 USB_STATE_UNAUTHENTICATED,
588 USB_STATE_DEFAULT,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800589 USB_STATE_ADDRESS,
Tao Baod7db5942015-01-28 10:07:51 -0800590 USB_STATE_CONFIGURED,
591 USB_STATE_SUSPENDED
Ben Cheng655a7c02013-10-16 16:09:24 -0700592};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800593enum usb3_link_state {
Tao Baod7db5942015-01-28 10:07:51 -0800594 USB3_LPM_U0 = 0,
595 USB3_LPM_U1,
596 USB3_LPM_U2,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800597 USB3_LPM_U3
Ben Cheng655a7c02013-10-16 16:09:24 -0700598};
Ben Cheng655a7c02013-10-16 16:09:24 -0700599#define USB3_LPM_DISABLED 0x0
600#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
Christopher Ferris05d08e92016-02-04 13:16:38 -0800601#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
Ben Cheng655a7c02013-10-16 16:09:24 -0700602#define USB3_LPM_DEVICE_INITIATED 0xFF
Ben Cheng655a7c02013-10-16 16:09:24 -0700603struct usb_set_sel_req {
Tao Baod7db5942015-01-28 10:07:51 -0800604 __u8 u1_sel;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800605 __u8 u1_pel;
Tao Baod7db5942015-01-28 10:07:51 -0800606 __le16 u2_sel;
607 __le16 u2_pel;
608} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800609#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
Tao Baod7db5942015-01-28 10:07:51 -0800610#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
Ben Cheng655a7c02013-10-16 16:09:24 -0700611#define USB_SELF_POWER_VBUS_MAX_DRAW 100
612#endif