1 /****************************************************************************** 2 * 3 * Copyright (C) 2012-2013 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_HAL_TARGET_H 20 #define NFC_HAL_TARGET_H 21 22 #include "gki.h" 23 #include "data_types.h" 24 25 /**************************************************************************** 26 ** NCI related configuration 27 ****************************************************************************/ 28 29 /* Initial Max Control Packet Payload Size (until receiving payload size in INIT_CORE_RSP) */ 30 #ifndef NFC_HAL_NCI_INIT_CTRL_PAYLOAD_SIZE 31 #define NFC_HAL_NCI_INIT_CTRL_PAYLOAD_SIZE 0xFF 32 #endif 33 34 /* Number of bytes to reserve in front of NCI messages (e.g. for transport header) */ 35 #ifndef NFC_HAL_NCI_MSG_OFFSET_SIZE 36 #define NFC_HAL_NCI_MSG_OFFSET_SIZE 1 37 #endif 38 39 /* NFC-WAKE */ 40 #ifndef NFC_HAL_LP_NFC_WAKE_GPIO 41 #define NFC_HAL_LP_NFC_WAKE_GPIO UPIO_GENERAL3 42 #endif 43 44 /* NFCC snooze mode idle timeout before deassert NFC_WAKE in ms */ 45 #ifndef NFC_HAL_LP_IDLE_TIMEOUT 46 #define NFC_HAL_LP_IDLE_TIMEOUT 100 47 #endif 48 49 /* NFC snooze mode */ 50 #ifndef NFC_HAL_LP_SNOOZE_MODE 51 #define NFC_HAL_LP_SNOOZE_MODE NFC_HAL_LP_SNOOZE_MODE_UART 52 #endif 53 54 /* Idle Threshold Host in 100ms unit */ 55 #ifndef NFC_HAL_LP_IDLE_THRESHOLD_HOST 56 #define NFC_HAL_LP_IDLE_THRESHOLD_HOST 0 57 #endif 58 59 /* Idle Threshold HC in 100ms unit */ 60 #ifndef NFC_HAL_LP_IDLE_THRESHOLD_HC 61 #define NFC_HAL_LP_IDLE_THRESHOLD_HC 0 62 #endif 63 64 65 /* Default NFCC power-up baud rate */ 66 #ifndef NFC_HAL_DEFAULT_BAUD 67 #define NFC_HAL_DEFAULT_BAUD USERIAL_BAUD_115200 68 #endif 69 70 /* time (in ms) between power off and on NFCC */ 71 #ifndef NFC_HAL_POWER_CYCLE_DELAY 72 #define NFC_HAL_POWER_CYCLE_DELAY 100 73 #endif 74 75 /* time (in ms) between power off and on NFCC */ 76 #ifndef NFC_HAL_NFCC_ENABLE_TIMEOUT 77 #define NFC_HAL_NFCC_ENABLE_TIMEOUT 1000 78 #endif 79 80 #ifndef NFC_HAL_PRM_DEBUG 81 #define NFC_HAL_PRM_DEBUG TRUE 82 #endif 83 84 /* max patch data length (Can be overridden by platform for ACL HCI command size) */ 85 #ifndef NFC_HAL_PRM_HCD_CMD_MAXLEN 86 #define NFC_HAL_PRM_HCD_CMD_MAXLEN 250 87 #endif 88 89 /* Require PreI2C patch by default */ 90 #ifndef NFC_HAL_PRE_I2C_PATCH_INCLUDED 91 #define NFC_HAL_PRE_I2C_PATCH_INCLUDED TRUE 92 #endif 93 94 /* Set to TRUE to always download patch regardless of version */ 95 #ifndef NFC_HAL_PRM_SKIP_VERSION_CHECK 96 #define NFC_HAL_PRM_SKIP_VERSION_CHECK FALSE 97 #endif 98 99 /* Mininum payload size for SPD NCI commands (used to validate HAL_NfcPrmSetSpdNciCmdPayloadSize) */ 100 /* Default is 32, as required by the NCI specifications; however this value may be */ 101 /* over-riden for platforms that have transport packet limitations */ 102 #ifndef NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE 103 #define NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE (32) 104 #endif 105 106 /* amount of time to wait for authenticating/committing patch to NVM */ 107 #ifndef NFC_HAL_PRM_COMMIT_DELAY 108 #define NFC_HAL_PRM_COMMIT_DELAY (30000) 109 #endif 110 111 /* amount of time to wait after downloading preI2C patch before downloading LPM/FPM patch */ 112 #ifndef NFC_HAL_PRM_POST_I2C_FIX_DELAY 113 #define NFC_HAL_PRM_POST_I2C_FIX_DELAY (200) 114 #endif 115 116 /* NFCC will respond to more than one technology during listen discovery */ 117 #ifndef NFC_HAL_DM_MULTI_TECH_RESP 118 #define NFC_HAL_DM_MULTI_TECH_RESP TRUE 119 #endif 120 121 /* Data rate for 15693 command/response, it must be same as RW_I93_FLAG_DATA_RATE in nfc_target.h */ 122 #define NFC_HAL_I93_FLAG_DATA_RATE_LOW 0x00 123 #define NFC_HAL_I93_FLAG_DATA_RATE_HIGH 0x02 124 125 #ifndef NFC_HAL_I93_FLAG_DATA_RATE 126 #define NFC_HAL_I93_FLAG_DATA_RATE NFC_HAL_I93_FLAG_DATA_RATE_HIGH 127 #endif 128 129 /* Quick Timer */ 130 #ifndef QUICK_TIMER_TICKS_PER_SEC 131 #define QUICK_TIMER_TICKS_PER_SEC 100 /* 10ms timer */ 132 #endif 133 134 #ifndef NFC_HAL_SHARED_TRANSPORT_ENABLED 135 #define NFC_HAL_SHARED_TRANSPORT_ENABLED FALSE 136 #endif 137 138 /* Enable verbose tracing by default */ 139 #ifndef NFC_HAL_TRACE_VERBOSE 140 #define NFC_HAL_TRACE_VERBOSE TRUE 141 #endif 142 143 #ifndef NFC_HAL_INITIAL_TRACE_LEVEL 144 #define NFC_HAL_INITIAL_TRACE_LEVEL 5 145 #endif 146 147 /* Map NFC serial port to USERIAL_PORT_6 by default */ 148 #ifndef USERIAL_NFC_PORT 149 #define USERIAL_NFC_PORT (USERIAL_PORT_6) 150 #endif 151 152 /* Restore NFCC baud rate to default on shutdown if baud rate was updated */ 153 #ifndef NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN 154 #define NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN TRUE 155 #endif 156 157 /* Enable protocol tracing by default */ 158 #ifndef NFC_HAL_TRACE_PROTOCOL 159 #define NFC_HAL_TRACE_PROTOCOL TRUE 160 #endif 161 162 /* Legacy protocol-trace-enable macro */ 163 #ifndef BT_TRACE_PROTOCOL 164 #define BT_TRACE_PROTOCOL (NFC_HAL_TRACE_PROTOCOL) 165 #endif 166 167 /* Enable HAL tracing by default */ 168 #ifndef NFC_HAL_USE_TRACES 169 #define NFC_HAL_USE_TRACES TRUE 170 #endif 171 172 /* HAL trace macros */ 173 #if (NFC_HAL_USE_TRACES == TRUE) 174 #define NCI_TRACE_0(l,t,m) LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)),(m)) 175 #define NCI_TRACE_1(l,t,m,p1) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1)) 176 #define NCI_TRACE_2(l,t,m,p1,p2) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1), \ 177 (UINTPTR)(p2)) 178 #define NCI_TRACE_3(l,t,m,p1,p2,p3) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1), \ 179 (UINTPTR)(p2),(UINTPTR)(p3)) 180 #define NCI_TRACE_4(l,t,m,p1,p2,p3,p4) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1), \ 181 (UINTPTR)(p2),(UINTPTR)(p3),(UINTPTR)(p4)) 182 #define NCI_TRACE_5(l,t,m,p1,p2,p3,p4,p5) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1), \ 183 (UINTPTR)(p2),(UINTPTR)(p3),(UINTPTR)(p4), \ 184 (UINTPTR)(p5)) 185 #define NCI_TRACE_6(l,t,m,p1,p2,p3,p4,p5,p6) LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1), \ 186 (UINTPTR)(p2),(UINTPTR)(p3),(UINTPTR)(p4), \ 187 (UINTPTR)(p5),(UINTPTR)(p6)) 188 189 #define HAL_TRACE_ERROR0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m);} 190 #define HAL_TRACE_ERROR1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m,p1);} 191 #define HAL_TRACE_ERROR2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m,p1,p2);} 192 #define HAL_TRACE_ERROR3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m,p1,p2,p3);} 193 #define HAL_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);} 194 #define HAL_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);} 195 #define HAL_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);} 196 197 #define HAL_TRACE_WARNING0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m);} 198 #define HAL_TRACE_WARNING1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m,p1);} 199 #define HAL_TRACE_WARNING2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m,p1,p2);} 200 #define HAL_TRACE_WARNING3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m,p1,p2,p3);} 201 #define HAL_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);} 202 #define HAL_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);} 203 #define HAL_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);} 204 205 #define HAL_TRACE_API0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_API, m);} 206 #define HAL_TRACE_API1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_API, m,p1);} 207 #define HAL_TRACE_API2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_API, m,p1,p2);} 208 #define HAL_TRACE_API3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_API, m,p1,p2,p3);} 209 #define HAL_TRACE_API4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_API, m,p1,p2,p3,p4);} 210 #define HAL_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);} 211 #define HAL_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);} 212 213 #define HAL_TRACE_EVENT0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m);} 214 #define HAL_TRACE_EVENT1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m, p1);} 215 #define HAL_TRACE_EVENT2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m,p1,p2);} 216 #define HAL_TRACE_EVENT3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m,p1,p2,p3);} 217 #define HAL_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);} 218 #define HAL_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);} 219 #define HAL_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);} 220 221 #define HAL_TRACE_DEBUG0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_0(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m);} 222 #define HAL_TRACE_DEBUG1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_1(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m,p1);} 223 #define HAL_TRACE_DEBUG2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_2(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m,p1,p2);} 224 #define HAL_TRACE_DEBUG3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_3(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m,p1,p2,p3);} 225 #define HAL_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_4(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);} 226 #define HAL_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_5(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);} 227 #define HAL_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) NCI_TRACE_6(TRACE_LAYER_HAL, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);} 228 229 #else /* Disable HAL tracing */ 230 231 #define HAL_TRACE_0(l,t,m) 232 #define HAL_TRACE_1(l,t,m,p1) 233 #define HAL_TRACE_2(l,t,m,p1,p2) 234 #define HAL_TRACE_3(l,t,m,p1,p2,p3) 235 #define HAL_TRACE_4(l,t,m,p1,p2,p3,p4) 236 #define HAL_TRACE_5(l,t,m,p1,p2,p3,p4,p5) 237 #define HAL_TRACE_6(l,t,m,p1,p2,p3,p4,p5,p6) 238 239 #define HAL_TRACE_ERROR0(m) 240 #define HAL_TRACE_ERROR1(m,p1) 241 #define HAL_TRACE_ERROR2(m,p1,p2) 242 #define HAL_TRACE_ERROR3(m,p1,p2,p3) 243 #define HAL_TRACE_ERROR4(m,p1,p2,p3,p4) 244 #define HAL_TRACE_ERROR5(m,p1,p2,p3,p4,p5) 245 #define HAL_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) 246 247 #define HAL_TRACE_WARNING0(m) 248 #define HAL_TRACE_WARNING1(m,p1) 249 #define HAL_TRACE_WARNING2(m,p1,p2) 250 #define HAL_TRACE_WARNING3(m,p1,p2,p3) 251 #define HAL_TRACE_WARNING4(m,p1,p2,p3,p4) 252 #define HAL_TRACE_WARNING5(m,p1,p2,p3,p4,p5) 253 #define HAL_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) 254 255 #define HAL_TRACE_API0(m) 256 #define HAL_TRACE_API1(m,p1) 257 #define HAL_TRACE_API2(m,p1,p2) 258 #define HAL_TRACE_API3(m,p1,p2,p3) 259 #define HAL_TRACE_API4(m,p1,p2,p3,p4) 260 #define HAL_TRACE_API5(m,p1,p2,p3,p4,p5) 261 #define HAL_TRACE_API6(m,p1,p2,p3,p4,p5,p6) 262 263 #define HAL_TRACE_EVENT0(m) 264 #define HAL_TRACE_EVENT1(m,p1) 265 #define HAL_TRACE_EVENT2(m,p1,p2) 266 #define HAL_TRACE_EVENT3(m,p1,p2,p3) 267 #define HAL_TRACE_EVENT4(m,p1,p2,p3,p4) 268 #define HAL_TRACE_EVENT5(m,p1,p2,p3,p4,p5) 269 #define HAL_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) 270 271 #define HAL_TRACE_DEBUG0(m) 272 #define HAL_TRACE_DEBUG1(m,p1) 273 #define HAL_TRACE_DEBUG2(m,p1,p2) 274 #define HAL_TRACE_DEBUG3(m,p1,p2,p3) 275 #define HAL_TRACE_DEBUG4(m,p1,p2,p3,p4) 276 #define HAL_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) 277 #define HAL_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) 278 #endif /* Disable HAL tracing */ 279 280 #endif /* GKI_TARGET_H */ 281