1 /*
2  * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_SMARTCARD_PHY_H_
10 #define _FSL_SMARTCARD_PHY_H_
11 
12 #include "fsl_smartcard.h"
13 
14 /*!
15  * @addtogroup smartcard_phy_driver
16  * @{
17  */
18 
19 /*******************************************************************************
20  * Definitions
21  ******************************************************************************/
22 
23 /*! @brief Smart card definition which specifies the adjustment number of clock cycles during which an ATR string has to
24  * be received.
25  */
26 #define SMARTCARD_ATR_DURATION_ADJUSTMENT (360u)
27 
28 /*! @brief Smart card definition which specifies the adjustment number of clock cycles until an initial 'TS' character
29  * has to be
30  * received. */
31 #define SMARTCARD_INIT_DELAY_CLOCK_CYCLES_ADJUSTMENT (4200u)
32 
33 /*******************************************************************************
34  * API
35  ******************************************************************************/
36 
37 #if defined(__cplusplus)
38 extern "C" {
39 #endif
40 
41 /*!
42  * @brief Fills in the configuration structure with default values.
43  *
44  * @param config The Smart card user configuration structure which contains configuration structure of type
45  * smartcard_interface_config_t.
46  * Function fill in members:
47  *      clockToResetDelay = 42000,
48  *      vcc = kSmartcardVoltageClassB3_3V,
49  * with default values.
50  */
51 void SMARTCARD_PHY_GetDefaultConfig(smartcard_interface_config_t *config);
52 
53 /*!
54  * @brief Initializes a Smart card interface instance.
55  *
56  * @param base The Smart card peripheral base address.
57  * @param config The user configuration structure of type smartcard_interface_config_t. Call the
58  *  function SMARTCARD_PHY_GetDefaultConfig() to fill the configuration structure.
59  * @param srcClock_Hz Smart card clock generation module source clock.
60  *
61  * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error.
62  */
63 status_t SMARTCARD_PHY_Init(void *base, smartcard_interface_config_t const *config, uint32_t srcClock_Hz);
64 
65 /*!
66  * @brief De-initializes a Smart card interface, stops the Smart card clock, and disables the VCC.
67  *
68  * @param base The Smart card peripheral module base address.
69  * @param config The user configuration structure of type smartcard_interface_config_t.
70  */
71 void SMARTCARD_PHY_Deinit(void *base, smartcard_interface_config_t const *config);
72 
73 /*!
74  * @brief Activates the Smart card IC.
75  *
76  * @param base The Smart card peripheral module base address.
77  * @param context A pointer to a Smart card driver context structure.
78  * @param resetType type of reset to be performed, possible values
79  *                       = kSmartcardColdReset, kSmartcardWarmReset
80  *
81  * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error.
82  */
83 status_t SMARTCARD_PHY_Activate(void *base, smartcard_context_t *context, smartcard_reset_type_t resetType);
84 
85 /*!
86  * @brief De-activates the Smart card IC.
87  *
88  * @param base The Smart card peripheral module base address.
89  * @param context A pointer to a Smart card driver context structure.
90  *
91  * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error.
92  */
93 status_t SMARTCARD_PHY_Deactivate(void *base, smartcard_context_t *context);
94 
95 /*!
96  * @brief Controls the Smart card interface IC.
97  *
98  * @param base The Smart card peripheral module base address.
99  * @param context A pointer to a Smart card driver context structure.
100  * @param control A interface command type.
101  * @param param Integer value specific to control type
102  *
103  * @retval kStatus_SMARTCARD_Success or kStatus_SMARTCARD_OtherError in case of error.
104  */
105 status_t SMARTCARD_PHY_Control(void *base,
106                                smartcard_context_t *context,
107                                smartcard_interface_control_t control,
108                                uint32_t param);
109 
110 /*!
111  * @brief Smart card interface IC IRQ ISR.
112  *
113  * @param base The Smart card peripheral module base address.
114  * @param context The Smart card context pointer.
115  */
116 #if defined(USING_PHY_TDA8035)
117 void SMARTCARD_PHY_IRQHandler(void *base, smartcard_context_t *context);
118 #endif
119 /*@}*/
120 
121 #if defined(__cplusplus)
122 }
123 #endif
124 
125 /*! @}*/
126 
127 #endif /* _FSL_SMARTCARD_PHY_H_*/
128