usb.h revision 186730
1/* $FreeBSD: head/sys/dev/usb2/include/usb2_standard.h 186730 2009-01-04 00:12:01Z alfred $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
5 * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29/*
30 * This file contains standard definitions for the following USB
31 * protocol versions:
32 *
33 * USB v1.0
34 * USB v1.1
35 * USB v2.0
36 * USB v3.0
37 */
38
39#ifndef _USB2_STANDARD_H_
40#define	_USB2_STANDARD_H_
41
42#include <dev/usb2/include/usb2_endian.h>
43
44/*
45 * Minimum time a device needs to be powered down to go through a
46 * power cycle. These values are not in the USB specification.
47 */
48#define	USB_POWER_DOWN_TIME	200	/* ms */
49#define	USB_PORT_POWER_DOWN_TIME	100	/* ms */
50
51/* Definition of software USB power modes */
52#define	USB_POWER_MODE_OFF 0		/* turn off device */
53#define	USB_POWER_MODE_ON 1		/* always on */
54#define	USB_POWER_MODE_SAVE 2		/* automatic suspend and resume */
55#define	USB_POWER_MODE_SUSPEND 3	/* force suspend */
56#define	USB_POWER_MODE_RESUME 4		/* force resume */
57
58#if 0
59/* These are the values from the USB specification. */
60#define	USB_PORT_RESET_DELAY	10	/* ms */
61#define	USB_PORT_ROOT_RESET_DELAY 50	/* ms */
62#define	USB_PORT_RESET_RECOVERY	10	/* ms */
63#define	USB_PORT_POWERUP_DELAY	100	/* ms */
64#define	USB_PORT_RESUME_DELAY	20	/* ms */
65#define	USB_SET_ADDRESS_SETTLE	2	/* ms */
66#define	USB_RESUME_DELAY	(20*5)	/* ms */
67#define	USB_RESUME_WAIT		10	/* ms */
68#define	USB_RESUME_RECOVERY	10	/* ms */
69#define	USB_EXTRA_POWER_UP_TIME	0	/* ms */
70#else
71/* Allow for marginal and non-conforming devices. */
72#define	USB_PORT_RESET_DELAY	50	/* ms */
73#define	USB_PORT_ROOT_RESET_DELAY 250	/* ms */
74#define	USB_PORT_RESET_RECOVERY	250	/* ms */
75#define	USB_PORT_POWERUP_DELAY	300	/* ms */
76#define	USB_PORT_RESUME_DELAY	(20*2)	/* ms */
77#define	USB_SET_ADDRESS_SETTLE	10	/* ms */
78#define	USB_RESUME_DELAY	(50*5)	/* ms */
79#define	USB_RESUME_WAIT		50	/* ms */
80#define	USB_RESUME_RECOVERY	50	/* ms */
81#define	USB_EXTRA_POWER_UP_TIME	20	/* ms */
82#endif
83
84#define	USB_MIN_POWER		100	/* mA */
85#define	USB_MAX_POWER		500	/* mA */
86
87#define	USB_BUS_RESET_DELAY	100	/* ms */
88
89/*
90 * USB record layout in memory:
91 *
92 * - USB config 0
93 *   - USB interfaces
94 *     - USB alternative interfaces
95 *       - USB pipes
96 *
97 * - USB config 1
98 *   - USB interfaces
99 *     - USB alternative interfaces
100 *       - USB pipes
101 */
102
103/* Declaration of USB records */
104
105struct usb2_device_request {
106	uByte	bmRequestType;
107	uByte	bRequest;
108	uWord	wValue;
109	uWord	wIndex;
110	uWord	wLength;
111} __packed;
112
113#define	UT_WRITE		0x00
114#define	UT_READ			0x80
115#define	UT_STANDARD		0x00
116#define	UT_CLASS		0x20
117#define	UT_VENDOR		0x40
118#define	UT_DEVICE		0x00
119#define	UT_INTERFACE		0x01
120#define	UT_ENDPOINT		0x02
121#define	UT_OTHER		0x03
122
123#define	UT_READ_DEVICE		(UT_READ  | UT_STANDARD | UT_DEVICE)
124#define	UT_READ_INTERFACE	(UT_READ  | UT_STANDARD | UT_INTERFACE)
125#define	UT_READ_ENDPOINT	(UT_READ  | UT_STANDARD | UT_ENDPOINT)
126#define	UT_WRITE_DEVICE		(UT_WRITE | UT_STANDARD | UT_DEVICE)
127#define	UT_WRITE_INTERFACE	(UT_WRITE | UT_STANDARD | UT_INTERFACE)
128#define	UT_WRITE_ENDPOINT	(UT_WRITE | UT_STANDARD | UT_ENDPOINT)
129#define	UT_READ_CLASS_DEVICE	(UT_READ  | UT_CLASS | UT_DEVICE)
130#define	UT_READ_CLASS_INTERFACE	(UT_READ  | UT_CLASS | UT_INTERFACE)
131#define	UT_READ_CLASS_OTHER	(UT_READ  | UT_CLASS | UT_OTHER)
132#define	UT_READ_CLASS_ENDPOINT	(UT_READ  | UT_CLASS | UT_ENDPOINT)
133#define	UT_WRITE_CLASS_DEVICE	(UT_WRITE | UT_CLASS | UT_DEVICE)
134#define	UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
135#define	UT_WRITE_CLASS_OTHER	(UT_WRITE | UT_CLASS | UT_OTHER)
136#define	UT_WRITE_CLASS_ENDPOINT	(UT_WRITE | UT_CLASS | UT_ENDPOINT)
137#define	UT_READ_VENDOR_DEVICE	(UT_READ  | UT_VENDOR | UT_DEVICE)
138#define	UT_READ_VENDOR_INTERFACE (UT_READ  | UT_VENDOR | UT_INTERFACE)
139#define	UT_READ_VENDOR_OTHER	(UT_READ  | UT_VENDOR | UT_OTHER)
140#define	UT_READ_VENDOR_ENDPOINT	(UT_READ  | UT_VENDOR | UT_ENDPOINT)
141#define	UT_WRITE_VENDOR_DEVICE	(UT_WRITE | UT_VENDOR | UT_DEVICE)
142#define	UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
143#define	UT_WRITE_VENDOR_OTHER	(UT_WRITE | UT_VENDOR | UT_OTHER)
144#define	UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
145
146/* Requests */
147#define	UR_GET_STATUS		0x00
148#define	UR_CLEAR_FEATURE	0x01
149#define	UR_SET_FEATURE		0x03
150#define	UR_SET_ADDRESS		0x05
151#define	UR_GET_DESCRIPTOR	0x06
152#define	UDESC_DEVICE		0x01
153#define	UDESC_CONFIG		0x02
154#define	UDESC_STRING		0x03
155#define	USB_LANGUAGE_TABLE	0x00	/* language ID string index */
156#define	UDESC_INTERFACE		0x04
157#define	UDESC_ENDPOINT		0x05
158#define	UDESC_DEVICE_QUALIFIER	0x06
159#define	UDESC_OTHER_SPEED_CONFIGURATION 0x07
160#define	UDESC_INTERFACE_POWER	0x08
161#define	UDESC_OTG		0x09
162#define	UDESC_DEBUG		0x0A
163#define	UDESC_IFACE_ASSOC	0x0B	/* interface association */
164#define	UDESC_BOS		0x0F	/* binary object store */
165#define	UDESC_DEVICE_CAPABILITY	0x10
166#define	UDESC_CS_DEVICE		0x21	/* class specific */
167#define	UDESC_CS_CONFIG		0x22
168#define	UDESC_CS_STRING		0x23
169#define	UDESC_CS_INTERFACE	0x24
170#define	UDESC_CS_ENDPOINT	0x25
171#define	UDESC_HUB		0x29
172#define	UDESC_ENDPOINT_SS_COMP	0x30	/* super speed */
173#define	UR_SET_DESCRIPTOR	0x07
174#define	UR_GET_CONFIG		0x08
175#define	UR_SET_CONFIG		0x09
176#define	UR_GET_INTERFACE	0x0a
177#define	UR_SET_INTERFACE	0x0b
178#define	UR_SYNCH_FRAME		0x0c
179#define	UR_SET_SEL		0x30
180#define	UR_ISOCH_DELAY		0x31
181
182/* HUB specific request */
183#define	UR_GET_BUS_STATE	0x02
184#define	UR_CLEAR_TT_BUFFER	0x08
185#define	UR_RESET_TT		0x09
186#define	UR_GET_TT_STATE		0x0a
187#define	UR_STOP_TT		0x0b
188#define	UR_SET_HUB_DEPTH	0x0c
189#define	UR_GET_PORT_ERR_COUNT	0x0d
190
191/* Feature numbers */
192#define	UF_ENDPOINT_HALT	0
193#define	UF_DEVICE_REMOTE_WAKEUP	1
194#define	UF_TEST_MODE		2
195#define	UF_U1_ENABLE		0x30
196#define	UF_U2_ENABLE		0x31
197#define	UF_LTM_ENABLE		0x32
198
199/* HUB specific features */
200#define	UHF_C_HUB_LOCAL_POWER	0
201#define	UHF_C_HUB_OVER_CURRENT	1
202#define	UHF_PORT_CONNECTION	0
203#define	UHF_PORT_ENABLE		1
204#define	UHF_PORT_SUSPEND	2
205#define	UHF_PORT_OVER_CURRENT	3
206#define	UHF_PORT_RESET		4
207#define	UHF_PORT_LINK_STATE	5
208#define	UHF_PORT_POWER		8
209#define	UHF_PORT_LOW_SPEED	9
210#define	UHF_C_PORT_CONNECTION	16
211#define	UHF_C_PORT_ENABLE	17
212#define	UHF_C_PORT_SUSPEND	18
213#define	UHF_C_PORT_OVER_CURRENT	19
214#define	UHF_C_PORT_RESET	20
215#define	UHF_PORT_TEST		21
216#define	UHF_PORT_INDICATOR	22
217
218/* SuperSpeed HUB specific features */
219#define	UHF_PORT_U1_TIMEOUT	23
220#define	UHF_PORT_U2_TIMEOUT	24
221#define	UHF_C_PORT_LINK_STATE	25
222#define	UHF_C_PORT_CONFIG_ERROR	26
223#define	UHF_PORT_REMOTE_WAKE_MASK	27
224#define	UHF_BH_PORT_RESET	28
225#define	UHF_C_BH_PORT_RESET	29
226#define	UHF_FORCE_LINKPM_ACCEPT	30
227
228struct usb2_descriptor {
229	uByte	bLength;
230	uByte	bDescriptorType;
231	uByte	bDescriptorSubtype;
232} __packed;
233
234struct usb2_device_descriptor {
235	uByte	bLength;
236	uByte	bDescriptorType;
237	uWord	bcdUSB;
238#define	UD_USB_2_0		0x0200
239#define	UD_USB_3_0		0x0300
240#define	UD_IS_USB2(d) ((d)->bcdUSB[1] == 0x02)
241#define	UD_IS_USB3(d) ((d)->bcdUSB[1] == 0x03)
242	uByte	bDeviceClass;
243	uByte	bDeviceSubClass;
244	uByte	bDeviceProtocol;
245	uByte	bMaxPacketSize;
246	/* The fields below are not part of the initial descriptor. */
247	uWord	idVendor;
248	uWord	idProduct;
249	uWord	bcdDevice;
250	uByte	iManufacturer;
251	uByte	iProduct;
252	uByte	iSerialNumber;
253	uByte	bNumConfigurations;
254} __packed;
255
256/* Binary Device Object Store (BOS) */
257struct usb2_bos_descriptor {
258	uByte	bLength;
259	uByte	bDescriptorType;
260	uWord	wTotalLength;
261	uByte	bNumDeviceCaps;
262} __packed;
263
264/* Binary Device Object Store Capability */
265struct usb2_bos_cap_descriptor {
266	uByte	bLength;
267	uByte	bDescriptorType;
268	uByte	bDevCapabilityType;
269#define	USB_DEVCAP_RESERVED	0x00
270#define	USB_DEVCAP_WUSB		0x01
271#define	USB_DEVCAP_USB2EXT	0x02
272#define	USB_DEVCAP_SUPER_SPEED	0x03
273#define	USB_DEVCAP_CONTAINER_ID	0x04
274	/* data ... */
275} __packed;
276
277struct usb2_devcap_usb2ext_descriptor {
278	uByte	bLength;
279	uByte	bDescriptorType;
280	uByte	bDevCapabilityType;
281	uByte	bmAttributes;
282#define	USB_V2EXT_LPM 0x02
283} __packed;
284
285struct usb2_devcap_ss_descriptor {
286	uByte	bLength;
287	uByte	bDescriptorType;
288	uByte	bDevCapabilityType;
289	uByte	bmAttributes;
290	uWord	wSpeedsSupported;
291	uByte	bFunctionaltySupport;
292	uByte	bU1DevExitLat;
293	uByte	bU2DevExitLat;
294} __packed;
295
296struct usb2_devcap_container_id_descriptor {
297	uByte	bLength;
298	uByte	bDescriptorType;
299	uByte	bDevCapabilityType;
300	uByte	bReserved;
301	uByte	ContainerID;
302} __packed;
303
304/* Device class codes */
305#define	UDCLASS_IN_INTERFACE	0x00
306#define	UDCLASS_COMM		0x02
307#define	UDCLASS_HUB		0x09
308#define	UDSUBCLASS_HUB		0x00
309#define	UDPROTO_FSHUB		0x00
310#define	UDPROTO_HSHUBSTT	0x01
311#define	UDPROTO_HSHUBMTT	0x02
312#define	UDCLASS_DIAGNOSTIC	0xdc
313#define	UDCLASS_WIRELESS	0xe0
314#define	UDSUBCLASS_RF		0x01
315#define	UDPROTO_BLUETOOTH	0x01
316#define	UDCLASS_VENDOR		0xff
317
318struct usb2_config_descriptor {
319	uByte	bLength;
320	uByte	bDescriptorType;
321	uWord	wTotalLength;
322	uByte	bNumInterface;
323	uByte	bConfigurationValue;
324#define	USB_UNCONFIG_NO 0
325	uByte	iConfiguration;
326	uByte	bmAttributes;
327#define	UC_BUS_POWERED		0x80
328#define	UC_SELF_POWERED		0x40
329#define	UC_REMOTE_WAKEUP	0x20
330	uByte	bMaxPower;		/* max current in 2 mA units */
331#define	UC_POWER_FACTOR 2
332} __packed;
333
334struct usb2_interface_descriptor {
335	uByte	bLength;
336	uByte	bDescriptorType;
337	uByte	bInterfaceNumber;
338	uByte	bAlternateSetting;
339	uByte	bNumEndpoints;
340	uByte	bInterfaceClass;
341	uByte	bInterfaceSubClass;
342	uByte	bInterfaceProtocol;
343	uByte	iInterface;
344} __packed;
345
346struct usb2_interface_assoc_descriptor {
347	uByte	bLength;
348	uByte	bDescriptorType;
349	uByte	bFirstInterface;
350	uByte	bInterfaceCount;
351	uByte	bFunctionClass;
352	uByte	bFunctionSubClass;
353	uByte	bFunctionProtocol;
354	uByte	iFunction;
355} __packed;
356
357/* Interface class codes */
358#define	UICLASS_UNSPEC		0x00
359#define	UICLASS_AUDIO		0x01	/* audio */
360#define	UISUBCLASS_AUDIOCONTROL	1
361#define	UISUBCLASS_AUDIOSTREAM		2
362#define	UISUBCLASS_MIDISTREAM		3
363
364#define	UICLASS_CDC		0x02	/* communication */
365#define	UISUBCLASS_DIRECT_LINE_CONTROL_MODEL	1
366#define	UISUBCLASS_ABSTRACT_CONTROL_MODEL	2
367#define	UISUBCLASS_TELEPHONE_CONTROL_MODEL	3
368#define	UISUBCLASS_MULTICHANNEL_CONTROL_MODEL	4
369#define	UISUBCLASS_CAPI_CONTROLMODEL		5
370#define	UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
371#define	UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
372#define	UISUBCLASS_WIRELESS_HANDSET_CM 8
373#define	UISUBCLASS_DEVICE_MGMT 9
374#define	UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10
375#define	UISUBCLASS_OBEX 11
376#define	UISUBCLASS_ETHERNET_EMULATION_MODEL 12
377
378#define	UIPROTO_CDC_AT			1
379#define	UIPROTO_CDC_ETH_512X4 0x76	/* FreeBSD specific */
380
381#define	UICLASS_HID		0x03
382#define	UISUBCLASS_BOOT		1
383#define	UIPROTO_BOOT_KEYBOARD	1
384#define	UIPROTO_MOUSE		2
385
386#define	UICLASS_PHYSICAL	0x05
387#define	UICLASS_IMAGE		0x06
388#define	UISUBCLASS_SIC		1	/* still image class */
389#define	UICLASS_PRINTER		0x07
390#define	UISUBCLASS_PRINTER	1
391#define	UIPROTO_PRINTER_UNI	1
392#define	UIPROTO_PRINTER_BI	2
393#define	UIPROTO_PRINTER_1284	3
394
395#define	UICLASS_MASS		0x08
396#define	UISUBCLASS_RBC		1
397#define	UISUBCLASS_SFF8020I	2
398#define	UISUBCLASS_QIC157	3
399#define	UISUBCLASS_UFI		4
400#define	UISUBCLASS_SFF8070I	5
401#define	UISUBCLASS_SCSI		6
402#define	UIPROTO_MASS_CBI_I	0
403#define	UIPROTO_MASS_CBI	1
404#define	UIPROTO_MASS_BBB_OLD	2	/* Not in the spec anymore */
405#define	UIPROTO_MASS_BBB	80	/* 'P' for the Iomega Zip drive */
406
407#define	UICLASS_HUB		0x09
408#define	UISUBCLASS_HUB		0
409#define	UIPROTO_FSHUB		0
410#define	UIPROTO_HSHUBSTT	0	/* Yes, same as previous */
411#define	UIPROTO_HSHUBMTT	1
412
413#define	UICLASS_CDC_DATA	0x0a
414#define	UISUBCLASS_DATA		0
415#define	UIPROTO_DATA_ISDNBRI		0x30	/* Physical iface */
416#define	UIPROTO_DATA_HDLC		0x31	/* HDLC */
417#define	UIPROTO_DATA_TRANSPARENT	0x32	/* Transparent */
418#define	UIPROTO_DATA_Q921M		0x50	/* Management for Q921 */
419#define	UIPROTO_DATA_Q921		0x51	/* Data for Q921 */
420#define	UIPROTO_DATA_Q921TM		0x52	/* TEI multiplexer for Q921 */
421#define	UIPROTO_DATA_V42BIS		0x90	/* Data compression */
422#define	UIPROTO_DATA_Q931		0x91	/* Euro-ISDN */
423#define	UIPROTO_DATA_V120		0x92	/* V.24 rate adaption */
424#define	UIPROTO_DATA_CAPI		0x93	/* CAPI 2.0 commands */
425#define	UIPROTO_DATA_HOST_BASED		0xfd	/* Host based driver */
426#define	UIPROTO_DATA_PUF		0xfe	/* see Prot. Unit Func. Desc. */
427#define	UIPROTO_DATA_VENDOR		0xff	/* Vendor specific */
428
429#define	UICLASS_SMARTCARD	0x0b
430#define	UICLASS_FIRM_UPD	0x0c
431#define	UICLASS_SECURITY	0x0d
432#define	UICLASS_DIAGNOSTIC	0xdc
433#define	UICLASS_WIRELESS	0xe0
434#define	UISUBCLASS_RF			0x01
435#define	UIPROTO_BLUETOOTH		0x01
436
437#define	UICLASS_APPL_SPEC	0xfe
438#define	UISUBCLASS_FIRMWARE_DOWNLOAD	1
439#define	UISUBCLASS_IRDA			2
440#define	UIPROTO_IRDA			0
441
442#define	UICLASS_VENDOR		0xff
443#define	UISUBCLASS_XBOX360_CONTROLLER	0x5d
444#define	UIPROTO_XBOX360_GAMEPAD	0x01
445
446struct usb2_endpoint_descriptor {
447	uByte	bLength;
448	uByte	bDescriptorType;
449	uByte	bEndpointAddress;
450#define	UE_GET_DIR(a)	((a) & 0x80)
451#define	UE_SET_DIR(a,d)	((a) | (((d)&1) << 7))
452#define	UE_DIR_IN	0x80
453#define	UE_DIR_OUT	0x00
454#define	UE_DIR_ANY	0xff		/* for internal use only! */
455#define	UE_ADDR		0x0f
456#define	UE_ADDR_ANY	0xff		/* for internal use only! */
457#define	UE_GET_ADDR(a)	((a) & UE_ADDR)
458	uByte	bmAttributes;
459#define	UE_XFERTYPE	0x03
460#define	UE_CONTROL	0x00
461#define	UE_ISOCHRONOUS	0x01
462#define	UE_BULK	0x02
463#define	UE_INTERRUPT	0x03
464#define	UE_BULK_INTR	0xfe		/* for internal use only! */
465#define	UE_TYPE_ANY	0xff		/* for internal use only! */
466#define	UE_GET_XFERTYPE(a)	((a) & UE_XFERTYPE)
467#define	UE_ISO_TYPE	0x0c
468#define	UE_ISO_ASYNC	0x04
469#define	UE_ISO_ADAPT	0x08
470#define	UE_ISO_SYNC	0x0c
471#define	UE_GET_ISO_TYPE(a)	((a) & UE_ISO_TYPE)
472	uWord	wMaxPacketSize;
473#define	UE_ZERO_MPS 0xFFFF		/* for internal use only */
474	uByte	bInterval;
475} __packed;
476
477struct usb2_endpoint_ss_comp_descriptor {
478	uByte	bLength;
479	uByte	bDescriptorType;
480	uWord	bMaxBurst;
481	uByte	bmAttributes;
482	uWord	wBytesPerInterval;
483} __packed;
484
485struct usb2_string_descriptor {
486	uByte	bLength;
487	uByte	bDescriptorType;
488	uWord	bString[126];
489	uByte	bUnused;
490} __packed;
491
492#define	USB_MAKE_STRING_DESC(m,name)	\
493struct name {				\
494  uByte bLength;			\
495  uByte bDescriptorType;		\
496  uByte bData[sizeof((uint8_t []){m})];	\
497} __packed;				\
498static const struct name name = {	\
499  .bLength = sizeof(struct name),	\
500  .bDescriptorType = UDESC_STRING,	\
501  .bData = { m },			\
502}
503
504struct usb2_hub_descriptor {
505	uByte	bDescLength;
506	uByte	bDescriptorType;
507	uByte	bNbrPorts;
508	uWord	wHubCharacteristics;
509#define	UHD_PWR			0x0003
510#define	UHD_PWR_GANGED		0x0000
511#define	UHD_PWR_INDIVIDUAL	0x0001
512#define	UHD_PWR_NO_SWITCH	0x0002
513#define	UHD_COMPOUND		0x0004
514#define	UHD_OC			0x0018
515#define	UHD_OC_GLOBAL		0x0000
516#define	UHD_OC_INDIVIDUAL	0x0008
517#define	UHD_OC_NONE		0x0010
518#define	UHD_TT_THINK		0x0060
519#define	UHD_TT_THINK_8		0x0000
520#define	UHD_TT_THINK_16		0x0020
521#define	UHD_TT_THINK_24		0x0040
522#define	UHD_TT_THINK_32		0x0060
523#define	UHD_PORT_IND		0x0080
524	uByte	bPwrOn2PwrGood;		/* delay in 2 ms units */
525#define	UHD_PWRON_FACTOR 2
526	uByte	bHubContrCurrent;
527	uByte	DeviceRemovable[32];	/* max 255 ports */
528#define	UHD_NOT_REMOV(desc, i) \
529    (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
530	uByte	PortPowerCtrlMask[1];	/* deprecated */
531} __packed;
532
533struct usb2_hub_ss_descriptor {
534	uByte	bDescLength;
535	uByte	bDescriptorType;
536	uByte	bNbrPorts;		/* max 15 */
537	uWord	wHubCharacteristics;
538	uByte	bPwrOn2PwrGood;		/* delay in 2 ms units */
539	uByte	bHubContrCurrent;
540	uByte	bHubHdrDecLat;
541	uWord	wHubDelay;
542	uByte	DeviceRemovable[2];	/* max 15 ports */
543} __packed;
544
545/* minimum HUB descriptor (8-ports maximum) */
546struct usb2_hub_descriptor_min {
547	uByte	bDescLength;
548	uByte	bDescriptorType;
549	uByte	bNbrPorts;
550	uWord	wHubCharacteristics;
551	uByte	bPwrOn2PwrGood;
552	uByte	bHubContrCurrent;
553	uByte	DeviceRemovable[1];
554	uByte	PortPowerCtrlMask[1];
555} __packed;
556
557struct usb2_device_qualifier {
558	uByte	bLength;
559	uByte	bDescriptorType;
560	uWord	bcdUSB;
561	uByte	bDeviceClass;
562	uByte	bDeviceSubClass;
563	uByte	bDeviceProtocol;
564	uByte	bMaxPacketSize0;
565	uByte	bNumConfigurations;
566	uByte	bReserved;
567} __packed;
568
569struct usb2_otg_descriptor {
570	uByte	bLength;
571	uByte	bDescriptorType;
572	uByte	bmAttributes;
573#define	UOTG_SRP	0x01
574#define	UOTG_HNP	0x02
575} __packed;
576
577/* OTG feature selectors */
578#define	UOTG_B_HNP_ENABLE	3
579#define	UOTG_A_HNP_SUPPORT	4
580#define	UOTG_A_ALT_HNP_SUPPORT	5
581
582struct usb2_status {
583	uWord	wStatus;
584/* Device status flags */
585#define	UDS_SELF_POWERED		0x0001
586#define	UDS_REMOTE_WAKEUP		0x0002
587/* Endpoint status flags */
588#define	UES_HALT			0x0001
589} __packed;
590
591struct usb2_hub_status {
592	uWord	wHubStatus;
593#define	UHS_LOCAL_POWER			0x0001
594#define	UHS_OVER_CURRENT		0x0002
595	uWord	wHubChange;
596} __packed;
597
598struct usb2_port_status {
599	uWord	wPortStatus;
600#define	UPS_CURRENT_CONNECT_STATUS	0x0001
601#define	UPS_PORT_ENABLED		0x0002
602#define	UPS_SUSPEND			0x0004
603#define	UPS_OVERCURRENT_INDICATOR	0x0008
604#define	UPS_RESET			0x0010
605#define	UPS_PORT_MODE_DEVICE		0x0020	/* currently FreeBSD specific */
606#define	UPS_PORT_POWER			0x0100
607#define	UPS_LOW_SPEED			0x0200
608#define	UPS_HIGH_SPEED			0x0400
609#define	UPS_PORT_TEST			0x0800
610#define	UPS_PORT_INDICATOR		0x1000
611	uWord	wPortChange;
612#define	UPS_C_CONNECT_STATUS		0x0001
613#define	UPS_C_PORT_ENABLED		0x0002
614#define	UPS_C_SUSPEND			0x0004
615#define	UPS_C_OVERCURRENT_INDICATOR	0x0008
616#define	UPS_C_PORT_RESET		0x0010
617} __packed;
618
619#endif					/* _USB2_STANDARD_H_ */
620