NFC: Merge branch 'caf/caf/nxpnfc-project/br_android_ncihalx_o' into nfc.lnx.3.1

* caf/caf/nxpnfc-project/br_android_ncihalx_o: (66 commits)
  NFC_NCIHALx_AR003C.8.3.0_O_OpnSrc
  MW version updated to 8.3.0
  NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc
  MW version updated to 8.3.0
  Switching NFCC clock source from XTAL to PLL is not working.
  Update README.md
  NFC_NCIHALx_AR180C.8.3.0_O_OpnSrc
  MW version updated to 8.3.0
  MW version updated to 8.2.B
  MW version updated to 8.2.A
  Added GKI error prints
  Fix for selftest failures on android O
  Fix for Model ID print issue
  Selftest Single binary improvements
  Add Lx Debug decoding information
  MW version updated to 8.2.9
  Fix for UICC detection issue after FW download
  MW version updated to 8.2.8
  Fix for selfTest application cr*sh due to HAL library path mismatch
  Observing NFC Init success with Model ID mismatch
  ...

Change-Id: Ie0682fda686cf41c97e9f925318672f0cbd3c5ec
diff --git a/README.md b/README.md
index 5dbc62f..8491caa 100644
--- a/README.md
+++ b/README.md
@@ -42,3 +42,7 @@
 | android-o-preview2                     |  8.0.C_O (PN553/PN557) |  NFC_NCIHALx_AR1800.8.0.C_O_OpnSrc |
 | android-o-preview2                     |  8.0.13_O (PN553/PN557) |  NFC_NCIHALx_AR18C0.8.0.13_O_OpnSrc |
 | android-8.0.0_r4               |  8.1.0_O (PN553) |  NFC_NCIHALx_AR00C0.8.1.0_O_OpnSrc |
+| android-8.0.0_r4               |  8.2.0_O (PN557) |  NFC_NCIHALx_AR18C0.8.2.0_O_OpnSrc |
+| android-8.0.0_r4               |  8.2.3_O (PN557) |  NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc |
+| android-8.0.0_r4               |  8.3.0_O (PN548C2/PN551/PN553) |  NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc |
+| android-8.0.0_r4               |  8.3.0_O (PN548C2/PN551) | NFC_NCIHALx_AR003C.8.3.0_O_OpnSrc  |
diff --git a/halimpl/pn54x/common/phNfcCommon.h b/halimpl/pn54x/common/phNfcCommon.h
index 4ba1bbf..f03896d 100644
--- a/halimpl/pn54x/common/phNfcCommon.h
+++ b/halimpl/pn54x/common/phNfcCommon.h
@@ -33,7 +33,7 @@
 #include <phNfcCompId.h>
 
 /* HAL Version number (Updated as per release) */
-#define NXP_MW_VERSION_MAJ (0x01)
+#define NXP_MW_VERSION_MAJ (0x03)
 #define NXP_MW_VERSION_MIN (0x00)
 
 #define GET_EEPROM_DATA (1U)
diff --git a/halimpl/pn54x/configs/NxpNfcCapability.cpp b/halimpl/pn54x/configs/NxpNfcCapability.cpp
index 5a89486..a4d0e14 100644
--- a/halimpl/pn54x/configs/NxpNfcCapability.cpp
+++ b/halimpl/pn54x/configs/NxpNfcCapability.cpp
@@ -45,11 +45,13 @@
 
             case 0x40 : //PN553 A0
             case 0x41 : //PN553 B0
+                        //NQ310
                 chipType = pn553;
                 break;
 
             case 0x50 : //PN553 A0 + P73
-            case 0x51 : //PN553 B0 + P73
+            case 0x51 : //PN553 B0 + P73 , NQ440
+                        //NQ330
                 chipType = pn80T;
                 break;
 
@@ -58,16 +60,17 @@
                 break;
 
             case 0xA8 :
+            case 0x08 :
                 chipType = pn67T;
                 break;
 
             case 0x28 :
-            case 0x48 :
+            case 0x48 : //NQ210
                 chipType = pn548C2;
                 break;
 
             case 0x18 :
-            case 0x58 :
+            case 0x58 : //NQ220
                 chipType = pn66T;
                 break;
 
@@ -80,6 +83,7 @@
             chipType = pn80T;
         }
     }
+    ALOGD ("%s NxpNci > Product : %s",__func__,product[chipType]);
     return chipType;
 }
 
diff --git a/halimpl/pn54x/configs/NxpNfcCapability.h b/halimpl/pn54x/configs/NxpNfcCapability.h
index 538a9c8..e6c3beb 100644
--- a/halimpl/pn54x/configs/NxpNfcCapability.h
+++ b/halimpl/pn54x/configs/NxpNfcCapability.h
@@ -56,6 +56,10 @@
     static capability* instance;
     const uint16_t offsetHwVersion = 24;
     const uint16_t offsetFwVersion = 25;
+    /*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;
diff --git a/halimpl/pn54x/hal/phNxpNciHal.c b/halimpl/pn54x/hal/phNxpNciHal.c
index 6fcad93..f8d0103 100644
--- a/halimpl/pn54x/hal/phNxpNciHal.c
+++ b/halimpl/pn54x/hal/phNxpNciHal.c
@@ -547,6 +547,7 @@
         } while (init_retry_cnt < 0x03);
       }
     }
+    pthread_attr_destroy(&attr);
   }
   CONCURRENCY_UNLOCK();
   init_retry_cnt = 0;
@@ -876,12 +877,12 @@
   }
 
   /* Create local copy of cmd_data */
-  memcpy(nxpncihal_ctrl.p_cmd_data, p_data, data_len);
   nxpncihal_ctrl.cmd_len = data_len;
   if (nxpncihal_ctrl.cmd_len > NCI_MAX_DATA_LEN) {
     NXPLOG_NCIHAL_D("cmd_len exceeds limit NCI_MAX_DATA_LEN");
     goto clean_and_return;
   }
+  memcpy(nxpncihal_ctrl.p_cmd_data, p_data, data_len);
 #ifdef P2P_PRIO_LOGIC_HAL_IMP
   /* Specific logic to block RF disable when P2P priority logic is busy */
   if (p_data[0] == 0x21 && p_data[1] == 0x06 && p_data[2] == 0x01 &&
@@ -1180,7 +1181,23 @@
       ALOGE("%s: error deleting file %s", __func__, config_eseinfo_path);
   }
 }
+/*******************************************************************************
+ **
+ ** Function:        phNxpNciHal_lastResetNtfReason()
+ **
+ ** Description:     Returns and clears last reset notification reason.
+ **                      Intended to be called only once during recovery.
+ **
+ ** Returns:         reasonCode
+ **
+ ********************************************************************************/
+uint8_t phNxpNciHal_lastResetNtfReason(void) {
+  uint8_t reasonCode = nxpncihal_ctrl.nci_info.lastResetNtfReason;
 
+  nxpncihal_ctrl.nci_info.lastResetNtfReason = 0;
+
+  return reasonCode;
+}
 /******************************************************************************
  * Function         phNxpNciHal_core_initialized
  *
@@ -1210,6 +1227,8 @@
   static uint8_t cmd_init_nci[] = {0x20, 0x01, 0x00};
   static uint8_t cmd_reset_nci[] = {0x20, 0x00, 0x01, 0x00};
   static uint8_t cmd_init_nci2_0[] = {0x20,0x01,0x02,0x00,0x00};
+  static uint8_t cmd_get_cfg_dbg_info[] = {0x20, 0x03, 0x4, 0xA0, 0x1B, 0xA0, 0x27};
+
   config_success = true;
   long bufflen = 260;
   long retlen = 0;
@@ -1355,7 +1374,8 @@
 #endif
 
 
-  if((nfcFL.chipType != pn547C2) && nfcFL.nfccFL._NFCC_ROUTING_BLOCK_BIT_PROP) {
+  if((nfcFL.chipType != pn547C2) && (nfcFL.chipType != pn557) &&
+      nfcFL.nfccFL._NFCC_ROUTING_BLOCK_BIT_PROP) {
       if (isNxpConfigModified() || (fw_dwnld_flag == 0x01)) {
           uint8_t value;
           retlen = 0;
@@ -1450,6 +1470,11 @@
     }
   }
 #endif
+  if(phNxpNciHal_lastResetNtfReason() == FW_DBG_REASON_AVAILABLE){
+
+    phNxpNciHal_send_ext_cmd(sizeof(cmd_get_cfg_dbg_info), cmd_get_cfg_dbg_info);
+    NXPLOG_NCIHAL_D("NFCC txed reset ntf with reason code 0xA3");
+  }
   setConfigAlways = false;
   isfound = GetNxpNumValue(NAME_NXP_SET_CONFIG_ALWAYS, &num, sizeof(num));
   if (isfound > 0) {
@@ -1907,7 +1932,7 @@
 
   config_access = false;
   if (!((*p_core_init_rsp_params > 0) && (*p_core_init_rsp_params < 4))) {
-      if(nfcFL.nfcNxpEse == true) {
+      if(nfcFL.nfcNxpEse == true && nfcFL.eseFL._ESE_ETSI12_PROP_INIT) {
           status = phNxpNciHal_check_eSE_Session_Identity();
           if (status != NFCSTATUS_SUCCESS) {
               NXPLOG_NCIHAL_E("Session id/ SWP intf reset Failed");
@@ -2955,6 +2980,15 @@
             }
         }
       break;
+    case HAL_NFC_IOCTL_REL_DWP_WAIT:
+        if(nfcFL.nfcNxpEse) {
+            status = phTmlNfc_rel_dwpOnOff_wait(gpphTmlNfc_Context->pDevHandle);
+            NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_REL_DWP_ON_OFF_WAIT retval = %d\n", status);
+            if (NFCSTATUS_SUCCESS == status) {
+                ret = 0;
+            }
+        }
+      break;
 
     case HAL_NFC_IOCTL_SET_BOOT_MODE:
       if (NULL != p_data) {
@@ -3146,8 +3180,9 @@
 
 if(nfcFL.chipType == pn553) {
     static uint8_t set_clock_cmd[] = {0x20, 0x02, 0x05, 0x01, 0xA0, 0x03, 0x01, 0x08};
+    uint8_t setClkCmdLen = sizeof(set_clock_cmd);
     unsigned long  clockSource, frequency;
-    uint32_t pllSetRetryCount = 3, dpllSetRetryCount = 3;
+    uint32_t pllSetRetryCount = 3, dpllSetRetryCount = 3,setClockCmdWriteRetryCnt = 0;
     uint8_t *pCmd4PllSetting;
     uint8_t *pCmd4DpllSetting;
     uint32_t pllCmdLen, dpllCmdLen;
@@ -3251,6 +3286,12 @@
     switch(clockSource)
     {
         case CLK_SRC_PLL:
+            set_clock_cmd[setClkCmdLen -1] = 0x00;
+            while(status != NFCSTATUS_SUCCESS && setClockCmdWriteRetryCnt++ < MAX_RETRY_COUNT)
+            status = phNxpNciHal_send_ext_cmd(setClkCmdLen, set_clock_cmd);
+
+            status = NFCSTATUS_FAILED;
+
             while(status != NFCSTATUS_SUCCESS && pllSetRetryCount -- > 0)
                 status = phNxpNciHal_send_ext_cmd(pllCmdLen, pCmd4PllSetting);
 
@@ -3262,7 +3303,7 @@
             break;
 
         case CLK_SRC_XTAL:
-            status = phNxpNciHal_send_ext_cmd(sizeof(set_clock_cmd), set_clock_cmd);
+            status = phNxpNciHal_send_ext_cmd(setClkCmdLen, set_clock_cmd);
             if (status != NFCSTATUS_SUCCESS)
             {
                 NXPLOG_NCIHAL_E("XTAL clock setting failed !!");
diff --git a/halimpl/pn54x/hal/phNxpNciHal.h b/halimpl/pn54x/hal/phNxpNciHal.h
index 3839631..8870dcc 100644
--- a/halimpl/pn54x/hal/phNxpNciHal.h
+++ b/halimpl/pn54x/hal/phNxpNciHal.h
@@ -80,6 +80,9 @@
 #define FW_MOBILE_ROM_VERSION_PN547C2 0x08
 #define FW_MOBILE_ROM_VERSION_PN557 0x12
 
+#define FW_DBG_REASON_AVAILABLE     (0xA3)
+
+
 /* NCI Data */
 #define NCI_MT_CMD  0x20
 #define NCI_MT_RSP  0x40
@@ -105,6 +108,7 @@
 typedef struct phNxpNciInfo {
   uint8_t   nci_version;
   bool_t    wait_for_ntf;
+  uint8_t   lastResetNtfReason;
 }phNxpNciInfo_t;
 /* NCI Control structure */
 typedef struct phNxpNciHal_Control {
diff --git a/halimpl/pn54x/hal/phNxpNciHal_ext.c b/halimpl/pn54x/hal/phNxpNciHal_ext.c
index 805fe9b..3f35693 100644
--- a/halimpl/pn54x/hal/phNxpNciHal_ext.c
+++ b/halimpl/pn54x/hal/phNxpNciHal_ext.c
@@ -344,6 +344,10 @@
              nxpncihal_ctrl.is_wait_for_ce_ntf) {
     NXPLOG_NCIHAL_D("CORE_INIT_RSP 2 received !");
   }
+  /*Retreive reset ntf reason code irrespective of NCI 1.0 or 2.0*/
+  if (p_ntf[0] == 0x60 && p_ntf[1] == 0x00 ){
+    nxpncihal_ctrl.nci_info.lastResetNtfReason = p_ntf[3];
+  }
 }
 /*Handle NFCC2.0 in NCI1.0 Boot sequence*/
 if (((nfcFL.nfccFL._NFCC_FORCE_NCI1_0_INIT) &&
@@ -365,69 +369,8 @@
         if (wFwVerRsp == 0) status = NFCSTATUS_FAILED;
         iCoreInitRspLen = *p_len;
         memcpy(bCoreInitRsp, p_ntf, *p_len);
-        NXPLOG_NCIHAL_D("NxpNci> FW Version: %x.%x.%x", p_ntf[len - 2],
-                p_ntf[len - 1], p_ntf[len]);
-        NXPLOG_NCIHAL_D("NxpNci> Model id: %x", p_ntf[len - 3] >> 4);
         fw_maj_ver = p_ntf[len - 1];
         rom_version = p_ntf[len - 2];
-        /* Before FW version: 10.01.12, products are PN548c2(for model id = 0) and
-         * PN66T(for model id = 1)*/
-        if (p_ntf[len - 2] == 0x10) {
-            if ((p_ntf[len - 1] < 0x01) |
-                    ((p_ntf[len - 1] == 0x01) &&
-                            (p_ntf[len] <= 0x11)))  // for FW < 10.01.12
-            {
-                NXPLOG_NCIHAL_D("NxpNci> Model ID: %x", p_ntf[len - 3] >> 4);
-                if (0x01 == (p_ntf[len - 3] >> 4)) {
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN66T");
-                } else {
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN548C2");
-                }
-            } else if ((p_ntf[len - 1] == 0x01) &&
-                    (p_ntf[len] >= 0x12))  // for FW >= 10.01.12
-            {
-                NXPLOG_NCIHAL_D("NxpNci> Model ID: %x", p_ntf[len - 3] >> 4);
-                /* From FW version: 10.01.12, product names based on Hardware Version
-                 * number */
-                switch (p_ntf[len - 3]) {
-                case 0x08:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN546");
-                    break;
-                case 0x18:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN66T");
-                    break;
-                case 0x28:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN548C2");
-                    break;
-                case 0x38:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN66U");
-                    break;
-                case 0x48:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: NQ210");
-                    break;
-                case 0x58:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: NQ220");
-                    break;
-                case 0x68:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: NPC300");
-                    break;
-                case 0x78:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: NPC320");
-                    break;
-                case 0x88:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN7150");
-                    break;
-                case 0x98:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: PN548C3");
-                    break;
-                default:
-                    NXPLOG_NCIHAL_D("NxpNci> Product: Invalid");
-                    break;
-                }
-            }
-        } else {
-            /* Do Nothing */
-        }
     }
 }
 
diff --git a/halimpl/pn54x/inc/phNxpNciHal_SelfTest.h b/halimpl/pn54x/inc/phNxpNciHal_SelfTest.h
index 0b4f22c..e937810 100644
--- a/halimpl/pn54x/inc/phNxpNciHal_SelfTest.h
+++ b/halimpl/pn54x/inc/phNxpNciHal_SelfTest.h
@@ -67,6 +67,35 @@
                                                   Tolerance 2*/
 } phAntenna_St_Resp_t; /* Instance of Transaction structure */
 
