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 //////////////////////////////////////////////////////////////////////////////// 79 // 80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 //////////////////////////////////////////////////////////////////////////////// 93 94 #ifndef _DRVMSPI_PRIV_H_ 95 #define _DRVMSPI_PRIV_H_ 96 97 //////////////////////////////////////////////////////////////////////////////// 98 /// @file drvMSPI_private.h 99 /// @author MStar Semiconductor Inc. 100 /// @brief Byte DMA control driver 101 //////////////////////////////////////////////////////////////////////////////// 102 103 //////////////////////////////////////////////////////////////////////////////// 104 // Header Files 105 //////////////////////////////////////////////////////////////////////////////// 106 #ifdef __cplusplus 107 extern "C" 108 { 109 #endif 110 111 #include "MsTypes.h" 112 #include "drvMSPI.h" 113 114 115 typedef MSPI_ErrorNo (*IOCTL_MSPI_Init_Ext)(MS_U8); 116 typedef MSPI_ErrorNo (*IOCTL_MSPI_Init)(MSPI_config*, MS_U8); 117 typedef MSPI_ErrorNo (*IOCTL_MSPI_Read)(MS_U8*, MS_U16); 118 typedef MSPI_ErrorNo (*IOCTL_MSPI_Write)(MS_U8*, MS_U16); 119 typedef MSPI_ErrorNo (*IOCTL_MSPI_DCConfig)(MSPI_DCConfig*); 120 typedef MSPI_ErrorNo (*IOCTL_MSPI_CLKConfig)(MSPI_CLKConfig*); 121 typedef MSPI_ErrorNo (*IOCTL_MSPI_FRAMEConfig)(MSPI_FrameConfig*); 122 typedef void (*IOCTL_MSPI_SlaveEnable)(MS_BOOL); 123 typedef MS_U32 (*IOCTL_MSPI_SetPowerState)(EN_POWER_MODE); 124 typedef MS_BOOL (*IOCTL_MSPI_SetDbgLevel)(MS_U8); 125 //============================================================================== 126 // NEW API for MSPI 127 //=============================================================================== 128 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_Init)(MSPI_config*, MS_U8); 129 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_Read)(MS_U32, MS_U8*, MS_U16); 130 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_Write)(MS_U32, MS_U8*, MS_U16); 131 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_DCConfig)(MS_U32, MSPI_DCConfig*); 132 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_CLKConfig)(MS_U32, MSPI_CLKConfig*); 133 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_FRAMEConfig)(MS_U32, MSPI_FrameConfig*); 134 typedef MSPI_ErrorNo (*IOCTL_MasterSPI_SlaveEnable)(MS_U32, MS_BOOL); 135 typedef MS_BOOL (*IOCTL_MasterSPI_CSPadConfig)(MS_U32, MS_U32); 136 typedef MS_BOOL (*IOCTL_MasterSPI_MaxClkConfig)(MS_U32, MS_U32); 137 138 typedef struct _MSPI_RESOURCE_PRIVATE 139 { 140 MS_U32 Dummy; 141 }MSPI_RESOURCE_PRIVATE; 142 143 typedef struct _MSPI_INSTANT_PRIVATE 144 { 145 IOCTL_MSPI_Init_Ext fpMSPI_Init_Ext; 146 IOCTL_MSPI_Init fpMSPI_Init; 147 IOCTL_MSPI_Read fpMSPI_Read; 148 IOCTL_MSPI_Write fpMSPI_Write; 149 IOCTL_MSPI_DCConfig fpMSPI_DCConfig; 150 IOCTL_MSPI_CLKConfig fpMSPI_CLKConfig; 151 IOCTL_MSPI_FRAMEConfig fpMSPI_FRAMEConfig; 152 IOCTL_MSPI_SlaveEnable fpMSPI_SlaveEnable; 153 IOCTL_MSPI_SetPowerState fpMSPI_SetPowerState; 154 IOCTL_MSPI_SetDbgLevel fpMSPI_SetDbgLevel; 155 IOCTL_MasterSPI_Init fpMasterSPI_Init; 156 IOCTL_MasterSPI_Read fpMasterSPI_Read; 157 IOCTL_MasterSPI_Write fpMasterSPI_Write; 158 IOCTL_MasterSPI_DCConfig fpMasterSPI_DCConfig; 159 IOCTL_MasterSPI_CLKConfig fpMasterSPI_CLKConfig; 160 IOCTL_MasterSPI_FRAMEConfig fpMasterSPI_FrameConfig; 161 IOCTL_MasterSPI_SlaveEnable fpMasterSPI_SlaveEnable; 162 IOCTL_MasterSPI_CSPadConfig fpMasterSPI_CsPadConfig; 163 IOCTL_MasterSPI_MaxClkConfig fpMasterSPI_MaxClkConfig; 164 }MSPI_INSTANT_PRIVATE; 165 166 void MSPIRegisterToUtopia(FUtopiaOpen ModuleType); 167 MS_U32 MSPIOpen(void** ppInstance, MS_U32 u32ModuleVersion, void* pAttribute); 168 MS_U32 MSPIClose(void* pInstance); 169 MS_U32 MSPIIoctl(void* pInstance, MS_U32 u32Cmd, void* pArgs); 170 #if (MSPI_UTOPIA20) 171 //------------------------------------------------------------------------------ 172 /// Description : Set detailed level of Parallel Flash driver debug message 173 /// @param u8DbgLevel \b IN debug level for Serial Flash driver 174 /// @return TRUE : succeed 175 /// @return FALSE : failed to set the debug level 176 //------------------------------------------------------------------------------ 177 MS_BOOL _MDrv_MSPI_SetDbgLevel(MS_U8 u8DbgLevel); 178 179 //------------------------------------------------------------------------------ 180 /// Description : MSPI Init 181 /// @param u8HwNum 182 /// @return TRUE : succeed 183 /// @return FALSE : failed to set the WP pin info 184 //------------------------------------------------------------------------------ 185 MSPI_ErrorNo _MDrv_MSPI_Init_Ext(MS_U8 u8HWNum); 186 187 //------------------------------------------------------------------------------ 188 /// Description : MSPI read data 189 /// @param pData 190 /// @param u16Size 191 /// @return TRUE : succeed 192 /// @return NULL : 193 //------------------------------------------------------------------------------ 194 MSPI_ErrorNo _MDrv_MSPI_Read(MS_U8 *pData, MS_U16 u16Size); 195 196 //------------------------------------------------------------------------------------------------- 197 /// Description : MSPI write data 198 /// @param pData 199 /// @param u16Size 200 /// @return TRUE : succeed 201 /// @return FALSE : unknown flash type 202 /// @note Not allowed in interrupt context 203 //------------------------------------------------------------------------------------------------- 204 MSPI_ErrorNo _MDrv_MSPI_Write(MS_U8 *pData, MS_U16 u16Size); 205 206 //------------------------------------------------------------------------------------------------- 207 /// Description : MSPI timing config 208 /// @param ptDCConfig \b IN: config MSPI timing 209 /// @return TRUE : succeed 210 /// @return FALSE : unknown flash size 211 /// @note Not allowed in interrupt context 212 //------------------------------------------------------------------------------------------------- 213 MSPI_ErrorNo _MDrv_MSPI_DCConfig(MSPI_DCConfig *ptDCConfig); 214 215 //------------------------------------------------------------------------------------------------- 216 /// Description : MSPI clock config 217 /// @param ptCLKConfig \b IN: clock config 218 /// @return TRUE : succeed 219 /// @return FALSE : not succeed 220 /// @note Please ref. sprc. to confirm Flash support or not 221 //------------------------------------------------------------------------------------------------- 222 MSPI_ErrorNo _MDrv_MSPI_CLKConfig(MSPI_CLKConfig *ptCLKConfig); 223 224 //------------------------------------------------------------------------------------------------- 225 /// Description : Config MSPI frame size 226 /// @param ptFrameConfig 227 /// @return TRUE : succeed 228 /// @return FALSE : not succeed 229 /// @note Please ref. sprc. to confirm Flash support or not. It is safty to run at 43M (Default). 230 //------------------------------------------------------------------------------------------------- 231 MSPI_ErrorNo _MDrv_MSPI_FRAMEConfig(MSPI_FrameConfig *ptFrameConfig); 232 //------------------------------------------------------------------------------------------------- 233 /// Description : set CS of MSPI 234 /// @param bEnable \b IN: set CS HIGH/LOW 235 /// @return TRUE : succeed 236 /// @return FALSE : not succeed 237 /// @note 238 //------------------------------------------------------------------------------------------------- 239 void _MDrv_MSPI_SlaveEnable(MS_BOOL bEnable); 240 241 //------------------------------------------------------------------------------------------------- 242 /// Description : Set MSPI power state 243 /// @param enPowerState \b IN: power state of MSPI 244 /// @return TRUE : succeed 245 /// @return FALSE : not succeed 246 //------------------------------------------------------------------------------------------------- 247 MS_BOOL _MDrv_MSPI_SetPowerState(EN_POWER_MODE enPowerState); 248 249 //------------------------------------------------------------------------------------------------- 250 /// Description : Set MSPI debug message level 251 /// @param u8DbgLevel /b IN: debug message level 252 /// @return TRUE : succeed 253 /// @return FALSE : illegal parameters 254 /// @note Not allowed in interrupt context 255 //------------------------------------------------------------------------------------------------- 256 MS_BOOL _MDrv_MSPI_SetDbgLevel(MS_U8 u8DbgLevevl); 257 258 //------------------------------------------------------------------------------------------------- 259 /// Description : MSPI Init 260 /// @param ptMSPIConfig \b IN: slave device config of mspi 261 /// @param u8HWNum \b IN: mspi ip number 262 /// @return error numbero of driver E_MSPI_OK : success \others fail 263 //------------------------------------------------------------------------------------------------- 264 MSPI_ErrorNo _MDrv_MasterSPI_Init(MSPI_config *ptMSPIConfig, MS_U8 u8HWNum); 265 266 //------------------------------------------------------------------------------------------------- 267 /// Description : MSPI READ DATA 268 /// @param u32DevID \b IN: device id of slave device 269 /// @param *pu8Data \b IN: pointer of buffer to get data 270 /// @param u16Size \b IN: size of read data 271 /// @return E_MSPI_OK : succeed 272 /// @return others: fail 273 /// @note Not allowed in interrupt context 274 //------------------------------------------------------------------------------------------------- 275 MSPI_ErrorNo _MDrv_MasterSPI_Read(MS_U32 u32DevID, MS_U8 *pu8Data, MS_U16 u16Size); 276 277 //------------------------------------------------------------------------------------------------- 278 /// Description : MSPI write data 279 /// @param u32DevID \b IN: device id of slave device 280 /// @param *pu8Data \b IN: pointer of buffer to send data 281 /// @param u16Size \b IN: size of write data 282 /// @return E_MSPI_OK : succeed 283 /// @return others : fail 284 /// @note Not allowed in interrupt context 285 //------------------------------------------------------------------------------------------------- 286 MSPI_ErrorNo _MDrv_MasterSPI_Write(MS_U32 u32DevID, MS_U8 *pu8Data, MS_U16 u16Size); 287 288 //------------------------------------------------------------------------------------------------- 289 /// Description : Set MSPI timming 290 /// @param u32DevID \b IN: device id of slave device 291 /// @param ptDCConfig \b IN: poniter of struct config slave timming 292 /// @return E_MSPI_OK : succeed 293 /// @return others: fail 294 /// @note Not allowed in interrupt context 295 //------------------------------------------------------------------------------------------------- 296 MSPI_ErrorNo _MDrv_MasterSPI_DCConfig(MS_U32 u32DevID, MSPI_DCConfig *ptDCConfig); 297 298 //------------------------------------------------------------------------------------------------- 299 /// Description : Set MSPI clock 300 /// @param u32DevID \b IN: device id of slave device 301 /// @param ptCLKConfig \b IN: pointer of struct to config mspi clock 302 /// @return E_MSPI_OK : success 303 /// @return others : fail 304 /// @note Not allowed in interrupt context 305 //------------------------------------------------------------------------------------------------- 306 MSPI_ErrorNo _MDrv_MasterSPI_CLKConfig(MS_U32 u32DevID, MSPI_CLKConfig *ptCLKConfig); 307 308 //------------------------------------------------------------------------------------------------- 309 /// Description : Set MSPI fram size 310 /// @param u32DevID \b IN: device id of slave device 311 /// @param ptFrameConfig \b IN: pointer of frame size 312 /// @return E_MSPI_OK : succeed 313 /// @return others: fail before timeout or illegal parameters 314 /// @note Not allowed in interrupt context 315 /// [NONOS_SUPPORT] 316 //------------------------------------------------------------------------------------------------- 317 MSPI_ErrorNo _MDrv_MasterSPI_FRAMEConfig(MS_U32 u32DevID, MSPI_FrameConfig *ptFrameConfig); 318 319 //------------------------------------------------------------------------------------------------- 320 /// Description : MSPI slave enable/disable 321 /// @param u32DevID \b IN: device id of slave id 322 /// @param bEnable \b IN: set CS high /low to enable /disable slave device 323 /// @return NONE 324 /// @note Not allowed in interrupt context 325 /// [NONOS_SUPPORT] 326 //------------------------------------------------------------------------------------------------- 327 MSPI_ErrorNo _MDrv_MasterSPI_SlaveEnable(MS_U32 u32DevID, MS_BOOL bEnable); 328 329 //------------------------------------------------------------------------------------------------- 330 /// Description : Set MSPI CS PAD number 331 /// @param u32DevID \b IN: slave device id of slave device 332 /// @param u32CsPad \b IN: pad number of cs pin 333 /// @return TRUE : succeed 334 /// @return FALSE : fail 335 /// @note Not allowed in interrupt context 336 //------------------------------------------------------------------------------------------------- 337 MS_BOOL _MDrv_MasterSPI_CsPadConfig(MS_U32 u32DevID, MS_U32 u32CsPad); 338 339 //------------------------------------------------------------------------------------------------- 340 /// Description : Set MSPI Slave Device Support Max Clock 341 /// @param u32DevID \b IN: slave device id of slave device 342 /// @param u32MaxCLk \b IN: max clock of slave device support 343 /// @return TRUE : succeed 344 /// @return FALSE : fail 345 /// @note Not allowed in interrupt contextb//------------------------------------------------------------------------------------------------- 346 MS_BOOL _MDrv_MasterSPI_MaxClkConfig(MS_U32 u32DevID, MS_U32 u32MaxClk); 347 348 #endif 349 350 #ifdef __cplusplus 351 } 352 #endif 353 #endif // _DRVBDMA_PRIV_H_ 354