summaryrefslogtreecommitdiffstats
path: root/halimpl
diff options
context:
space:
mode:
authorLove Khanna <love.khanna@nxp.com>2018-03-19 19:13:06 +0530
committerLove Khanna <love.khanna@nxp.com>2018-03-19 22:29:24 +0000
commite35823097843ed8c99e7c2b34c28ff6460901e6c (patch)
tree2dc630074bf2980452b8b8f8fb806dac464f0328 /halimpl
parent2f2631a4d0cf9c26003f1d796859ea81745d983c (diff)
downloadandroid_hardware_nxp_nfc-e35823097843ed8c99e7c2b34c28ff6460901e6c.tar.gz
android_hardware_nxp_nfc-e35823097843ed8c99e7c2b34c28ff6460901e6c.tar.bz2
android_hardware_nxp_nfc-e35823097843ed8c99e7c2b34c28ff6460901e6c.zip
Chip type decided at runtime.
Dynamically detect chip type, load configuarations and firmware file base on chip type. Test: NFC enable/disable. Change-Id: Iec6bd7f82ed65482df4b800e841e39e88968e201
Diffstat (limited to 'halimpl')
-rwxr-xr-xhalimpl/common/phNfcCommon.h41
-rwxr-xr-xhalimpl/common/phNfcTypes.h1
-rw-r--r--[-rwxr-xr-x]halimpl/dnld/phDnldNfc.cc172
-rwxr-xr-xhalimpl/dnld/phDnldNfc.h9
-rwxr-xr-xhalimpl/dnld/phDnldNfc_Internal.cc28
-rwxr-xr-xhalimpl/dnld/phDnldNfc_Internal.h4
-rw-r--r--[-rwxr-xr-x]halimpl/dnld/phNxpNciHal_Dnld.cc54
-rwxr-xr-xhalimpl/hal/phNxpNciHal.cc109
-rwxr-xr-xhalimpl/hal/phNxpNciHal.h12
-rwxr-xr-xhalimpl/hal/phNxpNciHal_ext.cc8
-rwxr-xr-xhalimpl/libnfc-nxp-PN553_example.conf6
-rwxr-xr-xhalimpl/libnfc-nxp-PN553_example_NCI2_0.conf6
-rwxr-xr-xhalimpl/libnfc-nxp-PN80T_example.conf6
-rwxr-xr-xhalimpl/libnfc-nxp-PN80T_example_NCI2_0.conf6
-rwxr-xr-xhalimpl/libnfc-nxp-PN81T_example_NCI2_0.conf8
-rw-r--r--halimpl/utils/NxpNfcCapability.cpp94
-rw-r--r--halimpl/utils/NxpNfcCapability.h41
-rwxr-xr-xhalimpl/utils/phNxpConfig.h2
-rw-r--r--[-rwxr-xr-x]halimpl/utils/phNxpNciHal_utils.cc6
19 files changed, 324 insertions, 289 deletions
diff --git a/halimpl/common/phNfcCommon.h b/halimpl/common/phNfcCommon.h
index ba1970e..919b191 100755
--- a/halimpl/common/phNfcCommon.h
+++ b/halimpl/common/phNfcCommon.h
@@ -33,42 +33,11 @@
#include <pthread.h>
#include <semaphore.h>
-#define FW_DLL_ROOT_DIR "/system/vendor/lib/"
-#define FW_DLL_EXTENSION ".so"
-
-#if(NFC_NXP_CHIP_TYPE == PN551)
-/* Actual FW library name*/
-#define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn551_fw" FW_DLL_EXTENSION
-/* Restore Corrupted PLL Settings/etc */
-#define PLATFORM_LIB_PATH \
- FW_DLL_ROOT_DIR "libpn551_fw_platform" FW_DLL_EXTENSION
-/* Upgrade the public Key */
-#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn551_fw_pku" FW_DLL_EXTENSION
-#elif(NFC_NXP_CHIP_TYPE == PN553)
-/* Actual FW library name*/
-#define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn553_fw" FW_DLL_EXTENSION
-/* Restore Corrupted PLL Settings/etc */
-#define PLATFORM_LIB_PATH \
- FW_DLL_ROOT_DIR "libpn553_fw_platform" FW_DLL_EXTENSION
-/* Upgrade the public Key */
-#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn553_fw_pku" FW_DLL_EXTENSION
-#elif(NFC_NXP_CHIP_TYPE == PN557)
-/* Actual FW library name*/
-#define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn557_fw" FW_DLL_EXTENSION
-/* Restore Corrupted PLL Settings/etc */
-#define PLATFORM_LIB_PATH \
-FW_DLL_ROOT_DIR "libpn557_fw_platform" FW_DLL_EXTENSION
-/* Upgrade the public Key */
-#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn557_fw_pku" FW_DLL_EXTENSION
-#endif
-
-#if(NFC_NXP_CHIP_TYPE == PN551)
-#define COMPILATION_MW "PN551"
-#elif(NFC_NXP_CHIP_TYPE == PN553)
-#define COMPILATION_MW "PN553"
-#elif(NFC_NXP_CHIP_TYPE == PN557)
-#define COMPILATION_MW "PN557"
-#endif
+#define FW_LIB_ROOT_DIR "/vendor/lib/"
+#define FW_BIN_ROOT_DIR "/vendor/firmware/"
+#define FW_LIB_EXTENSION ".so"
+#define FW_BIN_EXTENSION ".bin"
+
/* HAL Version number (Updated as per release) */
#define NXP_MW_VERSION_MAJ (3U)
#define NXP_MW_VERSION_MIN (5U)
diff --git a/halimpl/common/phNfcTypes.h b/halimpl/common/phNfcTypes.h
index 9f9b222..5333e3c 100755
--- a/halimpl/common/phNfcTypes.h
+++ b/halimpl/common/phNfcTypes.h
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "Nxp_Features.h"
#ifndef TRUE
#define TRUE (0x01) /* Logical True Value */
diff --git a/halimpl/dnld/phDnldNfc.cc b/halimpl/dnld/phDnldNfc.cc
index 419da0d..1adf3ad 100755..100644
--- a/halimpl/dnld/phDnldNfc.cc
+++ b/halimpl/dnld/phDnldNfc.cc
@@ -24,11 +24,11 @@
#include <phNxpConfig.h>
#include <phNxpLog.h>
#include <phTmlNfc.h>
-
+#include <string>
static void* pFwHandle; /* Global firmware handle */
-uint16_t wMwVer = 0; /* Middleware version no */
-uint16_t wFwVer = 0; /* Firmware version no */
-uint8_t gRecFWDwnld; // flag set to true to indicate dummy FW download
+uint16_t wMwVer = 0; /* Middleware version no */
+uint16_t wFwVer = 0; /* Firmware version no */
+uint8_t gRecFWDwnld; // flag set to true to indicate dummy FW download
phTmlNfc_i2cfragmentation_t fragmentation_enabled = I2C_FRAGMENATATION_DISABLED;
static pphDnldNfc_DlContext_t gpphDnldContext = NULL; /* Download contex */
#undef EEPROM_Read_Mem_IMP
@@ -242,15 +242,13 @@ NFCSTATUS phDnldNfc_CheckIntegrity(uint8_t bChipVer, pphDnldNfc_Buff_t pCRCData,
wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_BUSY);
} else {
if ((PHDNLDNFC_HWVER_MRA2_1 == bChipVer) ||
- (PHDNLDNFC_HWVER_MRA2_2 == bChipVer)
-#if (NFC_NXP_CHIP_TYPE == PN551)
- || (PHDNLDNFC_HWVER_PN551_MRA1_0 == bChipVer)
-#elif (NFC_NXP_CHIP_TYPE == PN553 || NFC_NXP_CHIP_TYPE == PN557)
- || (PHDNLDNFC_HWVER_PN553_MRA1_0 == bChipVer) ||
- (PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED & bChipVer) ||
- (PHDNLDNFC_HWVER_PN557_MRA1_0 == bChipVer)
-#endif
- ) {
+ (PHDNLDNFC_HWVER_MRA2_2 == bChipVer) ||
+ ((nfcFL.chipType == pn551) &&
+ (PHDNLDNFC_HWVER_PN551_MRA1_0 == bChipVer)) ||
+ (((nfcFL.chipType == pn553) || (nfcFL.chipType == pn557)) &&
+ ((PHDNLDNFC_HWVER_PN553_MRA1_0 == bChipVer) ||
+ (PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED & bChipVer) ||
+ (PHDNLDNFC_HWVER_PN557_MRA1_0 == bChipVer)))) {
(gpphDnldContext->FrameInp.Type) = phDnldNfc_ChkIntg;
} else {
(gpphDnldContext->FrameInp.Type) = phDnldNfc_FTNone;
@@ -730,16 +728,10 @@ NFCSTATUS phDnldNfc_RawReq(pphDnldNfc_Buff_t pFrameData,
**
*******************************************************************************/
NFCSTATUS phDnldNfc_InitImgInfo(void) {
- NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
- uint8_t* pImageInfo = NULL;
+ NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
+ uint8_t* pImageInfo = NULL;
uint16_t ImageInfoLen = 0;
- uint8_t fwPathLen = 0;
- char* fwFullPath = NULL;
- char fwName[50];
- char fwPath[100];
-
- memset(fwName, 0, sizeof(fwName));
- memset(fwPath, 0, sizeof(fwPath));
+ unsigned long fwType = FW_FORMAT_SO;
/* if memory is not allocated then allocate memory for download context
* structure */
@@ -748,27 +740,22 @@ NFCSTATUS phDnldNfc_InitImgInfo(void) {
gpphDnldContext->FwFormat = FW_FORMAT_UNKNOWN;
/*Read Firmware file name from config file*/
- if (GetNxpStrValue(NAME_NXP_FW_NAME, (char*)fwName, sizeof(fwName)) == true) {
- strcpy(fwPath, FW_DLL_ROOT_DIR);
- strncat(fwPath, fwName, strlen(fwName));
- fwPathLen = strlen(fwPath);
- fwFullPath = fwPath;
+ if (GetNxpNumValue(NAME_NXP_FW_TYPE, &fwType, sizeof(fwType)) == true) {
+ NXPLOG_FWDNLD_D("firmware type from conf file: %lu",fwType);
+ } else {
+ NXPLOG_FWDNLD_W("firmware type not found. Taking default value: %lu",fwType);
}
- if (!memcmp(&fwPath[fwPathLen - 3], ".so", 3) ) {
- gpphDnldContext->FwFormat = FW_FORMAT_SO;
- } else if (!memcmp(&fwPath[fwPathLen - 4], ".bin", 4) ) {
+ if(fwType == FW_FORMAT_BIN) {
gpphDnldContext->FwFormat = FW_FORMAT_BIN;
- }
-
- if(gpphDnldContext->FwFormat == FW_FORMAT_SO) {
- /* load the library and get the image info pointer */
- if (gRecFWDwnld == true)
- wStatus = phDnldNfc_LoadRecoveryFW(fwFullPath, &pImageInfo, &ImageInfoLen);
- else
- wStatus = phDnldNfc_LoadFW(fwFullPath, &pImageInfo, &ImageInfoLen);
- } else if(gpphDnldContext->FwFormat == FW_FORMAT_BIN) {
- wStatus = phDnldNfc_LoadBinFW(fwFullPath, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadBinFW(&pImageInfo, &ImageInfoLen);
+ } else if(fwType == FW_FORMAT_SO) {
+ gpphDnldContext->FwFormat = FW_FORMAT_SO;
+ if (gRecFWDwnld == true) {
+ wStatus = phDnldNfc_LoadRecoveryFW(&pImageInfo, &ImageInfoLen);
+ } else {
+ wStatus = phDnldNfc_LoadFW(&pImageInfo, &ImageInfoLen);
+ }
} else {
NXPLOG_FWDNLD_E("firmware file format mismatch!!!\n");
return NFCSTATUS_FAILED;
@@ -841,10 +828,10 @@ NFCSTATUS phDnldNfc_LoadRecInfo(void) {
* structure */
phDnldNfc_SetHwDevHandle();
if (gRecFWDwnld == true)
- wStatus =
- phDnldNfc_LoadRecoveryFW(PLATFORM_LIB_PATH, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadRecoveryFW(&pImageInfo, &ImageInfoLen);
else
- wStatus = phDnldNfc_LoadFW(PLATFORM_LIB_PATH, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadFW(&pImageInfo, &ImageInfoLen);
+
if ((pImageInfo == NULL) || (ImageInfoLen == 0)) {
NXPLOG_FWDNLD_E(
"Image extraction Failed - invalid imginfo or imginfolen!!");
@@ -895,13 +882,11 @@ NFCSTATUS phDnldNfc_LoadPKInfo(void) {
/* if memory is not allocated then allocate memory for donwload context
* structure */
phDnldNfc_SetHwDevHandle();
-
-/* load the PKU image library */
+ /* load the PKU image library */
if (gRecFWDwnld == true)
- wStatus =
- phDnldNfc_LoadRecoveryFW(PKU_LIB_PATH, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadRecoveryFW(&pImageInfo, &ImageInfoLen);
else
- wStatus = phDnldNfc_LoadFW(PKU_LIB_PATH, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadFW(&pImageInfo, &ImageInfoLen);
if ((pImageInfo == NULL) || (ImageInfoLen == 0)) {
NXPLOG_FWDNLD_E(
"Image extraction Failed - invalid imginfo or imginfolen!!");
@@ -945,18 +930,18 @@ NFCSTATUS phDnldNfc_LoadPKInfo(void) {
*******************************************************************************/
void phDnldNfc_CloseFwLibHandle(void) {
NFCSTATUS wStatus = NFCSTATUS_FAILED;
- if(gpphDnldContext->FwFormat == FW_FORMAT_SO) {
- wStatus = phDnldNfc_UnloadFW();
- if (wStatus != NFCSTATUS_SUCCESS) {
- NXPLOG_FWDNLD_E("free library FAILED !!\n");
- } else {
- NXPLOG_FWDNLD_E("free library SUCCESS !!\n");
- }
- } else if(gpphDnldContext->FwFormat == FW_FORMAT_BIN) {
- if(pFwHandle!=NULL) {
- free(pFwHandle);
- pFwHandle = NULL;
- }
+ if (gpphDnldContext->FwFormat == FW_FORMAT_SO) {
+ wStatus = phDnldNfc_UnloadFW();
+ if (wStatus != NFCSTATUS_SUCCESS) {
+ NXPLOG_FWDNLD_E("free library FAILED !!\n");
+ } else {
+ NXPLOG_FWDNLD_E("free library SUCCESS !!\n");
+ }
+ } else if (gpphDnldContext->FwFormat == FW_FORMAT_BIN) {
+ if (pFwHandle != NULL) {
+ free(pFwHandle);
+ pFwHandle = NULL;
+ }
}
return;
}
@@ -967,36 +952,25 @@ void phDnldNfc_CloseFwLibHandle(void) {
**
** Description Load the firmware version form firmware lib
**
-** Parameters pathName - Firmware image path
-** pImgInfo - Firmware image handle
+** Parameters pImgInfo - Firmware image handle
** pImgInfoLen - Firmware image length
**
** Returns NFC status
**
*******************************************************************************/
-NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t** pImgInfo,
- uint16_t* pImgInfoLen) {
+NFCSTATUS phDnldNfc_LoadFW(uint8_t** pImgInfo, uint16_t* pImgInfoLen) {
void* pImageInfo = NULL;
void* pImageInfoLen = NULL;
- if (pathName == NULL) {
-#if (NFC_NXP_CHIP_TYPE == PN551)
- pathName = "/system/vendor/lib/libpn551_fw.so";
-#elif (NFC_NXP_CHIP_TYPE == PN553)
- pathName = "/system/vendor/lib/libpn553_fw.so";
-#elif (NFC_NXP_CHIP_TYPE == PN557)
- pathName = "/system/vendor/lib/libpn557_fw.so";
-#endif
- }
/* check if the handle is not NULL then free the library */
if (pFwHandle != NULL) {
- phDnldNfc_UnloadFW();
+ phDnldNfc_CloseFwLibHandle();
pFwHandle = NULL;
}
/* load the DLL file */
- pFwHandle = dlopen(pathName, RTLD_LAZY);
- NXPLOG_FWDNLD_D("@@@%s", pathName);
+ pFwHandle = dlopen(nfcFL._FW_LIB_PATH.c_str(), RTLD_LAZY);
+ NXPLOG_FWDNLD_D("@@@%s", nfcFL._FW_LIB_PATH.c_str());
/* if library load failed then handle will be NULL */
if (pFwHandle == NULL) {
@@ -1033,34 +1007,32 @@ NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t** pImgInfo,
**
** Description Load the firmware version form firmware lib
**
-** Parameters pathName - Firmware image path
-** pImgInfo - Firmware image handle
+** Parameters pImgInfo - Firmware image handle
** pImgInfoLen - Firmware image length
**
** Returns NFC status
**
*******************************************************************************/
-NFCSTATUS phDnldNfc_LoadBinFW(const char* pathName, uint8_t **pImgInfo,
- uint16_t* pImgInfoLen) {
- FILE * pFile = NULL;
+NFCSTATUS phDnldNfc_LoadBinFW(uint8_t** pImgInfo, uint16_t* pImgInfoLen) {
+ FILE* pFile = NULL;
uint32_t fileSize = 0;
uint32_t bytesRead = 0;
long ftellFileSize = 0;
/* check for path name */
- if (pathName == NULL) {
+ if (nfcFL._FW_BIN_PATH.c_str() == NULL) {
NXPLOG_FWDNLD_E("Invalid FW file path!!!\n");
return NFCSTATUS_FAILED;
}
/* check if the handle is not NULL then free the memory*/
if (pFwHandle != NULL) {
- free(pFwHandle);
+ phDnldNfc_CloseFwLibHandle();
pFwHandle = NULL;
}
/* Open the FW binary image file to be read */
- pFile = fopen(pathName, "r");
+ pFile = fopen(nfcFL._FW_BIN_PATH.c_str(), "r");
if (NULL == pFile) {
NXPLOG_FWDNLD_E("Failed to load FW binary image file!!!\n");
return NFCSTATUS_FAILED;
@@ -1072,7 +1044,7 @@ NFCSTATUS phDnldNfc_LoadBinFW(const char* pathName, uint8_t **pImgInfo,
/* get the actual length of the file */
ftellFileSize = ftell(pFile);
- if(ftellFileSize > 0) {
+ if (ftellFileSize > 0) {
fileSize = ftellFileSize;
} else {
fileSize = 0;
@@ -1082,17 +1054,18 @@ NFCSTATUS phDnldNfc_LoadBinFW(const char* pathName, uint8_t **pImgInfo,
fseek(pFile, 0, SEEK_SET);
/* allocate the memory to read the FW binary image */
- pFwHandle = (void*)malloc(sizeof(uint8_t)*fileSize);
+ pFwHandle = (void*)malloc(sizeof(uint8_t) * fileSize);
/* check for valid memory allocation */
- if(NULL == pFwHandle) {
+ if (NULL == pFwHandle) {
NXPLOG_FWDNLD_E("Failed to allocate memory to load FW image !!!\n");
fclose(pFile);
return NFCSTATUS_FAILED;
}
/* Read the actual contents of the FW binary image */
- bytesRead = (uint32_t)fread(pFwHandle, sizeof(uint8_t), (size_t)fileSize, pFile);
+ bytesRead =
+ (uint32_t)fread(pFwHandle, sizeof(uint8_t), (size_t)fileSize, pFile);
if (bytesRead != fileSize) {
NXPLOG_FWDNLD_E("Unable to read the specified size from file !!!\n");
fclose(pFile);
@@ -1118,37 +1091,24 @@ NFCSTATUS phDnldNfc_LoadBinFW(const char* pathName, uint8_t **pImgInfo,
** recovery. This will change the FW version of the NFCC
** firmware and enable flashing of firmware of same version.
**
-** Parameters pathName - Firmware image path
-** pImgInfo - Firmware image handle
+** Parameters pImgInfo - Firmware image handle
** pImgInfoLen - Firmware image length
**
** Returns NFCSTATUS
**
*******************************************************************************/
-NFCSTATUS phDnldNfc_LoadRecoveryFW(const char* pathName, uint8_t** pImgInfo,
- uint16_t* pImgInfoLen) {
+NFCSTATUS phDnldNfc_LoadRecoveryFW(uint8_t** pImgInfo, uint16_t* pImgInfoLen) {
void* pImageInfo = NULL;
void* pImageInfoLen = NULL;
- /* check for path name */
- if (pathName == NULL) {
-#if (NFC_NXP_CHIP_TYPE == PN551)
- pathName = "/system/vendor/lib/libpn551_fw.so";
-#elif (NFC_NXP_CHIP_TYPE == PN553)
- pathName = "/system/vendor/lib/libpn553_fw.so";
-#elif(NFC_NXP_CHIP_TYPE == PN557)
- pathName = "/system/vendor/lib/libpn557_fw.so";
-#endif
- }
-
/* check if the handle is not NULL then free the library */
if (pFwHandle != NULL) {
- phDnldNfc_UnloadFW();
+ phDnldNfc_CloseFwLibHandle();
pFwHandle = NULL;
}
/* load the DLL file */
- pFwHandle = dlopen(pathName, RTLD_LAZY);
- NXPLOG_FWDNLD_D("phDnldNfc_LoadRecoveryFW %s ", pathName);
+ pFwHandle = dlopen(nfcFL._FW_LIB_PATH.c_str(), RTLD_LAZY);
+ NXPLOG_FWDNLD_D("phDnldNfc_LoadRecoveryFW %s ", nfcFL._FW_LIB_PATH.c_str());
/* if library load failed then handle will be NULL */
if (pFwHandle == NULL) {
diff --git a/halimpl/dnld/phDnldNfc.h b/halimpl/dnld/phDnldNfc.h
index 0c02a83..ae672ef 100755
--- a/halimpl/dnld/phDnldNfc.h
+++ b/halimpl/dnld/phDnldNfc.h
@@ -128,12 +128,9 @@ extern NFCSTATUS phDnldNfc_InitImgInfo(void);
extern NFCSTATUS phDnldNfc_LoadRecInfo(void);
extern NFCSTATUS phDnldNfc_LoadPKInfo(void);
extern void phDnldNfc_CloseFwLibHandle(void);
-extern NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t** pImgInfo,
- uint16_t* pImgInfoLen);
-extern NFCSTATUS phDnldNfc_LoadBinFW(const char* pathName, uint8_t** pImgInfo,
- uint16_t* pImgInfoLen);
-extern NFCSTATUS phDnldNfc_LoadRecoveryFW(const char* pathName,
- uint8_t** pImgInfo,
+extern NFCSTATUS phDnldNfc_LoadFW(uint8_t** pImgInfo, uint16_t* pImgInfoLen);
+extern NFCSTATUS phDnldNfc_LoadBinFW(uint8_t** pImgInfo, uint16_t* pImgInfoLen);
+extern NFCSTATUS phDnldNfc_LoadRecoveryFW(uint8_t** pImgInfo,
uint16_t* pImgInfoLen);
extern NFCSTATUS phDnldNfc_UnloadFW(void);
#endif /* PHDNLDNFC_H */
diff --git a/halimpl/dnld/phDnldNfc_Internal.cc b/halimpl/dnld/phDnldNfc_Internal.cc
index 87302f8..f5cbb3a 100755
--- a/halimpl/dnld/phDnldNfc_Internal.cc
+++ b/halimpl/dnld/phDnldNfc_Internal.cc
@@ -68,29 +68,6 @@
/* size of EEPROM offset */
#define PHDNLDNFC_USERDATA_EEPROM_OFFSIZE (0x02U)
-#ifdef NXP_PN547C1_DOWNLOAD
-/* EEPROM offset and length value for PN547C1 */
-/* 16 bits offset indicating user data area start location */
-#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x003CU)
-/* 16 bits length of user data area */
-#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0DC0U)
-#else
-
-#if (NFC_NXP_CHIP_TYPE == PN551)
-/* EEPROM offset and length value for PN551 */
-/* 16 bits offset indicating user data area start location */
-#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x02BCU)
-/* 16 bits length of user data area */
-#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0C00U)
-#elif(NFC_NXP_CHIP_TYPE == PN553 || NFC_NXP_CHIP_TYPE == PN557)
-/* EEPROM offset and length value for PN553/PN557 */
-/* 16 bits offset indicating user data area start location */
-#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x02BCU)
-/* 16 bits length of user data area */
-#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0BC0U)
-#endif
-
-#endif
#define PH_LIBNFC_VEN_RESET_ON_DOWNLOAD_TIMEOUT (1)
/* Function prototype declarations */
@@ -706,12 +683,13 @@ static NFCSTATUS phDnldNfc_CreateFramePld(pphDnldNfc_DlContext_t pDlContext) {
} else if (phDnldNfc_ChkIntg == (pDlContext->FrameInp.Type)) {
(pDlContext->tCmdRspFrameInfo.dwSendlength) += PHDNLDNFC_MIN_PLD_LEN;
- wChkIntgVal = PHDNLDNFC_USERDATA_EEPROM_OFFSET;
+ wChkIntgVal = nfcFL._PHDNLDNFC_USERDATA_EEPROM_OFFSET;
+
memcpy(&(pDlContext->tCmdRspFrameInfo
.aFrameBuff[PHDNLDNFC_FRAME_RDDATA_OFFSET]),
&wChkIntgVal, sizeof(wChkIntgVal));
- wChkIntgVal = PHDNLDNFC_USERDATA_EEPROM_LEN;
+ wChkIntgVal = nfcFL._PHDNLDNFC_USERDATA_EEPROM_LEN;
memcpy(&(pDlContext->tCmdRspFrameInfo
.aFrameBuff[PHDNLDNFC_FRAME_RDDATA_OFFSET +
PHDNLDNFC_USERDATA_EEPROM_OFFSIZE]),
diff --git a/halimpl/dnld/phDnldNfc_Internal.h b/halimpl/dnld/phDnldNfc_Internal.h
index ed8f32e..d37a16f 100755
--- a/halimpl/dnld/phDnldNfc_Internal.h
+++ b/halimpl/dnld/phDnldNfc_Internal.h
@@ -120,8 +120,8 @@ typedef enum {
*/
typedef enum phDnldNfc_FwFormat {
FW_FORMAT_UNKNOWN = 0x00,
- FW_FORMAT_BIN = 0x01,
- FW_FORMAT_SO = 0x02,
+ FW_FORMAT_SO = 0x01,
+ FW_FORMAT_BIN = 0x02,
} phDnldNfc_FwFormat_t;
/*
diff --git a/halimpl/dnld/phNxpNciHal_Dnld.cc b/halimpl/dnld/phNxpNciHal_Dnld.cc
index 2af6d8c..ceca050 100755..100644
--- a/halimpl/dnld/phNxpNciHal_Dnld.cc
+++ b/halimpl/dnld/phNxpNciHal_Dnld.cc
@@ -176,26 +176,18 @@ static NFCSTATUS phNxpNciHal_fw_seq_handler(
static NFCSTATUS (*phNxpNciHal_dwnld_seqhandler[])(void* pContext,
NFCSTATUS status,
void* pInfo) = {
- phNxpNciHal_fw_dnld_get_sessn_state,
- phNxpNciHal_fw_dnld_get_version,
- phNxpNciHal_fw_dnld_log_read,
- phNxpNciHal_fw_dnld_write,
- phNxpNciHal_fw_dnld_get_sessn_state,
- phNxpNciHal_fw_dnld_get_version,
- phNxpNciHal_fw_dnld_log,
- phNxpNciHal_fw_dnld_chk_integrity,
- NULL};
+ phNxpNciHal_fw_dnld_get_sessn_state, phNxpNciHal_fw_dnld_get_version,
+ phNxpNciHal_fw_dnld_log_read, phNxpNciHal_fw_dnld_write,
+ phNxpNciHal_fw_dnld_get_sessn_state, phNxpNciHal_fw_dnld_get_version,
+ phNxpNciHal_fw_dnld_log, phNxpNciHal_fw_dnld_chk_integrity, NULL};
/* Array of pointers to start dummy fw download seq */
static NFCSTATUS (*phNxpNciHal_dummy_rec_dwnld_seqhandler[])(void* pContext,
NFCSTATUS status,
void* pInfo) = {
- phNxpNciHal_fw_dnld_normal,
- phNxpNciHal_fw_dnld_normal,
- phNxpNciHal_fw_dnld_get_sessn_state,
- phNxpNciHal_fw_dnld_get_version,
- phNxpNciHal_fw_dnld_log_read,
- phNxpNciHal_fw_dnld_write,
+ phNxpNciHal_fw_dnld_normal, phNxpNciHal_fw_dnld_normal,
+ phNxpNciHal_fw_dnld_get_sessn_state, phNxpNciHal_fw_dnld_get_version,
+ phNxpNciHal_fw_dnld_log_read, phNxpNciHal_fw_dnld_write,
NULL};
/* Download Recovery Sequence */
@@ -530,21 +522,18 @@ static void phNxpNciHal_fw_dnld_get_version_cb(void* pContext, NFCSTATUS status,
bHwVer &= 0x0F; /* 0x0F is the mask to extract chip version */
if ((PHDNLDNFC_HWVER_MRA2_1 == bHwVer) ||
- (PHDNLDNFC_HWVER_MRA2_2 == bHwVer)
-#if (NFC_NXP_CHIP_TYPE == PN551)
- || (PHDNLDNFC_HWVER_PN551_MRA1_0 == bHwVer)
-#elif(NFC_NXP_CHIP_TYPE == PN553 || NFC_NXP_CHIP_TYPE == PN557)
- || (PHDNLDNFC_HWVER_PN553_MRA1_0 == bHwVer ||
- PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED & pRespBuff->pBuff[0])
-#endif
- ) {
+ (PHDNLDNFC_HWVER_MRA2_2 == bHwVer) ||
+ ((nfcFL.chipType == pn551) &&
+ (PHDNLDNFC_HWVER_PN551_MRA1_0 == bHwVer)) ||
+ (((nfcFL.chipType == pn553) || (nfcFL.chipType == pn557)) &&
+ (PHDNLDNFC_HWVER_PN553_MRA1_0 == bHwVer ||
+ PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED & pRespBuff->pBuff[0]))) {
bExpectedLen = PHLIBNFC_IOCTL_DNLD_GETVERLEN_MRA2_1;
(gphNxpNciHal_fw_IoctlCtx.bChipVer) = bHwVer;
-#if (NFC_NXP_CHIP_TYPE == PN553)
- if (PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED & pRespBuff->pBuff[0]) {
+ if ((nfcFL.chipType == pn553) &&
+ (PHDNLDNFC_HWVER_PN553_MRA1_0_UPDATED & pRespBuff->pBuff[0])) {
(gphNxpNciHal_fw_IoctlCtx.bChipVer) = pRespBuff->pBuff[0];
}
-#endif
} else if ((bHwVer >= PHDNLDNFC_HWVER_MRA1_0) &&
(bHwVer <= PHDNLDNFC_HWVER_MRA2_0)) {
bExpectedLen = PHLIBNFC_IOCTL_DNLD_GETVERLEN;
@@ -1501,7 +1490,7 @@ static NFCSTATUS phNxpNciHal_fw_seq_handler(
while (seq_handler[seq_counter] != NULL) {
status = NFCSTATUS_FAILED;
- status = (seq_handler[seq_counter])((void *)pContext, status, &pInfo);
+ status = (seq_handler[seq_counter])((void*)pContext, status, &pInfo);
if (NFCSTATUS_SUCCESS != status) {
NXPLOG_FWDNLD_E(" phNxpNciHal_fw_seq_handler : FAILED");
break;
@@ -1712,8 +1701,7 @@ NFCSTATUS phNxpNciHal_fw_download_seq(uint8_t bClkSrcVal, uint8_t bClkFreqVal) {
if (gRecFWDwnld == true) {
status =
phNxpNciHal_fw_seq_handler(phNxpNciHal_dummy_rec_dwnld_seqhandler);
- } else
- {
+ } else {
status = phNxpNciHal_fw_seq_handler(phNxpNciHal_dwnld_seqhandler);
}
} else {
@@ -1721,7 +1709,7 @@ NFCSTATUS phNxpNciHal_fw_download_seq(uint8_t bClkSrcVal, uint8_t bClkFreqVal) {
}
/* Chage to normal mode */
- status = phNxpNciHal_fw_dnld_complete((void *)pContext, status, &pInfo);
+ status = phNxpNciHal_fw_dnld_complete((void*)pContext, status, &pInfo);
/*if (NFCSTATUS_SUCCESS == status)
{
NXPLOG_FWDNLD_D(" phNxpNciHal_fw_dnld_complete : SUCCESS");
@@ -1735,14 +1723,8 @@ NFCSTATUS phNxpNciHal_fw_download_seq(uint8_t bClkSrcVal, uint8_t bClkFreqVal) {
}
static NFCSTATUS phLibNfc_VerifyCrcStatus(uint8_t bCrcStatus) {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
- || (NFC_NXP_CHIP_TYPE == PN557))
uint8_t bBitPos = 1;
uint8_t bShiftVal = 2;
-#else
- uint8_t bBitPos = 0;
- uint8_t bShiftVal = 1;
-#endif
NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
while (bBitPos < 7) {
if (!(bCrcStatus & bShiftVal)) {
diff --git a/halimpl/hal/phNxpNciHal.cc b/halimpl/hal/phNxpNciHal.cc
index af2062f..65bc7d9 100755
--- a/halimpl/hal/phNxpNciHal.cc
+++ b/halimpl/hal/phNxpNciHal.cc
@@ -37,22 +37,7 @@ using namespace android::hardware::nfc::V1_1;
#define PN547C2_CLOCK_SETTING
#undef PN547C2_FACTORY_RESET_DEBUG
#define CORE_RES_STATUS_BYTE 3
-/* FW Mobile major number */
-#define FW_MOBILE_MAJOR_NUMBER_PN553 0x01
-#define FW_MOBILE_MAJOR_NUMBER_PN81A 0x02
-#define FW_MOBILE_MAJOR_NUMBER_PN551 0x05
-#define FW_MOBILE_MAJOR_NUMBER_PN48AD 0x01
-#define FW_MOBILE_MAJOR_NUMBER_PN557 0x01
-
-#if (NFC_NXP_CHIP_TYPE == PN551)
-#define FW_MOBILE_MAJOR_NUMBER FW_MOBILE_MAJOR_NUMBER_PN551
-#elif (NFC_NXP_CHIP_TYPE == PN553)
-#define FW_MOBILE_MAJOR_NUMBER FW_MOBILE_MAJOR_NUMBER_PN553
-#elif(NFC_NXP_CHIP_TYPE == PN557)
-#define FW_MOBILE_MAJOR_NUMBER FW_MOBILE_MAJOR_NUMBER_PN557
-#else
-#define FW_MOBILE_MAJOR_NUMBER FW_MOBILE_MAJOR_NUMBER_PN48AD
-#endif
+
/* Processing of ISO 15693 EOF */
extern uint8_t icode_send_eof;
extern uint8_t icode_detected;
@@ -348,20 +333,9 @@ static NFCSTATUS phNxpNciHal_CheckValidFwVersion(void) {
/* extract the firmware's major no */
ufw_current_major_no = ((0x00FF) & (wFwVer >> 8U));
- NXPLOG_NCIHAL_D("%s current_major_no = 0x%x", __FUNCTION__,
- ufw_current_major_no);
- if ((ufw_current_major_no == FW_MOBILE_MAJOR_NUMBER) ||
- ((ufw_current_major_no == FW_MOBILE_MAJOR_NUMBER_PN81A &&
+ if ((ufw_current_major_no == nfcFL._FW_MOBILE_MAJOR_NUMBER) ||
+ ((ufw_current_major_no == FW_MOBILE_MAJOR_NUMBER_PN81A) &&
(nxpncihal_ctrl.nci_info.nci_version == NCI_VERSION_2_0)))
-#if (NFC_NXP_CHIP_TYPE == PN553)
- || ((rom_version == 0x00) &&
- (ufw_current_major_no == FW_MOBILE_MAJOR_NUMBER_PN81A))
-#elif (NFC_NXP_CHIP_TYPE == PN557)
- || ((rom_version == FW_MOBILE_MAJOR_NUMBER) &&
- (ufw_current_major_no == FW_MOBILE_MAJOR_NUMBER_PN557))
-#endif
- )
-
{
status = NFCSTATUS_SUCCESS;
} else if (ufw_current_major_no == sfw_infra_major_no) {
@@ -614,17 +588,17 @@ init_retry:
goto clean_and_return;
}
- status = phNxpNciHal_send_ext_cmd(sizeof(cmd_init_nci2_0), cmd_init_nci2_0);
- if (status == NFCSTATUS_SUCCESS) {
- if (nxpncihal_ctrl.nci_info.nci_version != NCI_VERSION_2_0) {
- NXPLOG_NCIHAL_E("Chip is in NCI1.0 mode reset the chip again");
+ if(nxpncihal_ctrl.nci_info.nci_version == NCI_VERSION_2_0) {
+ status = phNxpNciHal_send_ext_cmd(sizeof(cmd_init_nci2_0), cmd_init_nci2_0);
+ } else {
+ status = phNxpNciHal_send_ext_cmd(sizeof(cmd_init_nci), cmd_init_nci);
+ if(status == NFCSTATUS_SUCCESS && (nfcFL.chipType == pn557)) {
+ NXPLOG_NCIHAL_E("Chip is in NCI1.0 mode reset the chip to 2.0 mode");
status = phNxpNciHal_send_ext_cmd(sizeof(cmd_reset_nci), cmd_reset_nci);
- if (status == NFCSTATUS_SUCCESS) {
- if (nxpncihal_ctrl.nci_info.nci_version == NCI_VERSION_2_0) {
- status = phNxpNciHal_send_ext_cmd(sizeof(cmd_init_nci2_0),
- cmd_init_nci2_0);
- } else {
- status = phNxpNciHal_send_ext_cmd(sizeof(cmd_init_nci), cmd_init_nci);
+ if(status == NFCSTATUS_SUCCESS) {
+ status = phNxpNciHal_send_ext_cmd(sizeof(cmd_init_nci2_0), cmd_init_nci2_0);
+ if(status == NFCSTATUS_SUCCESS) {
+ goto init_retry;
}
}
}
@@ -778,15 +752,15 @@ clean_and_return:
******************************************************************************/
int phNxpNciHal_fw_mw_ver_check() {
NFCSTATUS status = NFCSTATUS_FAILED;
- if (!(strcmp(COMPILATION_MW, "PN557")) &&
+ if ((nfcFL.chipType == pn557) &&
(rom_version == FW_MOBILE_ROM_VERSION_PN557) &&
(fw_maj_ver == 0x01)) {
status = NFCSTATUS_SUCCESS;
- } else if (!(strcmp(COMPILATION_MW, "PN553")) &&
+ } else if ((nfcFL.chipType == pn553) &&
(rom_version == FW_MOBILE_ROM_VERSION_PN553) &&
(fw_maj_ver == 0x01 || fw_maj_ver == 0x02)) {
status = NFCSTATUS_SUCCESS;
- } else if (!strcmp(COMPILATION_MW, "PN551") &&
+ } else if ((nfcFL.chipType == pn551) &&
(rom_version == FW_MOBILE_ROM_VERSION_PN551) &&
(fw_maj_ver == 0x05)) {
status = NFCSTATUS_SUCCESS;
@@ -1152,10 +1126,8 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) {
static uint8_t cmd_ven_enable[] = {0x20, 0x02, 0x05, 0x01,
0xA0, 0x07, 0x01, 0x01};
-#ifndef NXP_NFC_CHIP_PN81T
static uint8_t android_l_aid_matching_mode_on_cmd[] = {
0x20, 0x02, 0x05, 0x01, 0xA0, 0x91, 0x01, 0x01};
-#endif
static uint8_t swp_switch_timeout_cmd[] = {0x20, 0x02, 0x06, 0x01, 0xA0,
0xF3, 0x02, 0x00, 0x00};
config_success = true;
@@ -1677,9 +1649,8 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) {
}
}
-#ifndef NXP_NFC_CHIP_PN81T
/* Android L AID Matching Platform Setting*/
- if (GetNxpNumValue(NAME_AID_MATCHING_PLATFORM, (void*)&retlen,
+ if ((nfcFL.chipType != pn557) && GetNxpNumValue(NAME_AID_MATCHING_PLATFORM, (void*)&retlen,
sizeof(retlen))) {
if (1 == retlen) {
status =
@@ -1702,7 +1673,6 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) {
}
}
}
-#endif
if ((*p_core_init_rsp_params > 0) && (*p_core_init_rsp_params < 4)) {
static phLibNfc_Message_t msg;
@@ -2528,12 +2498,11 @@ retrySetclock:
if (nxpprofile_ctrl.bClkSrcVal == CLK_SRC_PLL) {
static uint8_t set_clock_cmd[] = {0x20, 0x02, 0x09, 0x02, 0xA0, 0x03,
0x01, 0x11, 0xA0, 0x04, 0x01, 0x01};
-#if (NFC_NXP_CHIP_TYPE == PN553 || NFC_NXP_CHIP_TYPE == PN557)
uint8_t param_clock_src = 0x00;
-#else
- uint8_t param_clock_src = CLK_SRC_PLL;
- param_clock_src = param_clock_src << 3;
-#endif
+ if((nfcFL.chipType != pn553)&&(nfcFL.chipType != pn557)) {
+ uint8_t param_clock_src = CLK_SRC_PLL;
+ param_clock_src = param_clock_src << 3;
+ }
if (nxpprofile_ctrl.bClkFreqVal == CLK_FREQ_13MHZ) {
param_clock_src |= 0x00;
@@ -2549,11 +2518,11 @@ retrySetclock:
param_clock_src |= 0x05;
} else {
NXPLOG_NCIHAL_E("Wrong clock freq, send default PLL@19.2MHz");
-#if (NFC_NXP_CHIP_TYPE == PN553 || NFC_NXP_CHIP_TYPE == PN557)
- param_clock_src = 0x01;
-#else
- param_clock_src = 0x11;
-#endif
+ if((nfcFL.chipType == pn553) || (nfcFL.chipType == pn557)) {
+ param_clock_src = 0x01;
+ } else {
+ param_clock_src = 0x11;
+ }
}
set_clock_cmd[7] = param_clock_src;
@@ -2749,9 +2718,9 @@ static void phNxpNciHal_gpio_restore(phNxpNciHal_GpioInfoState state) {
int check_config_parameter() {
uint8_t param_clock_src = CLK_SRC_PLL;
if (nxpprofile_ctrl.bClkSrcVal == CLK_SRC_PLL) {
-#if (NFC_NXP_CHIP_TYPE != PN553 && NFC_NXP_CHIP_TYPE != PN557)
- param_clock_src = param_clock_src << 3;
-#endif
+ if((nfcFL.chipType != pn553)&&(nfcFL.chipType != pn557)) {
+ param_clock_src = param_clock_src << 3;
+ }
if (nxpprofile_ctrl.bClkFreqVal == CLK_FREQ_13MHZ) {
param_clock_src |= 0x00;
} else if (nxpprofile_ctrl.bClkFreqVal == CLK_FREQ_19_2MHZ) {
@@ -2916,6 +2885,26 @@ static void phNxpNciHal_check_factory_reset(void) {
#endif
}
+/*******************************************************************************
+**
+** Function phNxpNciHal_configFeatureList
+**
+** Description Configures the featureList based on chip type
+** HW Version information number will provide chipType.
+** HW Version can be obtained from CORE_INIT_RESPONSE(NCI 1.0)
+** or CORE_RST_NTF(NCI 2.0)
+**
+** Parameters CORE_INIT_RESPONSE/CORE_RST_NTF, len
+**
+** Returns none
+*******************************************************************************/
+void phNxpNciHal_configFeatureList(uint8_t* init_rsp, uint16_t rsp_len) {
+ nxpncihal_ctrl.chipType = pConfigFL->processChipType(init_rsp,rsp_len);
+ tNFC_chipType chipType = nxpncihal_ctrl.chipType;
+ CONFIGURE_FEATURELIST(chipType);
+ NXPLOG_NCIHAL_D("NFC_GetFeatureList ()chipType = %d", chipType);
+}
+
/******************************************************************************
* Function phNxpNciHal_print_res_status
*
diff --git a/halimpl/hal/phNxpNciHal.h b/halimpl/hal/phNxpNciHal.h
index 9a216e1..e9cfe06 100755
--- a/halimpl/hal/phNxpNciHal.h
+++ b/halimpl/hal/phNxpNciHal.h
@@ -18,6 +18,7 @@
#include <hardware/nfc.h>
#include <phNxpNciHal_utils.h>
+#include "NxpNfcCapability.h"
/********************* Definitions and structures *****************************/
#define MAX_RETRY_COUNT 5
@@ -47,7 +48,6 @@ typedef void(phNxpNciHal_control_granted_callback_t)();
#define NCI_MSG_CORE_INIT 0x01
#define NCI_MT_MASK 0xE0
#define NCI_OID_MASK 0x3F
-#define NXP_NFC_CHIP_PN81T
#define NXP_MAX_CONFIG_STRING_LEN 260
@@ -127,6 +127,7 @@ typedef struct phNxpNciHal_Control {
/* to store and restore gpio values */
phNxpNciGpioInfo_t phNxpNciGpioInfo;
+ tNFC_chipType chipType;
} phNxpNciHal_Control_t;
typedef struct phNxpNciClock {
@@ -175,4 +176,13 @@ int phNxpNciHal_check_ncicmd_write_window(uint16_t cmd_len, uint8_t* p_cmd);
void phNxpNciHal_request_control(void);
void phNxpNciHal_release_control(void);
int phNxpNciHal_write_unlocked(uint16_t data_len, const uint8_t* p_data);
+/*******************************************************************************
+**
+** Function phNxpNciHal_configFeatureList
+**
+** Description Configures the featureList based on chip type
+
+** Returns none
+*******************************************************************************/
+void phNxpNciHal_configFeatureList(uint8_t* init_rsp, uint16_t rsp_len);
#endif /* _PHNXPNCIHAL_H_ */
diff --git a/halimpl/hal/phNxpNciHal_ext.cc b/halimpl/hal/phNxpNciHal_ext.cc
index a24317c..646a07b 100755
--- a/halimpl/hal/phNxpNciHal_ext.cc
+++ b/halimpl/hal/phNxpNciHal_ext.cc
@@ -395,6 +395,7 @@ NFCSTATUS phNxpNciHal_process_ext_rsp(uint8_t* p_ntf, uint16_t* p_len) {
static NFCSTATUS phNxpNciHal_ext_process_nfc_init_rsp(uint8_t* p_ntf,
uint16_t* p_len) {
NFCSTATUS status = NFCSTATUS_SUCCESS;
+
/* Parsing CORE_RESET_RSP and CORE_RESET_NTF to update NCI version.*/
if (p_ntf == NULL || *p_len == 0x00) {
return NFCSTATUS_FAILED;
@@ -416,6 +417,10 @@ static NFCSTATUS phNxpNciHal_ext_process_nfc_init_rsp(uint8_t* p_ntf,
p_ntf[3] == CORE_RESET_TRIGGER_TYPE_POWERED_ON) {
NXPLOG_NCIHAL_D("CORE_RESET_NTF NCI2.0 reason CORE_RESET_CMD received !");
nxpncihal_ctrl.nci_info.nci_version = p_ntf[5];
+ NXPLOG_NCIHAL_D("nci_version : 0x%02x",nxpncihal_ctrl.nci_info.nci_version);
+ if(!nxpncihal_ctrl.hal_open_status) {
+ phNxpNciHal_configFeatureList(p_ntf,*p_len);
+ }
int len = p_ntf[2] + 2; /*include 2 byte header*/
wFwVerRsp = (((uint32_t)p_ntf[len - 2]) << 16U) |
(((uint32_t)p_ntf[len - 1]) << 8U) | p_ntf[len];
@@ -442,6 +447,9 @@ static NFCSTATUS phNxpNciHal_ext_process_nfc_init_rsp(uint8_t* p_ntf,
NXPLOG_NCIHAL_D("CORE_INIT_RSP NCI2.0 received !");
} else {
NXPLOG_NCIHAL_D("CORE_INIT_RSP NCI1.0 received !");
+ if(!nxpncihal_ctrl.hal_open_status) {
+ phNxpNciHal_configFeatureList(p_ntf,*p_len);
+ }
int len = p_ntf[2] + 2; /*include 2 byte header*/
wFwVerRsp = (((uint32_t)p_ntf[len - 2]) << 16U) |
(((uint32_t)p_ntf[len - 1]) << 8U) | p_ntf[len];
diff --git a/halimpl/libnfc-nxp-PN553_example.conf b/halimpl/libnfc-nxp-PN553_example.conf
index 818e473..e11e495 100755
--- a/halimpl/libnfc-nxp-PN553_example.conf
+++ b/halimpl/libnfc-nxp-PN553_example.conf
@@ -28,8 +28,10 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File name for Firmware
-NXP_FW_NAME="libpn553_fw.so"
+# Firmware file type
+#.so file 0x01
+#.bin file 0x02
+NXP_FW_TYPE=0x01
###############################################################################
# System clock source selection configuration
diff --git a/halimpl/libnfc-nxp-PN553_example_NCI2_0.conf b/halimpl/libnfc-nxp-PN553_example_NCI2_0.conf
index 935b73e..f683666 100755
--- a/halimpl/libnfc-nxp-PN553_example_NCI2_0.conf
+++ b/halimpl/libnfc-nxp-PN553_example_NCI2_0.conf
@@ -28,8 +28,10 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File name for Firmware
-NXP_FW_NAME="libpn553_fw.so"
+# Firmware file type
+#.so file 0x01
+#.bin file 0x02
+NXP_FW_TYPE=0x01
###############################################################################
# System clock source selection configuration
diff --git a/halimpl/libnfc-nxp-PN80T_example.conf b/halimpl/libnfc-nxp-PN80T_example.conf
index 45d276c..634435c 100755
--- a/halimpl/libnfc-nxp-PN80T_example.conf
+++ b/halimpl/libnfc-nxp-PN80T_example.conf
@@ -28,8 +28,10 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File name for Firmware
-NXP_FW_NAME="libpn553_fw.so"
+# Firmware file type
+#.so file 0x01
+#.bin file 0x02
+NXP_FW_TYPE=0x01
###############################################################################
# System clock source selection configuration
diff --git a/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf b/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf
index 185b07d..aa4883d 100755
--- a/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf
+++ b/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf
@@ -28,8 +28,10 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File name for Firmware
-NXP_FW_NAME="libpn553_fw.so"
+# Firmware file type
+#.so file 0x01
+#.bin file 0x02
+NXP_FW_TYPE=0x01
###############################################################################
# System clock source selection configuration
diff --git a/halimpl/libnfc-nxp-PN81T_example_NCI2_0.conf b/halimpl/libnfc-nxp-PN81T_example_NCI2_0.conf
index 979d04d..a2b9465 100755
--- a/halimpl/libnfc-nxp-PN81T_example_NCI2_0.conf
+++ b/halimpl/libnfc-nxp-PN81T_example_NCI2_0.conf
@@ -29,10 +29,10 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File name for Firmware
-# for library format ex: libpn5xx_fw.so
-# for binary format ex: pn5xx.bin
-NXP_FW_NAME="pn557.bin"
+# Firmware file type
+#.so file 0x01
+#.bin file 0x02
+NXP_FW_TYPE=0x01
###############################################################################
# System clock source selection configuration
diff --git a/halimpl/utils/NxpNfcCapability.cpp b/halimpl/utils/NxpNfcCapability.cpp
new file mode 100644
index 0000000..fc0a6c3
--- /dev/null
+++ b/halimpl/utils/NxpNfcCapability.cpp
@@ -0,0 +1,94 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2015 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#define LOG_TAG "NxpHal"
+#include "NxpNfcCapability.h"
+#include <phNxpLog.h>
+
+capability* capability::instance = NULL;
+tNFC_chipType capability::chipType = pn81T;
+tNfc_featureList nfcFL;
+
+capability::capability() {}
+
+capability* capability::getInstance() {
+ if (NULL == instance) {
+ instance = new capability();
+ }
+ return instance;
+}
+
+tNFC_chipType capability::processChipType(uint8_t* msg, uint16_t msg_len) {
+ if ((msg != NULL) && (msg_len != 0)) {
+ if (msg[0] == 0x60 && msg[1] == 00) {
+ if ((msg[offsetRstFwVersion] == 0x12) &&
+ (msg[offsetRstFwVersion + 1] == 0x01)) {
+ chipType = pn81T;
+ } else if ((msg[offsetRstFwVersion] == 0x11) &&
+ (msg[offsetRstFwVersion + 1] == 0x02)) {
+ chipType = pn553;
+ }
+ } else if ((offsetInitFwVersion < msg_len) &&
+ (msg[offsetInitFwVersion] == 0x12)) {
+ chipType = pn81T;
+ }
+
+ else if (offsetHwVersion < msg_len) {
+ ALOGD("%s HwVersion : 0x%02x", __func__, msg[offsetHwVersion]);
+ switch (msg[offsetHwVersion]) {
+ case 0x40: // PN553 A0
+ case 0x41: // PN553 B0
+ // NQ310
+ chipType = pn553;
+ break;
+
+ case 0x50: // PN553 A0 + P73
+ case 0x51: // PN553 B0 + P73 , NQ440
+ // NQ330
+ chipType = pn80T;
+ break;
+
+ case 0x98:
+ chipType = pn551;
+ break;
+
+ case 0xA8:
+ case 0x08:
+ chipType = pn67T;
+ break;
+
+ case 0x28:
+ case 0x48: // NQ210
+ chipType = pn548C2;
+ break;
+
+ case 0x18:
+ case 0x58: // NQ220
+ chipType = pn66T;
+ break;
+
+ default:
+ chipType = pn80T;
+ }
+ } else {
+ ALOGD("%s Wrong msg_len. Setting Default ChiptType pn80T", __func__);
+ chipType = pn81T;
+ }
+ }
+ ALOGD("%s Product : %s", __func__, product[chipType]);
+ return chipType;
+}
diff --git a/halimpl/utils/NxpNfcCapability.h b/halimpl/utils/NxpNfcCapability.h
new file mode 100644
index 0000000..41e7b64
--- /dev/null
+++ b/halimpl/utils/NxpNfcCapability.h
@@ -0,0 +1,41 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2015 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+#ifndef __CAP_H__
+#define __CAP_H__
+#include "Nxp_Features.h"
+#define pConfigFL (capability::getInstance())
+
+class capability {
+ private:
+ static capability* instance;
+ const uint16_t offsetHwVersion = 24;
+ const uint16_t offsetInitFwVersion = 25;
+ const uint16_t offsetRstFwVersion = 9;
+ /*product[] will be used to print product version and
+ should be kept in accordance with tNFC_chipType*/
+ const char* product[11] = {"UNKNOWN", "PN547C2", "PN65T", "PN548C2",
+ "PN66T", "PN551", "PN67T", "PN553",
+ "PN80T", "PN557", "PN81T"};
+ capability();
+
+ public:
+ static tNFC_chipType chipType;
+ static capability* getInstance();
+ tNFC_chipType processChipType(uint8_t* msg, uint16_t msg_len);
+};
+#endif
diff --git a/halimpl/utils/phNxpConfig.h b/halimpl/utils/phNxpConfig.h
index 496cc24..e775d7c 100755
--- a/halimpl/utils/phNxpConfig.h
+++ b/halimpl/utils/phNxpConfig.h
@@ -65,7 +65,7 @@ int updateNxpConfigTimestamp();
#define NAME_MIFARE_READER_ENABLE "MIFARE_READER_ENABLE"
#define NAME_FW_STORAGE "FW_STORAGE"
#define NAME_NXP_NFC_DEV_NODE "NXP_NFC_DEV_NODE"
-#define NAME_NXP_FW_NAME "NXP_FW_NAME"
+#define NAME_NXP_FW_TYPE "NXP_FW_TYPE"
#define NAME_NXP_FW_PROTECION_OVERRIDE "NXP_FW_PROTECION_OVERRIDE"
#define NAME_NXP_SYS_CLK_SRC_SEL "NXP_SYS_CLK_SRC_SEL"
#define NAME_NXP_SYS_CLK_FREQ_SEL "NXP_SYS_CLK_FREQ_SEL"
diff --git a/halimpl/utils/phNxpNciHal_utils.cc b/halimpl/utils/phNxpNciHal_utils.cc
index c38e19a..4f50a10 100755..100644
--- a/halimpl/utils/phNxpNciHal_utils.cc
+++ b/halimpl/utils/phNxpNciHal_utils.cc
@@ -23,7 +23,6 @@
#include <phNxpNciHal.h>
#include <phNxpNciHal_utils.h>
-
/*********************** Link list functions **********************************/
/*******************************************************************************
@@ -338,10 +337,9 @@ void phNxpNciHal_cleanup_monitor(void) {
**
*******************************************************************************/
phNxpNciHal_Monitor_t* phNxpNciHal_get_monitor(void) {
- if(nxpncihal_monitor == NULL)
- {
+ if (nxpncihal_monitor == NULL) {
NXPLOG_NCIHAL_E("nxpncihal_monitor is null");
- }
+ }
return nxpncihal_monitor;
}