+/* NCI Commands */
+#define NCI_CORE_RESET_NCI20_RSP   {0x40, 0x00, 0x01, 0x00}
+#define NCI_CORE_RESET_NCI20_NTF   {0x60, 0x00, 0x09, 0x02, 0x00, 0x20, 0x04, 0x04, 0x51, 0x12, 0x01, 0x03}
+#define NCI_CORE_INIT_NCI20_CMD    {0x20, 0x01, 0x02, 0x00, 0x00}
+#define NCI_CORE_INIT_NCI20_RSP    {0x40, 0x01, 0x1E, 0x00}
+#define NCI_CORE_INIT_NCI10_CMD    {0x20, 0x01, 0x00}
+#define NCI20_CORE_RESET_RSP_LEN   0x01
+#define NCI10_CORE_RESET_RSP_LEN   0x03
+#define NCI_CORE_RESET_STATUS_OK   0x00
+#define NCI_MSG_TYPE_MASK          0xF0
+
+/* Proprietary Commands */
+#define SYSTEM_SET_POWERMGT_CMD        {0x2F, 0x00, 0x01, 0x00}
+#define SYSTEM_SET_POWERMGT_CMD_1      {0x2F, 0x00, 0x01, 0x01}
+#define SYSTEM_SET_POWERMGT_RSP        {0x4F, 0x00, 0x01, 0x00}
+#define SYSTEM_PROPRIETARY_ACT_CMD     {0x2F, 0x02, 0x00}
+#define SYSTEM_PROPRIETARY_ACT_RSP     {0x4F, 0x02, 0x05, 0x00}
+#define SYSTEM_TEST_ANTENNA_CMD_1      {0x2F, 0x3D, 0x05, 0x20, 0x01, 0x00, 0x00, 0x00}
+#define SYSTEM_TEST_ANTENNA_RSP_1      {0x4F, 0x3D, 0x05, 0x00}
+#define SYSTEM_TEST_ANTENNA_CMD_2      {0x2F, 0x3D, 0x02, 0x20, 0x01}
+#define SYSTEM_TEST_ANTENNA_CMD_3      {0x2F, 0x3D, 0x02, 0x20, 0x00}
+#define SYSTEM_TEST_ANTENNA_CMD_4      {0x2F, 0x3D, 0x05, 0x20, 0x00, 0x00, 0x00, 0x00}
+#define SYSTEM_TEST_ANTENNA_CMD_5      {0x2F, 0x3D, 0x02, 0x01, 0x80}
+#define SYSTEM_TEST_ANTENNA_RSP_2      {0x4F, 0x3D, 05}
+#define SYSTEM_TEST_ANTENNA_CMD_6      {0x2F, 0x3D, 0x04, 0x08, 0x8C, 0x60, 0x03}
+#define SYSTEM_TEST_ANTENNA_CMD_7      {0x2F, 0x3D, 0x04, 0x02, 0xC8, 0x60, 0x03}
+#define SYSTEM_TEST_ANTENNA_CMD_8      {0x2F, 0x3D, 0x04, 0x02, 0xCD, 0x60, 0x03}
+#define SYSTEM_TEST_ANTENNA_CMD_9      {0x2F, 0x3D, 0x04, 0x04, 0x20, 0x08, 0x20}
+
 /*******************************************************************************
  **
  ** Function         phNxpNciHal_TestMode_open
diff --git a/halimpl/pn54x/libnfc-nxp-PN553_example.conf b/halimpl/pn54x/libnfc-nxp-PN553_example.conf
index 1fdedf5..75466f4 100644
--- a/halimpl/pn54x/libnfc-nxp-PN553_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN553_example.conf
@@ -454,6 +454,12 @@
 NXP_CN_TRANSIT_BLK_NUM_CHECK_ENABLE=0x01
 
 ###############################################################################
+#Enable NXP NCI runtime parser library
+#Enable 0x01
+#Disable 0x00
+NXP_NCI_PARSER_LIBRARY=0x00
+
+###############################################################################
 #This config will enable different level of Rf transaction debugs based on the
 #following values provided. Decoded information will be printed in adb logcat
 #Debug Mode         Levels
@@ -466,10 +472,11 @@
 #NXP_CORE_PROP_SYSTEM_DEBUG=0x00
 
 ###############################################################################
-# Restrict routing to first matched rule only.
-# Blacklist enable   0x01
-# Blacklist disable  0x00
-NXP_PROP_BLACKLIST_ROUTING=0x00
+# Enable/Disable Block Route feature.
+# Block Route will restrict routing to first matched rule
+# Block Route enable   0x01
+# Block Route disable  0x00
+NFA_BLOCK_ROUTE=0x00
 
 ###############################################################################
 # Timeout value in milliseconds to send response for Felica command received
diff --git a/halimpl/pn54x/libnfc-nxp-PN557_example.conf b/halimpl/pn54x/libnfc-nxp-PN557_example.conf
index db3b79d..b8d925b 100644
--- a/halimpl/pn54x/libnfc-nxp-PN557_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN557_example.conf
@@ -441,10 +441,22 @@
 NXP_CN_TRANSIT_BLK_NUM_CHECK_ENABLE=0x01
 
 ###############################################################################
-# Restrict routing to first matched rule only.
-# Blacklist enable   0x01
-# Blacklist disable  0x00
-NXP_PROP_BLACKLIST_ROUTING=0x00
+#Enable NXP NCI runtime parser library
+#Enable 0x01
+#Disable 0x00
+NXP_NCI_PARSER_LIBRARY=0x00
+
+###############################################################################
+#This config will enable different level of Rf transaction debugs based on the
+#following values provided. Decoded information will be printed in adb logcat
+#Debug Mode         Levels
+#Disable Debug      0x00
+#L1 Debug           0x01
+#L2 Debug           0x02
+#L1 & L2 Debug      0x03
+#L1 & L2 & RSSI     0x04
+#L1 & L2 & Felica   0x05
+#NXP_CORE_PROP_SYSTEM_DEBUG=0x00
 
 ###############################################################################
 # Timeout value in milliseconds to send response for Felica command received
diff --git a/halimpl/pn54x/libnfc-nxp-PN65T_example.conf b/halimpl/pn54x/libnfc-nxp-PN65T_example.conf
index 3a9a807..e50eac8 100644
--- a/halimpl/pn54x/libnfc-nxp-PN65T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN65T_example.conf
@@ -311,3 +311,7 @@
 NXP_ENABLE_ADD_AID=0x01
 
 ###############################################################################
+# HAL library path for selftest
+NXP_HAL_PATH="/system/lib64/hw/nfc_nci.pn54x.so"
+
+###############################################################################
\ No newline at end of file
diff --git a/halimpl/pn54x/libnfc-nxp-PN66T_example.conf b/halimpl/pn54x/libnfc-nxp-PN66T_example.conf
index 1af8100..469646f 100644
--- a/halimpl/pn54x/libnfc-nxp-PN66T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN66T_example.conf
@@ -421,3 +421,7 @@
 NXP_CN_TRANSIT_BLK_NUM_CHECK_ENABLE=0x01
 
 ###############################################################################
+# HAL library path for selftest
+NXP_HAL_PATH="/system/lib64/hw/nfc_nci.pn54x.so"
+
+###############################################################################
diff --git a/halimpl/pn54x/libnfc-nxp-PN67T_example.conf b/halimpl/pn54x/libnfc-nxp-PN67T_example.conf
index 25f7a5f..b8ce7dd 100644
--- a/halimpl/pn54x/libnfc-nxp-PN67T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN67T_example.conf
@@ -432,3 +432,7 @@
 NXP_PROP_BLACKLIST_ROUTING=0x00
 
 ###############################################################################
+# HAL library path for selftest
+NXP_HAL_PATH="/system/lib64/hw/nfc_nci.pn54x.so"
+
+###############################################################################
diff --git a/halimpl/pn54x/libnfc-nxp-PN80T_example.conf b/halimpl/pn54x/libnfc-nxp-PN80T_example.conf
index 31d6ddc..1934ca2 100644
--- a/halimpl/pn54x/libnfc-nxp-PN80T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN80T_example.conf
@@ -529,16 +529,17 @@
 NXP_ALLOW_WIRED_IN_MIFARE_DESFIRE_CLT=0x00
 
 ###############################################################################
-# Restrict routing to first matched rule only.
-# Blacklist enable   0x01
-# Blacklist disable  0x00
-NXP_PROP_BLACKLIST_ROUTING=0x00
+# Enable/Disable Block Route feature.
+# Block Route will restrict routing to first matched rule
+# Block Route enable   0x01
+# Block Route disable  0x00
+NFA_BLOCK_ROUTE=0x00
 
 ###############################################################################
 # Send DWP interface reset command as part of SE open
 # Disable           0x00
 # Enable            0x01
-NXP_DWP_INTF_RESET_ENABLE=0x01
+NXP_DWP_INTF_RESET_ENABLE=0x00
 
 ###############################################################################
 # Timeout value in milliseconds for JCOP OS download to complete
@@ -550,6 +551,10 @@
 
 ###############################################################################
 # Maximum WTX requests entertained by MW
-NXP_WM_MAX_WTX_COUNT=9000
+NXP_WM_MAX_WTX_COUNT=50
 
-###############################################################################
\ No newline at end of file
+###############################################################################
+# HAL library path for selftest
+NXP_HAL_PATH="/vendor/lib64/hw/nfc_nci.pn54x.so"
+
+###############################################################################
diff --git a/halimpl/pn54x/libnfc-nxp-PN81T_example.conf b/halimpl/pn54x/libnfc-nxp-PN81T_example.conf
index 66948fd..d0f3aef 100644
--- a/halimpl/pn54x/libnfc-nxp-PN81T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN81T_example.conf
@@ -352,12 +352,31 @@
 NXP_CN_TRANSIT_BLK_NUM_CHECK_ENABLE=0x01
 
 ###############################################################################
+#Enable NXP NCI runtime parser library
+#Enable 0x01
+#Disable 0x00
+NXP_NCI_PARSER_LIBRARY=0x00
+
+###############################################################################
+#This config will enable different level of Rf transaction debugs based on the
+#following values provided. Decoded information will be printed in adb logcat
+#Debug Mode         Levels
+#Disable Debug      0x00
+#L1 Debug           0x01
+#L2 Debug           0x02
+#L1 & L2 Debug      0x03
+#L1 & L2 & RSSI     0x04
+#L1 & L2 & Felica   0x05
+#NXP_CORE_PROP_SYSTEM_DEBUG=0x00
+
+###############################################################################
 # Wired mode resume timeout vaule in wired mode resume feature enable
 # DWP resume time out in ms( 4 bytes hex value and LSB first)
 #example 1000 = 0x03E8
 #exmaple 2000 = 0x07D0
 #example 500 = 0x01F4
 NXP_WIREDMODE_RESUME_TIMEOUT={E8,03,00,00}
+
 ###############################################################################
 # Power to eSE is controlled by DH or PMU depending on following configurations
 #define DH_PWR_CONTROL         1
@@ -381,16 +400,10 @@
 NXP_ALLOW_WIRED_IN_MIFARE_DESFIRE_CLT=0x00
 
 ###############################################################################
-# Restrict routing to first matched rule only.
-# Blacklist enable   0x01
-# Blacklist disable  0x00
-NXP_PROP_BLACKLIST_ROUTING=0x00
-
-###############################################################################
 # Send DWP interface reset command as part of SE open
 # Disable           0x00
 # Enable            0x01
-NXP_DWP_INTF_RESET_ENABLE=0x01
+NXP_DWP_INTF_RESET_ENABLE=0x00
 
 ###############################################################################
 # Timeout value in milliseconds for JCOP OS download to complete
@@ -401,3 +414,11 @@
 NXP_HCEF_CMD_RSP_TIMEOUT_VALUE=5000
 
 ###############################################################################
+# Maximum WTX requests entertained by MW
+NXP_WM_MAX_WTX_COUNT=50
+
+###############################################################################
+# HAL library path for selftest
+NXP_HAL_PATH="/vendor/lib64/hw/nfc_nci.pn54x.so"
+
+###############################################################################
diff --git a/halimpl/pn54x/libnfc-nxp_RF-PN80T_example.conf b/halimpl/pn54x/libnfc-nxp_RF-PN80T_example.conf
index 3f4e061..d9e6199 100644
--- a/halimpl/pn54x/libnfc-nxp_RF-PN80T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp_RF-PN80T_example.conf
@@ -50,7 +50,7 @@
 # UICC2 bit rate A0D1
 # SWP1A interface A0D4
 # DWP intf behavior config, SVDD Load activated by default if set to 0x31 A037
-NXP_CORE_CONF_EXTN={20, 02, 29, 0A,
+NXP_CORE_CONF_EXTN={20, 02, 32, 0C,
     A0, EC, 01, 01,
     A0, ED, 01, 01,
     A0, 5E, 01, 01,
@@ -60,7 +60,9 @@
     A0, D4, 01, 01,
     A0, 37, 01, 35,
     A0, D8, 01, 02,
-    A0, D5, 01, 0A
+    A0, D5, 01, 0A,
+    A0, B2, 01, 1E,
+    A0, 9F, 02, 08, 08
    }
 #       A0, F2, 01, 01,
 #       A0, 40, 01, 01,
diff --git a/halimpl/pn54x/libnfc-nxp_RF-PN81T_example.conf b/halimpl/pn54x/libnfc-nxp_RF-PN81T_example.conf
index cb74752..6c31e03 100644
--- a/halimpl/pn54x/libnfc-nxp_RF-PN81T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp_RF-PN81T_example.conf
@@ -50,7 +50,7 @@
 # UICC2 bit rate A0D1
 # SWP1A interface A0D4
 # DWP intf behavior config, SVDD Load activated by default if set to 0x31 A037
-NXP_CORE_CONF_EXTN={20, 02, 29, 0A,
+NXP_CORE_CONF_EXTN={20, 02, 32, 0C,
     A0, EC, 01, 01,
     A0, ED, 01, 01,
     A0, 5E, 01, 01,
@@ -60,7 +60,9 @@
     A0, D4, 01, 01,
     A0, 37, 01, 35,
     A0, D8, 01, 02,
-    A0, D5, 01, 0A
+    A0, D5, 01, 0A,
+    A0, B2, 01, 1E,
+    A0, 9F, 02, 08, 08
    }
 #       A0, F2, 01, 01,
 #       A0, 40, 01, 01,
diff --git a/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c b/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c
index b475412..c45bb23 100644
--- a/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c
+++ b/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c
@@ -30,8 +30,12 @@
 #define HAL_WRITE_MAX_RETRY (10)
 #define CORE_INIT_NCI2_0 false
 
-#define NXP_NFCC_RESET_RSP_LEN (0x10U) //for PN553 (0x10U) else (0x11U)
-
+#define NXP_NFCC_RESET_RSP_LEN   (0x10U) //for PN553 and PN557 (0x10U) else (0x11U)
+#define NFCC_EXP_NTF_LEN_NULL    0x00
+#define NFCC_EXP_NTF_DATA_NULL   0x00
+#define NFCC_CMD_NCI20_LEN       0x05
+#define NFCC_CMD_NCI10_LEN       0x03
+#define NFCC_EXP_RES_DATA_BYTE2 ((nfcFL.chipType == pn547C2) ? 0x17 : 0x19)
 /******************* Structures and definitions *******************************/
 
 typedef uint8_t (*st_validator_t)(nci_data_t* exp,
@@ -48,6 +52,12 @@
 
 } nci_test_data_t;
 
+typedef struct selftest_hdlr{
+    bool wait_for_ntf;
+    uint8_t nci_version;
+    phTmlNfc_TransactInfo_t mTransInfo;
+}selftest_hdlr_t;
+selftest_hdlr_t mSelfTestHdlr;
 /******************* Global variables *****************************************/
 
 static int thread_running = 0;
@@ -62,6 +72,13 @@
 
 /* Driver parameters */
 phLibNfc_sConfig_t gDrvCfg;
+const static uint8_t nfcc_core_reset_nci20_rsp[] = NCI_CORE_RESET_NCI20_RSP;
+const static uint8_t nfcc_core_reset_nci20_ntf[] = NCI_CORE_RESET_NCI20_NTF;
+const static uint8_t nfcc_core_init_nci20_cmd[] = NCI_CORE_INIT_NCI20_CMD;
+const static uint8_t nfcc_core_init_nci20_rsp[] = NCI_CORE_INIT_NCI20_RSP;
+const static uint8_t nfcc_core_init_nci10_cmd[] = NCI_CORE_INIT_NCI10_CMD;
+uint8_t nfcc_power_mgt_cmd[] = SYSTEM_SET_POWERMGT_CMD;
+uint8_t nfcc_power_mgt_rsp[] = SYSTEM_SET_POWERMGT_RSP;
 
 NFCSTATUS gtxldo_status = NFCSTATUS_FAILED;
 NFCSTATUS gagc_value_status = NFCSTATUS_FAILED;
@@ -87,17 +104,15 @@
                                  uint8_t tech, uint8_t bitrate,
                                  uint8_t* prbs_cmd, uint8_t prbs_cmd_len);
 
+static NFCSTATUS phNxpNciHal_initialize_chipType();
+
 /* Test data to validate SWP line 2*/
 static nci_test_data_t swp2_test_data[] = {
     {{
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00} /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -105,21 +120,10 @@
      st_validator_testEquals, /* validator */
      st_validator_null},
     {{
-#if ((NFC_NXP_CHIP_TYPE != PN547C2) && (CORE_INIT_NCI2_0))
-      0x05, {0x20, 0x01, 0x02, 0x00, 0x00} /* cmd */
-#else
       0x03, {0x20, 0x01, 0x00}
-#endif
      },
      {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
-    || (NFC_NXP_CHIP_TYPE == PN557))
-      0x4, {0x40, 0x01, 0x19, 0x00} /* exp_rsp */
-#elif(NFC_NXP_CHIP_TYPE == PN548C2)
-      0x4, {0x40, 0x01, 0x19, 0x00}              /* exp_rsp */
-#else
-      0x4, {0x40, 0x01, 0x17, 0x00}
-#endif
+      0x4, {0x40, 0x01, 0x19, 0x00}
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -158,11 +162,7 @@
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00} /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -170,21 +170,10 @@
      st_validator_testEquals, /* validator */
      st_validator_null},
     {{
-#if ((NFC_NXP_CHIP_TYPE != PN547C2) && (CORE_INIT_NCI2_0))
-      0x05, {0x20, 0x01, 0x02, 0x00, 0x00} /* cmd */
-#else
       0x03, {0x20, 0x01, 0x00}
-#endif
      },
      {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
-    || (NFC_NXP_CHIP_TYPE == PN557))
-      0x4, {0x40, 0x01, 0x19, 0x00} /* exp_rsp */
-#elif(NFC_NXP_CHIP_TYPE == PN548C2)
       0x4, {0x40, 0x01, 0x19, 0x00}                          /* exp_rsp */
-#else
-      0x4, {0x40, 0x01, 0x17, 0x00}
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -216,16 +205,12 @@
      st_validator_testSWP1_vltg},
 };
 
