Home | History | Annotate | Download | only in include
      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 /* Mininum payload size for SPD NCI commands (used to validate HAL_NfcPrmSetSpdNciCmdPayloadSize) */
     95 /* Default is 32, as required by the NCI specifications; however this value may be          */
     96 /* over-riden for platforms that have transport packet limitations                          */
     97 #ifndef NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE
     98 #define NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE    (32)
     99 #endif
    100 
    101 /* amount of time to wait for authenticating/committing patch to NVM */
    102 #ifndef NFC_HAL_PRM_COMMIT_DELAY
    103 #define NFC_HAL_PRM_COMMIT_DELAY                (30000)
    104 #endif
    105 
    106 /* amount of time to wait after downloading preI2C patch before downloading LPM/FPM patch */
    107 #ifndef NFC_HAL_PRM_POST_I2C_FIX_DELAY
    108 #define NFC_HAL_PRM_POST_I2C_FIX_DELAY          (200)
    109 #endif
    110 
    111 /* NFCC will respond to more than one technology during listen discovery  */
    112 #ifndef NFC_HAL_DM_MULTI_TECH_RESP
    113 #define NFC_HAL_DM_MULTI_TECH_RESP              TRUE
    114 #endif
    115 
    116 /* Data rate for 15693 command/response, it must be same as RW_I93_FLAG_DATA_RATE in nfc_target.h */
    117 #define NFC_HAL_I93_FLAG_DATA_RATE_LOW          0x00
    118 #define NFC_HAL_I93_FLAG_DATA_RATE_HIGH         0x02
    119 
    120 #ifndef NFC_HAL_I93_FLAG_DATA_RATE
    121 #define NFC_HAL_I93_FLAG_DATA_RATE              NFC_HAL_I93_FLAG_DATA_RATE_HIGH
    122 #endif
    123 
    124 /* Quick Timer */
    125 #ifndef QUICK_TIMER_TICKS_PER_SEC
    126 #define QUICK_TIMER_TICKS_PER_SEC               100       /* 10ms timer */
    127 #endif
    128 
    129 #ifndef NFC_HAL_SHARED_TRANSPORT_ENABLED
    130 #define NFC_HAL_SHARED_TRANSPORT_ENABLED        FALSE
    131 #endif
    132 
    133 /* Enable verbose tracing by default */
    134 #ifndef NFC_HAL_TRACE_VERBOSE
    135 #define NFC_HAL_TRACE_VERBOSE                   TRUE
    136 #endif
    137 
    138 #ifndef NFC_HAL_INITIAL_TRACE_LEVEL
    139 #define NFC_HAL_INITIAL_TRACE_LEVEL             5
    140 #endif
    141 
    142 /* Map NFC serial port to USERIAL_PORT_6 by default */
    143 #ifndef USERIAL_NFC_PORT
    144 #define USERIAL_NFC_PORT                        (USERIAL_PORT_6)
    145 #endif
    146 
    147 /* Restore NFCC baud rate to default on shutdown if baud rate was updated */
    148 #ifndef NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN
    149 #define NFC_HAL_RESTORE_BAUD_ON_SHUTDOWN        TRUE
    150 #endif
    151 
    152 /* Enable protocol tracing by default */
    153 #ifndef NFC_HAL_TRACE_PROTOCOL
    154 #define NFC_HAL_TRACE_PROTOCOL                  TRUE
    155 #endif
    156 
    157 /* Legacy protocol-trace-enable macro */
    158 #ifndef BT_TRACE_PROTOCOL
    159 #define BT_TRACE_PROTOCOL                       (NFC_HAL_TRACE_PROTOCOL)
    160 #endif
    161 
    162 /* Enable HAL tracing by default */
    163 #ifndef NFC_HAL_USE_TRACES
    164 #define NFC_HAL_USE_TRACES                      TRUE
    165 #endif
    166 
    167 /* HAL trace macros */
    168 #if (NFC_HAL_USE_TRACES == TRUE)
    169 #define NCI_TRACE_0(l,t,m)                           LogMsg((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)),(m))
    170 #define NCI_TRACE_1(l,t,m,p1)                        LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1))
    171 #define NCI_TRACE_2(l,t,m,p1,p2)                     LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1),   \
    172                                                         (UINTPTR)(p2))
    173 #define NCI_TRACE_3(l,t,m,p1,p2,p3)                  LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1),   \
    174                                                         (UINTPTR)(p2),(UINTPTR)(p3))
    175 #define NCI_TRACE_4(l,t,m,p1,p2,p3,p4)               LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1),   \
    176                                                         (UINTPTR)(p2),(UINTPTR)(p3),(UINTPTR)(p4))
    177 #define NCI_TRACE_5(l,t,m,p1,p2,p3,p4,p5)            LogMsg(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t),(m),(UINTPTR)(p1),   \
    178                                                         (UINTPTR)(p2),(UINTPTR)(p3),(UINTPTR)(p4), \
    179                                                         (UINTPTR)(p5))
    180 #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),   \
    181                                                         (UINTPTR)(p2),(UINTPTR)(p3),(UINTPTR)(p4), \
    182                                                         (UINTPTR)(p5),(UINTPTR)(p6))
    183 
    184 #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);}
    185 #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);}
    186 #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);}
    187 #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);}
    188 #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);}
    189 #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);}
    190 #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);}
    191 
    192 #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);}
    193 #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);}
    194 #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);}
    195 #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);}
    196 #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);}
    197 #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);}
    198 #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);}
    199 
    200 #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);}
    201 #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);}
    202 #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);}
    203 #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);}
    204 #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);}
    205 #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);}
    206 #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);}
    207 
    208 #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);}
    209 #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);}
    210 #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);}
    211 #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);}
    212 #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);}
    213 #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);}
    214 #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);}
    215 
    216 #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);}
    217 #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);}
    218 #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);}
    219 #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);}
    220 #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);}
    221 #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);}
    222 #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);}
    223 
    224 #else /* Disable HAL tracing */
    225 
    226 #define HAL_TRACE_0(l,t,m)
    227 #define HAL_TRACE_1(l,t,m,p1)
    228 #define HAL_TRACE_2(l,t,m,p1,p2)
    229 #define HAL_TRACE_3(l,t,m,p1,p2,p3)
    230 #define HAL_TRACE_4(l,t,m,p1,p2,p3,p4)
    231 #define HAL_TRACE_5(l,t,m,p1,p2,p3,p4,p5)
    232 #define HAL_TRACE_6(l,t,m,p1,p2,p3,p4,p5,p6)
    233 
    234 #define HAL_TRACE_ERROR0(m)
    235 #define HAL_TRACE_ERROR1(m,p1)
    236 #define HAL_TRACE_ERROR2(m,p1,p2)
    237 #define HAL_TRACE_ERROR3(m,p1,p2,p3)
    238 #define HAL_TRACE_ERROR4(m,p1,p2,p3,p4)
    239 #define HAL_TRACE_ERROR5(m,p1,p2,p3,p4,p5)
    240 #define HAL_TRACE_ERROR6(m,p1,p2,p3,p4,p5,p6)
    241 
    242 #define HAL_TRACE_WARNING0(m)
    243 #define HAL_TRACE_WARNING1(m,p1)
    244 #define HAL_TRACE_WARNING2(m,p1,p2)
    245 #define HAL_TRACE_WARNING3(m,p1,p2,p3)
    246 #define HAL_TRACE_WARNING4(m,p1,p2,p3,p4)
    247 #define HAL_TRACE_WARNING5(m,p1,p2,p3,p4,p5)
    248 #define HAL_TRACE_WARNING6(m,p1,p2,p3,p4,p5,p6)
    249 
    250 #define HAL_TRACE_API0(m)
    251 #define HAL_TRACE_API1(m,p1)
    252 #define HAL_TRACE_API2(m,p1,p2)
    253 #define HAL_TRACE_API3(m,p1,p2,p3)
    254 #define HAL_TRACE_API4(m,p1,p2,p3,p4)
    255 #define HAL_TRACE_API5(m,p1,p2,p3,p4,p5)
    256 #define HAL_TRACE_API6(m,p1,p2,p3,p4,p5,p6)
    257 
    258 #define HAL_TRACE_EVENT0(m)
    259 #define HAL_TRACE_EVENT1(m,p1)
    260 #define HAL_TRACE_EVENT2(m,p1,p2)
    261 #define HAL_TRACE_EVENT3(m,p1,p2,p3)
    262 #define HAL_TRACE_EVENT4(m,p1,p2,p3,p4)
    263 #define HAL_TRACE_EVENT5(m,p1,p2,p3,p4,p5)
    264 #define HAL_TRACE_EVENT6(m,p1,p2,p3,p4,p5,p6)
    265 
    266 #define HAL_TRACE_DEBUG0(m)
    267 #define HAL_TRACE_DEBUG1(m,p1)
    268 #define HAL_TRACE_DEBUG2(m,p1,p2)
    269 #define HAL_TRACE_DEBUG3(m,p1,p2,p3)
    270 #define HAL_TRACE_DEBUG4(m,p1,p2,p3,p4)
    271 #define HAL_TRACE_DEBUG5(m,p1,p2,p3,p4,p5)
    272 #define HAL_TRACE_DEBUG6(m,p1,p2,p3,p4,p5,p6)
    273 #endif  /* Disable HAL tracing */
    274 
    275 #endif  /* GKI_TARGET_H */
    276