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 87 88 #define USB_IF_EHSET_SUPPORT 1 // embeded host hisg speed electrical test procedure 89 90 #ifdef MS_NOSAPI 91 #define USB_CDC_SUPPORT 0 // don't support cdc in non-os case in this stage 92 #else 93 #define USB_CDC_SUPPORT 0 // 1 to turn on cdc support 94 #endif 95 96 #define USB_MASS_STORAGE_SUPPORT 1 97 98 #define USB_HID_SUPPORT 0 99 100 // 101 // Parameter definition 102 // 103 #define USBC_OVER_CURRENT 1 104 #define USBC_NON_OVER_CURRENT 2 105 106 #define USB_PLUG_IN 1 107 #define USB_PLUG_OUT 2 108 109 #define USB_EVENT_DEV_TYPE_UNKNOW 0 110 #define USB_EVENT_DEV_TYPE_STOR 1 111 #define USB_EVENT_DEV_TYPE_HID 2 112 #define USB_EVENT_DEV_TYPE_CDC 3 113 114 #define USB_NOT_RESPONSE 0xff 115 #define USB_INTERFACE_CLASS_NONE 0 116 #define USB_INTERFACE_CLASS_MSD 0x08 117 #define USB_INTERFACE_CLASS_HUB 0x09 118 #define USB_INTERFACE_CLASS_HID 0x03 119 120 //----------------------------------------- 121 // U4_series_usb_init flag: 122 // Use low word as flag 123 #define EHCFLAG_NONE 0x0 124 #define EHCFLAG_DPDM_SWAP 0x1 125 #define EHCFLAG_TESTPKG 0x2 126 #define EHCFLAG_DOUBLE_DATARATE 0x4 127 // Use high word as data 128 #define EHCFLAG_DDR_MASK 0xF0000000 129 #define EHCFLAG_DDR_x15 0x10000000 //480MHz x1.5 130 #define EHCFLAG_DDR_x18 0x20000000 //480MHz x1.8 131 //----------------------------------------- 132 133 #define HUB_STACK_SIZE 0x2000 134 135 typedef void ( *USBCallback ) (MS_U8 u8Event, MS_U32 u32Para, char *s); 136 // for MDrv_USB_RegisterCallBack() 137 //u8Event: 1=plug, 2=unplug�K can extend later); 138 //u32Para: bit 0 ~ 3, device type (0: unknow, 1: Mass Storage, 2: HID) 139 // bit 4 ~ 31, reserved 140 // for MDrv_OverCurrentDetect_RegisterCallBack() 141 //u8Event: 1=over current,�K can extend later); 142 //u32Para: port number 143 144 extern USBCallback _DrvUSB_CBFun; 145 146 void MDrv_OverCurrentDetect_RegisterCallBack (USBCallback pCallbackFn, MS_U8 port_mask); 147 void MDrv_USB_RegisterCallBack (USBCallback pCallbackFn); 148 MS_BOOL MDrv_UsbBlockReadToMIU(MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr); 149 MS_BOOL MDrv_UsbBlockWriteFromMIU(MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr); 150 MS_BOOL MDrv_UsbBlockReadToMIUEx(MS_U8 uPort,MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr); 151 MS_BOOL MDrv_UsbBlockWriteFromMIUEx(MS_U8 uPort,MS_U8 lun, MS_U32 u32BlockAddr, MS_U32 u32BlockNum, MS_U32 u32MIUAddr); 152 153 //MS_BOOL MDrv_UsbDeviceConnect(struct usb_hcd *hcd); 154 //void MDrv_Usb_Init(void); 155 void MDrv_Usb_Init( 156 mem_Alloc pfn_Cachedmem_Alloc, 157 mem_Free pfn_Cachedmem_Free, 158 mem_Alloc pfn_NonCachedmem_Alloc, 159 mem_Free pfn_NonCachedmem_Free, 160 mem_VA2PA pfn_mem_VA2PA, 161 mem_PA2VA pfn_mem_PA2VA, 162 mem_Cached2Noncached pfn_mem_Cached2Noncached, 163 mem_NonCached2Cached pfn_mem_NonCached2Cached 164 ); 165 MS_BOOL MDrv_USB_Port_Init(MS_U8 u8PortNum); 166 void MDrv_UsbClose(void); 167 MS_U32 MDrv_GetUsbBlockSize(MS_U8 lun); 168 MS_U32 MDrv_GetUsbBlockSizeEx(MS_U8 uPort, MS_U8 lun); 169 MS_U32 MDrv_GetUsbBlockNumEx(MS_U8 uPort, MS_U8 lun); 170 171 MS_U32 MDrv_GetUsbBlockNum(MS_U8 lun); 172 MS_U8 MDrv_UsbGetMaxLUNCount(void); 173 MS_U8 MDrv_UsbGetMaxLUNCountEx(MS_U8 uPort); 174 MS_U8 MDrv_GET_MASS_VALID_LUN(void); 175 MS_BOOL ChkUsbReady(void); 176 MS_BOOL ChkUsbReadyEx(MS_U8 uPort); 177 MS_BOOL MDrv_UsbIsLunConnected(MS_U8 uPort, MS_U8 lun); 178 MS_U8 MDrv_USB_MscLookupHostID(char *str); 179 char *MDrv_USB_MscLookupProductString(char *str); 180 #endif //#ifndef _DRVUART_H 181 182