change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8830 / usb200_fdl.h
1 /******************************************************************************
2  ** File Name:    USB200.h                                                    *
3  ** Author:       Daniel.Ding                                                 *
4  ** DATE:         3/9/2005                                                    *
5  ** Copyright:    2005 Spreatrum, Incoporated. All Rights Reserved.           *
6  ** Description:                                                              *
7  ******************************************************************************/
8 /******************************************************************************
9  **                   Edit    History                                         *
10  **---------------------------------------------------------------------------*
11  ** DATE          NAME            DESCRIPTION                                 *
12  ** 9/1/2003      Daniel.Ding     Create.                                     *
13  ******************************************************************************/
14 #ifndef _USB200_FDL_H_
15 #define _USB200_FDL_H_
16 /*----------------------------------------------------------------------------*
17  **                         Dependencies                                      *
18  **-------------------------------------------------------------------------- */
19
20 #include "common.h"
21 /**---------------------------------------------------------------------------*
22  **                             Compiler Flag                                 *
23  **---------------------------------------------------------------------------*/
24 #ifdef   __cplusplus
25 extern   "C"
26 {
27 #endif
28 /**----------------------------------------------------------------------------*
29 **                               Micro Define                                 **
30 **----------------------------------------------------------------------------*/
31 #define MAXIMUM_USB_STRING_LENGTH 255
32
33 #define USB_GETSTATUS_SELF_POWERED                0x01
34 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED       0x02
35
36
37 #define USB_DEVICE_DESCRIPTOR_TYPE                0x01
38 #define USB_CONFIGURATION_DESCRIPTOR_TYPE         0x02
39 #define USB_STRING_DESCRIPTOR_TYPE                0x03
40 #define USB_INTERFACE_DESCRIPTOR_TYPE             0x04
41 #define USB_ENDPOINT_DESCRIPTOR_TYPE              0x05
42 #define USB_POWER_DESCRIPTOR_TYPE                 0x06
43
44 #define STR_INDEX_LANGUAGE                        0x00
45 #define STR_INDEX_MANUFACTURER                    0x01
46 #define STR_INDEX_PRODUCT                         0x02
47 #define STR_INDEX_SERIALNUMBER                    0x03
48 #define STR_INDEX_CONFIGURATION                   0x04
49 #define STR_INDEX_INTERFACE                       0x05
50
51 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((short)((short)d<<8 | i))
52
53 //
54 // Values for bmAttributes field of an
55 // endpoint descriptor
56 //
57
58 #define USB_ENDPOINT_TYPE_MASK                    0x03
59
60 #define USB_ENDPOINT_TYPE_CONTROL                 0x00
61 #define USB_ENDPOINT_TYPE_ISOCHRONOUS             0x01
62 #define USB_ENDPOINT_TYPE_BULK                    0x02
63 #define USB_ENDPOINT_TYPE_INTERRUPT               0x03
64
65
66 //
67 // definitions for bits in the bmAttributes field of a
68 // configuration descriptor.
69 //
70 #define USB_CONFIG_POWERED_MASK                   0xc0
71
72 #define USB_CONFIG_BUS_POWERED                    0x80
73 #define USB_CONFIG_SELF_POWERED                   0x40
74 #define USB_CONFIG_REMOTE_WAKEUP                  0x20
75
76 //
77 // Endpoint direction bit, stored in address
78 //
79
80 #define USB_ENDPOINT_DIRECTION_MASK               0x80
81
82 // test direction bit in the bEndpointAddress field of
83 // an endpoint descriptor.
84 #define USB_ENDPOINT_DIRECTION_OUT(addr)          (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
85 #define USB_ENDPOINT_DIRECTION_IN(addr)           ((addr) & USB_ENDPOINT_DIRECTION_MASK)
86
87 //
88 // USB defined request codes
89 // see chapter 9 of the USB 1.0 specifcation for
90 // more information.
91 //
92
93 // These are the correct values based on the USB 1.0
94 // specification
95
96 #define USB_REQUEST_GET_STATUS                    0x00
97 #define USB_REQUEST_CLEAR_FEATURE                 0x01
98
99 #define USB_REQUEST_SET_FEATURE                   0x03
100
101 #define USB_REQUEST_SET_ADDRESS                   0x05
102 #define USB_REQUEST_GET_DESCRIPTOR                0x06
103 #define USB_REQUEST_SET_DESCRIPTOR                0x07
104 #define USB_REQUEST_GET_CONFIGURATION             0x08
105 #define USB_REQUEST_SET_CONFIGURATION             0x09
106 #define USB_REQUEST_GET_INTERFACE                 0x0A
107 #define USB_REQUEST_SET_INTERFACE                 0x0B
108 #define USB_REQUEST_SYNC_FRAME                    0x0C
109
110
111 //
112 // defined USB device classes
113 //
114
115
116 #define USB_DEVICE_CLASS_RESERVED           0x00
117 #define USB_DEVICE_CLASS_AUDIO              0x01
118 #define USB_DEVICE_CLASS_COMMUNICATIONS     0x02
119 #define USB_DEVICE_CLASS_HUMAN_INTERFACE    0x03
120 #define USB_DEVICE_CLASS_MONITOR            0x04
121 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
122 #define USB_DEVICE_CLASS_POWER              0x06
123 #define USB_DEVICE_CLASS_PRINTER            0x07
124 #define USB_DEVICE_CLASS_STORAGE            0x08
125 #define USB_DEVICE_CLASS_HUB                0x09
126 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC    0xFF
127
128 //
129 // USB defined Feature selectors
130 //
131
132 #define USB_FEATURE_ENDPOINT_STALL          0x0000
133 #define USB_FEATURE_REMOTE_WAKEUP           0x0001
134 #define USB_FEATURE_POWER_D0                0x0002
135 #define USB_FEATURE_POWER_D1                0x0003
136 #define USB_FEATURE_POWER_D2                0x0004
137 #define USB_FEATURE_POWER_D3                0x0005
138
139
140 //Define direction ;
141 #define HOST_IN     0x01        //From device to host ;
142 #define HOST_OUT    0x00        //From host to device ;
143
144 //Define request type;
145 #define USB_REQ_STANDARD    0x00
146 #define USB_REQ_CLASS       0x01
147 #define USB_REQ_VENDOR      0x02
148 #define USB_REQ_RESERVED    0x03
149
150 //Define accepter ;
151 #define USB_REC_DEVICE      0x00
152 #define USB_REC_INTERFACE   0x01
153 #define USB_REC_ENDPOINT    0x02
154 #define USB_REC_OTHER       0x03
155
156 #define USB_MAX_REQ_TYPE    0x04
157 #define USB_MAX_RECIPIENT   0x05
158 #define USB_MAX_REQUEST     0x30
159
160 #define BUS_POWERED                           0x80
161 #define SELF_POWERED                          0x40
162 #define REMOTE_WAKEUP                         0x20
163
164 //
165 // USB power descriptor added to core specification
166 //
167
168 #define USB_SUPPORT_D0_COMMAND      0x01
169 #define USB_SUPPORT_D1_COMMAND      0x02
170 #define USB_SUPPORT_D2_COMMAND      0x04
171 #define USB_SUPPORT_D3_COMMAND      0x08
172
173 #define USB_SUPPORT_D1_WAKEUP       0x10
174 #define USB_SUPPORT_D2_WAKEUP       0x20
175
176 #define USB_CLEAR_COMM_FEATURE                              0x04
177 #define USB_GET_COMM_FEATURE                                0x03
178 #define USB_SET_COMM_FEATURE                                0x02
179 /**----------------------------------------------------------------------------*
180 **                             Data Prototype                                 **
181 **----------------------------------------------------------------------------*/
182 //Stand USB device request command type define ;
183 typedef union _USB_STD_DEV_REQ_T
184 {
185     struct
186     {
187         union
188         {
189             struct bit_map
190             {
191                 char direction :1;
192                 char command   :2;
193                 char receiver  :5;
194             } bits;
195             char octet;
196         } uReqType;
197         char  bReqCode;
198         short wValue;
199         short wIndex;
200         short wLength;
201     } sData;
202     char bBuf[8];
203 } USB_STD_DEV_REQ_U;
204
205 typedef union
206 {
207     struct
208     {
209         short   type    :8;
210         short   index   :8;
211     } sDescriptor;
212     short wValue;
213 } VALUE_U;
214
215 //Four bytes buildup a 32bit value ;
216 typedef union _USB_DWORD_U
217 {
218     union
219     {
220         struct
221         {
222             char  c0;
223             char  c1;
224             char  c2;
225             char  c3;
226         } sOcts;
227         char bBuf[4];
228     } uData;
229     int dwValue;
230 } USB_DWORD_U;
231
232
233 //Two bytes buildup a 16bit value ;
234 typedef union _USB_WORD_U
235 {
236     union
237     {
238         struct
239         {
240             char  c0;
241             char  c1;
242         } sOcts;
243         char bBuf[2];
244     } uData;
245     int wValue;
246 } USB_WORD_U;
247
248 //
249 // values for bmAttributes Field in
250 // USB_CONFIGURATION_DESCRIPTOR
251 //
252
253
254 //
255 // Standard USB HUB definitions
256 //
257 // See Chapter 11
258 //
259 typedef struct _USB_DEVICE_DESCRIPTOR
260 {
261     char bLength;
262     char bDescriptorType;
263     short bcdUSB;
264     char bDeviceClass;
265     char bDeviceSubClass;
266     char bDeviceProtocol;
267     char bMaxPacketSize0;
268     short idVendor;
269     short idProduct;
270     short bcdDevice;
271     char iManufacturer;
272     char iProduct;
273     char iSerialNumber;
274     char bNumConfigurations;
275 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
276
277 typedef struct _USB_CONFIGURATION_DESCRIPTOR
278 {
279     char bLength;
280     char bDescriptorType;
281     short wTotalLength;
282     char bNumInterfaces;
283     char bConfigurationValue;
284     char iConfiguration;
285     char bmAttributes;
286     char MaxPower;
287 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
288
289 typedef struct _USB_INTERFACE_DESCRIPTOR
290 {
291     char bLength;
292     char bDescriptorType;
293     char bInterfaceNumber;
294     char bAlternateSetting;
295     char bNumEndpoints;
296     char bInterfaceClass;
297     char bInterfaceSubClass;
298     char bInterfaceProtocol;
299     char iInterface;
300 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
301
302 typedef struct _USB_STRING_DESCRIPTOR
303 {
304     char bLength;
305     char bDescriptorType;
306     char bString[1];
307 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
308
309 typedef struct _USB_ENDPOINT_DESCRIPTOR
310 {
311     char bLength;
312     char bDescriptorType;
313     union _bEndpointAddress
314     {
315         struct
316         {
317             char direction      :1;
318             char reserved       :3;
319             char number         :4;
320         } bits;
321         char value;
322     } bEndpointAddress;
323     union _bmAttributes
324     {
325         struct
326         {
327             char reserved       :2;
328             char usage_type     :2;
329             char sync_type      :2;
330             char trans_type     :2;
331         } bits;
332         char value;
333     } bmAttributes;
334     short wMaxPacketSize;
335     char bInterval;
336 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
337
338
339 typedef struct _USB_HUB_DESCRIPTOR
340 {
341     char        bDescriptorLength;      // Length of this descriptor
342     char        bDescriptorType;        // Hub configuration type
343     char        bNumberOfPorts;         // number of ports on this hub
344     short       wHubCharacteristics;    // Hub Charateristics
345     char        bPowerOnToPowerGood;    // port power on till power good in 2ms
346     char        bHubControlCurrent;     // max current in mA
347     //
348     // room for 255 ports power control and removable bitmask
349     char        bRemoveAndPowerMask[64];
350 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
351
352
353 typedef struct _USB_STRING_LANGUAGE_DESCRIPTOR
354 {
355     char  bLength;
356     char  bDescriptorType;
357     short ulanguageID;
358 } USB_STRING_LANGUAGE_DESCRIPTOR,*PUSB_STRING_LANGUAGE_DESCRIPTOR;
359
360 typedef struct _USB_STRING_INTERFACE_DESCRIPTOR
361 {
362     char  bLength;
363     char  bDescriptorType;
364     char  Interface[22];
365 } USB_STRING_INTERFACE_DESCRIPTOR,*PUSB_STRING_INTERFACE_DESCRIPTOR;
366
367 typedef struct _USB_STRING_CONFIGURATION_DESCRIPTOR
368 {
369     char  bLength;
370     char  bDescriptorType;
371     char  Configuration[16];
372 } USB_STRING_CONFIGURATION_DESCRIPTOR,*PUSB_STRING_CONFIGURATION_DESCRIPTOR;
373
374 typedef struct _USB_STRING_SERIALNUMBER_DESCRIPTOR
375 {
376     char  bLength;
377     char  bDescriptorType;
378     char  SerialNum[24];
379 } USB_STRING_SERIALNUMBER_DESCRIPTOR,*PUSB_STRING_SERIALNUMBER_DESCRIPTOR;
380
381 typedef struct _USB_STRING_PRODUCT_DESCRIPTOR
382 {
383     char  bLength;
384     char  bDescriptorType;
385     char  Product[30];
386 } USB_STRING_PRODUCT_DESCRIPTOR,*PUSB_STRING_PRODUCT_DESCRIPTOR;
387
388 typedef struct _USB_STRING_MANUFACTURER_DESCRIPTOR
389 {
390     char  bLength;
391     char  bDescriptorType;
392     char  Manufacturer[24];
393 } USB_STRING_MANUFACTURER_DESCRIPTOR,*PUSB_STRING_MANUFACTURER_DESCRIPTOR;
394
395 typedef struct _USB_POWER_DESCRIPTOR
396 {
397     char bLength;
398     char bDescriptorType;
399     char bCapabilitiesFlags;
400     short EventNotification;
401     short D1LatencyTime;
402     short D2LatencyTime;
403     short D3LatencyTime;
404     char PowerUnit;
405     short D0PowerConsumption;
406     short D1PowerConsumption;
407     short D2PowerConsumption;
408 } USB_POWER_DESCRIPTOR, *PUSB_POWER_DESCRIPTOR;
409
410
411 typedef struct _USB_COMMON_DESCRIPTOR
412 {
413     char bLength;
414     char bDescriptorType;
415 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
416
417 /**----------------------------------------------------------------------------*
418 **                         Local Function Prototype                           **
419 **----------------------------------------------------------------------------*/
420
421 /**----------------------------------------------------------------------------*
422 **                           Function Prototype                               **
423 **----------------------------------------------------------------------------*/
424
425
426 /**----------------------------------------------------------------------------*
427 **                         Compiler Flag                                      **
428 **----------------------------------------------------------------------------*/
429 #ifdef   __cplusplus
430 }
431 #endif
432 /**---------------------------------------------------------------------------*/
433 #endif
434 // End