xref: /utopia/UTPA2-700.0.x/modules/usb/drv/usbhost/include/_drvUSB.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 //#define     USB_POWER_SAVING_MODE
79 #ifdef ENABLE_DMP
80 #define     USBHOST2PORT                                //for 2 usb ports board, if you use only one port , please undefine it.
81 #endif
82 
83 
84 extern void MDrv_USB_EnterPowerSaveMode(void);
85 extern void MDrv_USB_EnterPowerSaveMode_Port2(void);
86 extern void MDrv_USB_EnterPowerSaveMode_Port3(void);
87 extern void MDrv_USB_EnterPowerSaveMode_Port4(void);
88 
89 extern BOOLEAN MDrv_UsbHost_Init(void);
90 extern BOOLEAN MDrv_UsbHost_Init_Enum(void);
91 U8 MDrv_USBGetPortEnableStatus(void);
92 
93 #define     MDrv_UsbDiskRead_Port2    MDrv_UsbBlockReadToMIU_Port2
94 #define     MDrv_UsbDiskWrite_Port2   MDrv_UsbBlockWriteFromMIU_Port2
95 extern BOOLEAN MDrv_UsbBlockReadToMIU_Port2(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
96 extern BOOLEAN MDrv_UsbBlockWriteFromMIU_Port2(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
97 extern BOOLEAN MDrv_UsbDeviceConnect_Port2(void);
98 U8 MDrv_GET_MASS_MAX_LUN_PORT2(void);
99 U8 MDrv_GET_MASS_VALID_LUN_PORT2(void);
100 extern BOOLEAN  MDrv_Usb_Device_Enum_Port2(void);
101 extern void MDrv_UsbClose_Port2(void);
102 extern void MDrv_USB_Init_Port2(U32);
103 extern U8 MDrv_UsbGetMaxLUNCount_Port2(void);
104 extern void MDrv_EjectUsbDevice_Port2(void);
105 U32 MDrv_GetUsbBlockSize_Port2(U8 lun);
106 U32 MDrv_GetUsbBlockNum_Port2(U8 lun);
107 extern BOOLEAN MDrv_UsbHost_Init_Enum_Port2(void);
108 U8  MDrv_GetUsbDeviceStatusPort2(void);
109 void MDrv_SetUsbDeviceStatus_Port2(U8 status);
110 U8 MDrv_GetUsbDeviceType_Port2(void);
111 void MDrv_GetUsbString_Port2(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
112 U8*  MDrv_Get_HID_Report_Raw_Data_Port2(void);
113 U8 MDrv_USBGetqTDTimeoutValue_Port2(void);
114 void MDrv_USBSetqTDTimeoutValue_Port2(U8 u8Value);
115 U8 MDrv_USBGetIORetryCount_Port2(void);
116 void MDrv_USBSetIORetryCount_Port2(U8 u8Value);
117 
118 #define     MDrv_UsbDiskRead    MDrv_UsbBlockReadToMIU
119 #define     MDrv_UsbDiskWrite   MDrv_UsbBlockWriteFromMIU
120 extern BOOLEAN MDrv_UsbBlockReadToMIU(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
121 extern BOOLEAN MDrv_UsbBlockWriteFromMIU(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
122 extern BOOLEAN MDrv_UsbDeviceConnect(void);
123 extern U8 MDrv_UsbGetInterfaceClass(U8 i,U8 j);
124 extern void MDrv_UsbClose(void);
125 extern void MDrv_USB_Init(U32);
126 extern BOOLEAN  MDrv_Usb_Device_Enum(void);
127 extern U8 flib_Host20_Enumerate (U8,U8 );
128 extern void MDrv_EjectUsbDevice(void);
129 U32 MDrv_GetUsbBlockSize(U8 lun);
130 U32 MDrv_GetUsbBlockNum(U8 lun);
131 
132 extern U8 MDrv_UsbGetMaxLUNCount(void);
133 U8 MDrv_GET_MASS_MAX_LUN(void);
134 U8 MDrv_GET_MASS_VALID_LUN(void);
135 
136 U8  MDrv_GetUsbDeviceStatus(void);
137 void MDrv_SetUsbDeviceStatus(U8 status);
138 void  MDrv_ClearUsbDeviceStatus(void);
139 U8 MDrv_GetUsbDeviceType(void);
140 void MDrv_GetUsbString(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
141 U16  MDrv_GET_JOYSTICK_STATUS(void);
142 U8*  MDrv_Get_HID_Report_Raw_Data(void);
143 U8 MDrv_USBGetqTDTimeoutValue(void);
144 void MDrv_USBSetqTDTimeoutValue(U8 u8Value);
145 U8 MDrv_USBGetIORetryCount(void);
146 void MDrv_USBSetIORetryCount(U8 u8Value);
147 
148 
149 #define     MDrv_UsbDiskRead_Port3    MDrv_UsbBlockReadToMIU_Port3
150 #define     MDrv_UsbDiskWrite_Port3   MDrv_UsbBlockWriteFromMIU_Port3
151 extern BOOLEAN MDrv_UsbBlockReadToMIU_Port3(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
152 extern BOOLEAN MDrv_UsbBlockWriteFromMIU_Port3(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
153 extern BOOLEAN MDrv_UsbDeviceConnect_Port3(void);
154 U8 MDrv_GET_MASS_MAX_LUN_PORT3(void);
155 U8 MDrv_GET_MASS_VALID_LUN_PORT3(void);
156 extern BOOLEAN  MDrv_Usb_Device_Enum_Port3(void);
157 extern void MDrv_UsbClose_Port3(void);
158 extern void MDrv_USB_Init_Port3(U32);
159 extern U8 MDrv_UsbGetMaxLUNCount_Port3(void);
160 extern void MDrv_EjectUsbDevice_Port3(void);
161 U32 MDrv_GetUsbBlockSize_Port3(U8 lun);
162 U32 MDrv_GetUsbBlockNum_Port3(U8 lun);
163 extern BOOLEAN MDrv_UsbHost_Init_Enum_Port3(void);
164 U8  MDrv_GetUsbDeviceStatusPort3(void);
165 void MDrv_SetUsbDeviceStatus_Port3(U8 status);
166 U8 MDrv_GetUsbDeviceType_Port3(void);
167 void MDrv_GetUsbString_Port3(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
168 U8*  MDrv_Get_HID_Report_Raw_Data_Port3(void);
169 U8 MDrv_USBGetqTDTimeoutValue_Port3(void);
170 void MDrv_USBSetqTDTimeoutValue_Port3(U8 u8Value);
171 U8 MDrv_USBGetIORetryCount_Port3(void);
172 void MDrv_USBSetIORetryCount_Port3(U8 u8Value);
173 
174 #define     MDrv_UsbDiskRead_Port4    MDrv_UsbBlockReadToMIU_Port4
175 #define     MDrv_UsbDiskWrite_Port4   MDrv_UsbBlockWriteFromMIU_Port4
176 extern BOOLEAN MDrv_UsbBlockReadToMIU_Port4(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
177 extern BOOLEAN MDrv_UsbBlockWriteFromMIU_Port4(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
178 extern BOOLEAN MDrv_UsbDeviceConnect_Port4(void);
179 U8 MDrv_GET_MASS_MAX_LUN_PORT4(void);
180 U8 MDrv_GET_MASS_VALID_LUN_PORT4(void);
181 extern BOOLEAN  MDrv_Usb_Device_Enum_Port4(void);
182 extern void MDrv_UsbClose_Port4(void);
183 extern void MDrv_USB_Init_Port4(U32);
184 extern U8 MDrv_UsbGetMaxLUNCount_Port4(void);
185 extern void MDrv_EjectUsbDevice_Port4(void);
186 U32 MDrv_GetUsbBlockSize_Port4(U8 lun);
187 U32 MDrv_GetUsbBlockNum_Port4(U8 lun);
188 extern BOOLEAN MDrv_UsbHost_Init_Enum_Port4(void);
189 U8  MDrv_GetUsbDeviceStatusPort4(void);
190 void MDrv_SetUsbDeviceStatus_Port4(U8 status);
191 U8 MDrv_GetUsbDeviceType_Port4(void);
192 void MDrv_GetUsbString_Port4(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
193 U8*  MDrv_Get_HID_Report_Raw_Data_Port4(void);
194 U8 MDrv_USBGetqTDTimeoutValue_Port4(void);
195 void MDrv_USBSetqTDTimeoutValue_Port4(U8 u8Value);
196 U8 MDrv_USBGetIORetryCount_Port4(void);
197 void MDrv_USBSetIORetryCount_Port4(U8 u8Value);
198 
199 
200 #define USB_NOT_RESPONSE		    0xff
201 #define USB_INTERFACE_CLASS_NONE 0
202 #define USB_INTERFACE_CLASS_MSD  0x08
203 #define USB_INTERFACE_CLASS_HUB  0x09
204 #define USB_INTERFACE_CLASS_IMAGE  0x06
205 #define USB_INTERFACE_CLASS_HID  0x03
206 
207 
208 //Chip ID deifinition
209 #define CHIPID_NEPTUNE     0x0002
210 #define CHIPID_ERIS        0x0003
211 #define CHIPID_TITANIA     0x0004
212 #define CHIPID_PLUTO       0x0005
213 #define CHIPID_TRITON      0x0006
214 #define CHIPID_TITANIA2    0x000B
215 #define CHIPID_TITANIA3    0x000F
216 #define CHIPID_EUCLID      0x0015
217 #define CHIPID_TITANIA4    0x0018
218 #define CHIPID_TITANIA7    0x001C
219 #define CHIPID_TITANIA8    0x001F
220 #define CHIPID_TITANIA9    0x0023
221 #define CHIPID_TITANIA12   0x0029
222 #define CHIPID_TITANIA13   0x002D
223 #define CHIPID_JANUS       0x001D
224 #define CHIPID_MARIA10     0x0025
225 #define CHIPID_JANUS2      0x002B
226 #define CHIPID_AMBER1      0x0031
227 #define CHIPID_AMBER5      0x0038
228 #define CHIPID_AMBER6      0x0040
229 #define CHIPID_AMBER7      0x0042
230 #define CHIPID_AMBER3      0x0047
231 #define CHIPID_AMETHYST    0x004D
232 #define CHIPID_AGATE       0x004F
233 #define CHIPID_E8          0x004E
234 #define CHIPID_MACAW12     0x0107
235 #define CHIPID_ELK         0x0054
236 #define CHIPID_EAGLE       0x0051
237 #define CHIPID_EMERALD     0x0057
238 #define CHIPID_EDISON      0x0058
239 #define CHIPID_EDEN        0x0065
240 #define CHIPID_EULER       0x0068
241 #define CHIPID_EIFFEL      0x0067
242 #define CHIPID_NUGGET      0x0069
243 #define CHIPID_NIKE        0x0074
244 #define CHIPID_NIKON       0x0075
245 #define CHIPID_EINSTEIN    0x0066
246 #define CHIPID_NAPOLI      0x0166
247 #define CHIPID_EINSTEIN3   0x0070
248 #define CHIPID_MONACO      0x0072
249 #define CHIPID_MADISON     0x005C
250 #define CHIPID_MIAMI       0x0082
251 #define CHIPID_CLIPPERS    0x0086
252 #define CHIPID_MUJI        0x0087
253 #define CHIPID_MONET       0x008D
254 #define CHIPID_K6LITE      0x00BE
255 
256 // project code definition
257 #define     JUPITER                 0
258 #define     NEPTUNE                 1
259 #define     RAPHAEL                 2
260 #define     ERIS                    3
261 
262 #define 	NO_DEVICE               0
263 #define     USB11_DEVICE            1
264 #define 	USB20_DEVICE            2
265 #define	    BAD_DEVICE              3
266 #define     CONNECT_DEVICE          4
267 #define     POWER_SAVING            5
268 #define     WAIT_INIT               6
269 
270 #define USB_PORT_0          0
271 #define USB_PORT_2          1
272 #define USB_PORT_3          2
273 #define USB_PORT_4          3
274 
275 #define USB_STR_VENDOR              1
276 #define USB_STR_PRODUCT            2
277 
278 #define USB_HOST_INIT_DELAY   500
279 #define USB_ENUM_DELAY           150
280 
281 enum // for return value of MDrv_Usb_Device_Enum_EX()
282 {
283 DEVENUM_OK = 0,
284 DEVENUM_INPROGRESS,
285 DEVENUM_FAIL
286 };
287 
288 
289