1 /* $NetBSD: usb.h,v 1.118 2019/08/23 07:17:31 mrg Exp $ */ 2 3 /* 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Lennart Augustsson (lennart@augustsson.net) at 9 * Carlstedt Research & Technology. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 34 #ifndef _USB_H_ 35 #define _USB_H_ 36 37 #include <sys/types.h> 38 #include <sys/time.h> 39 40 #include <sys/ioctl.h> 41 42 #if defined(_KERNEL) 43 44 #include <sys/device.h> 45 46 #endif 47 48 #ifdef USB_DEBUG 49 #define Static 50 #else 51 #define Static static 52 #endif 53 54 #define USB_STACK_VERSION 2 55 56 #define USB_MAX_DEVICES 128 /* 0, 1-127 */ 57 #define USB_MIN_DEVICES 2 /* unused + root HUB */ 58 #define USB_START_ADDR 0 59 60 #define USB_CONTROL_ENDPOINT 0 61 #define USB_MAX_ENDPOINTS 16 62 63 #define USB_FRAMES_PER_SECOND 1000 64 #define USB_UFRAMES_PER_FRAME 8 65 66 /* 67 * The USB records contain some unaligned little-endian word 68 * components. The U[SG]ETW macros take care of both the alignment 69 * and endian problem and should always be used to access non-byte 70 * values. 71 */ 72 typedef uint8_t uByte; 73 typedef uint8_t uWord[2]; 74 typedef uint8_t uDWord[4]; 75 76 #define USETW2(w,h,l) ((w)[0] = (uint8_t)(l), (w)[1] = (uint8_t)(h)) 77 78 #define UGETW(w) ((w)[0] | ((w)[1] << 8)) 79 #define USETW(w,v) ((w)[0] = (uint8_t)(v), (w)[1] = (uint8_t)((v) >> 8)) 80 #define USETWD(val) { (uint8_t)(val), (uint8_t)((val) >> 8) } 81 #define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24)) 82 #define USETDW(w,v) ((w)[0] = (uint8_t)(v), \ 83 (w)[1] = (uint8_t)((v) >> 8), \ 84 (w)[2] = (uint8_t)((v) >> 16), \ 85 (w)[3] = (uint8_t)((v) >> 24)) 86 #define UPACKED __packed 87 88 typedef struct { 89 uByte bmRequestType; 90 uByte bRequest; 91 uWord wValue; 92 uWord wIndex; 93 uWord wLength; 94 } UPACKED usb_device_request_t; 95 96 #define UT_GET_DIR(a) ((a) & 0x80) 97 #define UT_WRITE 0x00 98 #define UT_READ 0x80 99 100 #define UT_GET_TYPE(a) ((a) & 0x60) 101 #define UT_STANDARD 0x00 102 #define UT_CLASS 0x20 103 #define UT_VENDOR 0x40 104 105 #define UT_GET_RECIPIENT(a) ((a) & 0x1f) 106 #define UT_DEVICE 0x00 107 #define UT_INTERFACE 0x01 108 #define UT_ENDPOINT 0x02 109 #define UT_OTHER 0x03 110 111 #define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE) 112 #define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE) 113 #define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT) 114 #define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE) 115 #define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE) 116 #define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT) 117 #define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE) 118 #define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE) 119 #define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER) 120 #define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT) 121 #define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE) 122 #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE) 123 #define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER) 124 #define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT) 125 #define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE) 126 #define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE) 127 #define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER) 128 #define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT) 129 #define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE) 130 #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE) 131 #define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER) 132 #define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT) 133 134 /* Standard Requests Codes from the USB 2.0 spec, table 9-4 */ 135 #define UR_GET_STATUS 0x00 136 #define UR_CLEAR_FEATURE 0x01 137 #define UR_SET_FEATURE 0x03 138 #define UR_SET_ADDRESS 0x05 139 #define UR_GET_DESCRIPTOR 0x06 140 #define UDESC_DEVICE 0x01 141 #define UDESC_CONFIG 0x02 142 #define UDESC_STRING 0x03 143 #define UDESC_INTERFACE 0x04 144 #define UDESC_ENDPOINT 0x05 145 #define UDESC_DEVICE_QUALIFIER 0x06 146 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07 147 #define UDESC_INTERFACE_POWER 0x08 148 #define UDESC_OTG 0x09 149 #define UDESC_DEBUG 0x0a 150 #define UDESC_INTERFACE_ASSOC 0x0b 151 #define UDESC_BOS 0x0f 152 #define UDESC_DEVICE_CAPABILITY 0x10 153 #define UDESC_CS_DEVICE 0x21 /* class specific */ 154 #define UDESC_CS_CONFIG 0x22 155 #define UDESC_CS_STRING 0x23 156 #define UDESC_CS_INTERFACE 0x24 157 #define UDESC_CS_ENDPOINT 0x25 158 #define UDESC_HUB 0x29 159 #define UDESC_SS_HUB 0x2a /* super speed */ 160 #define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */ 161 #define UDESC_ENDPOINT_ISOCH_SSP_COMP 0x31 162 #define UR_SET_DESCRIPTOR 0x07 163 #define UR_GET_CONFIG 0x08 164 #define UR_SET_CONFIG 0x09 165 #define UR_GET_INTERFACE 0x0a 166 #define UR_SET_INTERFACE 0x0b 167 #define UR_SYNCH_FRAME 0x0c 168 #define UR_SET_ENCRYPTION 0x0d 169 #define UR_GET_ENCRYPTION 0x0e 170 #define UR_SET_HANDSHAKE 0x0f 171 #define UR_GET_HANDSHAKE 0x10 172 #define UR_SET_CONNECTION 0x11 173 #define UR_SET_SECURITY_DATA 0x12 174 #define UR_GET_SECURITY_DATA 0x13 175 #define UR_SET_WUSB_DATA 0x14 176 #define UR_LOOPBACK_DATA_WRITE 0x15 177 #define UR_LOOPBACK_DATA_READ 0x16 178 #define UR_SET_INTERFACE_DS 0x17 179 #define UR_SET_SEL 0x30 180 #define UR_SET_ISOCH_DELAY 0x31 181 182 /* 183 * Feature selectors. USB 2.0 spec, table 9-6 and OTG and EH suppliment, 184 * table 6-2 185 */ 186 #define UF_ENDPOINT_HALT 0 187 #define UF_INTERFACE_FUNCTION_SUSPEND 0 188 #define UF_DEVICE_REMOTE_WAKEUP 1 189 #define UF_TEST_MODE 2 190 #define UF_DEVICE_B_HNP_ENABLE 3 191 #define UF_DEVICE_A_HNP_SUPPORT 4 192 #define UF_DEVICE_A_ALT_HNP_SUPPORT 5 193 #define UF_DEVICE_WUSB_DEVICE 6 194 #define UF_U1_ENABLE 0x30 195 #define UF_U2_ENABLE 0x31 196 #define UF_LTM_ENABLE 0x32 197 198 #define USB_MAX_IPACKET 8 /* maximum size of the initial packet */ 199 200 #define USB_2_MAX_CTRL_PACKET 64 201 #define USB_2_MAX_BULK_PACKET 512 202 203 #define USB_3_MAX_CTRL_PACKET 512 204 205 typedef struct { 206 uByte bLength; 207 uByte bDescriptorType; 208 uByte bDescriptorSubtype; 209 } UPACKED usb_descriptor_t; 210 #define USB_DESCRIPTOR_SIZE 3 211 212 typedef struct { 213 uByte bLength; 214 uByte bDescriptorType; 215 uWord bcdUSB; 216 #define UD_USB_2_0 0x0200 217 #define UD_USB_3_0 0x0300 218 #define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0) 219 #define UD_IS_USB3(d) (UGETW((d)->bcdUSB) >= UD_USB_3_0) 220 uByte bDeviceClass; 221 uByte bDeviceSubClass; 222 uByte bDeviceProtocol; 223 uByte bMaxPacketSize; 224 /* The fields below are not part of the initial descriptor. */ 225 uWord idVendor; 226 uWord idProduct; 227 uWord bcdDevice; 228 uByte iManufacturer; 229 uByte iProduct; 230 uByte iSerialNumber; 231 uByte bNumConfigurations; 232 } UPACKED usb_device_descriptor_t; 233 #define USB_DEVICE_DESCRIPTOR_SIZE 18 234 235 typedef struct { 236 uByte bLength; 237 uByte bDescriptorType; 238 uWord wTotalLength; 239 uByte bNumInterface; 240 uByte bConfigurationValue; 241 uByte iConfiguration; 242 uByte bmAttributes; 243 #define UC_ATTR_MBO 0x80 244 #define UC_SELF_POWERED 0x40 245 #define UC_REMOTE_WAKEUP 0x20 246 uByte bMaxPower; /* max current in 2 mA units */ 247 #define UC_POWER_FACTOR 2 248 #define UC_POWER_FACTOR_SS 8 249 } UPACKED usb_config_descriptor_t; 250 #define USB_CONFIG_DESCRIPTOR_SIZE 9 251 252 typedef struct { 253 uByte bLength; 254 uByte bDescriptorType; 255 uByte bInterfaceNumber; 256 uByte bAlternateSetting; 257 uByte bNumEndpoints; 258 uByte bInterfaceClass; 259 uByte bInterfaceSubClass; 260 uByte bInterfaceProtocol; 261 uByte iInterface; 262 } UPACKED usb_interface_descriptor_t; 263 #define USB_INTERFACE_DESCRIPTOR_SIZE 9 264 265 typedef struct { 266 uByte bLength; 267 uByte bDescriptorType; 268 uByte bFirstInterface; 269 uByte bInterfaceCount; 270 uByte bFunctionClass; 271 uByte bFunctionSubClass; 272 uByte bFunctionProtocol; 273 uByte iFunction; 274 } UPACKED usb_interface_assoc_descriptor_t; 275 #define USB_INTERFACE_ASSOC_DESCRIPTOR_SIZE 8 276 277 typedef struct { 278 uByte bLength; 279 uByte bDescriptorType; 280 uByte bEndpointAddress; 281 #define UE_GET_DIR(a) ((a) & 0x80) 282 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7)) 283 #define UE_DIR_IN 0x80 284 #define UE_DIR_OUT 0x00 285 #define UE_ADDR 0x0f 286 #define UE_GET_ADDR(a) ((a) & UE_ADDR) 287 uByte bmAttributes; 288 #define UE_XFERTYPE 0x03 289 #define UE_CONTROL 0x00 290 #define UE_ISOCHRONOUS 0x01 291 #define UE_BULK 0x02 292 #define UE_INTERRUPT 0x03 293 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE) 294 #define UE_ISO_TYPE 0x0c 295 #define UE_ISO_ASYNC 0x04 296 #define UE_ISO_ADAPT 0x08 297 #define UE_ISO_SYNC 0x0c 298 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE) 299 uWord wMaxPacketSize; 300 #define UE_GET_TRANS(a) (((a) >> 11) & 0x3) 301 #define UE_GET_SIZE(a) ((a) & 0x7ff) 302 uByte bInterval; 303 } UPACKED usb_endpoint_descriptor_t; 304 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7 305 306 typedef struct { 307 uByte bLength; 308 uByte bDescriptorType; 309 uByte bMaxBurst; 310 uByte bmAttributes; 311 #define UE_GET_BULK_STREAMS_MASK __BITS(4,0) 312 #define UE_GET_BULK_STREAMS(x) __SHIFTOUT(x, UE_GET_BULK_STREAMS_MASK) 313 #define UE_GET_SS_ISO_MULT_MASK __BITS(1,0) 314 #define UE_GET_SS_ISO_MULT(x) __SHIFTOUT(x, UE_GET_SS_ISO_MULT_MASK) 315 #define UE_GET_SS_ISO_SSP_MASK __BIT(7) 316 #define UE_GET_SS_ISO_SSP(x) __SHIFTOUT(x, UE_GET_SS_ISO_SSP_MASK) 317 /* The fields below are only valid for periodic endpoints */ 318 uWord wBytesPerInterval; 319 } UPACKED usb_endpoint_ss_comp_descriptor_t; 320 #define USB_ENDPOINT_SS_COMP_DESCRIPTOR_SIZE 6 321 322 /* USB 3.0 9.6.2, Table 9-12 */ 323 typedef struct { 324 uByte bLength; 325 uByte bDescriptorType; 326 uWord wTotalLength; 327 uByte bNumDeviceCaps; 328 } UPACKED usb_bos_descriptor_t; 329 #define USB_BOS_DESCRIPTOR_SIZE 5 330 331 /* common members of device capability descriptors */ 332 typedef struct { 333 uByte bLength; 334 uByte bDescriptorType; 335 uByte bDevCapabilityType; 336 /* Table 9-14 */ 337 #define USB_DEVCAP_RESERVED 0x00 338 #define USB_DEVCAP_WUSB 0x01 339 #define USB_DEVCAP_USB2EXT 0x02 340 #define USB_DEVCAP_SUPER_SPEED 0x03 341 #define USB_DEVCAP_CONTAINER_ID 0x04 342 #define USB_DEVCAP_PLATFORM 0x05 343 #define USB_DEVCAP_POWER_DELIVERY_CAPABILITY 0x06 344 #define USB_DEVCAP_BATTERY_INFO_CAPABILITY 0x07 345 #define USB_DEVCAP_PD_CONSUMER_PORT_CAPABILITY 0x08 346 #define USB_DEVCAP_PD_PROVIDER_PORT_CAPABILITY 0x09 347 #define USB_DEVCAP_SUPERSPEED_PLUS 0x0a 348 #define USB_DEVCAP_PRECISION_TIME_MEASUREMENT 0x0b 349 #define USB_DEVCAP_WUSB_EXT 0x0c 350 /* data ... */ 351 } UPACKED usb_device_capability_descriptor_t; 352 #define USB_DEVICE_CAPABILITY_DESCRIPTOR_SIZE 3 /* at least */ 353 354 /* 9.6.2.1 */ 355 typedef struct { 356 uByte bLength; 357 uByte bDescriptorType; 358 uByte bDevCapabilityType; 359 uDWord bmAttributes; 360 #define USB_DEVCAP_V2EXT_LPM __BIT(1) 361 #define USB_DEVCAP_V2EXT_BESL_SUPPORTED __BIT(2) 362 #define USB_DEVCAP_V2EXT_BESL_BASELINE_VALID __BIT(3) 363 #define USB_DEVCAP_V2EXT_BESL_DEEP_VALID __BIT(4) 364 #define USB_DEVCAP_V2EXT_BESL_BASELINE_MASK __BITS(11, 8) 365 #define USB_DEVCAP_V2EXT_BESL_BASELINE_GET(x) __SHIFTOUT(x, USB_V2EXT_BESL_BASELINE_MASK) 366 #define USB_DEVCAP_V2EXT_BESL_DEEP_MASK __BITS(15, 12) 367 #define USB_DEVCAP_V2EXT_BESL_DEEP_GET(x) __SHIFTOUT(x, USB_V2EXT_BESL_DEEP_MASK) 368 } UPACKED usb_devcap_usb2ext_descriptor_t; 369 #define USB_DEVCAP_USB2EXT_DESCRIPTOR_SIZE 7 370 371 /* 9.6.2.2 */ 372 typedef struct { 373 uByte bLength; 374 uByte bDescriptorType; 375 uByte bDevCapabilityType; 376 uByte bmAttributes; 377 #define USB_DEVCAP_SS_LTM __BIT(1) 378 uWord wSpeedsSupported; 379 #define USB_DEVCAP_SS_SPEED_LS __BIT(0) 380 #define USB_DEVCAP_SS_SPEED_FS __BIT(1) 381 #define USB_DEVCAP_SS_SPEED_HS __BIT(2) 382 #define USB_DEVCAP_SS_SPEED_SS __BIT(3) 383 uByte bFunctionalitySupport; 384 uByte bU1DevExitLat; 385 uWord wU2DevExitLat; 386 } UPACKED usb_devcap_ss_descriptor_t; 387 #define USB_DEVCAP_SS_DESCRIPTOR_SIZE 10 388 389 /* 9.6.2.4 */ 390 typedef struct { 391 uByte bLength; 392 uByte bDescriptorType; 393 uByte bDevCapabilityType; 394 uByte bReserved; 395 uByte ContainerID[16]; 396 } UPACKED usb_devcap_container_id_descriptor_t; 397 #define USB_DEVCAP_CONTAINER_ID_DESCRIPTOR_SIZE 20 398 399 typedef struct { 400 uByte bLength; 401 uByte bDescriptorType; 402 uByte bDevCapabilityType; 403 uByte bReserved; 404 uByte PlatformCapabilityUUID[16]; 405 uByte CapabilityData[0]; 406 } UPACKED usb_devcap_platform_descriptor_t; 407 #define USB_DEVCAP_PLATFORM_DESCRIPTOR_SIZE 20 408 409 /* usb 3.1 ch 9.6.2.5 */ 410 typedef struct { 411 uByte bLength; 412 uByte bDescriptorType; 413 uByte bDevCapabilityType; 414 uByte bReserved; 415 uDWord bmAttributes; 416 #define USB_DEVCAP_SSP_SSAC(x) __SHIFTOUT(x, __BITS(4,0)) 417 #define USB_DEVCAP_SSP_SSIC(x) __SHIFTOUT(x, __BITS(8,5)) 418 uWord wFunctionalitySupport; 419 #define USB_DEVCAP_SSP_SSID(x) __SHIFTOUT(x, __BITS(3,0)) 420 #define USB_DEVCAP_SSP_MIN_RXLANE_COUNT(x) __SHIFTOUT(x, __BITS(11,8)) 421 #define USB_DEVCAP_SSP_MIN_TXLANE_COUNT(x) __SHIFTOUT(x, __BITS(15,12)) 422 uWord wReserved; 423 uDWord bmSublinkSpeedAttr[0]; 424 #define USB_DEVCAP_SSP_SSID(x) __SHIFTOUT(x, __BITS(3,0)) 425 #define USB_DEVCAP_SSP_LSE(x) __SHIFTOUT(x, __BITS(5,4)) 426 #define USB_DEVCAP_SSP_ST(x) __SHIFTOUT(x, __BITS(7,6)) 427 #define USB_DEVCAP_SSP_LP(x) __SHIFTOUT(x, __BITS(15,14)) 428 #define USB_DEVCAP_SSP_LSM(x) __SHIFTOUT(x, __BITS(31,16)) 429 } UPACKED usb_devcap_ssp_descriptor_t; 430 #define USB_DEVCAP_SSP_DESCRIPTOR_SIZE 12 /* variable length */ 431 432 typedef struct { 433 uByte bLength; 434 uByte bDescriptorType; 435 uWord bString[126]; 436 } UPACKED usb_string_descriptor_t; 437 #define USB_MAX_STRING_LEN 128 438 #define USB_LANGUAGE_TABLE 0 /* # of the string language id table */ 439 #define USB_MAX_ENCODED_STRING_LEN (USB_MAX_STRING_LEN * 3) /* UTF8 */ 440 441 /* Hub specific request */ 442 #define UR_GET_BUS_STATE 0x02 443 #define UR_CLEAR_TT_BUFFER 0x08 444 #define UR_RESET_TT 0x09 445 #define UR_GET_TT_STATE 0x0a 446 #define UR_STOP_TT 0x0b 447 #define UR_SET_AND_TEST 0x0c /* USB 2.0 only */ 448 #define UR_SET_HUB_DEPTH 0x0c /* USB 3.0 only */ 449 #define UR_GET_PORT_ERR_COUNT 0x0d 450 /* Port Status Type for GET_STATUS, USB 3.1 10.16.2.6 and Table 10-12 */ 451 #define UR_PST_PORT_STATUS 0 452 #define UR_PST_PD_STATUS 1 453 #define UR_PST_EXT_PORT_STATUS 2 454 455 /* 456 * Hub features from USB 2.0 spec, table 11-17 and updated by the 457 * LPM ECN table 4-7. 458 */ 459 #define UHF_C_HUB_LOCAL_POWER 0 460 #define UHF_C_HUB_OVER_CURRENT 1 461 #define UHF_PORT_CONNECTION 0 462 #define UHF_PORT_ENABLE 1 463 #define UHF_PORT_SUSPEND 2 464 #define UHF_PORT_OVER_CURRENT 3 465 #define UHF_PORT_RESET 4 466 #define UHF_PORT_LINK_STATE 5 467 #define UHF_PORT_POWER 8 468 #define UHF_PORT_LOW_SPEED 9 469 #define UHF_PORT_L1 10 470 #define UHF_C_PORT_CONNECTION 16 471 #define UHF_C_PORT_ENABLE 17 472 #define UHF_C_PORT_SUSPEND 18 473 #define UHF_C_PORT_OVER_CURRENT 19 474 #define UHF_C_PORT_RESET 20 475 #define UHF_PORT_TEST 21 476 #define UHF_PORT_INDICATOR 22 477 #define UHF_C_PORT_L1 23 478 479 /* SS HUB specific features */ 480 #define UHF_PORT_U1_TIMEOUT 23 481 #define UHF_PORT_U2_TIMEOUT 24 482 #define UHF_C_PORT_LINK_STATE 25 483 #define UHF_C_PORT_CONFIG_ERROR 26 484 #define UHF_PORT_REMOTE_WAKE_MASK 27 485 #define UHF_BH_PORT_RESET 28 486 #define UHF_C_BH_PORT_RESET 29 487 #define UHF_FORCE_LINKPM_ACCEPT 30 488 489 typedef struct { 490 uByte bDescLength; 491 uByte bDescriptorType; 492 uByte bNbrPorts; 493 #define UHD_NPORTS_MAX 255 494 uWord wHubCharacteristics; 495 #define UHD_PWR 0x0003 496 #define UHD_PWR_GANGED 0x0000 497 #define UHD_PWR_INDIVIDUAL 0x0001 498 #define UHD_PWR_NO_SWITCH 0x0002 499 #define UHD_COMPOUND 0x0004 500 #define UHD_OC 0x0018 501 #define UHD_OC_GLOBAL 0x0000 502 #define UHD_OC_INDIVIDUAL 0x0008 503 #define UHD_OC_NONE 0x0010 504 #define UHD_TT_THINK 0x0060 505 #define UHD_TT_THINK_8 0x0000 506 #define UHD_TT_THINK_16 0x0020 507 #define UHD_TT_THINK_24 0x0040 508 #define UHD_TT_THINK_32 0x0060 509 #define UHD_PORT_IND 0x0080 510 uByte bPwrOn2PwrGood; /* delay in 2 ms units */ 511 #define UHD_PWRON_FACTOR 2 512 uByte bHubContrCurrent; 513 uByte DeviceRemovable[32]; /* max 255 ports */ 514 #define UHD_NOT_REMOV(desc, i) \ 515 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1) 516 /* deprecated */ uByte PortPowerCtrlMask[1]; 517 } UPACKED usb_hub_descriptor_t; 518 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */ 519 520 typedef struct { 521 uByte bLength; 522 uByte bDescriptorType; 523 uByte bNbrPorts; 524 #define UHD_SS_NPORTS_MAX 15 525 uWord wHubCharacteristics; 526 uByte bPwrOn2PwrGood; /* delay in 2 ms units */ 527 uByte bHubContrCurrent; 528 uByte bHubHdrDecLat; 529 uWord wHubDelay; /* forward delay in nanosec */ 530 uByte DeviceRemovable[2]; /* max 15 ports */ 531 } UPACKED usb_hub_ss_descriptor_t; 532 #define USB_HUB_SS_DESCRIPTOR_SIZE 12 533 534 typedef struct { 535 uByte bLength; 536 uByte bDescriptorType; 537 uWord bcdUSB; 538 uByte bDeviceClass; 539 uByte bDeviceSubClass; 540 uByte bDeviceProtocol; 541 uByte bMaxPacketSize0; 542 uByte bNumConfigurations; 543 uByte bReserved; 544 } UPACKED usb_device_qualifier_t; 545 #define USB_DEVICE_QUALIFIER_SIZE 10 546 547 typedef struct { 548 uByte bLength; 549 uByte bDescriptorType; 550 uByte bmAttributes; 551 #define UOTG_SRP 0x01 552 #define UOTG_HNP 0x02 553 } UPACKED usb_otg_descriptor_t; 554 555 /* OTG feature selectors */ 556 #define UOTG_B_HNP_ENABLE 3 557 #define UOTG_A_HNP_SUPPORT 4 558 #define UOTG_A_ALT_HNP_SUPPORT 5 559 560 typedef struct { 561 uByte bLength; 562 uByte bDescriptorType; 563 uByte bDebugInEndpoint; 564 uByte bDebugOutEndpoint; 565 } UPACKED usb_debug_descriptor_t; 566 567 typedef struct { 568 uWord wStatus; 569 /* Device status flags */ 570 #define UDS_SELF_POWERED 0x0001 571 #define UDS_REMOTE_WAKEUP 0x0002 572 /* Endpoint status flags */ 573 #define UES_HALT 0x0001 574 } UPACKED usb_status_t; 575 576 typedef struct { 577 uWord wHubStatus; 578 #define UHS_LOCAL_POWER 0x0001 579 #define UHS_OVER_CURRENT 0x0002 580 uWord wHubChange; 581 } UPACKED usb_hub_status_t; 582 583 typedef struct { 584 uWord wPortStatus; 585 #define UPS_CURRENT_CONNECT_STATUS 0x0001 586 #define UPS_PORT_ENABLED 0x0002 587 #define UPS_SUSPEND 0x0004 588 #define UPS_OVERCURRENT_INDICATOR 0x0008 589 #define UPS_RESET 0x0010 590 #define UPS_PORT_L1 0x0020 591 #define UPS_PORT_LS_MASK __BITS(8,5) 592 #define UPS_PORT_LS_GET(x) __SHIFTOUT(x, UPS_PORT_LS_MASK) 593 #define UPS_PORT_LS_SET(x) __SHIFTIN(x, UPS_PORT_LS_MASK) 594 #define UPS_PORT_LS_U0 0x00 595 #define UPS_PORT_LS_U1 0x01 596 #define UPS_PORT_LS_U2 0x02 597 #define UPS_PORT_LS_U3 0x03 598 #define UPS_PORT_LS_SS_DIS 0x04 599 #define UPS_PORT_LS_RX_DET 0x05 600 #define UPS_PORT_LS_SS_INA 0x06 601 #define UPS_PORT_LS_POLL 0x07 602 #define UPS_PORT_LS_RECOVER 0x08 603 #define UPS_PORT_LS_HOT_RST 0x09 604 #define UPS_PORT_LS_COMP_MODE 0x0a 605 #define UPS_PORT_LS_LOOPBACK 0x0b 606 #define UPS_PORT_LS_RESUME 0x0f 607 #define UPS_PORT_POWER 0x0100 608 #define UPS_PORT_POWER_SS 0x0200 609 #define UPS_FULL_SPEED 0x0000 /* for completeness */ 610 #define UPS_LOW_SPEED 0x0200 611 #define UPS_HIGH_SPEED 0x0400 612 #define UPS_PORT_TEST 0x0800 613 #define UPS_PORT_INDICATOR 0x1000 614 #define UPS_OTHER_SPEED 0x2000 /* currently NetBSD specific */ 615 uWord wPortChange; 616 #define UPS_C_CONNECT_STATUS 0x0001 617 #define UPS_C_PORT_ENABLED 0x0002 618 #define UPS_C_SUSPEND 0x0004 619 #define UPS_C_OVERCURRENT_INDICATOR 0x0008 620 #define UPS_C_PORT_RESET 0x0010 621 #define UPS_C_PORT_L1 0x0020 622 #define UPS_C_BH_PORT_RESET 0x0020 623 #define UPS_C_PORT_LINK_STATE 0x0040 624 #define UPS_C_PORT_CONFIG_ERROR 0x0080 625 } UPACKED usb_port_status_t; 626 627 /* 10.16.2.6 */ 628 /* Valid when port status type is UR_PST_EXT_PORT_STATUS. */ 629 typedef struct { 630 uWord wPortStatus; 631 uWord wPortChange; 632 uDWord dwExtPortStatus; 633 } UPACKED usb_port_status_ext_t; 634 635 /* Device class codes */ 636 #define UDCLASS_IN_INTERFACE 0x00 637 #define UDCLASS_COMM 0x02 638 #define UDCLASS_HUB 0x09 639 #define UDSUBCLASS_HUB 0x00 640 #define UDPROTO_FSHUB 0x00 641 #define UDPROTO_HSHUBSTT 0x01 642 #define UDPROTO_HSHUBMTT 0x02 643 #define UDPROTO_SSHUB 0x03 644 #define UDCLASS_DIAGNOSTIC 0xdc 645 #define UDCLASS_WIRELESS 0xe0 646 #define UDSUBCLASS_RF 0x01 647 #define UDPROTO_BLUETOOTH 0x01 648 #define UDCLASS_VENDOR 0xff 649 650 /* Interface class codes */ 651 #define UICLASS_UNSPEC 0x00 652 653 #define UICLASS_AUDIO 0x01 654 #define UISUBCLASS_AUDIOCONTROL 1 655 #define UISUBCLASS_AUDIOSTREAM 2 656 #define UISUBCLASS_MIDISTREAM 3 657 658 #define UICLASS_VIDEO 0x0e 659 #define UISUBCLASS_VIDEOCONTROL 1 660 #define UISUBCLASS_VIDEOSTREAMING 2 661 #define UISUBCLASS_VIDEOCOLLECTION 3 662 663 #define UICLASS_CDC 0x02 /* communication */ 664 #define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1 665 #define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2 666 #define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3 667 #define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4 668 #define UISUBCLASS_CAPI_CONTROLMODEL 5 669 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6 670 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7 671 #define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10 672 #define UISUBCLASS_NETWORK_CONTROL_MODEL 13 673 #define UISUBCLASS_MOBILE_BROADBAND_INTERFACE_MODEL 14 674 #define UIPROTO_CDC_NOCLASS 0 /* no class specific 675 protocol required */ 676 #define UIPROTO_CDC_AT 1 677 678 #define UICLASS_HID 0x03 679 #define UISUBCLASS_BOOT 1 680 #define UIPROTO_BOOT_KEYBOARD 1 681 #define UIPROTO_MOUSE 2 682 683 #define UICLASS_PHYSICAL 0x05 684 685 #define UICLASS_IMAGE 0x06 686 687 #define UICLASS_PRINTER 0x07 688 #define UISUBCLASS_PRINTER 1 689 #define UIPROTO_PRINTER_UNI 1 690 #define UIPROTO_PRINTER_BI 2 691 #define UIPROTO_PRINTER_1284 3 692 693 #define UICLASS_MASS 0x08 694 #define UISUBCLASS_RBC 1 695 #define UISUBCLASS_SFF8020I 2 696 #define UISUBCLASS_QIC157 3 697 #define UISUBCLASS_UFI 4 698 #define UISUBCLASS_SFF8070I 5 699 #define UISUBCLASS_SCSI 6 700 #define UIPROTO_MASS_CBI_I 0 701 #define UIPROTO_MASS_CBI 1 702 #define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */ 703 #define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */ 704 #define UIPROTO_MASS_UAS 98 /* USB Attached SCSI */ 705 706 #define UICLASS_HUB 0x09 707 #define UISUBCLASS_HUB 0 708 #define UIPROTO_FSHUB 0 709 #define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */ 710 #define UIPROTO_HSHUBMTT 1 711 712 #define UICLASS_CDC_DATA 0x0a 713 #define UISUBCLASS_DATA 0 714 #define UIPROTO_DATA_MBIM 0x02 /* MBIM */ 715 #define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */ 716 #define UIPROTO_DATA_HDLC 0x31 /* HDLC */ 717 #define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */ 718 #define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */ 719 #define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */ 720 #define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */ 721 #define UIPROTO_DATA_V42BIS 0x90 /* Data compression */ 722 #define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */ 723 #define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */ 724 #define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */ 725 #define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */ 726 #define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc.*/ 727 #define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */ 728 729 #define UICLASS_SMARTCARD 0x0b 730 731 /*#define UICLASS_FIRM_UPD 0x0c*/ 732 733 #define UICLASS_SECURITY 0x0d 734 735 #define UICLASS_DIAGNOSTIC 0xdc 736 737 #define UICLASS_WIRELESS 0xe0 738 #define UISUBCLASS_RF 0x01 739 #define UIPROTO_BLUETOOTH 0x01 740 #define UIPROTO_RNDIS 0x03 741 742 #define UICLASS_APPL_SPEC 0xfe 743 #define UISUBCLASS_FIRMWARE_DOWNLOAD 1 744 #define UISUBCLASS_IRDA 2 745 #define UIPROTO_IRDA 0 746 747 #define UICLASS_VENDOR 0xff 748 749 750 #define USB_HUB_MAX_DEPTH 5 751 752 /* 753 * Minimum time a device needs to be powered down to go through 754 * a power cycle. XXX Are these time in the spec? 755 */ 756 #define USB_POWER_DOWN_TIME 200 /* ms */ 757 #define USB_PORT_POWER_DOWN_TIME 100 /* ms */ 758 759 #if 0 760 /* These are the values from the spec. */ 761 #define USB_PORT_RESET_DELAY 10 /* ms */ 762 #define USB_PORT_ROOT_RESET_DELAY 50 /* ms */ 763 #define USB_PORT_RESET_RECOVERY 10 /* ms */ 764 #define USB_PORT_POWERUP_DELAY 100 /* ms */ 765 #define USB_SET_ADDRESS_SETTLE 2 /* ms */ 766 #define USB_RESUME_DELAY (20*5) /* ms */ 767 #define USB_RESUME_WAIT 10 /* ms */ 768 #define USB_RESUME_RECOVERY 10 /* ms */ 769 #define USB_EXTRA_POWER_UP_TIME 0 /* ms */ 770 #else 771 /* Allow for marginal (i.e. non-conforming) devices. */ 772 #define USB_PORT_RESET_DELAY 50 /* ms */ 773 #define USB_PORT_ROOT_RESET_DELAY 250 /* ms */ 774 #define USB_PORT_RESET_RECOVERY 250 /* ms */ 775 #define USB_PORT_POWERUP_DELAY 300 /* ms */ 776 #define USB_SET_ADDRESS_SETTLE 10 /* ms */ 777 #define USB_RESUME_DELAY (50*5) /* ms */ 778 #define USB_RESUME_WAIT 50 /* ms */ 779 #define USB_RESUME_RECOVERY 50 /* ms */ 780 #define USB_EXTRA_POWER_UP_TIME 20 /* ms */ 781 #endif 782 783 #define USB_MIN_POWER 100 /* mA */ 784 #define USB_MIN_POWER_SS 150 /* mA */ 785 #define USB_MAX_POWER 500 /* mA */ 786 #define USB_MAX_POWER_SS 900 /* mA */ 787 788 #define USB_BUS_RESET_DELAY 100 /* ms XXX?*/ 789 790 791 #define USB_UNCONFIG_NO 0 792 #define USB_UNCONFIG_INDEX (-1) 793 794 795 /* Packet IDs */ 796 #define UPID_RESERVED 0xf0 797 #define UPID_OUT 0xe1 798 #define UPID_ACK 0xd2 799 #define UPID_DATA0 0xc3 800 #define UPID_PING 0xb4 801 #define UPID_SOF 0xa5 802 #define UPID_NYET 0x96 803 #define UPID_DATA2 0x87 804 #define UPID_SPLIT 0x78 805 #define UPID_IN 0x69 806 #define UPID_NAK 0x5a 807 #define UPID_DATA1 0x4b 808 #define UPID_ERR 0x3c 809 #define UPID_PREAMBLE 0x3c 810 #define UPID_SETUP 0x2d 811 #define UPID_STALL 0x1e 812 #define UPID_MDATA 0x0f 813 814 815 /*** ioctl() related stuff ***/ 816 817 struct usb_ctl_request { 818 int ucr_addr; 819 usb_device_request_t ucr_request; 820 void *ucr_data; 821 int ucr_flags; 822 #define USBD_SHORT_XFER_OK 0x04 /* allow short reads */ 823 int ucr_actlen; /* actual length transferred */ 824 }; 825 826 struct usb_alt_interface { 827 int uai_config_index; 828 int uai_interface_index; 829 int uai_alt_no; 830 }; 831 832 #define USB_CURRENT_CONFIG_INDEX (-1) 833 #define USB_CURRENT_ALT_INDEX (-1) 834 835 struct usb_config_desc { 836 int ucd_config_index; 837 usb_config_descriptor_t ucd_desc; 838 }; 839 840 struct usb_interface_desc { 841 int uid_config_index; 842 int uid_interface_index; 843 int uid_alt_index; 844 usb_interface_descriptor_t uid_desc; 845 }; 846 847 struct usb_endpoint_desc { 848 int ued_config_index; 849 int ued_interface_index; 850 int ued_alt_index; 851 int ued_endpoint_index; 852 usb_endpoint_descriptor_t ued_desc; 853 }; 854 855 struct usb_full_desc { 856 int ufd_config_index; 857 unsigned ufd_size; 858 unsigned char *ufd_data; 859 }; 860 861 struct usb_string_desc { 862 int usd_string_index; 863 int usd_language_id; 864 usb_string_descriptor_t usd_desc; 865 }; 866 867 struct usb_ctl_report_desc { 868 int ucrd_size; 869 unsigned char ucrd_data[1024]; /* filled data size will vary */ 870 }; 871 872 typedef struct { uint32_t cookie; } usb_event_cookie_t; 873 874 #define USB_MAX_DEVNAMES 4 875 #define USB_MAX_DEVNAMELEN 16 876 struct usb_device_info { 877 uint8_t udi_bus; 878 uint8_t udi_addr; /* device address */ 879 usb_event_cookie_t udi_cookie; 880 char udi_product[USB_MAX_ENCODED_STRING_LEN]; 881 char udi_vendor[USB_MAX_ENCODED_STRING_LEN]; 882 char udi_release[8]; 883 char udi_serial[USB_MAX_ENCODED_STRING_LEN]; 884 uint16_t udi_productNo; 885 uint16_t udi_vendorNo; 886 uint16_t udi_releaseNo; 887 uint8_t udi_class; 888 uint8_t udi_subclass; 889 uint8_t udi_protocol; 890 uint8_t udi_config; 891 uint8_t udi_speed; 892 #define USB_SPEED_LOW 1 893 #define USB_SPEED_FULL 2 894 #define USB_SPEED_HIGH 3 895 #define USB_SPEED_SUPER 4 896 #define USB_SPEED_SUPER_PLUS 5 897 #define USB_IS_SS(X) ((X) == USB_SPEED_SUPER || (X) == USB_SPEED_SUPER_PLUS) 898 int udi_power; /* power consumption in mA, 0 if selfpowered */ 899 int udi_nports; 900 char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN]; 901 uint8_t udi_ports[16];/* hub only: addresses of devices on ports */ 902 #define USB_PORT_ENABLED 0xff 903 #define USB_PORT_SUSPENDED 0xfe 904 #define USB_PORT_POWERED 0xfd 905 #define USB_PORT_DISABLED 0xfc 906 }; 907 908 /* <=3.0 had this layout of the structure */ 909 struct usb_device_info_old { 910 uint8_t udi_bus; 911 uint8_t udi_addr; /* device address */ 912 usb_event_cookie_t udi_cookie; 913 char udi_product[USB_MAX_STRING_LEN]; 914 char udi_vendor[USB_MAX_STRING_LEN]; 915 char udi_release[8]; 916 uint16_t udi_productNo; 917 uint16_t udi_vendorNo; 918 uint16_t udi_releaseNo; 919 uint8_t udi_class; 920 uint8_t udi_subclass; 921 uint8_t udi_protocol; 922 uint8_t udi_config; 923 uint8_t udi_speed; 924 int udi_power; /* power consumption in mA, 0 if selfpowered */ 925 int udi_nports; 926 char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN]; 927 uint8_t udi_ports[16];/* hub only: addresses of devices on ports */ 928 }; 929 930 struct usb_ctl_report { 931 int ucr_report; 932 unsigned char ucr_data[1024]; /* filled data size will vary */ 933 }; 934 935 struct usb_device_stats { 936 unsigned long uds_requests[4]; /* indexed by transfer type UE_* */ 937 }; 938 939 struct usb_bulk_ra_wb_opt { 940 unsigned ra_wb_buffer_size; 941 unsigned ra_wb_request_size; 942 }; 943 944 /* Events that can be read from /dev/usb */ 945 struct usb_event { 946 int ue_type; 947 #define USB_EVENT_CTRLR_ATTACH 1 948 #define USB_EVENT_CTRLR_DETACH 2 949 #define USB_EVENT_DEVICE_ATTACH 3 950 #define USB_EVENT_DEVICE_DETACH 4 951 #define USB_EVENT_DRIVER_ATTACH 5 952 #define USB_EVENT_DRIVER_DETACH 6 953 #define USB_EVENT_IS_ATTACH(n) ((n) == USB_EVENT_CTRLR_ATTACH || (n) == USB_EVENT_DEVICE_ATTACH || (n) == USB_EVENT_DRIVER_ATTACH) 954 #define USB_EVENT_IS_DETACH(n) ((n) == USB_EVENT_CTRLR_DETACH || (n) == USB_EVENT_DEVICE_DETACH || (n) == USB_EVENT_DRIVER_DETACH) 955 struct timespec ue_time; 956 union { 957 struct { 958 int ue_bus; 959 } ue_ctrlr; 960 struct usb_device_info ue_device; 961 struct { 962 usb_event_cookie_t ue_cookie; 963 char ue_devname[16]; 964 } ue_driver; 965 } u; 966 }; 967 968 /* old <=3.0 compat event */ 969 struct usb_event_old { 970 int ue_type; 971 struct timespec ue_time; 972 union { 973 struct { 974 int ue_bus; 975 } ue_ctrlr; 976 struct usb_device_info_old ue_device; 977 struct { 978 usb_event_cookie_t ue_cookie; 979 char ue_devname[16]; 980 } ue_driver; 981 } u; 982 }; 983 984 985 /* USB controller */ 986 #define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request) 987 #define USB_SETDEBUG _IOW ('U', 2, int) 988 #define USB_DISCOVER _IO ('U', 3) 989 #define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info) 990 #define USB_DEVICEINFO_OLD _IOWR('U', 4, struct usb_device_info_old) 991 #define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) 992 993 /* Generic HID device */ 994 #define USB_GET_REPORT_DESC _IOR ('U', 21, struct usb_ctl_report_desc) 995 #define USB_SET_IMMED _IOW ('U', 22, int) 996 #define USB_GET_REPORT _IOWR('U', 23, struct usb_ctl_report) 997 #define USB_SET_REPORT _IOW ('U', 24, struct usb_ctl_report) 998 #define USB_GET_REPORT_ID _IOR ('U', 25, int) 999 1000 /* Generic USB device */ 1001 #define USB_GET_CONFIG _IOR ('U', 100, int) 1002 #define USB_SET_CONFIG _IOW ('U', 101, int) 1003 #define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface) 1004 #define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface) 1005 #define USB_GET_NO_ALT _IOWR('U', 104, struct usb_alt_interface) 1006 #define USB_GET_DEVICE_DESC _IOR ('U', 105, usb_device_descriptor_t) 1007 #define USB_GET_CONFIG_DESC _IOWR('U', 106, struct usb_config_desc) 1008 #define USB_GET_INTERFACE_DESC _IOWR('U', 107, struct usb_interface_desc) 1009 #define USB_GET_ENDPOINT_DESC _IOWR('U', 108, struct usb_endpoint_desc) 1010 #define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_full_desc) 1011 #define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_string_desc) 1012 #define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request) 1013 #define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) 1014 #define USB_GET_DEVICEINFO_OLD _IOR ('U', 112, struct usb_device_info_old) 1015 #define USB_SET_SHORT_XFER _IOW ('U', 113, int) 1016 #define USB_SET_TIMEOUT _IOW ('U', 114, int) 1017 #define USB_SET_BULK_RA _IOW ('U', 115, int) 1018 #define USB_SET_BULK_WB _IOW ('U', 116, int) 1019 #define USB_SET_BULK_RA_OPT _IOW ('U', 117, struct usb_bulk_ra_wb_opt) 1020 #define USB_SET_BULK_WB_OPT _IOW ('U', 118, struct usb_bulk_ra_wb_opt) 1021 1022 /* Modem device */ 1023 #define USB_GET_CM_OVER_DATA _IOR ('U', 130, int) 1024 #define USB_SET_CM_OVER_DATA _IOW ('U', 131, int) 1025 1026 #endif /* _USB_H_ */ 1027