The Android Open Source Project | e9df6ba | 2012-12-13 14:55:37 -0800 | [diff] [blame^] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 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 | #ifndef NFC_HAL_TARGET_H |
| 19 | #define NFC_HAL_TARGET_H |
| 20 | |
| 21 | #include "data_types.h" |
| 22 | |
| 23 | #ifdef BUILDCFG |
| 24 | #include "buildcfg_hal.h" |
| 25 | #endif |
| 26 | |
| 27 | /**************************************************************************** |
| 28 | ** NCI related configuration |
| 29 | ****************************************************************************/ |
| 30 | |
| 31 | /* GKI pool for NCI messages */ |
| 32 | #ifndef NFC_HAL_NCI_POOL_ID |
| 33 | #define NFC_HAL_NCI_POOL_ID GKI_POOL_ID_1 |
| 34 | #endif |
| 35 | |
| 36 | #ifndef NFC_HAL_NCI_POOL_BUF_SIZE |
| 37 | #define NFC_HAL_NCI_POOL_BUF_SIZE GKI_BUF1_SIZE |
| 38 | #endif |
| 39 | |
| 40 | /* Initial Max Control Packet Payload Size (until receiving payload size in INIT_CORE_RSP) */ |
| 41 | #ifndef NFC_HAL_NCI_INIT_CTRL_PAYLOAD_SIZE |
| 42 | #define NFC_HAL_NCI_INIT_CTRL_PAYLOAD_SIZE 0xFF |
| 43 | #endif |
| 44 | |
| 45 | /* Number of bytes to reserve in front of NCI messages (e.g. for transport header) */ |
| 46 | #ifndef NFC_HAL_NCI_MSG_OFFSET_SIZE |
| 47 | #define NFC_HAL_NCI_MSG_OFFSET_SIZE 1 |
| 48 | #endif |
| 49 | |
| 50 | /* NFC-WAKE */ |
| 51 | #ifndef NFC_HAL_LP_NFC_WAKE_GPIO |
| 52 | #define NFC_HAL_LP_NFC_WAKE_GPIO UPIO_GENERAL3 |
| 53 | #endif |
| 54 | |
| 55 | /* NFCC snooze mode idle timeout before deassert NFC_WAKE in ms */ |
| 56 | #ifndef NFC_HAL_LP_IDLE_TIMEOUT |
| 57 | #define NFC_HAL_LP_IDLE_TIMEOUT 100 |
| 58 | #endif |
| 59 | |
| 60 | /* NFC snooze mode */ |
| 61 | #ifndef NFC_HAL_LP_SNOOZE_MODE |
| 62 | #define NFC_HAL_LP_SNOOZE_MODE NFC_HAL_LP_SNOOZE_MODE_UART |
| 63 | #endif |
| 64 | |
| 65 | /* Idle Threshold Host in 100ms unit */ |
| 66 | #ifndef NFC_HAL_LP_IDLE_THRESHOLD_HOST |
| 67 | #define NFC_HAL_LP_IDLE_THRESHOLD_HOST 0 |
| 68 | #endif |
| 69 | |
| 70 | /* Idle Threshold HC in 100ms unit */ |
| 71 | #ifndef NFC_HAL_LP_IDLE_THRESHOLD_HC |
| 72 | #define NFC_HAL_LP_IDLE_THRESHOLD_HC 0 |
| 73 | #endif |
| 74 | |
| 75 | |
| 76 | /* Default NFCC power-up baud rate */ |
| 77 | #ifndef NFC_HAL_DEFAULT_BAUD |
| 78 | #define NFC_HAL_DEFAULT_BAUD USERIAL_BAUD_115200 |
| 79 | #endif |
| 80 | |
| 81 | /* time (in ms) between power off and on NFCC */ |
| 82 | #ifndef NFC_HAL_POWER_CYCLE_DELAY |
| 83 | #define NFC_HAL_POWER_CYCLE_DELAY 100 |
| 84 | #endif |
| 85 | |
| 86 | #ifndef NFC_HAL_PRM_DEBUG |
| 87 | #define NFC_HAL_PRM_DEBUG TRUE |
| 88 | #endif |
| 89 | |
| 90 | /* max patch data length (Can be overridden by platform for ACL HCI command size) */ |
| 91 | #ifndef NFC_HAL_PRM_HCD_CMD_MAXLEN |
| 92 | #define NFC_HAL_PRM_HCD_CMD_MAXLEN 250 |
| 93 | #endif |
| 94 | |
| 95 | /* Require PreI2C patch by default */ |
| 96 | #ifndef NFC_HAL_PRE_I2C_PATCH_INCLUDED |
| 97 | #define NFC_HAL_PRE_I2C_PATCH_INCLUDED TRUE |
| 98 | #endif |
| 99 | |
| 100 | /* Set to TRUE to always download patch regardless of version */ |
| 101 | #ifndef NFC_HAL_PRM_SKIP_VERSION_CHECK |
| 102 | #define NFC_HAL_PRM_SKIP_VERSION_CHECK FALSE |
| 103 | #endif |
| 104 | |
| 105 | /* Mininum payload size for SPD NCI commands (used to validate HAL_NfcPrmSetSpdNciCmdPayloadSize) */ |
| 106 | /* Default is 32, as required by the NCI specifications; however this value may be */ |
| 107 | /* over-riden for platforms that have transport packet limitations */ |
| 108 | #ifndef NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE |
| 109 | #define NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE (32) |
| 110 | #endif |
| 111 | |
| 112 | /* amount of time to wait for RESET NTF after patch download */ |
| 113 | #ifndef NFC_HAL_PRM_RESET_NTF_DELAY |
| 114 | #define NFC_HAL_PRM_RESET_NTF_DELAY (10000) |
| 115 | #endif |
| 116 | |
| 117 | /* amount of time to wait after downloading preI2C patch before downloading LPM/FPM patch */ |
| 118 | #ifndef NFC_HAL_PRM_POST_I2C_FIX_DELAY |
| 119 | #define NFC_HAL_PRM_POST_I2C_FIX_DELAY (200) |
| 120 | #endif |
| 121 | |
| 122 | /* NFCC will respond to more than one technology during listen discovery */ |
| 123 | #ifndef NFC_HAL_DM_MULTI_TECH_RESP |
| 124 | #define NFC_HAL_DM_MULTI_TECH_RESP TRUE |
| 125 | #endif |
| 126 | |
| 127 | /* Data rate for 15693 command/response, it must be same as RW_I93_FLAG_DATA_RATE in nfc_target.h */ |
| 128 | #define NFC_HAL_I93_FLAG_DATA_RATE_LOW 0x00 |
| 129 | #define NFC_HAL_I93_FLAG_DATA_RATE_HIGH 0x02 |
| 130 | |
| 131 | #ifndef NFC_HAL_I93_FLAG_DATA_RATE |
| 132 | #define NFC_HAL_I93_FLAG_DATA_RATE NFC_HAL_I93_FLAG_DATA_RATE_HIGH |
| 133 | #endif |
| 134 | |
| 135 | /* Quick Timer */ |
| 136 | #ifndef QUICK_TIMER_TICKS_PER_SEC |
| 137 | #define QUICK_TIMER_TICKS_PER_SEC 100 /* 10ms timer */ |
| 138 | #endif |
| 139 | |
| 140 | #ifndef NFC_HAL_SHARED_TRANSPORT_ENABLED |
| 141 | #define NFC_HAL_SHARED_TRANSPORT_ENABLED FALSE |
| 142 | #endif |
| 143 | |
| 144 | /* Enable verbose tracing by default */ |
| 145 | #ifndef NFC_HAL_TRACE_VERBOSE |
| 146 | #define NFC_HAL_TRACE_VERBOSE TRUE |
| 147 | #endif |
| 148 | |
| 149 | #ifndef NFC_HAL_INITIAL_TRACE_LEVEL |
| 150 | #define NFC_HAL_INITIAL_TRACE_LEVEL 5 |
| 151 | #endif |
| 152 | |
| 153 | /* Map NFC serial port to USERIAL_PORT_6 by default */ |
| 154 | #ifndef USERIAL_NFC_PORT |
| 155 | #define USERIAL_NFC_PORT (USERIAL_PORT_6) |
| 156 | #endif |
| 157 | |
| 158 | /* Restore NFCC baud rate to default on shutdown if baud rate was updated */ |
| 159 | #ifndef NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN |
| 160 | #define NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN TRUE |
| 161 | #endif |
| 162 | |
| 163 | /* Enable protocol tracing by default */ |
| 164 | #ifndef NFC_HAL_TRACE_PROTOCOL |
| 165 | #define NFC_HAL_TRACE_PROTOCOL TRUE |
| 166 | #endif |
| 167 | #define BT_TRACE_PROTOCOL (NFC_HAL_TRACE_PROTOCOL) |
| 168 | |
| 169 | #define LogMsg_0 LogMsg |
| 170 | #define LogMsg_1 LogMsg |
| 171 | #define LogMsg_2 LogMsg |
| 172 | #define LogMsg_3 LogMsg |
| 173 | #define LogMsg_4 LogMsg |
| 174 | #define LogMsg_5 LogMsg |
| 175 | #define LogMsg_6 LogMsg |
| 176 | |
| 177 | /* Trace macros */ |
| 178 | #define BT_TRACE_0(l,t,m) LogMsg_0((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)),(m)) |
| 179 | #define BT_TRACE_1(l,t,m,p1) LogMsg_1(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1)) |
| 180 | #define BT_TRACE_2(l,t,m,p1,p2) LogMsg_2(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \ |
| 181 | (UINT32)(p2)) |
| 182 | #define BT_TRACE_3(l,t,m,p1,p2,p3) LogMsg_3(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \ |
| 183 | (UINT32)(p2),(UINT32)(p3)) |
| 184 | #define BT_TRACE_4(l,t,m,p1,p2,p3,p4) LogMsg_4(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \ |
| 185 | (UINT32)(p2),(UINT32)(p3),(UINT32)(p4)) |
| 186 | #define BT_TRACE_5(l,t,m,p1,p2,p3,p4,p5) LogMsg_5(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \ |
| 187 | (UINT32)(p2),(UINT32)(p3),(UINT32)(p4), \ |
| 188 | (UINT32)(p5)) |
| 189 | #define BT_TRACE_6(l,t,m,p1,p2,p3,p4,p5,p6) LogMsg_6(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINT32)(p1), \ |
| 190 | (UINT32)(p2),(UINT32)(p3),(UINT32)(p4), \ |
| 191 | (UINT32)(p5),(UINT32)(p6)) |
| 192 | |
| 193 | #define NCI_TRACE_ERROR0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m);} |
| 194 | #define NCI_TRACE_ERROR1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1);} |
| 195 | #define NCI_TRACE_ERROR2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2);} |
| 196 | #define NCI_TRACE_ERROR3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3);} |
| 197 | #define NCI_TRACE_ERROR4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4);} |
| 198 | #define NCI_TRACE_ERROR5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5);} |
| 199 | #define NCI_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_ERROR) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m,p1,p2,p3,p4,p5,p6);} |
| 200 | |
| 201 | #define NCI_TRACE_WARNING0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m);} |
| 202 | #define NCI_TRACE_WARNING1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1);} |
| 203 | #define NCI_TRACE_WARNING2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2);} |
| 204 | #define NCI_TRACE_WARNING3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3);} |
| 205 | #define NCI_TRACE_WARNING4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4);} |
| 206 | #define NCI_TRACE_WARNING5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5);} |
| 207 | #define NCI_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_WARNING) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m,p1,p2,p3,p4,p5,p6);} |
| 208 | |
| 209 | #define NCI_TRACE_API0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_API, m);} |
| 210 | #define NCI_TRACE_API1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1);} |
| 211 | #define NCI_TRACE_API2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2);} |
| 212 | #define NCI_TRACE_API3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3);} |
| 213 | #define NCI_TRACE_API4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4);} |
| 214 | #define NCI_TRACE_API5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4,p5);} |
| 215 | #define NCI_TRACE_API6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_API) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_API, m,p1,p2,p3,p4,p5,p6);} |
| 216 | |
| 217 | #define NCI_TRACE_EVENT0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m);} |
| 218 | #define NCI_TRACE_EVENT1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1);} |
| 219 | #define NCI_TRACE_EVENT2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2);} |
| 220 | #define NCI_TRACE_EVENT3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3);} |
| 221 | #define NCI_TRACE_EVENT4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4);} |
| 222 | #define NCI_TRACE_EVENT5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5);} |
| 223 | #define NCI_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_EVENT) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m,p1,p2,p3,p4,p5,p6);} |
| 224 | |
| 225 | #define NCI_TRACE_DEBUG0(m) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m);} |
| 226 | #define NCI_TRACE_DEBUG1(m,p1) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1);} |
| 227 | #define NCI_TRACE_DEBUG2(m,p1,p2) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2);} |
| 228 | #define NCI_TRACE_DEBUG3(m,p1,p2,p3) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3);} |
| 229 | #define NCI_TRACE_DEBUG4(m,p1,p2,p3,p4) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4);} |
| 230 | #define NCI_TRACE_DEBUG5(m,p1,p2,p3,p4,p5) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5);} |
| 231 | #define NCI_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6) {if (nfc_hal_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m,p1,p2,p3,p4,p5,p6);} |
| 232 | |
| 233 | #ifdef __cplusplus |
| 234 | extern "C" |
| 235 | { |
| 236 | #endif |
| 237 | |
| 238 | extern void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...); |
| 239 | |
| 240 | #ifdef __cplusplus |
| 241 | } |
| 242 | #endif |
| 243 | |
| 244 | #endif /* GKI_TARGET_H */ |