Home | History | Annotate | Download | only in dnld
      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
     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 #define PHLIBNFC_FWDNLD_SESSNOPEN (0x01U)   /* download session is Open */
     38 #define PHLIBNFC_FWDNLD_SESSNCLOSED (0x00U) /* download session is Closed */
     39 
     40 #define PHDNLDNFC_HWVER_MRA1_0 (0x01U) /* ChipVersion MRA1.0 */
     41 #define PHDNLDNFC_HWVER_MRA1_1 (0x02U) /* ChipVersion MRA1.1 */
     42 #define PHDNLDNFC_HWVER_MRA2_0 (0x03U) /* ChipVersion MRA2.0 */
     43 #define PHDNLDNFC_HWVER_MRA2_1 (0x04U) /* ChipVersion MRA2.1 */
     44 #define PHDNLDNFC_HWVER_MRA2_2 (0x05U) /* ChipVersion MRA2.2 */
     45 
     46 /* PN548AD ChipVersion MRA1.0 */
     47 #define PHDNLDNFC_HWVER_PN548AD_MRA1_0 (0x08U)
     48 
     49 /* PN551 ChipVersion MRA1.0 */
     50 #define PHDNLDNFC_HWVER_PN551_MRA1_0 (0x08U)
     51 /* PN553-NCI1.0 ChipVersion MRA1.0 */
     52 #define PHDNLDNFC_HWVER_PN553_MRA1_0 (0x0BU)
     53 /* PN553 A0 -> 0x40 hardware version
     54    PN553 B0 -> 0x41
     55    PN80T A0 -> 0x50
     56    PN80T B0 -> 0x51 */
     57 #define PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED (0x40U)
     58 /*
     59  * Enum definition contains Download Life Cycle States
     60  */
     61 typedef enum phDnldNfc_LC {
     62   phDnldNfc_LCCreat = 11, /* Life Cycle Creation*/
     63   phDnldNfc_LCInit = 13,  /* Life Cycle Initializing */
     64   phDnldNfc_LCOper = 17,  /* Life Cycle Operational */
     65   phDnldNfc_LCTerm = 19   /* Life Cycle Termination */
     66 } phDnldNfc_LC_t;
     67 
     68 /*
     69  * Enum definition contains Clk Source Options for Force command request
     70  */
     71 typedef enum phDnldNfc_ClkSrc {
     72   phDnldNfc_ClkSrcXtal = 1U, /* Crystal */
     73   phDnldNfc_ClkSrcPLL = 2U,  /* PLL output */
     74   phDnldNfc_ClkSrcPad = 3U   /* Directly use clk on CLK_IN Pad */
     75 } phDnldNfc_ClkSrc_t;
     76 
     77 /*
     78  * Enum definition contains Clk Frequency value for Force command request
     79  */
     80 typedef enum phDnldNfc_ClkFreq {
     81   phDnldNfc_ClkFreq_13Mhz = 0U,   /* 13Mhz Clk Frequency */
     82   phDnldNfc_ClkFreq_19_2Mhz = 1U, /* 19.2Mhz Clk Frequency */
     83   phDnldNfc_ClkFreq_24Mhz = 2U,   /* 24Mhz Clk Frequency */
     84   phDnldNfc_ClkFreq_26Mhz = 3U,   /* 26Mhz Clk Frequency */
     85   phDnldNfc_ClkFreq_38_4Mhz = 4U, /* 38.4Mhz Clk Frequency */
     86   phDnldNfc_ClkFreq_52Mhz = 5U    /* 52Mhz Clk Frequency */
     87 } phDnldNfc_ClkFreq_t;
     88 
     89 /*
     90  * Struct contains buffer where user payload shall be stored
     91  */
     92 typedef struct phDnldNfc_Buff {
     93   uint8_t* pBuff; /*pointer to the buffer where user payload shall be stored*/
     94   uint16_t wLen;  /*Buffer length*/
     95 } phDnldNfc_Buff_t, *pphDnldNfc_Buff_t; /* pointer to #phDnldNfc_Buff_t */
     96 
     97 /*
     98 *********************** Function Prototype Declaration *************************
     99 */
    100 
    101 extern NFCSTATUS phDnldNfc_Reset(pphDnldNfc_RspCb_t pNotify, void* pContext);
    102 extern NFCSTATUS phDnldNfc_GetVersion(pphDnldNfc_Buff_t pVersionInfo,
    103                                       pphDnldNfc_RspCb_t pNotify,
    104                                       void* pContext);
    105 extern NFCSTATUS phDnldNfc_CheckIntegrity(uint8_t bChipVer,
    106                                           pphDnldNfc_Buff_t pCRCData,
    107                                           pphDnldNfc_RspCb_t pNotify,
    108                                           void* pContext);
    109 extern NFCSTATUS phDnldNfc_GetSessionState(pphDnldNfc_Buff_t pSession,
    110                                            pphDnldNfc_RspCb_t pNotify,
    111                                            void* pContext);
    112 extern NFCSTATUS phDnldNfc_Force(pphDnldNfc_Buff_t pInputs,
    113                                  pphDnldNfc_RspCb_t pNotify, void* pContext);
    114 extern NFCSTATUS phDnldNfc_Read(pphDnldNfc_Buff_t pData, uint32_t dwRdAddr,
    115                                 pphDnldNfc_RspCb_t pNotify, void* pContext);
    116 extern NFCSTATUS phDnldNfc_ReadLog(pphDnldNfc_Buff_t pData,
    117                                    pphDnldNfc_RspCb_t pNotify, void* pContext);
    118 extern NFCSTATUS phDnldNfc_Write(bool_t bRecoverSeq, pphDnldNfc_Buff_t pData,
    119                                  pphDnldNfc_RspCb_t pNotify, void* pContext);
    120 extern NFCSTATUS phDnldNfc_Log(pphDnldNfc_Buff_t pData,
    121                                pphDnldNfc_RspCb_t pNotify, void* pContext);
    122 extern void phDnldNfc_SetHwDevHandle(void);
    123 void phDnldNfc_ReSetHwDevHandle(void);
    124 extern NFCSTATUS phDnldNfc_ReadMem(void* pHwRef, pphDnldNfc_RspCb_t pNotify,
    125                                    void* pContext);
    126 extern NFCSTATUS phDnldNfc_RawReq(pphDnldNfc_Buff_t pFrameData,
    127                                   pphDnldNfc_Buff_t pRspData,
    128                                   pphDnldNfc_RspCb_t pNotify, void* pContext);
    129 extern NFCSTATUS phDnldNfc_InitImgInfo(void);
    130 extern NFCSTATUS phDnldNfc_LoadRecInfo(void);
    131 extern NFCSTATUS phDnldNfc_LoadPKInfo(void);
    132 extern void phDnldNfc_CloseFwLibHandle(void);
    133 extern NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t** pImgInfo,
    134                                   uint16_t* pImgInfoLen);
    135 #if (NFC_NXP_CHIP_TYPE != PN547C2)
    136 extern NFCSTATUS phDnldNfc_LoadRecoveryFW(const char* pathName,
    137                                           uint8_t** pImgInfo,
    138                                           uint16_t* pImgInfoLen);
    139 #endif
    140 extern NFCSTATUS phDnldNfc_UnloadFW(void);
    141 #endif /* PHDNLDNFC_H */
    142