source: svn/newcon3bcm2_21bu/nexus/modules/smartcard/7552/include/nexus_smartcard.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 21.8 KB
Line 
1/***************************************************************************
2*     (c)2004-2011 Broadcom Corporation
3*
4*  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5*  and may only be used, duplicated, modified or distributed pursuant to the terms and
6*  conditions of a separate, written license agreement executed between you and Broadcom
7*  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8*  no license (express or implied), right to use, or waiver of any kind with respect to the
9*  Software, and Broadcom expressly reserves all rights in and to the Software and all
10*  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11*  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12*  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13*
14*  Except as expressly set forth in the Authorized License,
15*
16*  1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17*  secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18*  and to use this information only in connection with your use of Broadcom integrated circuit products.
19*
20*  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21*  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22*  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23*  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24*  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25*  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26*  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27*  USE OR PERFORMANCE OF THE SOFTWARE.
28*
29*  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30*  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31*  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32*  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33*  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34*  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35*  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36*  ANY LIMITED REMEDY.
37*
38* $brcm_Workfile: nexus_smartcard.h $
39* $brcm_Revision: 18 $
40* $brcm_Date: 5/26/11 3:10p $
41*
42* API Description:
43*   API name: Smartcard
44*    Specific APIs related to SMARTCARD Control.
45*
46* Revision History:
47*
48* $brcm_Log: /nexus/modules/smartcard/7400/include/nexus_smartcard.h $
49*
50* 18   5/26/11 3:10p erickson
51* SW7346-228: add NEXUS_SmartcardSettings.resetCycles
52*
53* 17   4/11/11 4:38p erickson
54* SW7346-138: add NEXUS_SmartcardSettings.atrReceiveTime
55*
56* 16   4/8/11 12:39p erickson
57* SW7405-5210: add NEXUS_SmartcardStatus.iccClockFrequency
58*
59* 15   2/16/11 1:04p erickson
60* SW7420-1491: add nelem required with nelem_out
61*
62* 14   2/15/11 2:12p erickson
63* SW7420-1491: change to nelem and nelem_out attributes
64*
65* 13   2/7/11 11:13a erickson
66* SW7346-25: added NEXUS_SmartcardSettings.sourceClockFreq
67*
68* 12   2/7/11 9:51a erickson
69* SW7400-2841: add NEXUS_SmartcardVcc to fix nexus/magnum mismatch
70*
71* 11   9/28/10 2:02p erickson
72* SW7420-1123: fix attr hints for variable size param
73*
74* 10   8/24/10 3:37p mphillip
75* SW7125-598: Add IFSD as a parameter to the settings structure
76*
77* 9   8/16/10 4:41p mphillip
78* SW7405-4023: Add NEXUS_Smartcard_Deactivate
79*
80* 8   8/2/10 8:56p bandrews
81* SW7125-478: Currently the ATR(answer to reset) is passed through to the
82*  application. Its the resposibility of the application to decode the
83*  atr. But, once decoded, the application can use
84*  NEXUS_Smartcard_SetSettings() to set the desired parameters. So,
85*  deleting the api NEXUS_Smartcard_SetParamsFromAtr() as it is
86*  redundant. Please refer to the smartcard.c and smartcard_t1.c in
87*  nexus/examples/io for further details as to how to decode the ATR.
88*
89* 7   1/27/10 3:24p mphillip
90* SW7405-3841: Expose connect directly PI variable in Nexus
91*
92* 6   1/26/10 1:23p mphillip
93* SW7400-2551: Add pinmux and vcc settings
94*
95* 5   9/30/09 2:01p erickson
96* SW7400-2551: add NEXUS_Smartcard_PowerIcc
97*
98* 4   4/29/09 12:29p erickson
99* PR54618: added NEXUS_SmartcardSettings.baudDiv
100*
101* 3   8/19/08 2:19p erickson
102* PR45615: add smartcard settings
103*
104* 2   5/28/08 11:01a erickson
105* PR40034: fix attr hint for kernel mode
106*
107* 1   5/19/08 12:02p vishk
108* PR 40034: Develop Nexus Smartcard Interface/Module.
109*
110***************************************************************************/
111#ifndef NEXUS_SMARTCARD_H__
112#define NEXUS_SMARTCARD_H__
113
114#ifdef __cplusplus
115extern "C" {
116#endif
117
118/***************************************************************************
119Summary:
120Handle for the Smartcard Interface.
121
122Description:
123
124See Also:
125NEXUS_Smartcard_Open
126***************************************************************************/
127typedef struct NEXUS_Smartcard *NEXUS_SmartcardHandle;
128
129/***************************************************************************
130Summary:
131Smartcard error status enum.
132
133Description:
134
135See Also:
136NEXUS_Smartcard_Open
137***************************************************************************/
138typedef enum NEXUS_SmartcardError
139{
140    NEXUS_SmartcardError_eNoError,
141    NEXUS_SmartcardError_eRxParity,
142    NEXUS_SmartcardError_eTxParity,
143    NEXUS_SmartcardError_eRxTimeout,
144    NEXUS_SmartcardError_eTxTimeout,
145    NEXUS_SmartcardError_eHardwareFailure,
146    NEXUS_SmartcardError_eResetTerminal, /* requires a call to NEXUS_SmartCard_Reset() */
147    NEXUS_SmartcardError_eMax
148} NEXUS_SmartcardError;
149
150/***************************************************************************
151Summary:
152Smartcard state enum.
153
154Description:
155This represents the current state of the given slot and card.
156
157See Also:
158NEXUS_Smartcard_Open
159***************************************************************************/
160typedef enum NEXUS_SmartcardState
161{
162    NEXUS_SmartcardState_eUnknown = 0, /* Unknown state (perhaps not yet initialized).  Persistent. */
163    NEXUS_SmartcardState_eColdResetting, /* A cold reset has been requested but is not yet complete.  Transient. */
164    NEXUS_SmartcardState_eWarmResetting, /* A warm reset has been requested but is not yet complete.  Transient. */
165    NEXUS_SmartcardState_eResetDone, /* The slot/card reset has completed.  Persistent. */
166    NEXUS_SmartcardState_eActivating, /* The slot/card is currently being activated, but activation is not yet complete.  Transient. */
167    NEXUS_SmartcardState_eReceiveDecodeAtr, /* The ATR is being received or decoded.  Transient. */
168    NEXUS_SmartcardState_eReady, /* The slot/card is initialized and is awaiting sends/receives.  Persistent. */
169    NEXUS_SmartcardState_eTransmitting, /* The slot/card is currently transmitting. Transient. */
170    NEXUS_SmartcardState_eTransmitted, /* The slot/card has completed its transmission. Persistent. */
171    NEXUS_SmartcardState_eReceiving, /* The slot/card is currently receiving.  Transient. */
172    NEXUS_SmartcardState_eIgnore, /* The slot/card is ignoring events/commands. Persistent. */
173    NEXUS_SmartcardState_eInitialized, /* The slot/card has been initialized, but the ATR has not yet been received.  Persistent. */
174    NEXUS_SmartcardState_eMax /* A value indicating the total number of possible states.  The state returned from NEXUS_SmartCard_GetStatus should never exceed this value. */
175} NEXUS_SmartcardState;
176
177/***************************************************************************
178Summary:
179Status information returned by NEXUS_Smartcard_GetStatus.
180
181Description:
182
183See Also:
184NEXUS_Smartcard_Open
185***************************************************************************/
186typedef struct NEXUS_SmartcardStatus
187{
188    bool cardPresent;
189    NEXUS_SmartcardError err;
190    NEXUS_SmartcardState state;
191    unsigned iccClockFrequency; /* units of Hz */
192} NEXUS_SmartcardStatus;
193
194/***************************************************************************
195Summary:
196Smartcard protocol enum definition.
197
198Description:
199
200See Also:
201NEXUS_Smartcard_Open
202***************************************************************************/
203typedef enum NEXUS_SmartcardProtocol
204{
205    NEXUS_SmartcardProtocol_eUnknown,
206    NEXUS_SmartcardProtocol_eT0,
207    NEXUS_SmartcardProtocol_eT1,
208    NEXUS_SmartcardProtocol_eT14,
209    NEXUS_SmartcardProtocol_eMax
210} NEXUS_SmartcardProtocol;
211
212/***************************************************************************
213Summary:
214Smartcard standard enum definition.
215
216Description:
217Used in NEXUS_SmartcardSettings
218***************************************************************************/
219typedef enum NEXUS_SmartcardStandard
220{
221    NEXUS_SmartcardStandard_eUnknown,
222    NEXUS_SmartcardStandard_eNds,
223    NEXUS_SmartcardStandard_eIso,
224    NEXUS_SmartcardStandard_eEmv1996,
225    NEXUS_SmartcardStandard_eEmv2000,
226    NEXUS_SmartcardStandard_eIrdeto,
227    NEXUS_SmartcardStandard_eArib,
228    NEXUS_SmartcardStandard_eMt,
229    NEXUS_SmartcardStandard_eConax,
230    NEXUS_SmartcardStandard_eEs,
231    NEXUS_SmartcardStandard_eNdsNoFlowControl,
232    NEXUS_SmartcardStandard_eMax
233} NEXUS_SmartcardStandard;
234
235/***************************************************************************
236Summary:
237This enum is to identify the unit of timer value.
238
239Description:
240See Also:
241
242****************************************************************************/
243typedef enum NEXUS_TimerUnit {
244    NEXUS_TimerUnit_eEtu,       /* in Elementary Time Units */
245    NEXUS_TimerUnit_eClk,       /* in raw clock cycles that smart card receives */
246    NEXUS_TimerUnit_eMilliSec,  /* in milliseconds */
247    NEXUS_TimerUnit_eMax
248} NEXUS_TimerUnit;
249
250/***************************************************************************
251Summary:
252The timer value that application set to or get from the smartcard.
253
254Description:
255
256See Also:
257
258****************************************************************************/
259typedef struct NEXUS_TimerValue
260{
261    uint32_t        value;    /* timer value */
262    NEXUS_TimerUnit unit;   /* units */
263} NEXUS_TimerValue;
264
265/***************************************************************************
266Summary:
267This enum is to identify error detect code (EDC) encoding.
268
269Description:
270This enumeration defines the supported error detect code (EDC) encoding .
271
272See Also:
273
274
275****************************************************************************/
276typedef enum NEXUS_EdcEncode {
277    NEXUS_EdcEncode_eLrd,
278    NEXUS_EdcEncode_eCrc,
279    NEXUS_EdcEncode_eMax
280} NEXUS_EdcEncode;
281
282/***************************************************************************
283Summary:
284The configuration of EDC setting for T=1 protocol only.
285
286Description:
287
288See Also:
289
290
291****************************************************************************/
292typedef struct NEXUS_EdcSetting
293{
294    NEXUS_EdcEncode edcEncode;   /* EDC encoding */
295    bool    isEnabled;
296} NEXUS_EdcSetting;
297
298/***************************************************************************
299Summary:
300This enum is to identify read or write a specific register.
301
302Description:
303This enumeration defines read or write of a smart card register.
304
305See Also:
306
307
308****************************************************************************/
309typedef enum NEXUS_ScPresMode {
310    NEXUS_ScPresMode_eDebounce = 0,
311    NEXUS_ScPresMode_eMask,
312    NEXUS_ScPresMode_eMax
313}  NEXUS_ScPresMode;
314
315/***************************************************************************
316Summary:
317The configuration of Smartcard Pres Debounce.
318
319Description:
320
321See Also:
322
323****************************************************************************/
324typedef struct NEXUS_ScPresDbInfo
325{
326    NEXUS_ScPresMode    scPresMode;
327    bool                isEnabled;
328    uint8_t             dbWidth;
329} NEXUS_ScPresDbInfo;
330
331/***************************************************************************
332Summary:
333This enum is to identify action for NEXUS_Smartcard_ResetCard function.
334
335Description:
336This enumeration defines the supported action for NEXUS_Smartcard_ResetCard function.
337
338See Also:
339NEXUS_Smartcard_ResetCard
340****************************************************************************/
341typedef enum NEXUS_ResetCardAction
342{
343    NEXUS_ResetCardAction_eNoAction = 0,
344    NEXUS_ResetCardAction_eReceiveAndDecode,
345    NEXUS_ResetCardAction_eMax
346} NEXUS_ResetCardAction;
347
348/***************************************************************************
349Summary:
350This enum is to identify action for NEXUS_Smartcard_PowerIcc function.
351
352Description:
353
354See Also:
355
356****************************************************************************/
357typedef enum NEXUS_SmartcardPowerIcc {
358    NEXUS_SmartcardPowerIcc_ePowerDown = 0,   /* power down the ICC and request deactivation of the contact */
359    NEXUS_SmartcardPowerIcc_ePowerUp = 1,    /* power up the ICC and request activation of the contact */
360    NEXUS_SmartcardPowerIcc_eMax
361} NEXUS_SmartcardPowerIcc;
362
363/***************************************************************************
364Summary:
365Voltage level for the smartcard interface
366****************************************************************************/
367typedef enum NEXUS_SmartcardVcc {
368    NEXUS_SmartcardVcc_e5V = 0,   /* 5v is default value */
369    NEXUS_SmartcardVcc_e3V = 1,   /* 3v */
370    NEXUS_SmartcardVcc_eMax
371} NEXUS_SmartcardVcc;
372
373/***************************************************************************
374Summary:
375Smartcard settings structure.
376
377Description:
378Smartcard settings structure, used by NEXUS_Smartcard_Open.
379This allows protocol (T=0, T=1, T=14) and standard (NDS, ISO, EMV2000, IRDETO) to be selected.
380***************************************************************************/
381typedef struct NEXUS_SmartcardSettings
382{
383    NEXUS_SmartcardProtocol protocol;
384    NEXUS_SmartcardStandard standard;
385    uint8_t                 fFactor;
386    uint8_t                 dFactor;
387    uint8_t                 extClockDivisor;
388    uint8_t                 txRetries;
389    uint8_t                 rxRetries;
390    uint8_t                 baudDiv;
391    NEXUS_TimerValue        workWaitTime;
392    NEXUS_TimerValue        blockWaitTime;
393    NEXUS_TimerValue        extraGuardTime;
394    NEXUS_TimerValue        blockGuardTime;
395    uint32_t                characterWaitTime;
396    NEXUS_EdcSetting        edcSetting;
397    NEXUS_TimerValue        timeOut;
398    bool                    autoDeactiveReq;
399    bool                    nullFilter;
400    NEXUS_ScPresDbInfo      scPresDbInfo;
401    NEXUS_ResetCardAction   resetCardAction;
402    NEXUS_TimerValue        blockWaitTimeExt;
403    bool                    isPresHigh;
404    NEXUS_CallbackDesc      insertCard; /* Called when a card is inserted */
405    NEXUS_CallbackDesc      removeCard; /* Called when a card is removed */
406    bool                    setPinmux; /* Only applies during NEXUS_Smartcard_Open. */
407    bool                    setVcc; /* If true, Sets Vcc to vcc volts */
408    NEXUS_SmartcardVcc      vcc;
409    bool                    connectDirectly; /* If true, smartcard is directly connected to the backend chip.
410                                                If false, smartcard connected to the coupling chip TDA8024. */
411    uint32_t                currentIFSD;  /* This attribute indicates the current IFSD */
412    unsigned                sourceClockFreq; /* Configures the Smartcard CLK freq for each smartcard channel (slot). In units of Hz. */
413    NEXUS_TimerValue        atrReceiveTime; /* Defines the time to wait for the first byte of ATR. */
414    unsigned                            resetCycles; /* Defines the reset cycles for the coupling chips. */
415} NEXUS_SmartcardSettings;
416
417/***************************************************************************
418Summary:
419Get default settings for the structure.
420
421Description:
422This is required in order to make application code resilient to the addition of new strucutre members in the future.
423
424See Also:
425NEXUS_Smartcard_Open
426***************************************************************************/
427void NEXUS_Smartcard_GetDefaultSettings(
428    NEXUS_SmartcardSettings *pSettings /* [out] */
429    );
430
431/***************************************************************************
432Summary:
433Open a Smartcard handle.
434
435Description:
436
437See Also:
438NEXUS_Smartcard_Close
439***************************************************************************/
440NEXUS_SmartcardHandle NEXUS_Smartcard_Open( /* attr{destructor=NEXUS_Smartcard_Close}  */
441    unsigned index,
442    const NEXUS_SmartcardSettings *pSettings
443    );
444
445/***************************************************************************
446Summary:
447Close a Smartcard handle.
448
449Description:
450
451See Also:
452NEXUS_Smartcard_Open
453***************************************************************************/
454void NEXUS_Smartcard_Close(
455    NEXUS_SmartcardHandle handle
456    );
457
458/***************************************************************************
459Summary:
460Get the settings for a SMARTCARD
461
462Description:
463
464See Also:
465NEXUS_Smartcard_SetSettings
466***************************************************************************/
467void NEXUS_Smartcard_GetSettings(
468    NEXUS_SmartcardHandle handle,
469    NEXUS_SmartcardSettings *pSettings   /* [out] */
470    );
471
472/***************************************************************************
473Summary:
474Set the settings for a SMARTCARD
475
476Description:
477
478See Also:
479NEXUS_Smartcard_GetSettings
480***************************************************************************/
481NEXUS_Error NEXUS_Smartcard_SetSettings(
482    NEXUS_SmartcardHandle handle,
483    const NEXUS_SmartcardSettings *pSettings
484    );
485
486/***************************************************************************
487Summary:
488Read data from the smartcard.
489
490Description:
491If read fails, you should call NEXUS_Smartcard_GetStatus in order to determine
492the state of the smartcard interface.
493
494See Also:
495NEXUS_Smartcard_Write
496***************************************************************************/
497NEXUS_Error NEXUS_Smartcard_Read(
498    NEXUS_SmartcardHandle smartcard,    /* handle returned by NEXUS_SmartCard_Open */
499    void *pdata,            /* [out] attr{nelem=numBytes;nelem_out=pBytesRead;reserved=64} memory to read into */
500    size_t numBytes,        /* maximum number of bytes to read */
501    size_t *pBytesRead      /* [out] amount of data read into memory */
502    );
503
504/***************************************************************************
505Summary:
506Write data to a smartcard.
507
508Description:
509If write fails, you should call NEXUS_Smartcard_GetStatus in order to determine
510the state of the smartcard interface.
511
512
513See Also:
514NEXUS_Smartcard_Read
515***************************************************************************/
516NEXUS_Error NEXUS_Smartcard_Write(
517    NEXUS_SmartcardHandle smartcard,
518    const void *pData, /* attr{nelem=numBytes;reserved=64} */
519    size_t numBytes,
520    size_t *pBytesWritten /* [out] */
521    );
522
523/***************************************************************************
524Summary:
525Get the current status of a smartcard.
526***************************************************************************/
527NEXUS_Error NEXUS_Smartcard_GetStatus(
528    NEXUS_SmartcardHandle smartcard,
529    NEXUS_SmartcardStatus *pStatus   /* [out] */
530    );
531
532/***************************************************************************
533Summary:
534Reset a smartcard.
535
536Description:
537Reset the smartcard itself.
538
539See Also:
540NEXUS_Smartcard_Read
541***************************************************************************/
542NEXUS_Error NEXUS_Smartcard_ResetCard(
543    NEXUS_SmartcardHandle smartcard, /* handle returned by NEXUS_SmartCard_Open */
544    void *pdata,            /* [out] attr{nelem=numBytes;nelem_out=pBytesRead;reserved=64} pointer to memory that can be read into */
545    size_t numBytes,        /* maximum number of bytes pointed to by data */
546    size_t *pBytesRead      /* [out] length of data read into the data field. */
547    );
548
549/***************************************************************************
550Summary:
551Reset the smartcard interface.
552
553Description:
554Reprogram all the Broadcom smartcard interface, not the card.
555If you want to reset the card, use NEXUS_Smartcard_ResetCard.
556
557The interface must be reset whenever a card is inserted.
558
559See Also:
560NEXUS_Smartcard_Read
561***************************************************************************/
562NEXUS_Error NEXUS_Smartcard_Reset(
563    NEXUS_SmartcardHandle smartcard, /* handle returned by NEXUS_SmartCard_Open */
564    bool warmReset /* true for a warm reset, false for a cold reset */
565    );
566
567/***************************************************************************
568Summary:
569Detect the card insertion.
570
571Description:
572The function will be blocked until the card is inserted.
573
574See Also:
575NEXUS_Smartcard_Read
576***************************************************************************/
577NEXUS_Error NEXUS_Smartcard_DetectCard(
578    NEXUS_SmartcardHandle smartcard
579    );
580
581/***************************************************************************
582Summary:
583Power ICC
584
585Description:
586If iccAction is NEXUS_SmartcardPowerIcc_ePowerUp, this function shall set SC_VCC
587high.  System should call this function so that the next NEXUS_Smartcard_GetStatus
588will show the correct presence of the card or next NEXUS_Smartcard_DetectCard
589will response correctly after TDA8004 emergency deactivation.
590
591If iccAction is NEXUS_SmartcardPowerIcc_ePowerDown, this function shall set SC_VCC
592low.  The next NEXUS_Smartcard_GetStatus may not show the correct presence of the
593card or next NEXUS_Smartcard_DetectCard may not response correctly after
594TDA8004 emergency deactivation.
595**************************************************************************/
596NEXUS_Error NEXUS_Smartcard_PowerIcc(
597    NEXUS_SmartcardHandle      smartcard,
598    NEXUS_SmartcardPowerIcc    iccAction
599    );
600
601/***************************************************************************
602Summary:
603Deactivate the smartcard.
604
605Description:
606This function is used to deactivate the smartcard. After deactivation, the smartcard
607needs to be reset in order to communicate with it again.
608
609See Also:
610NEXUS_Smartcard_Read
611***************************************************************************/
612NEXUS_Error NEXUS_Smartcard_Deactivate (
613    NEXUS_SmartcardHandle smartcard
614    );
615
616#ifdef __cplusplus
617}
618#endif
619
620#endif /* #ifndef NEXUS_SMARTCARD_H__ */
621
Note: See TracBrowser for help on using the repository browser.