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 /* the maximum number of NCI connections allowed. 1-14 */ 206 #ifndef NCI_MAX_STATIC_CONN_CBS 207 #define NCI_MAX_STATIC_CONN_CBS 2 208 #endif 209 210 /* Maximum number of NCI commands that the NFCC accepts without needing to wait 211 * for response */ 212 #ifndef NCI_MAX_CMD_WINDOW 213 #define NCI_MAX_CMD_WINDOW 1 214 #endif 215 216 /* Define to TRUE to include the NFCEE related functionalities */ 217 #ifndef NFC_NFCEE_INCLUDED 218 #define NFC_NFCEE_INCLUDED TRUE 219 #endif 220 221 /* the maximum number of NFCEE interface supported */ 222 #ifndef NFC_MAX_EE_INTERFACE 223 #define NFC_MAX_EE_INTERFACE 3 224 #endif 225 226 /* the maximum number of NFCEE information supported. */ 227 #ifndef NFC_MAX_EE_INFO 228 #define NFC_MAX_EE_INFO 8 229 #endif 230 231 /* the maximum number of NFCEE TLVs supported */ 232 #ifndef NFC_MAX_EE_TLVS 233 #define NFC_MAX_EE_TLVS 1 234 #endif 235 236 /* the maximum size of NFCEE TLV list supported */ 237 #ifndef NFC_MAX_EE_TLV_SIZE 238 #define NFC_MAX_EE_TLV_SIZE 150 239 #endif 240 241 /* Maximum time to discover NFCEE */ 242 #ifndef NFA_EE_DISCV_TIMEOUT_VAL 243 #define NFA_EE_DISCV_TIMEOUT_VAL 2000 244 #endif 245 246 /* Number of times reader/writer should attempt to resend a command on failure 247 */ 248 #ifndef RW_MAX_RETRIES 249 #define RW_MAX_RETRIES 5 250 #endif 251 252 /* RW NDEF Support */ 253 #ifndef RW_NDEF_INCLUDED 254 #define RW_NDEF_INCLUDED TRUE 255 #endif 256 257 /* RW Type 1 Tag timeout for each API call, in ms */ 258 #ifndef RW_T1T_TOUT_RESP 259 #define RW_T1T_TOUT_RESP 100 260 #endif 261 262 /* CE Type 2 Tag timeout for controller command, in ms */ 263 #ifndef CE_T2T_TOUT_RESP 264 #define CE_T2T_TOUT_RESP 1000 265 #endif 266 267 /* RW Type 2 Tag timeout for each API call, in ms */ 268 #ifndef RW_T2T_TOUT_RESP 269 /* Android requires 150 instead of 100 for presence-check*/ 270 #define RW_T2T_TOUT_RESP 150 271 #endif 272 273 /* RW Type 2 Tag timeout for each API call, in ms */ 274 #ifndef RW_T2T_SEC_SEL_TOUT_RESP 275 #define RW_T2T_SEC_SEL_TOUT_RESP 10 276 #endif 277 278 /* RW Type 3 Tag timeout for each API call, in ms */ 279 #ifndef RW_T3T_TOUT_RESP 280 /* NFC-Android will use 100 instead of 75 for T3t presence-check */ 281 #define RW_T3T_TOUT_RESP 100 282 #endif 283 284 /* CE Type 3 Tag maximum response timeout index (for check and update, used in 285 * SENSF_RES) */ 286 #ifndef CE_T3T_MRTI_C 287 #define CE_T3T_MRTI_C 0xFF 288 #endif 289 #ifndef CE_T3T_MRTI_U 290 #define CE_T3T_MRTI_U 0xFF 291 #endif 292 293 /* Default maxblocks for CE_T3T UPDATE/CHECK operations */ 294 #ifndef CE_T3T_DEFAULT_UPDATE_MAXBLOCKS 295 #define CE_T3T_DEFAULT_UPDATE_MAXBLOCKS 3 296 #endif 297 298 #ifndef CE_T3T_DEFAULT_CHECK_MAXBLOCKS 299 #define CE_T3T_DEFAULT_CHECK_MAXBLOCKS 3 300 #endif 301 302 /* CE Type 4 Tag, Frame Waiting time Integer */ 303 #ifndef CE_T4T_ISO_DEP_FWI 304 #define CE_T4T_ISO_DEP_FWI 7 305 #ifndef RW_CI_TOUT_RESP 306 #define RW_CI_TOUT_RESP 1000 307 #endif 308 #endif 309 310 /* RW Type 4 Tag timeout for each API call, in ms */ 311 #ifndef RW_T4T_TOUT_RESP 312 #define RW_T4T_TOUT_RESP 1000 313 #endif 314 315 /* CE Type 4 Tag timeout for update file, in ms */ 316 #ifndef CE_T4T_TOUT_UPDATE 317 #define CE_T4T_TOUT_UPDATE 1000 318 #endif 319 320 /* CE Type 4 Tag, mandatory NDEF File ID */ 321 #ifndef CE_T4T_MANDATORY_NDEF_FILE_ID 322 #define CE_T4T_MANDATORY_NDEF_FILE_ID 0x1000 323 #endif 324 325 /* CE Type 4 Tag, max number of AID supported */ 326 #ifndef CE_T4T_MAX_REG_AID 327 #define CE_T4T_MAX_REG_AID 4 328 #endif 329 330 /* Sub carrier */ 331 #ifndef RW_I93_FLAG_SUB_CARRIER 332 #define RW_I93_FLAG_SUB_CARRIER I93_FLAG_SUB_CARRIER_SINGLE 333 #endif 334 335 /* Data rate for 15693 command/response */ 336 #ifndef RW_I93_FLAG_DATA_RATE 337 #define RW_I93_FLAG_DATA_RATE I93_FLAG_DATA_RATE_HIGH 338 #endif 339 340 /* RW Mifare Classic Tag timeout for each API call, in ms */ 341 #ifndef RW_MFC_TOUT_RESP 342 #define RW_MFC_TOUT_RESP 300 343 #endif 344 345 /* TRUE, to include Card Emulation related test commands */ 346 #ifndef CE_TEST_INCLUDED 347 #define CE_TEST_INCLUDED FALSE 348 #endif 349 350 /* Quick Timer */ 351 #ifndef QUICK_TIMER_TICKS_PER_SEC 352 #define QUICK_TIMER_TICKS_PER_SEC 100 /* 10ms timer */ 353 #endif 354 355 /****************************************************************************** 356 ** 357 ** NFA 358 ** 359 ******************************************************************************/ 360 361 /* Maximum Idle time (no hcp) to wait for EE DISC REQ Ntf(s) */ 362 #ifndef NFA_HCI_NETWK_INIT_IDLE_TIMEOUT 363 #define NFA_HCI_NETWK_INIT_IDLE_TIMEOUT 1000 364 #endif 365 366 #ifndef NFA_HCI_MAX_HOST_IN_NETWORK 367 #define NFA_HCI_MAX_HOST_IN_NETWORK 0x06 368 #endif 369 370 /* Max number of Application that can be registered to NFA-HCI */ 371 #ifndef NFA_HCI_MAX_APP_CB 372 #define NFA_HCI_MAX_APP_CB 0x05 373 #endif 374 375 /* Max number of HCI gates that can be created */ 376 #ifndef NFA_HCI_MAX_GATE_CB 377 #define NFA_HCI_MAX_GATE_CB 0x06 378 #endif 379 380 /* Max number of HCI pipes that can be created for the whole system */ 381 #ifndef NFA_HCI_MAX_PIPE_CB 382 #define NFA_HCI_MAX_PIPE_CB 0x0A 383 #endif 384 385 /* Timeout for waiting for the response to HCP Command packet */ 386 #ifndef NFA_HCI_RESPONSE_TIMEOUT 387 #define NFA_HCI_RESPONSE_TIMEOUT 1000 388 #endif 389 390 /* Default poll duration (may be over-ridden using NFA_SetRfDiscoveryDuration) 391 */ 392 #ifndef NFA_DM_DISC_DURATION_POLL 393 #define NFA_DM_DISC_DURATION_POLL 500 /* Android requires 500 */ 394 #endif 395 396 /* Automatic NDEF detection (when not in exclusive RF mode) */ 397 #ifndef NFA_DM_AUTO_DETECT_NDEF 398 #define NFA_DM_AUTO_DETECT_NDEF FALSE /* !!!!! NFC-Android needs FALSE */ 399 #endif 400 401 /* Automatic NDEF read (when not in exclusive RF mode) */ 402 #ifndef NFA_DM_AUTO_READ_NDEF 403 #define NFA_DM_AUTO_READ_NDEF FALSE /* !!!!! NFC-Android needs FALSE */ 404 #endif 405 406 /* Automatic NDEF presence check (when not in exclusive RF mode) */ 407 #ifndef NFA_DM_AUTO_PRESENCE_CHECK 408 #define NFA_DM_AUTO_PRESENCE_CHECK FALSE /* Android requires FALSE */ 409 #endif 410 411 /* Presence check option: 0x01: use sleep/wake for none-NDEF ISO-DEP tags */ 412 #ifndef NFA_DM_PRESENCE_CHECK_OPTION 413 /* !!!!! Android needs value 3 */ 414 #define NFA_DM_PRESENCE_CHECK_OPTION 0x03 415 #endif 416 417 /* Maximum time to wait for presence check response */ 418 #ifndef NFA_DM_MAX_PRESENCE_CHECK_TIMEOUT 419 #define NFA_DM_MAX_PRESENCE_CHECK_TIMEOUT 500 420 #endif 421 422 /* Default delay to auto presence check after sending raw frame */ 423 #ifndef NFA_DM_DEFAULT_PRESENCE_CHECK_START_DELAY 424 #define NFA_DM_DEFAULT_PRESENCE_CHECK_START_DELAY 750 425 #endif 426 427 /* Timeout for reactivation of Kovio bar code tag (presence check) */ 428 #ifndef NFA_DM_DISC_TIMEOUT_KOVIO_PRESENCE_CHECK 429 #define NFA_DM_DISC_TIMEOUT_KOVIO_PRESENCE_CHECK (1000) 430 #endif 431 432 /* timeout for waiting deactivation NTF, 433 ** possible delay to send deactivate CMD if all credit wasn't returned 434 ** transport delay (1sec) and max RWT (5sec) 435 */ 436 #define NFA_DM_DISC_TIMEOUT_W4_DEACT_NTF (NFC_DEACTIVATE_TIMEOUT * 1000 + 6000) 437 438 /* Max number of NDEF type handlers that can be registered (including the 439 * default handler) */ 440 #ifndef NFA_NDEF_MAX_HANDLERS 441 #define NFA_NDEF_MAX_HANDLERS 8 442 #endif 443 444 /* Maximum number of listen entries configured/registered with 445 * NFA_CeConfigureUiccListenTech, */ 446 /* NFA_CeRegisterFelicaSystemCodeOnDH, or NFA_CeRegisterT4tAidOnDH */ 447 #ifndef NFA_CE_LISTEN_INFO_MAX 448 #define NFA_CE_LISTEN_INFO_MAX 5 449 #endif 450 451 #ifndef NFA_SNEP_INCLUDED 452 /* Android must use FALSE to exclude SNEP */ 453 #define NFA_SNEP_INCLUDED FALSE 454 #endif 455 456 /* Max acceptable length */ 457 #ifndef NFA_SNEP_DEFAULT_SERVER_MAX_NDEF_SIZE 458 #define NFA_SNEP_DEFAULT_SERVER_MAX_NDEF_SIZE 500000 459 #endif 460 461 /* Max number of SNEP server/client and data link connection */ 462 #ifndef NFA_SNEP_MAX_CONN 463 #define NFA_SNEP_MAX_CONN 6 464 #endif 465 466 /* Max number data link connection of SNEP default server*/ 467 #ifndef NFA_SNEP_DEFAULT_MAX_CONN 468 #define NFA_SNEP_DEFAULT_MAX_CONN 3 469 #endif 470 471 /* MIU for SNEP */ 472 #ifndef NFA_SNEP_MIU 473 #define NFA_SNEP_MIU 1980 /* Modified for NFC-A */ 474 #endif 475 476 /* Receiving Window for SNEP */ 477 #ifndef NFA_SNEP_RW 478 #define NFA_SNEP_RW 2 /* Modified for NFC-A */ 479 #endif 480 481 /* Max number of NFCEE supported */ 482 #ifndef NFA_EE_MAX_EE_SUPPORTED 483 /* Modified for NFC-A until we add dynamic support */ 484 #define NFA_EE_MAX_EE_SUPPORTED 6 485 #endif 486 487 /* Maximum number of AID entries per target_handle */ 488 #ifndef NFA_EE_MAX_AID_ENTRIES 489 #define NFA_EE_MAX_AID_ENTRIES (32) 490 #endif 491 492 /* Maximum number of callback functions can be registered through 493 * NFA_EeRegister() */ 494 #ifndef NFA_EE_MAX_CBACKS 495 #define NFA_EE_MAX_CBACKS (3) 496 #endif 497 498 #ifndef NFA_DTA_INCLUDED 499 #define NFA_DTA_INCLUDED TRUE 500 #endif 501 502 /***************************************************************************** 503 ** Define HAL_WRITE depending on whether HAL is using shared GKI resources 504 ** as the NFC stack. 505 *****************************************************************************/ 506 #ifndef HAL_WRITE 507 #define HAL_WRITE(p) \ 508 { \ 509 nfc_cb.p_hal->write((p)->len, (uint8_t*)((p) + 1) + (p)->offset); \ 510 GKI_freebuf(p); \ 511 } 512 513 #ifdef NFC_HAL_SHARED_GKI 514 515 /* NFC HAL Included if NFC_NFCEE_INCLUDED */ 516 #if (NFC_NFCEE_INCLUDED == TRUE) 517 518 #ifndef NFC_HAL_HCI_INCLUDED 519 #define NFC_HAL_HCI_INCLUDED TRUE 520 #endif 521 #else /* NFC_NFCEE_INCLUDED == TRUE */ 522 #ifndef NFC_HAL_HCI_INCLUDED 523 #define NFC_HAL_HCI_INCLUDED FALSE 524 #endif 525 526 #endif /* NFC_NFCEE_INCLUDED == FALSE */ 527 528 #endif /* NFC_HAL_SHARED_GKI */ 529 530 #endif /* HAL_WRITE */ 531 532 #endif /* NFC_TARGET_H */ 533