xref: /openbmc/u-boot/include/linux/usb/ch9.h (revision d8a26f03)
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 */
3782651c39SIlya Yanok #include <asm/byteorder.h>	/* le16_to_cpu */
38f903a20dSVivek Gautam #include <asm/unaligned.h>	/* get_unaligned() */
3923cd1385SRemy Bohmer 
4023cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
4123cd1385SRemy Bohmer 
4223cd1385SRemy Bohmer /* CONTROL REQUEST SUPPORT */
4323cd1385SRemy Bohmer 
4423cd1385SRemy Bohmer /*
4523cd1385SRemy Bohmer  * USB directions
4623cd1385SRemy Bohmer  *
4723cd1385SRemy Bohmer  * This bit flag is used in endpoint descriptors' bEndpointAddress field.
4823cd1385SRemy Bohmer  * It's also one of three fields in control requests bRequestType.
4923cd1385SRemy Bohmer  */
5023cd1385SRemy Bohmer #define USB_DIR_OUT			0		/* to device */
5123cd1385SRemy Bohmer #define USB_DIR_IN			0x80		/* to host */
5223cd1385SRemy Bohmer 
5323cd1385SRemy Bohmer /*
5423cd1385SRemy Bohmer  * USB types, the second of three bRequestType fields
5523cd1385SRemy Bohmer  */
5623cd1385SRemy Bohmer #define USB_TYPE_MASK			(0x03 << 5)
5723cd1385SRemy Bohmer #define USB_TYPE_STANDARD		(0x00 << 5)
5823cd1385SRemy Bohmer #define USB_TYPE_CLASS			(0x01 << 5)
5923cd1385SRemy Bohmer #define USB_TYPE_VENDOR			(0x02 << 5)
6023cd1385SRemy Bohmer #define USB_TYPE_RESERVED		(0x03 << 5)
6123cd1385SRemy Bohmer 
6223cd1385SRemy Bohmer /*
6323cd1385SRemy Bohmer  * USB recipients, the third of three bRequestType fields
6423cd1385SRemy Bohmer  */
6523cd1385SRemy Bohmer #define USB_RECIP_MASK			0x1f
6623cd1385SRemy Bohmer #define USB_RECIP_DEVICE		0x00
6723cd1385SRemy Bohmer #define USB_RECIP_INTERFACE		0x01
6823cd1385SRemy Bohmer #define USB_RECIP_ENDPOINT		0x02
6923cd1385SRemy Bohmer #define USB_RECIP_OTHER			0x03
7023cd1385SRemy Bohmer /* From Wireless USB 1.0 */
7123cd1385SRemy Bohmer #define USB_RECIP_PORT			0x04
7223cd1385SRemy Bohmer #define USB_RECIP_RPIPE		0x05
7323cd1385SRemy Bohmer 
7423cd1385SRemy Bohmer /*
7523cd1385SRemy Bohmer  * Standard requests, for the bRequest field of a SETUP packet.
7623cd1385SRemy Bohmer  *
7723cd1385SRemy Bohmer  * These are qualified by the bRequestType field, so that for example
7823cd1385SRemy Bohmer  * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
7923cd1385SRemy Bohmer  * by a GET_STATUS request.
8023cd1385SRemy Bohmer  */
8123cd1385SRemy Bohmer #define USB_REQ_GET_STATUS		0x00
8223cd1385SRemy Bohmer #define USB_REQ_CLEAR_FEATURE		0x01
8323cd1385SRemy Bohmer #define USB_REQ_SET_FEATURE		0x03
8423cd1385SRemy Bohmer #define USB_REQ_SET_ADDRESS		0x05
8523cd1385SRemy Bohmer #define USB_REQ_GET_DESCRIPTOR		0x06
8623cd1385SRemy Bohmer #define USB_REQ_SET_DESCRIPTOR		0x07
8723cd1385SRemy Bohmer #define USB_REQ_GET_CONFIGURATION	0x08
8823cd1385SRemy Bohmer #define USB_REQ_SET_CONFIGURATION	0x09
8923cd1385SRemy Bohmer #define USB_REQ_GET_INTERFACE		0x0A
9023cd1385SRemy Bohmer #define USB_REQ_SET_INTERFACE		0x0B
9123cd1385SRemy Bohmer #define USB_REQ_SYNCH_FRAME		0x0C
9282651c39SIlya Yanok #define USB_REQ_SET_SEL			0x30
9382651c39SIlya Yanok #define USB_REQ_SET_ISOCH_DELAY		0x31
9423cd1385SRemy Bohmer 
9523cd1385SRemy Bohmer #define USB_REQ_SET_ENCRYPTION		0x0D	/* Wireless USB */
9623cd1385SRemy Bohmer #define USB_REQ_GET_ENCRYPTION		0x0E
9723cd1385SRemy Bohmer #define USB_REQ_RPIPE_ABORT		0x0E
9823cd1385SRemy Bohmer #define USB_REQ_SET_HANDSHAKE		0x0F
9923cd1385SRemy Bohmer #define USB_REQ_RPIPE_RESET		0x0F
10023cd1385SRemy Bohmer #define USB_REQ_GET_HANDSHAKE		0x10
10123cd1385SRemy Bohmer #define USB_REQ_SET_CONNECTION		0x11
10223cd1385SRemy Bohmer #define USB_REQ_SET_SECURITY_DATA	0x12
10323cd1385SRemy Bohmer #define USB_REQ_GET_SECURITY_DATA	0x13
10423cd1385SRemy Bohmer #define USB_REQ_SET_WUSB_DATA		0x14
10523cd1385SRemy Bohmer #define USB_REQ_LOOPBACK_DATA_WRITE	0x15
10623cd1385SRemy Bohmer #define USB_REQ_LOOPBACK_DATA_READ	0x16
10723cd1385SRemy Bohmer #define USB_REQ_SET_INTERFACE_DS	0x17
10823cd1385SRemy Bohmer 
10982651c39SIlya Yanok /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
11082651c39SIlya Yanok  * used by hubs to put ports into a new L1 suspend state, except that it
11182651c39SIlya Yanok  * forgot to define its number ...
11282651c39SIlya Yanok  */
11382651c39SIlya Yanok 
11423cd1385SRemy Bohmer /*
11523cd1385SRemy Bohmer  * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
11623cd1385SRemy Bohmer  * are read as a bit array returned by USB_REQ_GET_STATUS.  (So there
11782651c39SIlya Yanok  * are at most sixteen features of each type.)  Hubs may also support a
11882651c39SIlya Yanok  * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
11923cd1385SRemy Bohmer  */
12023cd1385SRemy Bohmer #define USB_DEVICE_SELF_POWERED		0	/* (read only) */
12123cd1385SRemy Bohmer #define USB_DEVICE_REMOTE_WAKEUP	1	/* dev may initiate wakeup */
12223cd1385SRemy Bohmer #define USB_DEVICE_TEST_MODE		2	/* (wired high speed only) */
12323cd1385SRemy Bohmer #define USB_DEVICE_BATTERY		2	/* (wireless) */
12423cd1385SRemy Bohmer #define USB_DEVICE_B_HNP_ENABLE		3	/* (otg) dev may initiate HNP */
12523cd1385SRemy Bohmer #define USB_DEVICE_WUSB_DEVICE		3	/* (wireless)*/
12623cd1385SRemy Bohmer #define USB_DEVICE_A_HNP_SUPPORT	4	/* (otg) RH port supports HNP */
12723cd1385SRemy Bohmer #define USB_DEVICE_A_ALT_HNP_SUPPORT	5	/* (otg) other RH port does */
12823cd1385SRemy Bohmer #define USB_DEVICE_DEBUG_MODE		6	/* (special devices only) */
12923cd1385SRemy Bohmer 
13082651c39SIlya Yanok /*
13182651c39SIlya Yanok  * Test Mode Selectors
13282651c39SIlya Yanok  * See USB 2.0 spec Table 9-7
13382651c39SIlya Yanok  */
13482651c39SIlya Yanok #define	TEST_J		1
13582651c39SIlya Yanok #define	TEST_K		2
13682651c39SIlya Yanok #define	TEST_SE0_NAK	3
13782651c39SIlya Yanok #define	TEST_PACKET	4
13882651c39SIlya Yanok #define	TEST_FORCE_EN	5
13982651c39SIlya Yanok 
14082651c39SIlya Yanok /*
14182651c39SIlya Yanok  * New Feature Selectors as added by USB 3.0
14282651c39SIlya Yanok  * See USB 3.0 spec Table 9-6
14382651c39SIlya Yanok  */
14482651c39SIlya Yanok #define USB_DEVICE_U1_ENABLE	48	/* dev may initiate U1 transition */
14582651c39SIlya Yanok #define USB_DEVICE_U2_ENABLE	49	/* dev may initiate U2 transition */
14682651c39SIlya Yanok #define USB_DEVICE_LTM_ENABLE	50	/* dev may send LTM */
14782651c39SIlya Yanok #define USB_INTRF_FUNC_SUSPEND	0	/* function suspend */
14882651c39SIlya Yanok 
14982651c39SIlya Yanok #define USB_INTR_FUNC_SUSPEND_OPT_MASK	0xFF00
15082651c39SIlya Yanok /*
15182651c39SIlya Yanok  * Suspend Options, Table 9-7 USB 3.0 spec
15282651c39SIlya Yanok  */
15382651c39SIlya Yanok #define USB_INTRF_FUNC_SUSPEND_LP	(1 << (8 + 0))
15482651c39SIlya Yanok #define USB_INTRF_FUNC_SUSPEND_RW	(1 << (8 + 1))
15582651c39SIlya Yanok 
15623cd1385SRemy Bohmer #define USB_ENDPOINT_HALT		0	/* IN/OUT will STALL */
15723cd1385SRemy Bohmer 
15882651c39SIlya Yanok /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
15982651c39SIlya Yanok #define USB_DEV_STAT_U1_ENABLED		2	/* transition into U1 state */
16082651c39SIlya Yanok #define USB_DEV_STAT_U2_ENABLED		3	/* transition into U2 state */
16182651c39SIlya Yanok #define USB_DEV_STAT_LTM_ENABLED	4	/* Latency tolerance messages */
16223cd1385SRemy Bohmer 
16323cd1385SRemy Bohmer /**
16423cd1385SRemy Bohmer  * struct usb_ctrlrequest - SETUP data for a USB device control request
16523cd1385SRemy Bohmer  * @bRequestType: matches the USB bmRequestType field
16623cd1385SRemy Bohmer  * @bRequest: matches the USB bRequest field
16723cd1385SRemy Bohmer  * @wValue: matches the USB wValue field (le16 byte order)
16823cd1385SRemy Bohmer  * @wIndex: matches the USB wIndex field (le16 byte order)
16923cd1385SRemy Bohmer  * @wLength: matches the USB wLength field (le16 byte order)
17023cd1385SRemy Bohmer  *
17123cd1385SRemy Bohmer  * This structure is used to send control requests to a USB device.  It matches
17223cd1385SRemy Bohmer  * the different fields of the USB 2.0 Spec section 9.3, table 9-2.  See the
17323cd1385SRemy Bohmer  * USB spec for a fuller description of the different fields, and what they are
17423cd1385SRemy Bohmer  * used for.
17523cd1385SRemy Bohmer  *
17623cd1385SRemy Bohmer  * Note that the driver for any interface can issue control requests.
17723cd1385SRemy Bohmer  * For most devices, interfaces don't coordinate with each other, so
17823cd1385SRemy Bohmer  * such requests may be made at any time.
17923cd1385SRemy Bohmer  */
18023cd1385SRemy Bohmer struct usb_ctrlrequest {
18123cd1385SRemy Bohmer 	__u8 bRequestType;
18223cd1385SRemy Bohmer 	__u8 bRequest;
18323cd1385SRemy Bohmer 	__le16 wValue;
18423cd1385SRemy Bohmer 	__le16 wIndex;
18523cd1385SRemy Bohmer 	__le16 wLength;
18623cd1385SRemy Bohmer } __attribute__ ((packed));
18723cd1385SRemy Bohmer 
18823cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
18923cd1385SRemy Bohmer 
19023cd1385SRemy Bohmer /*
19123cd1385SRemy Bohmer  * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
19223cd1385SRemy Bohmer  * (rarely) accepted by SET_DESCRIPTOR.
19323cd1385SRemy Bohmer  *
19423cd1385SRemy Bohmer  * Note that all multi-byte values here are encoded in little endian
19582651c39SIlya Yanok  * byte order "on the wire".  Within the kernel and when exposed
19682651c39SIlya Yanok  * through the Linux-USB APIs, they are not converted to cpu byte
19782651c39SIlya Yanok  * order; it is the responsibility of the client code to do this.
19882651c39SIlya Yanok  * The single exception is when device and configuration descriptors (but
19982651c39SIlya Yanok  * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
20082651c39SIlya Yanok  * in this case the fields are converted to host endianness by the kernel.
20123cd1385SRemy Bohmer  */
20223cd1385SRemy Bohmer 
20323cd1385SRemy Bohmer /*
20423cd1385SRemy Bohmer  * Descriptor types ... USB 2.0 spec table 9.5
20523cd1385SRemy Bohmer  */
20623cd1385SRemy Bohmer #define USB_DT_DEVICE			0x01
20723cd1385SRemy Bohmer #define USB_DT_CONFIG			0x02
20823cd1385SRemy Bohmer #define USB_DT_STRING			0x03
20923cd1385SRemy Bohmer #define USB_DT_INTERFACE		0x04
21023cd1385SRemy Bohmer #define USB_DT_ENDPOINT			0x05
21123cd1385SRemy Bohmer #define USB_DT_DEVICE_QUALIFIER		0x06
21223cd1385SRemy Bohmer #define USB_DT_OTHER_SPEED_CONFIG	0x07
21323cd1385SRemy Bohmer #define USB_DT_INTERFACE_POWER		0x08
21423cd1385SRemy Bohmer /* these are from a minor usb 2.0 revision (ECN) */
21523cd1385SRemy Bohmer #define USB_DT_OTG			0x09
21623cd1385SRemy Bohmer #define USB_DT_DEBUG			0x0a
21723cd1385SRemy Bohmer #define USB_DT_INTERFACE_ASSOCIATION	0x0b
21823cd1385SRemy Bohmer /* these are from the Wireless USB spec */
21923cd1385SRemy Bohmer #define USB_DT_SECURITY			0x0c
22023cd1385SRemy Bohmer #define USB_DT_KEY			0x0d
22123cd1385SRemy Bohmer #define USB_DT_ENCRYPTION_TYPE		0x0e
22223cd1385SRemy Bohmer #define USB_DT_BOS			0x0f
22323cd1385SRemy Bohmer #define USB_DT_DEVICE_CAPABILITY	0x10
22423cd1385SRemy Bohmer #define USB_DT_WIRELESS_ENDPOINT_COMP	0x11
22523cd1385SRemy Bohmer #define USB_DT_WIRE_ADAPTER		0x21
22623cd1385SRemy Bohmer #define USB_DT_RPIPE			0x22
22782651c39SIlya Yanok #define USB_DT_CS_RADIO_CONTROL		0x23
22882651c39SIlya Yanok /* From the T10 UAS specification */
22982651c39SIlya Yanok #define USB_DT_PIPE_USAGE		0x24
23082651c39SIlya Yanok /* From the USB 3.0 spec */
23182651c39SIlya Yanok #define	USB_DT_SS_ENDPOINT_COMP		0x30
232*d8a26f03SSimon Glass /* From HID 1.11 spec */
233*d8a26f03SSimon Glass #define USB_DT_HID_REPORT		0x22
23423cd1385SRemy Bohmer 
23523cd1385SRemy Bohmer /* Conventional codes for class-specific descriptors.  The convention is
23623cd1385SRemy Bohmer  * defined in the USB "Common Class" Spec (3.11).  Individual class specs
23723cd1385SRemy Bohmer  * are authoritative for their usage, not the "common class" writeup.
23823cd1385SRemy Bohmer  */
23923cd1385SRemy Bohmer #define USB_DT_CS_DEVICE		(USB_TYPE_CLASS | USB_DT_DEVICE)
24023cd1385SRemy Bohmer #define USB_DT_CS_CONFIG		(USB_TYPE_CLASS | USB_DT_CONFIG)
24123cd1385SRemy Bohmer #define USB_DT_CS_STRING		(USB_TYPE_CLASS | USB_DT_STRING)
24223cd1385SRemy Bohmer #define USB_DT_CS_INTERFACE		(USB_TYPE_CLASS | USB_DT_INTERFACE)
24323cd1385SRemy Bohmer #define USB_DT_CS_ENDPOINT		(USB_TYPE_CLASS | USB_DT_ENDPOINT)
24423cd1385SRemy Bohmer 
24523cd1385SRemy Bohmer /* All standard descriptors have these 2 fields at the beginning */
24623cd1385SRemy Bohmer struct usb_descriptor_header {
24723cd1385SRemy Bohmer 	__u8  bLength;
24823cd1385SRemy Bohmer 	__u8  bDescriptorType;
24923cd1385SRemy Bohmer } __attribute__ ((packed));
25023cd1385SRemy Bohmer 
25182651c39SIlya Yanok 
25282651c39SIlya Yanok /*-------------------------------------------------------------------------*/
25382651c39SIlya Yanok 
25482651c39SIlya Yanok /* USB_DT_DEVICE: Device descriptor */
25582651c39SIlya Yanok struct usb_device_descriptor {
25682651c39SIlya Yanok 	__u8  bLength;
25782651c39SIlya Yanok 	__u8  bDescriptorType;
25882651c39SIlya Yanok 
25982651c39SIlya Yanok 	__le16 bcdUSB;
26082651c39SIlya Yanok 	__u8  bDeviceClass;
26182651c39SIlya Yanok 	__u8  bDeviceSubClass;
26282651c39SIlya Yanok 	__u8  bDeviceProtocol;
26382651c39SIlya Yanok 	__u8  bMaxPacketSize0;
26482651c39SIlya Yanok 	__le16 idVendor;
26582651c39SIlya Yanok 	__le16 idProduct;
26682651c39SIlya Yanok 	__le16 bcdDevice;
26782651c39SIlya Yanok 	__u8  iManufacturer;
26882651c39SIlya Yanok 	__u8  iProduct;
26982651c39SIlya Yanok 	__u8  iSerialNumber;
27082651c39SIlya Yanok 	__u8  bNumConfigurations;
27182651c39SIlya Yanok } __attribute__ ((packed));
27282651c39SIlya Yanok 
27323cd1385SRemy Bohmer #define USB_DT_DEVICE_SIZE		18
27423cd1385SRemy Bohmer 
27523cd1385SRemy Bohmer 
27623cd1385SRemy Bohmer /*
27723cd1385SRemy Bohmer  * Device and/or Interface Class codes
27823cd1385SRemy Bohmer  * as found in bDeviceClass or bInterfaceClass
27923cd1385SRemy Bohmer  * and defined by www.usb.org documents
28023cd1385SRemy Bohmer  */
28123cd1385SRemy Bohmer #define USB_CLASS_PER_INTERFACE		0	/* for DeviceClass */
28223cd1385SRemy Bohmer #define USB_CLASS_AUDIO			1
28323cd1385SRemy Bohmer #define USB_CLASS_COMM			2
28423cd1385SRemy Bohmer #define USB_CLASS_HID			3
28523cd1385SRemy Bohmer #define USB_CLASS_PHYSICAL		5
28623cd1385SRemy Bohmer #define USB_CLASS_STILL_IMAGE		6
28723cd1385SRemy Bohmer #define USB_CLASS_PRINTER		7
28823cd1385SRemy Bohmer #define USB_CLASS_MASS_STORAGE		8
28923cd1385SRemy Bohmer #define USB_CLASS_HUB			9
29023cd1385SRemy Bohmer #define USB_CLASS_CDC_DATA		0x0a
29123cd1385SRemy Bohmer #define USB_CLASS_CSCID			0x0b	/* chip+ smart card */
29223cd1385SRemy Bohmer #define USB_CLASS_CONTENT_SEC		0x0d	/* content security */
29323cd1385SRemy Bohmer #define USB_CLASS_VIDEO			0x0e
29423cd1385SRemy Bohmer #define USB_CLASS_WIRELESS_CONTROLLER	0xe0
29523cd1385SRemy Bohmer #define USB_CLASS_MISC			0xef
29623cd1385SRemy Bohmer #define USB_CLASS_APP_SPEC		0xfe
29723cd1385SRemy Bohmer #define USB_CLASS_VENDOR_SPEC		0xff
29823cd1385SRemy Bohmer 
29982651c39SIlya Yanok #define USB_SUBCLASS_VENDOR_SPEC	0xff
30082651c39SIlya Yanok 
30123cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
30223cd1385SRemy Bohmer 
30323cd1385SRemy Bohmer /* USB_DT_CONFIG: Configuration descriptor information.
30423cd1385SRemy Bohmer  *
30523cd1385SRemy Bohmer  * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
30623cd1385SRemy Bohmer  * descriptor type is different.  Highspeed-capable devices can look
30723cd1385SRemy Bohmer  * different depending on what speed they're currently running.  Only
30823cd1385SRemy Bohmer  * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
30923cd1385SRemy Bohmer  * descriptors.
31023cd1385SRemy Bohmer  */
31123cd1385SRemy Bohmer struct usb_config_descriptor {
31223cd1385SRemy Bohmer 	__u8  bLength;
31323cd1385SRemy Bohmer 	__u8  bDescriptorType;
31423cd1385SRemy Bohmer 
31523cd1385SRemy Bohmer 	__le16 wTotalLength;
31623cd1385SRemy Bohmer 	__u8  bNumInterfaces;
31723cd1385SRemy Bohmer 	__u8  bConfigurationValue;
31823cd1385SRemy Bohmer 	__u8  iConfiguration;
31923cd1385SRemy Bohmer 	__u8  bmAttributes;
32023cd1385SRemy Bohmer 	__u8  bMaxPower;
32123cd1385SRemy Bohmer } __attribute__ ((packed));
32223cd1385SRemy Bohmer 
32323cd1385SRemy Bohmer #define USB_DT_CONFIG_SIZE		9
32423cd1385SRemy Bohmer 
32523cd1385SRemy Bohmer /* from config descriptor bmAttributes */
32623cd1385SRemy Bohmer #define USB_CONFIG_ATT_ONE		(1 << 7)	/* must be set */
32723cd1385SRemy Bohmer #define USB_CONFIG_ATT_SELFPOWER	(1 << 6)	/* self powered */
32823cd1385SRemy Bohmer #define USB_CONFIG_ATT_WAKEUP		(1 << 5)	/* can wakeup */
32923cd1385SRemy Bohmer #define USB_CONFIG_ATT_BATTERY		(1 << 4)	/* battery powered */
33023cd1385SRemy Bohmer 
33182651c39SIlya Yanok /*-------------------------------------------------------------------------*/
33282651c39SIlya Yanok 
33382651c39SIlya Yanok /* USB_DT_STRING: String descriptor */
33482651c39SIlya Yanok struct usb_string_descriptor {
33582651c39SIlya Yanok 	__u8  bLength;
33682651c39SIlya Yanok 	__u8  bDescriptorType;
33782651c39SIlya Yanok 
33882651c39SIlya Yanok 	__le16 wData[1];		/* UTF-16LE encoded */
33982651c39SIlya Yanok } __attribute__ ((packed));
34082651c39SIlya Yanok 
34123cd1385SRemy Bohmer /* note that "string" zero is special, it holds language codes that
34223cd1385SRemy Bohmer  * the device supports, not Unicode characters.
34323cd1385SRemy Bohmer  */
34423cd1385SRemy Bohmer 
34582651c39SIlya Yanok /*-------------------------------------------------------------------------*/
34682651c39SIlya Yanok 
34782651c39SIlya Yanok /* USB_DT_INTERFACE: Interface descriptor */
34882651c39SIlya Yanok struct usb_interface_descriptor {
34982651c39SIlya Yanok 	__u8  bLength;
35082651c39SIlya Yanok 	__u8  bDescriptorType;
35182651c39SIlya Yanok 
35282651c39SIlya Yanok 	__u8  bInterfaceNumber;
35382651c39SIlya Yanok 	__u8  bAlternateSetting;
35482651c39SIlya Yanok 	__u8  bNumEndpoints;
35582651c39SIlya Yanok 	__u8  bInterfaceClass;
35682651c39SIlya Yanok 	__u8  bInterfaceSubClass;
35782651c39SIlya Yanok 	__u8  bInterfaceProtocol;
35882651c39SIlya Yanok 	__u8  iInterface;
35982651c39SIlya Yanok } __attribute__ ((packed));
36082651c39SIlya Yanok 
36123cd1385SRemy Bohmer #define USB_DT_INTERFACE_SIZE		9
36282651c39SIlya Yanok 
36382651c39SIlya Yanok /*-------------------------------------------------------------------------*/
36482651c39SIlya Yanok 
36582651c39SIlya Yanok /* USB_DT_ENDPOINT: Endpoint descriptor */
36682651c39SIlya Yanok struct usb_endpoint_descriptor {
36782651c39SIlya Yanok 	__u8  bLength;
36882651c39SIlya Yanok 	__u8  bDescriptorType;
36982651c39SIlya Yanok 
37082651c39SIlya Yanok 	__u8  bEndpointAddress;
37182651c39SIlya Yanok 	__u8  bmAttributes;
37282651c39SIlya Yanok 	__le16 wMaxPacketSize;
37382651c39SIlya Yanok 	__u8  bInterval;
37482651c39SIlya Yanok 
37582651c39SIlya Yanok 	/* NOTE:  these two are _only_ in audio endpoints. */
37682651c39SIlya Yanok 	/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
37782651c39SIlya Yanok 	__u8  bRefresh;
37882651c39SIlya Yanok 	__u8  bSynchAddress;
37982651c39SIlya Yanok } __attribute__ ((packed));
38082651c39SIlya Yanok 
38123cd1385SRemy Bohmer #define USB_DT_ENDPOINT_SIZE		7
38223cd1385SRemy Bohmer #define USB_DT_ENDPOINT_AUDIO_SIZE	9	/* Audio extension */
38323cd1385SRemy Bohmer 
3848e2b6619SSimon Glass /* Used to access common fields */
3858e2b6619SSimon Glass struct usb_generic_descriptor {
3868e2b6619SSimon Glass 	__u8  bLength;
3878e2b6619SSimon Glass 	__u8  bDescriptorType;
3888e2b6619SSimon Glass };
38923cd1385SRemy Bohmer 
390*d8a26f03SSimon Glass struct __packed usb_class_hid_descriptor {
391*d8a26f03SSimon Glass 	u8 bLength;
392*d8a26f03SSimon Glass 	u8 bDescriptorType;
393*d8a26f03SSimon Glass 	u16 bcdCDC;
394*d8a26f03SSimon Glass 	u8 bCountryCode;
395*d8a26f03SSimon Glass 	u8 bNumDescriptors;	/* 0x01 */
396*d8a26f03SSimon Glass 	u8 bDescriptorType0;
397*d8a26f03SSimon Glass 	u16 wDescriptorLength0;
398*d8a26f03SSimon Glass 	/* optional descriptors are not supported. */
399*d8a26f03SSimon Glass };
400*d8a26f03SSimon Glass 
401*d8a26f03SSimon Glass struct __packed usb_class_report_descriptor {
402*d8a26f03SSimon Glass 	u8 bLength;	/* dummy */
403*d8a26f03SSimon Glass 	u8 bDescriptorType;
404*d8a26f03SSimon Glass 	u16 wLength;
405*d8a26f03SSimon Glass 	u8 bData[0];
406*d8a26f03SSimon Glass };
407*d8a26f03SSimon Glass 
40823cd1385SRemy Bohmer /*
40923cd1385SRemy Bohmer  * Endpoints
41023cd1385SRemy Bohmer  */
41123cd1385SRemy Bohmer #define USB_ENDPOINT_NUMBER_MASK	0x0f	/* in bEndpointAddress */
41223cd1385SRemy Bohmer #define USB_ENDPOINT_DIR_MASK		0x80
41323cd1385SRemy Bohmer 
41423cd1385SRemy Bohmer #define USB_ENDPOINT_XFERTYPE_MASK	0x03	/* in bmAttributes */
41523cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_CONTROL	0
41623cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_ISOC		1
41723cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_BULK		2
41823cd1385SRemy Bohmer #define USB_ENDPOINT_XFER_INT		3
41923cd1385SRemy Bohmer #define USB_ENDPOINT_MAX_ADJUSTABLE	0x80
42023cd1385SRemy Bohmer 
42182651c39SIlya Yanok /* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
42282651c39SIlya Yanok #define USB_ENDPOINT_INTRTYPE		0x30
42382651c39SIlya Yanok #define USB_ENDPOINT_INTR_PERIODIC	(0 << 4)
42482651c39SIlya Yanok #define USB_ENDPOINT_INTR_NOTIFICATION	(1 << 4)
42582651c39SIlya Yanok 
42682651c39SIlya Yanok #define USB_ENDPOINT_SYNCTYPE		0x0c
42782651c39SIlya Yanok #define USB_ENDPOINT_SYNC_NONE		(0 << 2)
42882651c39SIlya Yanok #define USB_ENDPOINT_SYNC_ASYNC		(1 << 2)
42982651c39SIlya Yanok #define USB_ENDPOINT_SYNC_ADAPTIVE	(2 << 2)
43082651c39SIlya Yanok #define USB_ENDPOINT_SYNC_SYNC		(3 << 2)
43182651c39SIlya Yanok 
43282651c39SIlya Yanok #define USB_ENDPOINT_USAGE_MASK		0x30
43382651c39SIlya Yanok #define USB_ENDPOINT_USAGE_DATA		0x00
43482651c39SIlya Yanok #define USB_ENDPOINT_USAGE_FEEDBACK	0x10
43582651c39SIlya Yanok #define USB_ENDPOINT_USAGE_IMPLICIT_FB	0x20	/* Implicit feedback Data endpoint */
43682651c39SIlya Yanok 
43782651c39SIlya Yanok /*-------------------------------------------------------------------------*/
43882651c39SIlya Yanok 
43982651c39SIlya Yanok /**
44082651c39SIlya Yanok  * usb_endpoint_num - get the endpoint's number
44182651c39SIlya Yanok  * @epd: endpoint to be checked
44282651c39SIlya Yanok  *
44382651c39SIlya Yanok  * Returns @epd's number: 0 to 15.
44482651c39SIlya Yanok  */
44582651c39SIlya Yanok static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
44682651c39SIlya Yanok {
44782651c39SIlya Yanok 	return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
44882651c39SIlya Yanok }
44982651c39SIlya Yanok 
45082651c39SIlya Yanok /**
45182651c39SIlya Yanok  * usb_endpoint_type - get the endpoint's transfer type
45282651c39SIlya Yanok  * @epd: endpoint to be checked
45382651c39SIlya Yanok  *
45482651c39SIlya Yanok  * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
45582651c39SIlya Yanok  * to @epd's transfer type.
45682651c39SIlya Yanok  */
45782651c39SIlya Yanok static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
45882651c39SIlya Yanok {
45982651c39SIlya Yanok 	return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
46082651c39SIlya Yanok }
46182651c39SIlya Yanok 
46282651c39SIlya Yanok /**
46382651c39SIlya Yanok  * usb_endpoint_dir_in - check if the endpoint has IN direction
46482651c39SIlya Yanok  * @epd: endpoint to be checked
46582651c39SIlya Yanok  *
46682651c39SIlya Yanok  * Returns true if the endpoint is of type IN, otherwise it returns false.
46782651c39SIlya Yanok  */
46882651c39SIlya Yanok static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
46982651c39SIlya Yanok {
47082651c39SIlya Yanok 	return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
47182651c39SIlya Yanok }
47282651c39SIlya Yanok 
47382651c39SIlya Yanok /**
47482651c39SIlya Yanok  * usb_endpoint_dir_out - check if the endpoint has OUT direction
47582651c39SIlya Yanok  * @epd: endpoint to be checked
47682651c39SIlya Yanok  *
47782651c39SIlya Yanok  * Returns true if the endpoint is of type OUT, otherwise it returns false.
47882651c39SIlya Yanok  */
47982651c39SIlya Yanok static inline int usb_endpoint_dir_out(
48082651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
48182651c39SIlya Yanok {
48282651c39SIlya Yanok 	return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
48382651c39SIlya Yanok }
48482651c39SIlya Yanok 
48582651c39SIlya Yanok /**
48682651c39SIlya Yanok  * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
48782651c39SIlya Yanok  * @epd: endpoint to be checked
48882651c39SIlya Yanok  *
48982651c39SIlya Yanok  * Returns true if the endpoint is of type bulk, otherwise it returns false.
49082651c39SIlya Yanok  */
49182651c39SIlya Yanok static inline int usb_endpoint_xfer_bulk(
49282651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
49382651c39SIlya Yanok {
49482651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
49582651c39SIlya Yanok 		USB_ENDPOINT_XFER_BULK);
49682651c39SIlya Yanok }
49782651c39SIlya Yanok 
49882651c39SIlya Yanok /**
49982651c39SIlya Yanok  * usb_endpoint_xfer_control - check if the endpoint has control transfer type
50082651c39SIlya Yanok  * @epd: endpoint to be checked
50182651c39SIlya Yanok  *
50282651c39SIlya Yanok  * Returns true if the endpoint is of type control, otherwise it returns false.
50382651c39SIlya Yanok  */
50482651c39SIlya Yanok static inline int usb_endpoint_xfer_control(
50582651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
50682651c39SIlya Yanok {
50782651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
50882651c39SIlya Yanok 		USB_ENDPOINT_XFER_CONTROL);
50982651c39SIlya Yanok }
51082651c39SIlya Yanok 
51182651c39SIlya Yanok /**
51282651c39SIlya Yanok  * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
51382651c39SIlya Yanok  * @epd: endpoint to be checked
51482651c39SIlya Yanok  *
51582651c39SIlya Yanok  * Returns true if the endpoint is of type interrupt, otherwise it returns
51682651c39SIlya Yanok  * false.
51782651c39SIlya Yanok  */
51882651c39SIlya Yanok static inline int usb_endpoint_xfer_int(
51982651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
52082651c39SIlya Yanok {
52182651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
52282651c39SIlya Yanok 		USB_ENDPOINT_XFER_INT);
52382651c39SIlya Yanok }
52482651c39SIlya Yanok 
52582651c39SIlya Yanok /**
52682651c39SIlya Yanok  * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
52782651c39SIlya Yanok  * @epd: endpoint to be checked
52882651c39SIlya Yanok  *
52982651c39SIlya Yanok  * Returns true if the endpoint is of type isochronous, otherwise it returns
53082651c39SIlya Yanok  * false.
53182651c39SIlya Yanok  */
53282651c39SIlya Yanok static inline int usb_endpoint_xfer_isoc(
53382651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
53482651c39SIlya Yanok {
53582651c39SIlya Yanok 	return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
53682651c39SIlya Yanok 		USB_ENDPOINT_XFER_ISOC);
53782651c39SIlya Yanok }
53882651c39SIlya Yanok 
53982651c39SIlya Yanok /**
54082651c39SIlya Yanok  * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
54182651c39SIlya Yanok  * @epd: endpoint to be checked
54282651c39SIlya Yanok  *
54382651c39SIlya Yanok  * Returns true if the endpoint has bulk transfer type and IN direction,
54482651c39SIlya Yanok  * otherwise it returns false.
54582651c39SIlya Yanok  */
54682651c39SIlya Yanok static inline int usb_endpoint_is_bulk_in(
54782651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
54882651c39SIlya Yanok {
54982651c39SIlya Yanok 	return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
55082651c39SIlya Yanok }
55182651c39SIlya Yanok 
55282651c39SIlya Yanok /**
55382651c39SIlya Yanok  * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
55482651c39SIlya Yanok  * @epd: endpoint to be checked
55582651c39SIlya Yanok  *
55682651c39SIlya Yanok  * Returns true if the endpoint has bulk transfer type and OUT direction,
55782651c39SIlya Yanok  * otherwise it returns false.
55882651c39SIlya Yanok  */
55982651c39SIlya Yanok static inline int usb_endpoint_is_bulk_out(
56082651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
56182651c39SIlya Yanok {
56282651c39SIlya Yanok 	return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
56382651c39SIlya Yanok }
56482651c39SIlya Yanok 
56582651c39SIlya Yanok /**
56682651c39SIlya Yanok  * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
56782651c39SIlya Yanok  * @epd: endpoint to be checked
56882651c39SIlya Yanok  *
56982651c39SIlya Yanok  * Returns true if the endpoint has interrupt transfer type and IN direction,
57082651c39SIlya Yanok  * otherwise it returns false.
57182651c39SIlya Yanok  */
57282651c39SIlya Yanok static inline int usb_endpoint_is_int_in(
57382651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
57482651c39SIlya Yanok {
57582651c39SIlya Yanok 	return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
57682651c39SIlya Yanok }
57782651c39SIlya Yanok 
57882651c39SIlya Yanok /**
57982651c39SIlya Yanok  * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
58082651c39SIlya Yanok  * @epd: endpoint to be checked
58182651c39SIlya Yanok  *
58282651c39SIlya Yanok  * Returns true if the endpoint has interrupt transfer type and OUT direction,
58382651c39SIlya Yanok  * otherwise it returns false.
58482651c39SIlya Yanok  */
58582651c39SIlya Yanok static inline int usb_endpoint_is_int_out(
58682651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
58782651c39SIlya Yanok {
58882651c39SIlya Yanok 	return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
58982651c39SIlya Yanok }
59082651c39SIlya Yanok 
59182651c39SIlya Yanok /**
59282651c39SIlya Yanok  * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
59382651c39SIlya Yanok  * @epd: endpoint to be checked
59482651c39SIlya Yanok  *
59582651c39SIlya Yanok  * Returns true if the endpoint has isochronous transfer type and IN direction,
59682651c39SIlya Yanok  * otherwise it returns false.
59782651c39SIlya Yanok  */
59882651c39SIlya Yanok static inline int usb_endpoint_is_isoc_in(
59982651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
60082651c39SIlya Yanok {
60182651c39SIlya Yanok 	return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
60282651c39SIlya Yanok }
60382651c39SIlya Yanok 
60482651c39SIlya Yanok /**
60582651c39SIlya Yanok  * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
60682651c39SIlya Yanok  * @epd: endpoint to be checked
60782651c39SIlya Yanok  *
60882651c39SIlya Yanok  * Returns true if the endpoint has isochronous transfer type and OUT direction,
60982651c39SIlya Yanok  * otherwise it returns false.
61082651c39SIlya Yanok  */
61182651c39SIlya Yanok static inline int usb_endpoint_is_isoc_out(
61282651c39SIlya Yanok 				const struct usb_endpoint_descriptor *epd)
61382651c39SIlya Yanok {
61482651c39SIlya Yanok 	return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
61582651c39SIlya Yanok }
61682651c39SIlya Yanok 
61782651c39SIlya Yanok /**
61882651c39SIlya Yanok  * usb_endpoint_maxp - get endpoint's max packet size
61982651c39SIlya Yanok  * @epd: endpoint to be checked
62082651c39SIlya Yanok  *
62182651c39SIlya Yanok  * Returns @epd's max packet
62282651c39SIlya Yanok  */
62382651c39SIlya Yanok static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
62482651c39SIlya Yanok {
625f903a20dSVivek Gautam 	return __le16_to_cpu(get_unaligned(&epd->wMaxPacketSize));
62682651c39SIlya Yanok }
62782651c39SIlya Yanok 
62882651c39SIlya Yanok static inline int usb_endpoint_interrupt_type(
62982651c39SIlya Yanok 		const struct usb_endpoint_descriptor *epd)
63082651c39SIlya Yanok {
63182651c39SIlya Yanok 	return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
63282651c39SIlya Yanok }
63382651c39SIlya Yanok 
63482651c39SIlya Yanok /*-------------------------------------------------------------------------*/
63582651c39SIlya Yanok 
63682651c39SIlya Yanok /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
63782651c39SIlya Yanok struct usb_ss_ep_comp_descriptor {
63882651c39SIlya Yanok 	__u8  bLength;
63982651c39SIlya Yanok 	__u8  bDescriptorType;
64082651c39SIlya Yanok 
64182651c39SIlya Yanok 	__u8  bMaxBurst;
64282651c39SIlya Yanok 	__u8  bmAttributes;
64382651c39SIlya Yanok 	__le16 wBytesPerInterval;
64482651c39SIlya Yanok } __attribute__ ((packed));
64582651c39SIlya Yanok 
64682651c39SIlya Yanok #define USB_DT_SS_EP_COMP_SIZE		6
64782651c39SIlya Yanok 
64882651c39SIlya Yanok /* Bits 4:0 of bmAttributes if this is a bulk endpoint */
64982651c39SIlya Yanok static inline int
65082651c39SIlya Yanok usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
65182651c39SIlya Yanok {
65282651c39SIlya Yanok 	int		max_streams;
65382651c39SIlya Yanok 
65482651c39SIlya Yanok 	if (!comp)
65582651c39SIlya Yanok 		return 0;
65682651c39SIlya Yanok 
65782651c39SIlya Yanok 	max_streams = comp->bmAttributes & 0x1f;
65882651c39SIlya Yanok 
65982651c39SIlya Yanok 	if (!max_streams)
66082651c39SIlya Yanok 		return 0;
66182651c39SIlya Yanok 
66282651c39SIlya Yanok 	max_streams = 1 << max_streams;
66382651c39SIlya Yanok 
66482651c39SIlya Yanok 	return max_streams;
66582651c39SIlya Yanok }
66682651c39SIlya Yanok 
66782651c39SIlya Yanok /* Bits 1:0 of bmAttributes if this is an isoc endpoint */
66882651c39SIlya Yanok #define USB_SS_MULT(p)			(1 + ((p) & 0x3))
66923cd1385SRemy Bohmer 
67023cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
67123cd1385SRemy Bohmer 
67223cd1385SRemy Bohmer /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
67323cd1385SRemy Bohmer struct usb_qualifier_descriptor {
67423cd1385SRemy Bohmer 	__u8  bLength;
67523cd1385SRemy Bohmer 	__u8  bDescriptorType;
67623cd1385SRemy Bohmer 
67723cd1385SRemy Bohmer 	__le16 bcdUSB;
67823cd1385SRemy Bohmer 	__u8  bDeviceClass;
67923cd1385SRemy Bohmer 	__u8  bDeviceSubClass;
68023cd1385SRemy Bohmer 	__u8  bDeviceProtocol;
68123cd1385SRemy Bohmer 	__u8  bMaxPacketSize0;
68223cd1385SRemy Bohmer 	__u8  bNumConfigurations;
68323cd1385SRemy Bohmer 	__u8  bRESERVED;
68423cd1385SRemy Bohmer } __attribute__ ((packed));
68523cd1385SRemy Bohmer 
68623cd1385SRemy Bohmer 
68723cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
68823cd1385SRemy Bohmer 
68923cd1385SRemy Bohmer /* USB_DT_OTG (from OTG 1.0a supplement) */
69023cd1385SRemy Bohmer struct usb_otg_descriptor {
69123cd1385SRemy Bohmer 	__u8  bLength;
69223cd1385SRemy Bohmer 	__u8  bDescriptorType;
69323cd1385SRemy Bohmer 
69423cd1385SRemy Bohmer 	__u8  bmAttributes;	/* support for HNP, SRP, etc */
69523cd1385SRemy Bohmer } __attribute__ ((packed));
69623cd1385SRemy Bohmer 
69723cd1385SRemy Bohmer /* from usb_otg_descriptor.bmAttributes */
69823cd1385SRemy Bohmer #define USB_OTG_SRP		(1 << 0)
69923cd1385SRemy Bohmer #define USB_OTG_HNP		(1 << 1)	/* swap host/device roles */
70023cd1385SRemy Bohmer 
70123cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
70223cd1385SRemy Bohmer 
70323cd1385SRemy Bohmer /* USB_DT_DEBUG:  for special highspeed devices, replacing serial console */
70423cd1385SRemy Bohmer struct usb_debug_descriptor {
70523cd1385SRemy Bohmer 	__u8  bLength;
70623cd1385SRemy Bohmer 	__u8  bDescriptorType;
70723cd1385SRemy Bohmer 
70823cd1385SRemy Bohmer 	/* bulk endpoints with 8 byte maxpacket */
70923cd1385SRemy Bohmer 	__u8  bDebugInEndpoint;
71023cd1385SRemy Bohmer 	__u8  bDebugOutEndpoint;
71123cd1385SRemy Bohmer } __attribute__((packed));
71223cd1385SRemy Bohmer 
71323cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
71423cd1385SRemy Bohmer 
71523cd1385SRemy Bohmer /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
71623cd1385SRemy Bohmer struct usb_interface_assoc_descriptor {
71723cd1385SRemy Bohmer 	__u8  bLength;
71823cd1385SRemy Bohmer 	__u8  bDescriptorType;
71923cd1385SRemy Bohmer 
72023cd1385SRemy Bohmer 	__u8  bFirstInterface;
72123cd1385SRemy Bohmer 	__u8  bInterfaceCount;
72223cd1385SRemy Bohmer 	__u8  bFunctionClass;
72323cd1385SRemy Bohmer 	__u8  bFunctionSubClass;
72423cd1385SRemy Bohmer 	__u8  bFunctionProtocol;
72523cd1385SRemy Bohmer 	__u8  iFunction;
72623cd1385SRemy Bohmer } __attribute__ ((packed));
72723cd1385SRemy Bohmer 
72823cd1385SRemy Bohmer 
72923cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
73023cd1385SRemy Bohmer 
73123cd1385SRemy Bohmer /* USB_DT_SECURITY:  group of wireless security descriptors, including
73223cd1385SRemy Bohmer  * encryption types available for setting up a CC/association.
73323cd1385SRemy Bohmer  */
73423cd1385SRemy Bohmer struct usb_security_descriptor {
73523cd1385SRemy Bohmer 	__u8  bLength;
73623cd1385SRemy Bohmer 	__u8  bDescriptorType;
73723cd1385SRemy Bohmer 
73823cd1385SRemy Bohmer 	__le16 wTotalLength;
73923cd1385SRemy Bohmer 	__u8  bNumEncryptionTypes;
74023cd1385SRemy Bohmer } __attribute__((packed));
74123cd1385SRemy Bohmer 
74223cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
74323cd1385SRemy Bohmer 
74423cd1385SRemy Bohmer /* USB_DT_KEY:  used with {GET,SET}_SECURITY_DATA; only public keys
74523cd1385SRemy Bohmer  * may be retrieved.
74623cd1385SRemy Bohmer  */
74723cd1385SRemy Bohmer struct usb_key_descriptor {
74823cd1385SRemy Bohmer 	__u8  bLength;
74923cd1385SRemy Bohmer 	__u8  bDescriptorType;
75023cd1385SRemy Bohmer 
75123cd1385SRemy Bohmer 	__u8  tTKID[3];
75223cd1385SRemy Bohmer 	__u8  bReserved;
75323cd1385SRemy Bohmer 	__u8  bKeyData[0];
75423cd1385SRemy Bohmer } __attribute__((packed));
75523cd1385SRemy Bohmer 
75623cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
75723cd1385SRemy Bohmer 
75823cd1385SRemy Bohmer /* USB_DT_ENCRYPTION_TYPE:  bundled in DT_SECURITY groups */
75923cd1385SRemy Bohmer struct usb_encryption_descriptor {
76023cd1385SRemy Bohmer 	__u8  bLength;
76123cd1385SRemy Bohmer 	__u8  bDescriptorType;
76223cd1385SRemy Bohmer 
76323cd1385SRemy Bohmer 	__u8  bEncryptionType;
76423cd1385SRemy Bohmer #define	USB_ENC_TYPE_UNSECURE		0
76523cd1385SRemy Bohmer #define	USB_ENC_TYPE_WIRED		1	/* non-wireless mode */
76623cd1385SRemy Bohmer #define	USB_ENC_TYPE_CCM_1		2	/* aes128/cbc session */
76723cd1385SRemy Bohmer #define	USB_ENC_TYPE_RSA_1		3	/* rsa3072/sha1 auth */
76823cd1385SRemy Bohmer 	__u8  bEncryptionValue;		/* use in SET_ENCRYPTION */
76923cd1385SRemy Bohmer 	__u8  bAuthKeyIndex;
77023cd1385SRemy Bohmer } __attribute__((packed));
77123cd1385SRemy Bohmer 
77223cd1385SRemy Bohmer 
77323cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
77423cd1385SRemy Bohmer 
77582651c39SIlya Yanok /* USB_DT_BOS:  group of device-level capabilities */
77623cd1385SRemy Bohmer struct usb_bos_descriptor {
77723cd1385SRemy Bohmer 	__u8  bLength;
77823cd1385SRemy Bohmer 	__u8  bDescriptorType;
77923cd1385SRemy Bohmer 
78023cd1385SRemy Bohmer 	__le16 wTotalLength;
78123cd1385SRemy Bohmer 	__u8  bNumDeviceCaps;
78223cd1385SRemy Bohmer } __attribute__((packed));
78323cd1385SRemy Bohmer 
78482651c39SIlya Yanok #define USB_DT_BOS_SIZE		5
78523cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
78623cd1385SRemy Bohmer 
78723cd1385SRemy Bohmer /* USB_DT_DEVICE_CAPABILITY:  grouped with BOS */
78823cd1385SRemy Bohmer struct usb_dev_cap_header {
78923cd1385SRemy Bohmer 	__u8  bLength;
79023cd1385SRemy Bohmer 	__u8  bDescriptorType;
79123cd1385SRemy Bohmer 	__u8  bDevCapabilityType;
79223cd1385SRemy Bohmer } __attribute__((packed));
79323cd1385SRemy Bohmer 
79423cd1385SRemy Bohmer #define	USB_CAP_TYPE_WIRELESS_USB	1
79523cd1385SRemy Bohmer 
79623cd1385SRemy Bohmer struct usb_wireless_cap_descriptor {	/* Ultra Wide Band */
79723cd1385SRemy Bohmer 	__u8  bLength;
79823cd1385SRemy Bohmer 	__u8  bDescriptorType;
79923cd1385SRemy Bohmer 	__u8  bDevCapabilityType;
80023cd1385SRemy Bohmer 
80123cd1385SRemy Bohmer 	__u8  bmAttributes;
80223cd1385SRemy Bohmer #define	USB_WIRELESS_P2P_DRD		(1 << 1)
80323cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_MASK	(3 << 2)
80423cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_SELF	(1 << 2)
80523cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_DIRECTED	(2 << 2)
80623cd1385SRemy Bohmer #define	USB_WIRELESS_BEACON_NONE	(3 << 2)
80723cd1385SRemy Bohmer 	__le16 wPHYRates;	/* bit rates, Mbps */
80823cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_53		(1 << 0)	/* always set */
80923cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_80		(1 << 1)
81023cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_107		(1 << 2)	/* always set */
81123cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_160		(1 << 3)
81223cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_200		(1 << 4)	/* always set */
81323cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_320		(1 << 5)
81423cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_400		(1 << 6)
81523cd1385SRemy Bohmer #define	USB_WIRELESS_PHY_480		(1 << 7)
81623cd1385SRemy Bohmer 	__u8  bmTFITXPowerInfo;	/* TFI power levels */
81723cd1385SRemy Bohmer 	__u8  bmFFITXPowerInfo;	/* FFI power levels */
81823cd1385SRemy Bohmer 	__le16 bmBandGroup;
81923cd1385SRemy Bohmer 	__u8  bReserved;
82023cd1385SRemy Bohmer } __attribute__((packed));
82123cd1385SRemy Bohmer 
82282651c39SIlya Yanok /* USB 2.0 Extension descriptor */
82382651c39SIlya Yanok #define	USB_CAP_TYPE_EXT		2
82482651c39SIlya Yanok 
82582651c39SIlya Yanok struct usb_ext_cap_descriptor {		/* Link Power Management */
82682651c39SIlya Yanok 	__u8  bLength;
82782651c39SIlya Yanok 	__u8  bDescriptorType;
82882651c39SIlya Yanok 	__u8  bDevCapabilityType;
82982651c39SIlya Yanok 	__le32 bmAttributes;
83082651c39SIlya Yanok #define USB_LPM_SUPPORT			(1 << 1)	/* supports LPM */
83182651c39SIlya Yanok #define USB_BESL_SUPPORT		(1 << 2)	/* supports BESL */
83282651c39SIlya Yanok #define USB_BESL_BASELINE_VALID		(1 << 3)	/* Baseline BESL valid*/
83382651c39SIlya Yanok #define USB_BESL_DEEP_VALID		(1 << 4)	/* Deep BESL valid */
83482651c39SIlya Yanok #define USB_GET_BESL_BASELINE(p)	(((p) & (0xf << 8)) >> 8)
83582651c39SIlya Yanok #define USB_GET_BESL_DEEP(p)		(((p) & (0xf << 12)) >> 12)
83682651c39SIlya Yanok } __attribute__((packed));
83782651c39SIlya Yanok 
83882651c39SIlya Yanok #define USB_DT_USB_EXT_CAP_SIZE	7
83982651c39SIlya Yanok 
84082651c39SIlya Yanok /*
84182651c39SIlya Yanok  * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
84282651c39SIlya Yanok  * specific device level capabilities
84382651c39SIlya Yanok  */
84482651c39SIlya Yanok #define		USB_SS_CAP_TYPE		3
84582651c39SIlya Yanok struct usb_ss_cap_descriptor {		/* Link Power Management */
84682651c39SIlya Yanok 	__u8  bLength;
84782651c39SIlya Yanok 	__u8  bDescriptorType;
84882651c39SIlya Yanok 	__u8  bDevCapabilityType;
84982651c39SIlya Yanok 	__u8  bmAttributes;
85082651c39SIlya Yanok #define USB_LTM_SUPPORT			(1 << 1) /* supports LTM */
85182651c39SIlya Yanok 	__le16 wSpeedSupported;
85282651c39SIlya Yanok #define USB_LOW_SPEED_OPERATION		(1)	 /* Low speed operation */
85382651c39SIlya Yanok #define USB_FULL_SPEED_OPERATION	(1 << 1) /* Full speed operation */
85482651c39SIlya Yanok #define USB_HIGH_SPEED_OPERATION	(1 << 2) /* High speed operation */
85582651c39SIlya Yanok #define USB_5GBPS_OPERATION		(1 << 3) /* Operation at 5Gbps */
85682651c39SIlya Yanok 	__u8  bFunctionalitySupport;
85782651c39SIlya Yanok 	__u8  bU1devExitLat;
85882651c39SIlya Yanok 	__le16 bU2DevExitLat;
85982651c39SIlya Yanok } __attribute__((packed));
86082651c39SIlya Yanok 
86182651c39SIlya Yanok #define USB_DT_USB_SS_CAP_SIZE	10
86282651c39SIlya Yanok 
86382651c39SIlya Yanok /*
86482651c39SIlya Yanok  * Container ID Capability descriptor: Defines the instance unique ID used to
86582651c39SIlya Yanok  * identify the instance across all operating modes
86682651c39SIlya Yanok  */
86782651c39SIlya Yanok #define	CONTAINER_ID_TYPE	4
86882651c39SIlya Yanok struct usb_ss_container_id_descriptor {
86982651c39SIlya Yanok 	__u8  bLength;
87082651c39SIlya Yanok 	__u8  bDescriptorType;
87182651c39SIlya Yanok 	__u8  bDevCapabilityType;
87282651c39SIlya Yanok 	__u8  bReserved;
87382651c39SIlya Yanok 	__u8  ContainerID[16]; /* 128-bit number */
87482651c39SIlya Yanok } __attribute__((packed));
87582651c39SIlya Yanok 
87682651c39SIlya Yanok #define USB_DT_USB_SS_CONTN_ID_SIZE	20
87723cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
87823cd1385SRemy Bohmer 
87923cd1385SRemy Bohmer /* USB_DT_WIRELESS_ENDPOINT_COMP:  companion descriptor associated with
88023cd1385SRemy Bohmer  * each endpoint descriptor for a wireless device
88123cd1385SRemy Bohmer  */
88223cd1385SRemy Bohmer struct usb_wireless_ep_comp_descriptor {
88323cd1385SRemy Bohmer 	__u8  bLength;
88423cd1385SRemy Bohmer 	__u8  bDescriptorType;
88523cd1385SRemy Bohmer 
88623cd1385SRemy Bohmer 	__u8  bMaxBurst;
88723cd1385SRemy Bohmer 	__u8  bMaxSequence;
88823cd1385SRemy Bohmer 	__le16 wMaxStreamDelay;
88923cd1385SRemy Bohmer 	__le16 wOverTheAirPacketSize;
89023cd1385SRemy Bohmer 	__u8  bOverTheAirInterval;
89123cd1385SRemy Bohmer 	__u8  bmCompAttributes;
89223cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_MASK	0x03	/* in bmCompAttributes */
89323cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_NO		0
89423cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_SWITCH	1
89523cd1385SRemy Bohmer #define USB_ENDPOINT_SWITCH_SCALE	2
89623cd1385SRemy Bohmer } __attribute__((packed));
89723cd1385SRemy Bohmer 
89823cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
89923cd1385SRemy Bohmer 
90023cd1385SRemy Bohmer /* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
90123cd1385SRemy Bohmer  * host and a device for connection set up, mutual authentication, and
90223cd1385SRemy Bohmer  * exchanging short lived session keys.  The handshake depends on a CC.
90323cd1385SRemy Bohmer  */
90423cd1385SRemy Bohmer struct usb_handshake {
90523cd1385SRemy Bohmer 	__u8 bMessageNumber;
90623cd1385SRemy Bohmer 	__u8 bStatus;
90723cd1385SRemy Bohmer 	__u8 tTKID[3];
90823cd1385SRemy Bohmer 	__u8 bReserved;
90923cd1385SRemy Bohmer 	__u8 CDID[16];
91023cd1385SRemy Bohmer 	__u8 nonce[16];
91123cd1385SRemy Bohmer 	__u8 MIC[8];
91223cd1385SRemy Bohmer } __attribute__((packed));
91323cd1385SRemy Bohmer 
91423cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
91523cd1385SRemy Bohmer 
91623cd1385SRemy Bohmer /* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
91723cd1385SRemy Bohmer  * A CC may also be set up using non-wireless secure channels (including
91823cd1385SRemy Bohmer  * wired USB!), and some devices may support CCs with multiple hosts.
91923cd1385SRemy Bohmer  */
92023cd1385SRemy Bohmer struct usb_connection_context {
92123cd1385SRemy Bohmer 	__u8 CHID[16];		/* persistent host id */
92223cd1385SRemy Bohmer 	__u8 CDID[16];		/* device id (unique w/in host context) */
92323cd1385SRemy Bohmer 	__u8 CK[16];		/* connection key */
92423cd1385SRemy Bohmer } __attribute__((packed));
92523cd1385SRemy Bohmer 
92623cd1385SRemy Bohmer /*-------------------------------------------------------------------------*/
92723cd1385SRemy Bohmer 
92823cd1385SRemy Bohmer /* USB 2.0 defines three speeds, here's how Linux identifies them */
92923cd1385SRemy Bohmer 
93023cd1385SRemy Bohmer enum usb_device_speed {
93123cd1385SRemy Bohmer 	USB_SPEED_UNKNOWN = 0,			/* enumerating */
93223cd1385SRemy Bohmer 	USB_SPEED_LOW, USB_SPEED_FULL,		/* usb 1.1 */
93323cd1385SRemy Bohmer 	USB_SPEED_HIGH,				/* usb 2.0 */
93482651c39SIlya Yanok 	USB_SPEED_WIRELESS,			/* wireless (usb 2.5) */
93582651c39SIlya Yanok 	USB_SPEED_SUPER,			/* usb 3.0 */
93623cd1385SRemy Bohmer };
93723cd1385SRemy Bohmer 
93882651c39SIlya Yanok #ifdef __KERNEL__
93982651c39SIlya Yanok 
94082651c39SIlya Yanok /**
94182651c39SIlya Yanok  * usb_speed_string() - Returns human readable-name of the speed.
94282651c39SIlya Yanok  * @speed: The speed to return human-readable name for.  If it's not
94382651c39SIlya Yanok  *   any of the speeds defined in usb_device_speed enum, string for
94482651c39SIlya Yanok  *   USB_SPEED_UNKNOWN will be returned.
94582651c39SIlya Yanok  */
94682651c39SIlya Yanok extern const char *usb_speed_string(enum usb_device_speed speed);
94782651c39SIlya Yanok 
94882651c39SIlya Yanok #endif
94982651c39SIlya Yanok 
95023cd1385SRemy Bohmer enum usb_device_state {
95123cd1385SRemy Bohmer 	/* NOTATTACHED isn't in the USB spec, and this state acts
95223cd1385SRemy Bohmer 	 * the same as ATTACHED ... but it's clearer this way.
95323cd1385SRemy Bohmer 	 */
95423cd1385SRemy Bohmer 	USB_STATE_NOTATTACHED = 0,
95523cd1385SRemy Bohmer 
95623cd1385SRemy Bohmer 	/* chapter 9 and authentication (wireless) device states */
95723cd1385SRemy Bohmer 	USB_STATE_ATTACHED,
95823cd1385SRemy Bohmer 	USB_STATE_POWERED,			/* wired */
95923cd1385SRemy Bohmer 	USB_STATE_RECONNECTING,			/* auth */
96082651c39SIlya Yanok 	USB_STATE_UNAUTHENTICATED,		/* auth */
96123cd1385SRemy Bohmer 	USB_STATE_DEFAULT,			/* limited function */
96223cd1385SRemy Bohmer 	USB_STATE_ADDRESS,
96323cd1385SRemy Bohmer 	USB_STATE_CONFIGURED,			/* most functions */
96423cd1385SRemy Bohmer 
96523cd1385SRemy Bohmer 	USB_STATE_SUSPENDED
96623cd1385SRemy Bohmer 
96723cd1385SRemy Bohmer 	/* NOTE:  there are actually four different SUSPENDED
96823cd1385SRemy Bohmer 	 * states, returning to POWERED, DEFAULT, ADDRESS, or
96923cd1385SRemy Bohmer 	 * CONFIGURED respectively when SOF tokens flow again.
97082651c39SIlya Yanok 	 * At this level there's no difference between L1 and L2
97182651c39SIlya Yanok 	 * suspend states.  (L2 being original USB 1.1 suspend.)
97223cd1385SRemy Bohmer 	 */
97323cd1385SRemy Bohmer };
97423cd1385SRemy Bohmer 
97582651c39SIlya Yanok enum usb3_link_state {
97682651c39SIlya Yanok 	USB3_LPM_U0 = 0,
97782651c39SIlya Yanok 	USB3_LPM_U1,
97882651c39SIlya Yanok 	USB3_LPM_U2,
97982651c39SIlya Yanok 	USB3_LPM_U3
98082651c39SIlya Yanok };
98182651c39SIlya Yanok 
98282651c39SIlya Yanok /*
98382651c39SIlya Yanok  * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
98482651c39SIlya Yanok  * 0xff means the parent hub will accept transitions to U1, but will not
98582651c39SIlya Yanok  * initiate a transition.
98682651c39SIlya Yanok  *
98782651c39SIlya Yanok  * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
98882651c39SIlya Yanok  * U1 after that many microseconds.  Timeouts of 0x80 to 0xFE are reserved
98982651c39SIlya Yanok  * values.
99082651c39SIlya Yanok  *
99182651c39SIlya Yanok  * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
99282651c39SIlya Yanok  * 0xff means the parent hub will accept transitions to U2, but will not
99382651c39SIlya Yanok  * initiate a transition.
99482651c39SIlya Yanok  *
99582651c39SIlya Yanok  * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
99682651c39SIlya Yanok  * U2 after N*256 microseconds.  Therefore a U2 timeout value of 0x1 means a U2
99782651c39SIlya Yanok  * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
99882651c39SIlya Yanok  * 65.024ms.
99982651c39SIlya Yanok  */
100082651c39SIlya Yanok #define USB3_LPM_DISABLED		0x0
100182651c39SIlya Yanok #define USB3_LPM_U1_MAX_TIMEOUT		0x7F
100282651c39SIlya Yanok #define USB3_LPM_U2_MAX_TIMEOUT		0xFE
100382651c39SIlya Yanok #define USB3_LPM_DEVICE_INITIATED	0xFF
100482651c39SIlya Yanok 
100582651c39SIlya Yanok struct usb_set_sel_req {
100682651c39SIlya Yanok 	__u8	u1_sel;
100782651c39SIlya Yanok 	__u8	u1_pel;
100882651c39SIlya Yanok 	__le16	u2_sel;
100982651c39SIlya Yanok 	__le16	u2_pel;
101082651c39SIlya Yanok } __attribute__ ((packed));
101182651c39SIlya Yanok 
101282651c39SIlya Yanok /*
101382651c39SIlya Yanok  * The Set System Exit Latency control transfer provides one byte each for
101482651c39SIlya Yanok  * U1 SEL and U1 PEL, so the max exit latency is 0xFF.  U2 SEL and U2 PEL each
101582651c39SIlya Yanok  * are two bytes long.
101682651c39SIlya Yanok  */
101782651c39SIlya Yanok #define USB3_LPM_MAX_U1_SEL_PEL		0xFF
101882651c39SIlya Yanok #define USB3_LPM_MAX_U2_SEL_PEL		0xFFFF
101982651c39SIlya Yanok 
102082651c39SIlya Yanok /*-------------------------------------------------------------------------*/
102182651c39SIlya Yanok 
102282651c39SIlya Yanok /*
102382651c39SIlya Yanok  * As per USB compliance update, a device that is actively drawing
102482651c39SIlya Yanok  * more than 100mA from USB must report itself as bus-powered in
102582651c39SIlya Yanok  * the GetStatus(DEVICE) call.
102682651c39SIlya Yanok  * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
102782651c39SIlya Yanok  */
102882651c39SIlya Yanok #define USB_SELF_POWER_VBUS_MAX_DRAW		100
102982651c39SIlya Yanok 
1030f84c052aSSimon Glass /**
1031f84c052aSSimon Glass  * struct usb_string - wraps a C string and its USB id
1032f84c052aSSimon Glass  * @id:the (nonzero) ID for this string
1033f84c052aSSimon Glass  * @s:the string, in UTF-8 encoding
1034f84c052aSSimon Glass  *
1035f84c052aSSimon Glass  * If you're using usb_gadget_get_string(), use this to wrap a string
1036f84c052aSSimon Glass  * together with its ID.
1037f84c052aSSimon Glass  */
1038f84c052aSSimon Glass struct usb_string {
1039f84c052aSSimon Glass 	u8 id;
1040f84c052aSSimon Glass 	const char *s;
1041f84c052aSSimon Glass };
1042f84c052aSSimon Glass 
104323cd1385SRemy Bohmer #endif /* __LINUX_USB_CH9_H */
1044