nfc_hal_int_api.h revision ba4c17ee1d31e1b9f396292711f1414d449dd361
1/****************************************************************************** 2 * 3 * Copyright (C) 2009-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19/****************************************************************************** 20 * 21 * Internal NFC HAL API functions. 22 * 23 ******************************************************************************/ 24#ifndef NFC_HAL_INT_API_H 25#define NFC_HAL_INT_API_H 26 27/**************************************************************************** 28** Device Configuration definitions 29****************************************************************************/ 30 31#define NFC_HAL_PLL_325_SETCONFIG_PARAM_LEN (2 + NCI_PARAM_LEN_PLL325_CFG_PARAM) 32 33/* Crystal Frequency Index (in 1 KHz) */ 34enum 35{ 36 NFC_HAL_XTAL_INDEX_9600, 37 NFC_HAL_XTAL_INDEX_13000, 38 NFC_HAL_XTAL_INDEX_16200, 39 NFC_HAL_XTAL_INDEX_19200, 40 NFC_HAL_XTAL_INDEX_24000, 41 NFC_HAL_XTAL_INDEX_26000, 42 NFC_HAL_XTAL_INDEX_38400, 43 NFC_HAL_XTAL_INDEX_52000, 44 NFC_HAL_XTAL_INDEX_37400, 45 NFC_HAL_XTAL_INDEX_MAX 46}; 47typedef UINT8 tNFC_HAL_XTAL_INDEX; 48 49/* Broadcom specific device initialization before sending NCI reset */ 50#define NFC_HAL_DEV_INIT_FLAGS_SET_XTAL_FREQ 0x02 /* set crystal frequency */ 51typedef UINT8 tNFC_HAL_DEV_INIT_FLAGS; 52 53typedef struct 54{ 55 tNFC_HAL_DEV_INIT_FLAGS flags; 56 UINT16 xtal_freq; 57} tNFC_HAL_DEV_INIT_CFG; 58 59/***************************************************************************** 60** Low Power Mode definitions 61*****************************************************************************/ 62 63#define NFC_HAL_LP_SNOOZE_MODE_NONE NFC_SNOOZE_MODE_NONE /* Snooze mode disabled */ 64#define NFC_HAL_LP_SNOOZE_MODE_UART NFC_SNOOZE_MODE_UART /* Snooze mode for UART */ 65#define NFC_HAL_LP_SNOOZE_MODE_SPI_I2C NFC_SNOOZE_MODE_SPI_I2C /* Snooze mode for SPI/I2C */ 66 67#define NFC_HAL_LP_ACTIVE_LOW NFC_SNOOZE_ACTIVE_LOW /* high to low voltage is asserting */ 68#define NFC_HAL_LP_ACTIVE_HIGH NFC_SNOOZE_ACTIVE_HIGH /* low to high voltage is asserting */ 69 70/***************************************************************************** 71** Patch RAM Constants 72*****************************************************************************/ 73 74/* patch format type */ 75#define NFC_HAL_PRM_FORMAT_BIN 0x00 76#define NFC_HAL_PRM_FORMAT_HCD 0x01 77#define NFC_HAL_PRM_FORMAT_NCD 0x02 78typedef UINT8 tNFC_HAL_PRM_FORMAT; 79 80/***************************************************************************** 81** Patch RAM Callback for event notificaton 82*****************************************************************************/ 83/* Events for tNFC_HAL_PRM_CBACK */ 84enum 85{ 86 NFC_HAL_PRM_CONTINUE_EVT, 87 NFC_HAL_PRM_COMPLETE_EVT, 88 NFC_HAL_PRM_ABORT_EVT, 89 NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT, /* Patch is invalid (bad version, project id, or chip) */ 90 NFC_HAL_PRM_ABORT_BAD_SIGNATURE_EVT, /* Patch has invalid signature */ 91 NFC_HAL_PRM_SPD_GET_PATCHFILE_HDR_EVT, /* Secure Patch Download: request for patchfile header */ 92 NFC_HAL_PRM_SPD_GET_NEXT_PATCH /* Get first command of next patch in patchfile */ 93}; 94 95typedef void (tNFC_HAL_PRM_CBACK) (UINT8 event); 96 97 98#ifdef __cplusplus 99extern "C" { 100#endif 101 102/******************************************************************************* 103** 104** Function HAL_NfcPreInitDone 105** 106** Description Notify that pre-initialization of NFCC is complete 107** 108** Returns void 109** 110*******************************************************************************/ 111void HAL_NfcPreInitDone (tHAL_NFC_STATUS status); 112 113/******************************************************************************* 114** 115** Function HAL_NfcSetSnoozeMode 116** 117** Description Set snooze mode 118** snooze_mode 119** NFC_HAL_LP_SNOOZE_MODE_NONE - Snooze mode disabled 120** NFC_HAL_LP_SNOOZE_MODE_UART - Snooze mode for UART 121** NFC_HAL_LP_SNOOZE_MODE_SPI_I2C - Snooze mode for SPI/I2C 122** 123** idle_threshold_dh/idle_threshold_nfcc 124** Idle Threshold Host in 100ms unit 125** 126** nfc_wake_active_mode/dh_wake_active_mode 127** NFC_HAL_LP_ACTIVE_LOW - high to low voltage is asserting 128** NFC_HAL_LP_ACTIVE_HIGH - low to high voltage is asserting 129** 130** p_snooze_cback 131** Notify status of operation 132** 133** Returns tHAL_NFC_STATUS 134** 135*******************************************************************************/ 136tHAL_NFC_STATUS HAL_NfcSetSnoozeMode (UINT8 snooze_mode, 137 UINT8 idle_threshold_dh, 138 UINT8 idle_threshold_nfcc, 139 UINT8 nfc_wake_active_mode, 140 UINT8 dh_wake_active_mode, 141 tHAL_NFC_STATUS_CBACK *p_snooze_cback); 142 143/******************************************************************************* 144** 145** Function HAL_NfcPrmDownloadStart 146** 147** Description Initiate patch download 148** 149** Input Params 150** format_type patch format type 151** (NFC_HAL_PRM_FORMAT_BIN, NFC_HAL_PRM_FORMAT_HCD, or 152** NFC_HAL_PRM_FORMAT_NCD) 153** 154** dest_address destination adderess (needed for BIN format only) 155** 156** p_patchram_buf pointer to patchram buffer. If NULL, 157** then app must call HAL_NfcPrmDownloadContinue when 158** NFC_HAL_PRM_CONTINUE_EVT is received, to send the next 159** segment of patchram 160** 161** patchram_len size of p_patchram_buf (if non-NULL) 162** 163** patchram_delay The delay after each patch. 164** If the given value is less than the size of the patchram, 165** the size of patchram is used instead. 166** 167** p_cback callback for download status 168** 169** 170** Returns TRUE if successful, otherwise FALSE 171** 172** 173*******************************************************************************/ 174BOOLEAN HAL_NfcPrmDownloadStart (tNFC_HAL_PRM_FORMAT format_type, 175 UINT32 dest_address, 176 UINT8 *p_patchram_buf, 177 UINT32 patchram_len, 178 UINT32 patchram_delay, 179 tNFC_HAL_PRM_CBACK *p_cback); 180 181/******************************************************************************* 182** 183** Function HAL_NfcPrmDownloadContinue 184** 185** Description Send next segment of patchram to controller. Called when 186** NFC_HAL_PRM_CONTINUE_EVT is received. 187** 188** Only needed if HAL_NfcPrmDownloadStart was called with 189** p_patchram_buf=NULL 190** 191** Input Params p_patch_data pointer to patch data 192** patch_data_len patch data len 193** 194** Returns TRUE if successful, otherwise FALSE 195** 196*******************************************************************************/ 197BOOLEAN HAL_NfcPrmDownloadContinue (UINT8 *p_patch_data, 198 UINT16 patch_data_len); 199 200/******************************************************************************* 201** 202** Function HAL_NfcPrmSetI2cPatch 203** 204** Description Specify patchfile for BCM20791B3 I2C fix. This fix 205** must be downloaded prior to initial patch download for I2C 206** transport 207** 208** Input Params p_i2c_patchfile_buf: pointer to patch for i2c fix 209** i2c_patchfile_len: length of patch 210** prei2c_delay: the delay before downloading main patch 211** if 0 is given, NFC_HAL_PRM_POST_I2C_FIX_DELAY is used instead. 212** 213** Returns Nothing 214** 215** 216*******************************************************************************/ 217void HAL_NfcPrmSetI2cPatch (UINT8 *p_i2c_patchfile_buf, 218 UINT16 i2c_patchfile_len, UINT32 prei2c_delay); 219 220/******************************************************************************* 221** 222** Function HAL_NfcPrmSetSpdNciCmdPayloadSize 223** 224** Description Set Host-to-NFCC NCI message size for secure patch download 225** 226** This API must be called before calling HAL_NfcPrmDownloadStart. 227** If the API is not called, then PRM will use the default 228** message size. 229** 230** Typically, this API is only called for platforms that have 231** message-size limitations in the transport/driver. 232** 233** Valid message size range: NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE to 255. 234** 235** Returns HAL_NFC_STATUS_OK if successful 236** HAL_NFC_STATUS_FAILED otherwise 237** 238** 239*******************************************************************************/ 240tHAL_NFC_STATUS HAL_NfcPrmSetSpdNciCmdPayloadSize (UINT8 max_payload_size); 241 242/******************************************************************************* 243** 244** Function HAL_NfcSetMaxRfDataCredits 245** 246** Description This function sets the maximum RF data credit for HAL. 247** If 0, use the value reported from NFCC. 248** 249** Returns none 250** 251*******************************************************************************/ 252void HAL_NfcSetMaxRfDataCredits (UINT8 max_credits); 253 254/******************************************************************************* 255** 256** Function HAL_NfcSetTraceLevel 257** 258** Description This function sets the trace level for HAL. If called with 259** a value of 0xFF, it simply returns the current trace level. 260** 261** Returns The new or current trace level 262** 263*******************************************************************************/ 264UINT8 HAL_NfcSetTraceLevel (UINT8 new_level); 265 266 267#ifdef __cplusplus 268} 269#endif 270 271#endif /* NFC_HAL_INT_API_H */ 272 273