-static nci_test_data_t prbs_test_data[] = {
+static nci_test_data_t prbs_test_data[10] = {
     {{
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00}             /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -233,54 +218,26 @@
      st_validator_testEquals, /* validator */
      st_validator_null},
     {{
-#if ((NFC_NXP_CHIP_TYPE != PN547C2) && (CORE_INIT_NCI2_0))
-      0x05, {0x20, 0x01, 0x02, 0x00, 0x00} /* cmd */
-#else
       0x03, {0x20, 0x01, 0x00}                               /* cmd */
-#endif
      },
      {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
-    || (NFC_NXP_CHIP_TYPE == PN557))
-      0x4, {0x40, 0x01, 0x19, 0x00} /* exp_rsp */
-#elif(NFC_NXP_CHIP_TYPE == PN548C2)
       0x4, {0x40, 0x01, 0x19, 0x00}                          /* exp_rsp */
-#else
-      0x4, {0x40, 0x01, 0x17, 0x00} /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
      },
      st_validator_testEquals, /* validator */
      st_validator_null
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-    },
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x00} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null
-#endif
-    }};
+    }
+};
 
 /* for rf field test, first requires to disable the standby mode */
-static nci_test_data_t rf_field_on_test_data[] = {
+static nci_test_data_t rf_field_on_test_data[10] = {
     {{
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00}             /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -288,92 +245,24 @@
      st_validator_testEquals, /* validator */
      st_validator_null},
     {{
-#if ((NFC_NXP_CHIP_TYPE != PN547C2) && (CORE_INIT_NCI2_0))
-      0x05, {0x20, 0x01, 0x02, 0x00, 0x00} /* cmd */
-#else
       0x03, {0x20, 0x01, 0x00}                               /* cmd */
-#endif
      },
      {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
-     || (NFC_NXP_CHIP_TYPE == PN557))
-      0x4, {0x40, 0x01, 0x19, 0x00} /* exp_rsp */
-#elif(NFC_NXP_CHIP_TYPE == PN548C2)
       0x4, {0x40, 0x01, 0x19, 0x00}                          /* exp_rsp */
-#else
-      0x4, {0x40, 0x01, 0x17, 0x00} /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
      },
      st_validator_testEquals, /* validator */
      st_validator_null},
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-    {{
-      0x03, {0x2F, 0x02, 0x00} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x02, 0x05, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null},
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x00} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null},
-#endif
-    {{
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-      0x05, {0x2F, 0x3D, 0x02, 0x20, 0x01} /* cmd */
-#else
-      0x08, {0x2F, 0x3D, 0x05, 0x20, 0x01, 0x00, 0x00, 0x00} /* cmd */
-#endif
-     },
-     {
-      0x04, {0x4F, 0x3D, 0x05, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-    },
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x01} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null
-#endif
-    }};
+};
 
-static nci_test_data_t rf_field_off_test_data[] = {
+static nci_test_data_t rf_field_off_test_data[10] = {
     {{
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00}             /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -381,81 +270,17 @@
      st_validator_testEquals, /* validator */
      st_validator_null},
     {{
-#if ((NFC_NXP_CHIP_TYPE != PN547C2) && (CORE_INIT_NCI2_0))
-      0x05, {0x20, 0x01, 0x02, 0x00, 0x00} /* cmd */
-#else
       0x03, {0x20, 0x01, 0x00}                               /* cmd */
-#endif
      },
      {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
-     || (NFC_NXP_CHIP_TYPE == PN557))
-      0x4, {0x40, 0x01, 0x19, 0x00} /* exp_rsp */
-#elif(NFC_NXP_CHIP_TYPE == PN548C2)
       0x4, {0x40, 0x01, 0x19, 0x00}                          /* exp_rsp */
-#else
-      0x4, {0x40, 0x01, 0x17, 0x00} /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
      },
      st_validator_testEquals, /* validator */
      st_validator_null},
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-    {{
-      0x03, {0x2F, 0x02, 0x00} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x02, 0x05, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null},
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x00} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null},
-#endif
-    {{
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-      0x05, {0x2F, 0x3D, 0x02, 0x20, 0x00} /* cmd */
-#else
-      0x08, {0x2F, 0x3D, 0x05, 0x20, 0x00, 0x00, 0x00, 0x00} /* cmd */
-#endif
-     },
-     {
-      0x04, {0x4F, 0x3D, 0x05, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-    },
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x01} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null
-#endif
-    }};
+};
 
 /* Download pin test data 1 */
 static nci_test_data_t download_pin_test_data1[] = {
@@ -463,11 +288,7 @@
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00}             /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -491,16 +312,12 @@
      st_validator_null},
 };
 /* Antenna self test data*/
