1 /* $FreeBSD$ */ 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/usb/usb_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 105 struct usb2_device_request { 106 uByte bmRequestType; 107 uByte bRequest; 108 uWord wValue; 109 uWord wIndex; 110 uWord wLength; 111 } __packed; 112 typedef struct usb2_device_request usb_device_request_t; 113 114 #define UT_WRITE 0x00 115 #define UT_READ 0x80 116 #define UT_STANDARD 0x00 117 #define UT_CLASS 0x20 118 #define UT_VENDOR 0x40 119 #define UT_DEVICE 0x00 120 #define UT_INTERFACE 0x01 121 #define UT_ENDPOINT 0x02 122 #define UT_OTHER 0x03 123 124 #define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE) 125 #define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE) 126 #define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT) 127 #define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE) 128 #define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE) 129 #define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT) 130 #define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE) 131 #define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE) 132 #define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER) 133 #define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT) 134 #define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE) 135 #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE) 136 #define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER) 137 #define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT) 138 #define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE) 139 #define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE) 140 #define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER) 141 #define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT) 142 #define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE) 143 #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE) 144 #define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER) 145 #define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT) 146 147 /* Requests */ 148 #define UR_GET_STATUS 0x00 149 #define UR_CLEAR_FEATURE 0x01 150 #define UR_SET_FEATURE 0x03 151 #define UR_SET_ADDRESS 0x05 152 #define UR_GET_DESCRIPTOR 0x06 153 #define UDESC_DEVICE 0x01 154 #define UDESC_CONFIG 0x02 155 #define UDESC_STRING 0x03 156 #define USB_LANGUAGE_TABLE 0x00 /* language ID string index */ 157 #define UDESC_INTERFACE 0x04 158 #define UDESC_ENDPOINT 0x05 159 #define UDESC_DEVICE_QUALIFIER 0x06 160 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07 161 #define UDESC_INTERFACE_POWER 0x08 162 #define UDESC_OTG 0x09 163 #define UDESC_DEBUG 0x0A 164 #define UDESC_IFACE_ASSOC 0x0B /* interface association */ 165 #define UDESC_BOS 0x0F /* binary object store */ 166 #define UDESC_DEVICE_CAPABILITY 0x10 167 #define UDESC_CS_DEVICE 0x21 /* class specific */ 168 #define UDESC_CS_CONFIG 0x22 169 #define UDESC_CS_STRING 0x23 170 #define UDESC_CS_INTERFACE 0x24 171 #define UDESC_CS_ENDPOINT 0x25 172 #define UDESC_HUB 0x29 173 #define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */ 174 #define UR_SET_DESCRIPTOR 0x07 175 #define UR_GET_CONFIG 0x08 176 #define UR_SET_CONFIG 0x09 177 #define UR_GET_INTERFACE 0x0a 178 #define UR_SET_INTERFACE 0x0b 179 #define UR_SYNCH_FRAME 0x0c 180 #define UR_SET_SEL 0x30 181 #define UR_ISOCH_DELAY 0x31 182 183 /* HUB specific request */ 184 #define UR_GET_BUS_STATE 0x02 185 #define UR_CLEAR_TT_BUFFER 0x08 186 #define UR_RESET_TT 0x09 187 #define UR_GET_TT_STATE 0x0a 188 #define UR_STOP_TT 0x0b 189 #define UR_SET_HUB_DEPTH 0x0c 190 #define UR_GET_PORT_ERR_COUNT 0x0d 191 192 /* Feature numbers */ 193 #define UF_ENDPOINT_HALT 0 194 #define UF_DEVICE_REMOTE_WAKEUP 1 195 #define UF_TEST_MODE 2 196 #define UF_U1_ENABLE 0x30 197 #define UF_U2_ENABLE 0x31 198 #define UF_LTM_ENABLE 0x32 199 200 /* HUB specific features */ 201 #define UHF_C_HUB_LOCAL_POWER 0 202 #define UHF_C_HUB_OVER_CURRENT 1 203 #define UHF_PORT_CONNECTION 0 204 #define UHF_PORT_ENABLE 1 205 #define UHF_PORT_SUSPEND 2 206 #define UHF_PORT_OVER_CURRENT 3 207 #define UHF_PORT_RESET 4 208 #define UHF_PORT_LINK_STATE 5 209 #define UHF_PORT_POWER 8 210 #define UHF_PORT_LOW_SPEED 9 211 #define UHF_C_PORT_CONNECTION 16 212 #define UHF_C_PORT_ENABLE 17 213 #define UHF_C_PORT_SUSPEND 18 214 #define UHF_C_PORT_OVER_CURRENT 19 215 #define UHF_C_PORT_RESET 20 216 #define UHF_PORT_TEST 21 217 #define UHF_PORT_INDICATOR 22 218 219 /* SuperSpeed HUB specific features */ 220 #define UHF_PORT_U1_TIMEOUT 23 221 #define UHF_PORT_U2_TIMEOUT 24 222 #define UHF_C_PORT_LINK_STATE 25 223 #define UHF_C_PORT_CONFIG_ERROR 26 224 #define UHF_PORT_REMOTE_WAKE_MASK 27 225 #define UHF_BH_PORT_RESET 28 226 #define UHF_C_BH_PORT_RESET 29 227 #define UHF_FORCE_LINKPM_ACCEPT 30 228 229 struct usb2_descriptor { 230 uByte bLength; 231 uByte bDescriptorType; 232 uByte bDescriptorSubtype; 233 } __packed; 234 typedef struct usb2_descriptor usb_descriptor_t; 235 236 struct usb2_device_descriptor { 237 uByte bLength; 238 uByte bDescriptorType; 239 uWord bcdUSB; 240 #define UD_USB_2_0 0x0200 241 #define UD_USB_3_0 0x0300 242 #define UD_IS_USB2(d) ((d)->bcdUSB[1] == 0x02) 243 #define UD_IS_USB3(d) ((d)->bcdUSB[1] == 0x03) 244 uByte bDeviceClass; 245 uByte bDeviceSubClass; 246 uByte bDeviceProtocol; 247 uByte bMaxPacketSize; 248 /* The fields below are not part of the initial descriptor. */ 249 uWord idVendor; 250 uWord idProduct; 251 uWord bcdDevice; 252 uByte iManufacturer; 253 uByte iProduct; 254 uByte iSerialNumber; 255 uByte bNumConfigurations; 256 } __packed; 257 typedef struct usb2_device_descriptor usb_device_descriptor_t; 258 259 /* Binary Device Object Store (BOS) */ 260 struct usb2_bos_descriptor { 261 uByte bLength; 262 uByte bDescriptorType; 263 uWord wTotalLength; 264 uByte bNumDeviceCaps; 265 } __packed; 266 typedef struct usb2_bos_descriptor usb_bos_descriptor_t; 267 268 /* Binary Device Object Store Capability */ 269 struct usb2_bos_cap_descriptor { 270 uByte bLength; 271 uByte bDescriptorType; 272 uByte bDevCapabilityType; 273 #define USB_DEVCAP_RESERVED 0x00 274 #define USB_DEVCAP_WUSB 0x01 275 #define USB_DEVCAP_USB2EXT 0x02 276 #define USB_DEVCAP_SUPER_SPEED 0x03 277 #define USB_DEVCAP_CONTAINER_ID 0x04 278 /* data ... */ 279 } __packed; 280 typedef struct usb2_bos_cap_descriptor usb_bos_cap_descriptor_t; 281 282 struct usb2_devcap_usb2ext_descriptor { 283 uByte bLength; 284 uByte bDescriptorType; 285 uByte bDevCapabilityType; 286 uByte bmAttributes; 287 #define USB_V2EXT_LPM 0x02 288 } __packed; 289 typedef struct usb2_devcap_usb2ext_descriptor usb_devcap_usb2ext_descriptor_t; 290 291 struct usb2_devcap_ss_descriptor { 292 uByte bLength; 293 uByte bDescriptorType; 294 uByte bDevCapabilityType; 295 uByte bmAttributes; 296 uWord wSpeedsSupported; 297 uByte bFunctionaltySupport; 298 uByte bU1DevExitLat; 299 uByte bU2DevExitLat; 300 } __packed; 301 typedef struct usb2_devcap_ss_descriptor usb_devcap_ss_descriptor_t; 302 303 struct usb2_devcap_container_id_descriptor { 304 uByte bLength; 305 uByte bDescriptorType; 306 uByte bDevCapabilityType; 307 uByte bReserved; 308 uByte ContainerID; 309 } __packed; 310 typedef struct usb2_devcap_container_id_descriptor 311 usb_devcap_container_id_descriptor_t; 312 313 /* Device class codes */ 314 #define UDCLASS_IN_INTERFACE 0x00 315 #define UDCLASS_COMM 0x02 316 #define UDCLASS_HUB 0x09 317 #define UDSUBCLASS_HUB 0x00 318 #define UDPROTO_FSHUB 0x00 319 #define UDPROTO_HSHUBSTT 0x01 320 #define UDPROTO_HSHUBMTT 0x02 321 #define UDCLASS_DIAGNOSTIC 0xdc 322 #define UDCLASS_WIRELESS 0xe0 323 #define UDSUBCLASS_RF 0x01 324 #define UDPROTO_BLUETOOTH 0x01 325 #define UDCLASS_VENDOR 0xff 326 327 struct usb2_config_descriptor { 328 uByte bLength; 329 uByte bDescriptorType; 330 uWord wTotalLength; 331 uByte bNumInterface; 332 uByte bConfigurationValue; 333 #define USB_UNCONFIG_NO 0 334 uByte iConfiguration; 335 uByte bmAttributes; 336 #define UC_BUS_POWERED 0x80 337 #define UC_SELF_POWERED 0x40 338 #define UC_REMOTE_WAKEUP 0x20 339 uByte bMaxPower; /* max current in 2 mA units */ 340 #define UC_POWER_FACTOR 2 341 } __packed; 342 typedef struct usb2_config_descriptor usb_config_descriptor_t; 343 344 struct usb2_interface_descriptor { 345 uByte bLength; 346 uByte bDescriptorType; 347 uByte bInterfaceNumber; 348 uByte bAlternateSetting; 349 uByte bNumEndpoints; 350 uByte bInterfaceClass; 351 uByte bInterfaceSubClass; 352 uByte bInterfaceProtocol; 353 uByte iInterface; 354 } __packed; 355 typedef struct usb2_interface_descriptor usb_interface_descriptor_t; 356 357 struct usb2_interface_assoc_descriptor { 358 uByte bLength; 359 uByte bDescriptorType; 360 uByte bFirstInterface; 361 uByte bInterfaceCount; 362 uByte bFunctionClass; 363 uByte bFunctionSubClass; 364 uByte bFunctionProtocol; 365 uByte iFunction; 366 } __packed; 367 typedef struct usb2_interface_assoc_descriptor usb_interface_assoc_descriptor_t; 368 369 /* Interface class codes */ 370 #define UICLASS_UNSPEC 0x00 371 #define UICLASS_AUDIO 0x01 /* audio */ 372 #define UISUBCLASS_AUDIOCONTROL 1 373 #define UISUBCLASS_AUDIOSTREAM 2 374 #define UISUBCLASS_MIDISTREAM 3 375 376 #define UICLASS_CDC 0x02 /* communication */ 377 #define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1 378 #define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2 379 #define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3 380 #define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4 381 #define UISUBCLASS_CAPI_CONTROLMODEL 5 382 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6 383 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7 384 #define UISUBCLASS_WIRELESS_HANDSET_CM 8 385 #define UISUBCLASS_DEVICE_MGMT 9 386 #define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10 387 #define UISUBCLASS_OBEX 11 388 #define UISUBCLASS_ETHERNET_EMULATION_MODEL 12 389 390 #define UIPROTO_CDC_AT 1 391 #define UIPROTO_CDC_ETH_512X4 0x76 /* FreeBSD specific */ 392 393 #define UICLASS_HID 0x03 394 #define UISUBCLASS_BOOT 1 395 #define UIPROTO_BOOT_KEYBOARD 1 396 #define UIPROTO_MOUSE 2 397 398 #define UICLASS_PHYSICAL 0x05 399 #define UICLASS_IMAGE 0x06 400 #define UISUBCLASS_SIC 1 /* still image class */ 401 #define UICLASS_PRINTER 0x07 402 #define UISUBCLASS_PRINTER 1 403 #define UIPROTO_PRINTER_UNI 1 404 #define UIPROTO_PRINTER_BI 2 405 #define UIPROTO_PRINTER_1284 3 406 407 #define UICLASS_MASS 0x08 408 #define UISUBCLASS_RBC 1 409 #define UISUBCLASS_SFF8020I 2 410 #define UISUBCLASS_QIC157 3 411 #define UISUBCLASS_UFI 4 412 #define UISUBCLASS_SFF8070I 5 413 #define UISUBCLASS_SCSI 6 414 #define UIPROTO_MASS_CBI_I 0 415 #define UIPROTO_MASS_CBI 1 416 #define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */ 417 #define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */ 418 419 #define UICLASS_HUB 0x09 420 #define UISUBCLASS_HUB 0 421 #define UIPROTO_FSHUB 0 422 #define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */ 423 #define UIPROTO_HSHUBMTT 1 424 425 #define UICLASS_CDC_DATA 0x0a 426 #define UISUBCLASS_DATA 0 427 #define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */ 428 #define UIPROTO_DATA_HDLC 0x31 /* HDLC */ 429 #define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */ 430 #define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */ 431 #define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */ 432 #define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */ 433 #define UIPROTO_DATA_V42BIS 0x90 /* Data compression */ 434 #define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */ 435 #define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */ 436 #define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */ 437 #define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */ 438 #define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc. */ 439 #define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */ 440 441 #define UICLASS_SMARTCARD 0x0b 442 #define UICLASS_FIRM_UPD 0x0c 443 #define UICLASS_SECURITY 0x0d 444 #define UICLASS_DIAGNOSTIC 0xdc 445 #define UICLASS_WIRELESS 0xe0 446 #define UISUBCLASS_RF 0x01 447 #define UIPROTO_BLUETOOTH 0x01 448 449 #define UICLASS_APPL_SPEC 0xfe 450 #define UISUBCLASS_FIRMWARE_DOWNLOAD 1 451 #define UISUBCLASS_IRDA 2 452 #define UIPROTO_IRDA 0 453 454 #define UICLASS_VENDOR 0xff 455 #define UISUBCLASS_XBOX360_CONTROLLER 0x5d 456 #define UIPROTO_XBOX360_GAMEPAD 0x01 457 458 struct usb2_endpoint_descriptor { 459 uByte bLength; 460 uByte bDescriptorType; 461 uByte bEndpointAddress; 462 #define UE_GET_DIR(a) ((a) & 0x80) 463 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7)) 464 #define UE_DIR_IN 0x80 465 #define UE_DIR_OUT 0x00 466 #define UE_DIR_ANY 0xff /* for internal use only! */ 467 #define UE_ADDR 0x0f 468 #define UE_ADDR_ANY 0xff /* for internal use only! */ 469 #define UE_GET_ADDR(a) ((a) & UE_ADDR) 470 uByte bmAttributes; 471 #define UE_XFERTYPE 0x03 472 #define UE_CONTROL 0x00 473 #define UE_ISOCHRONOUS 0x01 474 #define UE_BULK 0x02 475 #define UE_INTERRUPT 0x03 476 #define UE_BULK_INTR 0xfe /* for internal use only! */ 477 #define UE_TYPE_ANY 0xff /* for internal use only! */ 478 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE) 479 #define UE_ISO_TYPE 0x0c 480 #define UE_ISO_ASYNC 0x04 481 #define UE_ISO_ADAPT 0x08 482 #define UE_ISO_SYNC 0x0c 483 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE) 484 uWord wMaxPacketSize; 485 #define UE_ZERO_MPS 0xFFFF /* for internal use only */ 486 uByte bInterval; 487 } __packed; 488 typedef struct usb2_endpoint_descriptor usb_endpoint_descriptor_t; 489 490 struct usb2_endpoint_ss_comp_descriptor { 491 uByte bLength; 492 uByte bDescriptorType; 493 uWord bMaxBurst; 494 uByte bmAttributes; 495 uWord wBytesPerInterval; 496 } __packed; 497 typedef struct usb2_endpoint_ss_comp_descriptor 498 usb_endpoint_ss_comp_descriptor_t; 499 500 struct usb2_string_descriptor { 501 uByte bLength; 502 uByte bDescriptorType; 503 uWord bString[126]; 504 uByte bUnused; 505 } __packed; 506 typedef struct usb2_string_descriptor usb_string_descriptor_t; 507 508 #define USB_MAKE_STRING_DESC(m,name) \ 509 struct name { \ 510 uByte bLength; \ 511 uByte bDescriptorType; \ 512 uByte bData[sizeof((uint8_t []){m})]; \ 513 } __packed; \ 514 static const struct name name = { \ 515 .bLength = sizeof(struct name), \ 516 .bDescriptorType = UDESC_STRING, \ 517 .bData = { m }, \ 518 } 519 520 struct usb2_hub_descriptor { 521 uByte bDescLength; 522 uByte bDescriptorType; 523 uByte bNbrPorts; 524 uWord wHubCharacteristics; 525 #define UHD_PWR 0x0003 526 #define UHD_PWR_GANGED 0x0000 527 #define UHD_PWR_INDIVIDUAL 0x0001 528 #define UHD_PWR_NO_SWITCH 0x0002 529 #define UHD_COMPOUND 0x0004 530 #define UHD_OC 0x0018 531 #define UHD_OC_GLOBAL 0x0000 532 #define UHD_OC_INDIVIDUAL 0x0008 533 #define UHD_OC_NONE 0x0010 534 #define UHD_TT_THINK 0x0060 535 #define UHD_TT_THINK_8 0x0000 536 #define UHD_TT_THINK_16 0x0020 537 #define UHD_TT_THINK_24 0x0040 538 #define UHD_TT_THINK_32 0x0060 539 #define UHD_PORT_IND 0x0080 540 uByte bPwrOn2PwrGood; /* delay in 2 ms units */ 541 #define UHD_PWRON_FACTOR 2 542 uByte bHubContrCurrent; 543 uByte DeviceRemovable[32]; /* max 255 ports */ 544 #define UHD_NOT_REMOV(desc, i) \ 545 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1) 546 uByte PortPowerCtrlMask[1]; /* deprecated */ 547 } __packed; 548 typedef struct usb2_hub_descriptor usb_hub_descriptor_t; 549 550 struct usb2_hub_ss_descriptor { 551 uByte bDescLength; 552 uByte bDescriptorType; 553 uByte bNbrPorts; /* max 15 */ 554 uWord wHubCharacteristics; 555 uByte bPwrOn2PwrGood; /* delay in 2 ms units */ 556 uByte bHubContrCurrent; 557 uByte bHubHdrDecLat; 558 uWord wHubDelay; 559 uByte DeviceRemovable[2]; /* max 15 ports */ 560 } __packed; 561 typedef struct usb2_hub_ss_descriptor usb_hub_ss_descriptor_t; 562 563 /* minimum HUB descriptor (8-ports maximum) */ 564 struct usb2_hub_descriptor_min { 565 uByte bDescLength; 566 uByte bDescriptorType; 567 uByte bNbrPorts; 568 uWord wHubCharacteristics; 569 uByte bPwrOn2PwrGood; 570 uByte bHubContrCurrent; 571 uByte DeviceRemovable[1]; 572 uByte PortPowerCtrlMask[1]; 573 } __packed; 574 typedef struct usb2_hub_descriptor_min usb_hub_descriptor_min_t; 575 576 struct usb2_device_qualifier { 577 uByte bLength; 578 uByte bDescriptorType; 579 uWord bcdUSB; 580 uByte bDeviceClass; 581 uByte bDeviceSubClass; 582 uByte bDeviceProtocol; 583 uByte bMaxPacketSize0; 584 uByte bNumConfigurations; 585 uByte bReserved; 586 } __packed; 587 typedef struct usb2_device_qualifier usb_device_qualifier_t; 588 589 struct usb2_otg_descriptor { 590 uByte bLength; 591 uByte bDescriptorType; 592 uByte bmAttributes; 593 #define UOTG_SRP 0x01 594 #define UOTG_HNP 0x02 595 } __packed; 596 typedef struct usb2_otg_descriptor usb_otg_descriptor_t; 597 598 /* OTG feature selectors */ 599 #define UOTG_B_HNP_ENABLE 3 600 #define UOTG_A_HNP_SUPPORT 4 601 #define UOTG_A_ALT_HNP_SUPPORT 5 602 603 struct usb2_status { 604 uWord wStatus; 605 /* Device status flags */ 606 #define UDS_SELF_POWERED 0x0001 607 #define UDS_REMOTE_WAKEUP 0x0002 608 /* Endpoint status flags */ 609 #define UES_HALT 0x0001 610 } __packed; 611 typedef struct usb2_status usb_status_t; 612 613 struct usb2_hub_status { 614 uWord wHubStatus; 615 #define UHS_LOCAL_POWER 0x0001 616 #define UHS_OVER_CURRENT 0x0002 617 uWord wHubChange; 618 } __packed; 619 typedef struct usb2_hub_status usb_hub_status_t; 620 621 struct usb2_port_status { 622 uWord wPortStatus; 623 #define UPS_CURRENT_CONNECT_STATUS 0x0001 624 #define UPS_PORT_ENABLED 0x0002 625 #define UPS_SUSPEND 0x0004 626 #define UPS_OVERCURRENT_INDICATOR 0x0008 627 #define UPS_RESET 0x0010 628 #define UPS_PORT_POWER 0x0100 629 #define UPS_LOW_SPEED 0x0200 630 #define UPS_HIGH_SPEED 0x0400 631 #define UPS_PORT_TEST 0x0800 632 #define UPS_PORT_INDICATOR 0x1000 633 #define UPS_PORT_MODE_DEVICE 0x8000 /* currently FreeBSD specific */ 634 uWord wPortChange; 635 #define UPS_C_CONNECT_STATUS 0x0001 636 #define UPS_C_PORT_ENABLED 0x0002 637 #define UPS_C_SUSPEND 0x0004 638 #define UPS_C_OVERCURRENT_INDICATOR 0x0008 639 #define UPS_C_PORT_RESET 0x0010 640 } __packed; 641 typedef struct usb2_port_status usb_port_status_t; 642 643 #endif /* _USB2_STANDARD_H_ */ 644