1 /*
2  * Copyright (C) 2010-2014 NXP Semiconductors
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 download function call:
29  *      pContext - Upper layer context
30  *      wStatus  - Status of the transaction
31  *      pInfo    - Contains the Transaction Info
32  */
33 typedef void (*pphDnldNfc_RspCb_t)(void* pContext, NFCSTATUS wStatus,void* pInfo);
34 
35 #define PHLIBNFC_FWDNLD_SESSNOPEN    (0x01U)   /* download session is Open */
36 #define PHLIBNFC_FWDNLD_SESSNCLOSED  (0x00U)   /* download session is Closed */
37 
38 #define PHDNLDNFC_HWVER_MRA1_0       (0x01U)   /* ChipVersion MRA1.0 */
39 #define PHDNLDNFC_HWVER_MRA1_1       (0x02U)   /* ChipVersion MRA1.1 */
40 #define PHDNLDNFC_HWVER_MRA2_0       (0x03U)   /* ChipVersion MRA2.0 */
41 #define PHDNLDNFC_HWVER_MRA2_1       (0x04U)   /* ChipVersion MRA2.1 */
42 #define PHDNLDNFC_HWVER_MRA2_2       (0x05U)   /* ChipVersion MRA2.2 */
43 
44 #define PHDNLDNFC_HWVER_PN548AD_MRA1_0       (0x08U)   /* PN548AD ChipVersion MRA1.0 */
45 /*
46  * Enum definition contains Download Life Cycle States
47  */
48 typedef enum phDnldNfc_LC{
49     phDnldNfc_LCCreat = 11,     /* Life Cycle Creation*/
50     phDnldNfc_LCInit = 13,      /* Life Cycle Initializing */
51     phDnldNfc_LCOper = 17,      /* Life Cycle Operational */
52     phDnldNfc_LCTerm = 19       /* Life Cycle Termination */
53 }phDnldNfc_LC_t;
54 
55 /*
56  * Enum definition contains Clk Source Options for Force command request
57  */
58 typedef enum phDnldNfc_ClkSrc{
59     phDnldNfc_ClkSrcXtal = 1U,     /* Crystal */
60     phDnldNfc_ClkSrcPLL = 2U,      /* PLL output */
61     phDnldNfc_ClkSrcPad = 3U      /* Directly use clk on CLK_IN Pad */
62 }phDnldNfc_ClkSrc_t;
63 
64 /*
65  * Enum definition contains Clk Frequency value for Force command request
66  */
67 typedef enum phDnldNfc_ClkFreq{
68     phDnldNfc_ClkFreq_13Mhz = 0U,    /* 13Mhz Clk Frequency */
69     phDnldNfc_ClkFreq_19_2Mhz = 1U,  /* 19.2Mhz Clk Frequency */
70     phDnldNfc_ClkFreq_24Mhz = 2U,    /* 24Mhz Clk Frequency */
71     phDnldNfc_ClkFreq_26Mhz = 3U,    /* 26Mhz Clk Frequency */
72     phDnldNfc_ClkFreq_38_4Mhz = 4U,  /* 38.4Mhz Clk Frequency */
73     phDnldNfc_ClkFreq_52Mhz = 5U     /* 52Mhz Clk Frequency */
74 }phDnldNfc_ClkFreq_t;
75 
76 /*
77  * Struct contains buffer where user payload shall be stored
78  */
79 typedef struct phDnldNfc_Buff
80 {
81     uint8_t *pBuff;                  /*pointer to the buffer where user payload shall be stored*/
82     uint16_t wLen;                   /*Buffer length*/
83 }phDnldNfc_Buff_t, *pphDnldNfc_Buff_t; /* pointer to #phDnldNfc_Buff_t */
84 
85 /*
86 *********************** Function Prototype Declaration *************************
87 */
88 
89 extern NFCSTATUS phDnldNfc_Reset(pphDnldNfc_RspCb_t pNotify, void *pContext);
90 extern NFCSTATUS phDnldNfc_GetVersion(pphDnldNfc_Buff_t pVersionInfo, pphDnldNfc_RspCb_t pNotify, void *pContext);
91 extern NFCSTATUS phDnldNfc_CheckIntegrity(uint8_t bChipVer, pphDnldNfc_Buff_t pCRCData, pphDnldNfc_RspCb_t pNotify, void *pContext);
92 extern NFCSTATUS phDnldNfc_GetSessionState(pphDnldNfc_Buff_t pSession, pphDnldNfc_RspCb_t pNotify, void *pContext);
93 extern NFCSTATUS phDnldNfc_Force(pphDnldNfc_Buff_t pInputs, pphDnldNfc_RspCb_t pNotify,void *pContext);
94 extern NFCSTATUS phDnldNfc_Read(pphDnldNfc_Buff_t pData, uint32_t dwRdAddr, pphDnldNfc_RspCb_t pNotify, void *pContext);
95 extern NFCSTATUS phDnldNfc_ReadLog(pphDnldNfc_Buff_t pData, pphDnldNfc_RspCb_t pNotify, void *pContext);
96 extern NFCSTATUS phDnldNfc_Write(bool_t  bRecoverSeq, pphDnldNfc_Buff_t pData, pphDnldNfc_RspCb_t pNotify, void *pContext);
97 extern NFCSTATUS phDnldNfc_Log(pphDnldNfc_Buff_t pData, pphDnldNfc_RspCb_t pNotify, void *pContext);
98 extern void phDnldNfc_SetHwDevHandle(void);
99 void phDnldNfc_ReSetHwDevHandle(void);
100 extern NFCSTATUS phDnldNfc_ReadMem(void *pHwRef, pphDnldNfc_RspCb_t pNotify, void *pContext);
101 extern NFCSTATUS phDnldNfc_RawReq(pphDnldNfc_Buff_t pFrameData, pphDnldNfc_Buff_t pRspData, pphDnldNfc_RspCb_t pNotify, void *pContext);
102 extern NFCSTATUS phDnldNfc_InitImgInfo(void);
103 extern NFCSTATUS phDnldNfc_LoadRecInfo(void);
104 extern NFCSTATUS phDnldNfc_LoadPKInfo(void);
105 extern void phDnldNfc_CloseFwLibHandle(void);
106 extern NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t **pImgInfo, uint16_t* pImgInfoLen);
107 extern NFCSTATUS phDnldNfc_UnloadFW(void);
108 #endif /* PHDNLDNFC_H */
109