xref: /utopia/UTPA2-700.0.x/mxlib/include/drvSC.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 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 ///////////////////////////////////////////////////////////////////////////////////////////////////
96 ///
97 /// @file   drvSC.h
98 /// @brief  SmartCard Driver Interface
99 /// @author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101 
102 /*! \defgroup G_SC SC interface (drvSC.h)
103     \ingroup  G_PERIPHERAL
104      <b>Features</b>
105      - SC driver init
106      - SC driver open
107      - Reset the smart card and get the ATR response data
108      - Send data to smart card
109      - Recv the data from smart card
110      - Send and recv data by T0 protocol
111      - Send and recv data by T1 protocol
112      - SC driver close
113      - SC driver exit
114 
115      <b> SC Block Diagram: </b> \n
116      The SC drver block diagram, all driver API are in user space, INT and data transfer are in kernel driver
117 
118      <b> Operation Code Flow: </b> \n
119      -# Call sc init
120      -# Call sc open
121      -# Reset sc and get atr
122      -# Call T0 send/recv if inserted card is T0 protocol
123      -# Call T1 send/recv if inserted card is T1protocol
124      -# Call sc close and then exit if want to exit the SC driver
125 
126      \defgroup G_SC_INIT Initialization Task relative
127      \ingroup  G_SC
128      \defgroup G_SC_COMMON Common Task relative
129      \ingroup  G_SC
130      \defgroup G_SC_CONTROL Control relative
131      \ingroup  G_SC
132      \defgroup G_SC_OTHER  other relative
133      \ingroup  G_SC
134      \defgroup G_SC_ToBeModified SC api to be modified
135      \ingroup  G_SC
136      \defgroup G_SC_ToBeRemove SC api to be removed
137      \ingroup  G_SC
138 */
139 
140 #ifndef __DRV_SC_H__
141 #define __DRV_SC_H__
142 
143 
144 #ifdef __cplusplus
145 extern "C"
146 {
147 #endif
148 
149 #include "MsDevice.h"
150 #include "UFO.h"
151 //-------------------------------------------------------------------------------------------------
152 //  Driver Capability
153 //-------------------------------------------------------------------------------------------------
154 
155 
156 //-------------------------------------------------------------------------------------------------
157 //  Macro and Define
158 //-------------------------------------------------------------------------------------------------
159 #define MSIF_SC_LIB_CODE            {'S','C'}    //Lib code
160 #define MSIF_SC_LIBVER              {'0','1'}            //LIB version
161 #define MSIF_SC_BUILDNUM            {'0','1'}            //Build Number
162 #define MSIF_SC_CHANGELIST          {'0','0','0','0','0','0','0','0'} //P4 ChangeList Number
163 
164 #define SC_DRV_VERSION              /* Character String for DRV/API version             */  \
165     MSIF_TAG,                       /* 'MSIF'                                           */  \
166     MSIF_CLASS,                     /* '00'                                             */  \
167     MSIF_CUS,                       /* 0x0000                                           */  \
168     MSIF_MOD,                       /* 0x0000                                           */  \
169     MSIF_CHIP,                                                                              \
170     MSIF_CPU,                                                                               \
171     MSIF_SC_LIB_CODE,               /* IP__                                             */  \
172     MSIF_SC_LIBVER,                 /* 0.0 ~ Z.Z                                        */  \
173     MSIF_SC_BUILDNUM,               /* 00 ~ 99                                          */  \
174     MSIF_SC_CHANGELIST,             /* CL#                                              */  \
175     MSIF_OS
176 
177 #define SC_ATR_LEN_MAX              33                                  ///< Maximum length of ATR
178 #define SC_ATR_LEN_MIN              2                                   ///< Minimum length of ATR
179 #define SC_HIST_LEN_MAX             15                                  ///< Maximum length of ATR history
180 #define SC_PPS_LEN_MAX              6                                   ///< Maximum length of PPS
181 #define SC_FIFO_SIZE                512                                 // Rx fifo size
182 
183 ///SC_Param.u8UartMode
184 #define SC_UART_CHAR_7              (0x02)
185 #define SC_UART_CHAR_8              (0x03)
186 #define SC_UART_STOP_1              (0x00)
187 #define SC_UART_STOP_2              (0x04)
188 #define SC_UART_PARITY_NO           (0x00)
189 #define SC_UART_PARITY_ODD          (0x08)
190 #define SC_UART_PARITY_EVEN         (0x08|0x10)
191 
192 #define SC_PROC_LOCK                (0xFE66)
193 #define SC_PROC_UNLOCK              (0x0)
194 
195 //-------------------------------------------------------------------------------------------------
196 //  Type and Structure
197 //-------------------------------------------------------------------------------------------------
198 
199 typedef struct _SC_Status
200 {
201     MS_BOOL                         bCardIn;                            ///< Card status
202 
203 } SC_Status;
204 
205 typedef enum _SC_DbgLv
206 {
207     E_SC_DBGLV_NONE,                                                    //no debug message
208     E_SC_DBGLV_ERR_ONLY,                                                //show error only
209     E_SC_DBGLV_REG_DUMP,                                                //show error & reg dump
210     E_SC_DBGLV_INFO,                                                    //show error & informaiton
211     E_SC_DBGLV_ALL,                                                     //show error, information & funciton name
212 } SC_DbgLv;
213 
214 /// SmartCard DDI error code
215 typedef enum
216 {
217     E_SC_FAIL,                                                          ///< Function fail
218     E_SC_OK,                                                            ///< No Error
219     E_SC_PPSFAIL,                                                       ///< Do PPS fail
220     E_SC_INVCONV,                                                       ///< Inverse convention
221     E_SC_CARDIN,                                                        ///< Card in
222     E_SC_CARDOUT,                                                       ///< Card out
223     E_SC_NODATA,                                                        ///< No data
224     E_SC_TIMEOUT,                                                       ///< Timeout
225     E_SC_OVERFLOW,                                                      ///< Rx data fifo overflow
226     E_SC_CRCERROR,                                                      ///< ATR checksum error
227     E_SC_DATAERROR,                                                     ///< Data error
228     E_SC_PARMERROR,                                                     ///< Parameter error
229 } SC_Result;
230 
231 /// SmartCard event
232 typedef enum
233 {
234     E_SC_EVENT_DATA,                                                    ///< Rx data valid
235     E_SC_EVENT_IN,                                                      ///< Card in
236     E_SC_EVENT_OUT,                                                     ///< Card out
237 
238 } SC_Event;
239 
240 /// SmartCard CLK setting
241 typedef enum
242 {
243     E_SC_CLK_3M,                                                        ///< 3 MHz
244     E_SC_CLK_4P5M,                                                      ///< 4.5 MHz
245     E_SC_CLK_6M,                                                        ///< 6 MHz
246     E_SC_CLK_13M,                                                        ///< 6 MHz
247     E_SC_CLK_4M,                                                        ///< 4 MHz
248 } SC_ClkCtrl;
249 
250 /// SmartCard VCC control mode
251 typedef enum
252 {
253     E_SC_VCC_CTRL_8024_ON,                                              ///< by external 8024 on
254     E_SC_VCC_CTRL_LOW,                                                  ///< by direct Vcc (low active)
255     E_SC_VCC_CTRL_HIGH,                                                 ///< by direct Vcc (high active)
256     E_SC_OCP_VCC_HIGH,
257     E_SC_VCC_VCC_ONCHIP_8024,
258 } SC_VccCtrl;
259 
260 // smart card 3V/5V control
261 typedef enum
262 {
263     E_SC_VOLTAGE_3_POINT_3V,                                              ///<3.3V
264     E_SC_VOLTAGE_5V,                                                      ///< 5V
265     E_SC_VOLTAGE_MAX
266 } SC_VoltageCtrl;
267 
268 typedef void(*P_SC_En5V_Callback)(MS_BOOL bEnable);
269 
270 
271 typedef enum
272 {
273     E_SC_HIGH_ACTIVE = 0x0,
274     E_SC_LOW_ACTIVE  = 0xff3
275 } SC_CardDetType;
276 
277 /// SmartCard configuration
278 typedef struct
279 {
280     MS_U8                           u8Protocal;                         ///< T=
281     SC_ClkCtrl                      eCardClk;                           ///< Clock
282     MS_U8                           u8UartMode;                         ///< Uart Mode
283     MS_U16                          u16ClkDiv;                          ///< Div
284     SC_VccCtrl                      eVccCtrl;
285     MS_U16                          u16Bonding;                         ///Chip Bonding type
286     P_SC_En5V_Callback              pfOCPControl;
287     MS_U8                           u8Convention;                       ///< Convention
288     SC_VoltageCtrl                  eVoltage;
289     SC_CardDetType                  u8CardDetInvert;
290 } SC_Param;
291 
292 /// SmartCard event callback
293 typedef void (*P_SC_Callback)(MS_U8 u8SCID, SC_Event eEvent);
294 
295 typedef struct _Smart_Dev
296 {
297 
298 } SC_Dev;
299 
300 
301 /// SmartCard Info
302 typedef struct
303 {
304     // SmsartCard Protocol
305     MS_U8                           u8Protocol;                         ///T= Protocol
306     MS_BOOL                         bSpecMode;                          ///Special mode
307     MS_U8                           pu8Atr[SC_ATR_LEN_MAX];             ///Atr buffer
308     MS_U16                          u16AtrLen;                          ///Atr length
309     MS_U8                           pu8Hist[SC_HIST_LEN_MAX];           ///History buffer
310     MS_U16                          u16HistLen;                         ///History length
311     MS_U8                           u8Fi;                               ///Fi
312     MS_U8                           u8Di;                               ///Di
313 #ifdef UFO_PUBLIC_HEADER_212
314     MS_U8                           u8N;                              ////N
315 #endif
316     // Device Setting
317     MS_BOOL                         bInited;
318     MS_BOOL                         bOpened;                           ///Open
319     MS_BOOL                         bCardIn;                            ///Status care in
320     MS_BOOL                         blast_cardin;
321     SC_ClkCtrl                      eCardClk;                           ///< Clock
322     MS_U8                           u8UartMode;                         ///< Uart Mode
323     SC_VccCtrl                      eVccCtrl;
324     MS_U16                          u16ClkDiv;                         ///< Div
325     MS_U16                          u16Bonding; //@TODO: how to take care of bonding?????
326     P_SC_En5V_Callback              pfEn5V;
327     MS_U8                           u8Convention;
328 
329     MS_U8                           u8FifoRx[SC_FIFO_SIZE];
330     MS_U16                          u16FifoRxRead;
331     MS_U16                          u16FifoRxWrite;
332 
333     MS_U8                           u8FifoTx[SC_FIFO_SIZE];
334     MS_U16                          u16FifoTxRead;
335     MS_U16                          u16FifoTxWrite;
336     P_SC_Callback                   pfNotify;                           ///Call back funtcion
337 
338     MS_BOOL                         bLastCardIn;
339     MS_S32                          s32DevFd;
340 #ifdef UFO_PUBLIC_HEADER_212
341     SC_VoltageCtrl                  eVoltage;
342 #endif
343 } SC_Info;
344 
345 
346 /// SmartCard Caps
347 typedef struct
348 {
349     MS_U8                           u8DevNum;                           ///SmartCard Device Number
350 
351 } SC_Caps;
352 
353 ///Define SC Command Index
354 typedef enum
355 {
356     //MIPS-->51 Command Index
357     SC_CMDIDX_RAW_EXCHANGE = 0x01,                  /// SC Command Index is Raw Data Exchange
358     SC_CMDIDX_GET_ATR      = 0x02,                  /// SC Command Index is Get ATR
359     SC_CMDIDX_SEND         = 0x03,                  /// SC Command Index is Send Data
360     SC_CMDIDX_RECV         = 0x04,                  /// SC Command Index is Receive Data
361 
362     SC_CMDIDX_ACK_51ToMIPS = 0x30,                  /// SC Command Index is ACK 51 To MIPS
363 
364     //51->MIPS Command Index
365     SC_CMDIDX_ACK_MIPSTo51 = 0xA0,                  /// SC Command Index is ACK MIPS To 51
366 
367 } SC_CmdIndex;
368 
369 
370 ///Define SC Acknowledge Flags
371 typedef enum
372 {
373     E_SC_ACKFLG_NULL                = 0,            /// Ack flag for NULL
374     E_SC_ACKFLG_WAIT_RAW_EXCHANGE   = (1<<0),       /// Ack flag for Raw Exchange
375     E_SC_ACKFLG_WAIT_GET_ATR        = (1<<1),       /// Ack flag for ATR
376     E_SC_ACKFLG_WAIT_SEND           = (1<<2),       /// Ack flag for Sending
377     E_SC_ACKFLG_WAIT_RECV           = (1<<3),       /// Ack flag for Receiving
378 
379 } SC_AckFlags;
380 
381 typedef struct __attribute__ ((packed, aligned (4096)))
382 {
383     MS_U8  u8SCID;
384     MS_U16 u16DataLen;       /* Send and reply data length*/
385     MS_U16 u16ReplyMaxLen;   /* Maximum length of reply data */
386     MS_U8  u8Data[259];      /* T=0, 256 data bytes plus the two status words SW1 and SW2
387                                                 T=1, 254 INF bytes plus NAD, PCB, LEN, and two EDC bytes
388                                                 Send and reply data buffer*/
389 } SC_DataCfg;
390 
391 /// SmartCard Caps
392 typedef struct
393 {
394     MS_PHY   u32DataBuffAddr;                            ///SmartCard Data Buffer Address, 4K alignment
395     MS_PHY   u32FwBuffAddr;                              ///SmartCard Firmware Buffer Address, 64K alignment
396 } SC_BuffAddr;
397 
398 //-------------------------------------------------------------------------------------------------
399 //  Function and Variable
400 //-------------------------------------------------------------------------------------------------
401 //-------------------------------------------------------------------------------------------------
402 /// MOBF Encrypt
403 /// @ingroup G_SC_INIT
404 /// @param u32Key \b IN: Key
405 /// @param bEnable \b IN: TRUE/FLASE
406 /// @return DRVAESDMA_OK : Success
407 /// @return Others : Fail
408 //-------------------------------------------------------------------------------------------------
409 SC_Result       MDrv_SC_Init(MS_U8 u8SCID);
410 //-------------------------------------------------------------------------------------------------
411 /// MOBF Encrypt
412 /// @ingroup G_SC_CONTROL
413 /// @param u32Key \b IN: Key
414 /// @param bEnable \b IN: TRUE/FLASE
415 /// @return DRVAESDMA_OK : Success
416 /// @return Others : Fail
417 //-------------------------------------------------------------------------------------------------
418 SC_Result       MDrv_SC_Open(MS_U8 u8SCID, MS_U8 u8Protocol, SC_Param* pParam, P_SC_Callback pfSmartNotify);
419 //-------------------------------------------------------------------------------------------------
420 /// MOBF Encrypt
421 /// @ingroup G_SC_CONTROL
422 /// @param u32Key \b IN: Key
423 /// @param bEnable \b IN: TRUE/FLASE
424 /// @return DRVAESDMA_OK : Success
425 /// @return Others : Fail
426 //-------------------------------------------------------------------------------------------------
427 SC_Result       MDrv_SC_Config(MS_U8 u8SCID, SC_Param* pParam);
428 //-------------------------------------------------------------------------------------------------
429 /// MOBF Encrypt
430 /// @ingroup G_SC_CONTROL
431 /// @param u32Key \b IN: Key
432 /// @param bEnable \b IN: TRUE/FLASE
433 /// @return DRVAESDMA_OK : Success
434 /// @return Others : Fail
435 //-------------------------------------------------------------------------------------------------
436 SC_Result       MDrv_SC_Close(MS_U8 u8SCID);
437 //-------------------------------------------------------------------------------------------------
438 /// MOBF Encrypt
439 /// @ingroup G_SC_CONTROL
440 /// @param u32Key \b IN: Key
441 /// @param bEnable \b IN: TRUE/FLASE
442 /// @return DRVAESDMA_OK : Success
443 /// @return Others : Fail
444 //-------------------------------------------------------------------------------------------------
445 SC_Result       MDrv_SC_Reset(MS_U8 u8SCID, SC_Param* pParam);
446 //-------------------------------------------------------------------------------------------------
447 /// MOBF Encrypt
448 /// @ingroup G_SC_CONTROL
449 /// @param u32Key \b IN: Key
450 /// @param bEnable \b IN: TRUE/FLASE
451 /// @return DRVAESDMA_OK : Success
452 /// @return Others : Fail
453 //-------------------------------------------------------------------------------------------------
454 SC_Result       MDrv_SC_Activate(MS_U8 u8SCID);
455 //-------------------------------------------------------------------------------------------------
456 /// MOBF Encrypt
457 /// @ingroup G_SC_CONTROL
458 /// @param u32Key \b IN: Key
459 /// @param bEnable \b IN: TRUE/FLASE
460 /// @return DRVAESDMA_OK : Success
461 /// @return Others : Fail
462 //-------------------------------------------------------------------------------------------------
463 SC_Result       MDrv_SC_Deactivate(MS_U8 u8SCID);
464 //-------------------------------------------------------------------------------------------------
465 /// MOBF Encrypt
466 /// @ingroup G_SC_CONTROL
467 /// @param u32Key \b IN: Key
468 /// @param bEnable \b IN: TRUE/FLASE
469 /// @return DRVAESDMA_OK : Success
470 /// @return Others : Fail
471 //-------------------------------------------------------------------------------------------------
472 SC_Result       MDrv_SC_Reset_ATR(MS_U8 u8SCID, SC_Param* pParam, MS_U8 *pu8Atr, MS_U16 *pu16AtrLen, MS_U8 *pu8His, MS_U16 *pu16HisLen);
473 //-------------------------------------------------------------------------------------------------
474 /// MOBF Encrypt
475 /// @ingroup G_SC_CONTROL
476 /// @param u32Key \b IN: Key
477 /// @param bEnable \b IN: TRUE/FLASE
478 /// @return DRVAESDMA_OK : Success
479 /// @return Others : Fail
480 //-------------------------------------------------------------------------------------------------
481 SC_Result       MDrv_SC_PPS(MS_U8 u8SCID);
482 //-------------------------------------------------------------------------------------------------
483 /// MOBF Encrypt
484 /// @ingroup G_SC_CONTROL
485 /// @param u32Key \b IN: Key
486 /// @param bEnable \b IN: TRUE/FLASE
487 /// @return DRVAESDMA_OK : Success
488 /// @return Others : Fail
489 //-------------------------------------------------------------------------------------------------
490 SC_Result       MDrv_SC_Send(MS_U8 u8SCID, MS_U8 *pu8SendData, MS_U16 u16SendDataLen, MS_U32 u32TimeoutMs);
491 //-------------------------------------------------------------------------------------------------
492 /// MOBF Encrypt
493 /// @ingroup G_SC_CONTROL
494 /// @param u32Key \b IN: Key
495 /// @param bEnable \b IN: TRUE/FLASE
496 /// @return DRVAESDMA_OK : Success
497 /// @return Others : Fail
498 //-------------------------------------------------------------------------------------------------
499 SC_Result       MDrv_SC_Recv(MS_U8 u8SCID, MS_U8 *pu8ReadData, MS_U16 *u16ReadDataLen, MS_U32 u32TimeoutMs);
500 //-------------------------------------------------------------------------------------------------
501 /// MOBF Encrypt
502 /// @ingroup G_SC_ToBeRemove
503 /// @param u32Key \b IN: Key
504 /// @param bEnable \b IN: TRUE/FLASE
505 /// @return DRVAESDMA_OK : Success
506 /// @return Others : Fail
507 //-------------------------------------------------------------------------------------------------
508 SC_Result       MDrv_SC_T0_SendRecv(MS_U8 u8SCID, MS_U8 *pu8SendData, MS_U16 u16SendLen, MS_U8 *pu8RecvData, MS_U16 *pu16RecvLen);
509 //-------------------------------------------------------------------------------------------------
510 /// MOBF Encrypt
511 /// @ingroup G_SC_ToBeRemove
512 /// @param u32Key \b IN: Key
513 /// @param bEnable \b IN: TRUE/FLASE
514 /// @return DRVAESDMA_OK : Success
515 /// @return Others : Fail
516 //-------------------------------------------------------------------------------------------------
517 SC_Result       MDrv_SC_T1_SendRecv(MS_U8 u8SCID, MS_U8 *pu8SendData, MS_U16 *u16SendDataLen, MS_U8 *pu8ReadData, MS_U16 *u16ReadDataLen);
518 //-------------------------------------------------------------------------------------------------
519 /// MOBF Encrypt
520 /// @ingroup G_SC_ToBeRemove
521 /// @param u32Key \b IN: Key
522 /// @param bEnable \b IN: TRUE/FLASE
523 /// @return DRVAESDMA_OK : Success
524 /// @return Others : Fail
525 //-------------------------------------------------------------------------------------------------
526 SC_Result       MDrv_SC_T14_SendRecv(MS_U8 u8SCID, MS_U8 *pu8SendData, MS_U16 u16SendLen, MS_U8 *pu8RecvData, MS_U16 *pu16RecvLen);
527 //-------------------------------------------------------------------------------------------------
528 /// MOBF Encrypt
529 /// @ingroup G_SC_CONTROL
530 /// @param u32Key \b IN: Key
531 /// @param bEnable \b IN: TRUE/FLASE
532 /// @return DRVAESDMA_OK : Success
533 /// @return Others : Fail
534 //-------------------------------------------------------------------------------------------------
535 SC_Result       MDrv_SC_Exit(MS_U8 u8SCID);
536 //-------------------------------------------------------------------------------------------------
537 /// MOBF Encrypt
538 /// @ingroup G_SC_CONTROL
539 /// @param u32Key \b IN: Key
540 /// @param bEnable \b IN: TRUE/FLASE
541 /// @return DRVAESDMA_OK : Success
542 /// @return Others : Fail
543 //-------------------------------------------------------------------------------------------------
544 SC_Result       MDrv_SC_GetATR(MS_U8 u8SCID, MS_U32 u32TimeOut,MS_U8 *pu8Atr, MS_U16 *pu16AtrLen, MS_U8 *pu8His, MS_U16 *pu16HisLen);
545 //-------------------------------------------------------------------------------------------------
546 /// MOBF Encrypt
547 /// @ingroup G_SC_COMMON
548 /// @param u32Key \b IN: Key
549 /// @param bEnable \b IN: TRUE/FLASE
550 /// @return DRVAESDMA_OK : Success
551 /// @return Others : Fail
552 //-------------------------------------------------------------------------------------------------
553 const SC_Info*  MDrv_SC_GetInfo(MS_U8 u8SCID);
554 //-------------------------------------------------------------------------------------------------
555 /// MOBF Encrypt
556 /// @ingroup G_SC_COMMON
557 /// @param u32Key \b IN: Key
558 /// @param bEnable \b IN: TRUE/FLASE
559 /// @return DRVAESDMA_OK : Success
560 /// @return Others : Fail
561 //-------------------------------------------------------------------------------------------------
562 SC_Result       MDrv_SC_GetLibVer(const MSIF_Version **ppVersion);
563 //-------------------------------------------------------------------------------------------------
564 /// MOBF Encrypt
565 /// @ingroup G_SC_COMMON
566 /// @param u32Key \b IN: Key
567 /// @param bEnable \b IN: TRUE/FLASE
568 /// @return DRVAESDMA_OK : Success
569 /// @return Others : Fail
570 //-------------------------------------------------------------------------------------------------
571 SC_Result       MDrv_SC_GetStatus(MS_U8 u8SCID, SC_Status *pStatus);
572 //-------------------------------------------------------------------------------------------------
573 /// MOBF Encrypt
574 /// @ingroup G_SC_COMMON
575 /// @param u32Key \b IN: Key
576 /// @param bEnable \b IN: TRUE/FLASE
577 /// @return DRVAESDMA_OK : Success
578 /// @return Others : Fail
579 //-------------------------------------------------------------------------------------------------
580 void            MDrv_SC_SetDbgLevel(SC_DbgLv eLevel);
581 //-------------------------------------------------------------------------------------------------
582 /// MOBF Encrypt
583 /// @ingroup G_SC_CONTROL
584 /// @param u32Key \b IN: Key
585 /// @param bEnable \b IN: TRUE/FLASE
586 /// @return DRVAESDMA_OK : Success
587 /// @return Others : Fail
588 //-------------------------------------------------------------------------------------------------
589 SC_Result       MDrv_SC_SetPPS(MS_U8 u8SCID, MS_U8 u8SCProtocol, MS_U8 u8Di,MS_U8 u8Fi);
590 //-------------------------------------------------------------------------------------------------
591 /// MOBF Encrypt
592 /// @ingroup G_SC_COMMON
593 /// @param u32Key \b IN: Key
594 /// @param bEnable \b IN: TRUE/FLASE
595 /// @return DRVAESDMA_OK : Success
596 /// @return Others : Fail
597 //-------------------------------------------------------------------------------------------------
598 SC_Result       MDrv_SC_ClearState(MS_U8 u8SCID);
599 //-------------------------------------------------------------------------------------------------
600 /// MOBF Encrypt
601 /// @ingroup G_SC_CONTROL
602 /// @param u32Key \b IN: Key
603 /// @param bEnable \b IN: TRUE/FLASE
604 /// @return DRVAESDMA_OK : Success
605 /// @return Others : Fail
606 //-------------------------------------------------------------------------------------------------
607 SC_Result       MDrv_SC_PowerOff(void);
608 //-------------------------------------------------------------------------------------------------
609 /// MOBF Encrypt
610 /// @ingroup G_SC_CONTROL
611 /// @param u32Key \b IN: Key
612 /// @param bEnable \b IN: TRUE/FLASE
613 /// @return DRVAESDMA_OK : Success
614 /// @return Others : Fail
615 //-------------------------------------------------------------------------------------------------
616 SC_Result       MDrv_SC_SetGuardTime(MS_U8 u8SCID, MS_U8 u8GuardTime);
617 
618 //-------------------------------------------------------------------------------------------------
619 /// MOBF Encrypt
620 /// @ingroup G_SC_ToBeRemove
621 /// @param u32Key \b IN: Key
622 /// @param bEnable \b IN: TRUE/FLASE
623 /// @return DRVAESDMA_OK : Success
624 /// @return Others : Fail
625 //-------------------------------------------------------------------------------------------------
626 SC_Result       MDrv_SC_Task_Proc(void);
627 //-------------------------------------------------------------------------------------------------
628 /// MOBF Encrypt
629 /// @ingroup G_SC_ToBeRemove
630 /// @param u32Key \b IN: Key
631 /// @param bEnable \b IN: TRUE/FLASE
632 /// @return DRVAESDMA_OK : Success
633 /// @return Others : Fail
634 //-------------------------------------------------------------------------------------------------
635 MS_BOOL         MDrv_SC_ISR_Proc(MS_U8 u8SCID);
636 //-------------------------------------------------------------------------------------------------
637 /// MOBF Encrypt
638 /// @ingroup G_SC_ToBeRemove
639 /// @param u32Key \b IN: Key
640 /// @param bEnable \b IN: TRUE/FLASE
641 /// @return DRVAESDMA_OK : Success
642 /// @return Others : Fail
643 //-------------------------------------------------------------------------------------------------
644 SC_Result       MDrv_SC_RawExchange(MS_U8 u8SCID, MS_U8 *pu8SendData, MS_U16 *u16SendDataLen, MS_U8 *pu8ReadData, MS_U16 *u16ReadDataLen);
645 //-------------------------------------------------------------------------------------------------
646 /// MOBF Encrypt
647 /// @ingroup G_SC_ToBeRemove
648 /// @param u32Key \b IN: Key
649 /// @param bEnable \b IN: TRUE/FLASE
650 /// @return DRVAESDMA_OK : Success
651 /// @return Others : Fail
652 //-------------------------------------------------------------------------------------------------
653 SC_Result       MDrv_SC_RawExchangeTimeout(MS_U8 u8SCID, MS_U8 *pu8SendData, MS_U16 *u16SendDataLen, MS_U8 *pu8ReadData, MS_U16 *u16ReadDataLen, MS_U32 u32TimeoutMs);
654 //-------------------------------------------------------------------------------------------------
655 /// MOBF Encrypt
656 /// @ingroup G_SC_ToBeRemove
657 /// @param u32Key \b IN: Key
658 /// @param bEnable \b IN: TRUE/FLASE
659 /// @return DRVAESDMA_OK : Success
660 /// @return Others : Fail
661 //-------------------------------------------------------------------------------------------------
662 SC_Result       MDrv_SC_SetBuffAddr(SC_BuffAddr *pScBuffAddr);
663 //-------------------------------------------------------------------------------------------------
664 /// MOBF Encrypt
665 /// @ingroup G_SC_ToBeRemove
666 /// @param u32Key \b IN: Key
667 /// @param bEnable \b IN: TRUE/FLASE
668 /// @return DRVAESDMA_OK : Success
669 /// @return Others : Fail
670 //-------------------------------------------------------------------------------------------------
671 MS_BOOL         MDrv_SC_CardVoltage_Config(MS_U8 u8SCID, SC_VoltageCtrl eVoltage);
672 //-------------------------------------------------------------------------------------------------
673 /// MOBF Encrypt
674 /// @ingroup G_SC_ToBeRemove
675 /// @param u32Key \b IN: Key
676 /// @param bEnable \b IN: TRUE/FLASE
677 /// @return DRVAESDMA_OK : Success
678 /// @return Others : Fail
679 //-------------------------------------------------------------------------------------------------
680 void            MDrv_SC_EnableTimeout(MS_BOOL bTimeout);
681 //-------------------------------------------------------------------------------------------------
682 /// MOBF Encrypt
683 /// @ingroup G_SC_COMMON
684 /// @param u32Key \b IN: Key
685 /// @param bEnable \b IN: TRUE/FLASE
686 /// @return DRVAESDMA_OK : Success
687 /// @return Others : Fail
688 //-------------------------------------------------------------------------------------------------
689 MS_U32          MDrv_SC_SetPowerState(EN_POWER_MODE u16PowerState);
690 
691 #ifdef __cplusplus
692 }
693 #endif
694 
695 #endif // __DRV_SC_H__
696