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.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
30 * This file contains standard definitions for the following USB
39 #ifndef _USB_STANDARD_H_
40 #define _USB_STANDARD_H_
45 /* Declare parent SYSCTL USB node. */
50 #include <sys/malloc.h>
52 MALLOC_DECLARE(M_USB);
53 MALLOC_DECLARE(M_USBDEV);
54 MALLOC_DECLARE(M_USBHC);
57 #include <dev/usb/usb_endian.h>
58 #include <dev/usb/usb_freebsd.h>
60 #define USB_STACK_VERSION 2000 /* 2.0 */
62 /* Definition of some hardcoded USB constants. */
64 #define USB_MAX_IPACKET 8 /* initial USB packet size */
65 #define USB_EP_MAX (2*16) /* hardcoded */
66 #define USB_ROOT_HUB_ADDR 1 /* index */
67 #define USB_MIN_DEVICES 2 /* unused + root HUB */
68 #define USB_UNCONFIG_INDEX 0xFF /* internal use only */
69 #define USB_IFACE_INDEX_ANY 0xFF /* internal use only */
70 #define USB_START_ADDR 0 /* default USB device BUS address
71 * after USB bus reset */
72 #define USB_CONTROL_ENDPOINT 0 /* default control endpoint */
74 #define USB_FRAMES_PER_SECOND_FS 1000 /* full speed */
75 #define USB_FRAMES_PER_SECOND_HS 8000 /* high speed */
77 #define USB_FS_BYTES_PER_HS_UFRAME 188 /* bytes */
78 #define USB_HS_MICRO_FRAMES_MAX 8 /* units */
80 #define USB_ISOC_TIME_MAX 128 /* ms */
83 * Minimum time a device needs to be powered down to go through a
84 * power cycle. These values are not in the USB specification.
86 #define USB_POWER_DOWN_TIME 200 /* ms */
87 #define USB_PORT_POWER_DOWN_TIME 100 /* ms */
89 /* Definition of software USB power modes */
90 #define USB_POWER_MODE_OFF 0 /* turn off device */
91 #define USB_POWER_MODE_ON 1 /* always on */
92 #define USB_POWER_MODE_SAVE 2 /* automatic suspend and resume */
93 #define USB_POWER_MODE_SUSPEND 3 /* force suspend */
94 #define USB_POWER_MODE_RESUME 4 /* force resume */
97 /* These are the values from the USB specification. */
98 #define USB_PORT_RESET_DELAY 10 /* ms */
99 #define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
100 #define USB_PORT_RESET_RECOVERY 10 /* ms */
101 #define USB_PORT_POWERUP_DELAY 100 /* ms */
102 #define USB_PORT_RESUME_DELAY 20 /* ms */
103 #define USB_SET_ADDRESS_SETTLE 2 /* ms */
104 #define USB_RESUME_DELAY (20*5) /* ms */
105 #define USB_RESUME_WAIT 10 /* ms */
106 #define USB_RESUME_RECOVERY 10 /* ms */
107 #define USB_EXTRA_POWER_UP_TIME 0 /* ms */
109 /* Allow for marginal and non-conforming devices. */
110 #define USB_PORT_RESET_DELAY 50 /* ms */
111 #define USB_PORT_ROOT_RESET_DELAY 250 /* ms */
112 #define USB_PORT_RESET_RECOVERY 250 /* ms */
113 #define USB_PORT_POWERUP_DELAY 300 /* ms */
114 #define USB_PORT_RESUME_DELAY (20*2) /* ms */
115 #define USB_SET_ADDRESS_SETTLE 10 /* ms */
116 #define USB_RESUME_DELAY (50*5) /* ms */
117 #define USB_RESUME_WAIT 50 /* ms */
118 #define USB_RESUME_RECOVERY 50 /* ms */
119 #define USB_EXTRA_POWER_UP_TIME 20 /* ms */
122 #define USB_MIN_POWER 100 /* mA */
123 #define USB_MAX_POWER 500 /* mA */
125 #define USB_BUS_RESET_DELAY 100 /* ms */
128 * USB record layout in memory:
132 * - USB alternative interfaces
137 * - USB alternative interfaces
141 /* Declaration of USB records */
143 struct usb_device_request {
150 typedef struct usb_device_request usb_device_request_t;
152 #define UT_WRITE 0x00
154 #define UT_STANDARD 0x00
155 #define UT_CLASS 0x20
156 #define UT_VENDOR 0x40
157 #define UT_DEVICE 0x00
158 #define UT_INTERFACE 0x01
159 #define UT_ENDPOINT 0x02
160 #define UT_OTHER 0x03
162 #define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE)
163 #define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE)
164 #define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT)
165 #define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE)
166 #define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE)
167 #define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT)
168 #define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE)
169 #define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE)
170 #define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER)
171 #define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT)
172 #define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE)
173 #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
174 #define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER)
175 #define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT)
176 #define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE)
177 #define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE)
178 #define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER)
179 #define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT)
180 #define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE)
181 #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
182 #define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER)
183 #define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
186 #define UR_GET_STATUS 0x00
187 #define UR_CLEAR_FEATURE 0x01
188 #define UR_SET_FEATURE 0x03
189 #define UR_SET_ADDRESS 0x05
190 #define UR_GET_DESCRIPTOR 0x06
191 #define UDESC_DEVICE 0x01
192 #define UDESC_CONFIG 0x02
193 #define UDESC_STRING 0x03
194 #define USB_LANGUAGE_TABLE 0x00 /* language ID string index */
195 #define UDESC_INTERFACE 0x04
196 #define UDESC_ENDPOINT 0x05
197 #define UDESC_DEVICE_QUALIFIER 0x06
198 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07
199 #define UDESC_INTERFACE_POWER 0x08
200 #define UDESC_OTG 0x09
201 #define UDESC_DEBUG 0x0A
202 #define UDESC_IFACE_ASSOC 0x0B /* interface association */
203 #define UDESC_BOS 0x0F /* binary object store */
204 #define UDESC_DEVICE_CAPABILITY 0x10
205 #define UDESC_CS_DEVICE 0x21 /* class specific */
206 #define UDESC_CS_CONFIG 0x22
207 #define UDESC_CS_STRING 0x23
208 #define UDESC_CS_INTERFACE 0x24
209 #define UDESC_CS_ENDPOINT 0x25
210 #define UDESC_HUB 0x29
211 #define UDESC_SS_HUB 0x2A /* super speed */
212 #define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */
213 #define UR_SET_DESCRIPTOR 0x07
214 #define UR_GET_CONFIG 0x08
215 #define UR_SET_CONFIG 0x09
216 #define UR_GET_INTERFACE 0x0a
217 #define UR_SET_INTERFACE 0x0b
218 #define UR_SYNCH_FRAME 0x0c
219 #define UR_SET_SEL 0x30
220 #define UR_ISOCH_DELAY 0x31
222 /* HUB specific request */
223 #define UR_GET_BUS_STATE 0x02
224 #define UR_CLEAR_TT_BUFFER 0x08
225 #define UR_RESET_TT 0x09
226 #define UR_GET_TT_STATE 0x0a
227 #define UR_STOP_TT 0x0b
228 #define UR_SET_AND_TEST 0x0c /* USB 2.0 only */
229 #define UR_SET_HUB_DEPTH 0x0c /* USB 3.0 only */
230 #define USB_SS_HUB_DEPTH_MAX 5
231 #define UR_GET_PORT_ERR_COUNT 0x0d
233 /* Feature numbers */
234 #define UF_ENDPOINT_HALT 0
235 #define UF_DEVICE_REMOTE_WAKEUP 1
236 #define UF_TEST_MODE 2
237 #define UF_U1_ENABLE 0x30
238 #define UF_U2_ENABLE 0x31
239 #define UF_LTM_ENABLE 0x32
241 /* HUB specific features */
242 #define UHF_C_HUB_LOCAL_POWER 0
243 #define UHF_C_HUB_OVER_CURRENT 1
244 #define UHF_PORT_CONNECTION 0
245 #define UHF_PORT_ENABLE 1
246 #define UHF_PORT_SUSPEND 2
247 #define UHF_PORT_OVER_CURRENT 3
248 #define UHF_PORT_RESET 4
249 #define UHF_PORT_LINK_STATE 5
250 #define UHF_PORT_POWER 8
251 #define UHF_PORT_LOW_SPEED 9
252 #define UHF_PORT_L1 10
253 #define UHF_C_PORT_CONNECTION 16
254 #define UHF_C_PORT_ENABLE 17
255 #define UHF_C_PORT_SUSPEND 18
256 #define UHF_C_PORT_OVER_CURRENT 19
257 #define UHF_C_PORT_RESET 20
258 #define UHF_PORT_TEST 21
259 #define UHF_PORT_INDICATOR 22
260 #define UHF_C_PORT_L1 23
262 /* SuperSpeed HUB specific features */
263 #define UHF_PORT_U1_TIMEOUT 23
264 #define UHF_PORT_U2_TIMEOUT 24
265 #define UHF_C_PORT_LINK_STATE 25
266 #define UHF_C_PORT_CONFIG_ERROR 26
267 #define UHF_PORT_REMOTE_WAKE_MASK 27
268 #define UHF_BH_PORT_RESET 28
269 #define UHF_C_BH_PORT_RESET 29
270 #define UHF_FORCE_LINKPM_ACCEPT 30
272 struct usb_descriptor {
274 uByte bDescriptorType;
275 uByte bDescriptorSubtype;
277 typedef struct usb_descriptor usb_descriptor_t;
279 struct usb_device_descriptor {
281 uByte bDescriptorType;
283 #define UD_USB_2_0 0x0200
284 #define UD_USB_3_0 0x0300
285 #define UD_IS_USB2(d) ((d)->bcdUSB[1] == 0x02)
286 #define UD_IS_USB3(d) ((d)->bcdUSB[1] == 0x03)
288 uByte bDeviceSubClass;
289 uByte bDeviceProtocol;
290 uByte bMaxPacketSize;
291 /* The fields below are not part of the initial descriptor. */
298 uByte bNumConfigurations;
300 typedef struct usb_device_descriptor usb_device_descriptor_t;
302 /* Binary Device Object Store (BOS) */
303 struct usb_bos_descriptor {
305 uByte bDescriptorType;
307 uByte bNumDeviceCaps;
309 typedef struct usb_bos_descriptor usb_bos_descriptor_t;
311 /* Binary Device Object Store Capability */
312 struct usb_bos_cap_descriptor {
314 uByte bDescriptorType;
315 uByte bDevCapabilityType;
316 #define USB_DEVCAP_RESERVED 0x00
317 #define USB_DEVCAP_WUSB 0x01
318 #define USB_DEVCAP_USB2EXT 0x02
319 #define USB_DEVCAP_SUPER_SPEED 0x03
320 #define USB_DEVCAP_CONTAINER_ID 0x04
323 typedef struct usb_bos_cap_descriptor usb_bos_cap_descriptor_t;
325 struct usb_devcap_usb2ext_descriptor {
327 uByte bDescriptorType;
328 uByte bDevCapabilityType;
330 #define USB_V2EXT_LPM (1U << 1)
331 #define USB_V2EXT_BESL_SUPPORTED (1U << 2)
332 #define USB_V2EXT_BESL_BASELINE_VALID (1U << 3)
333 #define USB_V2EXT_BESL_DEEP_VALID (1U << 4)
334 #define USB_V2EXT_BESL_BASELINE_GET(x) (((x) >> 8) & 0xF)
335 #define USB_V2EXT_BESL_DEEP_GET(x) (((x) >> 12) & 0xF)
337 typedef struct usb_devcap_usb2ext_descriptor usb_devcap_usb2ext_descriptor_t;
339 struct usb_devcap_ss_descriptor {
341 uByte bDescriptorType;
342 uByte bDevCapabilityType;
344 uWord wSpeedsSupported;
345 uByte bFunctionalitySupport;
349 typedef struct usb_devcap_ss_descriptor usb_devcap_ss_descriptor_t;
351 struct usb_devcap_container_id_descriptor {
353 uByte bDescriptorType;
354 uByte bDevCapabilityType;
358 typedef struct usb_devcap_container_id_descriptor
359 usb_devcap_container_id_descriptor_t;
361 /* Device class codes */
362 #define UDCLASS_IN_INTERFACE 0x00
363 #define UDCLASS_COMM 0x02
364 #define UDCLASS_HUB 0x09
365 #define UDSUBCLASS_HUB 0x00
366 #define UDPROTO_FSHUB 0x00
367 #define UDPROTO_HSHUBSTT 0x01
368 #define UDPROTO_HSHUBMTT 0x02
369 #define UDPROTO_SSHUB 0x03
370 #define UDCLASS_DIAGNOSTIC 0xdc
371 #define UDCLASS_WIRELESS 0xe0
372 #define UDSUBCLASS_RF 0x01
373 #define UDPROTO_BLUETOOTH 0x01
374 #define UDCLASS_VENDOR 0xff
376 struct usb_config_descriptor {
378 uByte bDescriptorType;
381 uByte bConfigurationValue;
382 #define USB_UNCONFIG_NO 0
383 uByte iConfiguration;
385 #define UC_BUS_POWERED 0x80
386 #define UC_SELF_POWERED 0x40
387 #define UC_REMOTE_WAKEUP 0x20
388 uByte bMaxPower; /* max current in 2 mA units */
389 #define UC_POWER_FACTOR 2
391 typedef struct usb_config_descriptor usb_config_descriptor_t;
393 struct usb_interface_descriptor {
395 uByte bDescriptorType;
396 uByte bInterfaceNumber;
397 uByte bAlternateSetting;
399 uByte bInterfaceClass;
400 uByte bInterfaceSubClass;
401 uByte bInterfaceProtocol;
404 typedef struct usb_interface_descriptor usb_interface_descriptor_t;
406 struct usb_interface_assoc_descriptor {
408 uByte bDescriptorType;
409 uByte bFirstInterface;
410 uByte bInterfaceCount;
411 uByte bFunctionClass;
412 uByte bFunctionSubClass;
413 uByte bFunctionProtocol;
416 typedef struct usb_interface_assoc_descriptor usb_interface_assoc_descriptor_t;
418 /* Interface class codes */
419 #define UICLASS_UNSPEC 0x00
420 #define UICLASS_AUDIO 0x01 /* audio */
421 #define UISUBCLASS_AUDIOCONTROL 1
422 #define UISUBCLASS_AUDIOSTREAM 2
423 #define UISUBCLASS_MIDISTREAM 3
425 #define UICLASS_CDC 0x02 /* communication */
426 #define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
427 #define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2
428 #define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3
429 #define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4
430 #define UISUBCLASS_CAPI_CONTROLMODEL 5
431 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
432 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
433 #define UISUBCLASS_WIRELESS_HANDSET_CM 8
434 #define UISUBCLASS_DEVICE_MGMT 9
435 #define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10
436 #define UISUBCLASS_OBEX 11
437 #define UISUBCLASS_ETHERNET_EMULATION_MODEL 12
438 #define UISUBCLASS_NETWORK_CONTROL_MODEL 13
440 #define UIPROTO_CDC_AT 1
442 #define UICLASS_HID 0x03
443 #define UISUBCLASS_BOOT 1
444 #define UIPROTO_BOOT_KEYBOARD 1
445 #define UIPROTO_MOUSE 2
447 #define UICLASS_PHYSICAL 0x05
448 #define UICLASS_IMAGE 0x06
449 #define UISUBCLASS_SIC 1 /* still image class */
450 #define UICLASS_PRINTER 0x07
451 #define UISUBCLASS_PRINTER 1
452 #define UIPROTO_PRINTER_UNI 1
453 #define UIPROTO_PRINTER_BI 2
454 #define UIPROTO_PRINTER_1284 3
456 #define UICLASS_MASS 0x08
457 #define UISUBCLASS_RBC 1
458 #define UISUBCLASS_SFF8020I 2
459 #define UISUBCLASS_QIC157 3
460 #define UISUBCLASS_UFI 4
461 #define UISUBCLASS_SFF8070I 5
462 #define UISUBCLASS_SCSI 6
463 #define UIPROTO_MASS_CBI_I 0
464 #define UIPROTO_MASS_CBI 1
465 #define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */
466 #define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */
468 #define UICLASS_HUB 0x09
469 #define UISUBCLASS_HUB 0
470 #define UIPROTO_FSHUB 0
471 #define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */
472 #define UIPROTO_HSHUBMTT 1
474 #define UICLASS_CDC_DATA 0x0a
475 #define UISUBCLASS_DATA 0x00
476 #define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */
477 #define UIPROTO_DATA_HDLC 0x31 /* HDLC */
478 #define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */
479 #define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */
480 #define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */
481 #define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */
482 #define UIPROTO_DATA_V42BIS 0x90 /* Data compression */
483 #define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */
484 #define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */
485 #define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */
486 #define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */
487 #define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc. */
488 #define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */
489 #define UIPROTO_DATA_NCM 0x01 /* Network Control Model */
491 #define UICLASS_SMARTCARD 0x0b
492 #define UICLASS_FIRM_UPD 0x0c
493 #define UICLASS_SECURITY 0x0d
494 #define UICLASS_DIAGNOSTIC 0xdc
495 #define UICLASS_WIRELESS 0xe0
496 #define UISUBCLASS_RF 0x01
497 #define UIPROTO_BLUETOOTH 0x01
499 #define UICLASS_IAD 0xEF /* Interface Association Descriptor */
501 #define UICLASS_APPL_SPEC 0xfe
502 #define UISUBCLASS_FIRMWARE_DOWNLOAD 1
503 #define UISUBCLASS_IRDA 2
504 #define UIPROTO_IRDA 0
506 #define UICLASS_VENDOR 0xff
507 #define UISUBCLASS_XBOX360_CONTROLLER 0x5d
508 #define UIPROTO_XBOX360_GAMEPAD 0x01
510 struct usb_endpoint_descriptor {
512 uByte bDescriptorType;
513 uByte bEndpointAddress;
514 #define UE_GET_DIR(a) ((a) & 0x80)
515 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
516 #define UE_DIR_IN 0x80 /* IN-token endpoint, fixed */
517 #define UE_DIR_OUT 0x00 /* OUT-token endpoint, fixed */
518 #define UE_DIR_RX 0xfd /* for internal use only! */
519 #define UE_DIR_TX 0xfe /* for internal use only! */
520 #define UE_DIR_ANY 0xff /* for internal use only! */
522 #define UE_ADDR_ANY 0xff /* for internal use only! */
523 #define UE_GET_ADDR(a) ((a) & UE_ADDR)
525 #define UE_XFERTYPE 0x03
526 #define UE_CONTROL 0x00
527 #define UE_ISOCHRONOUS 0x01
529 #define UE_INTERRUPT 0x03
530 #define UE_BULK_INTR 0xfe /* for internal use only! */
531 #define UE_TYPE_ANY 0xff /* for internal use only! */
532 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
533 #define UE_ISO_TYPE 0x0c
534 #define UE_ISO_ASYNC 0x04
535 #define UE_ISO_ADAPT 0x08
536 #define UE_ISO_SYNC 0x0c
537 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
538 uWord wMaxPacketSize;
539 #define UE_ZERO_MPS 0xFFFF /* for internal use only */
542 typedef struct usb_endpoint_descriptor usb_endpoint_descriptor_t;
544 struct usb_endpoint_ss_comp_descriptor {
546 uByte bDescriptorType;
549 uWord wBytesPerInterval;
551 typedef struct usb_endpoint_ss_comp_descriptor
552 usb_endpoint_ss_comp_descriptor_t;
554 struct usb_string_descriptor {
556 uByte bDescriptorType;
560 typedef struct usb_string_descriptor usb_string_descriptor_t;
562 #define USB_MAKE_STRING_DESC(m,name) \
565 uByte bDescriptorType; \
566 uByte bData[sizeof((uint8_t []){m})]; \
568 static const struct name name = { \
569 .bLength = sizeof(struct name), \
570 .bDescriptorType = UDESC_STRING, \
574 struct usb_hub_descriptor {
576 uByte bDescriptorType;
578 uWord wHubCharacteristics;
579 #define UHD_PWR 0x0003
580 #define UHD_PWR_GANGED 0x0000
581 #define UHD_PWR_INDIVIDUAL 0x0001
582 #define UHD_PWR_NO_SWITCH 0x0002
583 #define UHD_COMPOUND 0x0004
584 #define UHD_OC 0x0018
585 #define UHD_OC_GLOBAL 0x0000
586 #define UHD_OC_INDIVIDUAL 0x0008
587 #define UHD_OC_NONE 0x0010
588 #define UHD_TT_THINK 0x0060
589 #define UHD_TT_THINK_8 0x0000
590 #define UHD_TT_THINK_16 0x0020
591 #define UHD_TT_THINK_24 0x0040
592 #define UHD_TT_THINK_32 0x0060
593 #define UHD_PORT_IND 0x0080
594 uByte bPwrOn2PwrGood; /* delay in 2 ms units */
595 #define UHD_PWRON_FACTOR 2
596 uByte bHubContrCurrent;
597 uByte DeviceRemovable[32]; /* max 255 ports */
598 #define UHD_NOT_REMOV(desc, i) \
599 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
600 uByte PortPowerCtrlMask[1]; /* deprecated */
602 typedef struct usb_hub_descriptor usb_hub_descriptor_t;
604 struct usb_hub_ss_descriptor {
606 uByte bDescriptorType;
608 uWord wHubCharacteristics;
609 uByte bPwrOn2PwrGood; /* delay in 2 ms units */
610 uByte bHubContrCurrent;
613 uByte DeviceRemovable[32]; /* max 255 ports */
615 typedef struct usb_hub_ss_descriptor usb_hub_ss_descriptor_t;
617 /* minimum HUB descriptor (8-ports maximum) */
618 struct usb_hub_descriptor_min {
620 uByte bDescriptorType;
622 uWord wHubCharacteristics;
623 uByte bPwrOn2PwrGood;
624 uByte bHubContrCurrent;
625 uByte DeviceRemovable[1];
626 uByte PortPowerCtrlMask[1];
628 typedef struct usb_hub_descriptor_min usb_hub_descriptor_min_t;
630 struct usb_device_qualifier {
632 uByte bDescriptorType;
635 uByte bDeviceSubClass;
636 uByte bDeviceProtocol;
637 uByte bMaxPacketSize0;
638 uByte bNumConfigurations;
641 typedef struct usb_device_qualifier usb_device_qualifier_t;
643 struct usb_otg_descriptor {
645 uByte bDescriptorType;
647 #define UOTG_SRP 0x01
648 #define UOTG_HNP 0x02
650 typedef struct usb_otg_descriptor usb_otg_descriptor_t;
652 /* OTG feature selectors */
653 #define UOTG_B_HNP_ENABLE 3
654 #define UOTG_A_HNP_SUPPORT 4
655 #define UOTG_A_ALT_HNP_SUPPORT 5
659 /* Device status flags */
660 #define UDS_SELF_POWERED 0x0001
661 #define UDS_REMOTE_WAKEUP 0x0002
662 /* Endpoint status flags */
663 #define UES_HALT 0x0001
665 typedef struct usb_status usb_status_t;
667 struct usb_hub_status {
669 #define UHS_LOCAL_POWER 0x0001
670 #define UHS_OVER_CURRENT 0x0002
673 typedef struct usb_hub_status usb_hub_status_t;
675 struct usb_port_status {
677 #define UPS_CURRENT_CONNECT_STATUS 0x0001
678 #define UPS_PORT_ENABLED 0x0002
679 #define UPS_SUSPEND 0x0004
680 #define UPS_OVERCURRENT_INDICATOR 0x0008
681 #define UPS_RESET 0x0010
682 #define UPS_PORT_L1 0x0020 /* USB 2.0 only */
683 /* The link-state bits are valid for Super-Speed USB HUBs */
684 #define UPS_PORT_LINK_STATE_GET(x) (((x) >> 5) & 0xF)
685 #define UPS_PORT_LINK_STATE_SET(x) (((x) & 0xF) << 5)
686 #define UPS_PORT_LS_U0 0x00
687 #define UPS_PORT_LS_U1 0x01
688 #define UPS_PORT_LS_U2 0x02
689 #define UPS_PORT_LS_U3 0x03
690 #define UPS_PORT_LS_SS_DIS 0x04
691 #define UPS_PORT_LS_RX_DET 0x05
692 #define UPS_PORT_LS_SS_INA 0x06
693 #define UPS_PORT_LS_POLL 0x07
694 #define UPS_PORT_LS_RECOVER 0x08
695 #define UPS_PORT_LS_HOT_RST 0x09
696 #define UPS_PORT_LS_COMP_MODE 0x0A
697 #define UPS_PORT_LS_LOOPBACK 0x0B
698 #define UPS_PORT_LS_RESUME 0x0F
699 #define UPS_PORT_POWER 0x0100
700 #define UPS_PORT_POWER_SS 0x0200 /* super-speed only */
701 #define UPS_LOW_SPEED 0x0200
702 #define UPS_HIGH_SPEED 0x0400
703 #define UPS_OTHER_SPEED 0x0600 /* currently FreeBSD specific */
704 #define UPS_PORT_TEST 0x0800
705 #define UPS_PORT_INDICATOR 0x1000
706 #define UPS_PORT_MODE_DEVICE 0x8000 /* currently FreeBSD specific */
708 #define UPS_C_CONNECT_STATUS 0x0001
709 #define UPS_C_PORT_ENABLED 0x0002
710 #define UPS_C_SUSPEND 0x0004
711 #define UPS_C_OVERCURRENT_INDICATOR 0x0008
712 #define UPS_C_PORT_RESET 0x0010
713 #define UPS_C_PORT_L1 0x0020 /* USB 2.0 only */
714 #define UPS_C_BH_PORT_RESET 0x0020 /* USB 3.0 only */
715 #define UPS_C_PORT_LINK_STATE 0x0040
716 #define UPS_C_PORT_CONFIG_ERROR 0x0080
718 typedef struct usb_port_status usb_port_status_t;
721 * The "USB_SPEED" macros defines all the supported USB speeds.
730 #define USB_SPEED_MAX (USB_SPEED_SUPER+1)
733 * The "USB_REV" macros defines all the supported USB revisions.
744 #define USB_REV_MAX (USB_REV_3_0+1)
747 * Supported host contoller modes.
750 USB_MODE_HOST, /* initiates transfers */
751 USB_MODE_DEVICE, /* bus transfer target */
752 USB_MODE_DUAL /* can be host or device */
754 #define USB_MODE_MAX (USB_MODE_DUAL+1)
757 * The "USB_MODE" macros defines all the supported device states.
764 USB_STATE_CONFIGURED,
766 #define USB_STATE_MAX (USB_STATE_CONFIGURED+1)
767 #endif /* _USB_STANDARD_H_ */