• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2010-2022 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 /*
18  * Firmware Download Interface File
19  */
20 #ifndef PHDNLDNFC_H
21 #define PHDNLDNFC_H
22 
23 #include <phNfcStatus.h>
24 
25 /*
26  *
27  * Callback for handling the received data/response from PN54X.
28  * Parameters to be passed/registered to download context during respective
29  * download function call:
30  *      pContext - Upper layer context
31  *      wStatus  - Status of the transaction
32  *      pInfo    - Contains the Transaction Info
33  */
34 typedef void (*pphDnldNfc_RspCb_t)(void* pContext, NFCSTATUS wStatus,
35                                    void* pInfo);
36 
37 /* Timeout value to wait for response from NFCC */
38 #define PHDNLDNFC_RSP_TIMEOUT (2500)
39 /* Timeout value to wait for dnld  reset rsp */
40 #define PHDNLDNFC_RESET_RSP_TIMEOUT (15)
41 
42 #define PHLIBNFC_FWDNLD_SESSNOPEN (0x01U)   /* download session is Open */
43 #define PHLIBNFC_FWDNLD_SESSNCLOSED (0x00U) /* download session is Closed */
44 
45 #define PHDNLDNFC_HWVER_MRA1_0 (0x01U) /* ChipVersion MRA1.0 */
46 #define PHDNLDNFC_HWVER_MRA1_1 (0x02U) /* ChipVersion MRA1.1 */
47 #define PHDNLDNFC_HWVER_MRA2_0 (0x03U) /* ChipVersion MRA2.0 */
48 #define PHDNLDNFC_HWVER_MRA2_1 (0x04U) /* ChipVersion MRA2.1 */
49 #define PHDNLDNFC_HWVER_MRA2_2 (0x05U) /* ChipVersion MRA2.2 */
50 
51 /* PN551 ChipVersion MRA1.0 */
52 #define PHDNLDNFC_HWVER_PN551_MRA1_0 (0x08U)
53 /* PN553-NCI1.0 ChipVersion MRA1.0 */
54 #define PHDNLDNFC_HWVER_PN553_MRA1_0 (0x0BU)
55 /* PN553 A0 -> 0x40 hardware version
56    PN553 B0 -> 0x41
57    PN80T A0 -> 0x50
58    PN80T B0 -> 0x51 */
59 #define PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED (0x40U)
60 #define PHDNLDNFC_HWVER_PN557_MRA1_0 (0x01U)
61 #define PHDNLDNFC_HWVER_VENUS_MRA1_0 (0xA0U)
62 #define PHDNLDNFC_HWVER_VULCAN_MRA1_0 (0xC0U)
63 /*
64  * Enum definition contains Download Life Cycle States
65  */
66 typedef enum phDnldNfc_LC {
67   phDnldNfc_LCCreat = 11, /* Life Cycle Creation*/
68   phDnldNfc_LCInit = 13,  /* Life Cycle Initializing */
69   phDnldNfc_LCOper = 17,  /* Life Cycle Operational */
70   phDnldNfc_LCTerm = 19   /* Life Cycle Termination */
71 } phDnldNfc_LC_t;
72 
73 /*
74  * Enum definition contains Clk Source Options for Force command request
75  */
76 typedef enum phDnldNfc_ClkSrc {
77   phDnldNfc_ClkSrcXtal = 1U, /* Crystal */
78   phDnldNfc_ClkSrcPLL = 2U,  /* PLL output */
79   phDnldNfc_ClkSrcPad = 3U   /* Directly use clk on CLK_IN Pad */
80 } phDnldNfc_ClkSrc_t;
81 
82 /*
83  * Enum definition contains Clk Frequency value for Force command request
84  */
85 typedef enum phDnldNfc_ClkFreq {
86   phDnldNfc_ClkFreq_13Mhz = 0U,   /* 13Mhz Clk Frequency */
87   phDnldNfc_ClkFreq_19_2Mhz = 1U, /* 19.2Mhz Clk Frequency */
88   phDnldNfc_ClkFreq_24Mhz = 2U,   /* 24Mhz Clk Frequency */
89   phDnldNfc_ClkFreq_26Mhz = 3U,   /* 26Mhz Clk Frequency */
90   phDnldNfc_ClkFreq_38_4Mhz = 4U, /* 38.4Mhz Clk Frequency */
91   phDnldNfc_ClkFreq_52Mhz = 5U,   /* 52Mhz Clk Frequency */
92   phDnldNfc_ClkFreq_32Mhz = 6U,   /* 32Mhz Clk Frequency */
93   phDnldNfc_ClkFreq_48Mhz = 0x0AU /* 48Mhz Clk Frequency */
94 } phDnldNfc_ClkFreq_t;
95 
96 /*
97  * Struct contains buffer where user payload shall be stored
98  */
99 typedef struct phDnldNfc_Buff {
100   uint8_t* pBuff; /*pointer to the buffer where user payload shall be stored*/
101   uint32_t wLen;  /*Buffer length*/
102 } phDnldNfc_Buff_t, *pphDnldNfc_Buff_t; /* pointer to #phDnldNfc_Buff_t */
103 
104 typedef struct phDnldChkIntegrityRsp_Buff {
105   uint8_t* pBuff; /* pointer to the buffer where chk integrity rsp is stored*/
106   uint32_t wLen;  /* check integrity rsp Buffer length*/
107   uint8_t
108       data_len; /* length of data area whose CRC is checked, maximum 28 bits*/
109   uint8_t
110       code_len; /* length of code area whose CRC is checked, maximum 4 bits*/
111   uint32_t crc_status; /* crc info of all the sections*/
112 } phDnldChkIntegrityRsp_Buff_t;
113 /*
114 *********************** Function Prototype Declaration *************************
115 */
116 
117 extern NFCSTATUS phDnldNfc_Reset(pphDnldNfc_RspCb_t pNotify, void* pContext);
118 extern NFCSTATUS phDnldNfc_GetVersion(pphDnldNfc_Buff_t pVersionInfo,
119                                       pphDnldNfc_RspCb_t pNotify,
120                                       void* pContext);
121 extern NFCSTATUS phDnldNfc_CheckIntegrity(uint8_t bChipVer,
122                                           pphDnldNfc_Buff_t pCRCData,
123                                           pphDnldNfc_RspCb_t pNotify,
124                                           void* pContext);
125 extern NFCSTATUS phDnldNfc_GetSessionState(pphDnldNfc_Buff_t pSession,
126                                            pphDnldNfc_RspCb_t pNotify,
127                                            void* pContext);
128 extern NFCSTATUS phDnldNfc_Force(pphDnldNfc_Buff_t pInputs,
129                                  pphDnldNfc_RspCb_t pNotify, void* pContext);
130 extern NFCSTATUS phDnldNfc_Read(pphDnldNfc_Buff_t pData, uint32_t dwRdAddr,
131                                 pphDnldNfc_RspCb_t pNotify, void* pContext);
132 extern NFCSTATUS phDnldNfc_ReadLog(pphDnldNfc_Buff_t pData,
133                                    pphDnldNfc_RspCb_t pNotify, void* pContext);
134 extern NFCSTATUS phDnldNfc_Write(bool_t bRecoverSeq, pphDnldNfc_Buff_t pData,
135                                  pphDnldNfc_RspCb_t pNotify, void* pContext);
136 extern NFCSTATUS phDnldNfc_Log(pphDnldNfc_Buff_t pData,
137                                pphDnldNfc_RspCb_t pNotify, void* pContext);
138 extern void phDnldNfc_SetHwDevHandle(void);
139 void phDnldNfc_ReSetHwDevHandle(void);
140 extern NFCSTATUS phDnldNfc_ReadMem(void* pHwRef, pphDnldNfc_RspCb_t pNotify,
141                                    void* pContext);
142 extern NFCSTATUS phDnldNfc_RawReq(pphDnldNfc_Buff_t pFrameData,
143                                   pphDnldNfc_Buff_t pRspData,
144                                   pphDnldNfc_RspCb_t pNotify, void* pContext);
145 extern NFCSTATUS phDnldNfc_InitImgInfo(bool bMinimalFw = false);
146 extern NFCSTATUS phDnldNfc_LoadRecInfo(void);
147 extern NFCSTATUS phDnldNfc_LoadPKInfo(void);
148 extern void phDnldNfc_CloseFwLibHandle(void);
149 extern NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t** pImgInfo,
150                                   uint32_t* pImgInfoLen);
151 extern NFCSTATUS phDnldNfc_LoadRecoveryFW(const char* pathName,
152                                           uint8_t** pImgInfo,
153                                           uint32_t* pImgInfoLen);
154 extern NFCSTATUS phDnldNfc_LoadBinFW(uint8_t** pImgInfo, uint32_t* pImgInfoLen);
155 extern NFCSTATUS phDnldNfc_UnloadFW(void);
156 extern void phDnldNfc_SetDlRspTimeout(uint16_t timeout);
157 extern void phDnldNfc_SetI2CFragmentLength(uint16_t len);
158 #endif /* PHDNLDNFC_H */
159