1 /****************************************************************************** 2 * 3 * Copyright (C) 1999-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 #ifndef NFC_TARGET_H 20 #define NFC_TARGET_H 21 22 #include "data_types.h" 23 24 #ifdef BUILDCFG 25 #include "buildcfg.h" 26 #endif 27 28 /* Include common GKI definitions used by this platform */ 29 #include "bt_types.h" /* This must be defined AFTER buildcfg.h */ 30 #include "gki_target.h" 31 32 #ifndef USERIAL_DEBUG 33 #define USERIAL_DEBUG FALSE 34 #endif 35 36 /****************************************************************************** 37 ** 38 ** GKI Mail Box and Timer 39 ** 40 ******************************************************************************/ 41 42 /* Mailbox event mask for NFC stack */ 43 #ifndef NFC_MBOX_EVT_MASK 44 #define NFC_MBOX_EVT_MASK (TASK_MBOX_0_EVT_MASK) 45 #endif 46 47 /* Mailbox ID for NFC stack */ 48 #ifndef NFC_MBOX_ID 49 #define NFC_MBOX_ID (TASK_MBOX_0) 50 #endif 51 52 /* Mailbox event mask for NFA */ 53 #ifndef NFA_MBOX_EVT_MASK 54 #define NFA_MBOX_EVT_MASK (TASK_MBOX_2_EVT_MASK) 55 #endif 56 57 /* Mailbox ID for NFA */ 58 #ifndef NFA_MBOX_ID 59 #define NFA_MBOX_ID (TASK_MBOX_2) 60 #endif 61 62 /* GKI timer id used for protocol timer in NFC stack */ 63 #ifndef NFC_TIMER_ID 64 #define NFC_TIMER_ID (TIMER_0) 65 #endif 66 67 /* GKI timer event mask used for protocol timer in NFC stack */ 68 #ifndef NFC_TIMER_EVT_MASK 69 #define NFC_TIMER_EVT_MASK (TIMER_0_EVT_MASK) 70 #endif 71 72 /* GKI timer id used for quick timer in NFC stack */ 73 #ifndef NFC_QUICK_TIMER_ID 74 #define NFC_QUICK_TIMER_ID (TIMER_1) 75 #endif 76 77 /* GKI timer event mask used for quick timer in NFC stack */ 78 #ifndef NFC_QUICK_TIMER_EVT_MASK 79 #define NFC_QUICK_TIMER_EVT_MASK (TIMER_1_EVT_MASK) 80 #endif 81 82 /* GKI timer id used for protocol timer in NFA */ 83 #ifndef NFA_TIMER_ID 84 #define NFA_TIMER_ID (TIMER_2) 85 #endif 86 87 /* GKI timer event mask used for protocol timer in NFA */ 88 #ifndef NFA_TIMER_EVT_MASK 89 #define NFA_TIMER_EVT_MASK (TIMER_2_EVT_MASK) 90 #endif 91 92 /****************************************************************************** 93 ** 94 ** GKI Buffer Pools 95 ** 96 ******************************************************************************/ 97 98 /* NCI command/notification/data */ 99 #ifndef NFC_NCI_POOL_ID 100 #define NFC_NCI_POOL_ID GKI_POOL_ID_2 101 #endif 102 103 #ifndef NFC_NCI_POOL_BUF_SIZE 104 #define NFC_NCI_POOL_BUF_SIZE GKI_BUF2_SIZE 105 #endif 106 107 /* Reader/Write commands (NCI data payload) */ 108 #ifndef NFC_RW_POOL_ID 109 #define NFC_RW_POOL_ID GKI_POOL_ID_2 110 #endif 111 112 #ifndef NFC_RW_POOL_BUF_SIZE 113 #define NFC_RW_POOL_BUF_SIZE GKI_BUF2_SIZE 114 #endif 115 116 /* Card Emulation responses (NCI data payload) */ 117 #ifndef NFC_CE_POOL_ID 118 #define NFC_CE_POOL_ID GKI_POOL_ID_2 119 #endif 120 121 #ifndef NFC_CE_POOL_BUF_SIZE 122 #define NFC_CE_POOL_BUF_SIZE GKI_BUF2_SIZE 123 #endif 124 125 /* NCI msg pool for HAL (for shared NFC/HAL GKI)*/ 126 #ifndef NFC_HAL_NCI_POOL_ID 127 #define NFC_HAL_NCI_POOL_ID NFC_NCI_POOL_ID 128 #endif 129 130 #ifndef NFC_HAL_NCI_POOL_BUF_SIZE 131 #define NFC_HAL_NCI_POOL_BUF_SIZE NFC_NCI_POOL_BUF_SIZE 132 #endif 133 134 /****************************************************************************** 135 ** 136 ** NCI Transport definitions 137 ** 138 ******************************************************************************/ 139 /* offset of the first NCI packet in buffer for outgoing */ 140 #ifndef NCI_MSG_OFFSET_SIZE 141 #define NCI_MSG_OFFSET_SIZE 1 142 #endif 143 144 /* Restore NFCC baud rate to default on shutdown if NFC_UpdateBaudRate was 145 * called */ 146 #ifndef NFC_RESTORE_BAUD_ON_SHUTDOWN 147 #define NFC_RESTORE_BAUD_ON_SHUTDOWN TRUE 148 #endif 149 150 /****************************************************************************** 151 ** 152 ** NCI 153 ** 154 ******************************************************************************/ 155 #define NCI_VERSION_UNKNOWN 0x00 156 #define NCI_VERSION_1_0 0x10 157 #define NCI_VERSION_2_0 0x20 158 #ifndef NCI_VERSION 159 #define NCI_VERSION NCI_VERSION_2_0 160 #endif 161 #define NCI_CORE_RESET_RSP_LEN(X) (((X) >= NCI_VERSION_2_0) ? (0x01) : (0x03)) 162 163 /* TRUE I2C patch is needed */ 164 #ifndef NFC_I2C_PATCH_INCLUDED 165 #define NFC_I2C_PATCH_INCLUDED TRUE /* NFC-Android uses this!!! */ 166 #endif 167 168 /****************************************************************************** 169 ** 170 ** NFC 171 ** 172 ******************************************************************************/ 173 174 /* Define to TRUE to include Broadcom Vendor Specific implementation */ 175 #ifndef NFC_BRCM_VS_INCLUDED 176 #define NFC_BRCM_VS_INCLUDED TRUE 177 #endif 178 179 /* Define to TRUE if compling for NFC Reader/Writer Only mode */ 180 #ifndef NFC_RW_ONLY 181 #define NFC_RW_ONLY FALSE 182 #endif 183 184 /* Timeout for receiving response to NCI command */ 185 #ifndef NFC_CMD_CMPL_TIMEOUT 186 #define NFC_CMD_CMPL_TIMEOUT 2 187 #endif 188 189 /* Timeout for waiting on data credit/NFC-DEP */ 190 #ifndef NFC_DEACTIVATE_TIMEOUT 191 #define NFC_DEACTIVATE_TIMEOUT 2 192 #endif 193 194 /* the maximum number of Vendor Specific callback functions allowed to be 195 * registered. 1-14 */ 196 #ifndef NFC_NUM_VS_CBACKS 197 #define NFC_NUM_VS_CBACKS 3 198 #endif 199 200 /* the maximum number of NCI connections allowed. 1-14 */ 201 #ifndef NCI_MAX_CONN_CBS 202 #define NCI_MAX_CONN_CBS 4 203 #endif 204 205 /* Maximum number of NCI commands that the NFCC accepts without needing to wait 206 * for response */ 207 #ifndef NCI_MAX_CMD_WINDOW 208 #define NCI_MAX_CMD_WINDOW 1 209 #endif 210 211 /* Define to TRUE to include the NFCEE related functionalities */ 212 #ifndef NFC_NFCEE_INCLUDED 213 #define NFC_NFCEE_INCLUDED TRUE 214 #endif 215 216 /* the maximum number of NFCEE interface supported */ 217 #ifndef NFC_MAX_EE_INTERFACE 218 #define NFC_MAX_EE_INTERFACE 3 219 #endif 220 221 /* the maximum number of NFCEE information supported. */ 222 #ifndef NFC_MAX_EE_INFO 223 #define NFC_MAX_EE_INFO 8 224 #endif 225 226 /* the maximum number of NFCEE TLVs supported */ 227 #ifndef NFC_MAX_EE_TLVS 228 #define NFC_MAX_EE_TLVS 1 229 #endif 230 231 /* the maximum size of NFCEE TLV list supported */ 232 #ifndef NFC_MAX_EE_TLV_SIZE 233 #define NFC_MAX_EE_TLV_SIZE 150 234 #endif 235 236 /* Maximum time to discover NFCEE */ 237 #ifndef NFA_EE_DISCV_TIMEOUT_VAL 238 #define NFA_EE_DISCV_TIMEOUT_VAL 2000 239 #endif 240 241 /* Number of times reader/writer should attempt to resend a command on failure 242 */ 243 #ifndef RW_MAX_RETRIES 244 #define RW_MAX_RETRIES 5 245 #endif 246 247 /* RW NDEF Support */ 248 #ifndef RW_NDEF_INCLUDED 249 #define RW_NDEF_INCLUDED TRUE 250 #endif 251 252 /* RW Type 1 Tag timeout for each API call, in ms */ 253 #ifndef RW_T1T_TOUT_RESP 254 #define RW_T1T_TOUT_RESP 100 255 #endif 256 257 /* CE Type 2 Tag timeout for controller command, in ms */ 258 #ifndef CE_T2T_TOUT_RESP 259 #define CE_T2T_TOUT_RESP 1000 260 #endif 261 262 /* RW Type 2 Tag timeout for each API call, in ms */ 263 #ifndef RW_T2T_TOUT_RESP 264 /* Android requires 150 instead of 100 for presence-check*/ 265 #define RW_T2T_TOUT_RESP 150 266 #endif 267 268 /* RW Type 2 Tag timeout for each API call, in ms */ 269 #ifndef RW_T2T_SEC_SEL_TOUT_RESP 270 #define RW_T2T_SEC_SEL_TOUT_RESP 10 271 #endif 272 273 /* RW Type 3 Tag timeout for each API call, in ms */ 274 #ifndef RW_T3T_TOUT_RESP 275 /* NFC-Android will use 100 instead of 75 for T3t presence-check */ 276 #define RW_T3T_TOUT_RESP 100 277 #endif 278 279 /* CE Type 3 Tag maximum response timeout index (for check and update, used in 280 * SENSF_RES) */ 281 #ifndef CE_T3T_MRTI_C 282 #define CE_T3T_MRTI_C 0xFF 283 #endif 284 #ifndef CE_T3T_MRTI_U 285 #define CE_T3T_MRTI_U 0xFF 286 #endif 287 288 /* Default maxblocks for CE_T3T UPDATE/CHECK operations */ 289 #ifndef CE_T3T_DEFAULT_UPDATE_MAXBLOCKS 290 #define CE_T3T_DEFAULT_UPDATE_MAXBLOCKS 3 291 #endif 292 293 #ifndef CE_T3T_DEFAULT_CHECK_MAXBLOCKS 294 #define CE_T3T_DEFAULT_CHECK_MAXBLOCKS 3 295 #endif 296 297 /* CE Type 4 Tag, Frame Waiting time Integer */ 298 #ifndef CE_T4T_ISO_DEP_FWI 299 #define CE_T4T_ISO_DEP_FWI 7 300 #endif 301 302 /* RW Type 4 Tag timeout for each API call, in ms */ 303 #ifndef RW_T4T_TOUT_RESP 304 #define RW_T4T_TOUT_RESP 1000 305 #endif 306 307 /* CE Type 4 Tag timeout for update file, in ms */ 308 #ifndef CE_T4T_TOUT_UPDATE 309 #define CE_T4T_TOUT_UPDATE 1000 310 #endif 311 312 /* CE Type 4 Tag, mandatory NDEF File ID */ 313 #ifndef CE_T4T_MANDATORY_NDEF_FILE_ID 314 #define CE_T4T_MANDATORY_NDEF_FILE_ID 0x1000 315 #endif 316 317 /* CE Type 4 Tag, max number of AID supported */ 318 #ifndef CE_T4T_MAX_REG_AID 319 #define CE_T4T_MAX_REG_AID 4 320 #endif 321 322 /* Sub carrier */ 323 #ifndef RW_I93_FLAG_SUB_CARRIER 324 #define RW_I93_FLAG_SUB_CARRIER I93_FLAG_SUB_CARRIER_SINGLE 325 #endif 326 327 /* Data rate for 15693 command/response */ 328 #ifndef RW_I93_FLAG_DATA_RATE 329 #define RW_I93_FLAG_DATA_RATE I93_FLAG_DATA_RATE_HIGH 330 #endif 331 332 /* RW Mifare Classic Tag timeout for each API call, in ms */ 333 #ifndef RW_MFC_TOUT_RESP 334 #define RW_MFC_TOUT_RESP 300 335 #endif 336 337 /* TRUE, to include Card Emulation related test commands */ 338 #ifndef CE_TEST_INCLUDED 339 #define CE_TEST_INCLUDED FALSE 340 #endif 341 342 /* Quick Timer */ 343 #ifndef QUICK_TIMER_TICKS_PER_SEC 344 #define QUICK_TIMER_TICKS_PER_SEC 100 /* 10ms timer */ 345 #endif 346 347 /****************************************************************************** 348 ** 349 ** NFA 350 ** 351 ******************************************************************************/ 352 353 /* Maximum Idle time (no hcp) to wait for EE DISC REQ Ntf(s) */ 354 #ifndef NFA_HCI_NETWK_INIT_IDLE_TIMEOUT 355 #define NFA_HCI_NETWK_INIT_IDLE_TIMEOUT 1000 356 #endif 357 358 #ifndef NFA_HCI_MAX_HOST_IN_NETWORK 359 #define NFA_HCI_MAX_HOST_IN_NETWORK 0x06 360 #endif 361 362 /* Max number of Application that can be registered to NFA-HCI */ 363 #ifndef NFA_HCI_MAX_APP_CB 364 #define NFA_HCI_MAX_APP_CB 0x05 365 #endif 366 367 /* Max number of HCI gates that can be created */ 368 #ifndef NFA_HCI_MAX_GATE_CB 369 #define NFA_HCI_MAX_GATE_CB 0x06 370 #endif 371 372 /* Max number of HCI pipes that can be created for the whole system */ 373 #ifndef NFA_HCI_MAX_PIPE_CB 374 #define NFA_HCI_MAX_PIPE_CB 0x0A 375 #endif 376 377 /* Timeout for waiting for the response to HCP Command packet */ 378 #ifndef NFA_HCI_RESPONSE_TIMEOUT 379 #define NFA_HCI_RESPONSE_TIMEOUT 1000 380 #endif 381 382 /* Default poll duration (may be over-ridden using NFA_SetRfDiscoveryDuration) 383 */ 384 #ifndef NFA_DM_DISC_DURATION_POLL 385 #define NFA_DM_DISC_DURATION_POLL 500 /* Android requires 500 */ 386 #endif 387 388 /* Automatic NDEF detection (when not in exclusive RF mode) */ 389 #ifndef NFA_DM_AUTO_DETECT_NDEF 390 #define NFA_DM_AUTO_DETECT_NDEF FALSE /* !!!!! NFC-Android needs FALSE */ 391 #endif 392 393 /* Automatic NDEF read (when not in exclusive RF mode) */ 394 #ifndef NFA_DM_AUTO_READ_NDEF 395 #define NFA_DM_AUTO_READ_NDEF FALSE /* !!!!! NFC-Android needs FALSE */ 396 #endif 397 398 /* Automatic NDEF presence check (when not in exclusive RF mode) */ 399 #ifndef NFA_DM_AUTO_PRESENCE_CHECK 400 #define NFA_DM_AUTO_PRESENCE_CHECK FALSE /* Android requires FALSE */ 401 #endif 402 403 /* Presence check option: 0x01: use sleep/wake for none-NDEF ISO-DEP tags */ 404 #ifndef NFA_DM_PRESENCE_CHECK_OPTION 405 /* !!!!! Android needs value 3 */ 406 #define NFA_DM_PRESENCE_CHECK_OPTION 0x03 407 #endif 408 409 /* Maximum time to wait for presence check response */ 410 #ifndef NFA_DM_MAX_PRESENCE_CHECK_TIMEOUT 411 #define NFA_DM_MAX_PRESENCE_CHECK_TIMEOUT 500 412 #endif 413 414 /* Default delay to auto presence check after sending raw frame */ 415 #ifndef NFA_DM_DEFAULT_PRESENCE_CHECK_START_DELAY 416 #define NFA_DM_DEFAULT_PRESENCE_CHECK_START_DELAY 750 417 #endif 418 419 /* Timeout for reactivation of Kovio bar code tag (presence check) */ 420 #ifndef NFA_DM_DISC_TIMEOUT_KOVIO_PRESENCE_CHECK 421 #define NFA_DM_DISC_TIMEOUT_KOVIO_PRESENCE_CHECK (1000) 422 #endif 423 424 /* Max number of NDEF type handlers that can be registered (including the 425 * default handler) */ 426 #ifndef NFA_NDEF_MAX_HANDLERS 427 #define NFA_NDEF_MAX_HANDLERS 8 428 #endif 429 430 /* Maximum number of listen entries configured/registered with 431 * NFA_CeConfigureUiccListenTech, */ 432 /* NFA_CeRegisterFelicaSystemCodeOnDH, or NFA_CeRegisterT4tAidOnDH */ 433 #ifndef NFA_CE_LISTEN_INFO_MAX 434 #define NFA_CE_LISTEN_INFO_MAX 5 435 #endif 436 437 #ifndef NFA_SNEP_INCLUDED 438 /* Android must use FALSE to exclude SNEP */ 439 #define NFA_SNEP_INCLUDED FALSE 440 #endif 441 442 /* Max acceptable length */ 443 #ifndef NFA_SNEP_DEFAULT_SERVER_MAX_NDEF_SIZE 444 #define NFA_SNEP_DEFAULT_SERVER_MAX_NDEF_SIZE 500000 445 #endif 446 447 /* Max number of SNEP server/client and data link connection */ 448 #ifndef NFA_SNEP_MAX_CONN 449 #define NFA_SNEP_MAX_CONN 6 450 #endif 451 452 /* Max number data link connection of SNEP default server*/ 453 #ifndef NFA_SNEP_DEFAULT_MAX_CONN 454 #define NFA_SNEP_DEFAULT_MAX_CONN 3 455 #endif 456 457 /* MIU for SNEP */ 458 #ifndef NFA_SNEP_MIU 459 #define NFA_SNEP_MIU 1980 /* Modified for NFC-A */ 460 #endif 461 462 /* Receiving Window for SNEP */ 463 #ifndef NFA_SNEP_RW 464 #define NFA_SNEP_RW 2 /* Modified for NFC-A */ 465 #endif 466 467 /* Max number of NFCEE supported */ 468 #ifndef NFA_EE_MAX_EE_SUPPORTED 469 /* Modified for NFC-A until we add dynamic support */ 470 #define NFA_EE_MAX_EE_SUPPORTED 6 471 #endif 472 473 /* Maximum number of AID entries per target_handle */ 474 #ifndef NFA_EE_MAX_AID_ENTRIES 475 #define NFA_EE_MAX_AID_ENTRIES (32) 476 #endif 477 478 /* Maximum number of callback functions can be registered through 479 * NFA_EeRegister() */ 480 #ifndef NFA_EE_MAX_CBACKS 481 #define NFA_EE_MAX_CBACKS (3) 482 #endif 483 484 #ifndef NFA_DTA_INCLUDED 485 #define NFA_DTA_INCLUDED TRUE 486 #endif 487 488 /***************************************************************************** 489 ** Define HAL_WRITE depending on whether HAL is using shared GKI resources 490 ** as the NFC stack. 491 *****************************************************************************/ 492 #ifndef HAL_WRITE 493 #define HAL_WRITE(p) \ 494 { \ 495 nfc_cb.p_hal->write((p)->len, (uint8_t*)((p) + 1) + (p)->offset); \ 496 GKI_freebuf(p); \ 497 } 498 499 #ifdef NFC_HAL_SHARED_GKI 500 501 /* NFC HAL Included if NFC_NFCEE_INCLUDED */ 502 #if (NFC_NFCEE_INCLUDED == TRUE) 503 504 #ifndef NFC_HAL_HCI_INCLUDED 505 #define NFC_HAL_HCI_INCLUDED TRUE 506 #endif 507 #else /* NFC_NFCEE_INCLUDED == TRUE */ 508 #ifndef NFC_HAL_HCI_INCLUDED 509 #define NFC_HAL_HCI_INCLUDED FALSE 510 #endif 511 512 #endif /* NFC_NFCEE_INCLUDED == FALSE */ 513 514 #endif /* NFC_HAL_SHARED_GKI */ 515 516 #endif /* HAL_WRITE */ 517 518 #endif /* NFC_TARGET_H */ 519