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