xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvUSB_eCos.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 
81 #include "drvUsbcommon.h"
82 
83 //
84 // Function support
85 //
86 #define USBC_IP_SUPPORT 1 // over current detection support
87 
88 #define USB_IF_EHSET_SUPPORT 1 // embeded host hisg speed electrical test procedure
89 
90 #define USB_CDC_SUPPORT 0 // 1 to turn on cdc support
91 
92 #define USB_MASS_STORAGE_SUPPORT 1
93 
94 #define USB_HID_SUPPORT                     0
95 
96 //
97 // Extended Function support
98 //
99 
100 #define USB_SYSTEM_STR_SUPPORT
101 
102 //#define USB_NOT_SUPPORT_EX_HUB
103 
104 //
105 // Parameter definition
106 //
107 #define USBC_OVER_CURRENT 1
108 #define USBC_NON_OVER_CURRENT 2
109 
110 #define  USB_PLUG_IN	1
111 #define  USB_PLUG_OUT	2
112 
113 #define USB_EVENT_DEV_TYPE_UNKNOW    0
114 #define USB_EVENT_DEV_TYPE_STOR         1
115 #define USB_EVENT_DEV_TYPE_HID            2
116 #define USB_EVENT_DEV_TYPE_CDC          3
117 #define USB_EVENT_DEV_NO_RESPONSE          4
118 
119 #define USB_NOT_RESPONSE		 0xff
120 #define USB_INTERFACE_CLASS_NONE 0
121 #define USB_INTERFACE_CLASS_MSD  0x08
122 #define USB_INTERFACE_CLASS_HUB  0x09
123 #define USB_INTERFACE_CLASS_HID  0x03
124 
125 typedef void ( *USBCallback ) (MS_U8 u8Event, MS_U32 u32Para, char *s);
126 // for MDrv_USB_RegisterCallBack()
127 //u8Event: 1=plug, 2=unplug�K can extend later);
128 //u32Para: bit 0 ~ 3, device type (0: unknow, 1: Mass Storage, 2: HID)
129 //             bit 4 ~ 31, reserved
130 // for MDrv_OverCurrentDetect_RegisterCallBack()
131 //u8Event: 1=over current,�K can extend later);
132 //u32Para: port number
133 
134 extern USBCallback _DrvUSB_CBFun;
135 
136 void MDrv_OverCurrentDetect_RegisterCallBack (USBCallback pCallbackFn, MS_U8 port_mask);
137 void MDrv_USB_RegisterCallBack (USBCallback pCallbackFn);
138 
139 void MDrv_Usb_Init(
140     mem_Alloc     pfn_Cachedmem_Alloc,
141     mem_Free      pfn_Cachedmem_Free,
142     mem_Alloc     pfn_NonCachedmem_Alloc,
143     mem_Free      pfn_NonCachedmem_Free,
144     mem_VA2PA     pfn_mem_VA2PA,
145     mem_PA2VA     pfn_mem_PA2VA,
146     mem_Cached2Noncached pfn_mem_Cached2Noncached,
147     mem_NonCached2Cached pfn_mem_NonCached2Cached
148 );
149 MS_BOOL MDrv_USB_Port_Init(MS_U8 u8Hostid);
150 void MDrv_UsbClose(void);
151 int MDrv_UsbDeviceConnectBitEx(MS_U8 u8Hostid);
152 MS_BOOL MDrv_USB_Port_Close(MS_U8 u8Hostid);
153 #ifdef USB_SYSTEM_STR_SUPPORT
154 void MDrv_Usb_STR_Off(MS_U8 u8Hostid);
155 void MDrv_Usb_STR_On(MS_U8 u8Hostid);
156 #endif
157 
158 /* Mass Storage class API */
159 MS_BOOL MDrv_UsbBlockReadToMIU(MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr);
160 MS_BOOL MDrv_UsbBlockWriteFromMIU(MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr);
161 MS_BOOL MDrv_UsbBlockReadToMIUEx(MS_U8 uPort,MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr);
162 MS_BOOL MDrv_UsbBlockWriteFromMIUEx(MS_U8 uPort,MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr);
163 MS_U32 MDrv_GetUsbBlockSize(MS_U8 lun);
164 MS_U32 MDrv_GetUsbBlockSizeEx(MS_U8 uPort, MS_U8 lun);
165 MS_U32 MDrv_GetUsbBlockNumEx(MS_U8 uPort, MS_U8 lun);
166 MS_U32 MDrv_GetUsbBlockNum(MS_U8 lun);
167 MS_U8 MDrv_UsbGetMaxLUNCount(void);
168 MS_U8 MDrv_UsbGetMaxLUNCountEx(MS_U8 uPort);
169 MS_BOOL MDrv_UsbIsLunConnected(MS_U8 uPort, MS_U8 lun);
170 
171 MS_BOOL ChkUsbReady(void); // Obsolete
172 MS_BOOL ChkUsbReadyEx(MS_U8 uPort); // Obsolete
173 
174 /* Lookup USB information by disk path */
175 MS_U8 MDrv_USB_MscLookupHostID(char *str);
176 char *MDrv_USB_MscLookupManufacturerString(char *str);
177 char *MDrv_USB_MscLookupProductString(char *str);
178 char *MDrv_USB_MscLookupSerialNumberString(char *str);
179 MS_U32 MDrv_USB_MscLookupVidPid(char *str);
180 #endif
181 
182