xref: /freebsd/sys/dev/usb/usb.h (revision 51ec16035f5e79d144077df2f72f80bbee35a40b)
102ac6454SAndrew Thompson /* $FreeBSD$ */
202ac6454SAndrew Thompson /*-
302ac6454SAndrew Thompson  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
402ac6454SAndrew Thompson  * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
502ac6454SAndrew Thompson  * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
602ac6454SAndrew Thompson  *
702ac6454SAndrew Thompson  * Redistribution and use in source and binary forms, with or without
802ac6454SAndrew Thompson  * modification, are permitted provided that the following conditions
902ac6454SAndrew Thompson  * are met:
1002ac6454SAndrew Thompson  * 1. Redistributions of source code must retain the above copyright
1102ac6454SAndrew Thompson  *    notice, this list of conditions and the following disclaimer.
1202ac6454SAndrew Thompson  * 2. Redistributions in binary form must reproduce the above copyright
1302ac6454SAndrew Thompson  *    notice, this list of conditions and the following disclaimer in the
1402ac6454SAndrew Thompson  *    documentation and/or other materials provided with the distribution.
1502ac6454SAndrew Thompson  *
1602ac6454SAndrew Thompson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1702ac6454SAndrew Thompson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1802ac6454SAndrew Thompson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1902ac6454SAndrew Thompson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2002ac6454SAndrew Thompson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2102ac6454SAndrew Thompson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2202ac6454SAndrew Thompson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2302ac6454SAndrew Thompson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2402ac6454SAndrew Thompson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2502ac6454SAndrew Thompson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2602ac6454SAndrew Thompson  * SUCH DAMAGE.
2702ac6454SAndrew Thompson  */
2802ac6454SAndrew Thompson 
2902ac6454SAndrew Thompson /*
3002ac6454SAndrew Thompson  * This file contains standard definitions for the following USB
3102ac6454SAndrew Thompson  * protocol versions:
3202ac6454SAndrew Thompson  *
3302ac6454SAndrew Thompson  * USB v1.0
3402ac6454SAndrew Thompson  * USB v1.1
3502ac6454SAndrew Thompson  * USB v2.0
3602ac6454SAndrew Thompson  * USB v3.0
3702ac6454SAndrew Thompson  */
3802ac6454SAndrew Thompson 
3902ac6454SAndrew Thompson #ifndef _USB2_STANDARD_H_
4002ac6454SAndrew Thompson #define	_USB2_STANDARD_H_
4102ac6454SAndrew Thompson 
4202ac6454SAndrew Thompson #include <dev/usb/usb_endian.h>
4302ac6454SAndrew Thompson 
4402ac6454SAndrew Thompson /*
4502ac6454SAndrew Thompson  * Minimum time a device needs to be powered down to go through a
4602ac6454SAndrew Thompson  * power cycle. These values are not in the USB specification.
4702ac6454SAndrew Thompson  */
4802ac6454SAndrew Thompson #define	USB_POWER_DOWN_TIME	200	/* ms */
4902ac6454SAndrew Thompson #define	USB_PORT_POWER_DOWN_TIME	100	/* ms */
5002ac6454SAndrew Thompson 
5102ac6454SAndrew Thompson /* Definition of software USB power modes */
5202ac6454SAndrew Thompson #define	USB_POWER_MODE_OFF 0		/* turn off device */
5302ac6454SAndrew Thompson #define	USB_POWER_MODE_ON 1		/* always on */
5402ac6454SAndrew Thompson #define	USB_POWER_MODE_SAVE 2		/* automatic suspend and resume */
5502ac6454SAndrew Thompson #define	USB_POWER_MODE_SUSPEND 3	/* force suspend */
5602ac6454SAndrew Thompson #define	USB_POWER_MODE_RESUME 4		/* force resume */
5702ac6454SAndrew Thompson 
5802ac6454SAndrew Thompson #if 0
5902ac6454SAndrew Thompson /* These are the values from the USB specification. */
6002ac6454SAndrew Thompson #define	USB_PORT_RESET_DELAY	10	/* ms */
6102ac6454SAndrew Thompson #define	USB_PORT_ROOT_RESET_DELAY 50	/* ms */
6202ac6454SAndrew Thompson #define	USB_PORT_RESET_RECOVERY	10	/* ms */
6302ac6454SAndrew Thompson #define	USB_PORT_POWERUP_DELAY	100	/* ms */
6402ac6454SAndrew Thompson #define	USB_PORT_RESUME_DELAY	20	/* ms */
6502ac6454SAndrew Thompson #define	USB_SET_ADDRESS_SETTLE	2	/* ms */
6602ac6454SAndrew Thompson #define	USB_RESUME_DELAY	(20*5)	/* ms */
6702ac6454SAndrew Thompson #define	USB_RESUME_WAIT		10	/* ms */
6802ac6454SAndrew Thompson #define	USB_RESUME_RECOVERY	10	/* ms */
6902ac6454SAndrew Thompson #define	USB_EXTRA_POWER_UP_TIME	0	/* ms */
7002ac6454SAndrew Thompson #else
7102ac6454SAndrew Thompson /* Allow for marginal and non-conforming devices. */
7202ac6454SAndrew Thompson #define	USB_PORT_RESET_DELAY	50	/* ms */
7302ac6454SAndrew Thompson #define	USB_PORT_ROOT_RESET_DELAY 250	/* ms */
7402ac6454SAndrew Thompson #define	USB_PORT_RESET_RECOVERY	250	/* ms */
7502ac6454SAndrew Thompson #define	USB_PORT_POWERUP_DELAY	300	/* ms */
7602ac6454SAndrew Thompson #define	USB_PORT_RESUME_DELAY	(20*2)	/* ms */
7702ac6454SAndrew Thompson #define	USB_SET_ADDRESS_SETTLE	10	/* ms */
7802ac6454SAndrew Thompson #define	USB_RESUME_DELAY	(50*5)	/* ms */
7902ac6454SAndrew Thompson #define	USB_RESUME_WAIT		50	/* ms */
8002ac6454SAndrew Thompson #define	USB_RESUME_RECOVERY	50	/* ms */
8102ac6454SAndrew Thompson #define	USB_EXTRA_POWER_UP_TIME	20	/* ms */
8202ac6454SAndrew Thompson #endif
8302ac6454SAndrew Thompson 
8402ac6454SAndrew Thompson #define	USB_MIN_POWER		100	/* mA */
8502ac6454SAndrew Thompson #define	USB_MAX_POWER		500	/* mA */
8602ac6454SAndrew Thompson 
8702ac6454SAndrew Thompson #define	USB_BUS_RESET_DELAY	100	/* ms */
8802ac6454SAndrew Thompson 
8902ac6454SAndrew Thompson /*
9002ac6454SAndrew Thompson  * USB record layout in memory:
9102ac6454SAndrew Thompson  *
9202ac6454SAndrew Thompson  * - USB config 0
9302ac6454SAndrew Thompson  *   - USB interfaces
9402ac6454SAndrew Thompson  *     - USB alternative interfaces
9502ac6454SAndrew Thompson  *       - USB pipes
9602ac6454SAndrew Thompson  *
9702ac6454SAndrew Thompson  * - USB config 1
9802ac6454SAndrew Thompson  *   - USB interfaces
9902ac6454SAndrew Thompson  *     - USB alternative interfaces
10002ac6454SAndrew Thompson  *       - USB pipes
10102ac6454SAndrew Thompson  */
10202ac6454SAndrew Thompson 
10302ac6454SAndrew Thompson /* Declaration of USB records */
10402ac6454SAndrew Thompson 
10502ac6454SAndrew Thompson struct usb2_device_request {
10602ac6454SAndrew Thompson 	uByte	bmRequestType;
10702ac6454SAndrew Thompson 	uByte	bRequest;
10802ac6454SAndrew Thompson 	uWord	wValue;
10902ac6454SAndrew Thompson 	uWord	wIndex;
11002ac6454SAndrew Thompson 	uWord	wLength;
11102ac6454SAndrew Thompson } __packed;
112d7e3163dSAndrew Thompson typedef struct usb2_device_request usb_device_request_t;
11302ac6454SAndrew Thompson 
11402ac6454SAndrew Thompson #define	UT_WRITE		0x00
11502ac6454SAndrew Thompson #define	UT_READ			0x80
11602ac6454SAndrew Thompson #define	UT_STANDARD		0x00
11702ac6454SAndrew Thompson #define	UT_CLASS		0x20
11802ac6454SAndrew Thompson #define	UT_VENDOR		0x40
11902ac6454SAndrew Thompson #define	UT_DEVICE		0x00
12002ac6454SAndrew Thompson #define	UT_INTERFACE		0x01
12102ac6454SAndrew Thompson #define	UT_ENDPOINT		0x02
12202ac6454SAndrew Thompson #define	UT_OTHER		0x03
12302ac6454SAndrew Thompson 
12402ac6454SAndrew Thompson #define	UT_READ_DEVICE		(UT_READ  | UT_STANDARD | UT_DEVICE)
12502ac6454SAndrew Thompson #define	UT_READ_INTERFACE	(UT_READ  | UT_STANDARD | UT_INTERFACE)
12602ac6454SAndrew Thompson #define	UT_READ_ENDPOINT	(UT_READ  | UT_STANDARD | UT_ENDPOINT)
12702ac6454SAndrew Thompson #define	UT_WRITE_DEVICE		(UT_WRITE | UT_STANDARD | UT_DEVICE)
12802ac6454SAndrew Thompson #define	UT_WRITE_INTERFACE	(UT_WRITE | UT_STANDARD | UT_INTERFACE)
12902ac6454SAndrew Thompson #define	UT_WRITE_ENDPOINT	(UT_WRITE | UT_STANDARD | UT_ENDPOINT)
13002ac6454SAndrew Thompson #define	UT_READ_CLASS_DEVICE	(UT_READ  | UT_CLASS | UT_DEVICE)
13102ac6454SAndrew Thompson #define	UT_READ_CLASS_INTERFACE	(UT_READ  | UT_CLASS | UT_INTERFACE)
13202ac6454SAndrew Thompson #define	UT_READ_CLASS_OTHER	(UT_READ  | UT_CLASS | UT_OTHER)
13302ac6454SAndrew Thompson #define	UT_READ_CLASS_ENDPOINT	(UT_READ  | UT_CLASS | UT_ENDPOINT)
13402ac6454SAndrew Thompson #define	UT_WRITE_CLASS_DEVICE	(UT_WRITE | UT_CLASS | UT_DEVICE)
13502ac6454SAndrew Thompson #define	UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
13602ac6454SAndrew Thompson #define	UT_WRITE_CLASS_OTHER	(UT_WRITE | UT_CLASS | UT_OTHER)
13702ac6454SAndrew Thompson #define	UT_WRITE_CLASS_ENDPOINT	(UT_WRITE | UT_CLASS | UT_ENDPOINT)
13802ac6454SAndrew Thompson #define	UT_READ_VENDOR_DEVICE	(UT_READ  | UT_VENDOR | UT_DEVICE)
13902ac6454SAndrew Thompson #define	UT_READ_VENDOR_INTERFACE (UT_READ  | UT_VENDOR | UT_INTERFACE)
14002ac6454SAndrew Thompson #define	UT_READ_VENDOR_OTHER	(UT_READ  | UT_VENDOR | UT_OTHER)
14102ac6454SAndrew Thompson #define	UT_READ_VENDOR_ENDPOINT	(UT_READ  | UT_VENDOR | UT_ENDPOINT)
14202ac6454SAndrew Thompson #define	UT_WRITE_VENDOR_DEVICE	(UT_WRITE | UT_VENDOR | UT_DEVICE)
14302ac6454SAndrew Thompson #define	UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
14402ac6454SAndrew Thompson #define	UT_WRITE_VENDOR_OTHER	(UT_WRITE | UT_VENDOR | UT_OTHER)
14502ac6454SAndrew Thompson #define	UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
14602ac6454SAndrew Thompson 
14702ac6454SAndrew Thompson /* Requests */
14802ac6454SAndrew Thompson #define	UR_GET_STATUS		0x00
14902ac6454SAndrew Thompson #define	UR_CLEAR_FEATURE	0x01
15002ac6454SAndrew Thompson #define	UR_SET_FEATURE		0x03
15102ac6454SAndrew Thompson #define	UR_SET_ADDRESS		0x05
15202ac6454SAndrew Thompson #define	UR_GET_DESCRIPTOR	0x06
15302ac6454SAndrew Thompson #define	UDESC_DEVICE		0x01
15402ac6454SAndrew Thompson #define	UDESC_CONFIG		0x02
15502ac6454SAndrew Thompson #define	UDESC_STRING		0x03
15602ac6454SAndrew Thompson #define	USB_LANGUAGE_TABLE	0x00	/* language ID string index */
15702ac6454SAndrew Thompson #define	UDESC_INTERFACE		0x04
15802ac6454SAndrew Thompson #define	UDESC_ENDPOINT		0x05
15902ac6454SAndrew Thompson #define	UDESC_DEVICE_QUALIFIER	0x06
16002ac6454SAndrew Thompson #define	UDESC_OTHER_SPEED_CONFIGURATION 0x07
16102ac6454SAndrew Thompson #define	UDESC_INTERFACE_POWER	0x08
16202ac6454SAndrew Thompson #define	UDESC_OTG		0x09
16302ac6454SAndrew Thompson #define	UDESC_DEBUG		0x0A
16402ac6454SAndrew Thompson #define	UDESC_IFACE_ASSOC	0x0B	/* interface association */
16502ac6454SAndrew Thompson #define	UDESC_BOS		0x0F	/* binary object store */
16602ac6454SAndrew Thompson #define	UDESC_DEVICE_CAPABILITY	0x10
16702ac6454SAndrew Thompson #define	UDESC_CS_DEVICE		0x21	/* class specific */
16802ac6454SAndrew Thompson #define	UDESC_CS_CONFIG		0x22
16902ac6454SAndrew Thompson #define	UDESC_CS_STRING		0x23
17002ac6454SAndrew Thompson #define	UDESC_CS_INTERFACE	0x24
17102ac6454SAndrew Thompson #define	UDESC_CS_ENDPOINT	0x25
17202ac6454SAndrew Thompson #define	UDESC_HUB		0x29
17302ac6454SAndrew Thompson #define	UDESC_ENDPOINT_SS_COMP	0x30	/* super speed */
17402ac6454SAndrew Thompson #define	UR_SET_DESCRIPTOR	0x07
17502ac6454SAndrew Thompson #define	UR_GET_CONFIG		0x08
17602ac6454SAndrew Thompson #define	UR_SET_CONFIG		0x09
17702ac6454SAndrew Thompson #define	UR_GET_INTERFACE	0x0a
17802ac6454SAndrew Thompson #define	UR_SET_INTERFACE	0x0b
17902ac6454SAndrew Thompson #define	UR_SYNCH_FRAME		0x0c
18002ac6454SAndrew Thompson #define	UR_SET_SEL		0x30
18102ac6454SAndrew Thompson #define	UR_ISOCH_DELAY		0x31
18202ac6454SAndrew Thompson 
18302ac6454SAndrew Thompson /* HUB specific request */
18402ac6454SAndrew Thompson #define	UR_GET_BUS_STATE	0x02
18502ac6454SAndrew Thompson #define	UR_CLEAR_TT_BUFFER	0x08
18602ac6454SAndrew Thompson #define	UR_RESET_TT		0x09
18702ac6454SAndrew Thompson #define	UR_GET_TT_STATE		0x0a
18802ac6454SAndrew Thompson #define	UR_STOP_TT		0x0b
18902ac6454SAndrew Thompson #define	UR_SET_HUB_DEPTH	0x0c
19002ac6454SAndrew Thompson #define	UR_GET_PORT_ERR_COUNT	0x0d
19102ac6454SAndrew Thompson 
19202ac6454SAndrew Thompson /* Feature numbers */
19302ac6454SAndrew Thompson #define	UF_ENDPOINT_HALT	0
19402ac6454SAndrew Thompson #define	UF_DEVICE_REMOTE_WAKEUP	1
19502ac6454SAndrew Thompson #define	UF_TEST_MODE		2
19602ac6454SAndrew Thompson #define	UF_U1_ENABLE		0x30
19702ac6454SAndrew Thompson #define	UF_U2_ENABLE		0x31
19802ac6454SAndrew Thompson #define	UF_LTM_ENABLE		0x32
19902ac6454SAndrew Thompson 
20002ac6454SAndrew Thompson /* HUB specific features */
20102ac6454SAndrew Thompson #define	UHF_C_HUB_LOCAL_POWER	0
20202ac6454SAndrew Thompson #define	UHF_C_HUB_OVER_CURRENT	1
20302ac6454SAndrew Thompson #define	UHF_PORT_CONNECTION	0
20402ac6454SAndrew Thompson #define	UHF_PORT_ENABLE		1
20502ac6454SAndrew Thompson #define	UHF_PORT_SUSPEND	2
20602ac6454SAndrew Thompson #define	UHF_PORT_OVER_CURRENT	3
20702ac6454SAndrew Thompson #define	UHF_PORT_RESET		4
20802ac6454SAndrew Thompson #define	UHF_PORT_LINK_STATE	5
20902ac6454SAndrew Thompson #define	UHF_PORT_POWER		8
21002ac6454SAndrew Thompson #define	UHF_PORT_LOW_SPEED	9
21102ac6454SAndrew Thompson #define	UHF_C_PORT_CONNECTION	16
21202ac6454SAndrew Thompson #define	UHF_C_PORT_ENABLE	17
21302ac6454SAndrew Thompson #define	UHF_C_PORT_SUSPEND	18
21402ac6454SAndrew Thompson #define	UHF_C_PORT_OVER_CURRENT	19
21502ac6454SAndrew Thompson #define	UHF_C_PORT_RESET	20
21602ac6454SAndrew Thompson #define	UHF_PORT_TEST		21
21702ac6454SAndrew Thompson #define	UHF_PORT_INDICATOR	22
21802ac6454SAndrew Thompson 
21902ac6454SAndrew Thompson /* SuperSpeed HUB specific features */
22002ac6454SAndrew Thompson #define	UHF_PORT_U1_TIMEOUT	23
22102ac6454SAndrew Thompson #define	UHF_PORT_U2_TIMEOUT	24
22202ac6454SAndrew Thompson #define	UHF_C_PORT_LINK_STATE	25
22302ac6454SAndrew Thompson #define	UHF_C_PORT_CONFIG_ERROR	26
22402ac6454SAndrew Thompson #define	UHF_PORT_REMOTE_WAKE_MASK	27
22502ac6454SAndrew Thompson #define	UHF_BH_PORT_RESET	28
22602ac6454SAndrew Thompson #define	UHF_C_BH_PORT_RESET	29
22702ac6454SAndrew Thompson #define	UHF_FORCE_LINKPM_ACCEPT	30
22802ac6454SAndrew Thompson 
22902ac6454SAndrew Thompson struct usb2_descriptor {
23002ac6454SAndrew Thompson 	uByte	bLength;
23102ac6454SAndrew Thompson 	uByte	bDescriptorType;
23202ac6454SAndrew Thompson 	uByte	bDescriptorSubtype;
23302ac6454SAndrew Thompson } __packed;
234d7e3163dSAndrew Thompson typedef struct usb2_descriptor usb_descriptor_t;
23502ac6454SAndrew Thompson 
23602ac6454SAndrew Thompson struct usb2_device_descriptor {
23702ac6454SAndrew Thompson 	uByte	bLength;
23802ac6454SAndrew Thompson 	uByte	bDescriptorType;
23902ac6454SAndrew Thompson 	uWord	bcdUSB;
24002ac6454SAndrew Thompson #define	UD_USB_2_0		0x0200
24102ac6454SAndrew Thompson #define	UD_USB_3_0		0x0300
24202ac6454SAndrew Thompson #define	UD_IS_USB2(d) ((d)->bcdUSB[1] == 0x02)
24302ac6454SAndrew Thompson #define	UD_IS_USB3(d) ((d)->bcdUSB[1] == 0x03)
24402ac6454SAndrew Thompson 	uByte	bDeviceClass;
24502ac6454SAndrew Thompson 	uByte	bDeviceSubClass;
24602ac6454SAndrew Thompson 	uByte	bDeviceProtocol;
24702ac6454SAndrew Thompson 	uByte	bMaxPacketSize;
24802ac6454SAndrew Thompson 	/* The fields below are not part of the initial descriptor. */
24902ac6454SAndrew Thompson 	uWord	idVendor;
25002ac6454SAndrew Thompson 	uWord	idProduct;
25102ac6454SAndrew Thompson 	uWord	bcdDevice;
25202ac6454SAndrew Thompson 	uByte	iManufacturer;
25302ac6454SAndrew Thompson 	uByte	iProduct;
25402ac6454SAndrew Thompson 	uByte	iSerialNumber;
25502ac6454SAndrew Thompson 	uByte	bNumConfigurations;
25602ac6454SAndrew Thompson } __packed;
257d7e3163dSAndrew Thompson typedef struct usb2_device_descriptor usb_device_descriptor_t;
25802ac6454SAndrew Thompson 
25902ac6454SAndrew Thompson /* Binary Device Object Store (BOS) */
26002ac6454SAndrew Thompson struct usb2_bos_descriptor {
26102ac6454SAndrew Thompson 	uByte	bLength;
26202ac6454SAndrew Thompson 	uByte	bDescriptorType;
26302ac6454SAndrew Thompson 	uWord	wTotalLength;
26402ac6454SAndrew Thompson 	uByte	bNumDeviceCaps;
26502ac6454SAndrew Thompson } __packed;
266d7e3163dSAndrew Thompson typedef struct usb2_bos_descriptor usb_bos_descriptor_t;
26702ac6454SAndrew Thompson 
26802ac6454SAndrew Thompson /* Binary Device Object Store Capability */
26902ac6454SAndrew Thompson struct usb2_bos_cap_descriptor {
27002ac6454SAndrew Thompson 	uByte	bLength;
27102ac6454SAndrew Thompson 	uByte	bDescriptorType;
27202ac6454SAndrew Thompson 	uByte	bDevCapabilityType;
27302ac6454SAndrew Thompson #define	USB_DEVCAP_RESERVED	0x00
27402ac6454SAndrew Thompson #define	USB_DEVCAP_WUSB		0x01
27502ac6454SAndrew Thompson #define	USB_DEVCAP_USB2EXT	0x02
27602ac6454SAndrew Thompson #define	USB_DEVCAP_SUPER_SPEED	0x03
27702ac6454SAndrew Thompson #define	USB_DEVCAP_CONTAINER_ID	0x04
27802ac6454SAndrew Thompson 	/* data ... */
27902ac6454SAndrew Thompson } __packed;
280d7e3163dSAndrew Thompson typedef struct usb2_bos_cap_descriptor usb_bos_cap_descriptor_t;
28102ac6454SAndrew Thompson 
28202ac6454SAndrew Thompson struct usb2_devcap_usb2ext_descriptor {
28302ac6454SAndrew Thompson 	uByte	bLength;
28402ac6454SAndrew Thompson 	uByte	bDescriptorType;
28502ac6454SAndrew Thompson 	uByte	bDevCapabilityType;
28602ac6454SAndrew Thompson 	uByte	bmAttributes;
28702ac6454SAndrew Thompson #define	USB_V2EXT_LPM 0x02
28802ac6454SAndrew Thompson } __packed;
289d7e3163dSAndrew Thompson typedef struct usb2_devcap_usb2ext_descriptor usb_devcap_usb2ext_descriptor_t;
29002ac6454SAndrew Thompson 
29102ac6454SAndrew Thompson struct usb2_devcap_ss_descriptor {
29202ac6454SAndrew Thompson 	uByte	bLength;
29302ac6454SAndrew Thompson 	uByte	bDescriptorType;
29402ac6454SAndrew Thompson 	uByte	bDevCapabilityType;
29502ac6454SAndrew Thompson 	uByte	bmAttributes;
29602ac6454SAndrew Thompson 	uWord	wSpeedsSupported;
29702ac6454SAndrew Thompson 	uByte	bFunctionaltySupport;
29802ac6454SAndrew Thompson 	uByte	bU1DevExitLat;
29902ac6454SAndrew Thompson 	uByte	bU2DevExitLat;
30002ac6454SAndrew Thompson } __packed;
301d7e3163dSAndrew Thompson typedef struct usb2_devcap_ss_descriptor usb_devcap_ss_descriptor_t;
30202ac6454SAndrew Thompson 
30302ac6454SAndrew Thompson struct usb2_devcap_container_id_descriptor {
30402ac6454SAndrew Thompson 	uByte	bLength;
30502ac6454SAndrew Thompson 	uByte	bDescriptorType;
30602ac6454SAndrew Thompson 	uByte	bDevCapabilityType;
30702ac6454SAndrew Thompson 	uByte	bReserved;
30802ac6454SAndrew Thompson 	uByte	ContainerID;
30902ac6454SAndrew Thompson } __packed;
310d7e3163dSAndrew Thompson typedef struct usb2_devcap_container_id_descriptor
311d7e3163dSAndrew Thompson 		usb_devcap_container_id_descriptor_t;
31202ac6454SAndrew Thompson 
31302ac6454SAndrew Thompson /* Device class codes */
31402ac6454SAndrew Thompson #define	UDCLASS_IN_INTERFACE	0x00
31502ac6454SAndrew Thompson #define	UDCLASS_COMM		0x02
31602ac6454SAndrew Thompson #define	UDCLASS_HUB		0x09
31702ac6454SAndrew Thompson #define	UDSUBCLASS_HUB		0x00
31802ac6454SAndrew Thompson #define	UDPROTO_FSHUB		0x00
31902ac6454SAndrew Thompson #define	UDPROTO_HSHUBSTT	0x01
32002ac6454SAndrew Thompson #define	UDPROTO_HSHUBMTT	0x02
32102ac6454SAndrew Thompson #define	UDCLASS_DIAGNOSTIC	0xdc
32202ac6454SAndrew Thompson #define	UDCLASS_WIRELESS	0xe0
32302ac6454SAndrew Thompson #define	UDSUBCLASS_RF		0x01
32402ac6454SAndrew Thompson #define	UDPROTO_BLUETOOTH	0x01
32502ac6454SAndrew Thompson #define	UDCLASS_VENDOR		0xff
32602ac6454SAndrew Thompson 
32702ac6454SAndrew Thompson struct usb2_config_descriptor {
32802ac6454SAndrew Thompson 	uByte	bLength;
32902ac6454SAndrew Thompson 	uByte	bDescriptorType;
33002ac6454SAndrew Thompson 	uWord	wTotalLength;
33102ac6454SAndrew Thompson 	uByte	bNumInterface;
33202ac6454SAndrew Thompson 	uByte	bConfigurationValue;
33302ac6454SAndrew Thompson #define	USB_UNCONFIG_NO 0
33402ac6454SAndrew Thompson 	uByte	iConfiguration;
33502ac6454SAndrew Thompson 	uByte	bmAttributes;
33602ac6454SAndrew Thompson #define	UC_BUS_POWERED		0x80
33702ac6454SAndrew Thompson #define	UC_SELF_POWERED		0x40
33802ac6454SAndrew Thompson #define	UC_REMOTE_WAKEUP	0x20
33902ac6454SAndrew Thompson 	uByte	bMaxPower;		/* max current in 2 mA units */
34002ac6454SAndrew Thompson #define	UC_POWER_FACTOR 2
34102ac6454SAndrew Thompson } __packed;
342d7e3163dSAndrew Thompson typedef struct usb2_config_descriptor usb_config_descriptor_t;
34302ac6454SAndrew Thompson 
34402ac6454SAndrew Thompson struct usb2_interface_descriptor {
34502ac6454SAndrew Thompson 	uByte	bLength;
34602ac6454SAndrew Thompson 	uByte	bDescriptorType;
34702ac6454SAndrew Thompson 	uByte	bInterfaceNumber;
34802ac6454SAndrew Thompson 	uByte	bAlternateSetting;
34902ac6454SAndrew Thompson 	uByte	bNumEndpoints;
35002ac6454SAndrew Thompson 	uByte	bInterfaceClass;
35102ac6454SAndrew Thompson 	uByte	bInterfaceSubClass;
35202ac6454SAndrew Thompson 	uByte	bInterfaceProtocol;
35302ac6454SAndrew Thompson 	uByte	iInterface;
35402ac6454SAndrew Thompson } __packed;
355d7e3163dSAndrew Thompson typedef struct usb2_interface_descriptor usb_interface_descriptor_t;
35602ac6454SAndrew Thompson 
35702ac6454SAndrew Thompson struct usb2_interface_assoc_descriptor {
35802ac6454SAndrew Thompson 	uByte	bLength;
35902ac6454SAndrew Thompson 	uByte	bDescriptorType;
36002ac6454SAndrew Thompson 	uByte	bFirstInterface;
36102ac6454SAndrew Thompson 	uByte	bInterfaceCount;
36202ac6454SAndrew Thompson 	uByte	bFunctionClass;
36302ac6454SAndrew Thompson 	uByte	bFunctionSubClass;
36402ac6454SAndrew Thompson 	uByte	bFunctionProtocol;
36502ac6454SAndrew Thompson 	uByte	iFunction;
36602ac6454SAndrew Thompson } __packed;
367d7e3163dSAndrew Thompson typedef struct usb2_interface_assoc_descriptor usb_interface_assoc_descriptor_t;
36802ac6454SAndrew Thompson 
36902ac6454SAndrew Thompson /* Interface class codes */
37002ac6454SAndrew Thompson #define	UICLASS_UNSPEC		0x00
37102ac6454SAndrew Thompson #define	UICLASS_AUDIO		0x01	/* audio */
37202ac6454SAndrew Thompson #define	UISUBCLASS_AUDIOCONTROL	1
37302ac6454SAndrew Thompson #define	UISUBCLASS_AUDIOSTREAM		2
37402ac6454SAndrew Thompson #define	UISUBCLASS_MIDISTREAM		3
37502ac6454SAndrew Thompson 
37602ac6454SAndrew Thompson #define	UICLASS_CDC		0x02	/* communication */
37702ac6454SAndrew Thompson #define	UISUBCLASS_DIRECT_LINE_CONTROL_MODEL	1
37802ac6454SAndrew Thompson #define	UISUBCLASS_ABSTRACT_CONTROL_MODEL	2
37902ac6454SAndrew Thompson #define	UISUBCLASS_TELEPHONE_CONTROL_MODEL	3
38002ac6454SAndrew Thompson #define	UISUBCLASS_MULTICHANNEL_CONTROL_MODEL	4
38102ac6454SAndrew Thompson #define	UISUBCLASS_CAPI_CONTROLMODEL		5
38202ac6454SAndrew Thompson #define	UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
38302ac6454SAndrew Thompson #define	UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
38402ac6454SAndrew Thompson #define	UISUBCLASS_WIRELESS_HANDSET_CM 8
38502ac6454SAndrew Thompson #define	UISUBCLASS_DEVICE_MGMT 9
38602ac6454SAndrew Thompson #define	UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10
38702ac6454SAndrew Thompson #define	UISUBCLASS_OBEX 11
38802ac6454SAndrew Thompson #define	UISUBCLASS_ETHERNET_EMULATION_MODEL 12
38902ac6454SAndrew Thompson 
39002ac6454SAndrew Thompson #define	UIPROTO_CDC_AT			1
39102ac6454SAndrew Thompson #define	UIPROTO_CDC_ETH_512X4 0x76	/* FreeBSD specific */
39202ac6454SAndrew Thompson 
39302ac6454SAndrew Thompson #define	UICLASS_HID		0x03
39402ac6454SAndrew Thompson #define	UISUBCLASS_BOOT		1
39502ac6454SAndrew Thompson #define	UIPROTO_BOOT_KEYBOARD	1
39602ac6454SAndrew Thompson #define	UIPROTO_MOUSE		2
39702ac6454SAndrew Thompson 
39802ac6454SAndrew Thompson #define	UICLASS_PHYSICAL	0x05
39902ac6454SAndrew Thompson #define	UICLASS_IMAGE		0x06
40002ac6454SAndrew Thompson #define	UISUBCLASS_SIC		1	/* still image class */
40102ac6454SAndrew Thompson #define	UICLASS_PRINTER		0x07
40202ac6454SAndrew Thompson #define	UISUBCLASS_PRINTER	1
40302ac6454SAndrew Thompson #define	UIPROTO_PRINTER_UNI	1
40402ac6454SAndrew Thompson #define	UIPROTO_PRINTER_BI	2
40502ac6454SAndrew Thompson #define	UIPROTO_PRINTER_1284	3
40602ac6454SAndrew Thompson 
40702ac6454SAndrew Thompson #define	UICLASS_MASS		0x08
40802ac6454SAndrew Thompson #define	UISUBCLASS_RBC		1
40902ac6454SAndrew Thompson #define	UISUBCLASS_SFF8020I	2
41002ac6454SAndrew Thompson #define	UISUBCLASS_QIC157	3
41102ac6454SAndrew Thompson #define	UISUBCLASS_UFI		4
41202ac6454SAndrew Thompson #define	UISUBCLASS_SFF8070I	5
41302ac6454SAndrew Thompson #define	UISUBCLASS_SCSI		6
41402ac6454SAndrew Thompson #define	UIPROTO_MASS_CBI_I	0
41502ac6454SAndrew Thompson #define	UIPROTO_MASS_CBI	1
41602ac6454SAndrew Thompson #define	UIPROTO_MASS_BBB_OLD	2	/* Not in the spec anymore */
41702ac6454SAndrew Thompson #define	UIPROTO_MASS_BBB	80	/* 'P' for the Iomega Zip drive */
41802ac6454SAndrew Thompson 
41902ac6454SAndrew Thompson #define	UICLASS_HUB		0x09
42002ac6454SAndrew Thompson #define	UISUBCLASS_HUB		0
42102ac6454SAndrew Thompson #define	UIPROTO_FSHUB		0
42202ac6454SAndrew Thompson #define	UIPROTO_HSHUBSTT	0	/* Yes, same as previous */
42302ac6454SAndrew Thompson #define	UIPROTO_HSHUBMTT	1
42402ac6454SAndrew Thompson 
42502ac6454SAndrew Thompson #define	UICLASS_CDC_DATA	0x0a
42602ac6454SAndrew Thompson #define	UISUBCLASS_DATA		0
42702ac6454SAndrew Thompson #define	UIPROTO_DATA_ISDNBRI		0x30	/* Physical iface */
42802ac6454SAndrew Thompson #define	UIPROTO_DATA_HDLC		0x31	/* HDLC */
42902ac6454SAndrew Thompson #define	UIPROTO_DATA_TRANSPARENT	0x32	/* Transparent */
43002ac6454SAndrew Thompson #define	UIPROTO_DATA_Q921M		0x50	/* Management for Q921 */
43102ac6454SAndrew Thompson #define	UIPROTO_DATA_Q921		0x51	/* Data for Q921 */
43202ac6454SAndrew Thompson #define	UIPROTO_DATA_Q921TM		0x52	/* TEI multiplexer for Q921 */
43302ac6454SAndrew Thompson #define	UIPROTO_DATA_V42BIS		0x90	/* Data compression */
43402ac6454SAndrew Thompson #define	UIPROTO_DATA_Q931		0x91	/* Euro-ISDN */
43502ac6454SAndrew Thompson #define	UIPROTO_DATA_V120		0x92	/* V.24 rate adaption */
43602ac6454SAndrew Thompson #define	UIPROTO_DATA_CAPI		0x93	/* CAPI 2.0 commands */
43702ac6454SAndrew Thompson #define	UIPROTO_DATA_HOST_BASED		0xfd	/* Host based driver */
43802ac6454SAndrew Thompson #define	UIPROTO_DATA_PUF		0xfe	/* see Prot. Unit Func. Desc. */
43902ac6454SAndrew Thompson #define	UIPROTO_DATA_VENDOR		0xff	/* Vendor specific */
44002ac6454SAndrew Thompson 
44102ac6454SAndrew Thompson #define	UICLASS_SMARTCARD	0x0b
44202ac6454SAndrew Thompson #define	UICLASS_FIRM_UPD	0x0c
44302ac6454SAndrew Thompson #define	UICLASS_SECURITY	0x0d
44402ac6454SAndrew Thompson #define	UICLASS_DIAGNOSTIC	0xdc
44502ac6454SAndrew Thompson #define	UICLASS_WIRELESS	0xe0
44602ac6454SAndrew Thompson #define	UISUBCLASS_RF			0x01
44702ac6454SAndrew Thompson #define	UIPROTO_BLUETOOTH		0x01
44802ac6454SAndrew Thompson 
44902ac6454SAndrew Thompson #define	UICLASS_APPL_SPEC	0xfe
45002ac6454SAndrew Thompson #define	UISUBCLASS_FIRMWARE_DOWNLOAD	1
45102ac6454SAndrew Thompson #define	UISUBCLASS_IRDA			2
45202ac6454SAndrew Thompson #define	UIPROTO_IRDA			0
45302ac6454SAndrew Thompson 
45402ac6454SAndrew Thompson #define	UICLASS_VENDOR		0xff
45502ac6454SAndrew Thompson #define	UISUBCLASS_XBOX360_CONTROLLER	0x5d
45602ac6454SAndrew Thompson #define	UIPROTO_XBOX360_GAMEPAD	0x01
45702ac6454SAndrew Thompson 
45802ac6454SAndrew Thompson struct usb2_endpoint_descriptor {
45902ac6454SAndrew Thompson 	uByte	bLength;
46002ac6454SAndrew Thompson 	uByte	bDescriptorType;
46102ac6454SAndrew Thompson 	uByte	bEndpointAddress;
46202ac6454SAndrew Thompson #define	UE_GET_DIR(a)	((a) & 0x80)
46302ac6454SAndrew Thompson #define	UE_SET_DIR(a,d)	((a) | (((d)&1) << 7))
46451ec1603SAndrew Thompson #define	UE_DIR_IN	0x80		/* IN-token endpoint, fixed */
46551ec1603SAndrew Thompson #define	UE_DIR_OUT	0x00		/* OUT-token endpoint, fixed */
46651ec1603SAndrew Thompson #define	UE_DIR_RX	0xfd		/* for internal use only! */
46751ec1603SAndrew Thompson #define	UE_DIR_TX	0xfe		/* for internal use only! */
46802ac6454SAndrew Thompson #define	UE_DIR_ANY	0xff		/* for internal use only! */
46902ac6454SAndrew Thompson #define	UE_ADDR		0x0f
47002ac6454SAndrew Thompson #define	UE_ADDR_ANY	0xff		/* for internal use only! */
47102ac6454SAndrew Thompson #define	UE_GET_ADDR(a)	((a) & UE_ADDR)
47202ac6454SAndrew Thompson 	uByte	bmAttributes;
47302ac6454SAndrew Thompson #define	UE_XFERTYPE	0x03
47402ac6454SAndrew Thompson #define	UE_CONTROL	0x00
47502ac6454SAndrew Thompson #define	UE_ISOCHRONOUS	0x01
47602ac6454SAndrew Thompson #define	UE_BULK	0x02
47702ac6454SAndrew Thompson #define	UE_INTERRUPT	0x03
47802ac6454SAndrew Thompson #define	UE_BULK_INTR	0xfe		/* for internal use only! */
47902ac6454SAndrew Thompson #define	UE_TYPE_ANY	0xff		/* for internal use only! */
48002ac6454SAndrew Thompson #define	UE_GET_XFERTYPE(a)	((a) & UE_XFERTYPE)
48102ac6454SAndrew Thompson #define	UE_ISO_TYPE	0x0c
48202ac6454SAndrew Thompson #define	UE_ISO_ASYNC	0x04
48302ac6454SAndrew Thompson #define	UE_ISO_ADAPT	0x08
48402ac6454SAndrew Thompson #define	UE_ISO_SYNC	0x0c
48502ac6454SAndrew Thompson #define	UE_GET_ISO_TYPE(a)	((a) & UE_ISO_TYPE)
48602ac6454SAndrew Thompson 	uWord	wMaxPacketSize;
48702ac6454SAndrew Thompson #define	UE_ZERO_MPS 0xFFFF		/* for internal use only */
48802ac6454SAndrew Thompson 	uByte	bInterval;
48902ac6454SAndrew Thompson } __packed;
490d7e3163dSAndrew Thompson typedef struct usb2_endpoint_descriptor usb_endpoint_descriptor_t;
49102ac6454SAndrew Thompson 
49202ac6454SAndrew Thompson struct usb2_endpoint_ss_comp_descriptor {
49302ac6454SAndrew Thompson 	uByte	bLength;
49402ac6454SAndrew Thompson 	uByte	bDescriptorType;
49502ac6454SAndrew Thompson 	uWord	bMaxBurst;
49602ac6454SAndrew Thompson 	uByte	bmAttributes;
49702ac6454SAndrew Thompson 	uWord	wBytesPerInterval;
49802ac6454SAndrew Thompson } __packed;
499d7e3163dSAndrew Thompson typedef struct usb2_endpoint_ss_comp_descriptor
500d7e3163dSAndrew Thompson 		usb_endpoint_ss_comp_descriptor_t;
50102ac6454SAndrew Thompson 
50202ac6454SAndrew Thompson struct usb2_string_descriptor {
50302ac6454SAndrew Thompson 	uByte	bLength;
50402ac6454SAndrew Thompson 	uByte	bDescriptorType;
50502ac6454SAndrew Thompson 	uWord	bString[126];
50602ac6454SAndrew Thompson 	uByte	bUnused;
50702ac6454SAndrew Thompson } __packed;
508d7e3163dSAndrew Thompson typedef struct usb2_string_descriptor usb_string_descriptor_t;
50902ac6454SAndrew Thompson 
51002ac6454SAndrew Thompson #define	USB_MAKE_STRING_DESC(m,name)	\
51102ac6454SAndrew Thompson struct name {				\
51202ac6454SAndrew Thompson   uByte bLength;			\
51302ac6454SAndrew Thompson   uByte bDescriptorType;		\
51402ac6454SAndrew Thompson   uByte bData[sizeof((uint8_t []){m})];	\
51502ac6454SAndrew Thompson } __packed;				\
51602ac6454SAndrew Thompson static const struct name name = {	\
51702ac6454SAndrew Thompson   .bLength = sizeof(struct name),	\
51802ac6454SAndrew Thompson   .bDescriptorType = UDESC_STRING,	\
51902ac6454SAndrew Thompson   .bData = { m },			\
52002ac6454SAndrew Thompson }
52102ac6454SAndrew Thompson 
52202ac6454SAndrew Thompson struct usb2_hub_descriptor {
52302ac6454SAndrew Thompson 	uByte	bDescLength;
52402ac6454SAndrew Thompson 	uByte	bDescriptorType;
52502ac6454SAndrew Thompson 	uByte	bNbrPorts;
52602ac6454SAndrew Thompson 	uWord	wHubCharacteristics;
52702ac6454SAndrew Thompson #define	UHD_PWR			0x0003
52802ac6454SAndrew Thompson #define	UHD_PWR_GANGED		0x0000
52902ac6454SAndrew Thompson #define	UHD_PWR_INDIVIDUAL	0x0001
53002ac6454SAndrew Thompson #define	UHD_PWR_NO_SWITCH	0x0002
53102ac6454SAndrew Thompson #define	UHD_COMPOUND		0x0004
53202ac6454SAndrew Thompson #define	UHD_OC			0x0018
53302ac6454SAndrew Thompson #define	UHD_OC_GLOBAL		0x0000
53402ac6454SAndrew Thompson #define	UHD_OC_INDIVIDUAL	0x0008
53502ac6454SAndrew Thompson #define	UHD_OC_NONE		0x0010
53602ac6454SAndrew Thompson #define	UHD_TT_THINK		0x0060
53702ac6454SAndrew Thompson #define	UHD_TT_THINK_8		0x0000
53802ac6454SAndrew Thompson #define	UHD_TT_THINK_16		0x0020
53902ac6454SAndrew Thompson #define	UHD_TT_THINK_24		0x0040
54002ac6454SAndrew Thompson #define	UHD_TT_THINK_32		0x0060
54102ac6454SAndrew Thompson #define	UHD_PORT_IND		0x0080
54202ac6454SAndrew Thompson 	uByte	bPwrOn2PwrGood;		/* delay in 2 ms units */
54302ac6454SAndrew Thompson #define	UHD_PWRON_FACTOR 2
54402ac6454SAndrew Thompson 	uByte	bHubContrCurrent;
54502ac6454SAndrew Thompson 	uByte	DeviceRemovable[32];	/* max 255 ports */
54602ac6454SAndrew Thompson #define	UHD_NOT_REMOV(desc, i) \
54702ac6454SAndrew Thompson     (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
54802ac6454SAndrew Thompson 	uByte	PortPowerCtrlMask[1];	/* deprecated */
54902ac6454SAndrew Thompson } __packed;
550d7e3163dSAndrew Thompson typedef struct usb2_hub_descriptor usb_hub_descriptor_t;
55102ac6454SAndrew Thompson 
55202ac6454SAndrew Thompson struct usb2_hub_ss_descriptor {
55302ac6454SAndrew Thompson 	uByte	bDescLength;
55402ac6454SAndrew Thompson 	uByte	bDescriptorType;
55502ac6454SAndrew Thompson 	uByte	bNbrPorts;		/* max 15 */
55602ac6454SAndrew Thompson 	uWord	wHubCharacteristics;
55702ac6454SAndrew Thompson 	uByte	bPwrOn2PwrGood;		/* delay in 2 ms units */
55802ac6454SAndrew Thompson 	uByte	bHubContrCurrent;
55902ac6454SAndrew Thompson 	uByte	bHubHdrDecLat;
56002ac6454SAndrew Thompson 	uWord	wHubDelay;
56102ac6454SAndrew Thompson 	uByte	DeviceRemovable[2];	/* max 15 ports */
56202ac6454SAndrew Thompson } __packed;
563d7e3163dSAndrew Thompson typedef struct usb2_hub_ss_descriptor usb_hub_ss_descriptor_t;
56402ac6454SAndrew Thompson 
56502ac6454SAndrew Thompson /* minimum HUB descriptor (8-ports maximum) */
56602ac6454SAndrew Thompson struct usb2_hub_descriptor_min {
56702ac6454SAndrew Thompson 	uByte	bDescLength;
56802ac6454SAndrew Thompson 	uByte	bDescriptorType;
56902ac6454SAndrew Thompson 	uByte	bNbrPorts;
57002ac6454SAndrew Thompson 	uWord	wHubCharacteristics;
57102ac6454SAndrew Thompson 	uByte	bPwrOn2PwrGood;
57202ac6454SAndrew Thompson 	uByte	bHubContrCurrent;
57302ac6454SAndrew Thompson 	uByte	DeviceRemovable[1];
57402ac6454SAndrew Thompson 	uByte	PortPowerCtrlMask[1];
57502ac6454SAndrew Thompson } __packed;
576d7e3163dSAndrew Thompson typedef struct usb2_hub_descriptor_min usb_hub_descriptor_min_t;
57702ac6454SAndrew Thompson 
57802ac6454SAndrew Thompson struct usb2_device_qualifier {
57902ac6454SAndrew Thompson 	uByte	bLength;
58002ac6454SAndrew Thompson 	uByte	bDescriptorType;
58102ac6454SAndrew Thompson 	uWord	bcdUSB;
58202ac6454SAndrew Thompson 	uByte	bDeviceClass;
58302ac6454SAndrew Thompson 	uByte	bDeviceSubClass;
58402ac6454SAndrew Thompson 	uByte	bDeviceProtocol;
58502ac6454SAndrew Thompson 	uByte	bMaxPacketSize0;
58602ac6454SAndrew Thompson 	uByte	bNumConfigurations;
58702ac6454SAndrew Thompson 	uByte	bReserved;
58802ac6454SAndrew Thompson } __packed;
589d7e3163dSAndrew Thompson typedef struct usb2_device_qualifier usb_device_qualifier_t;
59002ac6454SAndrew Thompson 
59102ac6454SAndrew Thompson struct usb2_otg_descriptor {
59202ac6454SAndrew Thompson 	uByte	bLength;
59302ac6454SAndrew Thompson 	uByte	bDescriptorType;
59402ac6454SAndrew Thompson 	uByte	bmAttributes;
59502ac6454SAndrew Thompson #define	UOTG_SRP	0x01
59602ac6454SAndrew Thompson #define	UOTG_HNP	0x02
59702ac6454SAndrew Thompson } __packed;
598d7e3163dSAndrew Thompson typedef struct usb2_otg_descriptor usb_otg_descriptor_t;
59902ac6454SAndrew Thompson 
60002ac6454SAndrew Thompson /* OTG feature selectors */
60102ac6454SAndrew Thompson #define	UOTG_B_HNP_ENABLE	3
60202ac6454SAndrew Thompson #define	UOTG_A_HNP_SUPPORT	4
60302ac6454SAndrew Thompson #define	UOTG_A_ALT_HNP_SUPPORT	5
60402ac6454SAndrew Thompson 
60502ac6454SAndrew Thompson struct usb2_status {
60602ac6454SAndrew Thompson 	uWord	wStatus;
60702ac6454SAndrew Thompson /* Device status flags */
60802ac6454SAndrew Thompson #define	UDS_SELF_POWERED		0x0001
60902ac6454SAndrew Thompson #define	UDS_REMOTE_WAKEUP		0x0002
61002ac6454SAndrew Thompson /* Endpoint status flags */
61102ac6454SAndrew Thompson #define	UES_HALT			0x0001
61202ac6454SAndrew Thompson } __packed;
613d7e3163dSAndrew Thompson typedef struct usb2_status usb_status_t;
61402ac6454SAndrew Thompson 
61502ac6454SAndrew Thompson struct usb2_hub_status {
61602ac6454SAndrew Thompson 	uWord	wHubStatus;
61702ac6454SAndrew Thompson #define	UHS_LOCAL_POWER			0x0001
61802ac6454SAndrew Thompson #define	UHS_OVER_CURRENT		0x0002
61902ac6454SAndrew Thompson 	uWord	wHubChange;
62002ac6454SAndrew Thompson } __packed;
621d7e3163dSAndrew Thompson typedef struct usb2_hub_status usb_hub_status_t;
62202ac6454SAndrew Thompson 
62302ac6454SAndrew Thompson struct usb2_port_status {
62402ac6454SAndrew Thompson 	uWord	wPortStatus;
62502ac6454SAndrew Thompson #define	UPS_CURRENT_CONNECT_STATUS	0x0001
62602ac6454SAndrew Thompson #define	UPS_PORT_ENABLED		0x0002
62702ac6454SAndrew Thompson #define	UPS_SUSPEND			0x0004
62802ac6454SAndrew Thompson #define	UPS_OVERCURRENT_INDICATOR	0x0008
62902ac6454SAndrew Thompson #define	UPS_RESET			0x0010
63002ac6454SAndrew Thompson #define	UPS_PORT_POWER			0x0100
63102ac6454SAndrew Thompson #define	UPS_LOW_SPEED			0x0200
63202ac6454SAndrew Thompson #define	UPS_HIGH_SPEED			0x0400
63302ac6454SAndrew Thompson #define	UPS_PORT_TEST			0x0800
63402ac6454SAndrew Thompson #define	UPS_PORT_INDICATOR		0x1000
63502ac6454SAndrew Thompson #define	UPS_PORT_MODE_DEVICE		0x8000	/* currently FreeBSD specific */
63602ac6454SAndrew Thompson 	uWord	wPortChange;
63702ac6454SAndrew Thompson #define	UPS_C_CONNECT_STATUS		0x0001
63802ac6454SAndrew Thompson #define	UPS_C_PORT_ENABLED		0x0002
63902ac6454SAndrew Thompson #define	UPS_C_SUSPEND			0x0004
64002ac6454SAndrew Thompson #define	UPS_C_OVERCURRENT_INDICATOR	0x0008
64102ac6454SAndrew Thompson #define	UPS_C_PORT_RESET		0x0010
64202ac6454SAndrew Thompson } __packed;
643d7e3163dSAndrew Thompson typedef struct usb2_port_status usb_port_status_t;
64402ac6454SAndrew Thompson 
64502ac6454SAndrew Thompson #endif					/* _USB2_STANDARD_H_ */
646