xref: /rk3399_rockchip-uboot/include/linux/usb/ch9.h (revision 82651c39f6544e932fb86853bf9a648414ccca9a)
123cd1385SRemy Bohmer /*
223cd1385SRemy Bohmer  * This file holds USB constants and structures that are needed for
323cd1385SRemy Bohmer  * USB device APIs.  These are used by the USB device model, which is
423cd1385SRemy Bohmer  * defined in chapter 9 of the USB 2.0 specification and in the
523cd1385SRemy Bohmer  * Wireless USB 1.0 (spread around).  Linux has several APIs in C that
623cd1385SRemy Bohmer  * need these:
723cd1385SRemy Bohmer  *
823cd1385SRemy Bohmer  * - the master/host side Linux-USB kernel driver API;
923cd1385SRemy Bohmer  * - the "usbfs" user space API; and
1023cd1385SRemy Bohmer  * - the Linux "gadget" slave/device/peripheral side driver API.
1123cd1385SRemy Bohmer  *
1223cd1385SRemy Bohmer  * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
1323cd1385SRemy Bohmer  * act either as a USB master/host or as a USB slave/device.  That means
1423cd1385SRemy Bohmer  * the master and slave side APIs benefit from working well together.
1523cd1385SRemy Bohmer  *
1623cd1385SRemy Bohmer  * There's also "Wireless USB", using low power short range radios for
1723cd1385SRemy Bohmer  * peripheral interconnection but otherwise building on the USB framework.
1823cd1385SRemy Bohmer  *
1923cd1385SRemy Bohmer  * Note all descriptors are declared '__attribute__((packed))' so that:
2023cd1385SRemy Bohmer  *
2123cd1385SRemy Bohmer  * [a] they never get padded, either internally (USB spec writers
2223cd1385SRemy Bohmer  *     probably handled that) or externally;
2323cd1385SRemy Bohmer  *
2423cd1385SRemy Bohmer  * [b] so that accessing bigger-than-a-bytes fields will never
2523cd1385SRemy Bohmer  *     generate bus errors on any platform, even when the location of
2623cd1385SRemy Bohmer  *     its descriptor inside a bundle isn't "naturally aligned", and
2723cd1385SRemy Bohmer  *
2823cd1385SRemy Bohmer  * [c] for consistency, removing all doubt even when it appears to
2923cd1385SRemy Bohmer  *     someone that the two other points are non-issues for that
3023cd1385SRemy Bohmer  *     particular descriptor type.
3123cd1385SRemy Bohmer  */
3223cd1385SRemy Bohmer 
3323cd1385SRemy Bohmer #ifndef __LINUX_USB_CH9_H
3423cd1385SRemy Bohmer #define __LINUX_USB_CH9_H
3523cd1385SRemy Bohmer 
3623cd1385SRemy Bohmer #include <linux/types.h>	/* __u8 etc */
37*82651c39SIlya Yanok #include <asm/byteorder.h>	/* le16_to_cpu */
3823cd1385SRemy Bohmer 
3923cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
4023cd1385SRemy Bohmer 
4123cd1385SRemy Bohmer /* CONTROL REQUEST SUPPORT */
4223cd1385SRemy Bohmer 
4323cd1385SRemy Bohmer /*
4423cd1385SRemy Bohmer  * USB directions
4523cd1385SRemy Bohmer  *
4623cd1385SRemy Bohmer  * This bit flag is used in endpoint descriptors' bEndpointAddress field.
4723cd1385SRemy Bohmer  * It's also one of three fields in control requests bRequestType.
4823cd1385SRemy Bohmer  */
4923cd1385SRemy Bohmer #define USB_DIR_OUT			0		/* to device */
5023cd1385SRemy Bohmer #define USB_DIR_IN			0x80		/* to host */
5123cd1385SRemy Bohmer 
5223cd1385SRemy Bohmer /*
5323cd1385SRemy Bohmer  * USB types, the second of three bRequestType fields
5423cd1385SRemy Bohmer  */
5523cd1385SRemy Bohmer #define USB_TYPE_MASK			(0x03 << 5)
5623cd1385SRemy Bohmer #define USB_TYPE_STANDARD		(0x00 << 5)
5723cd1385SRemy Bohmer #define USB_TYPE_CLASS			(0x01 << 5)
5823cd1385SRemy Bohmer #define USB_TYPE_VENDOR			(0x02 << 5)
5923cd1385SRemy Bohmer #define USB_TYPE_RESERVED		(0x03 << 5)
6023cd1385SRemy Bohmer 
6123cd1385SRemy Bohmer /*
6223cd1385SRemy Bohmer  * USB recipients, the third of three bRequestType fields
6323cd1385SRemy Bohmer  */
6423cd1385SRemy Bohmer #define USB_RECIP_MASK			0x1f
6523cd1385SRemy Bohmer #define USB_RECIP_DEVICE		0x00
6623cd1385SRemy Bohmer #define USB_RECIP_INTERFACE		0x01
6723cd1385SRemy Bohmer #define USB_RECIP_ENDPOINT		0x02
6823cd1385SRemy Bohmer #define USB_RECIP_OTHER			0x03
6923cd1385SRemy Bohmer /* From Wireless USB 1.0 */
7023cd1385SRemy Bohmer #define USB_RECIP_PORT			0x04
7123cd1385SRemy Bohmer #define USB_RECIP_RPIPE		0x05
7223cd1385SRemy Bohmer 
7323cd1385SRemy Bohmer /*
7423cd1385SRemy Bohmer  * Standard requests, for the bRequest field of a SETUP packet.
7523cd1385SRemy Bohmer  *
7623cd1385SRemy Bohmer  * These are qualified by the bRequestType field, so that for example
7723cd1385SRemy Bohmer  * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
7823cd1385SRemy Bohmer  * by a GET_STATUS request.
7923cd1385SRemy Bohmer  */
8023cd1385SRemy Bohmer #define USB_REQ_GET_STATUS		0x00
8123cd1385SRemy Bohmer #define USB_REQ_CLEAR_FEATURE		0x01
8223cd1385SRemy Bohmer #define USB_REQ_SET_FEATURE		0x03
8323cd1385SRemy Bohmer #define USB_REQ_SET_ADDRESS		0x05
8423cd1385SRemy Bohmer #define USB_REQ_GET_DESCRIPTOR		0x06
8523cd1385SRemy Bohmer #define USB_REQ_SET_DESCRIPTOR		0x07
8623cd1385SRemy Bohmer #define USB_REQ_GET_CONFIGURATION	0x08
8723cd1385SRemy Bohmer #define USB_REQ_SET_CONFIGURATION	0x09
8823cd1385SRemy Bohmer #define USB_REQ_GET_INTERFACE		0x0A
8923cd1385SRemy Bohmer #define USB_REQ_SET_INTERFACE		0x0B
9023cd1385SRemy Bohmer #define USB_REQ_SYNCH_FRAME		0x0C
91*82651c39SIlya Yanok #define USB_REQ_SET_SEL			0x30
92*82651c39SIlya Yanok #define USB_REQ_SET_ISOCH_DELAY		0x31
9323cd1385SRemy Bohmer 
9423cd1385SRemy Bohmer #define USB_REQ_SET_ENCRYPTION		0x0D	/* Wireless USB */
9523cd1385SRemy Bohmer #define USB_REQ_GET_ENCRYPTION		0x0E
9623cd1385SRemy Bohmer #define USB_REQ_RPIPE_ABORT		0x0E
9723cd1385SRemy Bohmer #define USB_REQ_SET_HANDSHAKE		0x0F
9823cd1385SRemy Bohmer #define USB_REQ_RPIPE_RESET		0x0F
9923cd1385SRemy Bohmer #define USB_REQ_GET_HANDSHAKE		0x10
10023cd1385SRemy Bohmer #define USB_REQ_SET_CONNECTION		0x11
10123cd1385SRemy Bohmer #define USB_REQ_SET_SECURITY_DATA	0x12
10223cd1385SRemy Bohmer #define USB_REQ_GET_SECURITY_DATA	0x13
10323cd1385SRemy Bohmer #define USB_REQ_SET_WUSB_DATA		0x14
10423cd1385SRemy Bohmer #define USB_REQ_LOOPBACK_DATA_WRITE	0x15
10523cd1385SRemy Bohmer #define USB_REQ_LOOPBACK_DATA_READ	0x16
10623cd1385SRemy Bohmer #define USB_REQ_SET_INTERFACE_DS	0x17
10723cd1385SRemy Bohmer 
108*82651c39SIlya Yanok /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
109*82651c39SIlya Yanok  * used by hubs to put ports into a new L1 suspend state, except that it
110*82651c39SIlya Yanok  * forgot to define its number ...
111*82651c39SIlya Yanok  */
112*82651c39SIlya Yanok 
11323cd1385SRemy Bohmer /*
11423cd1385SRemy Bohmer  * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
11523cd1385SRemy Bohmer  * are read as a bit array returned by USB_REQ_GET_STATUS.  (So there
116*82651c39SIlya Yanok  * are at most sixteen features of each type.)  Hubs may also support a
117*82651c39SIlya Yanok  * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
11823cd1385SRemy Bohmer  */
11923cd1385SRemy Bohmer #define USB_DEVICE_SELF_POWERED		0	/* (read only) */
12023cd1385SRemy Bohmer #define USB_DEVICE_REMOTE_WAKEUP	1	/* dev may initiate wakeup */
12123cd1385SRemy Bohmer #define USB_DEVICE_TEST_MODE		2	/* (wired high speed only) */
12223cd1385SRemy Bohmer #define USB_DEVICE_BATTERY		2	/* (wireless) */
12323cd1385SRemy Bohmer #define USB_DEVICE_B_HNP_ENABLE		3	/* (otg) dev may initiate HNP */
12423cd1385SRemy Bohmer #define USB_DEVICE_WUSB_DEVICE		3	/* (wireless)*/
12523cd1385SRemy Bohmer #define USB_DEVICE_A_HNP_SUPPORT	4	/* (otg) RH port supports HNP */
12623cd1385SRemy Bohmer #define USB_DEVICE_A_ALT_HNP_SUPPORT	5	/* (otg) other RH port does */
12723cd1385SRemy Bohmer #define USB_DEVICE_DEBUG_MODE		6	/* (special devices only) */
12823cd1385SRemy Bohmer 
129*82651c39SIlya Yanok /*
130*82651c39SIlya Yanok  * Test Mode Selectors
131*82651c39SIlya Yanok  * See USB 2.0 spec Table 9-7
132*82651c39SIlya Yanok  */
133*82651c39SIlya Yanok #define	TEST_J		1
134*82651c39SIlya Yanok #define	TEST_K		2
135*82651c39SIlya Yanok #define	TEST_SE0_NAK	3
136*82651c39SIlya Yanok #define	TEST_PACKET	4
137*82651c39SIlya Yanok #define	TEST_FORCE_EN	5
138*82651c39SIlya Yanok 
139*82651c39SIlya Yanok /*
140*82651c39SIlya Yanok  * New Feature Selectors as added by USB 3.0
141*82651c39SIlya Yanok  * See USB 3.0 spec Table 9-6
142*82651c39SIlya Yanok  */
143*82651c39SIlya Yanok #define USB_DEVICE_U1_ENABLE	48	/* dev may initiate U1 transition */
144*82651c39SIlya Yanok #define USB_DEVICE_U2_ENABLE	49	/* dev may initiate U2 transition */
145*82651c39SIlya Yanok #define USB_DEVICE_LTM_ENABLE	50	/* dev may send LTM */
146*82651c39SIlya Yanok #define USB_INTRF_FUNC_SUSPEND	0	/* function suspend */
147*82651c39SIlya Yanok 
148*82651c39SIlya Yanok #define USB_INTR_FUNC_SUSPEND_OPT_MASK	0xFF00
149*82651c39SIlya Yanok /*
150*82651c39SIlya Yanok  * Suspend Options, Table 9-7 USB 3.0 spec
151*82651c39SIlya Yanok  */
152*82651c39SIlya Yanok #define USB_INTRF_FUNC_SUSPEND_LP	(1 << (8 + 0))
153*82651c39SIlya Yanok #define USB_INTRF_FUNC_SUSPEND_RW	(1 << (8 + 1))
154*82651c39SIlya Yanok 
15523cd1385SRemy Bohmer #define USB_ENDPOINT_HALT		0	/* IN/OUT will STALL */
15623cd1385SRemy Bohmer 
157*82651c39SIlya Yanok /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
158*82651c39SIlya Yanok #define USB_DEV_STAT_U1_ENABLED		2	/* transition into U1 state */
159*82651c39SIlya Yanok #define USB_DEV_STAT_U2_ENABLED		3	/* transition into U2 state */
160*82651c39SIlya Yanok #define USB_DEV_STAT_LTM_ENABLED	4	/* Latency tolerance messages */
16123cd1385SRemy Bohmer 
16223cd1385SRemy Bohmer /**
16323cd1385SRemy Bohmer  * struct usb_ctrlrequest - SETUP data for a USB device control request
16423cd1385SRemy Bohmer  * @bRequestType: matches the USB bmRequestType field
16523cd1385SRemy Bohmer  * @bRequest: matches the USB bRequest field
16623cd1385SRemy Bohmer  * @wValue: matches the USB wValue field (le16 byte order)
16723cd1385SRemy Bohmer  * @wIndex: matches the USB wIndex field (le16 byte order)
16823cd1385SRemy Bohmer  * @wLength: matches the USB wLength field (le16 byte order)
16923cd1385SRemy Bohmer  *
17023cd1385SRemy Bohmer  * This structure is used to send control requests to a USB device.  It matches
17123cd1385SRemy Bohmer  * the different fields of the USB 2.0 Spec section 9.3, table 9-2.  See the
17223cd1385SRemy Bohmer  * USB spec for a fuller description of the different fields, and what they are
17323cd1385SRemy Bohmer  * used for.
17423cd1385SRemy Bohmer  *
17523cd1385SRemy Bohmer  * Note that the driver for any interface can issue control requests.
17623cd1385SRemy Bohmer  * For most devices, interfaces don't coordinate with each other, so
17723cd1385SRemy Bohmer  * such requests may be made at any time.
17823cd1385SRemy Bohmer  */
17923cd1385SRemy Bohmer struct usb_ctrlrequest {
18023cd1385SRemy Bohmer 	__u8 bRequestType;
18123cd1385SRemy Bohmer 	__u8 bRequest;
18223cd1385SRemy Bohmer 	__le16 wValue;
18323cd1385SRemy Bohmer 	__le16 wIndex;
18423cd1385SRemy Bohmer 	__le16 wLength;
18523cd1385SRemy Bohmer } __attribute__ ((packed));
18623cd1385SRemy Bohmer 
18723cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
18823cd1385SRemy Bohmer 
18923cd1385SRemy Bohmer /*
19023cd1385SRemy Bohmer  * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
19123cd1385SRemy Bohmer  * (rarely) accepted by SET_DESCRIPTOR.
19223cd1385SRemy Bohmer  *
19323cd1385SRemy Bohmer  * Note that all multi-byte values here are encoded in little endian
194*82651c39SIlya Yanok  * byte order "on the wire".  Within the kernel and when exposed
195*82651c39SIlya Yanok  * through the Linux-USB APIs, they are not converted to cpu byte
196*82651c39SIlya Yanok  * order; it is the responsibility of the client code to do this.
197*82651c39SIlya Yanok  * The single exception is when device and configuration descriptors (but
198*82651c39SIlya Yanok  * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
199*82651c39SIlya Yanok  * in this case the fields are converted to host endianness by the kernel.
20023cd1385SRemy Bohmer  */
20123cd1385SRemy Bohmer 
20223cd1385SRemy Bohmer /*
20323cd1385SRemy Bohmer  * Descriptor types ... USB 2.0 spec table 9.5
20423cd1385SRemy Bohmer  */
20523cd1385SRemy Bohmer #define USB_DT_DEVICE			0x01
20623cd1385SRemy Bohmer #define USB_DT_CONFIG			0x02
20723cd1385SRemy Bohmer #define USB_DT_STRING			0x03
20823cd1385SRemy Bohmer #define USB_DT_INTERFACE		0x04
20923cd1385SRemy Bohmer #define USB_DT_ENDPOINT			0x05
21023cd1385SRemy Bohmer #define USB_DT_DEVICE_QUALIFIER		0x06
21123cd1385SRemy Bohmer #define USB_DT_OTHER_SPEED_CONFIG	0x07
21223cd1385SRemy Bohmer #define USB_DT_INTERFACE_POWER		0x08
21323cd1385SRemy Bohmer /* these are from a minor usb 2.0 revision (ECN) */
21423cd1385SRemy Bohmer #define USB_DT_OTG			0x09
21523cd1385SRemy Bohmer #define USB_DT_DEBUG			0x0a
21623cd1385SRemy Bohmer #define USB_DT_INTERFACE_ASSOCIATION	0x0b
21723cd1385SRemy Bohmer /* these are from the Wireless USB spec */
21823cd1385SRemy Bohmer #define USB_DT_SECURITY			0x0c
21923cd1385SRemy Bohmer #define USB_DT_KEY			0x0d
22023cd1385SRemy Bohmer #define USB_DT_ENCRYPTION_TYPE		0x0e
22123cd1385SRemy Bohmer #define USB_DT_BOS			0x0f
22223cd1385SRemy Bohmer #define USB_DT_DEVICE_CAPABILITY	0x10
22323cd1385SRemy Bohmer #define USB_DT_WIRELESS_ENDPOINT_COMP	0x11
22423cd1385SRemy Bohmer #define USB_DT_WIRE_ADAPTER		0x21
22523cd1385SRemy Bohmer #define USB_DT_RPIPE			0x22
226*82651c39SIlya Yanok #define USB_DT_CS_RADIO_CONTROL		0x23
227*82651c39SIlya Yanok /* From the T10 UAS specification */
228*82651c39SIlya Yanok #define USB_DT_PIPE_USAGE		0x24
229*82651c39SIlya Yanok /* From the USB 3.0 spec */
230*82651c39SIlya Yanok #define	USB_DT_SS_ENDPOINT_COMP		0x30
23123cd1385SRemy Bohmer 
23223cd1385SRemy Bohmer /* Conventional codes for class-specific descriptors.  The convention is
23323cd1385SRemy Bohmer  * defined in the USB "Common Class" Spec (3.11).  Individual class specs
23423cd1385SRemy Bohmer  * are authoritative for their usage, not the "common class" writeup.
23523cd1385SRemy Bohmer  */
23623cd1385SRemy Bohmer #define USB_DT_CS_DEVICE		(USB_TYPE_CLASS | USB_DT_DEVICE)
23723cd1385SRemy Bohmer #define USB_DT_CS_CONFIG		(USB_TYPE_CLASS | USB_DT_CONFIG)
23823cd1385SRemy Bohmer #define USB_DT_CS_STRING		(USB_TYPE_CLASS | USB_DT_STRING)
23923cd1385SRemy Bohmer #define USB_DT_CS_INTERFACE		(USB_TYPE_CLASS | USB_DT_INTERFACE)
24023cd1385SRemy Bohmer #define USB_DT_CS_ENDPOINT		(USB_TYPE_CLASS | USB_DT_ENDPOINT)
24123cd1385SRemy Bohmer 
24223cd1385SRemy Bohmer /* All standard descriptors have these 2 fields at the beginning */
24323cd1385SRemy Bohmer struct usb_descriptor_header {
24423cd1385SRemy Bohmer 	__u8  bLength;
24523cd1385SRemy Bohmer 	__u8  bDescriptorType;
24623cd1385SRemy Bohmer } __attribute__ ((packed));
24723cd1385SRemy Bohmer 
248*82651c39SIlya Yanok 
249*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
250*82651c39SIlya Yanok 
251*82651c39SIlya Yanok /* USB_DT_DEVICE: Device descriptor */
252*82651c39SIlya Yanok struct usb_device_descriptor {
253*82651c39SIlya Yanok 	__u8  bLength;
254*82651c39SIlya Yanok 	__u8  bDescriptorType;
255*82651c39SIlya Yanok 
256*82651c39SIlya Yanok 	__le16 bcdUSB;
257*82651c39SIlya Yanok 	__u8  bDeviceClass;
258*82651c39SIlya Yanok 	__u8  bDeviceSubClass;
259*82651c39SIlya Yanok 	__u8  bDeviceProtocol;
260*82651c39SIlya Yanok 	__u8  bMaxPacketSize0;
261*82651c39SIlya Yanok 	__le16 idVendor;
262*82651c39SIlya Yanok 	__le16 idProduct;
263*82651c39SIlya Yanok 	__le16 bcdDevice;
264*82651c39SIlya Yanok 	__u8  iManufacturer;
265*82651c39SIlya Yanok 	__u8  iProduct;
266*82651c39SIlya Yanok 	__u8  iSerialNumber;
267*82651c39SIlya Yanok 	__u8  bNumConfigurations;
268*82651c39SIlya Yanok } __attribute__ ((packed));
269*82651c39SIlya Yanok 
27023cd1385SRemy Bohmer #define USB_DT_DEVICE_SIZE		18
27123cd1385SRemy Bohmer 
27223cd1385SRemy Bohmer 
27323cd1385SRemy Bohmer /*
27423cd1385SRemy Bohmer  * Device and/or Interface Class codes
27523cd1385SRemy Bohmer  * as found in bDeviceClass or bInterfaceClass
27623cd1385SRemy Bohmer  * and defined by www.usb.org documents
27723cd1385SRemy Bohmer  */
27823cd1385SRemy Bohmer #define USB_CLASS_PER_INTERFACE		0	/* for DeviceClass */
27923cd1385SRemy Bohmer #define USB_CLASS_AUDIO			1
28023cd1385SRemy Bohmer #define USB_CLASS_COMM			2
28123cd1385SRemy Bohmer #define USB_CLASS_HID			3
28223cd1385SRemy Bohmer #define USB_CLASS_PHYSICAL		5
28323cd1385SRemy Bohmer #define USB_CLASS_STILL_IMAGE		6
28423cd1385SRemy Bohmer #define USB_CLASS_PRINTER		7
28523cd1385SRemy Bohmer #define USB_CLASS_MASS_STORAGE		8
28623cd1385SRemy Bohmer #define USB_CLASS_HUB			9
28723cd1385SRemy Bohmer #define USB_CLASS_CDC_DATA		0x0a
28823cd1385SRemy Bohmer #define USB_CLASS_CSCID			0x0b	/* chip+ smart card */
28923cd1385SRemy Bohmer #define USB_CLASS_CONTENT_SEC		0x0d	/* content security */
29023cd1385SRemy Bohmer #define USB_CLASS_VIDEO			0x0e
29123cd1385SRemy Bohmer #define USB_CLASS_WIRELESS_CONTROLLER	0xe0
29223cd1385SRemy Bohmer #define USB_CLASS_MISC			0xef
29323cd1385SRemy Bohmer #define USB_CLASS_APP_SPEC		0xfe
29423cd1385SRemy Bohmer #define USB_CLASS_VENDOR_SPEC		0xff
29523cd1385SRemy Bohmer 
296*82651c39SIlya Yanok #define USB_SUBCLASS_VENDOR_SPEC	0xff
297*82651c39SIlya Yanok 
29823cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
29923cd1385SRemy Bohmer 
30023cd1385SRemy Bohmer /* USB_DT_CONFIG: Configuration descriptor information.
30123cd1385SRemy Bohmer  *
30223cd1385SRemy Bohmer  * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
30323cd1385SRemy Bohmer  * descriptor type is different.  Highspeed-capable devices can look
30423cd1385SRemy Bohmer  * different depending on what speed they're currently running.  Only
30523cd1385SRemy Bohmer  * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
30623cd1385SRemy Bohmer  * descriptors.
30723cd1385SRemy Bohmer  */
30823cd1385SRemy Bohmer struct usb_config_descriptor {
30923cd1385SRemy Bohmer 	__u8  bLength;
31023cd1385SRemy Bohmer 	__u8  bDescriptorType;
31123cd1385SRemy Bohmer 
31223cd1385SRemy Bohmer 	__le16 wTotalLength;
31323cd1385SRemy Bohmer 	__u8  bNumInterfaces;
31423cd1385SRemy Bohmer 	__u8  bConfigurationValue;
31523cd1385SRemy Bohmer 	__u8  iConfiguration;
31623cd1385SRemy Bohmer 	__u8  bmAttributes;
31723cd1385SRemy Bohmer 	__u8  bMaxPower;
31823cd1385SRemy Bohmer } __attribute__ ((packed));
31923cd1385SRemy Bohmer 
32023cd1385SRemy Bohmer #define USB_DT_CONFIG_SIZE		9
32123cd1385SRemy Bohmer 
32223cd1385SRemy Bohmer /* from config descriptor bmAttributes */
32323cd1385SRemy Bohmer #define USB_CONFIG_ATT_ONE		(1 << 7)	/* must be set */
32423cd1385SRemy Bohmer #define USB_CONFIG_ATT_SELFPOWER	(1 << 6)	/* self powered */
32523cd1385SRemy Bohmer #define USB_CONFIG_ATT_WAKEUP		(1 << 5)	/* can wakeup */
32623cd1385SRemy Bohmer #define USB_CONFIG_ATT_BATTERY		(1 << 4)	/* battery powered */
32723cd1385SRemy Bohmer 
328*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
329*82651c39SIlya Yanok 
330*82651c39SIlya Yanok /* USB_DT_STRING: String descriptor */
331*82651c39SIlya Yanok struct usb_string_descriptor {
332*82651c39SIlya Yanok 	__u8  bLength;
333*82651c39SIlya Yanok 	__u8  bDescriptorType;
334*82651c39SIlya Yanok 
335*82651c39SIlya Yanok 	__le16 wData[1];		/* UTF-16LE encoded */
336*82651c39SIlya Yanok } __attribute__ ((packed));
337*82651c39SIlya Yanok 
33823cd1385SRemy Bohmer /* note that "string" zero is special, it holds language codes that
33923cd1385SRemy Bohmer  * the device supports, not Unicode characters.
34023cd1385SRemy Bohmer  */
34123cd1385SRemy Bohmer 
342*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
343*82651c39SIlya Yanok 
344*82651c39SIlya Yanok /* USB_DT_INTERFACE: Interface descriptor */
345*82651c39SIlya Yanok struct usb_interface_descriptor {
346*82651c39SIlya Yanok 	__u8  bLength;
347*82651c39SIlya Yanok 	__u8  bDescriptorType;
348*82651c39SIlya Yanok 
349*82651c39SIlya Yanok 	__u8  bInterfaceNumber;
350*82651c39SIlya Yanok 	__u8  bAlternateSetting;
351*82651c39SIlya Yanok 	__u8  bNumEndpoints;
352*82651c39SIlya Yanok 	__u8  bInterfaceClass;
353*82651c39SIlya Yanok 	__u8  bInterfaceSubClass;
354*82651c39SIlya Yanok 	__u8  bInterfaceProtocol;
355*82651c39SIlya Yanok 	__u8  iInterface;
356*82651c39SIlya Yanok } __attribute__ ((packed));
357*82651c39SIlya Yanok 
35823cd1385SRemy Bohmer #define USB_DT_INTERFACE_SIZE		9
359*82651c39SIlya Yanok 
360*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
361*82651c39SIlya Yanok 
362*82651c39SIlya Yanok /* USB_DT_ENDPOINT: Endpoint descriptor */
363*82651c39SIlya Yanok struct usb_endpoint_descriptor {
364*82651c39SIlya Yanok 	__u8  bLength;
365*82651c39SIlya Yanok 	__u8  bDescriptorType;
366*82651c39SIlya Yanok 
367*82651c39SIlya Yanok 	__u8  bEndpointAddress;
368*82651c39SIlya Yanok 	__u8  bmAttributes;
369*82651c39SIlya Yanok 	__le16 wMaxPacketSize;
370*82651c39SIlya Yanok 	__u8  bInterval;
371*82651c39SIlya Yanok 
372*82651c39SIlya Yanok 	/* NOTE:  these two are _only_ in audio endpoints. */
373*82651c39SIlya Yanok 	/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
374*82651c39SIlya Yanok 	__u8  bRefresh;
375*82651c39SIlya Yanok 	__u8  bSynchAddress;
376*82651c39SIlya Yanok } __attribute__ ((packed));
377*82651c39SIlya Yanok 
37823cd1385SRemy Bohmer #define USB_DT_ENDPOINT_SIZE		7
37923cd1385SRemy Bohmer #define USB_DT_ENDPOINT_AUDIO_SIZE	9	/* Audio extension */
38023cd1385SRemy Bohmer 
38123cd1385SRemy Bohmer 
38223cd1385SRemy Bohmer /*
38323cd1385SRemy Bohmer  * Endpoints
38423cd1385SRemy Bohmer  */
38523cd1385SRemy Bohmer #define USB_ENDPOINT_NUMBER_MASK	0x0f	/* in bEndpointAddress */
38623cd1385SRemy Bohmer #define USB_ENDPOINT_DIR_MASK		0x80
38723cd1385SRemy Bohmer 
38823cd1385SRemy Bohmer #define USB_ENDPOINT_XFERTYPE_MASK	0x03	/* in bmAttributes */
38923cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_CONTROL	0
39023cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_ISOC		1
39123cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_BULK		2
39223cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_INT		3
39323cd1385SRemy Bohmer #define USB_ENDPOINT_MAX_ADJUSTABLE	0x80
39423cd1385SRemy Bohmer 
395*82651c39SIlya Yanok /* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
396*82651c39SIlya Yanok #define USB_ENDPOINT_INTRTYPE		0x30
397*82651c39SIlya Yanok #define USB_ENDPOINT_INTR_PERIODIC	(0 << 4)
398*82651c39SIlya Yanok #define USB_ENDPOINT_INTR_NOTIFICATION	(1 << 4)
399*82651c39SIlya Yanok 
400*82651c39SIlya Yanok #define USB_ENDPOINT_SYNCTYPE		0x0c
401*82651c39SIlya Yanok #define USB_ENDPOINT_SYNC_NONE		(0 << 2)
402*82651c39SIlya Yanok #define USB_ENDPOINT_SYNC_ASYNC		(1 << 2)
403*82651c39SIlya Yanok #define USB_ENDPOINT_SYNC_ADAPTIVE	(2 << 2)
404*82651c39SIlya Yanok #define USB_ENDPOINT_SYNC_SYNC		(3 << 2)
405*82651c39SIlya Yanok 
406*82651c39SIlya Yanok #define USB_ENDPOINT_USAGE_MASK		0x30
407*82651c39SIlya Yanok #define USB_ENDPOINT_USAGE_DATA		0x00
408*82651c39SIlya Yanok #define USB_ENDPOINT_USAGE_FEEDBACK	0x10
409*82651c39SIlya Yanok #define USB_ENDPOINT_USAGE_IMPLICIT_FB	0x20	/* Implicit feedback Data endpoint */
410*82651c39SIlya Yanok 
411*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
412*82651c39SIlya Yanok 
413*82651c39SIlya Yanok /**
414*82651c39SIlya Yanok  * usb_endpoint_num - get the endpoint's number
415*82651c39SIlya Yanok  * @epd: endpoint to be checked
416*82651c39SIlya Yanok  *
417*82651c39SIlya Yanok  * Returns @epd's number: 0 to 15.
418*82651c39SIlya Yanok  */
419*82651c39SIlya Yanok static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
420*82651c39SIlya Yanok {
421*82651c39SIlya Yanok 	return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
422*82651c39SIlya Yanok }
423*82651c39SIlya Yanok 
424*82651c39SIlya Yanok /**
425*82651c39SIlya Yanok  * usb_endpoint_type - get the endpoint's transfer type
426*82651c39SIlya Yanok  * @epd: endpoint to be checked
427*82651c39SIlya Yanok  *
428*82651c39SIlya Yanok  * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
429*82651c39SIlya Yanok  * to @epd's transfer type.
430*82651c39SIlya Yanok  */
431*82651c39SIlya Yanok static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
432*82651c39SIlya Yanok {
433*82651c39SIlya Yanok 	return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
434*82651c39SIlya Yanok }
435*82651c39SIlya Yanok 
436*82651c39SIlya Yanok /**
437*82651c39SIlya Yanok  * usb_endpoint_dir_in - check if the endpoint has IN direction
438*82651c39SIlya Yanok  * @epd: endpoint to be checked
439*82651c39SIlya Yanok  *
440*82651c39SIlya Yanok  * Returns true if the endpoint is of type IN, otherwise it returns false.
441*82651c39SIlya Yanok  */
442*82651c39SIlya Yanok static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
443*82651c39SIlya Yanok {
444*82651c39SIlya Yanok 	return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
445*82651c39SIlya Yanok }
446*82651c39SIlya Yanok 
447*82651c39SIlya Yanok /**
448*82651c39SIlya Yanok  * usb_endpoint_dir_out - check if the endpoint has OUT direction
449*82651c39SIlya Yanok  * @epd: endpoint to be checked
450*82651c39SIlya Yanok  *
451*82651c39SIlya Yanok  * Returns true if the endpoint is of type OUT, otherwise it returns false.
452*82651c39SIlya Yanok  */
453*82651c39SIlya Yanok static inline int usb_endpoint_dir_out(
454*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
455*82651c39SIlya Yanok {
456*82651c39SIlya Yanok 	return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
457*82651c39SIlya Yanok }
458*82651c39SIlya Yanok 
459*82651c39SIlya Yanok /**
460*82651c39SIlya Yanok  * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
461*82651c39SIlya Yanok  * @epd: endpoint to be checked
462*82651c39SIlya Yanok  *
463*82651c39SIlya Yanok  * Returns true if the endpoint is of type bulk, otherwise it returns false.
464*82651c39SIlya Yanok  */
465*82651c39SIlya Yanok static inline int usb_endpoint_xfer_bulk(
466*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
467*82651c39SIlya Yanok {
468*82651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
469*82651c39SIlya Yanok 		USB_ENDPOINT_XFER_BULK);
470*82651c39SIlya Yanok }
471*82651c39SIlya Yanok 
472*82651c39SIlya Yanok /**
473*82651c39SIlya Yanok  * usb_endpoint_xfer_control - check if the endpoint has control transfer type
474*82651c39SIlya Yanok  * @epd: endpoint to be checked
475*82651c39SIlya Yanok  *
476*82651c39SIlya Yanok  * Returns true if the endpoint is of type control, otherwise it returns false.
477*82651c39SIlya Yanok  */
478*82651c39SIlya Yanok static inline int usb_endpoint_xfer_control(
479*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
480*82651c39SIlya Yanok {
481*82651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
482*82651c39SIlya Yanok 		USB_ENDPOINT_XFER_CONTROL);
483*82651c39SIlya Yanok }
484*82651c39SIlya Yanok 
485*82651c39SIlya Yanok /**
486*82651c39SIlya Yanok  * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
487*82651c39SIlya Yanok  * @epd: endpoint to be checked
488*82651c39SIlya Yanok  *
489*82651c39SIlya Yanok  * Returns true if the endpoint is of type interrupt, otherwise it returns
490*82651c39SIlya Yanok  * false.
491*82651c39SIlya Yanok  */
492*82651c39SIlya Yanok static inline int usb_endpoint_xfer_int(
493*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
494*82651c39SIlya Yanok {
495*82651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
496*82651c39SIlya Yanok 		USB_ENDPOINT_XFER_INT);
497*82651c39SIlya Yanok }
498*82651c39SIlya Yanok 
499*82651c39SIlya Yanok /**
500*82651c39SIlya Yanok  * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
501*82651c39SIlya Yanok  * @epd: endpoint to be checked
502*82651c39SIlya Yanok  *
503*82651c39SIlya Yanok  * Returns true if the endpoint is of type isochronous, otherwise it returns
504*82651c39SIlya Yanok  * false.
505*82651c39SIlya Yanok  */
506*82651c39SIlya Yanok static inline int usb_endpoint_xfer_isoc(
507*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
508*82651c39SIlya Yanok {
509*82651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
510*82651c39SIlya Yanok 		USB_ENDPOINT_XFER_ISOC);
511*82651c39SIlya Yanok }
512*82651c39SIlya Yanok 
513*82651c39SIlya Yanok /**
514*82651c39SIlya Yanok  * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
515*82651c39SIlya Yanok  * @epd: endpoint to be checked
516*82651c39SIlya Yanok  *
517*82651c39SIlya Yanok  * Returns true if the endpoint has bulk transfer type and IN direction,
518*82651c39SIlya Yanok  * otherwise it returns false.
519*82651c39SIlya Yanok  */
520*82651c39SIlya Yanok static inline int usb_endpoint_is_bulk_in(
521*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
522*82651c39SIlya Yanok {
523*82651c39SIlya Yanok 	return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
524*82651c39SIlya Yanok }
525*82651c39SIlya Yanok 
526*82651c39SIlya Yanok /**
527*82651c39SIlya Yanok  * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
528*82651c39SIlya Yanok  * @epd: endpoint to be checked
529*82651c39SIlya Yanok  *
530*82651c39SIlya Yanok  * Returns true if the endpoint has bulk transfer type and OUT direction,
531*82651c39SIlya Yanok  * otherwise it returns false.
532*82651c39SIlya Yanok  */
533*82651c39SIlya Yanok static inline int usb_endpoint_is_bulk_out(
534*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
535*82651c39SIlya Yanok {
536*82651c39SIlya Yanok 	return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
537*82651c39SIlya Yanok }
538*82651c39SIlya Yanok 
539*82651c39SIlya Yanok /**
540*82651c39SIlya Yanok  * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
541*82651c39SIlya Yanok  * @epd: endpoint to be checked
542*82651c39SIlya Yanok  *
543*82651c39SIlya Yanok  * Returns true if the endpoint has interrupt transfer type and IN direction,
544*82651c39SIlya Yanok  * otherwise it returns false.
545*82651c39SIlya Yanok  */
546*82651c39SIlya Yanok static inline int usb_endpoint_is_int_in(
547*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
548*82651c39SIlya Yanok {
549*82651c39SIlya Yanok 	return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
550*82651c39SIlya Yanok }
551*82651c39SIlya Yanok 
552*82651c39SIlya Yanok /**
553*82651c39SIlya Yanok  * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
554*82651c39SIlya Yanok  * @epd: endpoint to be checked
555*82651c39SIlya Yanok  *
556*82651c39SIlya Yanok  * Returns true if the endpoint has interrupt transfer type and OUT direction,
557*82651c39SIlya Yanok  * otherwise it returns false.
558*82651c39SIlya Yanok  */
559*82651c39SIlya Yanok static inline int usb_endpoint_is_int_out(
560*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
561*82651c39SIlya Yanok {
562*82651c39SIlya Yanok 	return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
563*82651c39SIlya Yanok }
564*82651c39SIlya Yanok 
565*82651c39SIlya Yanok /**
566*82651c39SIlya Yanok  * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
567*82651c39SIlya Yanok  * @epd: endpoint to be checked
568*82651c39SIlya Yanok  *
569*82651c39SIlya Yanok  * Returns true if the endpoint has isochronous transfer type and IN direction,
570*82651c39SIlya Yanok  * otherwise it returns false.
571*82651c39SIlya Yanok  */
572*82651c39SIlya Yanok static inline int usb_endpoint_is_isoc_in(
573*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
574*82651c39SIlya Yanok {
575*82651c39SIlya Yanok 	return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
576*82651c39SIlya Yanok }
577*82651c39SIlya Yanok 
578*82651c39SIlya Yanok /**
579*82651c39SIlya Yanok  * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
580*82651c39SIlya Yanok  * @epd: endpoint to be checked
581*82651c39SIlya Yanok  *
582*82651c39SIlya Yanok  * Returns true if the endpoint has isochronous transfer type and OUT direction,
583*82651c39SIlya Yanok  * otherwise it returns false.
584*82651c39SIlya Yanok  */
585*82651c39SIlya Yanok static inline int usb_endpoint_is_isoc_out(
586*82651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
587*82651c39SIlya Yanok {
588*82651c39SIlya Yanok 	return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
589*82651c39SIlya Yanok }
590*82651c39SIlya Yanok 
591*82651c39SIlya Yanok /**
592*82651c39SIlya Yanok  * usb_endpoint_maxp - get endpoint's max packet size
593*82651c39SIlya Yanok  * @epd: endpoint to be checked
594*82651c39SIlya Yanok  *
595*82651c39SIlya Yanok  * Returns @epd's max packet
596*82651c39SIlya Yanok  */
597*82651c39SIlya Yanok static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
598*82651c39SIlya Yanok {
599*82651c39SIlya Yanok 	return __le16_to_cpu(epd->wMaxPacketSize);
600*82651c39SIlya Yanok }
601*82651c39SIlya Yanok 
602*82651c39SIlya Yanok static inline int usb_endpoint_interrupt_type(
603*82651c39SIlya Yanok 		const struct usb_endpoint_descriptor *epd)
604*82651c39SIlya Yanok {
605*82651c39SIlya Yanok 	return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
606*82651c39SIlya Yanok }
607*82651c39SIlya Yanok 
608*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
609*82651c39SIlya Yanok 
610*82651c39SIlya Yanok /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
611*82651c39SIlya Yanok struct usb_ss_ep_comp_descriptor {
612*82651c39SIlya Yanok 	__u8  bLength;
613*82651c39SIlya Yanok 	__u8  bDescriptorType;
614*82651c39SIlya Yanok 
615*82651c39SIlya Yanok 	__u8  bMaxBurst;
616*82651c39SIlya Yanok 	__u8  bmAttributes;
617*82651c39SIlya Yanok 	__le16 wBytesPerInterval;
618*82651c39SIlya Yanok } __attribute__ ((packed));
619*82651c39SIlya Yanok 
620*82651c39SIlya Yanok #define USB_DT_SS_EP_COMP_SIZE		6
621*82651c39SIlya Yanok 
622*82651c39SIlya Yanok /* Bits 4:0 of bmAttributes if this is a bulk endpoint */
623*82651c39SIlya Yanok static inline int
624*82651c39SIlya Yanok usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
625*82651c39SIlya Yanok {
626*82651c39SIlya Yanok 	int		max_streams;
627*82651c39SIlya Yanok 
628*82651c39SIlya Yanok 	if (!comp)
629*82651c39SIlya Yanok 		return 0;
630*82651c39SIlya Yanok 
631*82651c39SIlya Yanok 	max_streams = comp->bmAttributes & 0x1f;
632*82651c39SIlya Yanok 
633*82651c39SIlya Yanok 	if (!max_streams)
634*82651c39SIlya Yanok 		return 0;
635*82651c39SIlya Yanok 
636*82651c39SIlya Yanok 	max_streams = 1 << max_streams;
637*82651c39SIlya Yanok 
638*82651c39SIlya Yanok 	return max_streams;
639*82651c39SIlya Yanok }
640*82651c39SIlya Yanok 
641*82651c39SIlya Yanok /* Bits 1:0 of bmAttributes if this is an isoc endpoint */
642*82651c39SIlya Yanok #define USB_SS_MULT(p)			(1 + ((p) & 0x3))
64323cd1385SRemy Bohmer 
64423cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
64523cd1385SRemy Bohmer 
64623cd1385SRemy Bohmer /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
64723cd1385SRemy Bohmer struct usb_qualifier_descriptor {
64823cd1385SRemy Bohmer 	__u8  bLength;
64923cd1385SRemy Bohmer 	__u8  bDescriptorType;
65023cd1385SRemy Bohmer 
65123cd1385SRemy Bohmer 	__le16 bcdUSB;
65223cd1385SRemy Bohmer 	__u8  bDeviceClass;
65323cd1385SRemy Bohmer 	__u8  bDeviceSubClass;
65423cd1385SRemy Bohmer 	__u8  bDeviceProtocol;
65523cd1385SRemy Bohmer 	__u8  bMaxPacketSize0;
65623cd1385SRemy Bohmer 	__u8  bNumConfigurations;
65723cd1385SRemy Bohmer 	__u8  bRESERVED;
65823cd1385SRemy Bohmer } __attribute__ ((packed));
65923cd1385SRemy Bohmer 
66023cd1385SRemy Bohmer 
66123cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
66223cd1385SRemy Bohmer 
66323cd1385SRemy Bohmer /* USB_DT_OTG (from OTG 1.0a supplement) */
66423cd1385SRemy Bohmer struct usb_otg_descriptor {
66523cd1385SRemy Bohmer 	__u8  bLength;
66623cd1385SRemy Bohmer 	__u8  bDescriptorType;
66723cd1385SRemy Bohmer 
66823cd1385SRemy Bohmer 	__u8  bmAttributes;	/* support for HNP, SRP, etc */
66923cd1385SRemy Bohmer } __attribute__ ((packed));
67023cd1385SRemy Bohmer 
67123cd1385SRemy Bohmer /* from usb_otg_descriptor.bmAttributes */
67223cd1385SRemy Bohmer #define USB_OTG_SRP		(1 << 0)
67323cd1385SRemy Bohmer #define USB_OTG_HNP		(1 << 1)	/* swap host/device roles */
67423cd1385SRemy Bohmer 
67523cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
67623cd1385SRemy Bohmer 
67723cd1385SRemy Bohmer /* USB_DT_DEBUG:  for special highspeed devices, replacing serial console */
67823cd1385SRemy Bohmer struct usb_debug_descriptor {
67923cd1385SRemy Bohmer 	__u8  bLength;
68023cd1385SRemy Bohmer 	__u8  bDescriptorType;
68123cd1385SRemy Bohmer 
68223cd1385SRemy Bohmer 	/* bulk endpoints with 8 byte maxpacket */
68323cd1385SRemy Bohmer 	__u8  bDebugInEndpoint;
68423cd1385SRemy Bohmer 	__u8  bDebugOutEndpoint;
68523cd1385SRemy Bohmer } __attribute__((packed));
68623cd1385SRemy Bohmer 
68723cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
68823cd1385SRemy Bohmer 
68923cd1385SRemy Bohmer /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
69023cd1385SRemy Bohmer struct usb_interface_assoc_descriptor {
69123cd1385SRemy Bohmer 	__u8  bLength;
69223cd1385SRemy Bohmer 	__u8  bDescriptorType;
69323cd1385SRemy Bohmer 
69423cd1385SRemy Bohmer 	__u8  bFirstInterface;
69523cd1385SRemy Bohmer 	__u8  bInterfaceCount;
69623cd1385SRemy Bohmer 	__u8  bFunctionClass;
69723cd1385SRemy Bohmer 	__u8  bFunctionSubClass;
69823cd1385SRemy Bohmer 	__u8  bFunctionProtocol;
69923cd1385SRemy Bohmer 	__u8  iFunction;
70023cd1385SRemy Bohmer } __attribute__ ((packed));
70123cd1385SRemy Bohmer 
70223cd1385SRemy Bohmer 
70323cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
70423cd1385SRemy Bohmer 
70523cd1385SRemy Bohmer /* USB_DT_SECURITY:  group of wireless security descriptors, including
70623cd1385SRemy Bohmer  * encryption types available for setting up a CC/association.
70723cd1385SRemy Bohmer  */
70823cd1385SRemy Bohmer struct usb_security_descriptor {
70923cd1385SRemy Bohmer 	__u8  bLength;
71023cd1385SRemy Bohmer 	__u8  bDescriptorType;
71123cd1385SRemy Bohmer 
71223cd1385SRemy Bohmer 	__le16 wTotalLength;
71323cd1385SRemy Bohmer 	__u8  bNumEncryptionTypes;
71423cd1385SRemy Bohmer } __attribute__((packed));
71523cd1385SRemy Bohmer 
71623cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
71723cd1385SRemy Bohmer 
71823cd1385SRemy Bohmer /* USB_DT_KEY:  used with {GET,SET}_SECURITY_DATA; only public keys
71923cd1385SRemy Bohmer  * may be retrieved.
72023cd1385SRemy Bohmer  */
72123cd1385SRemy Bohmer struct usb_key_descriptor {
72223cd1385SRemy Bohmer 	__u8  bLength;
72323cd1385SRemy Bohmer 	__u8  bDescriptorType;
72423cd1385SRemy Bohmer 
72523cd1385SRemy Bohmer 	__u8  tTKID[3];
72623cd1385SRemy Bohmer 	__u8  bReserved;
72723cd1385SRemy Bohmer 	__u8  bKeyData[0];
72823cd1385SRemy Bohmer } __attribute__((packed));
72923cd1385SRemy Bohmer 
73023cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
73123cd1385SRemy Bohmer 
73223cd1385SRemy Bohmer /* USB_DT_ENCRYPTION_TYPE:  bundled in DT_SECURITY groups */
73323cd1385SRemy Bohmer struct usb_encryption_descriptor {
73423cd1385SRemy Bohmer 	__u8  bLength;
73523cd1385SRemy Bohmer 	__u8  bDescriptorType;
73623cd1385SRemy Bohmer 
73723cd1385SRemy Bohmer 	__u8  bEncryptionType;
73823cd1385SRemy Bohmer #define	USB_ENC_TYPE_UNSECURE		0
73923cd1385SRemy Bohmer #define	USB_ENC_TYPE_WIRED		1	/* non-wireless mode */
74023cd1385SRemy Bohmer #define	USB_ENC_TYPE_CCM_1		2	/* aes128/cbc session */
74123cd1385SRemy Bohmer #define	USB_ENC_TYPE_RSA_1		3	/* rsa3072/sha1 auth */
74223cd1385SRemy Bohmer 	__u8  bEncryptionValue;		/* use in SET_ENCRYPTION */
74323cd1385SRemy Bohmer 	__u8  bAuthKeyIndex;
74423cd1385SRemy Bohmer } __attribute__((packed));
74523cd1385SRemy Bohmer 
74623cd1385SRemy Bohmer 
74723cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
74823cd1385SRemy Bohmer 
749*82651c39SIlya Yanok /* USB_DT_BOS:  group of device-level capabilities */
75023cd1385SRemy Bohmer struct usb_bos_descriptor {
75123cd1385SRemy Bohmer 	__u8  bLength;
75223cd1385SRemy Bohmer 	__u8  bDescriptorType;
75323cd1385SRemy Bohmer 
75423cd1385SRemy Bohmer 	__le16 wTotalLength;
75523cd1385SRemy Bohmer 	__u8  bNumDeviceCaps;
75623cd1385SRemy Bohmer } __attribute__((packed));
75723cd1385SRemy Bohmer 
758*82651c39SIlya Yanok #define USB_DT_BOS_SIZE		5
75923cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
76023cd1385SRemy Bohmer 
76123cd1385SRemy Bohmer /* USB_DT_DEVICE_CAPABILITY:  grouped with BOS */
76223cd1385SRemy Bohmer struct usb_dev_cap_header {
76323cd1385SRemy Bohmer 	__u8  bLength;
76423cd1385SRemy Bohmer 	__u8  bDescriptorType;
76523cd1385SRemy Bohmer 	__u8  bDevCapabilityType;
76623cd1385SRemy Bohmer } __attribute__((packed));
76723cd1385SRemy Bohmer 
76823cd1385SRemy Bohmer #define	USB_CAP_TYPE_WIRELESS_USB	1
76923cd1385SRemy Bohmer 
77023cd1385SRemy Bohmer struct usb_wireless_cap_descriptor {	/* Ultra Wide Band */
77123cd1385SRemy Bohmer 	__u8  bLength;
77223cd1385SRemy Bohmer 	__u8  bDescriptorType;
77323cd1385SRemy Bohmer 	__u8  bDevCapabilityType;
77423cd1385SRemy Bohmer 
77523cd1385SRemy Bohmer 	__u8  bmAttributes;
77623cd1385SRemy Bohmer #define	USB_WIRELESS_P2P_DRD		(1 << 1)
77723cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_MASK	(3 << 2)
77823cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_SELF	(1 << 2)
77923cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_DIRECTED	(2 << 2)
78023cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_NONE	(3 << 2)
78123cd1385SRemy Bohmer 	__le16 wPHYRates;	/* bit rates, Mbps */
78223cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_53		(1 << 0)	/* always set */
78323cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_80		(1 << 1)
78423cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_107		(1 << 2)	/* always set */
78523cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_160		(1 << 3)
78623cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_200		(1 << 4)	/* always set */
78723cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_320		(1 << 5)
78823cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_400		(1 << 6)
78923cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_480		(1 << 7)
79023cd1385SRemy Bohmer 	__u8  bmTFITXPowerInfo;	/* TFI power levels */
79123cd1385SRemy Bohmer 	__u8  bmFFITXPowerInfo;	/* FFI power levels */
79223cd1385SRemy Bohmer 	__le16 bmBandGroup;
79323cd1385SRemy Bohmer 	__u8  bReserved;
79423cd1385SRemy Bohmer } __attribute__((packed));
79523cd1385SRemy Bohmer 
796*82651c39SIlya Yanok /* USB 2.0 Extension descriptor */
797*82651c39SIlya Yanok #define	USB_CAP_TYPE_EXT		2
798*82651c39SIlya Yanok 
799*82651c39SIlya Yanok struct usb_ext_cap_descriptor {		/* Link Power Management */
800*82651c39SIlya Yanok 	__u8  bLength;
801*82651c39SIlya Yanok 	__u8  bDescriptorType;
802*82651c39SIlya Yanok 	__u8  bDevCapabilityType;
803*82651c39SIlya Yanok 	__le32 bmAttributes;
804*82651c39SIlya Yanok #define USB_LPM_SUPPORT			(1 << 1)	/* supports LPM */
805*82651c39SIlya Yanok #define USB_BESL_SUPPORT		(1 << 2)	/* supports BESL */
806*82651c39SIlya Yanok #define USB_BESL_BASELINE_VALID		(1 << 3)	/* Baseline BESL valid*/
807*82651c39SIlya Yanok #define USB_BESL_DEEP_VALID		(1 << 4)	/* Deep BESL valid */
808*82651c39SIlya Yanok #define USB_GET_BESL_BASELINE(p)	(((p) & (0xf << 8)) >> 8)
809*82651c39SIlya Yanok #define USB_GET_BESL_DEEP(p)		(((p) & (0xf << 12)) >> 12)
810*82651c39SIlya Yanok } __attribute__((packed));
811*82651c39SIlya Yanok 
812*82651c39SIlya Yanok #define USB_DT_USB_EXT_CAP_SIZE	7
813*82651c39SIlya Yanok 
814*82651c39SIlya Yanok /*
815*82651c39SIlya Yanok  * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
816*82651c39SIlya Yanok  * specific device level capabilities
817*82651c39SIlya Yanok  */
818*82651c39SIlya Yanok #define		USB_SS_CAP_TYPE		3
819*82651c39SIlya Yanok struct usb_ss_cap_descriptor {		/* Link Power Management */
820*82651c39SIlya Yanok 	__u8  bLength;
821*82651c39SIlya Yanok 	__u8  bDescriptorType;
822*82651c39SIlya Yanok 	__u8  bDevCapabilityType;
823*82651c39SIlya Yanok 	__u8  bmAttributes;
824*82651c39SIlya Yanok #define USB_LTM_SUPPORT			(1 << 1) /* supports LTM */
825*82651c39SIlya Yanok 	__le16 wSpeedSupported;
826*82651c39SIlya Yanok #define USB_LOW_SPEED_OPERATION		(1)	 /* Low speed operation */
827*82651c39SIlya Yanok #define USB_FULL_SPEED_OPERATION	(1 << 1) /* Full speed operation */
828*82651c39SIlya Yanok #define USB_HIGH_SPEED_OPERATION	(1 << 2) /* High speed operation */
829*82651c39SIlya Yanok #define USB_5GBPS_OPERATION		(1 << 3) /* Operation at 5Gbps */
830*82651c39SIlya Yanok 	__u8  bFunctionalitySupport;
831*82651c39SIlya Yanok 	__u8  bU1devExitLat;
832*82651c39SIlya Yanok 	__le16 bU2DevExitLat;
833*82651c39SIlya Yanok } __attribute__((packed));
834*82651c39SIlya Yanok 
835*82651c39SIlya Yanok #define USB_DT_USB_SS_CAP_SIZE	10
836*82651c39SIlya Yanok 
837*82651c39SIlya Yanok /*
838*82651c39SIlya Yanok  * Container ID Capability descriptor: Defines the instance unique ID used to
839*82651c39SIlya Yanok  * identify the instance across all operating modes
840*82651c39SIlya Yanok  */
841*82651c39SIlya Yanok #define	CONTAINER_ID_TYPE	4
842*82651c39SIlya Yanok struct usb_ss_container_id_descriptor {
843*82651c39SIlya Yanok 	__u8  bLength;
844*82651c39SIlya Yanok 	__u8  bDescriptorType;
845*82651c39SIlya Yanok 	__u8  bDevCapabilityType;
846*82651c39SIlya Yanok 	__u8  bReserved;
847*82651c39SIlya Yanok 	__u8  ContainerID[16]; /* 128-bit number */
848*82651c39SIlya Yanok } __attribute__((packed));
849*82651c39SIlya Yanok 
850*82651c39SIlya Yanok #define USB_DT_USB_SS_CONTN_ID_SIZE	20
85123cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
85223cd1385SRemy Bohmer 
85323cd1385SRemy Bohmer /* USB_DT_WIRELESS_ENDPOINT_COMP:  companion descriptor associated with
85423cd1385SRemy Bohmer  * each endpoint descriptor for a wireless device
85523cd1385SRemy Bohmer  */
85623cd1385SRemy Bohmer struct usb_wireless_ep_comp_descriptor {
85723cd1385SRemy Bohmer 	__u8  bLength;
85823cd1385SRemy Bohmer 	__u8  bDescriptorType;
85923cd1385SRemy Bohmer 
86023cd1385SRemy Bohmer 	__u8  bMaxBurst;
86123cd1385SRemy Bohmer 	__u8  bMaxSequence;
86223cd1385SRemy Bohmer 	__le16 wMaxStreamDelay;
86323cd1385SRemy Bohmer 	__le16 wOverTheAirPacketSize;
86423cd1385SRemy Bohmer 	__u8  bOverTheAirInterval;
86523cd1385SRemy Bohmer 	__u8  bmCompAttributes;
86623cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_MASK	0x03	/* in bmCompAttributes */
86723cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_NO		0
86823cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_SWITCH	1
86923cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_SCALE	2
87023cd1385SRemy Bohmer } __attribute__((packed));
87123cd1385SRemy Bohmer 
87223cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
87323cd1385SRemy Bohmer 
87423cd1385SRemy Bohmer /* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
87523cd1385SRemy Bohmer  * host and a device for connection set up, mutual authentication, and
87623cd1385SRemy Bohmer  * exchanging short lived session keys.  The handshake depends on a CC.
87723cd1385SRemy Bohmer  */
87823cd1385SRemy Bohmer struct usb_handshake {
87923cd1385SRemy Bohmer 	__u8 bMessageNumber;
88023cd1385SRemy Bohmer 	__u8 bStatus;
88123cd1385SRemy Bohmer 	__u8 tTKID[3];
88223cd1385SRemy Bohmer 	__u8 bReserved;
88323cd1385SRemy Bohmer 	__u8 CDID[16];
88423cd1385SRemy Bohmer 	__u8 nonce[16];
88523cd1385SRemy Bohmer 	__u8 MIC[8];
88623cd1385SRemy Bohmer } __attribute__((packed));
88723cd1385SRemy Bohmer 
88823cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
88923cd1385SRemy Bohmer 
89023cd1385SRemy Bohmer /* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
89123cd1385SRemy Bohmer  * A CC may also be set up using non-wireless secure channels (including
89223cd1385SRemy Bohmer  * wired USB!), and some devices may support CCs with multiple hosts.
89323cd1385SRemy Bohmer  */
89423cd1385SRemy Bohmer struct usb_connection_context {
89523cd1385SRemy Bohmer 	__u8 CHID[16];		/* persistent host id */
89623cd1385SRemy Bohmer 	__u8 CDID[16];		/* device id (unique w/in host context) */
89723cd1385SRemy Bohmer 	__u8 CK[16];		/* connection key */
89823cd1385SRemy Bohmer } __attribute__((packed));
89923cd1385SRemy Bohmer 
90023cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
90123cd1385SRemy Bohmer 
90223cd1385SRemy Bohmer /* USB 2.0 defines three speeds, here's how Linux identifies them */
90323cd1385SRemy Bohmer 
90423cd1385SRemy Bohmer enum usb_device_speed {
90523cd1385SRemy Bohmer 	USB_SPEED_UNKNOWN = 0,			/* enumerating */
90623cd1385SRemy Bohmer 	USB_SPEED_LOW, USB_SPEED_FULL,		/* usb 1.1 */
90723cd1385SRemy Bohmer 	USB_SPEED_HIGH,				/* usb 2.0 */
908*82651c39SIlya Yanok 	USB_SPEED_WIRELESS,			/* wireless (usb 2.5) */
909*82651c39SIlya Yanok 	USB_SPEED_SUPER,			/* usb 3.0 */
91023cd1385SRemy Bohmer };
91123cd1385SRemy Bohmer 
912*82651c39SIlya Yanok #ifdef __KERNEL__
913*82651c39SIlya Yanok 
914*82651c39SIlya Yanok /**
915*82651c39SIlya Yanok  * usb_speed_string() - Returns human readable-name of the speed.
916*82651c39SIlya Yanok  * @speed: The speed to return human-readable name for.  If it's not
917*82651c39SIlya Yanok  *   any of the speeds defined in usb_device_speed enum, string for
918*82651c39SIlya Yanok  *   USB_SPEED_UNKNOWN will be returned.
919*82651c39SIlya Yanok  */
920*82651c39SIlya Yanok extern const char *usb_speed_string(enum usb_device_speed speed);
921*82651c39SIlya Yanok 
922*82651c39SIlya Yanok #endif
923*82651c39SIlya Yanok 
92423cd1385SRemy Bohmer enum usb_device_state {
92523cd1385SRemy Bohmer 	/* NOTATTACHED isn't in the USB spec, and this state acts
92623cd1385SRemy Bohmer 	 * the same as ATTACHED ... but it's clearer this way.
92723cd1385SRemy Bohmer 	 */
92823cd1385SRemy Bohmer 	USB_STATE_NOTATTACHED = 0,
92923cd1385SRemy Bohmer 
93023cd1385SRemy Bohmer 	/* chapter 9 and authentication (wireless) device states */
93123cd1385SRemy Bohmer 	USB_STATE_ATTACHED,
93223cd1385SRemy Bohmer 	USB_STATE_POWERED,			/* wired */
93323cd1385SRemy Bohmer 	USB_STATE_RECONNECTING,			/* auth */
934*82651c39SIlya Yanok 	USB_STATE_UNAUTHENTICATED,		/* auth */
93523cd1385SRemy Bohmer 	USB_STATE_DEFAULT,			/* limited function */
93623cd1385SRemy Bohmer 	USB_STATE_ADDRESS,
93723cd1385SRemy Bohmer 	USB_STATE_CONFIGURED,			/* most functions */
93823cd1385SRemy Bohmer 
93923cd1385SRemy Bohmer 	USB_STATE_SUSPENDED
94023cd1385SRemy Bohmer 
94123cd1385SRemy Bohmer 	/* NOTE:  there are actually four different SUSPENDED
94223cd1385SRemy Bohmer 	 * states, returning to POWERED, DEFAULT, ADDRESS, or
94323cd1385SRemy Bohmer 	 * CONFIGURED respectively when SOF tokens flow again.
944*82651c39SIlya Yanok 	 * At this level there's no difference between L1 and L2
945*82651c39SIlya Yanok 	 * suspend states.  (L2 being original USB 1.1 suspend.)
94623cd1385SRemy Bohmer 	 */
94723cd1385SRemy Bohmer };
94823cd1385SRemy Bohmer 
949*82651c39SIlya Yanok enum usb3_link_state {
950*82651c39SIlya Yanok 	USB3_LPM_U0 = 0,
951*82651c39SIlya Yanok 	USB3_LPM_U1,
952*82651c39SIlya Yanok 	USB3_LPM_U2,
953*82651c39SIlya Yanok 	USB3_LPM_U3
954*82651c39SIlya Yanok };
955*82651c39SIlya Yanok 
956*82651c39SIlya Yanok /*
957*82651c39SIlya Yanok  * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
958*82651c39SIlya Yanok  * 0xff means the parent hub will accept transitions to U1, but will not
959*82651c39SIlya Yanok  * initiate a transition.
960*82651c39SIlya Yanok  *
961*82651c39SIlya Yanok  * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
962*82651c39SIlya Yanok  * U1 after that many microseconds.  Timeouts of 0x80 to 0xFE are reserved
963*82651c39SIlya Yanok  * values.
964*82651c39SIlya Yanok  *
965*82651c39SIlya Yanok  * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
966*82651c39SIlya Yanok  * 0xff means the parent hub will accept transitions to U2, but will not
967*82651c39SIlya Yanok  * initiate a transition.
968*82651c39SIlya Yanok  *
969*82651c39SIlya Yanok  * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
970*82651c39SIlya Yanok  * U2 after N*256 microseconds.  Therefore a U2 timeout value of 0x1 means a U2
971*82651c39SIlya Yanok  * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
972*82651c39SIlya Yanok  * 65.024ms.
973*82651c39SIlya Yanok  */
974*82651c39SIlya Yanok #define USB3_LPM_DISABLED		0x0
975*82651c39SIlya Yanok #define USB3_LPM_U1_MAX_TIMEOUT		0x7F
976*82651c39SIlya Yanok #define USB3_LPM_U2_MAX_TIMEOUT		0xFE
977*82651c39SIlya Yanok #define USB3_LPM_DEVICE_INITIATED	0xFF
978*82651c39SIlya Yanok 
979*82651c39SIlya Yanok struct usb_set_sel_req {
980*82651c39SIlya Yanok 	__u8	u1_sel;
981*82651c39SIlya Yanok 	__u8	u1_pel;
982*82651c39SIlya Yanok 	__le16	u2_sel;
983*82651c39SIlya Yanok 	__le16	u2_pel;
984*82651c39SIlya Yanok } __attribute__ ((packed));
985*82651c39SIlya Yanok 
986*82651c39SIlya Yanok /*
987*82651c39SIlya Yanok  * The Set System Exit Latency control transfer provides one byte each for
988*82651c39SIlya Yanok  * U1 SEL and U1 PEL, so the max exit latency is 0xFF.  U2 SEL and U2 PEL each
989*82651c39SIlya Yanok  * are two bytes long.
990*82651c39SIlya Yanok  */
991*82651c39SIlya Yanok #define USB3_LPM_MAX_U1_SEL_PEL		0xFF
992*82651c39SIlya Yanok #define USB3_LPM_MAX_U2_SEL_PEL		0xFFFF
993*82651c39SIlya Yanok 
994*82651c39SIlya Yanok /*-------------------------------------------------------------------------*/
995*82651c39SIlya Yanok 
996*82651c39SIlya Yanok /*
997*82651c39SIlya Yanok  * As per USB compliance update, a device that is actively drawing
998*82651c39SIlya Yanok  * more than 100mA from USB must report itself as bus-powered in
999*82651c39SIlya Yanok  * the GetStatus(DEVICE) call.
1000*82651c39SIlya Yanok  * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
1001*82651c39SIlya Yanok  */
1002*82651c39SIlya Yanok #define USB_SELF_POWER_VBUS_MAX_DRAW		100
1003*82651c39SIlya Yanok 
100423cd1385SRemy Bohmer #endif /* __LINUX_USB_CH9_H */
1005