-static nci_test_data_t antenna_self_test_data[] = {
+static nci_test_data_t antenna_self_test_data[10] = {
     {{
       0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
      },
      {
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
       0x06, {0x40, 0x00, 0x03, 0x00, NXP_NFCC_RESET_RSP_LEN, 0x00} /* exp_rsp */
-#else
-      0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00}             /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -508,21 +325,10 @@
      st_validator_testEquals, /* validator */
      st_validator_null},
     {{
-#if ((NFC_NXP_CHIP_TYPE != PN547C2) && (CORE_INIT_NCI2_0))
-      0x05, {0x20, 0x01, 0x02, 0x00, 0x00} /* cmd */
-#else
       0x03, {0x20, 0x01, 0x00}                               /* cmd */
-#endif
      },
      {
-#if ((NFC_NXP_CHIP_TYPE == PN551) || (NFC_NXP_CHIP_TYPE == PN553)\
-     || (NFC_NXP_CHIP_TYPE == PN557))
-      0x4, {0x40, 0x01, 0x19, 0x00} /* exp_rsp */
-#elif(NFC_NXP_CHIP_TYPE == PN548C2)
       0x4, {0x40, 0x01, 0x19, 0x00}                          /* exp_rsp */
-#else
-      0x4, {0x40, 0x01, 0x17, 0x00} /* exp_rsp */
-#endif
      },
      {
       0x00, {0x00} /* ext_ntf */
@@ -539,85 +345,8 @@
       0x00, {0x00} /* ext_ntf */
      },
      st_validator_testEquals, /* validator */
-     st_validator_null},
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x00} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null},
-#endif
-    {{
-      0x05, {0x2F, 0x3D, 0x02, 0x01, 0x80} /* TxLDO cureent measurement cmd */
-     },
-     {
-      0x03, {0x4F, 0x3D, 05} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testAntenna_Txldo,
-     st_validator_null},
-    {{
-#if (NFC_NXP_CHIP_TYPE != PN547C2)
-      0x07, {0x2F, 0x3D, 0x04, 0x02, 0xC8, 0x60, 0x03} /* AGC measurement cmd */
-#else
-      0x07, {0x2F, 0x3D, 0x04, 0x02, 0xCD, 0x60, 0x03}       /* AGC measurement cmd */
-#endif
-     },
-     {
-      0x03, {0x4F, 0x3D, 05} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testAntenna_AgcVal,
-     st_validator_null},
-    {{
-      0x07,
-      {0x2F, 0x3D, 0x04, 0x04, 0x20, 0x08,
-       0x20} /* AGC with NFCLD measurement cmd */
-     },
-     {
-      0x03, {0x4F, 0x3D, 05} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testAntenna_AgcVal_FixedNfcLd,
-     st_validator_null},
-#if (NXP_HW_ANTENNA_LOOP4_SELF_TEST == true)
-    {{
-      0x07,
-      {0x2F, 0x3D, 0x04, 0x08, 0x8C, 0x60,
-       0x03} /* AGC with NFCLD measurement cmd */
-     },
-     {
-      0x03, {0x4F, 0x3D, 05} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testAntenna_AgcVal_Differential,
-     st_validator_null},
-#endif
-    {{
-      0x04, {0x2F, 0x00, 0x01, 0x01} /* cmd */
-     },
-     {
-      0x04, {0x4F, 0x00, 0x01, 0x00} /* exp_rsp */
-     },
-     {
-      0x00, {0x00} /* ext_ntf */
-     },
-     st_validator_testEquals, /* validator */
-     st_validator_null}};
+     st_validator_null}
+};
 
 /************** Self test functions ***************************************/
 
@@ -638,9 +367,17 @@
 *******************************************************************************/
 static uint8_t st_validator_null(nci_data_t* exp,
                                  phTmlNfc_TransactInfo_t* act) {
-  UNUSED(exp);
-  UNUSED(act);
-  return 1;
+  uint8_t result = 0;
+
+  if (NULL == exp || NULL == act) {
+    return result;
+  }
+
+  if (exp->len <= act->wLength &&
+    (memcmp(exp->p_data, act->pBuff, exp->len) == 0)) {
+    result = 1;
+  }
+  return result;
 }
 
 /*******************************************************************************
@@ -932,6 +669,7 @@
   if (NULL == exp || NULL == act) {
     return result;
   }
+
   if (exp->len <= act->wLength &&
       (memcmp(exp->p_data, act->pBuff, exp->len) == 0)) {
     result = 1;
@@ -967,7 +705,6 @@
 *******************************************************************************/
 static void hal_write_cb(void* pContext, phTmlNfc_TransactInfo_t* pInfo) {
   phNxpNciHal_Sem_t* p_cb_data = (phNxpNciHal_Sem_t*)pContext;
-
   if (pInfo->wStatus == NFCSTATUS_SUCCESS) {
     NXPLOG_NCIHAL_D("write successful status = 0x%x", pInfo->wStatus);
   } else {
@@ -976,7 +713,6 @@
 
   p_cb_data->status = pInfo->wStatus;
   SEM_POST(p_cb_data);
-
   return;
 }
 
@@ -990,8 +726,14 @@
 **
 *******************************************************************************/
 static void hal_read_cb(void* pContext, phTmlNfc_TransactInfo_t* pInfo) {
-  phNxpNciHal_Sem_t* p_cb_data = (phNxpNciHal_Sem_t*)pContext;
   NFCSTATUS status;
+  phNxpNciHal_Sem_t* p_cb_data = NULL;
+
+  if((pInfo == NULL) || (pContext == NULL)){
+    NXPLOG_NCIHAL_E("Invalid params..! exiting...");
+    return;
+  }
+  p_cb_data = (phNxpNciHal_Sem_t*)pContext;
   if (hal_write_timer_fired == 1) {
     NXPLOG_NCIHAL_D("hal_read_cb - response timeout occurred");
 
@@ -999,51 +741,71 @@
     p_cb_data->status = NFCSTATUS_RESPONSE_TIMEOUT;
     status = phTmlNfc_ReadAbort();
   } else {
-    NFCSTATUS status = phOsalNfc_Timer_Stop(timeoutTimerId);
 
+    NFCSTATUS status = phOsalNfc_Timer_Stop(timeoutTimerId);
     if (NFCSTATUS_SUCCESS == status) {
       NXPLOG_NCIHAL_D("Response timer stopped");
     } else {
       NXPLOG_NCIHAL_E("Response timer stop ERROR!!!");
       p_cb_data->status = NFCSTATUS_FAILED;
     }
-    if (pInfo == NULL) {
-      NXPLOG_NCIHAL_E("Empty TransactInfo");
-      p_cb_data->status = NFCSTATUS_FAILED;
-    } else {
-      if (pInfo->wStatus == NFCSTATUS_SUCCESS) {
-        NXPLOG_NCIHAL_D("hal_read_cb successful status = 0x%x", pInfo->wStatus);
-        p_cb_data->status = NFCSTATUS_SUCCESS;
-      } else {
-        NXPLOG_NCIHAL_E("hal_read_cb error status = 0x%x", pInfo->wStatus);
-        p_cb_data->status = NFCSTATUS_FAILED;
-      }
-
-      p_cb_data->status = pInfo->wStatus;
-
-      nci_test_data_t* test_data = (nci_test_data_t*)p_cb_data->pContext;
-
-      if (test_data->exp_rsp.len == 0) {
-        /* Compare the actual notification with expected notification.*/
-        if (test_data->ntf_validator(&(test_data->exp_ntf), pInfo) == 1) {
-          p_cb_data->status = NFCSTATUS_SUCCESS;
-        } else {
-          p_cb_data->status = NFCSTATUS_FAILED;
+    if (pInfo->wStatus == NFCSTATUS_SUCCESS) {
+      NXPLOG_NCIHAL_D("hal_read_cb successful status = 0x%x", pInfo->wStatus);
+      if(pInfo->pBuff[0] == NCI_MT_RSP && ((pInfo->pBuff[1] & NCI_OID_MASK) == NCI_MSG_CORE_RESET)){
+        if(pInfo->pBuff[2] == NCI20_CORE_RESET_RSP_LEN && pInfo->pBuff[3] == NCI_CORE_RESET_STATUS_OK){
+          NXPLOG_NCIHAL_D("CORE_RESET_RSP NCI2.0");
+          mSelfTestHdlr.wait_for_ntf = TRUE;
+        }
+        else if(pInfo->pBuff[2] == NCI10_CORE_RESET_RSP_LEN && pInfo->pBuff[3] == NCI_CORE_RESET_STATUS_OK){
+          NXPLOG_NCIHAL_D("CORE_RESET_RSP NCI1.0");
+          mSelfTestHdlr.wait_for_ntf = FALSE;
+          mSelfTestHdlr.nci_version = pInfo->pBuff[4];
+        }
+      }else if (pInfo->pBuff[0] == NCI_MT_NTF && ((pInfo->pBuff[1] & NCI_OID_MASK) == NCI_MSG_CORE_RESET)){
+        mSelfTestHdlr.mTransInfo.wStatus = pInfo->wStatus;
+        mSelfTestHdlr.mTransInfo.wLength = pInfo->wLength;
+        memcpy(mSelfTestHdlr.mTransInfo.pBuff, pInfo->pBuff, pInfo->wLength);
+        mSelfTestHdlr.nci_version = pInfo->pBuff[5];
+        mSelfTestHdlr.wait_for_ntf = FALSE;
+      }else if(pInfo->pBuff[0] == NCI_MT_RSP && ((pInfo->pBuff[1] & NCI_OID_MASK) == NCI_MSG_CORE_INIT)){
+        mSelfTestHdlr.wait_for_ntf = FALSE;
+        if(mSelfTestHdlr.nci_version == NCI_VERSION_2_0){
+          NXPLOG_NCIHAL_D("CORE_INIT_RSP NCI2.0 received !");
+        }
+        else{
+          mSelfTestHdlr.mTransInfo.wStatus = pInfo->wStatus;
+          mSelfTestHdlr.mTransInfo.wLength = pInfo->wLength;
+          memcpy(mSelfTestHdlr.mTransInfo.pBuff, pInfo->pBuff, pInfo->wLength);
+          NXPLOG_NCIHAL_D("CORE_INIT_RSP NCI1.0 received !");
         }
       }
+      p_cb_data->status = NFCSTATUS_SUCCESS;
+    } else {
+      NXPLOG_NCIHAL_E("hal_read_cb error status = 0x%x", pInfo->wStatus);
+      p_cb_data->status = NFCSTATUS_FAILED;
+    }
 
-      /* Compare the actual response with expected response.*/
-      else if (test_data->rsp_validator(&(test_data->exp_rsp), pInfo) == 1) {
+    nci_test_data_t* test_data = (nci_test_data_t*)p_cb_data->pContext;
+    if ((pInfo->pBuff[0] & NCI_MSG_TYPE_MASK) == NCI_MT_NTF) {
+      /* Compare the actual notification with expected notification.*/
+      if (test_data->ntf_validator(&(test_data->exp_ntf), pInfo) == 1) {
         p_cb_data->status = NFCSTATUS_SUCCESS;
       } else {
         p_cb_data->status = NFCSTATUS_FAILED;
       }
-      test_data->exp_rsp.len = 0;
+    }
+
+    /* Compare the actual response with expected response.*/
+    else if((pInfo->pBuff[0] & NCI_MSG_TYPE_MASK) == NCI_MT_RSP){
+      if (test_data->rsp_validator(&(test_data->exp_rsp), pInfo) == 1) {
+        p_cb_data->status = NFCSTATUS_SUCCESS;
+      } else {
+        p_cb_data->status = NFCSTATUS_FAILED;
+      }
     }
   }
 
   SEM_POST(p_cb_data);
-
   return;
 }
 
@@ -1073,7 +835,6 @@
     if (thread_running == 0) {
       break;
     }
-
     switch (msg.eMsgType) {
       case PH_LIBNFC_DEFERREDCALL_MSG: {
         phLibNfc_DeferredCall_t* deferCall =
@@ -1082,7 +843,6 @@
         REENTRANCE_LOCK();
         deferCall->pCallback(deferCall->pParameter);
         REENTRANCE_UNLOCK();
-
         break;
       }
     }
@@ -1111,7 +871,6 @@
   uint16_t read_len = 16;
   /* RX Buffer */
   uint32_t rx_data[NCI_MAX_DATA_LEN];
-
   /* Create the local semaphore */
   if (phNxpNciHal_init_cb_data(&cb_data, pData) != NFCSTATUS_SUCCESS) {
     NXPLOG_NCIHAL_D("phTmlNfc_Read Create cb data failed");
@@ -1162,7 +921,6 @@
 
 clean_and_return:
   phNxpNciHal_cleanup_cb_data(&cb_data);
-
   return status;
 }
 
@@ -1182,7 +940,6 @@
 
   phNxpNciHal_Sem_t cb_data;
   int retryCnt = 0;
-
   /* Create the local semaphore */
   if (phNxpNciHal_init_cb_data(&cb_data, NULL) != NFCSTATUS_SUCCESS) {
     NXPLOG_NCIHAL_D("phTmlNfc_Write Create cb data failed");
@@ -1218,7 +975,6 @@
 
 clean_and_return:
   phNxpNciHal_cleanup_cb_data(&cb_data);
-
   return status;
 }
 
@@ -1286,11 +1042,15 @@
   phOsalNfc_Config_t tOsalConfig;
   phTmlNfc_Config_t tTmlConfig;
   uint8_t* nfc_dev_node = NULL;
-  const uint16_t max_len =
-      260; /* device node name is max of 255 bytes + 5 bytes (/dev/) */
+  const uint16_t max_len = 260; /* device node name is max of 255 bytes + 5 bytes (/dev/) */
   NFCSTATUS status = NFCSTATUS_SUCCESS;
   uint16_t read_len = 255;
   int8_t ret_val = 0x00;
+  mSelfTestHdlr.mTransInfo.pBuff  = (uint8_t *)malloc(max_len * sizeof(uint8_t));
+  if(mSelfTestHdlr.mTransInfo.pBuff == NULL){
+      NXPLOG_NCIHAL_E("Error ! memory not allocated.");
+      return NFCSTATUS_FAILED;
+  }
   /* initialize trace level */
   phNxpLog_InitializeLogLevel();
 
@@ -1336,7 +1096,6 @@
       nfc_dev_node = NULL;
     }
   }
-
   pthread_attr_t attr;
   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@@ -1351,6 +1110,11 @@
 
   timeoutTimerId = phOsalNfc_Timer_Create();
 
+  if(phNxpNciHal_initialize_chipType() != NFCSTATUS_SUCCESS){
+    NXPLOG_NCIHAL_E("Chip initialization failed");
+    goto clean_and_return;
+  }
+
   if (timeoutTimerId == 0xFFFF) {
     NXPLOG_NCIHAL_E("phOsalNfc_Timer_Create failed");
   } else {
@@ -1372,6 +1136,101 @@
 
 /*******************************************************************************
  **
+ ** Function         phNxpNciHal_initialize_chipType
+ **
+ ** Description      This function Initializes the NFCC chip type and
+ **                  Feature list flags
+ **
+ ** Returns          None.
+ **
+ ******************************************************************************/
+NFCSTATUS phNxpNciHal_initialize_chipType()
+{
+    nci_test_data_t* pCoreResetCmd = &swp1_test_data[0];
+    nci_test_data_t* pCoreInitCmd = &swp1_test_data[1];
+    NFCSTATUS status = NFCSTATUS_SUCCESS;
+    NXPLOG_NCIHAL_D("phNxpNciHal_initialize_chipType() : entry");
+
+    //CORE RESET COMMAND
+    if(!phNxpNciHal_writeLocked(pCoreResetCmd)){
+      if(phNxpNciHal_readLocked(pCoreResetCmd) != NFCSTATUS_SUCCESS){
+        NXPLOG_NCIHAL_D("Response not received for CORE RESET command");
+      }
+
+      if(mSelfTestHdlr.wait_for_ntf){
+        pCoreResetCmd->exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+        memcpy(pCoreResetCmd->exp_rsp.p_data, nfcc_core_reset_nci20_rsp,pCoreResetCmd->exp_rsp.len);
+        pCoreResetCmd->exp_ntf.len = (sizeof(nfcc_core_reset_nci20_ntf) / sizeof(nfcc_core_reset_nci20_ntf[0]));
+        memcpy(pCoreResetCmd->exp_ntf.p_data, nfcc_core_reset_nci20_ntf, pCoreResetCmd->exp_ntf.len);
+        if(phNxpNciHal_readLocked(pCoreResetCmd) != NFCSTATUS_SUCCESS){
+          NXPLOG_NCIHAL_D("NCI 2.0 Notification is not received");
+          status = NFCSTATUS_FAILED;
+        }else{
+          phNxpNciHal_configFeatureList(mSelfTestHdlr.mTransInfo.pBuff,mSelfTestHdlr.mTransInfo.wLength);
+        }
+      }
+    }else{
+      NXPLOG_NCIHAL_E("CORE RESET Write failed");
+      return NFCSTATUS_FAILED;
+    }
+
+    //CORE INIT COMMAND
+    if(mSelfTestHdlr.nci_version == NCI_VERSION_2_0){
+      pCoreInitCmd->cmd.len = NFCC_CMD_NCI20_LEN;
+      memcpy(pCoreInitCmd->cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+      pCoreInitCmd->exp_rsp.len = sizeof(nfcc_core_init_nci20_rsp);
+      memcpy(pCoreInitCmd->exp_rsp.p_data, nfcc_core_init_nci20_rsp,pCoreInitCmd->exp_rsp.len);
+      status = phNxpNciHal_writeLocked(pCoreInitCmd);
+    }
+    else{
+      pCoreInitCmd->cmd.len = NFCC_CMD_NCI10_LEN;
+      memcpy(pCoreInitCmd->cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+      status = phNxpNciHal_writeLocked(pCoreInitCmd);
+    }
+    if(!status){
+      if(phNxpNciHal_readLocked(pCoreInitCmd)  != NFCSTATUS_SUCCESS){
+        NXPLOG_NCIHAL_D("Response not received for CORE INIT command");
+        status = NFCSTATUS_FAILED;
+      }else{
+        if(mSelfTestHdlr.nci_version != NCI_VERSION_2_0){
+          phNxpNciHal_configFeatureList(mSelfTestHdlr.mTransInfo.pBuff,mSelfTestHdlr.mTransInfo.wLength);
+        }
+      }
+    }else
+        status = NFCSTATUS_FAILED;
+    if(!status && (nfcFL.chipType == pn557) && (mSelfTestHdlr.nci_version != NCI_VERSION_2_0)){
+      NXPLOG_NCIHAL_E("Chip is in NCI1.0 mode reset the chip to 2.0 mode");
+      if(!phNxpNciHal_writeLocked(pCoreResetCmd)){
+        if(phNxpNciHal_readLocked(pCoreResetCmd) != NFCSTATUS_SUCCESS){
+          NXPLOG_NCIHAL_D("Response not received for CORE RESET command");
+          status = NFCSTATUS_FAILED;
+        }
+        if(mSelfTestHdlr.wait_for_ntf){
+          if(phNxpNciHal_readLocked(pCoreResetCmd) != NFCSTATUS_SUCCESS){
+            NXPLOG_NCIHAL_D("NCI 2.0 Notification is not received");
+            status = NFCSTATUS_FAILED;
+          }
+        }
+      }else
+        status = NFCSTATUS_FAILED;
+      pCoreInitCmd->cmd.len = NFCC_CMD_NCI20_LEN;
+      memcpy(pCoreInitCmd->cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+      pCoreInitCmd->exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+      memcpy(pCoreInitCmd->exp_rsp.p_data, nfcc_core_reset_nci20_rsp,pCoreInitCmd->exp_rsp.len);
+      if(!phNxpNciHal_writeLocked(pCoreInitCmd)){
+        if(phNxpNciHal_readLocked(pCoreInitCmd) != NFCSTATUS_SUCCESS){
+          NXPLOG_NCIHAL_D("Response not received for CORE RESET command");
+          status = NFCSTATUS_FAILED;
+        }
+      }
+      else
+        status = NFCSTATUS_FAILED;
+    }
+    NXPLOG_NCIHAL_D("phNxpNciHal_initialize_chipType() : exit chipType = 0x%02X",nfcFL.chipType);
+    return status;
+}
+/*******************************************************************************
+ **
  ** Function         phNxpNciHal_TestMode_close
  **
  ** Description      This function close the NFCC interface and free all
@@ -1404,6 +1263,8 @@
     status = phOsalNfc_Timer_Delete(timeoutTimerId);
   }
 
+  free(mSelfTestHdlr.mTransInfo.pBuff);
+  mSelfTestHdlr.mTransInfo.pBuff = NULL;
   CONCURRENCY_UNLOCK();
 
   phNxpNciHal_cleanup_monitor();
@@ -1431,8 +1292,22 @@
   NXPLOG_NCIHAL_D("phNxpNciHal_SwpTest - start\n");
 
   if (swp_line == 0x01) {
+    swp1_test_data[0].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+    swp1_test_data[1].exp_rsp.p_data[2] = NFCC_EXP_RES_DATA_BYTE2;
+    if(nfcFL.chipType == pn557){
+      swp1_test_data[0].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+      memcpy(swp1_test_data[0].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,swp1_test_data[0].exp_rsp.len);
+      swp1_test_data[0].exp_ntf.len = (sizeof(nfcc_core_reset_nci20_ntf) / sizeof(nfcc_core_reset_nci20_ntf[0]));
+      memcpy(swp1_test_data[0].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, swp1_test_data[0].exp_ntf.len);
+      swp1_test_data[1].cmd.len = NFCC_CMD_NCI20_LEN;
+      memcpy(swp1_test_data[1].cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+      swp1_test_data[1].exp_rsp.len = sizeof(nfcc_core_init_nci20_rsp);
+      memcpy(swp1_test_data[1].exp_rsp.p_data, nfcc_core_init_nci20_rsp, swp1_test_data[1].exp_rsp.len);
+    }else{
+      swp1_test_data[1].cmd.len = NFCC_CMD_NCI10_LEN;
+      memcpy(swp1_test_data[1].cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+    }
     len = (sizeof(swp1_test_data) / sizeof(swp1_test_data[0]));
-
     for (cnt = 0; cnt < len; cnt++) {
       status = phNxpNciHal_performTest(&(swp1_test_data[cnt]));
       if (status == NFCSTATUS_RESPONSE_TIMEOUT || status == NFCSTATUS_FAILED) {
@@ -1440,6 +1315,21 @@
       }
     }
   } else if (swp_line == 0x02) {
+     swp2_test_data[0].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+     swp2_test_data[1].exp_rsp.p_data[2] = NFCC_EXP_RES_DATA_BYTE2;
+     if(nfcFL.chipType == pn557){
+       swp2_test_data[0].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+       memcpy(swp2_test_data[0].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,swp2_test_data[0].exp_rsp.len);
+       swp2_test_data[0].exp_ntf.len = (sizeof(nfcc_core_reset_nci20_ntf) / sizeof(nfcc_core_reset_nci20_ntf[0]));
+       memcpy(swp2_test_data[0].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, swp2_test_data[0].exp_ntf.len);
+       swp2_test_data[1].cmd.len = NFCC_CMD_NCI20_LEN;
+       memcpy(swp2_test_data[1].cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+       swp2_test_data[1].exp_rsp.len = sizeof(nfcc_core_init_nci20_rsp);
+       memcpy(swp2_test_data[1].exp_rsp.p_data, nfcc_core_init_nci20_rsp, swp2_test_data[1].exp_rsp.len);
+     }else{
+       swp2_test_data[1].cmd.len = NFCC_CMD_NCI10_LEN;
+       memcpy(swp2_test_data[1].cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+     }
     len = (sizeof(swp2_test_data) / sizeof(swp2_test_data[0]));
 
     for (cnt = 0; cnt < len; cnt++) {
@@ -1488,10 +1378,10 @@
   uint8_t rsp_cmd_info[] = {0x4F, 0x30, 0x01, 0x00};
 
   if(nfcFL.chipType != pn547C2) {
-      prbs_cmd_data.cmd.len = 0x09;
+    prbs_cmd_data.cmd.len = 0x09;
   }
   else {
-      prbs_cmd_data.cmd.len = 0x07;
+    prbs_cmd_data.cmd.len = 0x07;
   }
 
   memcpy(prbs_cmd_data.exp_rsp.p_data, &rsp_cmd_info[0], sizeof(rsp_cmd_info));
@@ -1508,12 +1398,12 @@
 //    [NCI] -> [0x2F 0x30 0x04 0x00 0x00 0x01 0xFF]
 
   if(nfcFL.chipType != pn547C2) {
-      status =
+    status =
               phNxpNciHal_getPrbsCmd(prbs_type, hw_prbs_type, tech, bitrate,
                       prbs_cmd_data.cmd.p_data, prbs_cmd_data.cmd.len);
   }
   else {
-      status = phNxpNciHal_getPrbsCmd(0,0,tech, bitrate, prbs_cmd_data.cmd.p_data,
+    status = phNxpNciHal_getPrbsCmd(0,0,tech, bitrate, prbs_cmd_data.cmd.p_data,
               prbs_cmd_data.cmd.len);
   }
 
@@ -1523,8 +1413,37 @@
 
     goto clean_and_return;
   }
-
-  len = (sizeof(prbs_test_data) / sizeof(prbs_test_data[0]));
+  prbs_test_data[len].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+  if(nfcFL.chipType == pn557){
+    prbs_test_data[len].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+    memcpy(prbs_test_data[len].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,prbs_test_data[len].exp_rsp.len);
+    prbs_test_data[len].exp_ntf.len = (sizeof(nfcc_core_reset_nci20_ntf) / sizeof(nfcc_core_reset_nci20_ntf[len]));
+    memcpy(prbs_test_data[len].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, prbs_test_data[len].exp_ntf.len);
+  }
+  len++;//val 1
+  prbs_test_data[len].exp_rsp.p_data[2] = NFCC_EXP_RES_DATA_BYTE2;
+  if(nfcFL.chipType == pn557){
+    prbs_test_data[len].cmd.len = NFCC_CMD_NCI20_LEN;
+    memcpy(prbs_test_data[len].cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+    prbs_test_data[len].exp_rsp.len = sizeof(nfcc_core_init_nci20_rsp);
+    memcpy(prbs_test_data[len].exp_rsp.p_data, nfcc_core_init_nci20_rsp, prbs_test_data[len].exp_rsp.len);
+  }else{
+    prbs_test_data[len].cmd.len = NFCC_CMD_NCI10_LEN;
+    memcpy(prbs_test_data[len].cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+  }
+  len++;//val 2
+  if(nfcFL.chipType == pn547C2)
+  {
+    prbs_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd);
+    memcpy(prbs_test_data[len].cmd.p_data, nfcc_power_mgt_cmd, prbs_test_data[len].cmd.len);
+    prbs_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+    memcpy(prbs_test_data[2].exp_rsp.p_data, nfcc_power_mgt_rsp, prbs_test_data[len].cmd.len);
+    prbs_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+    prbs_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+    prbs_test_data[len].rsp_validator = st_validator_testEquals;
+    prbs_test_data[len].ntf_validator = st_validator_null;
+    len++;//val 3
+  }
 
   for (cnt = 0; cnt < len; cnt++) {
     status = phNxpNciHal_performTest(&(prbs_test_data[cnt]));
@@ -1609,28 +1528,27 @@
   prbs_cmd[0] = 0x2F;
   prbs_cmd[1] = 0x30;
   if(nfcFL.chipType != pn547C2) {
-      prbs_cmd[2] = 0x06;
-      prbs_cmd[3] = (uint8_t)prbs_type;
-      // 0xFF Error value used for validation.
-      prbs_cmd[4] = (uint8_t)hw_prbs_type;
-      prbs_cmd[5] = 0xFF;  // TECH
-      prbs_cmd[6] = 0xFF;  // BITRATE
-      prbs_cmd[7] = 0x01;
-      prbs_cmd[8] = 0xFF;
-      position_tech_param = 5;
-      position_bit_param = 6;
+    prbs_cmd[2] = 0x06;
+    prbs_cmd[3] = (uint8_t)prbs_type;
+    // 0xFF Error value used for validation.
+    prbs_cmd[4] = (uint8_t)hw_prbs_type;
+    prbs_cmd[5] = 0xFF;  // TECH
+    prbs_cmd[6] = 0xFF;  // BITRATE
+    prbs_cmd[7] = 0x01;
+    prbs_cmd[8] = 0xFF;
+    position_tech_param = 5;
+    position_bit_param = 6;
   } else {
-      prbs_cmd[2] = 0x04;
-      // 0xFF Error value used for validation.
-      prbs_cmd[3] = 0xFF;  // TECH
-      // 0xFF Error value used for validation.
-      prbs_cmd[4] = 0xFF;  // BITRATE
-      prbs_cmd[5] = 0x01;
-      prbs_cmd[6] = 0xFF;
-      position_tech_param = 3;
-      position_bit_param = 4;
+    prbs_cmd[2] = 0x04;
+    // 0xFF Error value used for validation.
+    prbs_cmd[3] = 0xFF;  // TECH
+    // 0xFF Error value used for validation.
+    prbs_cmd[4] = 0xFF;  // BITRATE
+    prbs_cmd[5] = 0x01;
+    prbs_cmd[6] = 0xFF;
+    position_tech_param = 3;
+    position_bit_param = 4;
   }
-
   switch (tech) {
     case NFC_RF_TECHNOLOGY_A:
       NXPLOG_NCIHAL_D("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_A");
@@ -1695,11 +1613,85 @@
   NFCSTATUS status = NFCSTATUS_SUCCESS;
   int len = 0;
   int cnt = 0;
-
+  uint8_t nfcc_act_cmd[] = SYSTEM_PROPRIETARY_ACT_CMD;
+  uint8_t nfcc_act_exp_rsp[] = SYSTEM_PROPRIETARY_ACT_RSP;
+  uint8_t nfcc_antena_cmd1[] = SYSTEM_TEST_ANTENNA_CMD_1;
+  uint8_t nfcc_antena_cmd2[] = SYSTEM_TEST_ANTENNA_CMD_2;
+  uint8_t nfcc_antena_rsp1[] = SYSTEM_TEST_ANTENNA_RSP_1;
+  uint8_t nfcc_power_mgt_cmd_1[] = SYSTEM_SET_POWERMGT_CMD_1;
+  uint8_t nfcc_antena_cmd3[] = SYSTEM_TEST_ANTENNA_CMD_3;
+  uint8_t nfcc_antena_cmd4[] = SYSTEM_TEST_ANTENNA_CMD_4;
   NXPLOG_NCIHAL_D("phNxpNciHal_RfFieldTest - start %x\n", on);
 
   if (on == 0x01) {
-    len = (sizeof(rf_field_on_test_data) / sizeof(rf_field_on_test_data[0]));
+    rf_field_on_test_data[len].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+    if(nfcFL.chipType == pn557)   {
+      rf_field_on_test_data[len].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+      memcpy(rf_field_on_test_data[len].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,rf_field_on_test_data[len].exp_rsp.len);
+      rf_field_on_test_data[len].exp_ntf.len = sizeof(nfcc_core_reset_nci20_ntf);
+      memcpy(rf_field_on_test_data[len].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, rf_field_on_test_data[len].exp_ntf.len);
+    }
+    len++;// len val 1
+    rf_field_on_test_data[len].exp_rsp.p_data[2] = NFCC_EXP_RES_DATA_BYTE2;
+    if(nfcFL.chipType == pn557){
+      rf_field_on_test_data[len].cmd.len = NFCC_CMD_NCI20_LEN;
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+      rf_field_on_test_data[len].exp_rsp.len = sizeof(nfcc_core_init_nci20_rsp);
+      memcpy(rf_field_on_test_data[len].exp_rsp.p_data, nfcc_core_init_nci20_rsp, rf_field_on_test_data[len].exp_rsp.len);
+    }else{
+      rf_field_on_test_data[len].cmd.len = NFCC_CMD_NCI10_LEN;
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+    }
+    len++; //len val 2
+    if(nfcFL.chipType != pn547C2)
+    {
+      rf_field_on_test_data[len].cmd.len = sizeof(nfcc_act_cmd);
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_act_cmd, rf_field_on_test_data[len].cmd.len);
+      rf_field_on_test_data[len].exp_rsp.len = sizeof(nfcc_act_exp_rsp);
+      memcpy(rf_field_on_test_data[len].exp_rsp.p_data, nfcc_act_exp_rsp, rf_field_on_test_data[len].cmd.len);
+      rf_field_on_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+      rf_field_on_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+      rf_field_on_test_data[len].rsp_validator = st_validator_testEquals;
+      rf_field_on_test_data[len].ntf_validator = st_validator_null;
+      len++; //len val 3
+
+      rf_field_on_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd);
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_power_mgt_cmd, rf_field_on_test_data[len].cmd.len);
+      rf_field_on_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+      memcpy(rf_field_on_test_data[len].exp_rsp.p_data, nfcc_power_mgt_rsp, rf_field_on_test_data[len].cmd.len);
+      rf_field_on_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+      rf_field_on_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+      rf_field_on_test_data[len].rsp_validator = st_validator_testEquals;
+      rf_field_on_test_data[len].ntf_validator = st_validator_null;
+      len++; //len val 4
+    }
+    if(nfcFL.chipType != pn547C2){
+      rf_field_on_test_data[len].cmd.len = sizeof(nfcc_antena_cmd2);
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_antena_cmd2, rf_field_on_test_data[len].cmd.len);
+    }
+    else{
+      rf_field_on_test_data[len].cmd.len = sizeof(nfcc_antena_cmd1);
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_antena_cmd1, rf_field_on_test_data[len].cmd.len);
+    }
+    rf_field_on_test_data[len].exp_rsp.len = sizeof(nfcc_antena_rsp1);
+    memcpy(rf_field_on_test_data[len].exp_rsp.p_data, nfcc_antena_rsp1, rf_field_on_test_data[len].cmd.len);
+    rf_field_on_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+    rf_field_on_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+    rf_field_on_test_data[len].rsp_validator = st_validator_testEquals;
+    rf_field_on_test_data[len].ntf_validator = st_validator_null;
+    len++; //len val 5
+    if(nfcFL.chipType != pn547C2)
+    {
+      rf_field_on_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd_1);
+      memcpy(rf_field_on_test_data[len].cmd.p_data, nfcc_power_mgt_cmd_1, rf_field_on_test_data[len].cmd.len);
+      rf_field_on_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+      memcpy(rf_field_on_test_data[len].exp_rsp.p_data, nfcc_power_mgt_rsp, rf_field_on_test_data[len].cmd.len);
+      rf_field_on_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+      rf_field_on_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+      rf_field_on_test_data[len].rsp_validator = st_validator_testEquals;
+      rf_field_on_test_data[len].ntf_validator = st_validator_null;
+      len++; //len val 6
+    }
 
     for (cnt = 0; cnt < len; cnt++) {
       status = phNxpNciHal_performTest(&(rf_field_on_test_data[cnt]));
@@ -1708,7 +1700,72 @@
       }
     }
   } else if (on == 0x00) {
-    len = (sizeof(rf_field_off_test_data) / sizeof(rf_field_off_test_data[0]));
+    rf_field_off_test_data[len].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+    if(nfcFL.chipType == pn557)   {
+      rf_field_off_test_data[len].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+      memcpy(rf_field_off_test_data[len].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,rf_field_off_test_data[len].exp_rsp.len);
+      rf_field_off_test_data[len].exp_ntf.len = sizeof(nfcc_core_reset_nci20_ntf);
+      memcpy(rf_field_off_test_data[len].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, rf_field_off_test_data[len].exp_ntf.len);
+    }
+    len++;//len val 1
+    rf_field_off_test_data[len].exp_rsp.p_data[2] = NFCC_EXP_RES_DATA_BYTE2;
+    if(nfcFL.chipType == pn557){
+      rf_field_off_test_data[len].cmd.len = NFCC_CMD_NCI20_LEN;
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+    }else{
+      rf_field_off_test_data[len].cmd.len = NFCC_CMD_NCI10_LEN;
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+    }
+    len++;//len val 2
+    if(nfcFL.chipType != pn547C2)
+    {
+      rf_field_off_test_data[len].cmd.len = sizeof(nfcc_act_cmd);
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_act_cmd, rf_field_off_test_data[len].cmd.len);
+      rf_field_off_test_data[len].exp_rsp.len = sizeof(nfcc_act_exp_rsp);
+      memcpy(rf_field_off_test_data[len].exp_rsp.p_data, nfcc_act_exp_rsp, rf_field_off_test_data[len].cmd.len);
+      rf_field_off_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+      rf_field_off_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+      rf_field_off_test_data[len].rsp_validator = st_validator_testEquals;
+      rf_field_off_test_data[len].ntf_validator = st_validator_null;
+      len++; //len val 3
+
+      rf_field_off_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd);
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_power_mgt_cmd, rf_field_off_test_data[len].cmd.len);
+      rf_field_off_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+      memcpy(rf_field_off_test_data[len].exp_rsp.p_data, nfcc_power_mgt_rsp, rf_field_off_test_data[len].cmd.len);
+      rf_field_off_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+      rf_field_off_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+      rf_field_off_test_data[len].rsp_validator = st_validator_testEquals;
+      rf_field_off_test_data[len].ntf_validator = st_validator_null;
+      len++; //len val 4
+    }
+    if(nfcFL.chipType != pn547C2){
+      rf_field_off_test_data[len].cmd.len = sizeof(nfcc_antena_cmd3);
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_antena_cmd3, rf_field_off_test_data[len].cmd.len);
+    }
+    else{
+      rf_field_off_test_data[len].cmd.len = sizeof(nfcc_antena_cmd4);
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_antena_cmd4, rf_field_off_test_data[len].cmd.len);
+    }
+    rf_field_off_test_data[len].exp_rsp.len = sizeof(nfcc_antena_rsp1);
+    memcpy(rf_field_off_test_data[len].exp_rsp.p_data, nfcc_antena_rsp1, rf_field_off_test_data[len].cmd.len);
+    rf_field_off_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+    rf_field_off_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+    rf_field_off_test_data[len].rsp_validator = st_validator_testEquals;
+    rf_field_off_test_data[len].ntf_validator = st_validator_null;
+    len++; //len val 5
+    if(nfcFL.chipType != pn547C2)
+    {
+      rf_field_off_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd);
+      memcpy(rf_field_off_test_data[len].cmd.p_data, nfcc_power_mgt_cmd, rf_field_off_test_data[len].cmd.len);
+      rf_field_off_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+      memcpy(rf_field_off_test_data[len].exp_rsp.p_data, nfcc_power_mgt_rsp, rf_field_off_test_data[len].cmd.len);
+      rf_field_off_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+      rf_field_off_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+      rf_field_off_test_data[len].rsp_validator = st_validator_testEquals;
+      rf_field_off_test_data[len].ntf_validator = st_validator_null;
+      len++; //len val 6
+    }
 
     for (cnt = 0; cnt < len; cnt++) {
       status = phNxpNciHal_performTest(&(rf_field_off_test_data[cnt]));
@@ -1762,6 +1819,13 @@
 
   NXPLOG_NCIHAL_D("phNxpNciHal_DownloadPinTest - start\n");
 
+  download_pin_test_data1[0].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+  if(nfcFL.chipType == pn557)   {
+    download_pin_test_data1[0].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+    memcpy(download_pin_test_data1[0].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,download_pin_test_data1[0].exp_rsp.len);
+    download_pin_test_data1[0].exp_ntf.len = sizeof(nfcc_core_reset_nci20_ntf);
+    memcpy(download_pin_test_data1[0].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, download_pin_test_data1[0].exp_ntf.len);
+  }
   len = (sizeof(download_pin_test_data1) / sizeof(download_pin_test_data1[0]));
 
   for (cnt = 0; cnt < len; cnt++) {
@@ -1818,10 +1882,101 @@
   NFCSTATUS antenna_st_status = NFCSTATUS_FAILED;
   int len = 0;
   int cnt = 0;
+  uint8_t nfcc_antena_cmd5[] = SYSTEM_TEST_ANTENNA_CMD_5;
+  uint8_t nfcc_antena_rsp2[] = SYSTEM_TEST_ANTENNA_RSP_2;
+  uint8_t nfcc_antena_cmd6[] = SYSTEM_TEST_ANTENNA_CMD_6; /* AGC with NFCLD measurement cmd */
+  uint8_t nfcc_antena_cmd7[] = SYSTEM_TEST_ANTENNA_CMD_7;
+  uint8_t nfcc_antena_cmd8[] = SYSTEM_TEST_ANTENNA_CMD_8;
+  uint8_t nfcc_antena_cmd9[] = SYSTEM_TEST_ANTENNA_CMD_9;
+  uint8_t nfcc_power_mgt_cmd_1[] = SYSTEM_SET_POWERMGT_CMD_1;
 
   NXPLOG_NCIHAL_D("phNxpNciHal_AntennaSelfTest - start\n");
   memcpy(&phAntenna_resp, phAntenna_St_Resp, sizeof(phAntenna_St_Resp_t));
-  len = (sizeof(antenna_self_test_data) / sizeof(antenna_self_test_data[0]));
+  antenna_self_test_data[len].exp_rsp.p_data[4] = nfcFL.platformFL._NFCC_RESET_RSP_LEN;
+  if(nfcFL.chipType == pn557){
+    antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_core_reset_nci20_rsp);
+    memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_core_reset_nci20_rsp,antenna_self_test_data[len].exp_rsp.len);
+    antenna_self_test_data[len].exp_ntf.len = sizeof(nfcc_core_reset_nci20_ntf);
+    memcpy(antenna_self_test_data[len].exp_ntf.p_data, nfcc_core_reset_nci20_ntf, antenna_self_test_data[len].exp_ntf.len);
+  }
+  len++;//len val 1
+  antenna_self_test_data[len].exp_rsp.p_data[2] = NFCC_EXP_RES_DATA_BYTE2;
+  if(nfcFL.chipType == pn557){
+    antenna_self_test_data[len].cmd.len = NFCC_CMD_NCI20_LEN;
+    memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_core_init_nci20_cmd, NFCC_CMD_NCI20_LEN);
+  }else{
+    antenna_self_test_data[len].cmd.len = NFCC_CMD_NCI10_LEN;
+    memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_core_init_nci10_cmd, NFCC_CMD_NCI10_LEN);
+  }
+  len+=2;//len val 3, By default, structure will be filled till array 3
+
+  if(nfcFL.chipType != pn547C2)
+  {
+    antenna_self_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd);
+    memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_power_mgt_cmd, antenna_self_test_data[len].cmd.len);
+    antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+    memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_power_mgt_rsp, antenna_self_test_data[len].cmd.len);
+    antenna_self_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+    antenna_self_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+    antenna_self_test_data[len].rsp_validator = st_validator_testEquals;
+    antenna_self_test_data[len].ntf_validator = st_validator_null;
+    len++; //len val 4
+  }
+  antenna_self_test_data[len].cmd.len = sizeof(nfcc_antena_cmd5);
+  memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_antena_cmd5, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_antena_rsp2);
+  memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_antena_rsp2, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+  antenna_self_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+  antenna_self_test_data[len].rsp_validator = st_validator_testAntenna_Txldo;
+  antenna_self_test_data[len].ntf_validator = st_validator_null;
+  len++; //len val 5
+  if(nfcFL.chipType != pn547C2){
+    antenna_self_test_data[len].cmd.len = sizeof(nfcc_antena_cmd7);
+    memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_antena_cmd7, antenna_self_test_data[len].cmd.len);
+  }
+  else{
+    antenna_self_test_data[len].cmd.len = sizeof(nfcc_antena_cmd8);
+    memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_antena_cmd8, antenna_self_test_data[len].cmd.len);
+  }
+  antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_antena_rsp2);
+  memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_antena_rsp2, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+  antenna_self_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+  antenna_self_test_data[len].rsp_validator = st_validator_testAntenna_AgcVal;
+  antenna_self_test_data[len].ntf_validator = st_validator_null;
+  len++;//len val 6
+  antenna_self_test_data[len].cmd.len = sizeof(nfcc_antena_cmd9);
+  memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_antena_cmd9, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_antena_rsp2);
+  memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_antena_rsp2, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+  antenna_self_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+  antenna_self_test_data[len].rsp_validator = st_validator_testAntenna_AgcVal_FixedNfcLd;
+  antenna_self_test_data[len].ntf_validator = st_validator_null;
+  len++;//len val 7
+
+  if(nfcFL.nfccFL._HW_ANTENNA_LOOP4_SELF_TEST){
+    antenna_self_test_data[len].cmd.len = sizeof(nfcc_antena_cmd6);
+    memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_antena_cmd6, antenna_self_test_data[len].cmd.len);
+    antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_antena_rsp2);
+    memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_antena_rsp2, antenna_self_test_data[len].cmd.len);
+    antenna_self_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+    antenna_self_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+    antenna_self_test_data[len].rsp_validator = st_validator_testAntenna_AgcVal_FixedNfcLd;
+    antenna_self_test_data[len].ntf_validator = st_validator_null;
+    len++;//len val 8
+  }
+
+  antenna_self_test_data[len].cmd.len = sizeof(nfcc_power_mgt_cmd_1);
+  memcpy(antenna_self_test_data[len].cmd.p_data, nfcc_power_mgt_cmd_1, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_rsp.len = sizeof(nfcc_power_mgt_rsp);
+  memcpy(antenna_self_test_data[len].exp_rsp.p_data, nfcc_power_mgt_rsp, antenna_self_test_data[len].cmd.len);
+  antenna_self_test_data[len].exp_ntf.len = NFCC_EXP_NTF_LEN_NULL;
+  antenna_self_test_data[len].exp_ntf.p_data[0] = NFCC_EXP_NTF_DATA_NULL;
+  antenna_self_test_data[len].rsp_validator = st_validator_testEquals;
+  antenna_self_test_data[len].ntf_validator = st_validator_null;
+  len++;//len val 9
 
   for (cnt = 0; cnt < len; cnt++) {
     status = phNxpNciHal_performTest(&(antenna_self_test_data[cnt]));
diff --git a/halimpl/pn54x/tml/phTmlNfc_i2c.c b/halimpl/pn54x/tml/phTmlNfc_i2c.c
index 55d0c0e..1a6abdf 100644
--- a/halimpl/pn54x/tml/phTmlNfc_i2c.c
+++ b/halimpl/pn54x/tml/phTmlNfc_i2c.c
@@ -578,3 +578,38 @@
 ** Returns           Current mode download/NCI
 *******************************************************************************/
 bool_t getDownloadFlag(void) { return bFwDnldFlag; }
+
+/*******************************************************************************
+**
+** Function         phTmlNfc_rel_dwpOnOff_wait
+**
+** Description
+**
+** Parameters       pDevHandle     - valid device handle
+**
+** Returns          success or failure
+**
+*******************************************************************************/
+NFCSTATUS phTmlNfc_rel_dwpOnOff_wait(void *pDevHandle)
+{
+    int ret = -1;
+    NFCSTATUS status = NFCSTATUS_SUCCESS;
+    NXPLOG_TML_D("phTmlNfc_rel_dwpOnOff_wait(), enter ");
+
+    if (NULL == pDevHandle)
+    {
+        return NFCSTATUS_FAILED;
+    }
+
+    ret = ioctl((intptr_t)pDevHandle, P544_REL_DWPONOFF_WAIT);
+    if (ret < 0)
+    {
+        if (ret == -EBUSY)
+            status = NFCSTATUS_BUSY;
+        else
+            status = NFCSTATUS_FAILED;
+    }
+    NXPLOG_TML_D("phTmlNfc_rel_dwpOnOff_wait(), exit  ret %d, status %d", ret, status);
+    return status;
+
+}
diff --git a/halimpl/pn54x/tml/phTmlNfc_i2c.h b/halimpl/pn54x/tml/phTmlNfc_i2c.h
index 23441f5..8903bc6 100644
--- a/halimpl/pn54x/tml/phTmlNfc_i2c.h
+++ b/halimpl/pn54x/tml/phTmlNfc_i2c.h
@@ -50,6 +50,7 @@
 NFCSTATUS phTmlNfc_get_ese_access(void* pDevHandle, long timeout);
 NFCSTATUS phTmlNfc_i2c_set_Jcop_dwnld_state(void* pDevHandle, long level);
 NFCSTATUS phTmlNfc_rel_svdd_wait(void* pDevHandle);
+NFCSTATUS phTmlNfc_rel_dwpOnOff_wait(void* pDevHandle);
 /*
  * SPI Request NFCC to enable p61 power, only in param
  * Only for SPI
@@ -93,3 +94,7 @@
  *
 */
 #define PN544_SET_DWNLD_STATUS _IOW(PN544_MAGIC, 0x09, long)
+/*
+ * NFC will call the ioctlto release the dwp on/off protection
+ */
+ #define P544_REL_DWPONOFF_WAIT  _IOW(PN544_MAGIC, 0x0A, long)
diff --git a/src/adaptation/NfcAdaptation.cpp b/src/adaptation/NfcAdaptation.cpp
index 273684d..25d94b7 100644
--- a/src/adaptation/NfcAdaptation.cpp
+++ b/src/adaptation/NfcAdaptation.cpp
@@ -200,9 +200,6 @@
   if (GetStrValue(NAME_NFA_DM_CFG, (char*)nfa_dm_cfg, sizeof(nfa_dm_cfg)))
     p_nfa_dm_cfg = (tNFA_DM_CFG*)((void*)&nfa_dm_cfg[0]);
 
-  nfa_ee_max_ee_cfg = NFA_EE_MAX_EE_SUPPORTED;
-  ALOGD("%s: NFA_EE_MAX_EE_SUPPORTED to use %d", func, nfa_ee_max_ee_cfg);
-
   if (GetNumValue(NAME_NFA_POLL_BAIL_OUT_MODE, &num, sizeof(num))) {
     nfa_poll_bail_out_mode = num;
     ALOGD("%s: Overriding NFA_POLL_BAIL_OUT_MODE to use %d", func,
diff --git a/src/gki/common/gki_buffer.c b/src/gki/common/gki_buffer.c
index 09f49e0..a99c352 100644
--- a/src/gki/common/gki_buffer.c
+++ b/src/gki/common/gki_buffer.c
@@ -651,9 +651,15 @@
 uint16_t GKI_get_buf_size(void* p_buf) {
   BUFFER_HDR_T* p_hdr;
 
+
   p_hdr = (BUFFER_HDR_T*)((uint8_t*)p_buf - BUFFER_HDR_SIZE);
 
-  if ((uint32_t)p_hdr & 1) return (0);
+  if ((uint32_t)p_hdr & 1){
+#if (GKI_BUFFER_DEBUG ==  true)
+    LOGD("GKI_get_buf_size() Found odd address p_hdr = 0x%x !!!!!",p_hdr);
+#endif
+    return (0);
+  }
 
   if (p_hdr->q_id < GKI_NUM_TOTAL_BUF_POOLS) {
     return (gki_cb.com.freeq[p_hdr->q_id].size);
@@ -677,7 +683,12 @@
   uint32_t* magic;
   magic = (uint32_t*)((uint8_t*)p_buf + GKI_get_buf_size(p_buf));
 
-  if ((uint32_t)magic & 1) return (true);
+  if ((uint32_t)magic & 1){
+#if (GKI_BUFFER_DEBUG == true)
+    LOGD("gki_chk_buf_damage() buffer corrupted !!!!! magic = 0x%x !!!!!",magic);
+#endif
+    return (true);
+  }
 
   if (*magic == MAGIC_NO) return (false);
 
diff --git a/src/gki/common/gki_time.c b/src/gki/common/gki_time.c
index f941354..85d68c2 100644
--- a/src/gki/common/gki_time.c
+++ b/src/gki/common/gki_time.c
@@ -186,6 +186,11 @@
   int32_t reload;
   int32_t orig_ticks;
   uint8_t task_id = GKI_get_taskid();
+
+  /*if task_id doesnt found in the array, use default task id 14*/
+  if(task_id == 255) {
+    task_id = 14;
+  }
   bool bad_timer = false;
 
   if (ticks <= 0) ticks = 1;
@@ -285,6 +290,10 @@
 void GKI_stop_timer(uint8_t tnum) {
   uint8_t task_id = GKI_get_taskid();
 
+    /*if task_id doesnt found in the array, use default task id 14*/
+  if(task_id == 255) {
+    task_id = 14;
+  }
   GKI_disable();
 
   switch (tnum) {
diff --git a/src/include/gki_target.h b/src/include/gki_target.h
index 1740ebd..23017fe 100644
--- a/src/include/gki_target.h
+++ b/src/include/gki_target.h
@@ -118,7 +118,7 @@
 
 /* The number of GKI tasks in the software system. */
 #ifndef GKI_MAX_TASKS
-#define GKI_MAX_TASKS 14
+#define GKI_MAX_TASKS 15
 #endif
 
 /******************************************************************************
diff --git a/src/nfa/ce/nfa_ce_act.c b/src/nfa/ce/nfa_ce_act.c
index 8b9c563..7735e33 100644
--- a/src/nfa/ce/nfa_ce_act.c
+++ b/src/nfa/ce/nfa_ce_act.c
@@ -1211,7 +1211,8 @@
                ) &&
           (i == p_cb->idx_cur_active)) {
         conn_evt.deactivated.type = deact_type;
-        (*p_cb->p_active_conn_cback)(NFA_DEACTIVATED_EVT, &conn_evt);
+      if (p_cb->p_active_conn_cback)
+          (*p_cb->p_active_conn_cback)(NFA_DEACTIVATED_EVT, &conn_evt);
       } else if ((p_cb->activation_params.protocol == NFA_PROTOCOL_ISO_DEP) &&
                  (p_cb->listen_info[i].protocol_mask &
                   NFA_PROTOCOL_MASK_ISO_DEP)) {
@@ -1220,12 +1221,14 @@
               NFA_CE_LISTEN_INFO_T4T_ACTIVATE_PND)) {
           if (i == NFA_CE_LISTEN_INFO_IDX_NDEF) {
             conn_evt.deactivated.type = deact_type;
-            (*p_cb->p_active_conn_cback)(NFA_DEACTIVATED_EVT, &conn_evt);
+            if (p_cb->p_active_conn_cback)
+                (*p_cb->p_active_conn_cback)(NFA_DEACTIVATED_EVT, &conn_evt);
           } else {
             conn_evt.ce_deactivated.handle =
                 NFA_HANDLE_GROUP_CE | ((tNFA_HANDLE)i);
             conn_evt.ce_deactivated.type = deact_type;
-            (*p_cb->p_active_conn_cback)(NFA_CE_DEACTIVATED_EVT, &conn_evt);
+            if (p_cb->p_active_conn_cback)
+                (*p_cb->p_active_conn_cback)(NFA_CE_DEACTIVATED_EVT, &conn_evt);
           }
         }
       } else if ((p_cb->activation_params.protocol == NFA_PROTOCOL_T3T) &&
@@ -1237,12 +1240,14 @@
 #endif
           if (i == NFA_CE_LISTEN_INFO_IDX_NDEF) {
             conn_evt.deactivated.type = deact_type;
-            (*p_cb->p_active_conn_cback)(NFA_DEACTIVATED_EVT, &conn_evt);
+            if (p_cb->p_active_conn_cback)
+                (*p_cb->p_active_conn_cback)(NFA_DEACTIVATED_EVT, &conn_evt);
           } else {
             conn_evt.ce_deactivated.handle =
                 NFA_HANDLE_GROUP_CE | ((tNFA_HANDLE)i);
             conn_evt.ce_deactivated.type = deact_type;
-            (*p_cb->p_active_conn_cback)(NFA_CE_DEACTIVATED_EVT, &conn_evt);
+            if (p_cb->p_active_conn_cback)
+                (*p_cb->p_active_conn_cback)(NFA_CE_DEACTIVATED_EVT, &conn_evt);
           }
 #if (NXP_EXTNS == TRUE)
         }
diff --git a/src/nfa/dm/nfa_dm_act.c b/src/nfa/dm/nfa_dm_act.c
index f49cd30..34ff680 100644
--- a/src/nfa/dm/nfa_dm_act.c
+++ b/src/nfa/dm/nfa_dm_act.c
@@ -422,9 +422,6 @@
     case NFC_NFCEE_MODE_SET_REVT: /* NFCEE Mode Set response */
 #if (NXP_EXTNS == TRUE)
     case NFC_NFCEE_PWR_LNK_CTRL_REVT:
-        if(!nfcFL.eseFL._WIRED_MODE_STANDBY) {
-            break;
-        }
     case NFC_NFCEE_MODE_SET_INFO:
 #endif
     case NFC_NFCEE_STATUS_REVT:
diff --git a/src/nfa/dm/nfa_dm_api.c b/src/nfa/dm/nfa_dm_api.c
index e7ab5e9..5fd8993 100644
--- a/src/nfa/dm/nfa_dm_api.c
+++ b/src/nfa/dm/nfa_dm_api.c
@@ -102,7 +102,6 @@
 #else
   NFC_Init(p_hal_entry_tbl);
 #endif
-  nfa_ee_max_ee_cfg == nfcFL.nfccFL._NFA_EE_MAX_EE_SUPPORTED;
 }
 
 /*******************************************************************************
@@ -1042,14 +1041,20 @@
   NFA_TRACE_API1("NFA_SendRawFrame () data_len:%d", data_len);
 
 /* Validate parameters */
-  if ((nfcFL.nfccFL._NXP_NFCC_EMPTY_DATA_PACKET &&
-          (((data_len == 0) || (p_raw_data == NULL)) &&
-                  (!(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE &&
-                          nfa_dm_cb.disc_cb.activated_protocol ==
-                                  NFA_PROTOCOL_T3T)))) ||
-          ((data_len == 0) || (p_raw_data == NULL))) {
+  if (nfcFL.nfccFL._NXP_NFCC_EMPTY_DATA_PACKET) {
+      if(((data_len == 0) || (p_raw_data == NULL)) &&
+              (!(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE &&
+                      nfa_dm_cb.disc_cb.activated_protocol ==
+                              NFA_PROTOCOL_T3T))){
+          return (NFA_STATUS_INVALID_PARAM);
+      } else {
+          //Do Nothing.
+      }
+  }else if((data_len == 0) || (p_raw_data == NULL)) {
       return (NFA_STATUS_INVALID_PARAM);
   }
+
+
   size = NFC_HDR_SIZE + NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE + data_len;
   p_msg = (NFC_HDR*)GKI_getbuf(size);
   if (p_msg != NULL) {
diff --git a/src/nfa/dm/nfa_dm_cfg.c b/src/nfa/dm/nfa_dm_cfg.c
index 2101855..a6ae8db 100644
--- a/src/nfa/dm/nfa_dm_cfg.c
+++ b/src/nfa/dm/nfa_dm_cfg.c
@@ -59,7 +59,6 @@
     (tNFA_DM_DISC_FREQ_CFG*)&nfa_dm_rf_disc_freq_cfg;
 
 uint8_t nfa_ee_max_ee_cfg = NFA_EE_MAX_EE_SUPPORTED;
-
 const tNCI_DISCOVER_MAPS nfa_dm_interface_mapping[NFA_DM_NUM_INTERFACE_MAP] = {
     /* Protocols that use Frame Interface do not need to be included in the
        interface mapping */
@@ -113,7 +112,7 @@
 #else
     0x83, /* NCI_PROTOCOL_15693 */
 #endif
-#if (NXP_EXTNS == TRUE && NFC_NXP_CHIP_TYPE != PN547C2)
+#if (NXP_EXTNS == TRUE)
     0x81,
 #else
     0x8A, /* NCI_PROTOCOL_KOVIO */
@@ -123,7 +122,7 @@
 #else
     0xFF, /* NCI_PROTOCOL_MIFARE */
 #endif
-#if (NXP_EXTNS == TRUE && NFC_NXP_CHIP_TYPE != PN547C2)
+#if (NXP_EXTNS == TRUE)
     0x70,
 #else
     0x77, /* NCI_DISCOVERY_TYPE_POLL_KOVIO */
diff --git a/src/nfa/dm/nfa_dm_discover.c b/src/nfa/dm/nfa_dm_discover.c
index 13593eb..b2d4030 100644
--- a/src/nfa/dm/nfa_dm_discover.c
+++ b/src/nfa/dm/nfa_dm_discover.c
@@ -101,7 +101,7 @@
 
 static void nfa_dm_send_tag_deselect_cmd(tNFA_NFC_PROTOCOL protocol);
 #define TAG_DESELECT_CMD 0xC2
-uint8_t T2T_SLP_REQ[] ={0x05,0x00};
+uint8_t T2T_SLP_REQ[] ={0x50,0x00};
 
 int getListenTechValue(int listenTechMask);
 #define P2P_RESUME_POLL_TIMEOUT 16 /*mili second timeout value*/
diff --git a/src/nfa/ee/nfa_ee_act.c b/src/nfa/ee/nfa_ee_act.c
index 2b46d69..6ebe4f6 100644
--- a/src/nfa/ee/nfa_ee_act.c
+++ b/src/nfa/ee/nfa_ee_act.c
@@ -804,6 +804,102 @@
 
 /*******************************************************************************
 **
+** Function         nfa_ee_get_num_nfcee_configured
+**
+** Description      Get the number of NFCEE configured
+**
+** Returns          void
+**
+*******************************************************************************/
+tNFA_STATUS nfa_ee_get_num_nfcee_configured(tNFA_VSC_CBACK* p_cback)
+{
+  tNFA_STATUS status = NFA_STATUS_OK;
+  uint8_t p_data[255];
+  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);
+  parm_len = p++;
+  num_param = p++;
+  UINT8_TO_STREAM(p, NXP_NFC_SET_CONFIG_PARAM_EXT);
+  UINT8_TO_STREAM(p, NXP_NFC_PARAM_ID_SWP1);
+  (*num_param)++;
+  UINT8_TO_STREAM(p, NXP_NFC_SET_CONFIG_PARAM_EXT);
+  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)++;
+  }
+
+  *parm_len = (p - num_param);
+  if (*num_param != 0x00) {
+    status = NFA_SendNxpNciCommand(p - p_data, p_data, p_cback);
+  } else {
+      status = NFA_STATUS_FAILED;
+  }
+  NFA_TRACE_DEBUG1("nfa_ee_get_num_nfcee_configured %x", *num_param);
+
+  return status;
+}
+
+/*******************************************************************************
+**
+** Function         nfa_hci_read_num_nfcee_config_cb
+**
+** Description      Callback function to handle the response of num of NFCEE
+*                   configured.
+**
+** Returns          None
+**
+*********************************************************************************/
+ void nfa_ee_read_num_nfcee_config_cb(uint8_t event, uint16_t param_len,
+                                             uint8_t* p_param) {
+    uint8_t num_param_id = 0x00, xx;
+    uint8_t configured_num_nfcee = 0x00;
+    uint8_t NFA_PARAM_ID_INDEX = 0x04;
+    uint8_t param_id1 = 0x00;
+    uint8_t param_id2 = 0x00;
+    uint8_t status = 0x00;
+
+    if (param_len == 0x00 || p_param == NULL ||
+        p_param[NFA_PARAM_ID_INDEX - 1] != NFA_STATUS_OK) {
+      return;
+    }
+    if(NFA_GetNCIVersion() != NCI_VERSION_2_0) { //HCI_NETWORK_ACCESS
+        configured_num_nfcee = 1;
+    }
+    p_param += NFA_PARAM_ID_INDEX;
+    STREAM_TO_UINT8(num_param_id, p_param);
+
+    while (num_param_id > 0x00) {
+      STREAM_TO_UINT8(param_id1, p_param);
+      STREAM_TO_UINT8(param_id2, p_param);
+      p_param++;
+      STREAM_TO_UINT8(status, p_param);
+      if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
+          param_id2 == NXP_NFC_PARAM_ID_SWP1 && status != 0x00)
+        configured_num_nfcee++;
+      else if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
+               param_id2 == NXP_NFC_PARAM_ID_SWP2 && status != 0x00)
+        configured_num_nfcee++;
+      else if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
+               param_id2 == NXP_NFC_PARAM_ID_SWP1A && status != 0x00)
+        configured_num_nfcee++;
+      else if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
+               param_id2 == NXP_NFC_PARAM_ID_NDEF_NFCEE && status != 0x00)
+        configured_num_nfcee++;
+      num_param_id--;
+    }
+    if(configured_num_nfcee)
+        nfa_ee_max_ee_cfg = configured_num_nfcee;
+    NFA_TRACE_DEBUG1("nfa_ee_read_num_nfcee_config_cb %x", configured_num_nfcee);
+}
+
+/******************************************************************************
+**
 ** Function         nfa_ee_api_discover
 **
 ** Description      process discover command from user
@@ -827,6 +923,7 @@
         return;
     }
   }
+  nfa_ee_get_num_nfcee_configured(nfa_ee_read_num_nfcee_config_cb);
   if (nfa_ee_cb.p_ee_disc_cback == NULL &&
       NFC_NfceeDiscover(true) == NFC_STATUS_OK) {
     nfa_ee_cb.p_ee_disc_cback = p_cback;
@@ -1800,7 +1897,8 @@
   if (p_cb->conn_st == NFA_EE_CONN_ST_NONE) {
     for (xx = 0; xx < p_cb->num_interface; xx++) {
       if (p_data->connect.ee_interface == p_cb->ee_interface[xx]) {
-        p_cb->p_ee_cback = p_data->connect.p_cback;
+          nfa_ee_get_num_nfcee_configured(nfa_ee_read_num_nfcee_config_cb);
+          p_cb->p_ee_cback = p_data->connect.p_cback;
         p_cb->conn_st = NFA_EE_CONN_ST_WAIT;
         p_cb->use_interface = p_data->connect.ee_interface;
         evt_data.connect.status =
@@ -2059,7 +2157,6 @@
             p_cb->nfcee_id = NFA_EE_INVALID;
           }
         }
-        nfa_ee_cb.cur_ee = num_nfcee;
       }
       break;
 
@@ -2249,9 +2346,11 @@
     if (nfa_ee_cb.discv_timer.in_use) {
       nfa_sys_stop_timer(&nfa_ee_cb.discv_timer);
       p_data->hdr.event = NFA_EE_DISCV_TIMEOUT_EVT;
+      NFA_TRACE_DEBUG0("ee_disc_timeout");
       nfa_ee_evt_hdlr((NFC_HDR*)p_data);
     }
   }
+  NFA_TRACE_DEBUG0("after nfa_ee_nci_disc_ntf");
 #if (NXP_EXTNS == TRUE)
   if (p_cb) {
     if ((nfa_hci_cb.hci_state == NFA_HCI_STATE_WAIT_NETWK_ENABLE) &&
@@ -2264,6 +2363,7 @@
     }
   }
 #endif
+  NFA_TRACE_DEBUG0("nfa_ee_nci_disc_ntf last");
 }
 
 /*******************************************************************************
@@ -2277,11 +2377,12 @@
 *******************************************************************************/
 void nfa_ee_nci_nfcee_status_ntf(tNFA_EE_MSG* p_data) {
   tNFC_NFCEE_STATUS_REVT* p_ee = p_data->nfcee_status_ntf.p_data;
+
   NFA_TRACE_DEBUG3(
       "nfa_ee_nci_nfcee_status_ntf() em_state:%d, nfcee_id:%d nfcee_status:%d",
-      nfa_ee_cb.em_state, p_ee->nfcee_id, p_ee->status);
+      nfa_ee_cb.em_state, p_ee->nfcee_id, p_ee->nfcee_status);
   tNFA_EE_ECB* p_cb = nfa_ee_find_ecb(p_ee->nfcee_id);
-  if(p_ee->status == NFC_NFCEE_STS_UNRECOVERABLE_ERROR) {
+  if(p_ee->nfcee_status == NFC_NFCEE_STS_UNRECOVERABLE_ERROR) {
     if(p_cb != NULL) {
         if (nfa_ee_cb.p_enable_cback)
                     (*nfa_ee_cb.p_enable_cback) (NFA_EE_RECOVERY);
diff --git a/src/nfa/ee/nfa_ee_main.c b/src/nfa/ee/nfa_ee_main.c
index da58a54..adcd6b2 100644
--- a/src/nfa/ee/nfa_ee_main.c
+++ b/src/nfa/ee/nfa_ee_main.c
@@ -163,7 +163,7 @@
                        nfa_ee_cb.route_block_control);
     }
   }
-
+  nfa_ee_get_num_nfcee_configured(nfa_ee_read_num_nfcee_config_cb);
   if (nfa_ee_max_ee_cfg) {
     /* collect NFCEE information */
     NFC_NfceeDiscover(true);
diff --git a/src/nfa/hci/nfa_hci_act.c b/src/nfa/hci/nfa_hci_act.c
index 6718a1d..8dc672a 100644
--- a/src/nfa/hci/nfa_hci_act.c
+++ b/src/nfa/hci/nfa_hci_act.c
@@ -2524,131 +2524,35 @@
 **
 ** Function         nfa_hci_get_num_nfcee_configured
 **
-** Description      Read the number of NFCEE configured by the user.
+** Description      Read number of NFCEE config.
 **
-** Returns          if success NFA_STATUS_OK or NFA_STATUS_FAILED
-**
-*********************************************************************************/
-static tNFA_STATUS nfa_hci_get_num_nfcee_configured() {
-  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);
-  parm_len = p++;
-  num_param = p++;
-  UINT8_TO_STREAM(p, NXP_NFC_SET_CONFIG_PARAM_EXT);
-  UINT8_TO_STREAM(p, NXP_NFC_PARAM_ID_SWP1);
-  (*num_param)++;
-  UINT8_TO_STREAM(p, NXP_NFC_SET_CONFIG_PARAM_EXT);
-  UINT8_TO_STREAM(p, NXP_NFC_PARAM_ID_SWP2);
-  (*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) {
-    status = nfa_hciu_send_raw_cmd(p - p_data, p_data,
-                                   nfa_hci_read_num_nfcee_config_cb);
-  }
-  NFA_TRACE_DEBUG1("nfa_hci_get_num_nfcee_configured %x", *num_param);
-
-  return status;
-}
-
-/*******************************************************************************
-**
-** Function         nfa_hci_read_num_nfcee_config_cb
-**
-** Description      Callback function to handle the response of num of NFCEE
-*configured cmd.
 **
 ** Returns          None
 **
 *********************************************************************************/
-static void nfa_hci_read_num_nfcee_config_cb(uint8_t event, uint16_t param_len,
-                                             uint8_t* p_param) {
+static tNFA_STATUS nfa_hci_get_num_nfcee_configured() {
   uint8_t num_param_id = 0x00, xx;
-  uint8_t configured_num_nfcee = 0x00;
-  uint8_t NFA_PARAM_ID_INDEX = 0x04;
-  uint8_t param_id1 = 0x00;
-  uint8_t param_id2 = 0x00;
-  uint8_t status = 0x00;
-
+  tNFA_STATUS status = NFA_STATUS_OK;
   nfa_sys_stop_timer(&nfa_hci_cb.timer);
   nfa_hci_cb.num_nfcee = NFA_HCI_MAX_HOST_IN_NETWORK;
   NFA_AllEeGetInfo(&nfa_hci_cb.num_nfcee, nfa_hci_cb.hci_ee_info);
-
   for (xx = 0; xx < nfa_hci_cb.num_nfcee; xx++) {
-    if(nfa_hci_cb.hci_ee_info[xx].ee_interface[0] ==
-            NCI_NFCEE_INTERFACE_HCI_ACCESS)
-    {
-      /*If NFCEE_HCI_NETWORK ID exists*/
-      configured_num_nfcee = 1;
-      break;
+    if ((((nfa_hci_cb.hci_ee_info[xx].ee_interface[0] !=
+        NCI_NFCEE_INTERFACE_HCI_ACCESS) &&
+        nfa_hci_cb.hci_ee_info[xx].ee_status == NFA_EE_STATUS_ACTIVE)) &&
+        (nfa_hci_cb.hci_ee_info[xx].ee_handle != 0x410)) {
+      nfa_hci_cb.nfcee_cfg.host_cb[num_param_id++] =
+          nfa_hci_cb.hci_ee_info[xx].ee_handle;
     }
   }
-
-  if (param_len == 0x00 || p_param == NULL ||
-      p_param[NFA_PARAM_ID_INDEX - 1] != NFA_STATUS_OK) {
-    for (xx = 0; xx < nfa_hci_cb.num_nfcee; xx++) {
-      if ((((nfa_hci_cb.hci_ee_info[xx].ee_interface[0] !=
-           NCI_NFCEE_INTERFACE_HCI_ACCESS) &&
-	          nfa_hci_cb.hci_ee_info[xx].ee_status == NFA_EE_STATUS_ACTIVE))  &&
-          (nfa_hci_cb.hci_ee_info[xx].ee_handle != 0x410)) {
-        nfa_hci_cb.nfcee_cfg.host_cb[num_param_id++] =
-            nfa_hci_cb.hci_ee_info[xx].ee_handle;
-      }
-    }
-    nfa_hci_handle_nfcee_config_evt(NFA_HCI_READ_SESSIONID);
-    return;
-  }
-  p_param += NFA_PARAM_ID_INDEX;
-  STREAM_TO_UINT8(num_param_id, p_param);
-
-  while (num_param_id > 0x00) {
-    STREAM_TO_UINT8(param_id1, p_param);
-    STREAM_TO_UINT8(param_id2, p_param);
-    p_param++;
-    STREAM_TO_UINT8(status, p_param);
-    if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
-        param_id2 == NXP_NFC_PARAM_ID_SWP1 && status != 0x00)
-      configured_num_nfcee++;
-    else if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
-             param_id2 == NXP_NFC_PARAM_ID_SWP2 && status != 0x00)
-      configured_num_nfcee++;
-    else if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
-             param_id2 == NXP_NFC_PARAM_ID_SWP1A && status != 0x00)
-      configured_num_nfcee++;
-    else if (param_id1 == NXP_NFC_SET_CONFIG_PARAM_EXT &&
-             param_id2 == NXP_NFC_PARAM_ID_NDEF_NFCEE && status != 0x00)
-      configured_num_nfcee++;
-    num_param_id--;
-  }
-  NFA_TRACE_DEBUG1("nfa_hci_read_num_nfcee_config_cb %x", configured_num_nfcee);
-  NFA_TRACE_DEBUG1("nfa_hci_read_num_nfcee_config_cb %x", nfa_hci_cb.num_nfcee);
-  if (configured_num_nfcee > nfa_hci_cb.num_nfcee)
+  NFA_TRACE_DEBUG1("nfa_hci_read_num_nfcee_config_cb  nfa_ee_max_ee_cfg%x", nfa_ee_max_ee_cfg);
+  NFA_TRACE_DEBUG1("nfa_hci_read_num_nfcee_config_cb nfa_hci_cb.num_nfcee%x", nfa_hci_cb.num_nfcee);
+  if (nfa_ee_max_ee_cfg > nfa_hci_cb.num_nfcee) {
     nfa_sys_start_timer(&nfa_hci_cb.timer, NFA_HCI_NFCEE_DISCOVER_TIMEOUT_EVT,
                         nfa_hci_cb.max_nfcee_disc_timeout);
-  else {
-    num_param_id = 0x00;
-    for (xx = 0; xx < nfa_hci_cb.num_nfcee; xx++) {
-      if ((((nfa_hci_cb.hci_ee_info[xx].ee_interface[0] !=
-          NCI_NFCEE_INTERFACE_HCI_ACCESS) &&
-          nfa_hci_cb.hci_ee_info[xx].ee_status == NFA_EE_STATUS_ACTIVE)) &&
-          (nfa_hci_cb.hci_ee_info[xx].ee_handle != 0x410)) {
-        nfa_hci_cb.nfcee_cfg.host_cb[num_param_id++] =
-            nfa_hci_cb.hci_ee_info[xx].ee_handle;
-      }
-    }
-    nfa_hci_handle_nfcee_config_evt(NFA_HCI_READ_SESSIONID);
+    status = NFA_STATUS_BUSY;
   }
+  return status;
 }
 
 /*******************************************************************************
@@ -2776,7 +2680,7 @@
 ** Function         nfa_hci_handle_nfcee_config_evt
 **
 ** Description      In case of NFCEE CONFIG EVT , the following sequence of
-*commands are sent.
+** commands are sent.
 **                  This function also handles the CLEAR_ALL_PIPE_NTF from
 *respective host.
 **                      a.Get the number of secelement configured and
@@ -2805,16 +2709,12 @@
         nfa_hci_cb.hci_state = NFA_HCI_STATE_NFCEE_ENABLE;
         nfa_hci_cb.nfcee_cfg.config_nfcee_state =
             NFA_HCI_GET_NUM_NFCEE_CONFIGURED;
-        if (nfa_hci_get_num_nfcee_configured() != NFA_STATUS_OK) {
+        if (nfa_hci_get_num_nfcee_configured() != NFA_STATUS_BUSY) {
           tNFA_HCI_API_CONFIGURE_EVT* p_msg;
           /* Send read session event to continue with other initialization*/
-          if ((p_msg = (tNFA_HCI_API_CONFIGURE_EVT*)GKI_getbuf(
-                   sizeof(tNFA_HCI_API_CONFIGURE_EVT))) != NULL) {
-            p_msg->hdr.event = NFA_HCI_API_CONFIGURE_EVT;
-            p_msg->config_nfcee_event = NFA_HCI_READ_SESSIONID;
-            nfa_sys_sendmsg(p_msg);
-          } else
-            event = NFA_HCI_NFCEE_CONFIG_COMPLETE;
+          /*Read the session ID of the host discovered */
+          nfa_hci_cb.nfcee_cfg.config_nfcee_state = NFA_HCI_READ_SESSIONID;
+          nfa_hci_poll_all_nfcee_session_id();
         }
       } else {
         event = NFA_HCI_NFCEE_CONFIG_COMPLETE;
diff --git a/src/nfa/hci/nfa_hci_main.c b/src/nfa/hci/nfa_hci_main.c
index 56399fd..35debff 100644
--- a/src/nfa/hci/nfa_hci_main.c
+++ b/src/nfa/hci/nfa_hci_main.c
@@ -243,18 +243,28 @@
           NFA_EeGetInfo(&nfa_hci_cb.num_nfcee, nfa_hci_cb.ee_info);
           nfa_hci_enable_one_nfcee();
         }
-        else if(nfa_hci_cb.hci_state == NFA_HCI_STATE_NFCEE_ENABLE)
+        else if((nfa_hci_cb.hci_state == NFA_HCI_STATE_NFCEE_ENABLE) &&
+          (nfa_hci_cb.nfcee_cfg.config_nfcee_state == NFA_HCI_INIT_NFCEE_CONFIG))
         {
             nfa_hci_api_config_nfcee(nfa_hci_cb.current_nfcee);
         }
       break;
     case NFA_EE_RECOVERY:
         /*NFCEE recovery in progress*/
-        if (!((nfa_hci_cb.hci_state == NFA_HCI_STATE_WAIT_NETWK_ENABLE) ||
+        if(nfa_hci_cb.hci_state == NFA_HCI_STATE_EE_RECOVERY) {
+            NFA_TRACE_DEBUG1("nfa_hci_ee_info_cback (): %d nfa_hci_cb.hci_state already in EE Recovery", nfa_hci_cb.hci_state);
+        }
+        else if (!((nfa_hci_cb.hci_state == NFA_HCI_STATE_WAIT_NETWK_ENABLE) ||
             (nfa_hci_cb.hci_state == NFA_HCI_STATE_RESTORE_NETWK_ENABLE))) {
           if (NFA_DM_RFST_DISCOVERY == nfa_dm_cb.disc_cb.disc_state)
             nfa_hci_cb.nfcee_cfg.discovery_stopped = nfa_dm_act_stop_rf_discovery(NULL);
+          tNFA_HCI_EVT_DATA evt_data;
+          evt_data.ee_recovery.status = NFA_HCI_EE_RECOVERY_STARTED;
+          nfa_hciu_send_to_all_apps(NFA_HCI_EE_RECOVERY_EVT, &evt_data);
+          nfa_hci_release_transcieve();
           if(NFC_NfceeDiscover(true) == NFC_STATUS_FAILED){
+              evt_data.ee_recovery.status = NFA_HCI_EE_RECOVERY_COMPLETED;
+              nfa_hciu_send_to_all_apps(NFA_HCI_EE_RECOVERY_EVT, &evt_data);
             if(nfa_hci_cb.nfcee_cfg.discovery_stopped == true) {
               nfa_dm_act_start_rf_discovery(NULL);
               nfa_hci_cb.nfcee_cfg.discovery_stopped = false;
@@ -773,10 +783,12 @@
           nfa_hci_cb.nfcee_cfg.discovery_stopped = false;
           nfa_dm_act_start_rf_discovery(NULL);
         }
+        tNFA_HCI_EVT_DATA evt_data;
+        evt_data.ee_recovery.status = NFA_HCI_EE_RECOVERY_COMPLETED;
+        nfa_hciu_send_to_all_apps(NFA_HCI_EE_RECOVERY_EVT, &evt_data);
     }
   }
 }
-
 /*******************************************************************************
 **
 ** Function         nfa_hci_startup
@@ -794,8 +806,6 @@
   uint8_t count = 0;
   bool found = false;
 
-  nfa_ee_max_ee_cfg = nfcFL.nfccFL._NFA_EE_MAX_EE_SUPPORTED;
-
   if (HCI_LOOPBACK_DEBUG) {
       /* First step in initialization is to open the admin pipe */
       nfa_hciu_send_open_pipe_cmd(NFA_HCI_ADMIN_PIPE);
@@ -911,6 +921,8 @@
 *******************************************************************************/
 static void nfa_hci_sys_disable(void) {
   tNFA_HCI_EVT_DATA evt_data;
+  tNFC_CONN_EVT event;
+  tNFC_CONN cData;
 
   nfa_sys_stop_timer(&nfa_hci_cb.timer);
 
@@ -921,6 +933,16 @@
         nfa_hciu_send_to_all_apps(NFA_HCI_EXIT_EVT, &evt_data);
         NFC_ConnClose(nfa_hci_cb.conn_id);
       }
+      else
+      {
+        /* HCI module deregister should be triggered to sto the nfa_sys_main timer,
+        so faking a connection close event */
+        NFA_TRACE_ERROR0("Fake NFC_CONN_CLOSE_CEVT triggered");
+        cData.data.status = NFA_STATUS_OK;
+        cData.data.p_data = NULL;
+        event = NFC_CONN_CLOSE_CEVT;
+        nfa_hci_conn_cback(nfa_hci_cb.conn_id, event, &cData);
+      }
       return;
     }
     nfa_hci_cb.conn_id = 0;
diff --git a/src/nfa/include/nfa_api.h b/src/nfa/include/nfa_api.h
index e2f23f2..6c4b272 100644
--- a/src/nfa/include/nfa_api.h
+++ b/src/nfa/include/nfa_api.h
@@ -294,7 +294,7 @@
 typedef struct {
   tNFA_STATUS status;    /* NFA_STATUS_OK if successful              */
   uint16_t tlv_size;     /* The length of TLV                        */
-  uint8_t param_tlvs[1]; /* TLV (Parameter ID-Len-Value byte stream) */
+  uint8_t param_tlvs[74]; /* TLV (Parameter ID-Len-Value byte stream) */
 } tNFA_GET_CONFIG;
 
 #if (NXP_EXTNS == TRUE)
diff --git a/src/nfa/include/nfa_hci_api.h b/src/nfa/include/nfa_hci_api.h
index c7ec22b..f909b5b 100644
--- a/src/nfa/include/nfa_hci_api.h
+++ b/src/nfa/include/nfa_hci_api.h
@@ -110,6 +110,7 @@
 #define NFA_HCI_HOST_TYPE_LIST_READ_EVT 0x17
 #define NFA_HCI_CONFIG_DONE_EVT \
   0x18 /* Configure NFCEE                              */
+#define NFA_HCI_EE_RECOVERY_EVT 0x19
 #endif
 typedef uint8_t tNFA_HCI_EVT;
 
@@ -138,6 +139,10 @@
 #define NFA_HCI_PIPE_CLOSED 0x00 /* Pipe is closed */
 #define NFA_HCI_PIPE_OPENED 0x01 /* Pipe is opened */
 
+ /* HCI Recovery status*/
+ #define NFA_HCI_EE_RECOVERY_STARTED 0x01
+ #define NFA_HCI_EE_RECOVERY_COMPLETED 0x02
+
 typedef uint8_t tNFA_HCI_PIPE_STATE;
 /* Dynamic pipe control block */
 typedef struct {
@@ -312,6 +317,11 @@
   tNFA_STATUS status; /* Status for ETSI12 config for NFCEE*/
 } tNFA_HCI_CONFIG_RSP_RCVD;
 #endif
+typedef struct {
+  tNFA_STATUS status;     /* Status of command on Admin pipe */
+  uint8_t host;
+} tNFA_HCI_EE_RECOVERY_EVT;
+/* Data for tNFA_HCI_CONFIG_RSP_RCVD */
 /* Union of all hci callback structures */
 typedef union {
   tNFA_HCI_REGISTER hci_register;          /* NFA_HCI_REGISTER_EVT           */
@@ -342,6 +352,7 @@
 #if (NXP_EXTNS == TRUE)
   tNFA_HCI_ADMIN_RSP_RCVD admin_rsp_rcvd;   /* NFA_HCI_ADMIN_RSP_RCVD         */
   tNFA_HCI_CONFIG_RSP_RCVD config_rsp_rcvd; /* NFA_HCI_CONFIG_RSP_RCVD       */
+  tNFA_HCI_EE_RECOVERY_EVT ee_recovery;
 #endif
 } tNFA_HCI_EVT_DATA;
 
diff --git a/src/nfa/int/nfa_ee_int.h b/src/nfa/int/nfa_ee_int.h
index 547dd7a..967a75f 100644
--- a/src/nfa/int/nfa_ee_int.h
+++ b/src/nfa/int/nfa_ee_int.h
@@ -719,6 +719,9 @@
 void nfa_ee_nci_disc_rsp(tNFA_EE_MSG* p_data);
 void nfa_ee_nci_disc_ntf(tNFA_EE_MSG* p_data);
 void nfa_ee_nci_mode_set_rsp(tNFA_EE_MSG* p_data);
+tNFA_STATUS nfa_ee_get_num_nfcee_configured(tNFA_VSC_CBACK* p_cback);
+ void nfa_ee_read_num_nfcee_config_cb(uint8_t event, uint16_t param_len,
+         uint8_t* p_param);
 #if (NXP_EXTNS == TRUE)
 extern void nfa_hci_conn_cback(uint8_t conn_id, tNFC_CONN_EVT event,
                                tNFC_CONN* p_data);
diff --git a/src/nfa/rw/nfa_rw_act.c b/src/nfa/rw/nfa_rw_act.c
index 2f34910..afad221 100644
--- a/src/nfa/rw/nfa_rw_act.c
+++ b/src/nfa/rw/nfa_rw_act.c
@@ -2618,10 +2618,12 @@
            NFA_T1T_HR_LEN);
     memcpy(tag_params.t1t.uid, p_activate_params->rf_tech_param.param.pa.nfcid1,
            p_activate_params->rf_tech_param.param.pa.nfcid1_len);
