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 __USBCOMMON_H 79 #define __USBCOMMON_H 80 81 #include "asmCPU.h" // ASSERT debug 82 83 typedef void* (*mem_Alloc)(int size); 84 typedef void (*mem_Free)(void* pBuf); 85 typedef MS_U32 (*mem_VA2PA)(MS_U32 addr); 86 typedef MS_U32 (*mem_PA2VA)(MS_U32 addr, int bCached); 87 typedef void* (*mem_Cached2Noncached)(MS_U32 addr); 88 typedef void* (*mem_NonCached2Cached)(MS_U32 addr); 89 90 91 extern mem_Alloc pfnAllocCachedMem, pfnAllocNoncachedMem; 92 extern mem_Free pfnFreeCachedMem, pfnFreeNoncachedMem; 93 extern mem_VA2PA pfnVA2PA; 94 extern mem_PA2VA pfnPA2VA; 95 extern mem_Cached2Noncached pfnCached2Noncached; 96 extern mem_NonCached2Cached pfnNoncached2Cached; 97 98 #if 1 // eCos lib 99 #define Usb_AllocateNonCachedMemory(x) pfnAllocNoncachedMem(x) 100 #define Usb_FreeNonCachedMemory(x) pfnFreeNoncachedMem(x) 101 #define Usb_AllocateCachedMemory(x) pfnAllocCachedMem(x) 102 #define Usb_FreeCachedMemory(x) pfnFreeCachedMem(x) 103 104 105 //extern void* (*kmalloc)(int size, int flag); 106 //extern void (*kfree)(void* pBuf); 107 #define kmalloc(size, flag) pfnAllocCachedMem(size) 108 #define kfree(pBuf) pfnFreeCachedMem(pBuf) 109 110 #define USB_VA2PA(addr) pfnVA2PA(addr) 111 #else 112 #define Usb_AllocateNonCachedMemory(x) kmalloc(x, 0) 113 #define Usb_FreeNonCachedMemory(x) kfree(x) 114 #define Usb_AllocateCachedMemory(x) kmalloc(x, 0) 115 #define Usb_FreeCachedMemory(x) kfree(x) 116 #endif 117 118 #if 1 // eCos lib 119 #define KSEG02KSEG1(addr) pfnCached2Noncached((MS_U32)addr) //cached -> unchched, 20111017 for K2 120 #define KSEG12KSEG0(addr) pfnNoncached2Cached((MS_U32)addr) //unchched -> cached 121 #else 122 #define KSEG02KSEG1(addr) ((void *)((MS_U32)(addr)|0x20000000)) //cached -> unchched 123 #define KSEG12KSEG0(addr) ((void *)((MS_U32)(addr)&~0x20000000)) //unchched -> cached 124 #endif 125 126 #ifndef U32 127 #define U32 MS_U32 128 #endif 129 130 #ifndef U16 131 #define U16 MS_U16 132 #endif 133 134 #ifndef U8 135 #define U8 MS_U8 136 #endif 137 138 #ifndef S32 139 #define S32 MS_S32 140 #endif 141 142 #ifndef S16 143 #define S16 MS_S16 144 #endif 145 146 #ifndef S8 147 #define S8 MS_S8 148 #endif 149 150 #ifndef __u32 151 #define __u32 MS_U32 152 #endif 153 154 #ifndef __u16 155 #define __u16 MS_U16 156 #endif 157 158 #ifndef __u8 159 #define __u8 MS_U8 160 #endif 161 162 #ifndef __s32 163 #define __s32 MS_S32 164 #endif 165 166 #ifndef __s16 167 #define __s16 MS_S16 168 #endif 169 170 #ifndef __s8 171 #define __s8 MS_S8 172 #endif 173 174 #ifndef BOOL 175 #define BOOL MS_BOOL 176 #endif 177 178 #ifndef BOOLEAN 179 #define BOOLEAN MS_BOOL 180 #endif 181 182 #ifdef MS_DEBUG 183 #define ASSERT(_bool_) \ 184 { \ 185 if ( ! ( _bool_ ) ) \ 186 { \ 187 diag_printf("ASSERT FAIL: %s, %s %s %d\n", #_bool_, __FILE__, __PRETTY_FUNCTION__, __LINE__);\ 188 MAsm_CPU_SwDbgBp(); \ 189 } \ 190 } 191 #else 192 #define ASSERT(_bool_) MS_ASSERT(_bool_) 193 #endif 194 195 196 //Chip ID deifinition 197 #define CHIPID_NEPTUNE 0x2 198 #define CHIPID_ERIS 0x3 199 #define CHIPID_TITANIA 0x4 200 #define CHIPID_PLUTO 0x5 201 #define CHIPID_TRITON 0x6 202 #define CHIPID_TITANIA2 0xB 203 #define CHIPID_TITANIA3 0xF 204 #define CHIPID_EUCLID 0x15 205 #define CHIPID_TITANIA4 0x18 206 #define CHIPID_URANUS4 0x1B 207 #define CHIPID_TITANIA7 0x1C 208 #define CHIPID_JANUS 0x1D 209 #define CHIPID_TITANIA8 0x1F 210 #define CHIPID_TITANIA9 0x23 211 #define CHIPID_KRONUS 0x2F 212 #define CHIPID_KAISERIN 0x41 213 #define CHIPID_KAPPA 0x75 214 #define CHIPID_KELTIC 0x72 215 #define CHIPID_KENYA 0x7C 216 #define CHIPID_KRITI 0x87 217 #define CHIPID_KAISER 0x56 218 #define CHIPID_KERES 0x7E 219 #define CHIPID_KIRIN 0x98 220 #define CHIPID_KRIS 0x8B 221 #define CHIPID_KRATOS 0x9F 222 #define CHIPID_KIWI 0xA7 223 #define CHIPID_CLIPPERS 0x7F 224 #define CHIPID_KAYLA 0xB1 225 #define CHIPID_KANO 0x92 226 #define CHIPID_K6 0xA8 227 #define CHIPID_CURRY 0xB2 228 #define CHIPID_K6LITE 0xBE 229 #define CHIPID_K5TN 0xC1 230 231 232 #if defined(CHIP_U4) 233 #define USB_LIB_CHIPID CHIPID_URANUS4 234 #elif defined(CHIP_K1) 235 #define USB_LIB_CHIPID CHIPID_KRONUS 236 #elif defined(CHIP_K2) 237 #define USB_LIB_CHIPID CHIPID_KAISERIN 238 #elif defined(CHIP_KAPPA) 239 #define USB_LIB_CHIPID CHIPID_KAPPA 240 #elif defined(CHIP_KELTIC) 241 #define USB_LIB_CHIPID CHIPID_KELTIC 242 #elif defined(CHIP_KENYA) 243 #define USB_LIB_CHIPID CHIPID_KENYA 244 #elif defined(CHIP_KRITI) 245 #define USB_LIB_CHIPID CHIPID_KRITI 246 #elif defined(CHIP_KRATOS) 247 #define USB_LIB_CHIPID CHIPID_KRATOS 248 #elif defined(CHIP_KAISER) 249 #define USB_LIB_CHIPID CHIPID_KAISER 250 #elif defined(CHIP_KERES) 251 #define USB_LIB_CHIPID CHIPID_KERES 252 #elif defined(CHIP_KIRIN) 253 #define USB_LIB_CHIPID CHIPID_KIRIN 254 #elif defined(CHIP_KRIS) 255 #define USB_LIB_CHIPID CHIPID_KRIS 256 #elif defined(CHIP_KIWI) 257 #define USB_LIB_CHIPID CHIPID_KIWI 258 #elif defined(CHIP_CLIPPERS) 259 #define USB_LIB_CHIPID CHIPID_CLIPPERS 260 #elif defined(CHIP_KAYLA) 261 #define USB_LIB_CHIPID CHIPID_KAYLA 262 #elif defined(CHIP_KANO) 263 #define USB_LIB_CHIPID CHIPID_KANO 264 #elif defined(CHIP_K6) 265 #define USB_LIB_CHIPID CHIPID_K6 266 #elif defined(CHIP_CURRY) 267 #define USB_LIB_CHIPID CHIPID_CURRY 268 #elif defined(CHIP_K6LITE) 269 #define USB_LIB_CHIPID CHIPID_K6LITE 270 #elif defined(CHIP_K5TN) 271 #define USB_LIB_CHIPID CHIPID_K5TN 272 #else 273 #error No USB Driver Supported 274 #endif 275 276 #endif 277 278