NFC: Fix SWP set/get configuration for NQ2xx
Set/get configuration command for SWP1A fails
in case of device using NQ2xx chipset
Changes done to dynamically modify the set/get
config commands for SWPs configuration
Change-Id: Ic0e20363036647287bebe94056a0dc7a78fc8675
diff --git a/halimpl/pn54x/dnld/phDnldNfc.c b/halimpl/pn54x/dnld/phDnldNfc.c
index af971c7..09882d2 100644
--- a/halimpl/pn54x/dnld/phDnldNfc.c
+++ b/halimpl/pn54x/dnld/phDnldNfc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2015 NXP Semiconductors
@@ -27,7 +27,6 @@
#include <phNxpLog.h>
#include <dlfcn.h>
#include <phNxpConfig.h>
-#include <cutils/properties.h>
static void*
pFwLibHandle; /* Global firmware lib handle used in this file only */
@@ -242,8 +241,6 @@
NFCSTATUS phDnldNfc_CheckIntegrity(uint8_t bChipVer, pphDnldNfc_Buff_t pCRCData,
pphDnldNfc_RspCb_t pNotify, void* pContext) {
NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
- int rc;
- char nq_chipid[PROPERTY_VALUE_MAX] = {0};
if ((NULL == pNotify) || (NULL == pContext)) {
NXPLOG_FWDNLD_E("Invalid Input Parameters!!");
@@ -253,11 +250,6 @@
NXPLOG_FWDNLD_E("Dnld Cmd Request in Progress..Cannot Continue!!");
wStatus = PHNFCSTVAL(CID_NFC_DNLD, NFCSTATUS_BUSY);
} else {
- rc = __system_property_get("sys.nfc.nq.chipid", nq_chipid);
- if (rc <= 0)
- ALOGE("get sys.nfc.nq.chipid fail, rc = %d\n", rc);
- else
- ALOGD("sys.nfc.nq.chipid = %s\n", nq_chipid);
if ((PHDNLDNFC_HWVER_MRA2_1 == bChipVer) ||
(PHDNLDNFC_HWVER_MRA2_2 == bChipVer) ||
((nfcFL.chipType == pn551) &&
diff --git a/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c b/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
index 2aceca3..100b72b 100644
--- a/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
+++ b/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
@@ -1,4 +1,7 @@
/*
+ * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
* Copyright (C) 2015 NXP Semiconductors
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +23,6 @@
#include <phNxpNciHal_utils.h>
#include <phNxpLog.h>
#include <phNxpConfig.h>
-#include <cutils/properties.h>
/* Macro */
#define PHLIBNFC_IOCTL_DNLD_MAX_ATTEMPTS 3
@@ -526,8 +528,6 @@
uint8_t bExpectedLen = 0;
uint8_t bNewVer[2];
uint8_t bCurrVer[2];
- int rc;
- char nq_chipid[PROPERTY_VALUE_MAX] = {0};
if ((NFCSTATUS_SUCCESS == wStatus) && (NULL != pInfo)) {
NXPLOG_FWDNLD_D("phNxpNciHal_fw_dnld_get_version_cb - Request Successful");
@@ -537,12 +537,6 @@
if ((0 != pRespBuff->wLen) && (NULL != pRespBuff->pBuff)) {
bHwVer = (pRespBuff->pBuff[0]);
bHwVer &= 0x0F; /* 0x0F is the mask to extract chip version */
-
- rc = __system_property_get("sys.nfc.nq.chipid", nq_chipid);
- if (rc <= 0)
- ALOGE("get sys.nfc.nq.chipid fail, rc = %d\n", rc);
- else
- ALOGD("sys.nfc.nq.chipid = %s\n", nq_chipid);
if ((PHDNLDNFC_HWVER_MRA2_1 == bHwVer) ||
(PHDNLDNFC_HWVER_MRA2_2 == bHwVer) ||
((nfcFL.chipType == pn551) &&
diff --git a/halimpl/pn54x/hal/phNxpNciHal.c b/halimpl/pn54x/hal/phNxpNciHal.c
index 30968c0..e7ad6cd 100644
--- a/halimpl/pn54x/hal/phNxpNciHal.c
+++ b/halimpl/pn54x/hal/phNxpNciHal.c
@@ -30,7 +30,6 @@
#include <phNxpNciHal_NfcDepSWPrio.h>
#include <phNxpNciHal_Kovio.h>
#include <phTmlNfc_i2c.h>
-#include <cutils/properties.h>
#include "phNxpNciHal_nciParser.h"
/*********************** Global Variables *************************************/
#define PN547C2_CLOCK_SETTING
@@ -1693,17 +1692,9 @@
uint8_t swp_info_buff[2];
uint8_t swp_intf_status = 0x00;
uint8_t swp1A_intf_status = 0x00;
- char nq_chipid[PROPERTY_VALUE_MAX] = {0};
- int rc = 0;
NFCSTATUS status = NFCSTATUS_FAILED;
phNxpNci_EEPROM_info_t swp_intf_info;
- rc = __system_property_get("sys.nfc.nq.chipid", nq_chipid);
- if (rc <= 0) {
- NXPLOG_NCIHAL_E("get sys.nfc.nq.chipid fail, rc = %d\n", rc);
- }
- else {
- NXPLOG_NCIHAL_D("sys.nfc.nq.chipid = %s\n", nq_chipid);
- }
+
memset(swp_info_buff, 0, sizeof(swp_info_buff));
/*Read SWP1 data*/
memset(&swp_intf_info, 0, sizeof(swp_intf_info));
@@ -1718,8 +1709,7 @@
NXPLOG_NCIHAL_E("request_EEPROM error occured %d", status);
NXP_NCI_HAL_CORE_INIT_RECOVER(retry_core_init_cnt, retry_core_init);
}
- if ((rc > 0) && (strncmp(nq_chipid, NQ220, PROPERTY_VALUE_MAX) != 0) &&
- (strncmp(nq_chipid, NQ210, PROPERTY_VALUE_MAX) != 0)) {
+ if ((nfcFL.chipType == pn551) || (nfcFL.chipType == pn553) || (nfcFL.chipType == pn557)) {
/*Read SWP1A data*/
memset(&swp_intf_info, 0, sizeof(swp_intf_info));
swp_intf_info.request_mode = GET_EEPROM_DATA;
@@ -2216,7 +2206,7 @@
if (status == NFCSTATUS_FAILED) {
/*Disable SWP1 and 1A interfaces*/
- if(nfcFL.nfccFL._NFC_NXP_STAT_DUAL_UICC_WO_EXT_SWITCH) {
+ if ((nfcFL.chipType == pn551) || (nfcFL.chipType == pn553) || (nfcFL.chipType == pn557)) {
status = phNxpNciHal_send_ext_cmd(sizeof(disable_dual_swp_intf),
disable_dual_swp_intf);
}
diff --git a/halimpl/pn54x/utils/phNxpConfig.cpp b/halimpl/pn54x/utils/phNxpConfig.cpp
index 7e688ac..fae228e 100644
--- a/halimpl/pn54x/utils/phNxpConfig.cpp
+++ b/halimpl/pn54x/utils/phNxpConfig.cpp
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2011-2012 Broadcom Corporation
@@ -297,6 +297,7 @@
char soc_info[MAX_SOC_INFO_NAME_LEN] = {'\0'};
char nq_chipid[PROPERTY_VALUE_MAX] = {0};
char nq_fw_ver[PROPERTY_VALUE_MAX] = {0};
+ bool nq2xx_present = false;
string strPath;
int rc = 0;
int idx = 0;
@@ -316,16 +317,19 @@
rc = __system_property_get("sys.nfc.nq.chipid", nq_chipid);
if (rc <= 0)
- ALOGE("get sys.nfc.nq.chipid fail, rc = %d\n", rc);
+ ALOGE("get sys.nfc.nq.chipid fail, chipid_found = %d\n", rc);
else
ALOGD("sys.nfc.nq.chipid = %s\n", nq_chipid);
rc = __system_property_get("sys.nfc.nq.fwver", nq_fw_ver);
if (rc <= 0)
- ALOGE("get sys.nfc.nq.fwver fail, rc = %d\n", rc);
+ ALOGE("get sys.nfc.nq.fwver fail, fwver found = %d\n", rc);
else
ALOGD("sys.nfc.nq.fwver = %s\n", nq_fw_ver);
+ nq2xx_present = (!strncmp(nq_chipid, NQ220, PROPERTY_VALUE_MAX))
+ || (!strncmp(nq_chipid, NQ210, PROPERTY_VALUE_MAX));
+
// Converting the HW_PLATFORM detail that is read from target to lowercase
for (int i=0;target_type[i];i++)
target_type[i] = tolower(target_type[i]);
@@ -357,7 +361,7 @@
case TARGET_MSM8937:
case TARGET_MSM8917:
case TARGET_MSM8940:
- if ((!strncmp(nq_chipid, NQ220, PROPERTY_VALUE_MAX)) || (!strncmp(nq_chipid, NQ210, PROPERTY_VALUE_MAX))) {
+ if (nq2xx_present) {
// NQ210 or NQ220
config_id = QRD_TYPE_DEFAULT;
strlcpy(config_file, config_name_qrd, MAX_DATA_CONFIG_PATH_LEN);
@@ -385,7 +389,7 @@
case TARGET_SDM630:
case TARGET_MSM8998:
case TARGET_MSM8997:
- if ((!strncmp(nq_chipid, NQ220, PROPERTY_VALUE_MAX)) || (!strncmp(nq_chipid, NQ210, PROPERTY_VALUE_MAX))) {
+ if (nq2xx_present) {
// NQ210 or NQ220
config_id = QRD_TYPE_2;
strlcpy(config_file, config_name_qrd2, MAX_DATA_CONFIG_PATH_LEN);
@@ -411,7 +415,7 @@
case TARGET_MSM8937:
case TARGET_MSM8917:
case TARGET_MSM8940:
- if ((!strncmp(nq_chipid, NQ220, PROPERTY_VALUE_MAX)) || (!strncmp(nq_chipid, NQ210, PROPERTY_VALUE_MAX))) {
+ if (nq2xx_present) {
// NQ210 or NQ220
config_id = MTP_TYPE_DEFAULT;
strlcpy(config_file, config_name_mtp, MAX_DATA_CONFIG_PATH_LEN);
@@ -434,7 +438,7 @@
case TARGET_SDM630:
case TARGET_MSM8998:
case TARGET_MSM8997:
- if ((!strncmp(nq_chipid, NQ220, PROPERTY_VALUE_MAX)) || (!strncmp(nq_chipid, NQ210, PROPERTY_VALUE_MAX))) {
+ if (nq2xx_present) {
// NQ210 or NQ220
config_id = MTP_TYPE_1;
strlcpy(config_file, config_name_mtp1, MAX_DATA_CONFIG_PATH_LEN);
diff --git a/src/nfa/hci/nfa_hci_act.c b/src/nfa/hci/nfa_hci_act.c
index d2c1c86..6718a1d 100644
--- a/src/nfa/hci/nfa_hci_act.c
+++ b/src/nfa/hci/nfa_hci_act.c
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2015 NXP Semiconductors
@@ -2533,6 +2533,7 @@
tNFA_STATUS status = NFA_STATUS_OK;
uint8_t p_data[NFA_MAX_HCI_CMD_LEN];
uint8_t* p = p_data, *parm_len, *num_param;
+
memset(p_data, 0, sizeof(p_data));
NCI_MSG_BLD_HDR0(p, NCI_MT_CMD, NCI_GID_CORE);
NCI_MSG_BLD_HDR1(p, NCI_MSG_CORE_GET_CONFIG);
@@ -2545,11 +2546,11 @@
UINT8_TO_STREAM(p, NXP_NFC_PARAM_ID_SWP2);
(*num_param)++;
-if(nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC) {
- UINT8_TO_STREAM(p, NXP_NFC_SET_CONFIG_PARAM_EXT);
- UINT8_TO_STREAM(p, NXP_NFC_PARAM_ID_SWP1A);
- (*num_param)++;
-}
+ if ((nfcFL.chipType == pn551) || (nfcFL.chipType == pn553) || (nfcFL.chipType == pn557)) {
+ UINT8_TO_STREAM(p, NXP_NFC_SET_CONFIG_PARAM_EXT);
+ UINT8_TO_STREAM(p, NXP_NFC_PARAM_ID_SWP1A);
+ (*num_param)++;
+ }
*parm_len = (p - num_param);
if (*num_param != 0x00) {