15d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
25d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Copyright (C) 2010 NXP Semiconductors
35d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
45d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Licensed under the Apache License, Version 2.0 (the "License");
55d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * you may not use this file except in compliance with the License.
65d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * You may obtain a copy of the License at
75d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
85d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *      http://www.apache.org/licenses/LICENSE-2.0
95d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Unless required by applicable law or agreed to in writing, software
115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * distributed under the License is distributed on an "AS IS" BASIS,
125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * See the License for the specific language governing permissions and
145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * limitations under the License.
155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== *
205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \file  phHciNfc_DevMgmt.c                                                   *
235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief HCI PN544 Device Management Gate Routines.                           *
245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Project: NFC-FRI-1.1                                                        *
275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Date: Fri Mar 12 10:21:54 2010 $                                           *
295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Author: ing04880 $                                                         *
305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Revision: 1.29 $                                                            *
315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Aliases: NFC_FRI1.1_WK1007_R33_3,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $                                                                *
325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*                                                                             *
335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== *
345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Header File Inclusion ****************************
385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcConfig.h>
405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcCompId.h>
415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Pipe.h>
425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_DevMgmt.h>
435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Emulation.h>
445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h>
455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly****************************** Macro Definitions *******************************
485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*  Commands for System Management module */
515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_RF_CHECK_SETTINGS   0x10U
525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_RF_UPDATE_SETTINGS  0x11U
535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Self Test Commands */
555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_SELF_TEST_ANTENNA   0x20U
565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_SELF_TEST_SWP       0x21U
575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_SELF_TEST_NFCWI     0x22U
585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_SELF_TEST_PRBS      0x25U
595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* System Management propreitary control */
615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_DBG_READ            0x3EU
625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_DBG_WRITE           0x3FU
635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* System Management Events */
655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_SET_AUTONOMOUS   0x01U
665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_CLF_WAKEUP       0x02U
675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* System Management Information Events */
695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_INFO_TXLDO_OVERCUR   0x10U
705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_INFO_PMUVCC          0x11U
715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_INFO_EXT_RF_FIELD    0x12U
725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_INFO_MEM_VIOLATION   0x13U
735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NXP_EVT_INFO_TEMP_OVERHEAT   0x14U
746dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#define NXP_EVT_INFO_LLC_ERROR       0x15U
755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NFC_DEV_TXLDO_MASK           0x03U
775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Structure and Enumeration ***************************
815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** \defgroup grp_hci_nfc HCI PN544 Device Management Component
855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef enum phHciNfc_DevMgmt_Seq{
905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_PIPE_OPEN      = 0x00U,
915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_SET_PWR_STATUS,
925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_SET_INFO_EVT,
935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_GET_EEPROM_INFO,
945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_GPIO_PDIR,
955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_GPIO_PEN,
965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_TX_LDO,
975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_IFC_TO_RX_H,
985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_IFC_TO_RX_L,
995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_IFC_TO_TX_H,
1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_IFC_TO_TX_L,
1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_ANAIRQ_CONF,
1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_PMOS_MOD,
1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_CLK_REQ,
1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_INPUT_CLK,
1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_PWR_REQUEST,
1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_ACTIVE_GUARD_TO,
1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_MAX_ACT_TO_LOW,
1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_MAX_ACT_TO_HIGH,
1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_CE_A_ACCESS,
1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_CE_B_ACCESS,
1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_CE_BP_ACCESS,
1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_CE_F_ACCESS,
1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_RD_A_ACCESS,
1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_RD_B_ACCESS,
1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_BIT_RATE,
1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_RX_ERR_CNT,
1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_UICC_TX_ERR_CNT,
1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_LLC_GRD_TO_H,
1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_LLC_GRD_TO_L,
1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_LLC_ACK_TO_H,
1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_LLC_ACK_TO_L,
122dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi    DEV_MGMT_FELICA_RC,
1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_EVT_AUTONOMOUS,
1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    DEV_MGMT_PIPE_CLOSE
1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} phHciNfc_DevMgmt_Seq_t;
1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef struct phHciNfc_DevMgmt_Info{
1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Seq_t  current_seq;
1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Seq_t  next_seq;
1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t    *p_pipe_info;
1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 test_status;
1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 value;
1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 rf_status;
1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 pmuvcc_status;
1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 overheat_status;
1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 *p_val;
1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 eeprom_crc;
1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phNfc_sData_t           test_result;
1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} phHciNfc_DevMgmt_Info_t;
1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration **************************
1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_InfoUpdate(
1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHal_sHwReference_t    *pHwRef,
1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 index,
1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 *reg_value,
1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 reg_length
1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                         );
1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_DevMgmt_Response(
1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *psHciContext,
1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *pHwRef,
1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             *pResponse,
1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN
1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             length
1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint16_t            length
1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                       );
1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_DevMgmt_Event(
1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *psContext,
1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *pHwRef,
1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             *pEvent,
1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN
1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             length
1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint16_t            length
1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    );
1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Send_DevMgmt_Command (
1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            phHciNfc_sContext_t *psHciContext,
1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            void                *pHwRef,
1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            uint8_t             pipe_id,
1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            uint8_t             cmd
1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                );
1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_DevMgmt_Event (
1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             pipe_id,
2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             event
2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    );
2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*
2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions ***************************
2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/
2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Init_Resources(
2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                           phHciNfc_sContext_t  *psHciContext
2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                          )
2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t          *p_device_mgmt_info=NULL;
2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(( NULL == psHciContext->p_device_mgmt_info ) &&
2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly             (phHciNfc_Allocate_Resource((void **)(&p_device_mgmt_info),
2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            sizeof(phHciNfc_DevMgmt_Info_t))== NFCSTATUS_SUCCESS))
2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->p_device_mgmt_info = p_device_mgmt_info;
2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_device_mgmt_info->current_seq = DEV_MGMT_PIPE_OPEN;
2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN;
2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_device_mgmt_info->p_pipe_info = NULL;
2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES);
2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Get_PipeID(
2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            phHciNfc_sContext_t        *psHciContext,
2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            uint8_t                    *ppipe_id
2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            )
2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL != psHciContext)
2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && ( NULL != ppipe_id )
2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && ( NULL != psHciContext->p_device_mgmt_info )
2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phHciNfc_Pipe_Info_t     *p_pipe_info = NULL;
2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->p_device_mgmt_info)->p_pipe_info ;
2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if (NULL != p_pipe_info)
2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            *ppipe_id = p_pipe_info->pipe.pipe_id ;
2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            *ppipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Get_Test_Result(
2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t        *psHciContext,
2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phNfc_sData_t              *p_test_result
2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            )
2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL != psHciContext)
2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && ( NULL != p_test_result )
2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && ( NULL != psHciContext->p_device_mgmt_info )
2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_device_mgmt_info ;
2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_test_result->buffer = p_device_mgmt_info->test_result.buffer;
2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_test_result->length = p_device_mgmt_info->test_result.length;
2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Set_Test_Result(
3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t        *psHciContext,
3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                    test_status
3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            )
3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL != psHciContext)
3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        && ( NULL != psHciContext->p_device_mgmt_info )
3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_device_mgmt_info ;
3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info->test_status = test_status;
3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Update_PipeInfo(
3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  phHciNfc_sContext_t     *psHciContext,
3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  uint8_t                 pipeID,
3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                  phHciNfc_Pipe_Info_t    *pPipeInfo
3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                           )
3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(NULL == psHciContext->p_device_mgmt_info)
3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_device_mgmt_info ;
3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        /* Update the pipe_info of the Device Management Gate obtained
3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly         * from HCI Response */
3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info->p_pipe_info = pPipeInfo;
3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if (( NULL != pPipeInfo)
3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            && ((uint8_t)HCI_UNKNOWN_PIPE_ID != pipeID)
3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            )
3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Update the Response Receive routine of the Device
3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly             * Managment Gate */
3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            pPipeInfo->recv_resp = &phHciNfc_Recv_DevMgmt_Response;
3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            pPipeInfo->recv_event = &phHciNfc_Recv_DevMgmt_Event;
3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_DevMgmt_Configure (
3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint16_t            address,
3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             value
3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     i=0;
3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     params[5];
3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(  NULL == psHciContext->p_device_mgmt_info )
3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                       psHciContext->p_device_mgmt_info)->p_pipe_info ;
3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(NULL == p_pipe_info )
3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI,
4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFCSTATUS_INVALID_HCI_SEQUENCE);
4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            pipe_id = p_pipe_info->pipe.pipe_id ;
4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = 0x00;
4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = (uint8_t)(address >> BYTE_SIZE);
4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = (uint8_t)address;
4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = value;
4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->param_info = &params;
4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->param_length = i ;
4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                pipe_id, (uint8_t)NXP_DBG_WRITE );
4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_DevMgmt_Get_Info (
4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint16_t            address,
4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             *p_val
4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     i=0;
4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     params[5];
4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(  NULL == psHciContext->p_device_mgmt_info )
4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                       psHciContext->p_device_mgmt_info)->p_pipe_info ;
4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if(NULL == p_pipe_info )
4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI,
4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFCSTATUS_INVALID_HCI_SEQUENCE);
4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            ((phHciNfc_DevMgmt_Info_t *)
4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    psHciContext->p_device_mgmt_info)->p_val = p_val;
4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            pipe_id = p_pipe_info->pipe.pipe_id ;
4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = 0x00;
4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = (uint8_t)(address >> BYTE_SIZE);
4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            params[i++] = (uint8_t) address;
4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->param_info = &params;
4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->param_length = i ;
4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            pipe_id, (uint8_t)NXP_DBG_READ );
4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Initialisation of PN544 Device Managment Gate.
4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function initialses the PN544 Device Management gate and
4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * populates the PN544 Device Management Information Structure
4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Initialise(
4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef
4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                         )
4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                       status = NFCSTATUS_SUCCESS;
4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t            *p_pipe_info = NULL;
4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t         *p_device_mgmt_info=NULL;
4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    static uint8_t                   config = 0x10;
4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( ( NULL == psHciContext )
4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == pHwRef )
4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        )
4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if (NULL == psHciContext->p_device_mgmt_info)
4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI,
4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    NFCSTATUS_INVALID_HCI_INFORMATION);
4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }/* End of the PN544 Device Info Memory Check */
5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_device_mgmt_info ;
5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = p_device_mgmt_info->p_pipe_info;
5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if (NULL == p_pipe_info)
5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL(CID_NFC_HCI,
5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFCSTATUS_INVALID_HCI_SEQUENCE);
5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            switch(p_device_mgmt_info->current_seq )
5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* PN544 Device Mgmt pipe open sequence */
5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_PIPE_OPEN:
5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Open_Pipe( psHciContext,
5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    pHwRef, p_pipe_info );
5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_SUCCESS)
5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
522dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                        p_device_mgmt_info->next_seq =
523dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                                    DEV_MGMT_FELICA_RC;
5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_PENDING;
5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_GET_EEPROM_INFO:
5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->reg_index = DEVICE_INFO_EEPROM_INDEX;
5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_Generic_Cmd( psHciContext,
5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            pHwRef, (uint8_t)p_pipe_info->pipe.pipe_id,
5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                (uint8_t)ANY_GET_PARAMETER);
5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( NXP_NFC_IFC_TIMEOUT & 0x01 )
5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_IFC_TO_TX_H;
5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        DEV_MGMT_TX_LDO;
5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if  ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_GPIO_PDIR:
5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0x00;
5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_GPIO_PDIR , config );
5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_GPIO_PEN;
5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_GPIO_PEN:
5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = NXP_NFC_GPIO_MASK(NXP_DOWNLOAD_GPIO)| 0x03 ;
5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_GPIO_PEN , config );
5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( NXP_NFC_IFC_TIMEOUT & 0x01 )
5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_IFC_TO_TX_H;
5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_TX_LDO;
5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if  ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
575dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                case DEV_MGMT_FELICA_RC:
576dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                {
577dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                    config = 0x00;
578dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
579dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                                 NFC_FELICA_RC_ADDR , config );
580dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                    if(NFCSTATUS_PENDING == status )
581dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                    {
5826dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren
5836dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                        if ((HCI_SELF_TEST == psHciContext->init_mode )
5846dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                            || (HCI_NFC_DEVICE_TEST == psHciContext->init_mode ))
585dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                        {
586dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                            p_device_mgmt_info->next_seq =
587dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                                   DEV_MGMT_GPIO_PDIR;
588dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                        }
589dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                        else
590dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                        {
591dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                            p_device_mgmt_info->next_seq =
592dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                                   DEV_MGMT_GET_EEPROM_INFO;
593dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                        }
594dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                    }
595dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                    break;
596dd7125f5ab402a8e52625182542c668db3e51c2cSunil Jogi                }
5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( NXP_NFC_IFC_TIMEOUT & 0x01 )
5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_IFC_TO_TX_H:
6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config =  (uint8_t)
6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ( NXP_NFC_IFC_CONFIG_DEFAULT >> BYTE_SIZE ) /* 0x03 */;
6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        NFC_ADDRESS_IFC_TO_TX_H , config );
6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_IFC_TO_TX_L;
6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_IFC_TO_TX_L:
6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t)
6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ( NXP_NFC_IFC_CONFIG_DEFAULT & BYTE_MASK ) /* 0xE8 */;
6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_IFC_TO_TX_L , config );
6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( NXP_NFC_IFC_TIMEOUT & 0x02 )
6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_IFC_TO_RX_H;
6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_TX_LDO;
6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if  ( NXP_NFC_IFC_TIMEOUT & 0x02 ) */
6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_IFC_TO_RX_H:
6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0x10;
6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_IFC_TO_RX_H , config );
6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_IFC_TO_RX_L;
6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_IFC_TO_RX_L:
6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0x1E;
6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_IFC_TO_RX_L , config );
6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_TX_LDO;
6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if  ( NXP_NFC_IFC_TIMEOUT & 0x01 ) */
6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_TX_LDO:
6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6596dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#if ( NXP_HAL_VERIFY_EEPROM_CRC & 0x01U )
6606dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    if (0 != p_device_mgmt_info->eeprom_crc)
6616dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    {
6626dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                        status = NFCSTATUS_FAILED;
6636dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    }
6646dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    else
6656dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren#endif
6666dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    {
6676dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                       config = (NFC_DEV_HWCONF_DEFAULT |
6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (NXP_DEFAULT_TX_LDO & NFC_DEV_TXLDO_MASK));
6696dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                       status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_HW_CONF , config );
6716dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                       if(NFCSTATUS_PENDING == status )
6726dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                       {
6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if ( SW_TYPE_RF_TUNING_BF & 0x01)
6746dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                           p_device_mgmt_info->next_seq = DEV_MGMT_ANAIRQ_CONF;
6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
6766dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                           p_device_mgmt_info->next_seq = DEV_MGMT_CLK_REQ;
6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
6786dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                           /* status = NFCSTATUS_SUCCESS; */
6796dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                       }
6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if ( SW_TYPE_RF_TUNING_BF & 0x01)
6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* The Analogue IRQ Configuartion */
6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_ANAIRQ_CONF:
6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0x04;
6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_ANAIRQ_CONF , config );
6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_PMOS_MOD;
6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_SUCCESS; */
6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* The PMOS Modulation Index */
6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_PMOS_MOD:
7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = NFC_DEV_PMOS_MOD_DEFAULT;
7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_PMOS_MOD , config );
7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_CLK_REQ;
7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_SUCCESS; */
7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( SW_TYPE_RF_TUNING_BF & 0x01) */
7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_CLK_REQ:
7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = ((phHal_sHwConfig_t *)
7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext->p_config_params)->clk_req ;
7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_CLK_REQ , config );
7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_INPUT_CLK;
7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_SUCCESS; */
7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_INPUT_CLK:
7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = ((phHal_sHwConfig_t *)
7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    psHciContext->p_config_params)->input_clk;
7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_CLK_INPUT , config );
7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_PWR_REQUEST;
7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_PWR_REQUEST:
7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = NXP_UICC_PWR_REQUEST;
7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_SWP_PWR_REQ , config );
7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_RD_A_ACCESS;
7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_RD_A_ACCESS:
7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if ( NXP_UICC_RD_RIGHTS & 0x01 )
7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t) phHciNfc_RFReaderAGate;
7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0xFFU;
7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( NXP_UICC_RD_RIGHTS & 0x01 ) */
7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_UICC_RD_A_ACCESS , config );
7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_RD_B_ACCESS;
7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_RD_B_ACCESS:
7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if ( NXP_UICC_RD_RIGHTS & 0x02 )
7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t) phHciNfc_RFReaderBGate;
7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0xFFU;
7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( NXP_UICC_RD_RIGHTS & 0x02 ) */
7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_UICC_RD_B_ACCESS , config );
7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_CE_A_ACCESS;
7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_CE_A_ACCESS:
7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x01 )
7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t) phHciNfc_CETypeAGate;
7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0xFFU;
7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( NXP_UICC_CE_RIGHTS & 0x01 ) */
7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_UICC_CE_A_ACCESS , config );
7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_CE_B_ACCESS;
7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_CE_B_ACCESS:
8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x02 )
8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t) phHciNfc_CETypeBGate;
8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0xFFU;
8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( NXP_UICC_CE_RIGHTS & 0x02 ) */
8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_UICC_CE_B_ACCESS , config );
8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_CE_BP_ACCESS;
8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_CE_BP_ACCESS:
8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x04 )
8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t) phHciNfc_CETypeBPrimeGate;
8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0xFFU;
8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( NXP_UICC_CE_RIGHTS & 0x04 ) */
8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_UICC_CE_BP_ACCESS , config );
8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_CE_F_ACCESS;
8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_CE_F_ACCESS:
8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined(HOST_EMULATION) || ( NXP_UICC_CE_RIGHTS & 0x08 )
8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t) phHciNfc_CETypeFGate;
8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = 0xFFU;
8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( NXP_UICC_CE_RIGHTS & 0x08 ) */
8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_UICC_CE_F_ACCESS , config );
8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_UICC_BIT_RATE;
8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_UICC_BIT_RATE:
8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = NXP_UICC_BIT_RATE;
8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_SWP_BITRATE , config );
8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if defined (CFG_PWR_STATUS)
8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_SET_PWR_STATUS;
8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_SET_INFO_EVT;
8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef CFG_PWR_STATUS
8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_SET_PWR_STATUS:
8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = NXP_SYSTEM_PWR_STATUS;
8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_PWR_STATUS , config );
8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_SET_INFO_EVT;
8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_SET_INFO_EVT:
8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = NXP_SYSTEM_EVT_INFO;
8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Set_Param(psHciContext, pHwRef,
8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_pipe_info, DEVICE_INFO_EVT_INDEX,
8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (uint8_t *)&config, sizeof(config) );
8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( HOST_LINK_TIMEOUT & 0x01 )
8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_LLC_GRD_TO_H;
8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_EVT_AUTONOMOUS;
8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_SUCCESS;
8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( HOST_LINK_TIMEOUT & 0x01 ) */
8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( HOST_LINK_TIMEOUT & 0x01 )
8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_LLC_GRD_TO_H:
9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config =(uint8_t)
9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ( NXP_NFC_LINK_GRD_CFG_DEFAULT >> BYTE_SIZE ) /* 0x00 */;
9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_LLC_GRD_TO_H , config );
9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_LLC_GRD_TO_L;
9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_LLC_GRD_TO_L:
9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t)
9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ( NXP_NFC_LINK_GRD_CFG_DEFAULT & BYTE_MASK ) /* 0x32 */;
9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_LLC_GRD_TO_L , config );
9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if  ( HOST_LINK_TIMEOUT & 0x02 )
9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_LLC_ACK_TO_H;
9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_EVT_AUTONOMOUS;
9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_SUCCESS;
9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( HOST_LINK_TIMEOUT & 0x02 ) */
9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_LLC_ACK_TO_H:
9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t)
9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ( NXP_NFC_LINK_ACK_CFG_DEFAULT >> BYTE_SIZE )/* 0x00 */;
9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_LLC_ACK_TO_H , config );
9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_LLC_ACK_TO_L;
9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_LLC_ACK_TO_L:
9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    config = (uint8_t)
9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        ( NXP_NFC_LINK_ACK_CFG_DEFAULT & BYTE_MASK ) /* 0x00 */;;
9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFC_ADDRESS_LLC_ACK_TO_L , config );
9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(NFCSTATUS_PENDING == status )
9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq =
9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                DEV_MGMT_EVT_AUTONOMOUS;
9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_SUCCESS;
9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #if ( HOST_LINK_TIMEOUT & 0x01 ) */
9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                default:
9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }/* End of the Sequence Switch */
9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    } /* End of Null Context Check */
9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Releases the resources allocated the PN544 Device Management.
9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Releases the resources allocated the PN544 Device Management
9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * and resets the hardware to the reset state.
9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Release(
9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                    *pHwRef
9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                           status = NFCSTATUS_SUCCESS;
9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t                *p_pipe_info = NULL;
9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t         *p_device_mgmt_info=NULL;
9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NULL != psHciContext->p_device_mgmt_info )
9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_device_mgmt_info ;
10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            switch(p_device_mgmt_info->current_seq)
10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* PN544 Device pipe close sequence */
10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_EVT_AUTONOMOUS:
10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = p_device_mgmt_info->p_pipe_info;
10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_info = NULL;
10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info->param_length = HCP_ZERO_LEN;
10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Send_DevMgmt_Event(psHciContext, pHwRef,
10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                p_pipe_info->pipe.pipe_id, NXP_EVT_SET_AUTONOMOUS);
10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_PENDING)
10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN;
10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        status = NFCSTATUS_SUCCESS;
10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* PN544 Device pipe close sequence */
10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                case DEV_MGMT_PIPE_CLOSE:
10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    p_pipe_info = p_device_mgmt_info->p_pipe_info;
10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = phHciNfc_Close_Pipe( psHciContext,
10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                        pHwRef, p_pipe_info );
10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if(status == NFCSTATUS_SUCCESS)
10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN;
10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        /* status = NFCSTATUS_PENDING; */
10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                default:
10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    break;
10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }/* End of the Sequence Switch */
10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }/* End of the PN544 Device Info Memory Check */
10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    } /* End of Null Context Check */
10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Update_Sequence(
10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_eSeqType_t     DevMgmt_seq
10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                             )
10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t          *p_device_mgmt_info=NULL;
10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( NULL == psHciContext )
10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if ( NULL == psHciContext->p_device_mgmt_info )
10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI,
10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        NFCSTATUS_INVALID_HCI_INFORMATION);
10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_device_mgmt_info ;
10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch(DevMgmt_seq)
10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case RESET_SEQ:
10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case INIT_SEQ:
10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->current_seq = DEV_MGMT_PIPE_OPEN;
10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->next_seq = DEV_MGMT_PIPE_OPEN ;
10796dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                break;
10806dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren            }
10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case UPDATE_SEQ:
10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->current_seq = p_device_mgmt_info->next_seq;
10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
10856dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                break;
10866dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren            }
10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case REL_SEQ:
10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->current_seq = DEV_MGMT_EVT_AUTONOMOUS;
10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->next_seq = DEV_MGMT_EVT_AUTONOMOUS ;
10916dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                break;
10926dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren            }
10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }/* End of Update Sequence Switch */
10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Perform the System Management Tests
11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * provided by the corresponding peripheral device.
11085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function performs the System Management Tests provided by the NFC
11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Peripheral device.
11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_Test(
11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    void                            *psContext,
11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    void                            *pHwRef,
11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    uint8_t                         test_type,
11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    phNfc_sData_t                   *test_param
11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                 )
11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_sContext_t         *psHciContext =
11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (phHciNfc_sContext_t *)psContext ;
11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t        *p_pipe_info = NULL;
11255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(  NULL == psHciContext->p_device_mgmt_info )
11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
11335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
11345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
11355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
11376dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren        phHciNfc_DevMgmt_Info_t *p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
11386dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                                        psHciContext->p_device_mgmt_info ;
11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = ((phHciNfc_DevMgmt_Info_t *)
11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                       psHciContext->p_device_mgmt_info)->p_pipe_info ;
11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch(test_type)
11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_ANTENNA:
11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_SWP:
11455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_PRBS:
11465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* case NXP_SELF_TEST_NFCWI: */
11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                if (NULL != p_pipe_info)
11495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
11505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    pipe_id = p_pipe_info->pipe.pipe_id ;
11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    if ( NULL != test_param )
11525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    {
11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_pipe_info->param_info = test_param->buffer;
11545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        p_pipe_info->param_length = (uint8_t)test_param->length;
11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    }
11566dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    p_device_mgmt_info->test_result.buffer = NULL;
11576dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    p_device_mgmt_info->test_result.length = 0;
11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status =
11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        phHciNfc_Send_DevMgmt_Command( psHciContext, pHwRef,
11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            pipe_id, (uint8_t)test_type );
11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                else
11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                {
11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    status = PHNFCSTVAL(CID_NFC_HCI,
11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_INFORMATION);
11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                }
11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI,
11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            NFCSTATUS_FEATURE_NOT_SUPPORTED);
11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Receives the HCI Response from the corresponding peripheral device.
11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function receives the HCI Command Response from the connected NFC
11865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Peripheral device.
11875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
11885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
11895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
11905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_DevMgmt_Response(
11915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *psContext,
11925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *pHwRef,
11935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             *pResponse,
11945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN
11955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             length
11965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
11975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint16_t            length
11985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
11995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
12005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
12015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_sContext_t         *psHciContext =
12025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (phHciNfc_sContext_t *)psContext ;
12035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
12045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
12055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     prev_cmd = ANY_GET_PARAMETER;
12065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
12085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
12095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
12105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(  NULL == psHciContext->p_device_mgmt_info )
12125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
12165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
12185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_device_mgmt_info ;
12195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        prev_cmd = p_device_mgmt_info->p_pipe_info->prev_msg ;
12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch(prev_cmd)
12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
12225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case ANY_GET_PARAMETER:
12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = phHciNfc_DevMgmt_InfoUpdate(psHciContext,
12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            (phHal_sHwReference_t *)pHwRef,
12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            p_device_mgmt_info->p_pipe_info->reg_index,
12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            &pResponse[HCP_HEADER_LEN],
12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                (uint8_t)(length - HCP_HEADER_LEN));
12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case ANY_SET_PARAMETER:
12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case ANY_OPEN_PIPE:
12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case ANY_CLOSE_PIPE:
12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phOsalNfc_FreeMemory(p_device_mgmt_info->p_pipe_info);
12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->p_pipe_info = NULL;
12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                psHciContext->p_pipe_list[PIPETYPE_STATIC_LINK] = NULL;
12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_DBG_READ:
12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* fall through */
12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_DBG_WRITE:
12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12506dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                if( NULL != p_device_mgmt_info->p_val )
12516dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                {
12526dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    *p_device_mgmt_info->p_val = (uint8_t)( length > HCP_HEADER_LEN ) ?
12536dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                                        pResponse[HCP_HEADER_LEN]: 0;
12546dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                    p_device_mgmt_info->p_val = NULL;
12556dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                }
12565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Self Test Commands */
12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_ANTENNA:
12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_SWP:
12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_NFCWI:
12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_PRBS:
12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->test_status = (uint8_t) ( length > HCP_HEADER_LEN ) ?
12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    pResponse[HCP_HEADER_LEN]: 0;
12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->test_result.buffer = (uint8_t)( length > HCP_HEADER_LEN ) ?
12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    &pResponse[HCP_HEADER_LEN]: NULL;
12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->test_result.length = ( length - HCP_HEADER_LEN );
12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI,
12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_RESPONSE);
12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NFCSTATUS_SUCCESS == status )
12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
12805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NULL != p_device_mgmt_info->p_pipe_info)
12815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
12825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->p_pipe_info->prev_status = NFCSTATUS_SUCCESS;
12835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
12845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_device_mgmt_info->current_seq = p_device_mgmt_info->next_seq;
12855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
12865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
12885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
12895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
12905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
12925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Receives the HCI Event from the corresponding peripheral device.
12935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
12945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function receives the HCI Event from the connected NFC
12955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Peripheral device.
12965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
12975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
12985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
12995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
13005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_DevMgmt_Event(
13015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *psContext,
13025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        void                *pHwRef,
13035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             *pEvent,
13045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN
13055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint8_t             length
13065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
13075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                        uint16_t            length
13085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
13095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
13105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
13115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_sContext_t         *psHciContext =
13125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (phHciNfc_sContext_t *)psContext ;
13135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t     *p_device_mgmt_info=NULL;
13145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Packet_t       *hcp_packet = NULL;
13155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Message_t      *hcp_message = NULL;
13165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
13175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHal_sEventInfo_t          event_info;
13185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                     event = (uint8_t) HCP_MSG_INSTRUCTION_INVALID;
13195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext) || (NULL == pHwRef) )
13215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
13235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if(  NULL == psHciContext->p_device_mgmt_info )
13255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
13275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
13285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
13295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
13305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
13315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                            psHciContext->p_device_mgmt_info ;
13325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        hcp_packet = (phHciNfc_HCP_Packet_t *)pEvent;
13335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        hcp_message = &hcp_packet->msg.message;
13345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        /* Get the Event instruction bits from the Message Header */
13365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        event = (uint8_t) GET_BITS8( hcp_message->msg_header,
13375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN);
13385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        event_info.eventHost = phHal_eHostController ;
13395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        event_info.eventSource = phHal_ePCD_DevType;
13405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
13415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch(event)
13425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
13435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Information Events */
13445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_EVT_INFO_TXLDO_OVERCUR:
13455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventType = NFC_INFO_TXLDO_OVERCUR;
13475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_EVT_INFO_PMUVCC:
13505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->pmuvcc_status = (uint8_t) ( length > HCP_HEADER_LEN ) ?
13525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    pEvent[HCP_HEADER_LEN]: 0;
13535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_EVT_INFO_EXT_RF_FIELD:
13565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventSource = phHal_ePICC_DevType ;
13585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->rf_status = (uint8_t) ( length > HCP_HEADER_LEN ) ?
13595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    pEvent[HCP_HEADER_LEN]: 0;
13605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef EVT_INFO_EXT_EVT_DIRECT
13615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventType = ( CE_EVT_NFC_FIELD_ON ==
13625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                (p_device_mgmt_info->rf_status & 0x1FU))?
13635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    NFC_EVT_FIELD_ON : NFC_EVT_FIELD_OFF;
13645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else
13655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventType = (TRUE == p_device_mgmt_info->rf_status)?
13665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    NFC_EVT_FIELD_ON : NFC_EVT_FIELD_OFF;
13675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif
13685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_EVT_INFO_MEM_VIOLATION:
13715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventType = NFC_INFO_MEM_VIOLATION;
1373113bdd7504d69f483c4208bc30a457b7ff4b69faSteve Block                ALOGW("Your NFC controller is kinda hosed, take it to npelly@ to fix");
13745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_EVT_INFO_TEMP_OVERHEAT:
13775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->overheat_status = (uint8_t)( length > HCP_HEADER_LEN ) ?
13795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    pEvent[HCP_HEADER_LEN]: 0;
13805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventType = NFC_INFO_TEMP_OVERHEAT;
13815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                event_info.eventInfo.overheat_status =
13825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    p_device_mgmt_info->overheat_status;
13835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13856dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren            case NXP_EVT_INFO_LLC_ERROR:
13866dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren            {
13876dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                event_info.eventType = NFC_INFO_LLC_ERROR;
13886dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren                break;
13896dd948323de0f31b413c9f19a905f1c145c9c456Rob von Behren            }
13905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
13915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
13925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL(CID_NFC_HCI,
13935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFCSTATUS_INVALID_HCI_RESPONSE);
13945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
13955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
13965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
13975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NFCSTATUS_SUCCESS == status )
13985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
13995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            if( NULL != p_device_mgmt_info->p_pipe_info)
14005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->p_pipe_info->prev_status =
14025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                    NFCSTATUS_SUCCESS;
14035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_device_mgmt_info->current_seq =
14055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        p_device_mgmt_info->next_seq;
14065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            phHciNfc_Notify_Event(psHciContext, pHwRef,
14075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        NFC_NOTIFY_EVENT, &event_info);
14085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
14095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
14115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
14125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
14155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS
14165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_DevMgmt_InfoUpdate(
14175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t     *psHciContext,
14185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHal_sHwReference_t    *pHwRef,
14195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 index,
14205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 *reg_value,
14215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t                 reg_length
14225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                          )
14235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{
14245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_DevMgmt_Info_t *p_device_mgmt_info=NULL;
14255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS               status = NFCSTATUS_SUCCESS;
14265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 i=0;
14275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    PHNFC_UNUSED_VARIABLE(pHwRef);
14295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext)
14305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (NULL == reg_value)
14315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || (reg_length == 0)
14325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      )
14335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
14355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else if ( NULL == psHciContext->p_device_mgmt_info )
14375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
14395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
14415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_device_mgmt_info = (phHciNfc_DevMgmt_Info_t *)
14435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_device_mgmt_info ;
14445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch(index)
14465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
14475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case DEVICE_INFO_EEPROM_INDEX:
14485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                p_device_mgmt_info->eeprom_crc = reg_value[i];
14505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
14535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
14545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
14555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
14565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
14575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    } /* End of Context and the PN544 Device information validity check */
14595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
14615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
14625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
14665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the RF Settings HCI Additonal Commands to the connected
14675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * reader device.
14685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
14695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Sends the RF Settings HCI Command frames in the HCP packet
14705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * format to the connected reader device.
14715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
14725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
14735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
14745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_DevMgmt_Command (
14755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
14765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
14775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             pipe_id,
14785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             cmd
14795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
14805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {
14815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Packet_t   *hcp_packet = NULL;
14825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Message_t  *hcp_message = NULL;
14835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t    *p_pipe_info = NULL;
14845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 length=0;
14855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 i = 0;
14865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS               status = NFCSTATUS_SUCCESS;
14875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
14885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext)
14895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( pipe_id > PHHCINFC_MAX_PIPE)
14905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(NULL == psHciContext->p_pipe_list[pipe_id])
14915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      )
14925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
14945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        HCI_DEBUG("%s: Invalid Arguments passed \n",
14955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                "phHciNfc_Send_DevMgmt_Command");
14965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
14975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
14985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
14995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = (phHciNfc_Pipe_Info_t *)
15005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_pipe_list[pipe_id];
15015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        psHciContext->tx_total = 0 ;
15025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        length +=  HCP_HEADER_LEN ;
15035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        switch( cmd )
15045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
15055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Self Test Commands */
15065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_ANTENNA:
15075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_SWP:
15085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_NFCWI:
15095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_SELF_TEST_PRBS:
15105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Internal Properietary Commands */
15115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_DBG_READ:
15125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            case NXP_DBG_WRITE:
15135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
15165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Construct the HCP Frame */
15175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
15185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        (uint8_t) pipe_id, HCP_MSG_TYPE_COMMAND, cmd);
15195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                hcp_message = &(hcp_packet->msg.message);
15205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                /* Append the RF Setting Parameter also the optional Value */
15215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
15225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            i, p_pipe_info->param_info,
15235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            p_pipe_info->param_length);
15245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                length =(uint8_t)(length + i + p_pipe_info->param_length);
15255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
15265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
15275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            default:
15285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            {
15295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED );
15305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                HCI_DEBUG("%s: Statement Should Not Occur \n",
15315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                "phHciNfc_Send_DevMgmt_Command");
15325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                break;
15335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            }
15345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
15355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NFCSTATUS_SUCCESS == status )
15365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
15375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->sent_msg_type = HCP_MSG_TYPE_COMMAND;
15385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_msg = cmd;
15395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->tx_total = length;
15405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->response_pending = TRUE ;
15415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Send the Constructed HCP packet to the lower layer */
15435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_HCP( psHciContext, pHwRef );
15445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_status = NFCSTATUS_PENDING;
15455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
15465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
15475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
15495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
15505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*!
15545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Sends the RF Settings HCI Additonal Events to the connected
15555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * reader device.
15565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *
15575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Sends the RF Settings HCI Events frames in the HCP packet
15585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * format to the connected reader device.
15595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */
15605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic
15625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS
15635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Send_DevMgmt_Event (
15645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                phHciNfc_sContext_t *psHciContext,
15655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                void                *pHwRef,
15665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             pipe_id,
15675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                uint8_t             event
15685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                    )
15695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {
15705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Packet_t   *hcp_packet = NULL;
15715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_HCP_Message_t  *hcp_message = NULL;
15725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    phHciNfc_Pipe_Info_t    *p_pipe_info = NULL;
15735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 length=0;
15745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    uint8_t                 i = 0;
15755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    NFCSTATUS               status = NFCSTATUS_SUCCESS;
15765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    if( (NULL == psHciContext)
15785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        || ( pipe_id > PHHCINFC_MAX_PIPE)
15795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        ||(NULL == psHciContext->p_pipe_list[pipe_id])
15805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly      )
15815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
15825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
15835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        HCI_DEBUG("%s: Invalid Arguments passed \n",
15845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                                "phHciNfc_Send_DevMgmt_Event");
15855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
15865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    else
15875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    {
15885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        p_pipe_info = (phHciNfc_Pipe_Info_t *)
15895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                psHciContext->p_pipe_list[pipe_id];
15905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        psHciContext->tx_total = 0 ;
15915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        length +=  HCP_HEADER_LEN ;
15925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NXP_EVT_SET_AUTONOMOUS == event )
15935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
15945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
15955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer;
15965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Construct the HCP Frame */
15975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT,
15985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                    (uint8_t) pipe_id, HCP_MSG_TYPE_EVENT, event);
15995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            hcp_message = &(hcp_packet->msg.message);
16005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Append the RF Setting Parameter also the optional Value */
16015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            phHciNfc_Append_HCPFrame((uint8_t *)hcp_message->payload,
16025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        i, p_pipe_info->param_info,
16035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                        p_pipe_info->param_length);
16045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            length =(uint8_t)(length + i + p_pipe_info->param_length);
16055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
16065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        else
16075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
16085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED );
16095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            HCI_DEBUG("%s: Statement Should Not Occur \n",
16105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly                                            "phHciNfc_Send_DevMgmt_Event");
16115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
16125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        if( NFCSTATUS_SUCCESS == status )
16135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        {
16145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->sent_msg_type = HCP_MSG_TYPE_EVENT;
16155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_msg = event;
16165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            psHciContext->tx_total = length;
16175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            /* Send the Constructed HCP packet to the lower layer */
16195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            status = phHciNfc_Send_HCP( psHciContext, pHwRef );
16205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly            p_pipe_info->prev_status = NFCSTATUS_PENDING;
16215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly        }
16225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    }
16235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly    return status;
16255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly}
16265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
16305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly
1631