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 #ifndef _DRVUSB_H_
79 #define _DRVUSB_H_
80 #include "SW_Config.h"
81 #include "Board.h"
82 #if (ENABLE_PWS == 1)
83 //#define     USB_POWER_SAVING_MODE
84 #endif
85 
86 #if ENABLE_DMP
87 #define     USBHOST2PORT                                //for 2 usb ports board, if you use only one port , please undefine it.
88 #endif
89 
90 
91 extern void MDrv_USB_EnterPowerSaveMode(void);
92 extern void MDrv_USB_EnterPowerSaveMode_Port2(void);
93 extern void MDrv_USB_EnterPowerSaveMode_Port3(void);
94 extern void MDrv_USB_EnterPowerSaveMode_Port4(void);
95 
96 
97 extern BOOLEAN MDrv_UsbHost_Init(void);
98 extern BOOLEAN MDrv_UsbHost_Init_Enum(void);
99 U8 MDrv_USBGetPortEnableStatus(void);
100 
101 #define     MDrv_UsbDiskRead_Port2    MDrv_UsbBlockReadToMIU_Port2
102 #define     MDrv_UsbDiskWrite_Port2   MDrv_UsbBlockWriteFromMIU_Port2
103 extern BOOLEAN MDrv_UsbBlockReadToMIU_Port2(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
104 extern BOOLEAN MDrv_UsbBlockWriteFromMIU_Port2(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
105 extern BOOLEAN MDrv_UsbDeviceConnect_Port2(void);
106 U8 MDrv_GET_MASS_MAX_LUN_PORT2(void);
107 U8 MDrv_GET_MASS_VALID_LUN_PORT2(void);
108 extern BOOLEAN  MDrv_Usb_Device_Enum_Port2(void);
109 extern U8 MDrv_Usb_Device_Enum_EX_Port2(void);
110 extern void MDrv_UsbClose_Port2(void);
111 extern void MDrv_USB_Init_Port2(U32);
112 extern U8 MDrv_UsbGetMaxLUNCount_Port2(void);
113 extern void MDrv_EjectUsbDevice_Port2(void);
114 U32 MDrv_GetUsbBlockSize_Port2(U8 lun);
115 U32 MDrv_GetUsbBlockNum_Port2(U8 lun);
116 extern BOOLEAN MDrv_UsbHost_Init_Enum_Port2(void);
117 U8  MDrv_GetUsbDeviceStatusPort2(void);
118 void MDrv_SetUsbDeviceStatus_Port2(U8 status);
119 U8 MDrv_GetUsbDeviceType_Port2(void);
120 void MDrv_GetUsbString_Port2(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
121 U8*  MDrv_Get_HID_Report_Raw_Data_Port2(void);
122 U8 MDrv_USBGetqTDTimeoutValue_Port2(void);
123 void MDrv_USBSetqTDTimeoutValue_Port2(U8 u8Value);
124 U8 MDrv_USBGetIORetryCount_Port2(void);
125 void MDrv_USBSetIORetryCount_Port2(U8 u8Value);
126 void MDrv_GetUsbStorString_Port2(U8 uLun, U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
127 void MDrv_UsbSendTestPacket_Port2(void);
128 void MDrv_UsbSendSE0_Port2(void);
129 void MDrv_UsbSendTestJ_Port2(void);
130 void MDrv_UsbSendTestK_Port2(void);
131 U8 MDrv_GetUsbDevInterfaceClass_Port2(void);
132 
133 #define     MDrv_UsbDiskRead    MDrv_UsbBlockReadToMIU
134 #define     MDrv_UsbDiskWrite   MDrv_UsbBlockWriteFromMIU
135 extern BOOLEAN MDrv_UsbBlockReadToMIU(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
136 extern BOOLEAN MDrv_UsbBlockWriteFromMIU(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
137 extern BOOLEAN MDrv_UsbDeviceConnect(void);
138 extern U8 MDrv_UsbGetInterfaceClass(U8 i,U8 j);
139 extern void MDrv_UsbClose(void);
140 extern void MDrv_USB_Init(U32);
141 extern BOOLEAN  MDrv_Usb_Device_Enum(void);
142 extern U8 MDrv_Usb_Device_Enum_EX(void);
143 extern U8 flib_Host20_Enumerate (U8,U8 );
144 extern void MDrv_EjectUsbDevice(void);
145 U32 MDrv_GetUsbBlockSize(U8 lun);
146 U32 MDrv_GetUsbBlockNum(U8 lun);
147 
148 extern U8 MDrv_UsbGetMaxLUNCount(void);
149 U8 MDrv_GET_MASS_MAX_LUN(void);
150 U8 MDrv_GET_MASS_VALID_LUN(void);
151 
152 U8  MDrv_GetUsbDeviceStatus(void);
153 void MDrv_SetUsbDeviceStatus(U8 status);
154 void  MDrv_ClearUsbDeviceStatus(void);
155 U8 MDrv_GetUsbDeviceType(void);
156 void MDrv_GetUsbString(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
157 U16  MDrv_GET_JOYSTICK_STATUS(void);
158 U8*  MDrv_Get_HID_Report_Raw_Data(void);
159 U8 MDrv_USBGetqTDTimeoutValue(void);
160 void MDrv_USBSetqTDTimeoutValue(U8 u8Value);
161 U8 MDrv_USBGetIORetryCount(void);
162 void MDrv_USBSetIORetryCount(U8 u8Value);
163 BOOLEAN MDrv_USBGetPortAutoSwitchStatus(void);
164 void MDrv_USBSetPortAutoSwitchStatus(BOOLEAN bEnable);
165 void MDrv_USBSetPortSwitch(U8 uPort);
166 void MDrv_GetUsbStorString(U8 uLun, U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
167 void MDrv_UsbSendTestPacket(void);
168 void MDrv_UsbSendSE0(void);
169 void MDrv_UsbSendTestJ(void);
170 void MDrv_UsbSendTestK(void);
171 U8 MDrv_GetUsbDevInterfaceClass(void);
172 
173 #define     MDrv_UsbDiskRead_Port3    MDrv_UsbBlockReadToMIU_Port3
174 #define     MDrv_UsbDiskWrite_Port3   MDrv_UsbBlockWriteFromMIU_Port3
175 extern BOOLEAN MDrv_UsbBlockReadToMIU_Port3(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
176 extern BOOLEAN MDrv_UsbBlockWriteFromMIU_Port3(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
177 extern BOOLEAN MDrv_UsbDeviceConnect_Port3(void);
178 U8 MDrv_GET_MASS_MAX_LUN_PORT3(void);
179 U8 MDrv_GET_MASS_VALID_LUN_PORT3(void);
180 extern BOOLEAN  MDrv_Usb_Device_Enum_Port3(void);
181 extern U8 MDrv_Usb_Device_Enum_EX_Port3(void);
182 extern void MDrv_UsbClose_Port3(void);
183 extern void MDrv_USB_Init_Port3(U32);
184 extern U8 MDrv_UsbGetMaxLUNCount_Port3(void);
185 extern void MDrv_EjectUsbDevice_Port3(void);
186 U32 MDrv_GetUsbBlockSize_Port3(U8 lun);
187 U32 MDrv_GetUsbBlockNum_Port3(U8 lun);
188 extern BOOLEAN MDrv_UsbHost_Init_Enum_Port3(void);
189 U8  MDrv_GetUsbDeviceStatusPort3(void);
190 void MDrv_SetUsbDeviceStatus_Port3(U8 status);
191 U8 MDrv_GetUsbDeviceType_Port3(void);
192 void MDrv_GetUsbString_Port3(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
193 U8*  MDrv_Get_HID_Report_Raw_Data_Port3(void);
194 U8 MDrv_USBGetqTDTimeoutValue_Port3(void);
195 void MDrv_USBSetqTDTimeoutValue_Port3(U8 u8Value);
196 U8 MDrv_USBGetIORetryCount_Port3(void);
197 void MDrv_USBSetIORetryCount_Port3(U8 u8Value);
198 void MDrv_GetUsbStorString_Port3(U8 uLun, U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
199 void MDrv_UsbSendTestPacket_Port3(void);
200 void MDrv_UsbSendSE0_Port3(void);
201 void MDrv_UsbSendTestJ_Port3(void);
202 void MDrv_UsbSendTestK_Port3(void);
203 U8 MDrv_GetUsbDevInterfaceClass_Port3(void);
204 
205 #define     MDrv_UsbDiskRead_Port4    MDrv_UsbBlockReadToMIU_Port4
206 #define     MDrv_UsbDiskWrite_Port4   MDrv_UsbBlockWriteFromMIU_Port4
207 extern BOOLEAN MDrv_UsbBlockReadToMIU_Port4(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
208 extern BOOLEAN MDrv_UsbBlockWriteFromMIU_Port4(U8 lun,U32 u32BlockAddr, U32 u32BlockNum,U32 u32Buffer);
209 extern BOOLEAN MDrv_UsbDeviceConnect_Port4(void);
210 U8 MDrv_GET_MASS_MAX_LUN_PORT4(void);
211 U8 MDrv_GET_MASS_VALID_LUN_PORT4(void);
212 extern BOOLEAN  MDrv_Usb_Device_Enum_Port4(void);
213 extern U8 MDrv_Usb_Device_Enum_EX_Port4(void);
214 extern void MDrv_UsbClose_Port4(void);
215 extern void MDrv_USB_Init_Port4(U32);
216 extern U8 MDrv_UsbGetMaxLUNCount_Port4(void);
217 extern void MDrv_EjectUsbDevice_Port4(void);
218 U32 MDrv_GetUsbBlockSize_Port4(U8 lun);
219 U32 MDrv_GetUsbBlockNum_Port4(U8 lun);
220 extern BOOLEAN MDrv_UsbHost_Init_Enum_Port4(void);
221 U8  MDrv_GetUsbDeviceStatusPort4(void);
222 void MDrv_SetUsbDeviceStatus_Port4(U8 status);
223 U8 MDrv_GetUsbDeviceType_Port4(void);
224 void MDrv_GetUsbString_Port4(U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
225 U8*  MDrv_Get_HID_Report_Raw_Data_Port4(void);
226 U8 MDrv_USBGetqTDTimeoutValue_Port4(void);
227 void MDrv_USBSetqTDTimeoutValue_Port4(U8 u8Value);
228 U8 MDrv_USBGetIORetryCount_Port4(void);
229 void MDrv_USBSetIORetryCount_Port4(U8 u8Value);
230 void MDrv_GetUsbStorString_Port4(U8 uLun, U8 u8StrID, S8 *pStrBuf, U8 u8BufLen);
231 void MDrv_UsbSendTestPacket_Port4(void);
232 void MDrv_UsbSendSE0_Port4(void);
233 void MDrv_UsbSendTestJ_Port4(void);
234 void MDrv_UsbSendTestK_Port4(void);
235 U8 MDrv_GetUsbDevInterfaceClass_Port4(void);
236 
237 #define USB_NOT_RESPONSE		    0xff
238 #define USB_INTERFACE_CLASS_NONE 0
239 #define USB_INTERFACE_CLASS_MSD  0x08
240 #define USB_INTERFACE_CLASS_HUB  0x09
241 #define USB_INTERFACE_CLASS_IMAGE  0x06
242 #define USB_INTERFACE_CLASS_HID  0x03
243 
244 
245 //Chip ID deifinition
246 #define CHIPID_NEPTUNE     0x2
247 #define CHIPID_ERIS            0x3
248 #define CHIPID_TITANIA      0x4
249 #define CHIPID_PLUTO          0x5
250 #define CHIPID_TRITON        0x6
251 #define CHIPID_TITANIA2    0xB
252 #define CHIPID_TITANIA3    0xF
253 #define CHIPID_EUCLID        0x15
254 #define CHIPID_TITANIA4     0x18
255 #define CHIPID_TITANIA7     0x1C
256 #define CHIPID_TITANIA8     0x1F
257 #define CHIPID_TITANIA9     0x23
258 #define CHIPID_JANUS        0x1D
259 
260 // project code definition
261 #define     JUPITER                 0
262 #define     NEPTUNE                 1
263 #define     RAPHAEL                 2
264 #define     ERIS                    3
265 
266 #define 	NO_DEVICE               0
267 #define     USB11_DEVICE            1
268 #define 	USB20_DEVICE            2
269 #define	    BAD_DEVICE              3
270 #define     CONNECT_DEVICE          4
271 #define     POWER_SAVING            5
272 #define     WAIT_INIT               6
273 
274 #define USB_PORT_0          0
275 #define USB_PORT_2          1
276 #define USB_PORT_3          2
277 #define USB_PORT_4          3
278 
279 #define USB_STR_VENDOR              1
280 #define USB_STR_PRODUCT            2
281 
282 enum // for return value of MDrv_Usb_Device_Enum_EX()
283 {
284 DEVENUM_OK = 0,
285 DEVENUM_INPROGRESS,
286 DEVENUM_FAIL
287 };
288 #endif
289