1 /*
2  * Copyright 2019-2023 NXP
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <hardware/nfc.h>
18 
19 #include "phNfcStatus.h"
20 #include "phNxpConfig.h"
21 #include "phNxpLog.h"
22 
23 /******************************************************************************
24  ** Function         phNxpNciHal_ioctlIf
25  **
26  ** Description      This function shall be called from HAL when libnfc-nci
27  **                  calls phNxpNciHal_ioctl() to perform any IOCTL operation
28  **
29  ** Returns          return 0 on success and -1 on fail,
30  ******************************************************************************/
31 int phNxpNciHal_ioctlIf(long arg, void* p_data);
32 
33 /*******************************************************************************
34 **
35 ** Function         phNxpNciHal_getSystemProperty
36 **
37 ** Description      It shall be used to get property value of the given Key
38 **
39 ** Parameters       string key
40 **
41 ** Returns          It returns the property value of the key
42 *******************************************************************************/
43 string phNxpNciHal_getSystemProperty(string key);
44 
45 /*******************************************************************************
46  **
47  ** Function         phNxpNciHal_setSystemProperty
48  **
49  ** Description      It shall be used to save/chage value to system property
50  **                  based on provided key.
51  **
52  ** Parameters       string key, string value
53  **
54  ** Returns          true if success, false if fail
55  *******************************************************************************/
56 bool phNxpNciHal_setSystemProperty(string key, string value);
57 
58 /*******************************************************************************
59 **
60 ** Function         phNxpNciHal_getNxpConfig
61 **
62 ** Description      It shall be used to read config values from the
63 *libnfc-nxp.conf
64 **
65 ** Parameters       nxpConfigs config
66 **
67 ** Returns          void
68 *******************************************************************************/
69 string phNxpNciHal_getNxpConfigIf();
70 
71 /*******************************************************************************
72 **
73 ** Function         phNxpNciHal_resetEse
74 **
75 ** Description      It shall be used to to reset eSE by proprietary command.
76 **
77 ** Parameters       None
78 **
79 ** Returns          status of eSE reset response
80 *******************************************************************************/
81 NFCSTATUS phNxpNciHal_resetEse(uint64_t resetType);
82 
83 /******************************************************************************
84 ** Function         phNxpNciHal_setNxpTransitConfig
85 **
86 ** Description      This function overwrite libnfc-nxpTransit.conf file
87 **                  with transitConfValue.
88 **
89 ** Returns          bool.
90 **
91 *******************************************************************************/
92 bool phNxpNciHal_setNxpTransitConfig(char* transitConfValue);
93 
94 /*******************************************************************************
95  **
96  ** Function:        phNxpNciHal_CheckFwRegFlashRequired()
97  **
98  ** Description:     Updates FW and Reg configurations if required
99  **
100  ** Returns:         status
101  **
102  ********************************************************************************/
103 int phNxpNciHal_CheckFwRegFlashRequired(uint8_t* fw_update_req,
104                                         uint8_t* rf_update_req,
105                                         uint8_t skipEEPROMRead);
106 
107 /******************************************************************************
108  * Function         phNxpNciHal_txNfccClockSetCmd
109  *
110  * Description      This function is called after successful download
111  *                  to apply the clock setting provided in config file
112  *
113  * Returns          void.
114  *
115  ******************************************************************************/
116 void phNxpNciHal_txNfccClockSetCmd(void);
117 
118 /*******************************************************************************
119  **
120  ** Function:        property_get_intf()
121  **
122  ** Description:     Gets property value for the input property name
123  **
124  ** Parameters       propName:   Name of the property whichs value need to get
125  **                  valueStr:   output value of the property.
126  **                  defaultStr: default value of the property if value is not
127  **                              there this will be set to output value.
128  **
129  ** Returns:         actual length of the property value
130  **
131  ********************************************************************************/
132 int property_get_intf(const char* propName, char* valueStr,
133                       const char* defaultStr);
134 
135 /*******************************************************************************
136  **
137  ** Function:        property_set_intf()
138  **
139  ** Description:     Sets property value for the input property name
140  **
141  ** Parameters       propName:   Name of the property whichs value need to set
142  **                  valueStr:   value of the property.
143  **
144  ** Returns:        returns 0 on success, < 0 on failure
145  **
146  ********************************************************************************/
147 int property_set_intf(const char* propName, const char* valueStr);
148 
149 /*******************************************************************************
150  **
151  ** Function:        phNxpNciHal_GetNfcGpiosStatus()
152  **
153  ** Description:     Sets the gpios status flag byte
154  **
155  ** Parameters       gpiostatus: flag byte
156  **
157  ** Returns:        returns 0 on success, < 0 on failure
158  **
159  ********************************************************************************/
160 NFCSTATUS phNxpNciHal_GetNfcGpiosStatus(uint32_t* gpiosstatus);
161 
162 /*******************************************************************************
163  **
164  ** Function:        phNxpNciHal_Abort()
165  **
166  ** Description:     This function shall be used to trigger the abort
167  **
168  ** Parameters       None
169  **
170  ** Returns:        returns 0 on success, < 0 on failure
171  **
172  ********************************************************************************/
173 bool phNxpNciHal_Abort();
174 
175 #undef PROPERTY_VALUE_MAX
176 #define PROPERTY_VALUE_MAX 92
177 #define property_get(a, b, c) property_get_intf(a, b, c)
178 #define property_set(a, b) property_set_intf(a, b)
179