tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc9630 / 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 /**----------------------------------------------------------------------------*
177 **                             Data Prototype                                 **
178 **----------------------------------------------------------------------------*/
179 //Stand USB device request command type define ;
180 typedef union _USB_STD_DEV_REQ_T
181 {
182     struct
183     {
184         union
185         {
186             struct bit_map
187             {
188                 char direction :1;
189                 char command   :2;
190                 char receiver  :5;
191             } bits;
192             char octet;
193         } uReqType;
194         char  bReqCode;
195         short wValue;
196         short wIndex;
197         short wLength;
198     } sData;
199     char bBuf[8];
200 } USB_STD_DEV_REQ_U;
201
202 typedef union
203 {
204     struct
205     {
206         short   type    :8;
207         short   index   :8;
208     } sDescriptor;
209     short wValue;
210 } VALUE_U;
211
212 //Four bytes buildup a 32bit value ;
213 typedef union _USB_DWORD_U
214 {
215     union
216     {
217         struct
218         {
219             char  c0;
220             char  c1;
221             char  c2;
222             char  c3;
223         } sOcts;
224         char bBuf[4];
225     } uData;
226     int dwValue;
227 } USB_DWORD_U;
228
229
230 //Two bytes buildup a 16bit value ;
231 typedef union _USB_WORD_U
232 {
233     union
234     {
235         struct
236         {
237             char  c0;
238             char  c1;
239         } sOcts;
240         char bBuf[2];
241     } uData;
242     int wValue;
243 } USB_WORD_U;
244
245 //
246 // values for bmAttributes Field in
247 // USB_CONFIGURATION_DESCRIPTOR
248 //
249
250
251 //
252 // Standard USB HUB definitions
253 //
254 // See Chapter 11
255 //
256 typedef struct _USB_DEVICE_DESCRIPTOR
257 {
258     char bLength;
259     char bDescriptorType;
260     short bcdUSB;
261     char bDeviceClass;
262     char bDeviceSubClass;
263     char bDeviceProtocol;
264     char bMaxPacketSize0;
265     short idVendor;
266     short idProduct;
267     short bcdDevice;
268     char iManufacturer;
269     char iProduct;
270     char iSerialNumber;
271     char bNumConfigurations;
272 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
273
274 typedef struct _USB_CONFIGURATION_DESCRIPTOR
275 {
276     char bLength;
277     char bDescriptorType;
278     short wTotalLength;
279     char bNumInterfaces;
280     char bConfigurationValue;
281     char iConfiguration;
282     char bmAttributes;
283     char MaxPower;
284 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
285
286 typedef struct _USB_INTERFACE_DESCRIPTOR
287 {
288     char bLength;
289     char bDescriptorType;
290     char bInterfaceNumber;
291     char bAlternateSetting;
292     char bNumEndpoints;
293     char bInterfaceClass;
294     char bInterfaceSubClass;
295     char bInterfaceProtocol;
296     char iInterface;
297 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
298
299 typedef struct _USB_STRING_DESCRIPTOR
300 {
301     char bLength;
302     char bDescriptorType;
303     char bString[1];
304 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
305
306 typedef struct _USB_ENDPOINT_DESCRIPTOR
307 {
308     char bLength;
309     char bDescriptorType;
310     union _bEndpointAddress
311     {
312         struct
313         {
314             char direction      :1;
315             char reserved       :3;
316             char number         :4;
317         } bits;
318         char value;
319     } bEndpointAddress;
320     union _bmAttributes
321     {
322         struct
323         {
324             char reserved       :2;
325             char usage_type     :2;
326             char sync_type      :2;
327             char trans_type     :2;
328         } bits;
329         char value;
330     } bmAttributes;
331     short wMaxPacketSize;
332     char bInterval;
333 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
334
335
336 typedef struct _USB_HUB_DESCRIPTOR
337 {
338     char        bDescriptorLength;      // Length of this descriptor
339     char        bDescriptorType;        // Hub configuration type
340     char        bNumberOfPorts;         // number of ports on this hub
341     short       wHubCharacteristics;    // Hub Charateristics
342     char        bPowerOnToPowerGood;    // port power on till power good in 2ms
343     char        bHubControlCurrent;     // max current in mA
344     //
345     // room for 255 ports power control and removable bitmask
346     char        bRemoveAndPowerMask[64];
347 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
348
349
350 typedef struct _USB_STRING_LANGUAGE_DESCRIPTOR
351 {
352     char  bLength;
353     char  bDescriptorType;
354     short ulanguageID;
355 } USB_STRING_LANGUAGE_DESCRIPTOR,*PUSB_STRING_LANGUAGE_DESCRIPTOR;
356
357 typedef struct _USB_STRING_INTERFACE_DESCRIPTOR
358 {
359     char  bLength;
360     char  bDescriptorType;
361     char  Interface[22];
362 } USB_STRING_INTERFACE_DESCRIPTOR,*PUSB_STRING_INTERFACE_DESCRIPTOR;
363
364 typedef struct _USB_STRING_CONFIGURATION_DESCRIPTOR
365 {
366     char  bLength;
367     char  bDescriptorType;
368     char  Configuration[16];
369 } USB_STRING_CONFIGURATION_DESCRIPTOR,*PUSB_STRING_CONFIGURATION_DESCRIPTOR;
370
371 typedef struct _USB_STRING_SERIALNUMBER_DESCRIPTOR
372 {
373     char  bLength;
374     char  bDescriptorType;
375     char  SerialNum[24];
376 } USB_STRING_SERIALNUMBER_DESCRIPTOR,*PUSB_STRING_SERIALNUMBER_DESCRIPTOR;
377
378 typedef struct _USB_STRING_PRODUCT_DESCRIPTOR
379 {
380     char  bLength;
381     char  bDescriptorType;
382     char  Product[30];
383 } USB_STRING_PRODUCT_DESCRIPTOR,*PUSB_STRING_PRODUCT_DESCRIPTOR;
384
385 typedef struct _USB_STRING_MANUFACTURER_DESCRIPTOR
386 {
387     char  bLength;
388     char  bDescriptorType;
389     char  Manufacturer[24];
390 } USB_STRING_MANUFACTURER_DESCRIPTOR,*PUSB_STRING_MANUFACTURER_DESCRIPTOR;
391
392 typedef struct _USB_POWER_DESCRIPTOR
393 {
394     char bLength;
395     char bDescriptorType;
396     char bCapabilitiesFlags;
397     short EventNotification;
398     short D1LatencyTime;
399     short D2LatencyTime;
400     short D3LatencyTime;
401     char PowerUnit;
402     short D0PowerConsumption;
403     short D1PowerConsumption;
404     short D2PowerConsumption;
405 } USB_POWER_DESCRIPTOR, *PUSB_POWER_DESCRIPTOR;
406
407
408 typedef struct _USB_COMMON_DESCRIPTOR
409 {
410     char bLength;
411     char bDescriptorType;
412 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
413
414 /**----------------------------------------------------------------------------*
415 **                         Local Function Prototype                           **
416 **----------------------------------------------------------------------------*/
417
418 /**----------------------------------------------------------------------------*
419 **                           Function Prototype                               **
420 **----------------------------------------------------------------------------*/
421
422
423 /**----------------------------------------------------------------------------*
424 **                         Compiler Flag                                      **
425 **----------------------------------------------------------------------------*/
426 #ifdef   __cplusplus
427 }
428 #endif
429 /**---------------------------------------------------------------------------*/
430 #endif
431 // End