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) */ 34 enum 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 }; 47 typedef 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 */ 51 typedef UINT8 tNFC_HAL_DEV_INIT_FLAGS; 52 53 typedef 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 78 typedef UINT8 tNFC_HAL_PRM_FORMAT; 79 80 /***************************************************************************** 81 ** Patch RAM Callback for event notificaton 82 *****************************************************************************/ 83 /* Events for tNFC_HAL_PRM_CBACK */ 84 enum 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 NFC_HAL_PRM_ABORT_NO_NVM_EVT /* nfc_hal_prm_nvm_required is TRUE and NVM is unavail */ 94 }; 95 96 typedef void (tNFC_HAL_PRM_CBACK) (UINT8 event); 97 98 typedef UINT8 tNFC_HAL_NCI_EVT; /* MT + Opcode */ 99 typedef void (tNFC_HAL_NCI_CBACK) (tNFC_HAL_NCI_EVT event, UINT16 data_len, UINT8 *p_data); 100 101 #ifdef __cplusplus 102 extern "C" { 103 #endif 104 105 /******************************************************************************* 106 ** 107 ** Function HAL_NfcPreInitDone 108 ** 109 ** Description Notify that pre-initialization of NFCC is complete 110 ** 111 ** Returns void 112 ** 113 *******************************************************************************/ 114 void HAL_NfcPreInitDone (tHAL_NFC_STATUS status); 115 116 /******************************************************************************* 117 ** 118 ** Function HAL_NfcReInit 119 ** 120 ** Description This function is called to send an RESET and GET_PATCH_VERSION 121 ** command to NFCC. 122 ** 123 ** p_cback - The callback function to receive the command 124 ** status 125 ** 126 ** Note This function should be called only during the HAL init process 127 ** 128 ** Returns HAL_NFC_STATUS_OK if successfully initiated 129 ** HAL_NFC_STATUS_FAILED otherwise 130 ** 131 *******************************************************************************/ 132 tHAL_NFC_STATUS HAL_NfcReInit (tNFC_HAL_NCI_CBACK *p_cback); 133 134 /******************************************************************************* 135 ** 136 ** Function HAL_NfcSetSnoozeMode 137 ** 138 ** Description Set snooze mode 139 ** snooze_mode 140 ** NFC_HAL_LP_SNOOZE_MODE_NONE - Snooze mode disabled 141 ** NFC_HAL_LP_SNOOZE_MODE_UART - Snooze mode for UART 142 ** NFC_HAL_LP_SNOOZE_MODE_SPI_I2C - Snooze mode for SPI/I2C 143 ** 144 ** idle_threshold_dh/idle_threshold_nfcc 145 ** Idle Threshold Host in 100ms unit 146 ** 147 ** nfc_wake_active_mode/dh_wake_active_mode 148 ** NFC_HAL_LP_ACTIVE_LOW - high to low voltage is asserting 149 ** NFC_HAL_LP_ACTIVE_HIGH - low to high voltage is asserting 150 ** 151 ** p_snooze_cback 152 ** Notify status of operation 153 ** 154 ** Returns tHAL_NFC_STATUS 155 ** 156 *******************************************************************************/ 157 tHAL_NFC_STATUS HAL_NfcSetSnoozeMode (UINT8 snooze_mode, 158 UINT8 idle_threshold_dh, 159 UINT8 idle_threshold_nfcc, 160 UINT8 nfc_wake_active_mode, 161 UINT8 dh_wake_active_mode, 162 tHAL_NFC_STATUS_CBACK *p_snooze_cback); 163 164 /******************************************************************************* 165 ** 166 ** Function HAL_NfcPrmDownloadStart 167 ** 168 ** Description Initiate patch download 169 ** 170 ** Input Params 171 ** format_type patch format type 172 ** (NFC_HAL_PRM_FORMAT_BIN, NFC_HAL_PRM_FORMAT_HCD, or 173 ** NFC_HAL_PRM_FORMAT_NCD) 174 ** 175 ** dest_address destination adderess (needed for BIN format only) 176 ** 177 ** p_patchram_buf pointer to patchram buffer. If NULL, 178 ** then app must call HAL_NfcPrmDownloadContinue when 179 ** NFC_HAL_PRM_CONTINUE_EVT is received, to send the next 180 ** segment of patchram 181 ** 182 ** patchram_len size of p_patchram_buf (if non-NULL) 183 ** 184 ** patchram_delay The delay after each patch. 185 ** If the given value is less than the size of the patchram, 186 ** the size of patchram is used instead. 187 ** 188 ** p_cback callback for download status 189 ** 190 ** 191 ** Returns TRUE if successful, otherwise FALSE 192 ** 193 ** 194 *******************************************************************************/ 195 BOOLEAN HAL_NfcPrmDownloadStart (tNFC_HAL_PRM_FORMAT format_type, 196 UINT32 dest_address, 197 UINT8 *p_patchram_buf, 198 UINT32 patchram_len, 199 UINT32 patchram_delay, 200 tNFC_HAL_PRM_CBACK *p_cback); 201 202 /******************************************************************************* 203 ** 204 ** Function HAL_NfcPrmDownloadContinue 205 ** 206 ** Description Send next segment of patchram to controller. Called when 207 ** NFC_HAL_PRM_CONTINUE_EVT is received. 208 ** 209 ** Only needed if HAL_NfcPrmDownloadStart was called with 210 ** p_patchram_buf=NULL 211 ** 212 ** Input Params p_patch_data pointer to patch data 213 ** patch_data_len patch data len 214 ** 215 ** Returns TRUE if successful, otherwise FALSE 216 ** 217 *******************************************************************************/ 218 BOOLEAN HAL_NfcPrmDownloadContinue (UINT8 *p_patch_data, 219 UINT16 patch_data_len); 220 221 /******************************************************************************* 222 ** 223 ** Function HAL_NfcPrmSetI2cPatch 224 ** 225 ** Description Specify patchfile for BCM20791B3 I2C fix. This fix 226 ** must be downloaded prior to initial patch download for I2C 227 ** transport 228 ** 229 ** Input Params p_i2c_patchfile_buf: pointer to patch for i2c fix 230 ** i2c_patchfile_len: length of patch 231 ** prei2c_delay: the delay before downloading main patch 232 ** if 0 is given, NFC_HAL_PRM_POST_I2C_FIX_DELAY is used instead. 233 ** 234 ** Returns Nothing 235 ** 236 ** 237 *******************************************************************************/ 238 void HAL_NfcPrmSetI2cPatch (UINT8 *p_i2c_patchfile_buf, 239 UINT16 i2c_patchfile_len, UINT32 prei2c_delay); 240 241 /******************************************************************************* 242 ** 243 ** Function HAL_NfcPrmSetSpdNciCmdPayloadSize 244 ** 245 ** Description Set Host-to-NFCC NCI message size for secure patch download 246 ** 247 ** This API must be called before calling HAL_NfcPrmDownloadStart. 248 ** If the API is not called, then PRM will use the default 249 ** message size. 250 ** 251 ** Typically, this API is only called for platforms that have 252 ** message-size limitations in the transport/driver. 253 ** 254 ** Valid message size range: NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE to 255. 255 ** 256 ** Returns HAL_NFC_STATUS_OK if successful 257 ** HAL_NFC_STATUS_FAILED otherwise 258 ** 259 ** 260 *******************************************************************************/ 261 tHAL_NFC_STATUS HAL_NfcPrmSetSpdNciCmdPayloadSize (UINT8 max_payload_size); 262 263 /******************************************************************************* 264 ** 265 ** Function HAL_NfcSetMaxRfDataCredits 266 ** 267 ** Description This function sets the maximum RF data credit for HAL. 268 ** If 0, use the value reported from NFCC. 269 ** 270 ** Returns none 271 ** 272 *******************************************************************************/ 273 void HAL_NfcSetMaxRfDataCredits (UINT8 max_credits); 274 275 /******************************************************************************* 276 ** 277 ** Function HAL_NfcSetTraceLevel 278 ** 279 ** Description This function sets the trace level for HAL. If called with 280 ** a value of 0xFF, it simply returns the current trace level. 281 ** 282 ** Returns The new or current trace level 283 ** 284 *******************************************************************************/ 285 UINT8 HAL_NfcSetTraceLevel (UINT8 new_level); 286 287 288 #ifdef __cplusplus 289 } 290 #endif 291 292 #endif /* NFC_HAL_INT_API_H */ 293 294