+    if(NFC_GetNCIVersion() == NCI_VERSION_1_0) {
     msg.op = NFA_RW_OP_T1T_RID;
     nfa_rw_handle_op_req((void*)&msg);
     activate_notify = false; /* Delay notifying upper layer of NFA_ACTIVATED_EVT
                                 until HR0/HR1 is received */
+   }
   } else if (NFC_PROTOCOL_T2T == nfa_rw_cb.protocol) {
     /* Retrieve UID fields from activation notification */
     memcpy(tag_params.t2t.uid, p_activate_params->rf_tech_param.param.pa.nfcid1,
diff --git a/src/nfc/include/nfc_api.h b/src/nfc/include/nfc_api.h
index 40935a8..92eeeaa 100644
--- a/src/nfc/include/nfc_api.h
+++ b/src/nfc/include/nfc_api.h
@@ -106,19 +106,19 @@
 // DTA API for MW Version need to change according to release
 #define NXP_EN_PN547C2 0
 #define NXP_EN_PN65T 0
-#define NXP_EN_PN548C2 0
-#define NXP_EN_PN66T 0
-#define NXP_EN_PN551 0
-#define NXP_EN_PN67T 0
-#define NXP_EN_PN553 1
-#define NXP_EN_PN80T 1
+#define NXP_EN_PN548C2 1
+#define NXP_EN_PN66T 1
+#define NXP_EN_PN551 1
+#define NXP_EN_PN67T 1
+#define NXP_EN_PN553 0
+#define NXP_EN_PN80T 0
 #define NXP_EN_PN553_MR1 0
 #define NXP_EN_PN81A     0
 #define NXP_EN_PN553_MR2 0
 #define NXP_EN_PN557     0
 #define NXP_EN_PN81T     0
 #define NXP_ANDROID_VER (8U)        /* NXP android version */
-#define NFC_NXP_MW_VERSION_MAJ (0x01) /* MW Major Version */
+#define NFC_NXP_MW_VERSION_MAJ (0x03) /* MW Major Version */
 #define NFC_NXP_MW_VERSION_MIN (0x00) /* MW Minor Version */
 #endif
 /* 0xE0 ~0xFF are proprietary status codes */
@@ -982,10 +982,6 @@
 #define NFC_RF_PARAM_SOS_REQUIRED 0x00     /* SoS required */
 #define NFC_RF_PARAM_SOS_NOT_REQUIRED 0x01 /* SoS not required */
 
-#if (NXP_EXTNS == TRUE)
-#define NFA_EE_MAX_EE_SUPPORTED_DEFAULT 0x04
-#endif
-
 typedef struct {
   bool include_rf_tech_mode; /* true if including RF Tech and Mode update    */
   tNFC_RF_TECH_N_MODE rf_tech_n_mode; /* RF tech and mode */
@@ -1536,17 +1532,6 @@
 *******************************************************************************/
 extern uint8_t NFC_SetTraceLevel(uint8_t new_level);
 
-/*******************************************************************************
-**
-** Function         NFC_GetChipType
-**
-** Description      Gets the chipType
-**
-** Returns          ChipType
-**
-*******************************************************************************/
-tNFC_chipType NFC_GetChipType();
-
 #if (BT_TRACE_VERBOSE == true)
 /*******************************************************************************
 **
@@ -1763,6 +1748,18 @@
 
 /*******************************************************************************
 **
+** Function         NFC_RelForceDwpOnOffWait
+**
+** Description      This function release wait for DWP On/Off
+**                  of P73. Status would be updated to pdata
+**
+** Returns          0 if api call success, else -1
+**
+*******************************************************************************/
+int32_t NFC_RelForceDwpOnOffWait (void *pdata);
+
+/*******************************************************************************
+**
 ** Function         NFC_Queue_Is_empty
 **
 ** Description      This function to get NFCEE connection ID queue information
@@ -1841,4 +1838,5 @@
 **
 *******************************************************************************/
 extern tNFC_STATUS NFC_ISODEPNakPresCheck ();
+
 #endif /* NFC_API_H */
diff --git a/src/nfc/nfc/nfc_main.c b/src/nfc/nfc/nfc_main.c
index 0d05a13..3acdaab 100644
--- a/src/nfc/nfc/nfc_main.c
+++ b/src/nfc/nfc/nfc_main.c
@@ -49,9 +49,9 @@
 #include "ce_int.h"
 #include "llcp_int.h"
 
-#if(NXP_EXTNS == TRUE)
-static phNxpNci_getCfg_info_t* mGetCfg_info_main = NULL;
-extern void nfa_dm_init_cfgs (phNxpNci_getCfg_info_t* mGetCfg_info_main);
+#if (NXP_EXTNS == TRUE)
+extern void nfa_dm_init_cfgs(phNxpNci_getCfg_info_t* mGetCfg_info_main);
+extern nfa_ee_max_ee_cfg;
 #endif
 
 /* NFC mandates support for at least one logical connection;
@@ -682,6 +682,8 @@
         } else {
           nfc_main_post_hal_evt(event, status);
         }
+        nfa_ee_max_ee_cfg = nfcFL.nfccFL._NFA_EE_MAX_EE_SUPPORTED;
+        NFC_TRACE_DEBUG1("NFA_EE_MAX_EE_SUPPORTED to use %d", nfa_ee_max_ee_cfg);
       }
       break;
 
@@ -818,6 +820,11 @@
 void NFC_Disable(void) {
   NFC_TRACE_API1("NFC_Disable (): nfc_state = %d", nfc_cb.nfc_state);
 
+#if (NXP_EXTNS == TRUE)
+  if(nfcFL.eseFL._ESE_DUAL_MODE_PRIO_SCHEME == nfcFL.eseFL._ESE_WIRED_MODE_RESUME)
+    nfc_stop_timer(&nfc_cb.rf_filed_event_timeout_timer);
+#endif
+
   if ((nfc_cb.nfc_state == NFC_STATE_NONE) ||
       (nfc_cb.nfc_state == NFC_STATE_NFCC_POWER_OFF_SLEEP)) {
     nfc_set_state(NFC_STATE_NONE);
@@ -835,19 +842,6 @@
     nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_BOOT_MODE, (void*)&inpOutData);
   }
 #endif
-
-  if(nfcFL.nfcNxpEse) {
-      tNFC_STATUS setPidStatus = NFC_STATUS_OK;
-      nfc_nci_IoctlInOutData_t inpOutData;
-      inpOutData.inp.data.nfcServicePid = 0;
-      setPidStatus = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_NFC_SERVICE_PID,(void*)&inpOutData);
-      if (setPidStatus == NFC_STATUS_OK) {
-          NFC_TRACE_API0("nfc service set pid done");
-      } else {
-          NFC_TRACE_API0("nfc service set pid failed");
-      }
-  }
-
   /* Close transport and clean up */
   nfc_task_shutdown_nfcc();
 
@@ -1803,7 +1797,20 @@
   *(tNFC_STATUS*)pdata = inpOutData.out.data.status;
   return status;
 }
-
+/*******************************************************************************
+**
+** Function         NFC_RelForceDwpOnOffWait
+**
+** Description      This function release wait for DWP On/Off
+**                  of P73. Status would be updated to pdata
+**
+** Returns          0 if api call success, else -1
+**
+*******************************************************************************/
+int32_t NFC_RelForceDwpOnOffWait (void *pdata)
+{
+    return (nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_REL_DWP_WAIT, pdata));
+}
 #endif
 
 #if (NXP_EXTNS == TRUE)
diff --git a/src/nfc/nfc/nfc_ncif.c b/src/nfc/nfc/nfc_ncif.c
index 0ef276b..1e183df 100644
--- a/src/nfc/nfc/nfc_ncif.c
+++ b/src/nfc/nfc/nfc_ncif.c
@@ -766,7 +766,6 @@
   if ((nfc_cb.nxpCbflag == true) &&
       (nfc_ncif_proc_proprietary_rsp(mt, gid, oid) == true)) {
     nci_proc_prop_nxp_rsp(p_msg);
-    nfc_cb.nxpCbflag = false;
     return (free);
   }
 #endif
@@ -2336,7 +2335,7 @@
             ((NFC_STATE_CORE_INIT == nfc_cb.nfc_state) &&
                     (MW_RCVRY_FW_DNLD_ALLOWED == false))) ||
             ((!nfcFL.nfccFL._NFCC_MW_RCVRY_BLK_FW_DNLD) &&
-                    (nfcFL.nfccFL._NFCC_MW_RCVRY_BLK_FW_DNLD)))
+                    (NFC_STATE_CORE_INIT == nfc_cb.nfc_state)))
     {
       nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_CHECK_FLASH_REQ, &inpOutData);
       fw_update_inf = *(tNFC_FWUpdate_Info_t*)&inpOutData.out.data.fwUpdateInf;
