| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 
|  | 3 | * All rights reserved. | 
|  | 4 | * | 
|  | 5 | * This code is derived from software contributed to The NetBSD Foundation | 
|  | 6 | * by Lennart Augustsson (lennart@augustsson.net) at | 
|  | 7 | * Carlstedt Research & Technology. | 
|  | 8 | * | 
|  | 9 | * Redistribution and use in source and binary forms, with or without | 
|  | 10 | * modification, are permitted provided that the following conditions | 
|  | 11 | * are met: | 
|  | 12 | * 1. Redistributions of source code must retain the above copyright | 
|  | 13 | *    notice, this list of conditions and the following disclaimer. | 
|  | 14 | * 2. Redistributions in binary form must reproduce the above copyright | 
|  | 15 | *    notice, this list of conditions and the following disclaimer in the | 
|  | 16 | *    documentation and/or other materials provided with the distribution. | 
|  | 17 | * 3. All advertising materials mentioning features or use of this software | 
|  | 18 | *    must display the following acknowledgement: | 
|  | 19 | *        This product includes software developed by the NetBSD | 
|  | 20 | *        Foundation, Inc. and its contributors. | 
|  | 21 | * 4. Neither the name of The NetBSD Foundation nor the names of its | 
|  | 22 | *    contributors may be used to endorse or promote products derived | 
|  | 23 | *    from this software without specific prior written permission. | 
|  | 24 | * | 
|  | 25 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 
|  | 26 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 
|  | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
|  | 28 | * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 
|  | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
|  | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
|  | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
|  | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
|  | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
|  | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|  | 35 | * POSSIBILITY OF SUCH DAMAGE. | 
|  | 36 | */ | 
|  | 37 |  | 
|  | 38 | /* Modified by Synopsys, Inc, 12/12/2007 */ | 
|  | 39 |  | 
|  | 40 |  | 
|  | 41 | #ifndef _USB_H_ | 
|  | 42 | #define _USB_H_ | 
|  | 43 |  | 
|  | 44 | #include "common.h" | 
|  | 45 | #include <linux/types.h> | 
|  | 46 | #ifdef __cplusplus | 
|  | 47 | extern "C" { | 
|  | 48 | #endif | 
|  | 49 |  | 
|  | 50 | // T_LANGID_DESCRIPTOR | 
|  | 51 | #define LANGID_US_ENGLISH					0x0409 | 
|  | 52 |  | 
|  | 53 | // T_STRING_DESCRIPTOR | 
|  | 54 | #define MAX_STRING_LENGTH					(0x20)//(0x100) | 
|  | 55 |  | 
|  | 56 |  | 
|  | 57 | typedef enum | 
|  | 58 | { | 
|  | 59 |  | 
|  | 60 | NEED_ENUM = 0, | 
|  | 61 | DONOT_NEED_ENUM | 
|  | 62 |  | 
|  | 63 | }T_USB_ENUM; | 
|  | 64 |  | 
|  | 65 | /*usb´«ÊäÀàÐÍ*/ | 
|  | 66 | typedef enum | 
|  | 67 | { | 
|  | 68 | TRA_CTRL = 0, | 
|  | 69 | TRA_BULK, | 
|  | 70 | TRA_INTR, | 
|  | 71 | TRA_ISO | 
|  | 72 | }T_USB_TRAN; | 
|  | 73 |  | 
|  | 74 | /* USB¿ØÖÆ´«ÊäÃüÁî*/ | 
|  | 75 | typedef struct | 
|  | 76 | { | 
|  | 77 | BYTE     bmRequestType; | 
|  | 78 | BYTE     bRequest; | 
|  | 79 | WORD16     wValue; | 
|  | 80 | WORD16     wIndex; | 
|  | 81 | WORD16     wLength; | 
|  | 82 | }T_CTRL_COMMAND; | 
|  | 83 |  | 
|  | 84 |  | 
|  | 85 | // ¶ËµãÊý¾Ý°ü´óС | 
|  | 86 | typedef enum | 
|  | 87 | { | 
|  | 88 | CONTROL_8		=8, | 
|  | 89 | CONTROL_16		=16, | 
|  | 90 | CONTROL_32		=32, | 
|  | 91 | CONTROL_64		=64, | 
|  | 92 |  | 
|  | 93 | BULK_8			=8, | 
|  | 94 | BULK_16			=16, | 
|  | 95 | BULK_32			=32, | 
|  | 96 | BULKL_64		=64 | 
|  | 97 | }T_EP_PKT_SIZE; | 
|  | 98 |  | 
|  | 99 |  | 
|  | 100 | // CLEAR_FEATURE, SET_FEATURE | 
|  | 101 | #define FEATURE_DEVICE_REMOTE_WAKEUP		(0x1) | 
|  | 102 | #define FEATURE_ENDPOINT_HALT				(0x0) | 
|  | 103 | #define FEATURE_TEST_MODE					(0x2) | 
|  | 104 |  | 
|  | 105 | // ¸ù¾Ýʵ¼ÊÇé¿öÐÞ¸Ä | 
|  | 106 | #define	USB_VENDOR_ID			                      (0x19D2)	// 2×Ö½Ú | 
|  | 107 | #define USB_PRODUCT_ID			                      (0x0256)	// 2×Ö½Ú | 
|  | 108 | #define PRODUCT_RELEASE_NUMBER	               (0x7520)	// 2×Ö½Ú | 
|  | 109 |  | 
|  | 110 | #define VERDOR_SPECIFIC			(0xff) | 
|  | 111 |  | 
|  | 112 | #define EP0_PACKET_SIZE CONTROL_64 | 
|  | 113 | #define EP1_PACKET_SIZE 64 | 
|  | 114 | #define EPX_PACKET_SIZE 64 | 
|  | 115 |  | 
|  | 116 | #define EP_FOR_IN 2 | 
|  | 117 | #define EP_FOR_OUT 3 | 
|  | 118 |  | 
|  | 119 |  | 
|  | 120 | /*usbÉ豸µÄÆß¸ö״̬*/ | 
|  | 121 | typedef enum | 
|  | 122 | { | 
|  | 123 | eUSB_ATTACHED = 0, | 
|  | 124 | eUSB_POWERED, | 
|  | 125 | eUSB_DEFAULT, | 
|  | 126 | eUSB_SUSPEND, | 
|  | 127 | eUSB_RUSUME, | 
|  | 128 | eUSB_ADDRESS, | 
|  | 129 | eUSB_CONFIG | 
|  | 130 | }E_USB_STATE; | 
|  | 131 |  | 
|  | 132 |  | 
|  | 133 | // ±ê×¼ÇëÇóÃüÁî | 
|  | 134 | typedef enum | 
|  | 135 | { | 
|  | 136 | GET_STATUS          =0x0, | 
|  | 137 | CLEAR_FEATURE       =0x1, | 
|  | 138 | SET_FEATURE         =0x3, | 
|  | 139 | SET_ADDRESS         =0x5, | 
|  | 140 | GET_DESCRIPTOR      =0x6, | 
|  | 141 | SET_DESCRIPTOR      =0x7, | 
|  | 142 | GET_CONFIGURATION   =0x8, | 
|  | 143 | SET_CONFIGURATION   =0x9, | 
|  | 144 | GET_INTERFACE       =0xa, | 
|  | 145 | SET_INTERFACE       =0xb, | 
|  | 146 | SYNCH_FRAME         =0xc | 
|  | 147 | }T_STANDARD_REQUST; | 
|  | 148 |  | 
|  | 149 |  | 
|  | 150 | // ÃèÊö·ûÀàÐÍ | 
|  | 151 | typedef enum | 
|  | 152 | { | 
|  | 153 | DEVICE_DESCRIPTOR   = 0x01, | 
|  | 154 | CONFIG_DESCRIPTOR   = 0x02, | 
|  | 155 | STRING_DESCRIPTOR   = 0x03, | 
|  | 156 | INTERFACE_DESCRIPTOR= 0x04, | 
|  | 157 | ENDPOINT_DESCRIPTOR = 0x05 | 
|  | 158 | } T_DESCRIPTORS_TYPE; | 
|  | 159 |  | 
|  | 160 | // USBÖ§³ÖµÄÌØÕ÷¶¨Òå | 
|  | 161 | typedef enum | 
|  | 162 | { | 
|  | 163 | DEVICE_REMOTE_WAKEUP	=1,		// Device | 
|  | 164 | ENDPOINT_HALT 			=0, 	// Endpoint | 
|  | 165 | TEST_MODE 				=2		//Device | 
|  | 166 | }T_FEATURE; | 
|  | 167 |  | 
|  | 168 |  | 
|  | 169 | // bmAttributes | 
|  | 170 | #define ATTR_D7						       (0x01 <<7)		// ±ØÐëΪ1 | 
|  | 171 | #define ATTR_SELF_POWERED			       (0x01 <<6)		// ×Ô¹©µç | 
|  | 172 | #define ATTR_SUPPORT_REMOTE_WAKEUP	(0x01 <<5)		// Ô¶³Ì»½ÐÑ | 
|  | 173 |  | 
|  | 174 | // bMaxPower | 
|  | 175 | #define POWER_MA(power)				        (power>>1)		// µ¥Î»: 2mA | 
|  | 176 |  | 
|  | 177 | #define EP_ADDRESS_DIRECTION_MASK	        (0x01 <<7)	//Direction, ignored for control endpoints | 
|  | 178 | #define EP_ADDRESS_DIRECTION_IN		 (0x01 <<7) | 
|  | 179 | #define EP_ADDRESS_DIRECTION_OUT	         (0x0   <<7) | 
|  | 180 |  | 
|  | 181 |  | 
|  | 182 | //bmAttributes | 
|  | 183 | #define EP_ATTR_TRANSFER_TYPE_MASK		 (0x03 <<0) | 
|  | 184 | #define EP_ATTR_TRANSFER_TYPE_CONTROL	        (0     <<0) | 
|  | 185 | #define EP_ATTR_TRANSFER_TYPE_ISO		        (1     <<0) | 
|  | 186 | #define EP_ATTR_TRANSFER_TYPE_BULK		 (2     <<0) | 
|  | 187 | #define EP_ATTR_TRANSFER_TYPE_INTERRUPT	 (3     <<0) | 
|  | 188 |  | 
|  | 189 | //ͬ²½´«Êä¶Ëµã, ×î´ó1023×Ö½Ú, ÂÖѯ¼ä¸ô---2^(bInterval -1)Ö¡ | 
|  | 190 | #define MAX_ISO_PKT			(256)	//×î´ó1023×Ö½Ú | 
|  | 191 | #define MAX_ISO_R_INTERVAL	(1)		//ÂÖѯ¼ä¸ô---2^(bInterval -1)Ö¡ | 
|  | 192 | #define MAX_ISO_T_INTERVAL	(1)		//ÂÖѯ¼ä¸ô---2^(bInterval -1)Ö¡ | 
|  | 193 |  | 
|  | 194 | //T_STRING_DESCRIPTOR, ascii to unicode---*2, length,type--+2 | 
|  | 195 | #define STRING_DESCRIPTOR_SIZE(size)    	((size*2)+2) | 
|  | 196 | //ת»»ascii×Ö·ûΪunicode×Ö·û | 
|  | 197 | #define UNICODE(ascii)							ascii,0x00 | 
|  | 198 |  | 
|  | 199 | /**************************************************************************/ | 
|  | 200 | typedef uint8_t uByte; | 
|  | 201 | typedef uint8_t uWord[2]; | 
|  | 202 | typedef uint8_t uDWord[4]; | 
|  | 203 |  | 
|  | 204 |  | 
|  | 205 | #define UT_GET_TYPE(a) ((a) & 0x60) | 
|  | 206 | #define UT_STANDARD		0x00 | 
|  | 207 | #define UT_CLASS		0x20 | 
|  | 208 | #define UT_VENDOR		0x40 | 
|  | 209 |  | 
|  | 210 | #define UT_GET_RECIPIENT(a) ((a) & 0x1f) | 
|  | 211 | #define UT_DEVICE		0x00 | 
|  | 212 | #define UT_INTERFACE		0x01 | 
|  | 213 | #define UT_ENDPOINT		0x02 | 
|  | 214 | #define UT_OTHER		0x03 | 
|  | 215 | /* Requests */ | 
|  | 216 | #define  UR_GET_STATUS		0x00 | 
|  | 217 | #define  USTAT_STANDARD_STATUS  0x00 | 
|  | 218 | #define  UR_CLEAR_FEATURE	0x01 | 
|  | 219 | #define  UR_SET_FEATURE		0x03 | 
|  | 220 | #define  UR_SET_ADDRESS		0x05 | 
|  | 221 | #define  UR_GET_DESCRIPTOR	0x06 | 
|  | 222 | #define UR_SET_CONFIG		0x09 | 
|  | 223 | /* Feature numbers */ | 
|  | 224 | #define UF_ENDPOINT_HALT	0 | 
|  | 225 |  | 
|  | 226 |  | 
|  | 227 |  | 
|  | 228 |  | 
|  | 229 |  | 
|  | 230 | #define UE_GET_DIR(a)	((a) & 0x80) | 
|  | 231 | #define UE_SET_DIR(a,d)	((a) | (((d)&1) << 7)) | 
|  | 232 | #define UE_DIR_IN	0x80 | 
|  | 233 | #define UE_DIR_OUT	0x00 | 
|  | 234 | #define UE_ADDR		0x0f | 
|  | 235 | #define UE_GET_ADDR(a)	((a) & UE_ADDR) | 
|  | 236 |  | 
|  | 237 |  | 
|  | 238 | #define USB_MAX_STRING_LEN 128 | 
|  | 239 | #define USB_LANGUAGE_TABLE 0	/* # of the string language id table */ | 
|  | 240 |  | 
|  | 241 | /* Hub specific request */ | 
|  | 242 | #define UR_GET_BUS_STATE	0x02 | 
|  | 243 | #define UR_CLEAR_TT_BUFFER	0x08 | 
|  | 244 | #define UR_RESET_TT		0x09 | 
|  | 245 | #define UR_GET_TT_STATE		0x0a | 
|  | 246 | #define UR_STOP_TT		0x0b | 
|  | 247 |  | 
|  | 248 | /* Hub features */ | 
|  | 249 | #define UHF_C_HUB_LOCAL_POWER	0 | 
|  | 250 | #define UHF_C_HUB_OVER_CURRENT	1 | 
|  | 251 | #define UHF_PORT_CONNECTION	0 | 
|  | 252 | #define UHF_PORT_ENABLE		1 | 
|  | 253 | #define UHF_PORT_SUSPEND	2 | 
|  | 254 | #define UHF_PORT_OVER_CURRENT	3 | 
|  | 255 | #define UHF_PORT_RESET		4 | 
|  | 256 | #define UHF_PORT_L1		5 | 
|  | 257 | #define UHF_PORT_POWER		8 | 
|  | 258 | #define UHF_PORT_LOW_SPEED	9 | 
|  | 259 | #define UHF_PORT_HIGH_SPEED	10 | 
|  | 260 | #define UHF_C_PORT_CONNECTION	16 | 
|  | 261 | #define UHF_C_PORT_ENABLE	17 | 
|  | 262 | #define UHF_C_PORT_SUSPEND	18 | 
|  | 263 | #define UHF_C_PORT_OVER_CURRENT	19 | 
|  | 264 | #define UHF_C_PORT_RESET	20 | 
|  | 265 | #define UHF_C_PORT_L1		23 | 
|  | 266 | #define UHF_PORT_TEST		21 | 
|  | 267 | #define UHF_PORT_INDICATOR	22 | 
|  | 268 |  | 
|  | 269 | #define UHD_PWR			0x0003 | 
|  | 270 | #define  UHD_PWR_GANGED		0x0000 | 
|  | 271 | #define  UHD_PWR_INDIVIDUAL	0x0001 | 
|  | 272 | #define  UHD_PWR_NO_SWITCH	0x0002 | 
|  | 273 | #define UHD_COMPOUND		0x0004 | 
|  | 274 | #define UHD_OC			0x0018 | 
|  | 275 | #define  UHD_OC_GLOBAL		0x0000 | 
|  | 276 | #define  UHD_OC_INDIVIDUAL	0x0008 | 
|  | 277 | #define  UHD_OC_NONE		0x0010 | 
|  | 278 | #define UHD_TT_THINK		0x0060 | 
|  | 279 | #define  UHD_TT_THINK_8		0x0000 | 
|  | 280 | #define  UHD_TT_THINK_16	0x0020 | 
|  | 281 | #define  UHD_TT_THINK_24	0x0040 | 
|  | 282 | #define  UHD_TT_THINK_32	0x0060 | 
|  | 283 | #define UHD_PORT_IND		0x0080 | 
|  | 284 | #define UHD_PWRON_FACTOR 2 | 
|  | 285 | #define UHD_NOT_REMOV(desc, i)  (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1) | 
|  | 286 |  | 
|  | 287 | #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */ | 
|  | 288 |  | 
|  | 289 |  | 
|  | 290 | /* OTG feature selectors */ | 
|  | 291 | #define UOTG_B_HNP_ENABLE	3 | 
|  | 292 | #define UOTG_A_HNP_SUPPORT	4 | 
|  | 293 | #define UOTG_A_ALT_HNP_SUPPORT	5 | 
|  | 294 |  | 
|  | 295 | /* Device status flags */ | 
|  | 296 | #define UDS_SELF_POWERED		0x0001 | 
|  | 297 | #define UDS_REMOTE_WAKEUP		0x0002 | 
|  | 298 | /* Endpoint status flags */ | 
|  | 299 | #define UES_HALT			0x0001 | 
|  | 300 |  | 
|  | 301 |  | 
|  | 302 |  | 
|  | 303 | #define UHS_LOCAL_POWER	    0x0001 | 
|  | 304 | #define UHS_OVER_CURRENT		0x0002 | 
|  | 305 |  | 
|  | 306 |  | 
|  | 307 |  | 
|  | 308 | #define UPS_CURRENT_CONNECT_STATUS	0x0001 | 
|  | 309 | #define UPS_PORT_ENABLED		0x0002 | 
|  | 310 | #define UPS_SUSPEND			0x0004 | 
|  | 311 | #define UPS_OVERCURRENT_INDICATOR	0x0008 | 
|  | 312 | #define UPS_RESET			0x0010 | 
|  | 313 | #define UPS_PORT_POWER			0x0100 | 
|  | 314 | #define UPS_LOW_SPEED			0x0200 | 
|  | 315 | #define UPS_HIGH_SPEED			0x0400 | 
|  | 316 | #define UPS_PORT_TEST			0x0800 | 
|  | 317 | #define UPS_PORT_INDICATOR		0x1000 | 
|  | 318 | #define UPS_C_CONNECT_STATUS		0x0001 | 
|  | 319 | #define UPS_C_PORT_ENABLED		0x0002 | 
|  | 320 | #define UPS_C_SUSPEND			0x0004 | 
|  | 321 | #define UPS_C_OVERCURRENT_INDICATOR	0x0008 | 
|  | 322 | #define UPS_C_PORT_RESET		0x0010 | 
|  | 323 |  | 
|  | 324 |  | 
|  | 325 | /* Device class codes */ | 
|  | 326 | #define UDCLASS_IN_INTERFACE	0x00 | 
|  | 327 | #define UDCLASS_COMM		0x02 | 
|  | 328 | #define UDCLASS_HUB		0x09 | 
|  | 329 | #define  UDSUBCLASS_HUB		0x00 | 
|  | 330 | #define  UDPROTO_FSHUB		0x00 | 
|  | 331 | #define  UDPROTO_HSHUBSTT	0x01 | 
|  | 332 | #define  UDPROTO_HSHUBMTT	0x02 | 
|  | 333 | #define UDCLASS_DIAGNOSTIC	0xdc | 
|  | 334 | #define UDCLASS_WIRELESS	0xe0 | 
|  | 335 | #define  UDSUBCLASS_RF		0x01 | 
|  | 336 | #define   UDPROTO_BLUETOOTH	0x01 | 
|  | 337 | #define UDCLASS_VENDOR		0xff | 
|  | 338 |  | 
|  | 339 | /* Interface class codes */ | 
|  | 340 | #define UICLASS_UNSPEC		0x00 | 
|  | 341 |  | 
|  | 342 | #define UICLASS_AUDIO		0x01 | 
|  | 343 | #define  UISUBCLASS_AUDIOCONTROL	1 | 
|  | 344 | #define  UISUBCLASS_AUDIOSTREAM		2 | 
|  | 345 | #define  UISUBCLASS_MIDISTREAM		3 | 
|  | 346 |  | 
|  | 347 | #define UICLASS_CDC		0x02 /* communication */ | 
|  | 348 | #define  UISUBCLASS_DIRECT_LINE_CONTROL_MODEL	1 | 
|  | 349 | #define  UISUBCLASS_ABSTRACT_CONTROL_MODEL	2 | 
|  | 350 | #define  UISUBCLASS_TELEPHONE_CONTROL_MODEL	3 | 
|  | 351 | #define  UISUBCLASS_MULTICHANNEL_CONTROL_MODEL	4 | 
|  | 352 | #define  UISUBCLASS_CAPI_CONTROLMODEL		5 | 
|  | 353 | #define  UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6 | 
|  | 354 | #define  UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7 | 
|  | 355 | #define   UIPROTO_CDC_AT			1 | 
|  | 356 |  | 
|  | 357 | #define UICLASS_HID		0x03 | 
|  | 358 | #define  UISUBCLASS_BOOT	1 | 
|  | 359 | #define  UIPROTO_BOOT_KEYBOARD	1 | 
|  | 360 |  | 
|  | 361 | #define UICLASS_PHYSICAL	0x05 | 
|  | 362 |  | 
|  | 363 | #define UICLASS_IMAGE		0x06 | 
|  | 364 |  | 
|  | 365 | #define UICLASS_PRINTER		0x07 | 
|  | 366 | #define  UISUBCLASS_PRINTER	1 | 
|  | 367 | #define  UIPROTO_PRINTER_UNI	1 | 
|  | 368 | #define  UIPROTO_PRINTER_BI	2 | 
|  | 369 | #define  UIPROTO_PRINTER_1284	3 | 
|  | 370 |  | 
|  | 371 | #define UICLASS_MASS		0x08 | 
|  | 372 | #define  UISUBCLASS_RBC		1 | 
|  | 373 | #define  UISUBCLASS_SFF8020I	2 | 
|  | 374 | #define  UISUBCLASS_QIC157	3 | 
|  | 375 | #define  UISUBCLASS_UFI		4 | 
|  | 376 | #define  UISUBCLASS_SFF8070I	5 | 
|  | 377 | #define  UISUBCLASS_SCSI	6 | 
|  | 378 | #define  UIPROTO_MASS_CBI_I	0 | 
|  | 379 | #define  UIPROTO_MASS_CBI	1 | 
|  | 380 | #define  UIPROTO_MASS_BBB_OLD	2	/* Not in the spec anymore */ | 
|  | 381 | #define  UIPROTO_MASS_BBB	80	/* 'P' for the Iomega Zip drive */ | 
|  | 382 |  | 
|  | 383 | #define UICLASS_HUB		0x09 | 
|  | 384 | #define  UISUBCLASS_HUB		0 | 
|  | 385 | #define  UIPROTO_FSHUB		0 | 
|  | 386 | #define  UIPROTO_HSHUBSTT	0 /* Yes, same as previous */ | 
|  | 387 | #define  UIPROTO_HSHUBMTT	1 | 
|  | 388 |  | 
|  | 389 | #define UICLASS_CDC_DATA	0x0a | 
|  | 390 | #define  UISUBCLASS_DATA		0 | 
|  | 391 | #define   UIPROTO_DATA_ISDNBRI		0x30    /* Physical iface */ | 
|  | 392 | #define   UIPROTO_DATA_HDLC		0x31    /* HDLC */ | 
|  | 393 | #define   UIPROTO_DATA_TRANSPARENT	0x32    /* Transparent */ | 
|  | 394 | #define   UIPROTO_DATA_Q921M		0x50    /* Management for Q921 */ | 
|  | 395 | #define   UIPROTO_DATA_Q921		0x51    /* Data for Q921 */ | 
|  | 396 | #define   UIPROTO_DATA_Q921TM		0x52    /* TEI multiplexer for Q921 */ | 
|  | 397 | #define   UIPROTO_DATA_V42BIS		0x90    /* Data compression */ | 
|  | 398 | #define   UIPROTO_DATA_Q931		0x91    /* Euro-ISDN */ | 
|  | 399 | #define   UIPROTO_DATA_V120		0x92    /* V.24 rate adaption */ | 
|  | 400 | #define   UIPROTO_DATA_CAPI		0x93    /* CAPI 2.0 commands */ | 
|  | 401 | #define   UIPROTO_DATA_HOST_BASED	0xfd    /* Host based driver */ | 
|  | 402 | #define   UIPROTO_DATA_PUF		0xfe    /* see Prot. Unit Func. Desc.*/ | 
|  | 403 | #define   UIPROTO_DATA_VENDOR		0xff    /* Vendor specific */ | 
|  | 404 |  | 
|  | 405 | #define UICLASS_SMARTCARD	0x0b | 
|  | 406 |  | 
|  | 407 | /*#define UICLASS_FIRM_UPD	0x0c*/ | 
|  | 408 |  | 
|  | 409 | #define UICLASS_SECURITY	0x0d | 
|  | 410 |  | 
|  | 411 | #define UICLASS_DIAGNOSTIC	0xdc | 
|  | 412 |  | 
|  | 413 | #define UICLASS_WIRELESS	0xe0 | 
|  | 414 | #define  UISUBCLASS_RF			0x01 | 
|  | 415 | #define   UIPROTO_BLUETOOTH		0x01 | 
|  | 416 |  | 
|  | 417 | #define UICLASS_APPL_SPEC	0xfe | 
|  | 418 | #define  UISUBCLASS_FIRMWARE_DOWNLOAD	1 | 
|  | 419 | #define  UISUBCLASS_IRDA		2 | 
|  | 420 | #define  UIPROTO_IRDA			0 | 
|  | 421 |  | 
|  | 422 | #define UICLASS_VENDOR		0xff | 
|  | 423 |  | 
|  | 424 | #define USB_HUB_MAX_DEPTH 5 | 
|  | 425 |  | 
|  | 426 | /* | 
|  | 427 | * Minimum time a device needs to be powered down to go through | 
|  | 428 | * a power cycle.  XXX Are these time in the spec? | 
|  | 429 | */ | 
|  | 430 | #define USB_POWER_DOWN_TIME	200 /* ms */ | 
|  | 431 | #define USB_PORT_POWER_DOWN_TIME	100 /* ms */ | 
|  | 432 |  | 
|  | 433 |  | 
|  | 434 | /* Allow for marginal (i.e. non-conforming) devices. */ | 
|  | 435 | #define USB_PORT_RESET_DELAY	50  /* ms */ | 
|  | 436 | #define USB_PORT_ROOT_RESET_DELAY 250  /* ms */ | 
|  | 437 | #define USB_PORT_RESET_RECOVERY	250  /* ms */ | 
|  | 438 | #define USB_PORT_POWERUP_DELAY	300 /* ms */ | 
|  | 439 | #define USB_SET_ADDRESS_SETTLE	10  /* ms */ | 
|  | 440 | #define USB_RESUME_DELAY	(50*5)  /* ms */ | 
|  | 441 | #define USB_RESUME_WAIT		50  /* ms */ | 
|  | 442 | #define USB_RESUME_RECOVERY	50  /* ms */ | 
|  | 443 | #define USB_EXTRA_POWER_UP_TIME	20  /* ms */ | 
|  | 444 |  | 
|  | 445 |  | 
|  | 446 | #define USB_MIN_POWER		100 /* mA */ | 
|  | 447 | #define USB_MAX_POWER		500 /* mA */ | 
|  | 448 |  | 
|  | 449 | #define USB_BUS_RESET_DELAY	100 /* ms XXX?*/ | 
|  | 450 |  | 
|  | 451 | #define USB_UNCONFIG_NO 0 | 
|  | 452 | #define USB_UNCONFIG_INDEX (-1) | 
|  | 453 |  | 
|  | 454 | typedef struct usb_device_request_t | 
|  | 455 | { | 
|  | 456 | uint8_t		bmRequestType; | 
|  | 457 | uint8_t		bRequest; | 
|  | 458 | uint16_t		wValue; | 
|  | 459 | uint16_t		wIndex; | 
|  | 460 | uint16_t		wLength; | 
|  | 461 | } __attribute__ ((__packed__)) usb_device_request_t; | 
|  | 462 |  | 
|  | 463 | /*** ioctl() related stuff ***/ | 
|  | 464 |  | 
|  | 465 | #define USBD_SHORT_XFER_OK	0x04	/* allow short reads */ | 
|  | 466 | #define USB_CURRENT_CONFIG_INDEX (-1) | 
|  | 467 | #define USB_CURRENT_ALT_INDEX (-1) | 
|  | 468 |  | 
|  | 469 |  | 
|  | 470 |  | 
|  | 471 | typedef struct usb_endpoint_descriptor_t | 
|  | 472 | { | 
|  | 473 | uint8_t		bLength; | 
|  | 474 | uint8_t		bDescriptorType; | 
|  | 475 | uint8_t		bEndpointAddress; | 
|  | 476 | uint8_t		bmAttributes; | 
|  | 477 | uint16_t	wMaxPacketSize; | 
|  | 478 | uint8_t		bInterval; | 
|  | 479 | } __attribute__ ((__packed__)) usb_endpoint_descriptor_t; | 
|  | 480 |  | 
|  | 481 | #define USB_MAX_DEVNAMES 4 | 
|  | 482 | #define USB_MAX_DEVNAMELEN 16 | 
|  | 483 | #define USB_SPEED_UNKNOWN	0 | 
|  | 484 | #define USB_SPEED_LOW		1 | 
|  | 485 | #define USB_SPEED_FULL		2 | 
|  | 486 | #define USB_SPEED_HIGH		3 | 
|  | 487 | /* | 
|  | 488 | * USB directions | 
|  | 489 | * | 
|  | 490 | * This bit flag is used in endpoint descriptors' bEndpointAddress field. | 
|  | 491 | * It's also one of three fields in control requests bRequestType. | 
|  | 492 | */ | 
|  | 493 | #define USB_DIR_OUT			0		/* to device */ | 
|  | 494 | #define USB_DIR_IN			0x80		/* to host */ | 
|  | 495 |  | 
|  | 496 | #define USB_DT_DEVICE			0x01 | 
|  | 497 | #define USB_DT_CONFIG			0x02 | 
|  | 498 | #define USB_DT_STRING			0x03 | 
|  | 499 | #define USB_DT_INTERFACE		0x04 | 
|  | 500 | #define USB_DT_ENDPOINT			0x05 | 
|  | 501 | #define USB_DT_DEVICE_QUALIFIER		0x06 | 
|  | 502 | #define USB_DT_OTHER_SPEED_CONFIG	0x07 | 
|  | 503 | #define USB_DT_INTERFACE_POWER		0x08 | 
|  | 504 |  | 
|  | 505 | /***************************************************/ | 
|  | 506 | // ±ê×¼½Ó¿ÚÃèÊö·û | 
|  | 507 | typedef struct dwc_interface_descriptor_t | 
|  | 508 | { | 
|  | 509 | BYTE 	bLength; | 
|  | 510 | BYTE 	bDescriptorType; | 
|  | 511 | BYTE 	bInterfaceNumber; | 
|  | 512 | BYTE 	bAlternateSetting; | 
|  | 513 | BYTE 	bNumEndpoints; | 
|  | 514 | BYTE 	bInterfaceClass; | 
|  | 515 | BYTE 	bInterfaceSubClass; | 
|  | 516 | BYTE 	bInterfaceProtocol; | 
|  | 517 | BYTE 	iInterface; | 
|  | 518 | }__attribute__ ((__packed__)) dwc_interface_descriptor_t; | 
|  | 519 |  | 
|  | 520 |  | 
|  | 521 | // ±ê×¼¶ËµãÃèÊö·û | 
|  | 522 | typedef struct dwc_ep_descriptor_t | 
|  | 523 | { | 
|  | 524 | BYTE 	bLength; | 
|  | 525 | BYTE 	bDescriptorType; | 
|  | 526 | BYTE 	bEndpointAddress; | 
|  | 527 | BYTE 	bmAttributes; | 
|  | 528 | WORD16	wMaxPacketSize; | 
|  | 529 | BYTE 	bInterval; | 
|  | 530 | }__attribute__ ((__packed__)) dwc_ep_descriptor_t; | 
|  | 531 |  | 
|  | 532 |  | 
|  | 533 | // ×Ö·û´®ÃèÊö·û | 
|  | 534 | typedef struct dwc_langid_descriptor_t | 
|  | 535 | { | 
|  | 536 | BYTE	bLength; | 
|  | 537 | BYTE 	bDescriptorType; | 
|  | 538 | WORD16	wLANGID0; | 
|  | 539 |  | 
|  | 540 | }__attribute__ ((__packed__)) dwc_langid_descriptor_t; | 
|  | 541 |  | 
|  | 542 | typedef struct dwc_string_descriptor_t | 
|  | 543 | { | 
|  | 544 | BYTE	bLength; | 
|  | 545 | BYTE 	bDescriptorType; | 
|  | 546 | BYTE	bString[MAX_STRING_LENGTH]; | 
|  | 547 |  | 
|  | 548 | }__attribute__ ((__packed__)) dwc_string_descriptor_t; | 
|  | 549 |  | 
|  | 550 | // É豸ÃèÊö·û | 
|  | 551 | typedef struct dwc_device_descriptor_t | 
|  | 552 | { | 
|  | 553 | BYTE    bLength; | 
|  | 554 | BYTE    bDescriptorType; | 
|  | 555 | WORD16	bcdUSB; | 
|  | 556 | BYTE    bDeviceClass; | 
|  | 557 | BYTE    bDeviceSubClass; | 
|  | 558 | BYTE    bDeviceProtocol; | 
|  | 559 | BYTE    bMaxPacketSize0; | 
|  | 560 | WORD16 	idVendor; | 
|  | 561 | WORD16 	idProduct; | 
|  | 562 | WORD16 	bcdDevice; | 
|  | 563 | BYTE 	iManufacturer; | 
|  | 564 | BYTE    iProduct; | 
|  | 565 | BYTE    iSerialNumber; | 
|  | 566 | BYTE    bNumConfigurations; | 
|  | 567 | }__attribute__ ((__packed__)) dwc_device_descriptor_t; | 
|  | 568 |  | 
|  | 569 | //device qualifierÃèÊö·û | 
|  | 570 | typedef struct dwc_dev_qual_descriptor_t | 
|  | 571 | { | 
|  | 572 | BYTE    bLength; | 
|  | 573 | BYTE    bDescriptorType; | 
|  | 574 | WORD16	bcdUSB; | 
|  | 575 | BYTE    bDeviceClass; | 
|  | 576 | BYTE    bDeviceSubClass; | 
|  | 577 | BYTE    bDeviceProtocol; | 
|  | 578 | BYTE    bMaxPacketSize0; | 
|  | 579 | BYTE    bNumConfigurations; | 
|  | 580 | BYTE    Reserved; | 
|  | 581 | }__attribute__ ((__packed__)) dwc_dev_qual_descriptor_t; | 
|  | 582 |  | 
|  | 583 |  | 
|  | 584 | // ±ê×¼ÅäÖÃÃèÊö·û | 
|  | 585 | typedef struct dwc_config_descriptor_t | 
|  | 586 | { | 
|  | 587 | BYTE 	bLength; | 
|  | 588 | BYTE 	bDescriptorType; | 
|  | 589 | WORD16 	wTotalLength; | 
|  | 590 | BYTE 	bNumInterfaces; | 
|  | 591 | BYTE 	bConfigurationValue; | 
|  | 592 | BYTE 	iConfiguration; | 
|  | 593 | BYTE 	bmAttributes; | 
|  | 594 | BYTE 	bMaxPower; | 
|  | 595 | }__attribute__ ((__packed__)) dwc_config_descriptor_t; | 
|  | 596 |  | 
|  | 597 | typedef struct dwc_product_descriptor_t | 
|  | 598 | { | 
|  | 599 | BYTE 	bLength; | 
|  | 600 | BYTE 	bDescriptorType; | 
|  | 601 | char    Prod_Desc[98]; | 
|  | 602 | } __attribute__ ((__packed__)) dwc_product_descriptor_t; | 
|  | 603 |  | 
|  | 604 | //#define	MAX_EPS				(0x8) | 
|  | 605 | #define	MAX_EPS				(0x2) | 
|  | 606 | typedef enum | 
|  | 607 | { | 
|  | 608 | USB_MAX_PACKET_SIZE_NOT_SET      = 0, | 
|  | 609 | USB_FULLSPEED_BULK_MAXSIZE         = 64, | 
|  | 610 | USB_HIGHSPEED_BULK_MAXSIZE        = 512, | 
|  | 611 | }T_USB_MAX_PACKET_SIZE; | 
|  | 612 |  | 
|  | 613 | typedef struct dwc_config_all_t | 
|  | 614 | { | 
|  | 615 | dwc_config_descriptor_t		tConfig; | 
|  | 616 | dwc_interface_descriptor_t	tInterface; | 
|  | 617 | dwc_ep_descriptor_t			atTxEP[1];	//·¢ËͶ˵ã(²»°üÀ¨ep0) | 
|  | 618 | dwc_ep_descriptor_t			atRxEP[1];	//½ÓÊն˵ã(²»°üÀ¨ep0) | 
|  | 619 | dwc_interface_descriptor_t	tInterface1; | 
|  | 620 | dwc_ep_descriptor_t			atTxEP1[1];	//·¢ËͶ˵ã(²»°üÀ¨ep0) | 
|  | 621 | dwc_ep_descriptor_t			atRxEP1[1];	//½ÓÊն˵ã(²»°üÀ¨ep0) | 
|  | 622 | }__attribute__ ((__packed__)) dwc_config_all_t; | 
|  | 623 |  | 
|  | 624 | #ifdef __cplusplus | 
|  | 625 | } | 
|  | 626 | #endif | 
|  | 627 |  | 
|  | 628 | #endif /* _USB_H_ */ |