xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/drvPCMCIA.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 // ********************************************************
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 // PCMCIA_STR
325 //-----------------
326 //-------------------------------------------------------------------------------------------------
327 /// Control PCMCIA STR functions.
328 /// @ingroup PCMCIA_STR
329 /// @param  u16PowerState  \b IN: STR power mode. (to control STR suspend & resume case.)
330 /// @return : Utopia status - UTOPIA_STATUS_SUCCESS (Succeed) or UTOPIA_STATUS_FAIL (Fail)
331 //-------------------------------------------------------------------------------------------------
332 MS_U32 MDrv_PCMCIA_SetPowerState(EN_POWER_MODE u16PowerState);
333 //-----------------
334 // PCMCIA_ToBeRemove
335 //-----------------
336 //-------------------------------------------------------------------------------------------------
337 /// Check CI CAM is detect or not. (Still call MDrv_PCMCIA_DetectV2)
338 /// @ingroup PCMCIA_ToBeRemove
339 /// @param  eModule       \b IN: CAM module.
340 /// @return TRUE  : Succeed - CAM detect
341 /// @return FALSE : Fail - CAM not detect
342 //-------------------------------------------------------------------------------------------------
343 MS_BOOL MDrv_PCMCIA_PollingV2( PCMCIA_MODULE eModule );
344 //-----------------
345 // PCMCIA_Task
346 //-----------------
347 //-------------------------------------------------------------------------------------------------
348 /// Check CI CAM is detect or not.
349 /// @ingroup PCMCIA_Task
350 /// @param  eModule       \b IN: CAM module.
351 /// @return TRUE  : Succeed - CAM detect
352 /// @return FALSE : Fail - CAM not detect
353 //-------------------------------------------------------------------------------------------------
354 // MS_BOOL MDrv_PCMCIA_DetectV2( PCMCIA_MODULE eModule );
355 //-------------------------------------------------------------------------------------------------
356 /// Set reset HW duration.
357 /// @ingroup PCMCIA_Task
358 /// @param  u8HW_ResetDuration       \b IN: Duration.
359 /// @return None
360 //-------------------------------------------------------------------------------------------------
361 void MDrv_PCMCIA_Set_HW_ResetDuration( MS_U8 u8HW_ResetDuration );
362 //-------------------------------------------------------------------------------------------------
363 /// Reset PCMCIA HW
364 /// @ingroup PCMCIA_Task
365 /// @param  eModule       \b IN: CAM module.
366 /// @return None
367 //-------------------------------------------------------------------------------------------------
368 void MDrv_PCMCIA_ResetHW_V2( PCMCIA_MODULE eModule );
369 //-----------------
370 // PCMCIA_AttributeMem
371 //-----------------
372 //-------------------------------------------------------------------------------------------------
373 /// Copy data from attribute memory.
374 /// @ingroup PCMCIA_AttributeMem
375 /// @param  eModule       \b IN: CAM module.
376 /// @param  u16Addr       \b IN: Read address.
377 /// @param  pDest           \b OUT: Copyed buffer.
378 /// @return None
379 //-------------------------------------------------------------------------------------------------
380 void MDrv_PCMCIA_ReadAttribMemV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 *pDest );
381 //-------------------------------------------------------------------------------------------------
382 /// Parse attribute memory data into an easily readable PCMCIA_INFO structure.
383 /// @ingroup PCMCIA_AttributeMem
384 /// @param  pAttribMem   \b IN: Attribute memory buffer.
385 /// @param  dwLen          \b IN: Data length.
386 /// @param  pInfo           \b OUT: PCMCIA information.
387 /// @return None
388 //-------------------------------------------------------------------------------------------------
389 void MDrv_PCMCIA_ParseAttribMem( MS_U8 *pAttribMem, MS_U16 dwLen, PCMCIA_INFO *pInfo );
390 //-------------------------------------------------------------------------------------------------
391 /// Write data to attribute memory.
392 /// @ingroup PCMCIA_AttributeMem
393 /// @param  eModule       \b IN: CAM module.
394 /// @param  wAddr          \b IN: Write address.
395 /// @param  bData          \b IN: Write data.
396 /// @return None
397 //-------------------------------------------------------------------------------------------------
398 void MDrv_PCMCIA_WriteAttribMemV2( PCMCIA_MODULE eModule, MS_U16 wAddr, MS_U8 bData );
399 //-------------------------------------------------------------------------------------------------
400 /// Write data to IO memory. (Only write 1 byte)
401 /// @ingroup PCMCIA_IOMem
402 /// @param  eModule       \b IN: CAM module.
403 /// @param  wAddr         \b IN: Write address.
404 /// @param  bData          \b IN: Write data.
405 /// @return None
406 //-------------------------------------------------------------------------------------------------
407 void MDrv_PCMCIA_WriteIOMemV2( PCMCIA_MODULE eModule, MS_U16 wAddr, MS_U8 bData );
408 //-------------------------------------------------------------------------------------------------
409 /// Write data to IO memory. (Write long size data to the IO memory)
410 /// @ingroup PCMCIA_ToBeModified
411 /// @param  eModule              \b IN: CAM module.
412 /// @param  u16Addr              \b IN: Write address.
413 /// @param  u8Value               \b IN: Write data. (Not used? It's use for 1 byte write)
414 /// @param  u16DataLen          \b IN: Write length.
415 /// @param  u8pWriteBuffer     \b IN: Write buffer.
416 /// @return None
417 //-------------------------------------------------------------------------------------------------
418 void MDrv_PCMCIA_WriteIOMemLongV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 u8Value, MS_U16 u16DataLen, MS_U8* u8pWriteBuffer);
419 //-----------------
420 // PCMCIA_IOMem
421 //-----------------
422 //-------------------------------------------------------------------------------------------------
423 /// Read data from IO memory. (Only read 1 byte)
424 /// @ingroup PCMCIA_IOMem
425 /// @param  eModule       \b IN: CAM module.
426 /// @param  wAddr          \b IN: Read address.
427 /// @return: The data from PCMCIA IO memory.
428 //-------------------------------------------------------------------------------------------------
429 MS_U8 MDrv_PCMCIA_ReadIOMemV2( PCMCIA_MODULE eModule, MS_U16 wAddr );
430 //-------------------------------------------------------------------------------------------------
431 /// Check CI CAM still plug or not
432 /// @ingroup PCMCIA_ToBeRemove
433 /// @param  eModule       \b IN: CAM module.
434 /// @return TRUE  : Still plug
435 /// @return FALSE : Already removed
436 //-------------------------------------------------------------------------------------------------
437 MS_BOOL MDrv_PCMCIA_IsModuleStillPluggedV2( PCMCIA_MODULE eModule );
438 //-------------------------------------------------------------------------------------------------
439 /// Set PCMCIA detect trigger is high active or low active
440 /// @ingroup PCMCIA_Task
441 /// @param  bActiveHigh     \b IN: Set TRUE:High active, FALSE: Low active
442 /// @return None
443 //-------------------------------------------------------------------------------------------------
444 void MDrv_PCMCIA_Set_Detect_Trigger( MS_BOOL bActiveHigh );
445 //-------------------------------------------------------------------------------------------------
446 /// Set PCMCIA detect function can work or not
447 /// @ingroup PCMCIA_Task
448 /// @param  bEnable     \b IN: Enable:enable detect function, Disable: disable detect function
449 /// @return None
450 //-------------------------------------------------------------------------------------------------
451 void MDrv_PCMCIA_Set_Detect_Enable( MS_BOOL bEnable );
452 //-------------------------------------------------------------------------------------------------
453 /// Get CAM detect interval time.
454 /// @ingroup PCMCIA_Task
455 /// @param  eModule       \b IN: CAM module.
456 /// @return: The CAM detect interval time
457 //-------------------------------------------------------------------------------------------------
458 MS_U32 MDrv_PCMCIA_Get_CD_IntervalV2( PCMCIA_MODULE eModule );
459 //--------------------------------------------------------------------------------------------------
460 /// Get PCMCIA driver library information
461 /// @ingroup PCMCIA_General
462 /// @param ppVersion      \b OUT: PCMCIA library version infomation
463 /// @return TRUE - Success
464 /// @return FALSE - Failure
465 //--------------------------------------------------------------------------------------------------
466 MS_BOOL MDrv_PCMCIA_GetLibVer( const MSIF_Version **ppVersion );
467 //-------------------------------------------------------------------------------------------------
468 /// Set PCMCIA command. (IO memory?)
469 /// @ingroup PCMCIA_Task
470 /// @param  eModule              \b IN: CAM module.
471 /// @param  u8CommandBit    \b IN: Command.
472 /// @param  bValue                \b IN:  TRUE: enable command bit. FALSE: disable command bit.
473 /// @return None
474 //-------------------------------------------------------------------------------------------------
475 void MDrv_PCMCIA_SetCommandBitV2( PCMCIA_MODULE eModule, MS_U8 u8CommandBit, MS_BOOL bValue );
476 //-------------------------------------------------------------------------------------------------
477 /// Reset PCMCIA interface. Send reset flag (RS).
478 /// @ingroup PCMCIA_Task
479 /// @param  eModule              \b IN: CAM module.
480 /// @return TRUE  : Succeed
481 /// @return FALSE : Fail
482 //-------------------------------------------------------------------------------------------------
483 MS_BOOL MDrv_PCMCIA_ResetInterfaceV2( PCMCIA_MODULE eModule );
484 //-------------------------------------------------------------------------------------------------
485 /// Check data is avaliable or not. (IO memory?)
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_IsDataAvailableV2( PCMCIA_MODULE eModule );
492 //-------------------------------------------------------------------------------------------------
493 /// Read data from CAM
494 /// @ingroup PCMCIA_Task
495 /// @param  eModule                  \b IN: CAM module.
496 /// @param  u8pReadBuffer         \b OUT: Read buffer.
497 /// @param  u16ReadBufferSize   \b IN: Buffer size.
498 /// @return : Read data length.
499 //-------------------------------------------------------------------------------------------------
500 MS_U16 MDrv_PCMCIA_ReadDataV2( PCMCIA_MODULE eModule, MS_U8* u8pReadBuffer, MS_U16 u16ReadBufferSize );
501 //-------------------------------------------------------------------------------------------------
502 /// Write data to CAM
503 /// @ingroup PCMCIA_Task
504 /// @param  eModule                  \b IN: CAM module.
505 /// @param  u8pWriteBuffer         \b IN: Write buffer.
506 /// @param  u16DataLen             \b IN: Buffer size.
507 /// @return TRUE  : Succeed
508 /// @return FALSE : Fail
509 //-------------------------------------------------------------------------------------------------
510 MS_BOOL MDrv_PCMCIA_WriteDataV2( PCMCIA_MODULE eModule, MS_U8* u8pWriteBuffer, MS_U16 u16DataLen );
511 
512 //-------------------------------------------------------------------------------------------------
513 /// Switch to I/O mode. (Attribute memory !?)
514 /// @ingroup PCMCIA_Task
515 /// @param  eModule     \b IN: CAM module.
516 /// @param  pInfo         \b IN: PCMCIA info: offset and offset index.
517 /// @return TRUE  : Succeed
518 /// @return FALSE : Fail
519 //-------------------------------------------------------------------------------------------------
520 MS_BOOL MDrv_PCMCIA_SwitchToIOmodeV2( PCMCIA_MODULE eModule, PCMCIA_INFO *pInfo );
521 //-----------------
522 // PCMCIA_ToBeModified
523 //-----------------
524 //-------------------------------------------------------------------------------------------------
525 /// Negotiate with PCMCIA biffer. Use size read (SR) to check.
526 /// @ingroup PCMCIA_Task
527 /// @param  eModule     \b IN: CAM module.
528 /// @param  pInfo         \b IN: PCMCIA info (Not used)
529 /// @return : Buffer size.
530 //-------------------------------------------------------------------------------------------------
531 MS_U16 MDrv_PCMCIA_NegotiateBufferSizeV2( PCMCIA_MODULE eModule, PCMCIA_INFO *pInfo );
532 //-------------------------------------------------------------------------------------------------
533 /// Write PCMCIA buffer size.
534 /// @ingroup PCMCIA_Task
535 /// @param  eModule           \b IN: CAM module.
536 /// @param  u16BufferSize  \b IN: Buffer size
537 /// @return None
538 //-------------------------------------------------------------------------------------------------
539 void MDrv_PCMCIA_WriteBufferSizeV2( PCMCIA_MODULE eModule, MS_U16 u16BufferSize );
540 
541 //-------------------------------------------------------------------------------------------------
542 /// Check status bit
543 /// @ingroup PCMCIA_Task
544 /// @param  eModule           \b IN: CAM module.
545 /// @param  u8StatusBit      \b IN: Status bit which you want to check.
546 /// @return TRUE  : Status bit check success.
547 /// @return FALSE : Can't find the match status bit.
548 //-------------------------------------------------------------------------------------------------
549 MS_BOOL MDrv_PCMCIA_WaitForStatusBitV2( PCMCIA_MODULE eModule, MS_U8 u8StatusBit );
550 
551 //-----------------
552 // PCMCIA_INT
553 //-----------------
554 //-------------------------------------------------------------------------------------------------
555 /// Check interrupt status.
556 /// @ingroup PCMCIA_INT
557 /// @return : The register value of interrupt.
558 //-------------------------------------------------------------------------------------------------
559 MS_U8 MDrv_PCMCIA_ReadyStatus( void );
560 //-------------------------------------------------------------------------------------------------
561 /// Finalize PCMCIA module
562 /// @ingroup PCMCIA_General
563 /// @return None
564 //-------------------------------------------------------------------------------------------------
565 void MDrv_PCMCIA_Exit( void );
566 
567 #if PCMCIA_IRQ_ENABLE
568 //-------------------------------------------------------------------------------------------------
569 /// Enable PCMCIA interrupt.
570 /// @ingroup PCMCIA_INT
571 /// @param  eModule     \b IN: CAM module.
572 /// @param  bEnable      \b IN: Enable/Disable
573 /// @return None
574 //-------------------------------------------------------------------------------------------------
575 void MDrv_PCMCIA_Enable_InterruptV2( PCMCIA_MODULE eModule, MS_BOOL bEnable );
576 
577 //-------------------------------------------------------------------------------------------------
578 /// Set PCMCIA IRQ Status.
579 /// @ingroup PCMCIA_INT
580 /// @param  eModule     \b IN: CAM module.
581 /// @param  Status        \b IN: TRUE/FALSE
582 /// @return None
583 //-------------------------------------------------------------------------------------------------
584 void MDrv_PCMCIA_Set_InterruptStatusV2( PCMCIA_MODULE eModule, MS_BOOL Status );
585 
586 //-------------------------------------------------------------------------------------------------
587 /// Get PCMCIA IRQ Status.
588 /// @ingroup PCMCIA_INT
589 /// @param  eModule     \b IN: CAM module.
590 /// @return : PCMCIA IRQ Status (TRUE/FALSE)
591 //-------------------------------------------------------------------------------------------------
592 MS_BOOL MDrv_PCMCIA_Get_InterruptStatusV2( PCMCIA_MODULE eModule );
593 //-------------------------------------------------------------------------------------------------
594 /// Set PCMCIA callback function.
595 /// @ingroup PCMCIA_ToBeRemove
596 /// @param  eModule            \b IN: CAM module.
597 /// @param  fnIsrCallback     \b IN: Callback function.
598 /// @return : PCMCIA IRQ Status (TRUE/FALSE)
599 //-------------------------------------------------------------------------------------------------
600 void MDrv_PCMCIA_InstarllIsrCallbackV2( PCMCIA_MODULE eModule, IsrCallback fnIsrCallback );
601 #endif
602 
603 
604 //-----------------------------------------------------------------------------
605 //  Function define for backward compatible
606 //-----------------------------------------------------------------------------
607 #define PCMCIA_DEFAULT_MODULE                   E_PCMCIA_MODULE_A
608 #if 0
609     //#define MDrv_PCMCIA_Detect(p...)              MDrv_PCMCIA_DetectV2(E_PCMCIA_MODULE_A)
610     #define MDrv_PCMCIA_Polling(p...)               MDrv_PCMCIA_PollingV2(PCMCIA_DEFAULT_MODULE)
611     #define MDrv_PCMCIA_IsModuleStillPlugged(p...)  MDrv_PCMCIA_IsModuleStillPluggedV2(PCMCIA_DEFAULT_MODULE)
612     #define MDrv_PCMCIA_SetCommandBit(p...)         MDrv_PCMCIA_SetCommandBitV2(PCMCIA_DEFAULT_MODULE, p)
613     #define MDrv_PCMCIA_ResetInterface(p...)        MDrv_PCMCIA_ResetInterfaceV2(PCMCIA_DEFAULT_MODULE)
614     #define MDrv_PCMCIA_IsDataAvailable(p...)       MDrv_PCMCIA_IsDataAvailableV2(PCMCIA_DEFAULT_MODULE)
615     #define MDrv_PCMCIA_ReadData(p...)              MDrv_PCMCIA_ReadDataV2(PCMCIA_DEFAULT_MODULE, p)
616     #define MDrv_PCMCIA_WriteData(p...)             MDrv_PCMCIA_WriteDataV2(PCMCIA_DEFAULT_MODULE, p)
617     #define MDrv_PCMCIA_SwitchToIOmode(p...)        MDrv_PCMCIA_SwitchToIOmodeV2(PCMCIA_DEFAULT_MODULE, p)
618     #define MDrv_PCMCIA_NegotiateBufferSize(p...)   MDrv_PCMCIA_NegotiateBufferSizeV2(PCMCIA_DEFAULT_MODULE, p)
619     #define MDrv_PCMCIA_WriteBufferSize(p...)       MDrv_PCMCIA_WriteBufferSizeV2(PCMCIA_DEFAULT_MODULE, p)
620     #define MDrv_PCMCIA_WaitForStatusBit(p...)      MDrv_PCMCIA_WaitForStatusBitV2(PCMCIA_DEFAULT_MODULE, p)
621     #define MDrv_PCMCIA_ResetHW(p...)               MDrv_PCMCIA_ResetHW_V2(PCMCIA_DEFAULT_MODULE)
622     #define MDrv_PCMCIA_WriteAttribMem(p...)        MDrv_PCMCIA_WriteAttribMemV2(PCMCIA_DEFAULT_MODULE, p)
623     #define MDrv_PCMCIA_ReadAttribMem(p...)         MDrv_PCMCIA_ReadAttribMemV2(PCMCIA_DEFAULT_MODULE, p)
624     #define MDrv_PCMCIA_WriteIOMem(p...)            MDrv_PCMCIA_WriteIOMemV2(PCMCIA_DEFAULT_MODULE, p)
625     #define MDrv_PCMCIA_WriteIOMemLong(p...)        MDrv_PCMCIA_WriteIOMemLongV2(PCMCIA_DEFAULT_MODULE, p)
626     #define MDrv_PCMCIA_ReadIOMem(p...)             MDrv_PCMCIA_ReadIOMemV2(PCMCIA_DEFAULT_MODULE, p)
627     #define MDrv_PCMCIA_Get_CD_Interval(p...)       MDrv_PCMCIA_Get_CD_IntervalV2(PCMCIA_DEFAULT_MODULE)
628 
629     #if PCMCIA_IRQ_ENABLE
630         #define MDrv_PCMCIA_Enable_Interrupt(p...)      MDrv_PCMCIA_Enable_InterruptV2(PCMCIA_DEFAULT_MODULE, p)
631         #define MDrv_PCMCIA_Set_InterruptStatus(p...)   MDrv_PCMCIA_Set_InterruptStatusV2(PCMCIA_DEFAULT_MODULE, p)
632         #define MDrv_PCMCIA_Get_InterruptStatus(p...)   MDrv_PCMCIA_Get_InterruptStatusV2(PCMCIA_DEFAULT_MODULE)
633         #define MDrv_PCMCIA_InstarllIsrCallback(p...)   MDrv_PCMCIA_InstarllIsrCallbackV2(PCMCIA_DEFAULT_MODULE, p)
634     #endif
635 #else
636     //-------------------------------------------------------------------------------------------------
637     /// Check CI CAM is detect or not. (use V2 version: for CAM module select)
638     /// @ingroup PCMCIA_ToBeRemove
639     /// @return TRUE  : Succeed - CAM detect
640     /// @return FALSE : Fail - CAM not detect
641     //-------------------------------------------------------------------------------------------------
642     MS_BOOL MDrv_PCMCIA_Polling( void );
643     //-------------------------------------------------------------------------------------------------
644     /// Check CI CAM still plug or not. (use V2 version: for CAM module select)
645     /// @ingroup PCMCIA_ToBeRemove
646     /// @return TRUE  : Still plug
647     /// @return FALSE : Already removed
648     //-------------------------------------------------------------------------------------------------
649     MS_BOOL MDrv_PCMCIA_IsModuleStillPlugged( void );
650 
651     //-------------------------------------------------------------------------------------------------
652     /// Set PCMCIA command. (use V2 version: for CAM module select)
653     /// @ingroup PCMCIA_ToBeRemove
654     /// @param  u8CommandBit    \b IN: Command.
655     /// @param  bValue                \b IN:  TRUE: enable command bit. FALSE: disable command bit.
656     /// @return None
657     //-------------------------------------------------------------------------------------------------
658     void MDrv_PCMCIA_SetCommandBit( MS_U8 u8CommandBit, MS_BOOL bValue );
659 
660     //-------------------------------------------------------------------------------------------------
661     /// Reset PCMCIA interface. Send reset flag (RS). (use V2 version: for CAM module select)
662     /// @ingroup PCMCIA_ToBeRemove
663     /// @return TRUE  : Succeed
664     /// @return FALSE : Fail
665     //-------------------------------------------------------------------------------------------------
666     MS_BOOL MDrv_PCMCIA_ResetInterface( void );
667 
668     //-------------------------------------------------------------------------------------------------
669     /// Check data is avaliable or not. (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_IsDataAvailable( void );
675 
676     //-------------------------------------------------------------------------------------------------
677     /// Read data from CAM. (use V2 version: for CAM module select)
678     /// @ingroup PCMCIA_ToBeRemove
679     /// @param  u8pReadBuffer         \b OUT: Read buffer.
680     /// @param  u16ReadBufferSize   \b IN: Buffer size.
681     /// @return : Read data length.
682     //-------------------------------------------------------------------------------------------------
683     MS_U16 MDrv_PCMCIA_ReadData( MS_U8* u8pReadBuffer, MS_U16 u16ReadBufferSize );
684 
685     //-------------------------------------------------------------------------------------------------
686     /// Write data to CAM. (use V2 version: for CAM module select)
687     /// @ingroup PCMCIA_ToBeRemove
688     /// @param  u8pWriteBuffer         \b IN: Write buffer.
689     /// @param  u16DataLen             \b IN: Buffer size.
690     /// @return TRUE  : Succeed
691     /// @return FALSE : Fail
692     //-------------------------------------------------------------------------------------------------
693     MS_BOOL MDrv_PCMCIA_WriteData( MS_U8* u8pWriteBuffer, MS_U16 u16DataLen );
694 
695     //-------------------------------------------------------------------------------------------------
696     /// Switch to I/O mode. (use V2 version: for CAM module select)
697     /// @ingroup PCMCIA_ToBeRemove
698     /// @param  pInfo         \b IN: PCMCIA info: offset and offset index.
699     /// @return TRUE  : Succeed
700     /// @return FALSE : Fail
701     //-------------------------------------------------------------------------------------------------
702     MS_BOOL MDrv_PCMCIA_SwitchToIOmode( PCMCIA_INFO *pInfo );
703 
704     //-------------------------------------------------------------------------------------------------
705     /// Negotiate with PCMCIA biffer. Use size read (SR) to check. (use V2 version: for CAM module select)
706     /// @ingroup PCMCIA_ToBeRemove
707     /// @param  pInfo         \b IN: PCMCIA info (Not used)
708     /// @return : Buffer size.
709     //-------------------------------------------------------------------------------------------------
710 //     MS_U16 MDrv_PCMCIA_NegotiateBufferSize( PCMCIA_INFO *pInfo );
711 
712     //-------------------------------------------------------------------------------------------------
713     /// Write PCMCIA buffer size. (use V2 version: for CAM module select)
714     /// @ingroup PCMCIA_ToBeRemove
715     /// @param  u16BufferSize  \b IN: Buffer size
716     /// @return None
717     //-------------------------------------------------------------------------------------------------
718 //     void MDrv_PCMCIA_WriteBufferSize( MS_U16 u16BufferSize );
719 
720     //-------------------------------------------------------------------------------------------------
721     /// Check status bit. (use V2 version: for CAM module select)
722     /// @ingroup PCMCIA_ToBeRemove
723     /// @param  u8StatusBit      \b IN: Status bit which you want to check.
724     /// @return TRUE  : Status bit check success.
725     /// @return FALSE : Can't find the match status bit.
726     //-------------------------------------------------------------------------------------------------
727     MS_BOOL MDrv_PCMCIA_WaitForStatusBit( MS_U8 u8StatusBit );
728 
729     //-------------------------------------------------------------------------------------------------
730     /// Reset PCMCIA HW. (use V2 version: for CAM module select)
731     /// @ingroup PCMCIA_ToBeRemove
732     /// @return None
733     //-------------------------------------------------------------------------------------------------
734     void MDrv_PCMCIA_ResetHW( void );
735 
736     //-------------------------------------------------------------------------------------------------
737     /// Write data to attribute memory. (use V2 version: for CAM module select)
738     /// @ingroup PCMCIA_ToBeRemove
739     /// @param  wAddr          \b IN: Write address.
740     /// @param  bData          \b IN: Write data.
741     /// @return None
742     //-------------------------------------------------------------------------------------------------
743     void MDrv_PCMCIA_WriteAttribMem( MS_U16 wAddr, MS_U8 bData );
744 
745     //-------------------------------------------------------------------------------------------------
746     /// Copy data from attribute memory. (use V2 version: for CAM module select)
747     /// @ingroup PCMCIA_ToBeRemove
748     /// @param  u16Addr       \b IN: Read address.
749     /// @param  pDest           \b OUT: Copyed buffer.
750     /// @return None
751     //-------------------------------------------------------------------------------------------------
752     void MDrv_PCMCIA_ReadAttribMem( MS_U16 u16Addr, MS_U8 *pDest );
753 
754     //-------------------------------------------------------------------------------------------------
755     /// Write data to IO memory. (Only write 1 byte) (use V2 version: for CAM module select)
756     /// @ingroup PCMCIA_ToBeRemove
757     /// @param  wAddr         \b IN: Write address.
758     /// @param  bData          \b IN: Write data.
759     /// @return None
760     //-------------------------------------------------------------------------------------------------
761     void MDrv_PCMCIA_WriteIOMem( MS_U16 wAddr, MS_U8 bData );
762 
763     //-------------------------------------------------------------------------------------------------
764     /// Write data to IO memory. (Write long size data to the IO memory) (use V2 version: for CAM module select)
765     /// @ingroup PCMCIA_ToBeRemove
766     /// @param  u16Addr              \b IN: Write address.
767     /// @param  u8Value               \b IN: Write data. (Not used? It's use for 1 byte write)
768     /// @param  u16DataLen          \b IN: Write length.
769     /// @param  u8pWriteBuffer     \b IN: Write buffer.
770     /// @return None
771     //-------------------------------------------------------------------------------------------------
772     void MDrv_PCMCIA_WriteIOMemLong( MS_U16 u16Addr, MS_U8 u8Value, MS_U16 u16DataLen, MS_U8* u8pWriteBuffer);
773 
774     //-------------------------------------------------------------------------------------------------
775     /// Read data from IO memory. (Only read 1 byte) (use V2 version: for CAM module select)
776     /// @ingroup PCMCIA_ToBeRemove
777     /// @param  wAddr          \b IN: Read address.
778     /// @return: The data from PCMCIA IO memory.
779     //-------------------------------------------------------------------------------------------------
780     MS_U8 MDrv_PCMCIA_ReadIOMem( MS_U16 wAddr );
781 
782     //-------------------------------------------------------------------------------------------------
783     /// Get CAM detect interval time. (use V2 version: for CAM module select)
784     /// @ingroup PCMCIA_ToBeRemove
785     /// @return: The CAM detect interval time
786     //-------------------------------------------------------------------------------------------------
787 //     MS_U32 MDrv_PCMCIA_Get_CD_Interval( void );
788 
789     #if PCMCIA_IRQ_ENABLE
790     //-------------------------------------------------------------------------------------------------
791     /// Enable PCMCIA interrupt. (use V2 version: for CAM module select)
792     /// @ingroup PCMCIA_ToBeRemove
793     /// @param  bEnable      \b IN: Enable/Disable
794     /// @return None
795     //-------------------------------------------------------------------------------------------------
796         void MDrv_PCMCIA_Enable_Interrupt( MS_BOOL bEnable );
797 
798     //-------------------------------------------------------------------------------------------------
799     /// Set PCMCIA IRQ Status. (use V2 version: for CAM module select)
800     /// @ingroup PCMCIA_ToBeRemove
801     /// @param  Status        \b IN: TRUE/FALSE
802     /// @return None
803     //-------------------------------------------------------------------------------------------------
804 //         void MDrv_PCMCIA_Set_InterruptStatus( MS_BOOL Status );
805 
806     //-------------------------------------------------------------------------------------------------
807     /// Get PCMCIA IRQ Status. (use V2 version: for CAM module select)
808     /// @ingroup PCMCIA_ToBeRemove
809     /// @return : PCMCIA IRQ Status (TRUE/FALSE)
810     //-------------------------------------------------------------------------------------------------
811 //         MS_BOOL MDrv_PCMCIA_Get_InterruptStatus( void );
812 
813     //-------------------------------------------------------------------------------------------------
814     /// Set PCMCIA callback function.
815     /// @ingroup PCMCIA_ToBeRemove
816     /// @param  fnIsrCallback     \b IN: Callback function.
817     /// @return : PCMCIA IRQ Status (TRUE/FALSE)
818     //-------------------------------------------------------------------------------------------------
819         void MDrv_PCMCIA_InstarllIsrCallback( IsrCallback fnIsrCallback );
820     #endif
821 #endif
822 
823 #ifdef __cplusplus
824 }
825 #endif
826 
827 #endif // _DRV_PCMCIA_H_
828