@@ -2659,21 +2658,16 @@
               }
           }
         }
-        if((NFC_GetNCIVersion() == NCI_VERSION_2_0)&&(p_cb->act_protocol == NCI_PROTOCOL_15693))
+#if (NXP_EXTNS == TRUE)
+        if(p_cb->act_protocol == NCI_PROTOCOL_15693)
         {
           p_evt->len--;
           p = (uint8_t*)(p_evt + 1);
           data_cevt.status = *(p + p_evt->offset + p_evt->len);
         }
-      }
-#if(NXP_EXTNS == TRUE)
-        if(p_cb->act_protocol == NCI_PROTOCOL_15693)
-        {
-            p_evt->len--;
-            p = (uint8_t *) (p_evt + 1);
-            data_cevt.status = *(p + p_evt->offset + p_evt->len);
-        }
 #endif
+      }
+
       (*p_cb->p_cback)(p_cb->conn_id, NFC_DATA_CEVT, (void*)&data_cevt);
       p_evt = NULL;
     }
diff --git a/src/nfc/nfc/nfc_task.c b/src/nfc/nfc/nfc_task.c
index e445bc8..012c20d 100644
--- a/src/nfc/nfc/nfc_task.c
+++ b/src/nfc/nfc/nfc_task.c
@@ -129,7 +129,13 @@
   while ((nfc_cb.timer_queue.p_first) && (!nfc_cb.timer_queue.p_first->ticks)) {
     p_tle = nfc_cb.timer_queue.p_first;
     GKI_remove_from_timer_list(&nfc_cb.timer_queue, p_tle);
-
+#if(NXP_EXTNS == TRUE)
+    /*Ignore expired timer when NFC off is in progress*/
+    if(nfc_cb.nfc_state == NFC_STATE_W4_HAL_CLOSE ||
+       nfc_cb.nfc_state == NFC_STATE_NONE){
+        return;
+    }
+#endif
     switch (p_tle->event) {
       case NFC_TTYPE_NCI_WAIT_RSP:
         nfc_ncif_cmd_timeout();
@@ -360,12 +366,6 @@
 void nfc_task_shutdown_nfcc(void) {
   NFC_HDR* p_msg;
 
-#if (NXP_EXTNS == TRUE)
- if(nfcFL.eseFL._ESE_DUAL_MODE_PRIO_SCHEME == nfcFL.eseFL._ESE_WIRED_MODE_RESUME) {
-     nfc_stop_timer(&nfc_cb.rf_filed_event_timeout_timer);
- }
-#endif
-
   /* Free any messages still in the mbox */
   while ((p_msg = (NFC_HDR*)GKI_read_mbox(NFC_MBOX_ID)) != NULL) {
     GKI_freebuf(p_msg);