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 // $Workfile: PCMCIA.h $ 81 // 82 // Author/Copyright Gero Kuehn / GkWare e.K. 83 // Humboldtstrasse 177 84 // 45149 Essen 85 // GERMANY 86 // Tel: +49 174 520 8026 87 // Email: support@gkware.com 88 // Web: http://www.gkware.com 89 // 90 // $Date: $ 91 // $Revision: $ 92 // 93 // ******************************************************** 94 // 95 // @file PCMCIA.h 96 // @brief This file contains the API of the PCMCIA CIS parser and the declaration 97 // for the PCMCIA driver API. PCMCIA drivers are expected to implement the functions starting with PCMCIA_ except for MDrv_PCMCIA_ReadAttribMem(), 98 // The MDrv_PCMCIA_ReadAttribMem() implementation is provided together with the GkWare CI Stack 99 100 /////////////////////////////////////////////////////////////////////////////// 101 /// 102 /// @file drvPCMCIA.h 103 /// @brief PCMCIA Driver Interface 104 /// @author MStar Semiconductor Inc. 105 /////////////////////////////////////////////////////////////////////////////// 106 107 //------------------------------------------------- 108 /*! \defgroup PCMCIA PCMCIA interface 109 \ingroup PCMCIA 110 111 \brief 112 113 PCMCIA I/O interface (EN50221) 114 115 <b> Operation Code Flow: </b> \n 116 \image html pcmcia.png 117 118 *! \defgroup PCMCIA_General PCMCIA general functions 119 * \ingroup PCMCIA 120 121 *! \defgroup PCMCIA_Task PCMCIA process related functions 122 * \ingroup PCMCIA 123 124 *! \defgroup PCMCIA_INT PCMCIA interrupt functions 125 * \ingroup PCMCIA 126 127 *! \defgroup PCMCIA_AttributeMem PCMCIA Attribute memory related functions. 128 * \ingroup PCMCIA 129 130 *! \defgroup PCMCIA_IOMem PCMCIA IO memory related functions. 131 * \ingroup PCMCIA 132 133 *! \defgroup PCMCIA_STR PCMCIA STR functions 134 * \ingroup PCMCIA 135 136 *! \defgroup PCMCIA_ToBeModified PCMCIA api to be modified 137 * \ingroup PCMCIA 138 139 *! \defgroup PCMCIA_ToBeRemove PCMCIA api to be removed 140 * \ingroup PCMCIA 141 */ 142 //------------------------------------------------- 143 144 #ifndef _DRV_PCMCIA_H_ 145 #define _DRV_PCMCIA_H_ 146 147 #include "MsTypes.h" 148 #include "MsDevice.h" 149 150 #include "ULog.h" 151 //----------------------------------------------------------------------------- 152 // Macro and Define 153 //----------------------------------------------------------------------------- 154 // PCMCIA 155 #define MAX_PCMCIA_CONFIGS 6 //!< The maximum number of configurations supported by a PCMCIA card 156 #define MAX_PCMCIA_STRLEN (64) //!< The maximum name of vendor/manufacturer/info strings 157 #define MAX_CIS_SIZE 0x100 //!< The maximum size of a CIS, that is understood by this driver 158 #define PCMCIA_HW_TIMEOUT 3000 159 #define PCMCIA_IRQ_ENABLE 1 160 161 // IRQ_force status bits 162 #define PCMCIA_MEM_READY (0x04) //The same pin as IRQ in I/O mode 163 164 // Command Interface Hardware Registers 165 #define PCMCIA_PHYS_REG_DATA (0) 166 #define PCMCIA_PHYS_REG_COMMANDSTATUS (1) 167 #define PCMCIA_PHYS_REG_SIZELOW (2) 168 #define PCMCIA_PHYS_REG_SIZEHIGH (3) 169 170 // Status Register Bits 171 #define PCMCIA_STATUS_DATAAVAILABLE (0x80) //!< PCMCIA Status Register Bit - The module wants to send data 172 #define PCMCIA_STATUS_FREE (0x40) //!< PCMCIA Status Register Bit - The module can accept data 173 #define PCMCIA_STATUS_IIR (0x10) //!< PCMCIA Status Register Bit - IIR 174 #define PCMCIA_STATUS_RESERVEDBITS (0x2C) //!< PCMCIA Status Register Bits - reserved 175 #define PCMCIA_STATUS_WRITEERROR (0x02) //!< PCMCIA Status Register Bit - Write error 176 #define PCMCIA_STATUS_READERROR (0x01) //!< PCMCIA Status Register Bit - Read error 177 178 // Command Register Bits 179 #define PCMCIA_COMMAND_DAIE (0x80) //!< PCMCIA Command register bit - DAIE 180 // when this bit is set, the module asserts IREQ# each time it has data to send 181 #define PCMCIA_COMMAND_FRIE (0x40) //!< PCMCIA Command register bit - FRIE 182 // when this bit is set, the module asserts IREQ# each time it is free to receive data 183 #define PCMCIA_COMMAND_RESERVEDBITS (0x30) //!< PCMCIA Command register bits - reserved 184 #define PCMCIA_COMMAND_RESET (0x08) //!< PCMCIA Command register bit - Reset 185 #define PCMCIA_COMMAND_SIZEREAD (0x04) //!< PCMCIA Command register bit - Size read 186 #define PCMCIA_COMMAND_SIZEWRITE (0x02) //!< PCMCIA Command register bit - Size Write 187 #define PCMCIA_COMMAND_HOSTCONTROL (0x01) //!< PCMCIA Command register bit - Host control 188 189 #define PCMCIAINFO_MANID_VALID (0x00000001) 190 #define PCMCIAINFO_VERS1_VALID (0x00000002) 191 #define PCMCIAINFO_FUNCID_VALID (0x00000004) 192 193 #ifdef __cplusplus 194 extern "C" { 195 #endif 196 197 //////////////////////////////////////////////////////////////////////////////// 198 // Constant & Macro Definition 199 //////////////////////////////////////////////////////////////////////////////// 200 /// Version string. 201 #define MSIF_PCMCIA_LIB_CODE {'P','C','M','_'} //Lib code 202 #define MSIF_PCMCIA_LIBVER {'0','1'} //LIB version 203 #define MSIF_PCMCIA_BUILDNUM {'0','1'} //Build Number 204 #define MSIF_PCMCIA_CHANGELIST {'0','0','2','5','8','4','9','3'} //P4 ChangeList Number 205 206 #define PCMCIA_DRV_VERSION /* Character String for DRV/API version */ \ 207 MSIF_TAG, /* 'MSIF' */ \ 208 MSIF_CLASS, /* '00' */ \ 209 MSIF_CUS, /* 0x0000 */ \ 210 MSIF_MOD, /* 0x0000 */ \ 211 MSIF_CHIP, \ 212 MSIF_CPU, \ 213 MSIF_PCMCIA_LIB_CODE, /* IP */ \ 214 MSIF_PCMCIA_LIBVER, /* 00 ~ 99 */ \ 215 MSIF_PCMCIA_BUILDNUM, /* 00 ~ 99 */ \ 216 MSIF_PCMCIA_CHANGELIST, /* CL# */ \ 217 MSIF_OS 218 219 typedef void (*IsrCallback)( void* wparam, void* lparam ); 220 221 //----------------------------------------------------------------------------- 222 // Enums 223 //----------------------------------------------------------------------------- 224 //! This enum contains the card types, that can be encoded in CISTPL_FUNCID (0x21) 225 typedef enum { 226 E_PCMCIA_FUNC_CUSTOM = 0, 227 E_PCMCIA_FUNC_MEMORY = 1, 228 E_PCMCIA_FUNC_SERIAL = 2, 229 E_PCMCIA_FUNC_PARALLEL = 3, 230 E_PCMCIA_FUNC_DRIVE = 4, 231 E_PCMCIA_FUNC_VIDEO = 5, 232 E_PCMCIA_FUNC_NETWORK = 6, 233 E_PCMCIA_FUNC_AIMS = 7, 234 E_PCMCIA_FUNC_SCSI = 8, 235 E_PCMCIA_FUNC_CARDBUS = 9, 236 E_PCMCIA_FUNC_MANUFACTURER = 0xFF // manifacturer designed purpose 237 } PCMCIA_FUNCTYPE; 238 239 typedef enum { 240 E_PCMCIA_MODULE_A = 0, 241 E_PCMCIA_MODULE_B = 1, 242 E_PCMCIA_MODULE_MAX = 2 243 } PCMCIA_MODULE; 244 245 //----------------------------------------------------------------------------- 246 // Structures 247 //----------------------------------------------------------------------------- 248 //! This structure contains information about exactly one possible PCMCIA card configuration. 249 typedef struct /* 13 Bytes */ 250 { 251 MS_U32 dwEAAddr; //!< EA-address 252 MS_U32 dwEALen; //!< size of the EA area (zero for none) 253 MS_U16 wIRQData; //!< supported IRQ number mask 254 MS_U8 bConfigIndex; //!< cor //!< The value of bConfigIndex has to be written into the card configuration register to activate this configuration. 255 MS_U8 bIRQDesc1; //!< Interrupt descriptor byte 256 MS_U8 fCITagsPresent; //!< Bitfield which is 0x03 if both required CI tags are present. 0x01 for DVB_HOST, 0x02 for DVB_CI_MODULE 257 } PCMCIA_CONFIG; 258 259 //! This structure provides simple access to the PCMCIA card information 260 //! after decoding of the Card Information Structure. This decoding is performed by MDrv_CI_PCMCIA_ReadAttribMem() 261 typedef struct 262 { 263 MS_U32 ConfigOffset; //!< Offset of the Configuration byte in the Attribute Memory 264 MS_U32 dwValidFlags; //!< Bitmask that defines which of the other fields are valid 265 MS_U16 wManufacturerId; //!< 16Bit Manufacturer ID (PCMCIAINFO_MANID_VALID) 266 MS_U16 wCardID; //!< 16Bit Card ID (PCMCIAINFO_MANID_VALID) 267 268 /* 99 Bytes */ 269 MS_U16 wPCMCIAStdRev; //!< PCMCIA Standard version supported by the card (PCMCIAINFO_VERS1_VALID) 270 MS_U8 pszManufacturerName[MAX_PCMCIA_STRLEN]; //!< Name of the card manufacturer (PCMCIAINFO_VERS1_VALID) 271 MS_U8 pszProductName[MAX_PCMCIA_STRLEN]; //!< Product name (PCMCIAINFO_VERS1_VALID) 272 MS_U8 pszProductInfo1[MAX_PCMCIA_STRLEN]; //!< (PCMCIAINFO_VERS1_VALID) 273 MS_U8 pszProductInfo2[MAX_PCMCIA_STRLEN]; //!< (PCMCIAINFO_VERS1_VALID) 274 MS_U8 bCI_PLUS; //!< PCMCIA card CI Plus Compatibility Identification 275 276 PCMCIA_FUNCTYPE FuncType; //!< Card function type (PCMCIAINFO_FUNCID_VALID) 277 MS_U8 bFuncIDSysInfo; //!< SysInitByte from the FuncID block (PCMCIAINFO_FUNCID_VALID) 278 279 MS_U8 bINT; //!< PCMCIA card Support interrupt or not 280 MS_U8 bNumConfigs; 281 /* 13 * MAX_PCMCIA_CONFIGS(=10) = 130 Bytes*/ //!< The number of configurations supported by the card. Exactly bNumConfigs entries are valid in the Config array. 282 PCMCIA_CONFIG Config[MAX_PCMCIA_CONFIGS]; //!< The array of possible card configurations 283 } PCMCIA_INFO; 284 285 //! This structure provides ISR data for upper layer 286 //! DO NOT change the current data member 287 //! Only allow to add new member in the tail of the structure 288 typedef struct { 289 MS_BOOL bISRCardInsert; 290 MS_BOOL bISRCardRemove; 291 MS_BOOL bISRCardData; 292 } PCMCIA_ISR; 293 294 //! This file typedefs PCMCIA_HANDLE as void*. 295 //! Actual PCMCIA driver implementations can hide whatever they want inside this handle. 296 //! Higher level drivers pass 297 typedef void *PCMCIA_HANDLE; 298 299 //----------------------------------------------------------------------------- 300 // Global Variables 301 //----------------------------------------------------------------------------- 302 303 //----------------------------------------------------------------------------- 304 // Global Functions 305 //----------------------------------------------------------------------------- 306 // PCMCIA 307 308 // revision history 309 // V2 310 // for multiple PCMCIA slot support 311 // 312 313 //----------------- 314 // PCMCIA_General 315 //----------------- 316 //------------------------------------------------------------------------------------------------- 317 /// Initialize PCMCIA module. 318 /// @ingroup PCMCIA_General 319 /// @param bCD_Reverse \b IN: Set TRUE:High active, FALSE: Low active 320 /// @return None 321 //------------------------------------------------------------------------------------------------- 322 void MDrv_PCMCIA_Init(MS_BOOL bCD_Reverse); 323 //------------------------------------------------------------------------------------------------- 324 /// Get PCMCIA initial parameter. 325 /// @ingroup PCMCIA_General 326 /// @param pointer to bCD_Reverse \b IN: Set TRUE:High active, FALSE: Low active 327 /// @return TRUE : Succeed 328 /// @return FALSE : Fail 329 //------------------------------------------------------------------------------------------------- 330 MS_BOOL MDrv_PCMCIA_GetConfig(MS_BOOL* bCD_Reverse); 331 //----------------- 332 // PCMCIA_STR 333 //----------------- 334 //------------------------------------------------------------------------------------------------- 335 /// Control PCMCIA STR functions. 336 /// @ingroup PCMCIA_STR 337 /// @param u16PowerState \b IN: STR power mode. (to control STR suspend & resume case.) 338 /// @return : Utopia status - UTOPIA_STATUS_SUCCESS (Succeed) or UTOPIA_STATUS_FAIL (Fail) 339 //------------------------------------------------------------------------------------------------- 340 MS_U32 MDrv_PCMCIA_SetPowerState(EN_POWER_MODE u16PowerState); 341 //----------------- 342 // PCMCIA_ToBeRemove 343 //----------------- 344 //------------------------------------------------------------------------------------------------- 345 /// Check CI CAM is detect or not. (Still call MDrv_PCMCIA_DetectV2) 346 /// @ingroup PCMCIA_ToBeRemove 347 /// @param eModule \b IN: CAM module. 348 /// @return TRUE : Succeed - CAM detect 349 /// @return FALSE : Fail - CAM not detect 350 //------------------------------------------------------------------------------------------------- 351 MS_BOOL MDrv_PCMCIA_PollingV2( PCMCIA_MODULE eModule ); 352 //----------------- 353 // PCMCIA_Task 354 //----------------- 355 //------------------------------------------------------------------------------------------------- 356 /// Check CI CAM is detect or not. 357 /// @ingroup PCMCIA_Task 358 /// @param eModule \b IN: CAM module. 359 /// @return TRUE : Succeed - CAM detect 360 /// @return FALSE : Fail - CAM not detect 361 //------------------------------------------------------------------------------------------------- 362 MS_BOOL MDrv_PCMCIA_DetectV2( PCMCIA_MODULE eModule ); 363 //------------------------------------------------------------------------------------------------- 364 /// Set reset HW duration. 365 /// @ingroup PCMCIA_Task 366 /// @param u8HW_ResetDuration \b IN: Duration. 367 /// @return None 368 //------------------------------------------------------------------------------------------------- 369 void MDrv_PCMCIA_Set_HW_ResetDuration( MS_U8 u8HW_ResetDuration ); 370 //------------------------------------------------------------------------------------------------- 371 /// Reset PCMCIA HW 372 /// @ingroup PCMCIA_Task 373 /// @param eModule \b IN: CAM module. 374 /// @return None 375 //------------------------------------------------------------------------------------------------- 376 void MDrv_PCMCIA_ResetHW_V2( PCMCIA_MODULE eModule ); 377 //----------------- 378 // PCMCIA_AttributeMem 379 //----------------- 380 //------------------------------------------------------------------------------------------------- 381 /// Copy data from attribute memory. 382 /// @ingroup PCMCIA_AttributeMem 383 /// @param eModule \b IN: CAM module. 384 /// @param u16Addr \b IN: Read address. 385 /// @param pDest \b OUT: Copyed buffer. 386 /// @return None 387 //------------------------------------------------------------------------------------------------- 388 void MDrv_PCMCIA_ReadAttribMemV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 *pDest ); 389 //------------------------------------------------------------------------------------------------- 390 /// Parse attribute memory data into an easily readable PCMCIA_INFO structure. 391 /// @ingroup PCMCIA_AttributeMem 392 /// @param pAttribMem \b IN: Attribute memory buffer. 393 /// @param dwLen \b IN: Data length. 394 /// @param pInfo \b OUT: PCMCIA information. 395 /// @return None 396 //------------------------------------------------------------------------------------------------- 397 void MDrv_PCMCIA_ParseAttribMem( MS_U8 *pAttribMem, MS_U16 dwLen, PCMCIA_INFO *pInfo ); 398 //------------------------------------------------------------------------------------------------- 399 /// Write data to attribute memory. 400 /// @ingroup PCMCIA_AttributeMem 401 /// @param eModule \b IN: CAM module. 402 /// @param wAddr \b IN: Write address. 403 /// @param bData \b IN: Write data. 404 /// @return None 405 //------------------------------------------------------------------------------------------------- 406 void MDrv_PCMCIA_WriteAttribMemV2( PCMCIA_MODULE eModule, MS_U16 wAddr, MS_U8 bData ); 407 //------------------------------------------------------------------------------------------------- 408 /// Write data to IO memory. (Only write 1 byte) 409 /// @ingroup PCMCIA_IOMem 410 /// @param eModule \b IN: CAM module. 411 /// @param wAddr \b IN: Write address. 412 /// @param bData \b IN: Write data. 413 /// @return None 414 //------------------------------------------------------------------------------------------------- 415 void MDrv_PCMCIA_WriteIOMemV2( PCMCIA_MODULE eModule, MS_U16 wAddr, MS_U8 bData ); 416 //------------------------------------------------------------------------------------------------- 417 /// Write data to IO memory. (Write long size data to the IO memory) 418 /// @ingroup PCMCIA_ToBeModified 419 /// @param eModule \b IN: CAM module. 420 /// @param u16Addr \b IN: Write address. 421 /// @param u8Value \b IN: Write data. (Not used? It's use for 1 byte write) 422 /// @param u16DataLen \b IN: Write length. 423 /// @param u8pWriteBuffer \b IN: Write buffer. 424 /// @return None 425 //------------------------------------------------------------------------------------------------- 426 void MDrv_PCMCIA_WriteIOMemLongV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 u8Value, MS_U16 u16DataLen, MS_U8* u8pWriteBuffer); 427 //----------------- 428 // PCMCIA_IOMem 429 //----------------- 430 //------------------------------------------------------------------------------------------------- 431 /// Read data from IO memory. (Only read 1 byte) 432 /// @ingroup PCMCIA_IOMem 433 /// @param eModule \b IN: CAM module. 434 /// @param wAddr \b IN: Read address. 435 /// @return: The data from PCMCIA IO memory. 436 //------------------------------------------------------------------------------------------------- 437 MS_U8 MDrv_PCMCIA_ReadIOMemV2( PCMCIA_MODULE eModule, MS_U16 wAddr ); 438 //------------------------------------------------------------------------------------------------- 439 /// Check CI CAM still plug or not 440 /// @ingroup PCMCIA_ToBeRemove 441 /// @param eModule \b IN: CAM module. 442 /// @return TRUE : Still plug 443 /// @return FALSE : Already removed 444 //------------------------------------------------------------------------------------------------- 445 MS_BOOL MDrv_PCMCIA_IsModuleStillPluggedV2( PCMCIA_MODULE eModule ); 446 //------------------------------------------------------------------------------------------------- 447 /// Set PCMCIA detect trigger is high active or low active 448 /// @ingroup PCMCIA_Task 449 /// @param bActiveHigh \b IN: Set TRUE:High active, FALSE: Low active 450 /// @return None 451 //------------------------------------------------------------------------------------------------- 452 void MDrv_PCMCIA_Set_Detect_Trigger( MS_BOOL bActiveHigh ); 453 //------------------------------------------------------------------------------------------------- 454 /// Set PCMCIA detect function can work or not 455 /// @ingroup PCMCIA_Task 456 /// @param bEnable \b IN: Enable:enable detect function, Disable: disable detect function 457 /// @return None 458 //------------------------------------------------------------------------------------------------- 459 void MDrv_PCMCIA_Set_Detect_Enable( MS_BOOL bEnable ); 460 //------------------------------------------------------------------------------------------------- 461 /// Get CAM detect interval time. 462 /// @ingroup PCMCIA_Task 463 /// @param eModule \b IN: CAM module. 464 /// @return: The CAM detect interval time 465 //------------------------------------------------------------------------------------------------- 466 MS_U32 MDrv_PCMCIA_Get_CD_IntervalV2( PCMCIA_MODULE eModule ); 467 //-------------------------------------------------------------------------------------------------- 468 /// Get PCMCIA driver library information 469 /// @ingroup PCMCIA_General 470 /// @param ppVersion \b OUT: PCMCIA library version infomation 471 /// @return TRUE - Success 472 /// @return FALSE - Failure 473 //-------------------------------------------------------------------------------------------------- 474 MS_BOOL MDrv_PCMCIA_GetLibVer( const MSIF_Version **ppVersion ); 475 //------------------------------------------------------------------------------------------------- 476 /// Set PCMCIA command. (IO memory?) 477 /// @ingroup PCMCIA_Task 478 /// @param eModule \b IN: CAM module. 479 /// @param u8CommandBit \b IN: Command. 480 /// @param bValue \b IN: TRUE: enable command bit. FALSE: disable command bit. 481 /// @return None 482 //------------------------------------------------------------------------------------------------- 483 void MDrv_PCMCIA_SetCommandBitV2( PCMCIA_MODULE eModule, MS_U8 u8CommandBit, MS_BOOL bValue ); 484 //------------------------------------------------------------------------------------------------- 485 /// Reset PCMCIA interface. Send reset flag (RS). 486 /// @ingroup PCMCIA_Task 487 /// @param eModule \b IN: CAM module. 488 /// @return TRUE : Succeed 489 /// @return FALSE : Fail 490 //------------------------------------------------------------------------------------------------- 491 MS_BOOL MDrv_PCMCIA_ResetInterfaceV2( PCMCIA_MODULE eModule ); 492 //------------------------------------------------------------------------------------------------- 493 /// Check data is avaliable or not. (IO memory?) 494 /// @ingroup PCMCIA_Task 495 /// @param eModule \b IN: CAM module. 496 /// @return TRUE : Succeed 497 /// @return FALSE : Fail 498 //------------------------------------------------------------------------------------------------- 499 MS_BOOL MDrv_PCMCIA_IsDataAvailableV2( PCMCIA_MODULE eModule ); 500 //------------------------------------------------------------------------------------------------- 501 /// Read data from CAM 502 /// @ingroup PCMCIA_Task 503 /// @param eModule \b IN: CAM module. 504 /// @param u8pReadBuffer \b OUT: Read buffer. 505 /// @param u16ReadBufferSize \b IN: Buffer size. 506 /// @return : Read data length. 507 //------------------------------------------------------------------------------------------------- 508 MS_U16 MDrv_PCMCIA_ReadDataV2( PCMCIA_MODULE eModule, MS_U8* u8pReadBuffer, MS_U16 u16ReadBufferSize ); 509 //------------------------------------------------------------------------------------------------- 510 /// Write data to CAM 511 /// @ingroup PCMCIA_Task 512 /// @param eModule \b IN: CAM module. 513 /// @param u8pWriteBuffer \b IN: Write buffer. 514 /// @param u16DataLen \b IN: Buffer size. 515 /// @return TRUE : Succeed 516 /// @return FALSE : Fail 517 //------------------------------------------------------------------------------------------------- 518 MS_BOOL MDrv_PCMCIA_WriteDataV2( PCMCIA_MODULE eModule, MS_U8* u8pWriteBuffer, MS_U16 u16DataLen ); 519 520 //------------------------------------------------------------------------------------------------- 521 /// Switch to I/O mode. (Attribute memory !?) 522 /// @ingroup PCMCIA_Task 523 /// @param eModule \b IN: CAM module. 524 /// @param pInfo \b IN: PCMCIA info: offset and offset index. 525 /// @return TRUE : Succeed 526 /// @return FALSE : Fail 527 //------------------------------------------------------------------------------------------------- 528 MS_BOOL MDrv_PCMCIA_SwitchToIOmodeV2( PCMCIA_MODULE eModule, PCMCIA_INFO *pInfo ); 529 //----------------- 530 // PCMCIA_ToBeModified 531 //----------------- 532 //------------------------------------------------------------------------------------------------- 533 /// Negotiate with PCMCIA biffer. Use size read (SR) to check. 534 /// @ingroup PCMCIA_Task 535 /// @param eModule \b IN: CAM module. 536 /// @param pInfo \b IN: PCMCIA info (Not used) 537 /// @return : Buffer size. 538 //------------------------------------------------------------------------------------------------- 539 MS_U16 MDrv_PCMCIA_NegotiateBufferSizeV2( PCMCIA_MODULE eModule, PCMCIA_INFO *pInfo ); 540 //------------------------------------------------------------------------------------------------- 541 /// Write PCMCIA buffer size. 542 /// @ingroup PCMCIA_Task 543 /// @param eModule \b IN: CAM module. 544 /// @param u16BufferSize \b IN: Buffer size 545 /// @return None 546 //------------------------------------------------------------------------------------------------- 547 void MDrv_PCMCIA_WriteBufferSizeV2( PCMCIA_MODULE eModule, MS_U16 u16BufferSize ); 548 549 //------------------------------------------------------------------------------------------------- 550 /// Check status bit 551 /// @ingroup PCMCIA_Task 552 /// @param eModule \b IN: CAM module. 553 /// @param u8StatusBit \b IN: Status bit which you want to check. 554 /// @return TRUE : Status bit check success. 555 /// @return FALSE : Can't find the match status bit. 556 //------------------------------------------------------------------------------------------------- 557 MS_BOOL MDrv_PCMCIA_WaitForStatusBitV2( PCMCIA_MODULE eModule, MS_U8 u8StatusBit ); 558 559 //----------------- 560 // PCMCIA_INT 561 //----------------- 562 //------------------------------------------------------------------------------------------------- 563 /// Check interrupt status. 564 /// @ingroup PCMCIA_INT 565 /// @return : The register value of interrupt. 566 //------------------------------------------------------------------------------------------------- 567 MS_U8 MDrv_PCMCIA_ReadyStatus( void ); 568 //------------------------------------------------------------------------------------------------- 569 /// Finalize PCMCIA module 570 /// @ingroup PCMCIA_General 571 /// @return None 572 //------------------------------------------------------------------------------------------------- 573 void MDrv_PCMCIA_Exit( void ); 574 575 #if PCMCIA_IRQ_ENABLE 576 //------------------------------------------------------------------------------------------------- 577 /// Enable PCMCIA interrupt. 578 /// @ingroup PCMCIA_INT 579 /// @param eModule \b IN: CAM module. 580 /// @param bEnable \b IN: Enable/Disable 581 /// @return None 582 //------------------------------------------------------------------------------------------------- 583 void MDrv_PCMCIA_Enable_InterruptV2( PCMCIA_MODULE eModule, MS_BOOL bEnable ); 584 585 //------------------------------------------------------------------------------------------------- 586 /// Set PCMCIA IRQ Status. 587 /// @ingroup PCMCIA_INT 588 /// @param eModule \b IN: CAM module. 589 /// @param Status \b IN: TRUE/FALSE 590 /// @return None 591 //------------------------------------------------------------------------------------------------- 592 void MDrv_PCMCIA_Set_InterruptStatusV2( PCMCIA_MODULE eModule, MS_BOOL Status ); 593 594 //------------------------------------------------------------------------------------------------- 595 /// Get PCMCIA IRQ Status. 596 /// @ingroup PCMCIA_INT 597 /// @param eModule \b IN: CAM module. 598 /// @return : PCMCIA IRQ Status (TRUE/FALSE) 599 //------------------------------------------------------------------------------------------------- 600 MS_BOOL MDrv_PCMCIA_Get_InterruptStatusV2( PCMCIA_MODULE eModule ); 601 //------------------------------------------------------------------------------------------------- 602 /// Set PCMCIA callback function. 603 /// @ingroup PCMCIA_ToBeRemove 604 /// @param eModule \b IN: CAM module. 605 /// @param fnIsrCallback \b IN: Callback function. 606 /// @return : PCMCIA IRQ Status (TRUE/FALSE) 607 //------------------------------------------------------------------------------------------------- 608 void MDrv_PCMCIA_InstarllIsrCallbackV2( PCMCIA_MODULE eModule, IsrCallback fnIsrCallback ); 609 #endif 610 611 612 //----------------------------------------------------------------------------- 613 // Function define for backward compatible 614 //----------------------------------------------------------------------------- 615 #define PCMCIA_DEFAULT_MODULE E_PCMCIA_MODULE_A 616 #if 0 617 //#define MDrv_PCMCIA_Detect(p...) MDrv_PCMCIA_DetectV2(E_PCMCIA_MODULE_A) 618 #define MDrv_PCMCIA_Polling(p...) MDrv_PCMCIA_PollingV2(PCMCIA_DEFAULT_MODULE) 619 #define MDrv_PCMCIA_IsModuleStillPlugged(p...) MDrv_PCMCIA_IsModuleStillPluggedV2(PCMCIA_DEFAULT_MODULE) 620 #define MDrv_PCMCIA_SetCommandBit(p...) MDrv_PCMCIA_SetCommandBitV2(PCMCIA_DEFAULT_MODULE, p) 621 #define MDrv_PCMCIA_ResetInterface(p...) MDrv_PCMCIA_ResetInterfaceV2(PCMCIA_DEFAULT_MODULE) 622 #define MDrv_PCMCIA_IsDataAvailable(p...) MDrv_PCMCIA_IsDataAvailableV2(PCMCIA_DEFAULT_MODULE) 623 #define MDrv_PCMCIA_ReadData(p...) MDrv_PCMCIA_ReadDataV2(PCMCIA_DEFAULT_MODULE, p) 624 #define MDrv_PCMCIA_WriteData(p...) MDrv_PCMCIA_WriteDataV2(PCMCIA_DEFAULT_MODULE, p) 625 #define MDrv_PCMCIA_SwitchToIOmode(p...) MDrv_PCMCIA_SwitchToIOmodeV2(PCMCIA_DEFAULT_MODULE, p) 626 #define MDrv_PCMCIA_NegotiateBufferSize(p...) MDrv_PCMCIA_NegotiateBufferSizeV2(PCMCIA_DEFAULT_MODULE, p) 627 #define MDrv_PCMCIA_WriteBufferSize(p...) MDrv_PCMCIA_WriteBufferSizeV2(PCMCIA_DEFAULT_MODULE, p) 628 #define MDrv_PCMCIA_WaitForStatusBit(p...) MDrv_PCMCIA_WaitForStatusBitV2(PCMCIA_DEFAULT_MODULE, p) 629 #define MDrv_PCMCIA_ResetHW(p...) MDrv_PCMCIA_ResetHW_V2(PCMCIA_DEFAULT_MODULE) 630 #define MDrv_PCMCIA_WriteAttribMem(p...) MDrv_PCMCIA_WriteAttribMemV2(PCMCIA_DEFAULT_MODULE, p) 631 #define MDrv_PCMCIA_ReadAttribMem(p...) MDrv_PCMCIA_ReadAttribMemV2(PCMCIA_DEFAULT_MODULE, p) 632 #define MDrv_PCMCIA_WriteIOMem(p...) MDrv_PCMCIA_WriteIOMemV2(PCMCIA_DEFAULT_MODULE, p) 633 #define MDrv_PCMCIA_WriteIOMemLong(p...) MDrv_PCMCIA_WriteIOMemLongV2(PCMCIA_DEFAULT_MODULE, p) 634 #define MDrv_PCMCIA_ReadIOMem(p...) MDrv_PCMCIA_ReadIOMemV2(PCMCIA_DEFAULT_MODULE, p) 635 #define MDrv_PCMCIA_Get_CD_Interval(p...) MDrv_PCMCIA_Get_CD_IntervalV2(PCMCIA_DEFAULT_MODULE) 636 637 #if PCMCIA_IRQ_ENABLE 638 #define MDrv_PCMCIA_Enable_Interrupt(p...) MDrv_PCMCIA_Enable_InterruptV2(PCMCIA_DEFAULT_MODULE, p) 639 #define MDrv_PCMCIA_Set_InterruptStatus(p...) MDrv_PCMCIA_Set_InterruptStatusV2(PCMCIA_DEFAULT_MODULE, p) 640 #define MDrv_PCMCIA_Get_InterruptStatus(p...) MDrv_PCMCIA_Get_InterruptStatusV2(PCMCIA_DEFAULT_MODULE) 641 #define MDrv_PCMCIA_InstarllIsrCallback(p...) MDrv_PCMCIA_InstarllIsrCallbackV2(PCMCIA_DEFAULT_MODULE, p) 642 #endif 643 #else 644 //------------------------------------------------------------------------------------------------- 645 /// Check CI CAM is detect or not. (use V2 version: for CAM module select) 646 /// @ingroup PCMCIA_ToBeRemove 647 /// @return TRUE : Succeed - CAM detect 648 /// @return FALSE : Fail - CAM not detect 649 //------------------------------------------------------------------------------------------------- 650 MS_BOOL MDrv_PCMCIA_Polling( void ); 651 //------------------------------------------------------------------------------------------------- 652 /// Check CI CAM still plug or not. (use V2 version: for CAM module select) 653 /// @ingroup PCMCIA_ToBeRemove 654 /// @return TRUE : Still plug 655 /// @return FALSE : Already removed 656 //------------------------------------------------------------------------------------------------- 657 MS_BOOL MDrv_PCMCIA_IsModuleStillPlugged( void ); 658 659 //------------------------------------------------------------------------------------------------- 660 /// Set PCMCIA command. (use V2 version: for CAM module select) 661 /// @ingroup PCMCIA_ToBeRemove 662 /// @param u8CommandBit \b IN: Command. 663 /// @param bValue \b IN: TRUE: enable command bit. FALSE: disable command bit. 664 /// @return None 665 //------------------------------------------------------------------------------------------------- 666 void MDrv_PCMCIA_SetCommandBit( MS_U8 u8CommandBit, MS_BOOL bValue ); 667 668 //------------------------------------------------------------------------------------------------- 669 /// Reset PCMCIA interface. Send reset flag (RS). (use V2 version: for CAM module select) 670 /// @ingroup PCMCIA_ToBeRemove 671 /// @return TRUE : Succeed 672 /// @return FALSE : Fail 673 //------------------------------------------------------------------------------------------------- 674 MS_BOOL MDrv_PCMCIA_ResetInterface( void ); 675 676 //------------------------------------------------------------------------------------------------- 677 /// Check data is avaliable or not. (use V2 version: for CAM module select) 678 /// @ingroup PCMCIA_ToBeRemove 679 /// @return TRUE : Succeed 680 /// @return FALSE : Fail 681 //------------------------------------------------------------------------------------------------- 682 MS_BOOL MDrv_PCMCIA_IsDataAvailable( void ); 683 684 //------------------------------------------------------------------------------------------------- 685 /// Read data from CAM. (use V2 version: for CAM module select) 686 /// @ingroup PCMCIA_ToBeRemove 687 /// @param u8pReadBuffer \b OUT: Read buffer. 688 /// @param u16ReadBufferSize \b IN: Buffer size. 689 /// @return : Read data length. 690 //------------------------------------------------------------------------------------------------- 691 MS_U16 MDrv_PCMCIA_ReadData( MS_U8* u8pReadBuffer, MS_U16 u16ReadBufferSize ); 692 693 //------------------------------------------------------------------------------------------------- 694 /// Write data to CAM. (use V2 version: for CAM module select) 695 /// @ingroup PCMCIA_ToBeRemove 696 /// @param u8pWriteBuffer \b IN: Write buffer. 697 /// @param u16DataLen \b IN: Buffer size. 698 /// @return TRUE : Succeed 699 /// @return FALSE : Fail 700 //------------------------------------------------------------------------------------------------- 701 MS_BOOL MDrv_PCMCIA_WriteData( MS_U8* u8pWriteBuffer, MS_U16 u16DataLen ); 702 703 //------------------------------------------------------------------------------------------------- 704 /// Switch to I/O mode. (use V2 version: for CAM module select) 705 /// @ingroup PCMCIA_ToBeRemove 706 /// @param pInfo \b IN: PCMCIA info: offset and offset index. 707 /// @return TRUE : Succeed 708 /// @return FALSE : Fail 709 //------------------------------------------------------------------------------------------------- 710 MS_BOOL MDrv_PCMCIA_SwitchToIOmode( PCMCIA_INFO *pInfo ); 711 712 //------------------------------------------------------------------------------------------------- 713 /// Negotiate with PCMCIA biffer. Use size read (SR) to check. (use V2 version: for CAM module select) 714 /// @ingroup PCMCIA_ToBeRemove 715 /// @param pInfo \b IN: PCMCIA info (Not used) 716 /// @return : Buffer size. 717 //------------------------------------------------------------------------------------------------- 718 MS_U16 MDrv_PCMCIA_NegotiateBufferSize( PCMCIA_INFO *pInfo ); 719 720 //------------------------------------------------------------------------------------------------- 721 /// Write PCMCIA buffer size. (use V2 version: for CAM module select) 722 /// @ingroup PCMCIA_ToBeRemove 723 /// @param u16BufferSize \b IN: Buffer size 724 /// @return None 725 //------------------------------------------------------------------------------------------------- 726 void MDrv_PCMCIA_WriteBufferSize( MS_U16 u16BufferSize ); 727 728 //------------------------------------------------------------------------------------------------- 729 /// Check status bit. (use V2 version: for CAM module select) 730 /// @ingroup PCMCIA_ToBeRemove 731 /// @param u8StatusBit \b IN: Status bit which you want to check. 732 /// @return TRUE : Status bit check success. 733 /// @return FALSE : Can't find the match status bit. 734 //------------------------------------------------------------------------------------------------- 735 MS_BOOL MDrv_PCMCIA_WaitForStatusBit( MS_U8 u8StatusBit ); 736 737 //------------------------------------------------------------------------------------------------- 738 /// Reset PCMCIA HW. (use V2 version: for CAM module select) 739 /// @ingroup PCMCIA_ToBeRemove 740 /// @return None 741 //------------------------------------------------------------------------------------------------- 742 void MDrv_PCMCIA_ResetHW( void ); 743 744 //------------------------------------------------------------------------------------------------- 745 /// Write data to attribute memory. (use V2 version: for CAM module select) 746 /// @ingroup PCMCIA_ToBeRemove 747 /// @param wAddr \b IN: Write address. 748 /// @param bData \b IN: Write data. 749 /// @return None 750 //------------------------------------------------------------------------------------------------- 751 void MDrv_PCMCIA_WriteAttribMem( MS_U16 wAddr, MS_U8 bData ); 752 753 //------------------------------------------------------------------------------------------------- 754 /// Copy data from attribute memory. (use V2 version: for CAM module select) 755 /// @ingroup PCMCIA_ToBeRemove 756 /// @param u16Addr \b IN: Read address. 757 /// @param pDest \b OUT: Copyed buffer. 758 /// @return None 759 //------------------------------------------------------------------------------------------------- 760 void MDrv_PCMCIA_ReadAttribMem( MS_U16 u16Addr, MS_U8 *pDest ); 761 762 //------------------------------------------------------------------------------------------------- 763 /// Write data to IO memory. (Only write 1 byte) (use V2 version: for CAM module select) 764 /// @ingroup PCMCIA_ToBeRemove 765 /// @param wAddr \b IN: Write address. 766 /// @param bData \b IN: Write data. 767 /// @return None 768 //------------------------------------------------------------------------------------------------- 769 void MDrv_PCMCIA_WriteIOMem( MS_U16 wAddr, MS_U8 bData ); 770 771 //------------------------------------------------------------------------------------------------- 772 /// Write data to IO memory. (Write long size data to the IO memory) (use V2 version: for CAM module select) 773 /// @ingroup PCMCIA_ToBeRemove 774 /// @param u16Addr \b IN: Write address. 775 /// @param u8Value \b IN: Write data. (Not used? It's use for 1 byte write) 776 /// @param u16DataLen \b IN: Write length. 777 /// @param u8pWriteBuffer \b IN: Write buffer. 778 /// @return None 779 //------------------------------------------------------------------------------------------------- 780 void MDrv_PCMCIA_WriteIOMemLong( MS_U16 u16Addr, MS_U8 u8Value, MS_U16 u16DataLen, MS_U8* u8pWriteBuffer); 781 782 //------------------------------------------------------------------------------------------------- 783 /// Read data from IO memory. (Only read 1 byte) (use V2 version: for CAM module select) 784 /// @ingroup PCMCIA_ToBeRemove 785 /// @param wAddr \b IN: Read address. 786 /// @return: The data from PCMCIA IO memory. 787 //------------------------------------------------------------------------------------------------- 788 MS_U8 MDrv_PCMCIA_ReadIOMem( MS_U16 wAddr ); 789 790 //------------------------------------------------------------------------------------------------- 791 /// Get CAM detect interval time. (use V2 version: for CAM module select) 792 /// @ingroup PCMCIA_ToBeRemove 793 /// @return: The CAM detect interval time 794 //------------------------------------------------------------------------------------------------- 795 MS_U32 MDrv_PCMCIA_Get_CD_Interval( void ); 796 797 #if PCMCIA_IRQ_ENABLE 798 //------------------------------------------------------------------------------------------------- 799 /// Enable PCMCIA interrupt. (use V2 version: for CAM module select) 800 /// @ingroup PCMCIA_ToBeRemove 801 /// @param bEnable \b IN: Enable/Disable 802 /// @return None 803 //------------------------------------------------------------------------------------------------- 804 void MDrv_PCMCIA_Enable_Interrupt( MS_BOOL bEnable ); 805 806 //------------------------------------------------------------------------------------------------- 807 /// Set PCMCIA IRQ Status. (use V2 version: for CAM module select) 808 /// @ingroup PCMCIA_ToBeRemove 809 /// @param Status \b IN: TRUE/FALSE 810 /// @return None 811 //------------------------------------------------------------------------------------------------- 812 void MDrv_PCMCIA_Set_InterruptStatus( MS_BOOL Status ); 813 814 //------------------------------------------------------------------------------------------------- 815 /// Get PCMCIA IRQ Status. (use V2 version: for CAM module select) 816 /// @ingroup PCMCIA_ToBeRemove 817 /// @return : PCMCIA IRQ Status (TRUE/FALSE) 818 //------------------------------------------------------------------------------------------------- 819 MS_BOOL MDrv_PCMCIA_Get_InterruptStatus( void ); 820 821 //------------------------------------------------------------------------------------------------- 822 /// Set PCMCIA callback function. 823 /// @ingroup PCMCIA_ToBeRemove 824 /// @param fnIsrCallback \b IN: Callback function. 825 /// @return : PCMCIA IRQ Status (TRUE/FALSE) 826 //------------------------------------------------------------------------------------------------- 827 void MDrv_PCMCIA_InstarllIsrCallback( IsrCallback fnIsrCallback ); 828 #endif 829 #endif 830 831 #ifdef __cplusplus 832 } 833 #endif 834 835 #endif // _DRV_PCMCIA_H_ 836