1 /*	$NetBSD: usb.h,v 1.113 2016/04/23 10:15:32 skrll 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
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 } UPACKED usb_descriptor_t;
209 
210 typedef struct {
211 	uByte		bLength;
212 	uByte		bDescriptorType;
213 	uWord		bcdUSB;
214 #define UD_USB_2_0		0x0200
215 #define UD_USB_3_0		0x0300
216 #define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0)
217 #define UD_IS_USB3(d) (UGETW((d)->bcdUSB) >= UD_USB_3_0)
218 	uByte		bDeviceClass;
219 	uByte		bDeviceSubClass;
220 	uByte		bDeviceProtocol;
221 	uByte		bMaxPacketSize;
222 	/* The fields below are not part of the initial descriptor. */
223 	uWord		idVendor;
224 	uWord		idProduct;
225 	uWord		bcdDevice;
226 	uByte		iManufacturer;
227 	uByte		iProduct;
228 	uByte		iSerialNumber;
229 	uByte		bNumConfigurations;
230 } UPACKED usb_device_descriptor_t;
231 #define USB_DEVICE_DESCRIPTOR_SIZE 18
232 
233 typedef struct {
234 	uByte		bLength;
235 	uByte		bDescriptorType;
236 	uWord		wTotalLength;
237 	uByte		bNumInterface;
238 	uByte		bConfigurationValue;
239 	uByte		iConfiguration;
240 	uByte		bmAttributes;
241 #define UC_ATTR_MBO		0x80
242 #define UC_SELF_POWERED		0x40
243 #define UC_REMOTE_WAKEUP	0x20
244 	uByte		bMaxPower; /* max current in 2 mA units */
245 #define UC_POWER_FACTOR 2
246 #define UC_POWER_FACTOR_SS 8
247 } UPACKED usb_config_descriptor_t;
248 #define USB_CONFIG_DESCRIPTOR_SIZE 9
249 
250 typedef struct {
251 	uByte		bLength;
252 	uByte		bDescriptorType;
253 	uByte		bInterfaceNumber;
254 	uByte		bAlternateSetting;
255 	uByte		bNumEndpoints;
256 	uByte		bInterfaceClass;
257 	uByte		bInterfaceSubClass;
258 	uByte		bInterfaceProtocol;
259 	uByte		iInterface;
260 } UPACKED usb_interface_descriptor_t;
261 #define USB_INTERFACE_DESCRIPTOR_SIZE 9
262 
263 typedef struct {
264 	uByte		bLength;
265 	uByte		bDescriptorType;
266 	uByte		bFirstInterface;
267 	uByte		bInterfaceCount;
268 	uByte		bFunctionClass;
269 	uByte		bFunctionSubClass;
270 	uByte		bFunctionProtocol;
271 	uByte		iFunction;
272 } UPACKED usb_interface_assoc_descriptor_t;
273 #define USB_INTERFACE_ASSOC_DESCRIPTOR_SIZE 8
274 
275 typedef struct {
276 	uByte		bLength;
277 	uByte		bDescriptorType;
278 	uByte		bEndpointAddress;
279 #define UE_GET_DIR(a)	((a) & 0x80)
280 #define UE_SET_DIR(a,d)	((a) | (((d)&1) << 7))
281 #define UE_DIR_IN	0x80
282 #define UE_DIR_OUT	0x00
283 #define UE_ADDR		0x0f
284 #define UE_GET_ADDR(a)	((a) & UE_ADDR)
285 	uByte		bmAttributes;
286 #define UE_XFERTYPE	0x03
287 #define  UE_CONTROL	0x00
288 #define  UE_ISOCHRONOUS	0x01
289 #define  UE_BULK	0x02
290 #define  UE_INTERRUPT	0x03
291 #define UE_GET_XFERTYPE(a)	((a) & UE_XFERTYPE)
292 #define UE_ISO_TYPE	0x0c
293 #define  UE_ISO_ASYNC	0x04
294 #define  UE_ISO_ADAPT	0x08
295 #define  UE_ISO_SYNC	0x0c
296 #define UE_GET_ISO_TYPE(a)	((a) & UE_ISO_TYPE)
297 	uWord		wMaxPacketSize;
298 #define UE_GET_TRANS(a)		(((a) >> 11) & 0x3)
299 #define UE_GET_SIZE(a)		((a) & 0x7ff)
300 	uByte		bInterval;
301 } UPACKED usb_endpoint_descriptor_t;
302 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
303 
304 typedef struct {
305 	uByte		bLength;
306 	uByte		bDescriptorType;
307 	uByte		bMaxBurst;
308 	uByte		bmAttributes;
309 #define UE_SSC_MAXSTREAMS(x)	__SHIFTOUT(x, __BITS(4,0))	/* bulk */
310 #define UE_SSC_MULT(x)		__SHIFTOUT(x, __BITS(1,0))	/* isoch */
311 #define UE_SSC_SSP_ISO(x) 	__SHIFTOUT(x, __BIT(7))		/* isoch */
312 	/* The fields below are only valid for periodic endpoints */
313 	uWord		wBytesPerInterval;
314 } UPACKED usb_endpoint_ss_comp_descriptor_t;
315 #define USB_ENDPOINT_SS_COMP_DESCRIPTOR_SIZE 6
316 
317 /* USB 3.0 9.6.2, Table 9-12 */
318 typedef struct {
319 	uByte		bLength;
320 	uByte		bDescriptorType;
321 	uWord		wTotalLength;
322 	uByte		bNumDeviceCaps;
323 } UPACKED usb_bos_descriptor_t;
324 #define USB_BOS_DESCRIPTOR_SIZE 5
325 
326 /* common members of device capability descriptors */
327 typedef struct {
328 	uByte		bLength;
329 	uByte		bDescriptorType;
330 	uByte		bDevCapabilityType;
331 /* Table 9-14 */
332 #define USB_DEVCAP_RESERVED			0x00
333 #define USB_DEVCAP_WUSB				0x01
334 #define USB_DEVCAP_USB2EXT			0x02
335 #define USB_DEVCAP_SUPER_SPEED			0x03
336 #define USB_DEVCAP_CONTAINER_ID			0x04
337 #define USB_DEVCAP_PLATFORM			0x05
338 #define USB_DEVCAP_POWER_DELIVERY_CAPABILITY	0x06
339 #define USB_DEVCAP_BATTERY_INFO_CAPABILITY	0x07
340 #define USB_DEVCAP_PD_CONSUMER_PORT_CAPABILITY	0x08
341 #define USB_DEVCAP_PD_PROVIDER_PORT_CAPABILITY	0x09
342 #define USB_DEVCAP_SUPERSPEED_PLUS		0x0a
343 #define USB_DEVCAP_PRECISION_TIME_MEASUREMENT	0x0b
344 #define USB_DEVCAP_WUSB_EXT			0x0c
345 	/* data ... */
346 } UPACKED usb_device_capability_descriptor_t;
347 #define USB_DEVICE_CAPABILITY_DESCRIPTOR_SIZE 3 /* at least */
348 
349 /* 9.6.2.1 */
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_devcap_usb2ext_descriptor_t;
357 #define USB_DEVCAP_USB2EXT_DESCRIPTOR_SIZE 7
358 
359 /* 9.6.2.2 */
360 typedef struct {
361 	uByte		bLength;
362 	uByte		bDescriptorType;
363 	uByte		bDevCapabilityType;
364 	uByte		bmAttributes;
365 #define USB_DEVCAP_SS_LTM __BIT(1)
366 	uWord		wSpeedsSupported;
367 #define USB_DEVCAP_SS_SPEED_LS __BIT(0)
368 #define USB_DEVCAP_SS_SPEED_FS __BIT(1)
369 #define USB_DEVCAP_SS_SPEED_HS __BIT(2)
370 #define USB_DEVCAP_SS_SPEED_SS __BIT(3)
371 	uByte		bFunctionalitySupport;
372 	uByte		bU1DevExitLat;
373 	uWord		wU2DevExitLat;
374 } UPACKED usb_devcap_ss_descriptor_t;
375 #define USB_DEVCAP_SS_DESCRIPTOR_SIZE 10
376 
377 /* 9.6.2.4 */
378 typedef struct {
379 	uByte		bLength;
380 	uByte		bDescriptorType;
381 	uByte		bDevCapabilityType;
382 	uByte		bReserved;
383 	uByte		ContainerID[16];
384 } UPACKED usb_devcap_container_id_descriptor_t;
385 #define USB_DEVCAP_CONTAINER_ID_DESCRIPTOR_SIZE 20
386 
387 typedef struct {
388 	uByte		bLength;
389 	uByte		bDescriptorType;
390 	uByte		bDevCapabilityType;
391 	uByte		bReserved;
392 	uByte		PlatformCapabilityUUID[16];
393 	uByte		CapabilityData[0];
394 } UPACKED usb_devcap_platform_descriptor_t;
395 #define USB_DEVCAP_PLATFORM_DESCRIPTOR_SIZE 20
396 
397 /* usb 3.1 ch 9.6.2.5 */
398 typedef struct {
399 	uByte		bLength;
400 	uByte		bDescriptorType;
401 	uByte		bDevCapabilityType;
402 	uByte		bReserved;
403 	uDWord		bmAttributes;
404 #define	USB_DEVCAP_SSP_SSAC(x)			__SHIFTOUT(x, __BITS(4,0))
405 #define	USB_DEVCAP_SSP_SSIC(x)			__SHIFTOUT(x, __BITS(8,5))
406 	uWord		wFunctionalitySupport;
407 #define	USB_DEVCAP_SSP_SSID(x)			__SHIFTOUT(x, __BITS(3,0))
408 #define	USB_DEVCAP_SSP_MIN_RXLANE_COUNT(x)	__SHIFTOUT(x, __BITS(11,8))
409 #define	USB_DEVCAP_SSP_MIN_TXLANE_COUNT(x)	__SHIFTOUT(x, __BITS(15,12))
410 	uWord		wReserved;
411 	uDWord		bmSublinkSpeedAttr[0];
412 #define	USB_DEVCAP_SSP_SSID(x)			__SHIFTOUT(x, __BITS(3,0))
413 #define	USB_DEVCAP_SSP_LSE(x)			__SHIFTOUT(x, __BITS(5,4))
414 #define	USB_DEVCAP_SSP_ST(x)			__SHIFTOUT(x, __BITS(7,6))
415 #define	USB_DEVCAP_SSP_LP(x)			__SHIFTOUT(x, __BITS(15,14))
416 #define	USB_DEVCAP_SSP_LSM(x)			__SHIFTOUT(x, __BITS(31,16))
417 } UPACKED usb_devcap_ssp_descriptor_t;
418 #define USB_DEVCAP_SSP_DESCRIPTOR_SIZE 12 /* variable length */
419 
420 typedef struct {
421 	uByte		bLength;
422 	uByte		bDescriptorType;
423 	uWord		bString[126];
424 } UPACKED usb_string_descriptor_t;
425 #define USB_MAX_STRING_LEN 128
426 #define USB_LANGUAGE_TABLE 0	/* # of the string language id table */
427 #define USB_MAX_ENCODED_STRING_LEN (USB_MAX_STRING_LEN * 3) /* UTF8 */
428 
429 /* Hub specific request */
430 #define UR_GET_BUS_STATE	0x02
431 #define UR_CLEAR_TT_BUFFER	0x08
432 #define UR_RESET_TT		0x09
433 #define UR_GET_TT_STATE		0x0a
434 #define UR_STOP_TT		0x0b
435 #define UR_SET_HUB_DEPTH	0x0c
436 #define UR_GET_PORT_ERR_COUNT	0x0d
437 /* Port Status Type for GET_STATUS,  USB 3.1 10.16.2.6 and Table 10-12 */
438 #define  UR_PST_PORT_STATUS	0
439 #define  UR_PST_PD_STATUS	1
440 #define  UR_PST_EXT_PORT_STATUS	2
441 
442 /*
443  * Hub features from USB 2.0 spec, table 11-17 and updated by the
444  * LPM ECN table 4-7.
445  */
446 #define UHF_C_HUB_LOCAL_POWER	0
447 #define UHF_C_HUB_OVER_CURRENT	1
448 #define UHF_PORT_CONNECTION	0
449 #define UHF_PORT_ENABLE		1
450 #define UHF_PORT_SUSPEND	2
451 #define UHF_PORT_OVER_CURRENT	3
452 #define UHF_PORT_RESET		4
453 #define UHF_PORT_LINK_STATE	5
454 #define UHF_PORT_POWER		8
455 #define UHF_PORT_LOW_SPEED	9
456 #define UHF_PORT_L1		10
457 #define UHF_C_PORT_CONNECTION	16
458 #define UHF_C_PORT_ENABLE	17
459 #define UHF_C_PORT_SUSPEND	18
460 #define UHF_C_PORT_OVER_CURRENT	19
461 #define UHF_C_PORT_RESET	20
462 #define UHF_PORT_TEST		21
463 #define UHF_PORT_INDICATOR	22
464 #define UHF_C_PORT_L1		23
465 
466 /* SS HUB specific features */
467 #define UHF_PORT_U1_TIMEOUT	23
468 #define UHF_PORT_U2_TIMEOUT	24
469 #define UHF_C_PORT_LINK_STATE	25
470 #define UHF_C_PORT_CONFIG_ERROR	26
471 #define UHF_PORT_REMOTE_WAKE_MASK	27
472 #define UHF_BH_PORT_RESET	28
473 #define UHF_C_BH_PORT_RESET	29
474 #define UHF_FORCE_LINKPM_ACCEPT	30
475 
476 typedef struct {
477 	uByte		bDescLength;
478 	uByte		bDescriptorType;
479 	uByte		bNbrPorts;
480 #define UHD_NPORTS_MAX		255
481 	uWord		wHubCharacteristics;
482 #define UHD_PWR			0x0003
483 #define  UHD_PWR_GANGED		0x0000
484 #define  UHD_PWR_INDIVIDUAL	0x0001
485 #define  UHD_PWR_NO_SWITCH	0x0002
486 #define UHD_COMPOUND		0x0004
487 #define UHD_OC			0x0018
488 #define  UHD_OC_GLOBAL		0x0000
489 #define  UHD_OC_INDIVIDUAL	0x0008
490 #define  UHD_OC_NONE		0x0010
491 #define UHD_TT_THINK		0x0060
492 #define  UHD_TT_THINK_8		0x0000
493 #define  UHD_TT_THINK_16	0x0020
494 #define  UHD_TT_THINK_24	0x0040
495 #define  UHD_TT_THINK_32	0x0060
496 #define UHD_PORT_IND		0x0080
497 	uByte		bPwrOn2PwrGood;	/* delay in 2 ms units */
498 #define UHD_PWRON_FACTOR 2
499 	uByte		bHubContrCurrent;
500 	uByte		DeviceRemovable[32]; /* max 255 ports */
501 #define UHD_NOT_REMOV(desc, i) \
502     (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
503 	/* deprecated */ uByte		PortPowerCtrlMask[1];
504 } UPACKED usb_hub_descriptor_t;
505 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
506 
507 typedef struct {
508 	uByte		bLength;
509 	uByte		bDescriptorType;
510 	uByte		bNbrPorts;
511 #define UHD_SS_NPORTS_MAX	15
512 	uWord		wHubCharacteristics;
513 	uByte		bPwrOn2PwrGood;	/* delay in 2 ms units */
514 	uByte		bHubContrCurrent;
515 	uByte		bHubHdrDecLat;
516 	uWord		wHubDelay;	/* forward delay in nanosec */
517 	uByte		DeviceRemovable[2]; /* max 15 ports */
518 } UPACKED usb_hub_ss_descriptor_t;
519 #define USB_HUB_SS_DESCRIPTOR_SIZE 12
520 
521 typedef struct {
522 	uByte		bLength;
523 	uByte		bDescriptorType;
524 	uWord		bcdUSB;
525 	uByte		bDeviceClass;
526 	uByte		bDeviceSubClass;
527 	uByte		bDeviceProtocol;
528 	uByte		bMaxPacketSize0;
529 	uByte		bNumConfigurations;
530 	uByte		bReserved;
531 } UPACKED usb_device_qualifier_t;
532 #define USB_DEVICE_QUALIFIER_SIZE 10
533 
534 typedef struct {
535 	uByte		bLength;
536 	uByte		bDescriptorType;
537 	uByte		bmAttributes;
538 #define UOTG_SRP	0x01
539 #define UOTG_HNP	0x02
540 } UPACKED usb_otg_descriptor_t;
541 
542 /* OTG feature selectors */
543 #define UOTG_B_HNP_ENABLE	3
544 #define UOTG_A_HNP_SUPPORT	4
545 #define UOTG_A_ALT_HNP_SUPPORT	5
546 
547 typedef struct {
548 	uByte		bLength;
549 	uByte		bDescriptorType;
550 	uByte		bDebugInEndpoint;
551 	uByte		bDebugOutEndpoint;
552 } UPACKED usb_debug_descriptor_t;
553 
554 typedef struct {
555 	uWord		wStatus;
556 /* Device status flags */
557 #define UDS_SELF_POWERED		0x0001
558 #define UDS_REMOTE_WAKEUP		0x0002
559 /* Endpoint status flags */
560 #define UES_HALT			0x0001
561 } UPACKED usb_status_t;
562 
563 typedef struct {
564 	uWord		wHubStatus;
565 #define UHS_LOCAL_POWER			0x0001
566 #define UHS_OVER_CURRENT		0x0002
567 	uWord		wHubChange;
568 } UPACKED usb_hub_status_t;
569 
570 typedef struct {
571 	uWord		wPortStatus;
572 #define UPS_CURRENT_CONNECT_STATUS	0x0001
573 #define UPS_PORT_ENABLED		0x0002
574 #define UPS_SUSPEND			0x0004
575 #define UPS_OVERCURRENT_INDICATOR	0x0008
576 #define UPS_RESET			0x0010
577 #define UPS_PORT_L1			0x0020
578 #define UPS_PORT_LS_MASK		__BITS(8,5)
579 #define UPS_PORT_LS_GET(x)		__SHIFTOUT(x, UPS_PORT_LS_MASK)
580 #define UPS_PORT_LS_SET(x)		__SHIFTIN(x, UPS_PORT_LS_MASK)
581 #define UPS_PORT_LS_U0			0x00
582 #define UPS_PORT_LS_U1			0x01
583 #define UPS_PORT_LS_U2			0x02
584 #define UPS_PORT_LS_U3			0x03
585 #define UPS_PORT_LS_SS_DIS		0x04
586 #define UPS_PORT_LS_RX_DET		0x05
587 #define UPS_PORT_LS_SS_INA		0x06
588 #define UPS_PORT_LS_POLL		0x07
589 #define UPS_PORT_LS_RECOVER		0x08
590 #define UPS_PORT_LS_HOT_RST		0x09
591 #define UPS_PORT_LS_COMP_MODE		0x0a
592 #define UPS_PORT_LS_LOOPBACK		0x0b
593 #define UPS_PORT_LS_RESUME		0x0f
594 #define UPS_PORT_POWER			0x0100
595 #define UPS_PORT_POWER_SS		0x0200
596 #define UPS_FULL_SPEED			0x0000	/* for completeness */
597 #define UPS_LOW_SPEED			0x0200
598 #define UPS_HIGH_SPEED			0x0400
599 #define UPS_PORT_TEST			0x0800
600 #define UPS_PORT_INDICATOR		0x1000
601 #define UPS_OTHER_SPEED			0x2000	/* currently NetBSD specific */
602 	uWord		wPortChange;
603 #define UPS_C_CONNECT_STATUS		0x0001
604 #define UPS_C_PORT_ENABLED		0x0002
605 #define UPS_C_SUSPEND			0x0004
606 #define UPS_C_OVERCURRENT_INDICATOR	0x0008
607 #define UPS_C_PORT_RESET		0x0010
608 #define UPS_C_PORT_L1			0x0020
609 #define UPS_C_BH_PORT_RESET		0x0020
610 #define UPS_C_PORT_LINK_STATE		0x0040
611 #define UPS_C_PORT_CONFIG_ERROR		0x0080
612 } UPACKED usb_port_status_t;
613 
614 /* 10.16.2.6 */
615 /* Valid when port status type is UR_PST_EXT_PORT_STATUS. */
616 typedef struct {
617 	uWord		wPortStatus;
618 	uWord		wPortChange;
619 	uDWord		dwExtPortStatus;
620 } UPACKED usb_port_status_ext_t;
621 
622 /* Device class codes */
623 #define UDCLASS_IN_INTERFACE	0x00
624 #define UDCLASS_COMM		0x02
625 #define UDCLASS_HUB		0x09
626 #define  UDSUBCLASS_HUB		0x00
627 #define  UDPROTO_FSHUB		0x00
628 #define  UDPROTO_HSHUBSTT	0x01
629 #define  UDPROTO_HSHUBMTT	0x02
630 #define  UDPROTO_SSHUB		0x03
631 #define UDCLASS_DIAGNOSTIC	0xdc
632 #define UDCLASS_WIRELESS	0xe0
633 #define  UDSUBCLASS_RF		0x01
634 #define   UDPROTO_BLUETOOTH	0x01
635 #define UDCLASS_VENDOR		0xff
636 
637 /* Interface class codes */
638 #define UICLASS_UNSPEC		0x00
639 
640 #define UICLASS_AUDIO		0x01
641 #define  UISUBCLASS_AUDIOCONTROL	1
642 #define  UISUBCLASS_AUDIOSTREAM		2
643 #define  UISUBCLASS_MIDISTREAM		3
644 
645 #define UICLASS_VIDEO		0x0e
646 #define  UISUBCLASS_VIDEOCONTROL	1
647 #define  UISUBCLASS_VIDEOSTREAMING	2
648 #define  UISUBCLASS_VIDEOCOLLECTION	3
649 
650 #define UICLASS_CDC		0x02 /* communication */
651 #define	 UISUBCLASS_DIRECT_LINE_CONTROL_MODEL	1
652 #define  UISUBCLASS_ABSTRACT_CONTROL_MODEL	2
653 #define	 UISUBCLASS_TELEPHONE_CONTROL_MODEL	3
654 #define	 UISUBCLASS_MULTICHANNEL_CONTROL_MODEL	4
655 #define	 UISUBCLASS_CAPI_CONTROLMODEL		5
656 #define	 UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
657 #define	 UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
658 #define	  UIPROTO_CDC_NOCLASS			0 /* no class specific
659 						     protocol required */
660 #define   UIPROTO_CDC_AT			1
661 
662 #define UICLASS_HID		0x03
663 #define  UISUBCLASS_BOOT	1
664 #define  UIPROTO_BOOT_KEYBOARD	1
665 #define  UIPROTO_MOUSE		2
666 
667 #define UICLASS_PHYSICAL	0x05
668 
669 #define UICLASS_IMAGE		0x06
670 
671 #define UICLASS_PRINTER		0x07
672 #define  UISUBCLASS_PRINTER	1
673 #define  UIPROTO_PRINTER_UNI	1
674 #define  UIPROTO_PRINTER_BI	2
675 #define  UIPROTO_PRINTER_1284	3
676 
677 #define UICLASS_MASS		0x08
678 #define  UISUBCLASS_RBC		1
679 #define  UISUBCLASS_SFF8020I	2
680 #define  UISUBCLASS_QIC157	3
681 #define  UISUBCLASS_UFI		4
682 #define  UISUBCLASS_SFF8070I	5
683 #define  UISUBCLASS_SCSI	6
684 #define  UIPROTO_MASS_CBI_I	0
685 #define  UIPROTO_MASS_CBI	1
686 #define  UIPROTO_MASS_BBB_OLD	2	/* Not in the spec anymore */
687 #define  UIPROTO_MASS_BBB	80	/* 'P' for the Iomega Zip drive */
688 #define  UIPROTO_MASS_UAS	98	/* USB Attached SCSI */
689 
690 #define UICLASS_HUB		0x09
691 #define  UISUBCLASS_HUB		0
692 #define  UIPROTO_FSHUB		0
693 #define  UIPROTO_HSHUBSTT	0 /* Yes, same as previous */
694 #define  UIPROTO_HSHUBMTT	1
695 
696 #define UICLASS_CDC_DATA	0x0a
697 #define  UISUBCLASS_DATA		0
698 #define   UIPROTO_DATA_ISDNBRI		0x30    /* Physical iface */
699 #define   UIPROTO_DATA_HDLC		0x31    /* HDLC */
700 #define   UIPROTO_DATA_TRANSPARENT	0x32    /* Transparent */
701 #define   UIPROTO_DATA_Q921M		0x50    /* Management for Q921 */
702 #define   UIPROTO_DATA_Q921		0x51    /* Data for Q921 */
703 #define   UIPROTO_DATA_Q921TM		0x52    /* TEI multiplexer for Q921 */
704 #define   UIPROTO_DATA_V42BIS		0x90    /* Data compression */
705 #define   UIPROTO_DATA_Q931		0x91    /* Euro-ISDN */
706 #define   UIPROTO_DATA_V120		0x92    /* V.24 rate adaption */
707 #define   UIPROTO_DATA_CAPI		0x93    /* CAPI 2.0 commands */
708 #define   UIPROTO_DATA_HOST_BASED	0xfd    /* Host based driver */
709 #define   UIPROTO_DATA_PUF		0xfe    /* see Prot. Unit Func. Desc.*/
710 #define   UIPROTO_DATA_VENDOR		0xff    /* Vendor specific */
711 
712 #define UICLASS_SMARTCARD	0x0b
713 
714 /*#define UICLASS_FIRM_UPD	0x0c*/
715 
716 #define UICLASS_SECURITY	0x0d
717 
718 #define UICLASS_DIAGNOSTIC	0xdc
719 
720 #define UICLASS_WIRELESS	0xe0
721 #define  UISUBCLASS_RF			0x01
722 #define   UIPROTO_BLUETOOTH		0x01
723 #define   UIPROTO_RNDIS			0x03
724 
725 #define UICLASS_APPL_SPEC	0xfe
726 #define  UISUBCLASS_FIRMWARE_DOWNLOAD	1
727 #define  UISUBCLASS_IRDA		2
728 #define  UIPROTO_IRDA			0
729 
730 #define UICLASS_VENDOR		0xff
731 
732 
733 #define USB_HUB_MAX_DEPTH 5
734 
735 /*
736  * Minimum time a device needs to be powered down to go through
737  * a power cycle.  XXX Are these time in the spec?
738  */
739 #define USB_POWER_DOWN_TIME	200 /* ms */
740 #define USB_PORT_POWER_DOWN_TIME	100 /* ms */
741 
742 #if 0
743 /* These are the values from the spec. */
744 #define USB_PORT_RESET_DELAY	10  /* ms */
745 #define USB_PORT_ROOT_RESET_DELAY 50  /* ms */
746 #define USB_PORT_RESET_RECOVERY	10  /* ms */
747 #define USB_PORT_POWERUP_DELAY	100 /* ms */
748 #define USB_SET_ADDRESS_SETTLE	2   /* ms */
749 #define USB_RESUME_DELAY	(20*5)  /* ms */
750 #define USB_RESUME_WAIT		10  /* ms */
751 #define USB_RESUME_RECOVERY	10  /* ms */
752 #define USB_EXTRA_POWER_UP_TIME	0   /* ms */
753 #else
754 /* Allow for marginal (i.e. non-conforming) devices. */
755 #define USB_PORT_RESET_DELAY	50  /* ms */
756 #define USB_PORT_ROOT_RESET_DELAY 250  /* ms */
757 #define USB_PORT_RESET_RECOVERY	250  /* ms */
758 #define USB_PORT_POWERUP_DELAY	300 /* ms */
759 #define USB_SET_ADDRESS_SETTLE	10  /* ms */
760 #define USB_RESUME_DELAY	(50*5)  /* ms */
761 #define USB_RESUME_WAIT		50  /* ms */
762 #define USB_RESUME_RECOVERY	50  /* ms */
763 #define USB_EXTRA_POWER_UP_TIME	20  /* ms */
764 #endif
765 
766 #define USB_MIN_POWER		100 /* mA */
767 #define USB_MIN_POWER_SS	150 /* mA */
768 #define USB_MAX_POWER		500 /* mA */
769 #define USB_MAX_POWER_SS	900 /* mA */
770 
771 #define USB_BUS_RESET_DELAY	100 /* ms XXX?*/
772 
773 
774 #define USB_UNCONFIG_NO 0
775 #define USB_UNCONFIG_INDEX (-1)
776 
777 
778 /* Packet IDs */
779 #define UPID_RESERVED	0xf0
780 #define UPID_OUT	0xe1
781 #define UPID_ACK	0xd2
782 #define UPID_DATA0	0xc3
783 #define UPID_PING	0xb4
784 #define UPID_SOF	0xa5
785 #define UPID_NYET	0x96
786 #define UPID_DATA2	0x87
787 #define UPID_SPLIT	0x78
788 #define UPID_IN		0x69
789 #define UPID_NAK	0x5a
790 #define UPID_DATA1	0x4b
791 #define UPID_ERR	0x3c
792 #define UPID_PREAMBLE	0x3c
793 #define UPID_SETUP	0x2d
794 #define UPID_STALL	0x1e
795 #define UPID_MDATA	0x0f
796 
797 
798 /*** ioctl() related stuff ***/
799 
800 struct usb_ctl_request {
801 	int	ucr_addr;
802 	usb_device_request_t ucr_request;
803 	void	*ucr_data;
804 	int	ucr_flags;
805 #define USBD_SHORT_XFER_OK	0x04	/* allow short reads */
806 	int	ucr_actlen;		/* actual length transferred */
807 };
808 
809 struct usb_alt_interface {
810 	int	uai_config_index;
811 	int	uai_interface_index;
812 	int	uai_alt_no;
813 };
814 
815 #define USB_CURRENT_CONFIG_INDEX (-1)
816 #define USB_CURRENT_ALT_INDEX (-1)
817 
818 struct usb_config_desc {
819 	int	ucd_config_index;
820 	usb_config_descriptor_t ucd_desc;
821 };
822 
823 struct usb_interface_desc {
824 	int	uid_config_index;
825 	int	uid_interface_index;
826 	int	uid_alt_index;
827 	usb_interface_descriptor_t uid_desc;
828 };
829 
830 struct usb_endpoint_desc {
831 	int	ued_config_index;
832 	int	ued_interface_index;
833 	int	ued_alt_index;
834 	int	ued_endpoint_index;
835 	usb_endpoint_descriptor_t ued_desc;
836 };
837 
838 struct usb_full_desc {
839 	int	ufd_config_index;
840 	u_int	ufd_size;
841 	u_char	*ufd_data;
842 };
843 
844 struct usb_string_desc {
845 	int	usd_string_index;
846 	int	usd_language_id;
847 	usb_string_descriptor_t usd_desc;
848 };
849 
850 struct usb_ctl_report_desc {
851 	int	ucrd_size;
852 	u_char	ucrd_data[1024];	/* filled data size will vary */
853 };
854 
855 typedef struct { uint32_t cookie; } usb_event_cookie_t;
856 
857 #define USB_MAX_DEVNAMES 4
858 #define USB_MAX_DEVNAMELEN 16
859 struct usb_device_info {
860 	uint8_t		udi_bus;
861 	uint8_t		udi_addr;	/* device address */
862 	usb_event_cookie_t udi_cookie;
863 	char		udi_product[USB_MAX_ENCODED_STRING_LEN];
864 	char		udi_vendor[USB_MAX_ENCODED_STRING_LEN];
865 	char		udi_release[8];
866 	char		udi_serial[USB_MAX_ENCODED_STRING_LEN];
867 	uint16_t	udi_productNo;
868 	uint16_t	udi_vendorNo;
869 	uint16_t	udi_releaseNo;
870 	uint8_t		udi_class;
871 	uint8_t		udi_subclass;
872 	uint8_t		udi_protocol;
873 	uint8_t		udi_config;
874 	uint8_t		udi_speed;
875 #define USB_SPEED_LOW  1
876 #define USB_SPEED_FULL 2
877 #define USB_SPEED_HIGH 3
878 #define USB_SPEED_SUPER 4
879 #define USB_SPEED_SUPER_PLUS 5
880 #define USB_IS_SS(X) ((X) == USB_SPEED_SUPER || (X) == USB_SPEED_SUPER_PLUS)
881 	int		udi_power;	/* power consumption in mA, 0 if selfpowered */
882 	int		udi_nports;
883 	char		udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
884 	uint8_t		udi_ports[16];/* hub only: addresses of devices on ports */
885 #define USB_PORT_ENABLED 0xff
886 #define USB_PORT_SUSPENDED 0xfe
887 #define USB_PORT_POWERED 0xfd
888 #define USB_PORT_DISABLED 0xfc
889 };
890 
891 /* <=3.0 had this layout of the structure */
892 struct usb_device_info_old {
893 	uint8_t		udi_bus;
894 	uint8_t		udi_addr;       /* device address */
895 	usb_event_cookie_t udi_cookie;
896 	char		udi_product[USB_MAX_STRING_LEN];
897 	char		udi_vendor[USB_MAX_STRING_LEN];
898 	char		udi_release[8];
899 	uint16_t	udi_productNo;
900 	uint16_t	udi_vendorNo;
901 	uint16_t	udi_releaseNo;
902 	uint8_t		udi_class;
903 	uint8_t		udi_subclass;
904 	uint8_t		udi_protocol;
905 	uint8_t		udi_config;
906 	uint8_t		udi_speed;
907 	int		udi_power;      /* power consumption in mA, 0 if selfpowered */
908 	int		udi_nports;
909 	char		udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
910 	uint8_t		udi_ports[16];/* hub only: addresses of devices on ports */
911 };
912 
913 struct usb_ctl_report {
914 	int	ucr_report;
915 	u_char	ucr_data[1024];	/* filled data size will vary */
916 };
917 
918 struct usb_device_stats {
919 	u_long	uds_requests[4];	/* indexed by transfer type UE_* */
920 };
921 
922 struct usb_bulk_ra_wb_opt {
923 	u_int	ra_wb_buffer_size;
924 	u_int	ra_wb_request_size;
925 };
926 
927 /* Events that can be read from /dev/usb */
928 struct usb_event {
929 	int			ue_type;
930 #define USB_EVENT_CTRLR_ATTACH 1
931 #define USB_EVENT_CTRLR_DETACH 2
932 #define USB_EVENT_DEVICE_ATTACH 3
933 #define USB_EVENT_DEVICE_DETACH 4
934 #define USB_EVENT_DRIVER_ATTACH 5
935 #define USB_EVENT_DRIVER_DETACH 6
936 #define USB_EVENT_IS_ATTACH(n) ((n) == USB_EVENT_CTRLR_ATTACH || (n) == USB_EVENT_DEVICE_ATTACH || (n) == USB_EVENT_DRIVER_ATTACH)
937 #define USB_EVENT_IS_DETACH(n) ((n) == USB_EVENT_CTRLR_DETACH || (n) == USB_EVENT_DEVICE_DETACH || (n) == USB_EVENT_DRIVER_DETACH)
938 	struct timespec		ue_time;
939 	union {
940 		struct {
941 			int			ue_bus;
942 		} ue_ctrlr;
943 		struct usb_device_info		ue_device;
944 		struct {
945 			usb_event_cookie_t	ue_cookie;
946 			char			ue_devname[16];
947 		} ue_driver;
948 	} u;
949 };
950 
951 /* old <=3.0 compat event */
952 struct usb_event_old {
953 	int                     ue_type;
954 	struct timespec         ue_time;
955 	union {
956 		struct {
957 			int                     ue_bus;
958 		} ue_ctrlr;
959 		struct usb_device_info_old          ue_device;
960 		struct {
961 			usb_event_cookie_t      ue_cookie;
962 			char                    ue_devname[16];
963 		} ue_driver;
964 	} u;
965 };
966 
967 
968 /* USB controller */
969 #define USB_REQUEST		_IOWR('U', 1, struct usb_ctl_request)
970 #define USB_SETDEBUG		_IOW ('U', 2, int)
971 #define USB_DISCOVER		_IO  ('U', 3)
972 #define USB_DEVICEINFO		_IOWR('U', 4, struct usb_device_info)
973 #define USB_DEVICEINFO_OLD	_IOWR('U', 4, struct usb_device_info_old)
974 #define USB_DEVICESTATS		_IOR ('U', 5, struct usb_device_stats)
975 
976 /* Generic HID device */
977 #define USB_GET_REPORT_DESC	_IOR ('U', 21, struct usb_ctl_report_desc)
978 #define USB_SET_IMMED		_IOW ('U', 22, int)
979 #define USB_GET_REPORT		_IOWR('U', 23, struct usb_ctl_report)
980 #define USB_SET_REPORT		_IOW ('U', 24, struct usb_ctl_report)
981 #define USB_GET_REPORT_ID	_IOR ('U', 25, int)
982 
983 /* Generic USB device */
984 #define USB_GET_CONFIG		_IOR ('U', 100, int)
985 #define USB_SET_CONFIG		_IOW ('U', 101, int)
986 #define USB_GET_ALTINTERFACE	_IOWR('U', 102, struct usb_alt_interface)
987 #define USB_SET_ALTINTERFACE	_IOWR('U', 103, struct usb_alt_interface)
988 #define USB_GET_NO_ALT		_IOWR('U', 104, struct usb_alt_interface)
989 #define USB_GET_DEVICE_DESC	_IOR ('U', 105, usb_device_descriptor_t)
990 #define USB_GET_CONFIG_DESC	_IOWR('U', 106, struct usb_config_desc)
991 #define USB_GET_INTERFACE_DESC	_IOWR('U', 107, struct usb_interface_desc)
992 #define USB_GET_ENDPOINT_DESC	_IOWR('U', 108, struct usb_endpoint_desc)
993 #define USB_GET_FULL_DESC	_IOWR('U', 109, struct usb_full_desc)
994 #define USB_GET_STRING_DESC	_IOWR('U', 110, struct usb_string_desc)
995 #define USB_DO_REQUEST		_IOWR('U', 111, struct usb_ctl_request)
996 #define USB_GET_DEVICEINFO	_IOR ('U', 112, struct usb_device_info)
997 #define USB_GET_DEVICEINFO_OLD	_IOR ('U', 112, struct usb_device_info_old)
998 #define USB_SET_SHORT_XFER	_IOW ('U', 113, int)
999 #define USB_SET_TIMEOUT		_IOW ('U', 114, int)
1000 #define USB_SET_BULK_RA		_IOW ('U', 115, int)
1001 #define USB_SET_BULK_WB		_IOW ('U', 116, int)
1002 #define USB_SET_BULK_RA_OPT	_IOW ('U', 117, struct usb_bulk_ra_wb_opt)
1003 #define USB_SET_BULK_WB_OPT	_IOW ('U', 118, struct usb_bulk_ra_wb_opt)
1004 
1005 /* Modem device */
1006 #define USB_GET_CM_OVER_DATA	_IOR ('U', 130, int)
1007 #define USB_SET_CM_OVER_DATA	_IOW ('U', 131, int)
1008 
1009 #endif /* _USB_H_ */
1010