summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Chaisson <chaisson@broadcom.com>2014-05-02 01:12:55 -0400
committerMartijn Coenen <maco@google.com>2014-06-26 09:26:26 -0700
commitc6d8cda88d41587a86032d6cc778e920dab94cf8 (patch)
tree52febacab8eba58256bd26bbc17756ffa23a4fe7
parentf937782dff072eeea70c04db97bdc76d8b6ef9f2 (diff)
downloadlibnfc-nci-c6d8cda88d41587a86032d6cc778e920dab94cf8.tar.gz
Disable BOC before sending XTAL_INDEX_CMD.
Send a few poke commands to perform global reset to avoid issue when booting in the field of a payment reader Change-Id: Icb9e87f8070fcfbd6c593a9f5b96b62c49dacd48
-rw-r--r--halimpl/bcm2079x/adaptation/HalAdaptation.cpp19
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_dm.c132
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_dm_cfg.c5
-rw-r--r--halimpl/bcm2079x/hal/hal/nfc_hal_nci.c1
-rw-r--r--src/hal/include/nfc_hal_api.h7
-rw-r--r--src/hal/int/nfc_hal_int.h6
-rw-r--r--src/include/config.h1
7 files changed, 155 insertions, 16 deletions
diff --git a/halimpl/bcm2079x/adaptation/HalAdaptation.cpp b/halimpl/bcm2079x/adaptation/HalAdaptation.cpp
index 8f669cb..5bdfc35 100644
--- a/halimpl/bcm2079x/adaptation/HalAdaptation.cpp
+++ b/halimpl/bcm2079x/adaptation/HalAdaptation.cpp
@@ -65,6 +65,16 @@ extern tNFC_HAL_CFG *p_nfc_hal_cfg;
extern const UINT8 nfca_version_string [];
extern const UINT8 nfa_version_string [];
+tNFC_HAL_DM_PRE_SET_MEM nfc_hal_pre_set_mem_20795a1 [] =
+{
+ {0x0016403c, 0x00000008},
+ {0x0016403c, 0x00000000},
+ {0x0014008c, 0x00000001},
+ {0, 0}
+};
+
+extern tNFC_HAL_DM_PRE_SET_MEM *p_nfc_hal_dm_pre_set_mem;
+
///////////////////////////////////////
@@ -80,6 +90,15 @@ int HaiInitializeLibrary (const bcm2079x_dev_t* device)
logLevel = InitializeGlobalAppLogLevel ();
+ if ( GetNumValue ( NAME_GLOBAL_RESET, &num, sizeof ( num ) ) )
+ {
+ if (num == 1)
+ {
+ // Send commands to disable boc
+ p_nfc_hal_dm_pre_set_mem = nfc_hal_pre_set_mem_20795a1;
+ }
+ }
+
configureCrystalFrequency ();
verify_hal_non_volatile_store ();
if ( GetNumValue ( NAME_PRESERVE_STORAGE, (char*)&num, sizeof ( num ) ) &&
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c b/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c
index b263abc..9e200f8 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_dm.c
@@ -84,6 +84,7 @@ extern UINT8 *p_nfc_hal_dm_pll_325_cfg;
extern UINT8 *p_nfc_hal_dm_start_up_cfg;
extern UINT8 *p_nfc_hal_dm_start_up_vsc_cfg;
extern tNFC_HAL_CFG *p_nfc_hal_cfg;
+extern tNFC_HAL_DM_PRE_SET_MEM *p_nfc_hal_dm_pre_set_mem;
/*****************************************************************************
** Local function prototypes
@@ -461,6 +462,104 @@ static UINT32 nfc_hal_dm_adjust_hw_id (UINT32 hw_id)
return hw_id;
}
+
+/*******************************************************************************
+**
+** Function nfc_hal_dm_check_xtal
+**
+** Description check if need to send xtal command.
+** If not, proceed to next step get_patch_version.
+**
+** Returns void
+**
+*******************************************************************************/
+static void nfc_hal_dm_check_xtal (void)
+{
+ UINT16 xtal_freq;
+ tNFC_HAL_XTAL_INDEX xtal_index;
+
+ /* if NFCC needs to set Xtal frequency before getting patch version */
+ xtal_index = nfc_hal_dm_get_xtal_index (nfc_hal_cb.dev_cb.brcm_hw_id, &xtal_freq);
+ if ((xtal_index < NFC_HAL_XTAL_INDEX_MAX) || (xtal_index == NFC_HAL_XTAL_INDEX_SPECIAL))
+ {
+ {
+ /* set Xtal index before getting patch version */
+ nfc_hal_dm_set_xtal_freq_index ();
+ return;
+ }
+ }
+
+ NFC_HAL_SET_INIT_STATE (NFC_HAL_INIT_STATE_W4_PATCH_INFO);
+
+ nfc_hal_dm_send_nci_cmd (nfc_hal_dm_get_patch_version_cmd, NCI_MSG_HDR_SIZE, NULL);
+}
+
+/*******************************************************************************
+**
+** Function nfc_hal_dm_pre_set_mem_cback
+**
+** Description This is pre-set mem complete callback.
+**
+** Returns void
+**
+*******************************************************************************/
+static void nfc_hal_dm_pre_set_mem_cback (tNFC_HAL_BTVSC_CPLT *pData)
+{
+ UINT8 status = pData->p_param_buf[0];
+
+ HAL_TRACE_DEBUG1 ("nfc_hal_dm_pre_set_mem_cback: %d", status);
+ /* if it is completed */
+ if (status == HCI_SUCCESS)
+ {
+ if (!nfc_hal_dm_check_pre_set_mem())
+ {
+ return;
+ }
+ }
+ nfc_hal_dm_check_xtal();
+}
+
+
+/*******************************************************************************
+**
+** Function nfc_hal_dm_check_pre_set_mem
+**
+** Description Check if need to send the command.
+**
+** Returns TRUE if done.
+**
+*******************************************************************************/
+BOOLEAN nfc_hal_dm_check_pre_set_mem (void)
+{
+ UINT8 cmd[NFC_HAL_BT_HCI_CMD_HDR_SIZE + HCI_BRCM_PRE_SET_MEM_LENGTH];
+ UINT8 *p;
+ UINT32 addr = 0;
+
+ if (p_nfc_hal_dm_pre_set_mem)
+ addr = p_nfc_hal_dm_pre_set_mem[nfc_hal_cb.pre_set_mem_idx].addr;
+ HAL_TRACE_DEBUG2 ("nfc_hal_dm_check_pre_set_mem: %d/0x%x", nfc_hal_cb.pre_set_mem_idx, addr);
+ if (addr == 0)
+ {
+ return TRUE;
+ }
+ p = cmd;
+
+ /* Add the command */
+ UINT16_TO_STREAM (p, HCI_BRCM_PRE_SET_MEM);
+ UINT8_TO_STREAM (p, HCI_BRCM_PRE_SET_MEM_LENGTH);
+
+ UINT8_TO_STREAM (p, HCI_BRCM_PRE_SET_MEM_TYPE);
+ UINT32_TO_STREAM (p, addr);
+ UINT8_TO_STREAM (p, 0);
+ UINT32_TO_STREAM (p, p_nfc_hal_dm_pre_set_mem[nfc_hal_cb.pre_set_mem_idx].data);
+ nfc_hal_cb.pre_set_mem_idx++;
+
+ nfc_hal_dm_send_bt_cmd (cmd,
+ NFC_HAL_BT_HCI_CMD_HDR_SIZE + HCI_BRCM_PRE_SET_MEM_LENGTH,
+ nfc_hal_dm_pre_set_mem_cback);
+ return FALSE;
+}
+
/*******************************************************************************
**
** Function nfc_hal_dm_proc_msg_during_init
@@ -480,9 +579,7 @@ void nfc_hal_dm_proc_msg_during_init (NFC_HDR *p_msg)
tNFC_HAL_NCI_CBACK *p_cback = NULL;
UINT8 chipverlen;
UINT8 chipverstr[NCI_SPD_HEADER_CHIPVER_LEN];
- UINT16 xtal_freq;
UINT32 hw_id = 0;
- tNFC_HAL_XTAL_INDEX xtal_index;
HAL_TRACE_DEBUG1 ("nfc_hal_dm_proc_msg_during_init(): init state:%d", nfc_hal_cb.dev_cb.initializing_state);
@@ -579,21 +676,13 @@ void nfc_hal_dm_proc_msg_during_init (NFC_HDR *p_msg)
STREAM_TO_ARRAY (chipverstr, p, chipverlen);
nfc_hal_hci_handle_build_info (chipverlen, chipverstr);
-
- /* if NFCC needs to set Xtal frequency before getting patch version */
- xtal_index = nfc_hal_dm_get_xtal_index (nfc_hal_cb.dev_cb.brcm_hw_id, &xtal_freq);
- if ((xtal_index < NFC_HAL_XTAL_INDEX_MAX) || (xtal_index == NFC_HAL_XTAL_INDEX_SPECIAL))
+ nfc_hal_cb.pre_set_mem_idx = 0;
+ if (!nfc_hal_dm_check_pre_set_mem())
{
- {
- /* set Xtal index before getting patch version */
- nfc_hal_dm_set_xtal_freq_index ();
- return;
- }
+ /* pre-set mem started */
+ return;
}
-
- NFC_HAL_SET_INIT_STATE (NFC_HAL_INIT_STATE_W4_PATCH_INFO);
-
- nfc_hal_dm_send_nci_cmd (nfc_hal_dm_get_patch_version_cmd, NCI_MSG_HDR_SIZE, NULL);
+ nfc_hal_dm_check_xtal();
}
else if ( (op_code == NFC_VS_GET_PATCH_VERSION_EVT)
&&(nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_PATCH_INFO) )
@@ -792,9 +881,20 @@ void nfc_hal_dm_send_pend_cmd (void)
void nfc_hal_dm_send_bt_cmd (const UINT8 *p_data, UINT16 len, tNFC_HAL_BTVSC_CPLT_CBACK *p_cback)
{
NFC_HDR *p_buf;
+ char buff[300];
+ char tmp[4];
+ buff[0] = 0;
+ int i;
HAL_TRACE_DEBUG1 ("nfc_hal_dm_send_bt_cmd (): nci_wait_rsp = 0x%x", nfc_hal_cb.ncit_cb.nci_wait_rsp);
+ for (i = 0; i < len; i++)
+ {
+ sprintf (tmp, "%02x ", p_data[i]);
+ strcat(buff, tmp);
+ }
+ HAL_TRACE_DEBUG2 ("nfc_hal_dm_send_bt_cmd (): HCI Write (%d bytes): %s", len, buff);
+
if (nfc_hal_cb.ncit_cb.nci_wait_rsp != NFC_HAL_WAIT_RSP_NONE)
{
HAL_TRACE_ERROR0 ("nfc_hal_dm_send_bt_cmd(): no command window");
@@ -1076,7 +1176,7 @@ tHAL_NFC_STATUS HAL_NfcReInit (void)
**
** Function nfc_hal_dm_set_snooze_mode_cback
**
-** Description This is baud rate update complete callback.
+** Description This is snooze update complete callback.
**
** Returns void
**
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_dm_cfg.c b/halimpl/bcm2079x/hal/hal/nfc_hal_dm_cfg.c
index 302c0fe..7c8e1e8 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_dm_cfg.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_dm_cfg.c
@@ -140,6 +140,11 @@ UINT8 *p_nfc_hal_dm_lptd_cfg = (UINT8 *) &nfc_hal_dm_lptd_cfg[0];
*/
UINT8 *p_nfc_hal_dm_pll_325_cfg = NULL;
+/*
+** Proprietary pre-set is required, if not NULL.
+*/
+tNFC_HAL_DM_PRE_SET_MEM *p_nfc_hal_dm_pre_set_mem = NULL;
+
tNFC_HAL_CFG nfc_hal_cfg =
{
FALSE, /* set nfc_hal_prm_nvm_required to TRUE, if the platform wants to abort PRM process without NVM */
diff --git a/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c b/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c
index f3547d3..f4eb9af 100644
--- a/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c
+++ b/halimpl/bcm2079x/hal/hal/nfc_hal_nci.c
@@ -425,6 +425,7 @@ static void nfc_hal_nci_proc_rx_bt_msg (void)
/* if initializing BRCM NFCC */
if ((nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_APP_COMPLETE) ||
+ (nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_BUILD_INFO) ||
(nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_CONTROL_DONE))
{
/* this is command complete event for baud rate update or download patch */
diff --git a/src/hal/include/nfc_hal_api.h b/src/hal/include/nfc_hal_api.h
index 6a7288b..ebd385d 100644
--- a/src/hal/include/nfc_hal_api.h
+++ b/src/hal/include/nfc_hal_api.h
@@ -92,6 +92,13 @@ typedef void (tHAL_API_POWER_CYCLE) (void);
typedef UINT8 (tHAL_API_GET_MAX_NFCEE) (void);
+#define NFC_HAL_DM_PRE_SET_MEM_LEN 5
+typedef struct
+{
+ UINT32 addr;
+ UINT32 data;
+} tNFC_HAL_DM_PRE_SET_MEM;
+
/* data members for NFC_HAL-HCI */
typedef struct
{
diff --git a/src/hal/int/nfc_hal_int.h b/src/hal/int/nfc_hal_int.h
index 05e51b0..fbde0f9 100644
--- a/src/hal/int/nfc_hal_int.h
+++ b/src/hal/int/nfc_hal_int.h
@@ -139,6 +139,9 @@ extern NFC_HAL_TRANS_CFG_QUALIFIER tNFC_HAL_TRANS_CFG nfc_hal_trans_cfg;
#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 12
#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
#define HCIE_PREAMBLE_SIZE 2
+#define HCI_BRCM_PRE_SET_MEM (0x000C | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_PRE_SET_MEM_LENGTH 10
+#define HCI_BRCM_PRE_SET_MEM_TYPE 8
/****************************************************************************
** Internal constants and definitions
@@ -431,6 +434,7 @@ typedef struct
#endif
UINT8 pre_discover_done; /* TRUE, when the prediscover config is complete */
+ UINT8 pre_set_mem_idx;
UINT8 max_rf_credits; /* NFC Max RF data credits */
UINT8 max_ee; /* NFC Max number of NFCEE supported by NFCC */
@@ -481,6 +485,8 @@ void nfc_hal_dm_shutting_down_nfcc (void);
BOOLEAN nfc_hal_dm_power_mode_execute (tNFC_HAL_LP_EVT event);
void nfc_hal_dm_send_pend_cmd (void);
tHAL_NFC_STATUS nfc_hal_dm_set_config (UINT8 tlv_size, UINT8 *p_param_tlvs, tNFC_HAL_NCI_CBACK *p_cback);
+BOOLEAN nfc_hal_dm_check_pre_set_mem (void);
+
/* nfc_hal_prm.c */
void nfc_hal_prm_spd_reset_ntf (UINT8 reset_reason, UINT8 reset_type);
diff --git a/src/include/config.h b/src/include/config.h
index 0cb8bec..acda04c 100644
--- a/src/include/config.h
+++ b/src/include/config.h
@@ -85,6 +85,7 @@ int GetNumValue(const char* name, void* p_value, unsigned long len);
#define NAME_PRESENCE_CHECK_ALGORITHM "PRESENCE_CHECK_ALGORITHM"
#define NAME_ALLOW_NO_NVM "ALLOW_NO_NVM"
#define NAME_DEVICE_HOST_WHITE_LIST "DEVICE_HOST_WHITE_LIST"
+#define NAME_GLOBAL_RESET "DO_GLOBAL_RESET"
#define LPTD_PARAM_LEN (40)