• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2018-2019, 2023 NXP
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /**
20  * \addtogroup SPI_Power_Management
21  *
22  * @{ */
23 
24 #ifndef _PHNXPESE_SPM_H
25 #define _PHNXPESE_SPM_H
26 
27 #include <phEseStatus.h>
28 #include <phNxpEseFeatures.h>
29 /*! SPI Power Manager (SPM) possible error codes */
30 typedef enum spm_power {
31   SPM_POWER_DISABLE = 0,
32   SPM_POWER_ENABLE,       /*!< SPM power disable */
33   SPM_POWER_RESET,        /*!< SPM Reset pwer */
34   SPM_POWER_PRIO_ENABLE,  /*!< SPM prio mode enable */
35   SPM_POWER_PRIO_DISABLE, /*!< SPM prio mode disable */
36   SPM_RECOVERY_RESET
37 } spm_power_t;
38 
39 /*! SPI Power Manager (SPM) possible states */
40 typedef enum spm_state {
41   SPM_STATE_INVALID = 0x0000,      /*!< Nfc i2c driver misbehaving */
42   SPM_STATE_IDLE = 0x0100,         /*!< ESE is free to use */
43   SPM_STATE_WIRED = 0x0200,        /*!< p61 is being accessed by DWP (NFCC)*/
44   SPM_STATE_SPI = 0x0400,          /*!< ESE is being accessed by SPI */
45   SPM_STATE_DWNLD = 0x0800,        /*!< NFCC fw download is in progress */
46   SPM_STATE_SPI_PRIO = 0x1000,     /*!< Start of p61 access by SPI on priority*/
47   SPM_STATE_SPI_PRIO_END = 0x2000, /*!< End of p61 access by SPI on priority*/
48   SPM_STATE_SPI_FAILED = 0x0010,   /*SPI open/close failed*/
49   SPM_STATE_JCOP_DWNLD = 0x8000    /*!< P73 state JCOP Download*/
50 } spm_state_t;
51 
52 /**
53  * \ingroup SPI_Power_Management
54  * \brief This function opens the nfc i2c driver to manage power
55  *                  and synchronization for ese secure element.
56  *
57  * \param[in]    pDevHandle       - Device handle to open.
58  *
59  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
60  */
61 ESESTATUS phNxpEse_SPM_Init(void* pDevHandle);
62 
63 /**
64  * \ingroup SPI_Power_Management
65  * \brief TThis function closes the nfc i2c driver node.
66  *
67  *
68  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
69  */
70 ESESTATUS phNxpEse_SPM_DeInit(void);
71 
72 /**
73  * \ingroup SPI_Power_Management
74  * \brief This function request to the nfc i2c driver
75  * to enable/disable power to ese. This api should be called
76  *before sending any apdu to ese/once apdu exchange is done.
77  *
78  * \param[in]    arg       -input can be of  type spm_power_t.
79  *
80  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
81  */
82 ESESTATUS phNxpEse_SPM_ConfigPwr(spm_power_t arg);
83 
84 /**
85  * \ingroup SPI_Power_Management
86  * \brief This function gets the current power state of ESE
87  * \param[in]    current_state       -input is of type spm_state_t.
88  *
89  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
90  */
91 ESESTATUS phNxpEse_SPM_GetState(spm_state_t* current_state);
92 
93 /**
94  * \ingroup SPI_Power_Management
95  * \brief  This function set the SPM power state
96  *
97  * \param[in]    arg - state value.
98  *
99  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
100  */
101 ESESTATUS phNxpEse_SPM_SetState(long arg);
102 
103 /**
104  * \ingroup SPI_Power_Management
105  * \brief  phNxpEse_SPM_RelAccess
106  *
107  *
108  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
109  */
110 ESESTATUS phNxpEse_SPM_RelAccess(void);
111 
112 /**
113  * \ingroup SPI_Power_Management
114  * \brief   This function request to the nfc i2c driver
115  *                  to set the chip type and power scheme.
116  *
117  * \param[in]    arg - set power scheme from config.
118  *
119  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
120  */
121 ESESTATUS phNxpEse_SPM_SetPwrScheme(long arg);
122 
123 /**
124  * \ingroup SPI_Power_Management
125  * \brief    This function request to the nfc i2c driver
126  *                  to set the chip type and power scheme.
127  *
128  * \param[in]    arg - arg.
129  *
130  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
131  */
132 ESESTATUS phNxpEse_SPM_DisablePwrControl(unsigned long arg);
133 /**
134  * \ingroup SPI_Power_Management
135  * \brief   This function is used to set the ese Update state.
136  *
137  * \param[in]    arg - eSE update status started/completed.
138  *
139  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
140  */
141 ESESTATUS phNxpEse_SPM_SetEseClientUpdateState(long arg);
142 
143 /**
144  * \ingroup SPI_Power_Management
145  * \brief   This function is used to set the ese Update state.
146  *
147  * \param[in]    arg -  JCOP update status started/completed..
148  *
149  * \retval       -On Success ESESTATUS_SUCCESS else proper error code
150  */
151 ESESTATUS phNxpEse_SPM_SetJcopDwnldState(long arg);
152 
153 #endif /*  _PHNXPESE_SPM_H    */
154 /** @} */
155