• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-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 
20 /******************************************************************************
21  *
22  *  Internal NFC HAL API functions.
23  *
24  ******************************************************************************/
25 #ifndef NFC_HAL_INT_API_H
26 #define NFC_HAL_INT_API_H
27 
28 /****************************************************************************
29 ** Device Configuration definitions
30 ****************************************************************************/
31 
32 #define NFC_HAL_PLL_325_SETCONFIG_PARAM_LEN     (2 + NCI_PARAM_LEN_PLL325_CFG_PARAM)
33 
34 /* Crystal Frequency Index (in 1 KHz) */
35 enum
36 {
37     NFC_HAL_XTAL_INDEX_9600,
38     NFC_HAL_XTAL_INDEX_13000,
39     NFC_HAL_XTAL_INDEX_16200,
40     NFC_HAL_XTAL_INDEX_19200,
41     NFC_HAL_XTAL_INDEX_24000,
42     NFC_HAL_XTAL_INDEX_26000,
43     NFC_HAL_XTAL_INDEX_38400,
44     NFC_HAL_XTAL_INDEX_52000,
45     NFC_HAL_XTAL_INDEX_37400,
46     NFC_HAL_XTAL_INDEX_MAX
47 };
48 typedef UINT8 tNFC_HAL_XTAL_INDEX;
49 
50 /* Broadcom specific device initialization before sending NCI reset */
51 
52 typedef struct
53 {
54     UINT32                  brcm_hw_id;
55     UINT16                  xtal_freq;
56     UINT8                   xtal_index;
57 } tNFC_HAL_DEV_INIT_XTAL_CFG;
58 
59 #define NFC_HAL_DEV_INIT_MAX_XTAL_CFG       5
60 
61 typedef struct
62 {
63     UINT8                       num_xtal_cfg;
64     tNFC_HAL_DEV_INIT_XTAL_CFG  xtal_cfg[NFC_HAL_DEV_INIT_MAX_XTAL_CFG];
65 } tNFC_HAL_DEV_INIT_CFG;
66 
67 /*****************************************************************************
68 **  Low Power Mode definitions
69 *****************************************************************************/
70 
71 #define NFC_HAL_LP_SNOOZE_MODE_NONE      NFC_SNOOZE_MODE_NONE       /* Snooze mode disabled    */
72 #define NFC_HAL_LP_SNOOZE_MODE_UART      NFC_SNOOZE_MODE_UART       /* Snooze mode for UART    */
73 #define NFC_HAL_LP_SNOOZE_MODE_SPI_I2C   NFC_SNOOZE_MODE_SPI_I2C    /* Snooze mode for SPI/I2C */
74 
75 #define NFC_HAL_LP_ACTIVE_LOW            NFC_SNOOZE_ACTIVE_LOW      /* high to low voltage is asserting */
76 #define NFC_HAL_LP_ACTIVE_HIGH           NFC_SNOOZE_ACTIVE_HIGH     /* low to high voltage is asserting */
77 
78 /*****************************************************************************
79 **  Patch RAM Constants
80 *****************************************************************************/
81 
82 /* patch format type */
83 #define NFC_HAL_PRM_FORMAT_BIN  0x00
84 #define NFC_HAL_PRM_FORMAT_HCD  0x01
85 #define NFC_HAL_PRM_FORMAT_NCD  0x02
86 typedef UINT8 tNFC_HAL_PRM_FORMAT;
87 
88 /*****************************************************************************
89 **  Patch RAM Callback for event notificaton
90 *****************************************************************************/
91 /* Events for tNFC_HAL_PRM_CBACK */
92 enum
93 {
94     NFC_HAL_PRM_CONTINUE_EVT,
95     NFC_HAL_PRM_COMPLETE_EVT,
96     NFC_HAL_PRM_ABORT_EVT,
97     NFC_HAL_PRM_ABORT_INVALID_PATCH_EVT,       /* Patch is invalid (bad version, project id, or chip)  */
98     NFC_HAL_PRM_ABORT_BAD_SIGNATURE_EVT,       /* Patch has invalid signature                          */
99     NFC_HAL_PRM_SPD_GET_PATCHFILE_HDR_EVT,     /* Secure Patch Download: request for patchfile header  */
100     NFC_HAL_PRM_SPD_GET_NEXT_PATCH,            /* Get first command of next patch in patchfile         */
101     NFC_HAL_PRM_ABORT_NO_NVM_EVT               /* nfc_hal_prm_nvm_required is TRUE and NVM is unavail  */
102 };
103 
104 typedef void (tNFC_HAL_PRM_CBACK) (UINT8 event);
105 
106 typedef UINT8 tNFC_HAL_NCI_EVT;     /* MT + Opcode */
107 typedef void (tNFC_HAL_NCI_CBACK) (tNFC_HAL_NCI_EVT event, UINT16 data_len, UINT8 *p_data);
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 
113 /*******************************************************************************
114 **
115 ** Function         HAL_NfcPreInitDone
116 **
117 ** Description      Notify that pre-initialization of NFCC is complete
118 **
119 ** Returns          void
120 **
121 *******************************************************************************/
122 void HAL_NfcPreInitDone (tHAL_NFC_STATUS status);
123 
124 /*******************************************************************************
125 **
126 ** Function         HAL_NfcReInit
127 **
128 ** Description      This function is called to restart initialization after REG_PU
129 **                  toggled because of failure to detect NVM type or download patchram.
130 **
131 ** Note             This function should be called only during the HAL init process
132 **
133 ** Returns          HAL_NFC_STATUS_OK if successfully initiated
134 **                  HAL_NFC_STATUS_FAILED otherwise
135 **
136 *******************************************************************************/
137 tHAL_NFC_STATUS HAL_NfcReInit (void);
138 
139 /*******************************************************************************
140 **
141 ** Function         HAL_NfcSetSnoozeMode
142 **
143 ** Description      Set snooze mode
144 **                  snooze_mode
145 **                      NFC_HAL_LP_SNOOZE_MODE_NONE - Snooze mode disabled
146 **                      NFC_HAL_LP_SNOOZE_MODE_UART - Snooze mode for UART
147 **                      NFC_HAL_LP_SNOOZE_MODE_SPI_I2C - Snooze mode for SPI/I2C
148 **
149 **                  idle_threshold_dh/idle_threshold_nfcc
150 **                      Idle Threshold Host in 100ms unit
151 **
152 **                  nfc_wake_active_mode/dh_wake_active_mode
153 **                      NFC_HAL_LP_ACTIVE_LOW - high to low voltage is asserting
154 **                      NFC_HAL_LP_ACTIVE_HIGH - low to high voltage is asserting
155 **
156 **                  p_snooze_cback
157 **                      Notify status of operation
158 **
159 ** Returns          tHAL_NFC_STATUS
160 **
161 *******************************************************************************/
162 tHAL_NFC_STATUS HAL_NfcSetSnoozeMode (UINT8 snooze_mode,
163                                       UINT8 idle_threshold_dh,
164                                       UINT8 idle_threshold_nfcc,
165                                       UINT8 nfc_wake_active_mode,
166                                       UINT8 dh_wake_active_mode,
167                                       tHAL_NFC_STATUS_CBACK *p_snooze_cback);
168 
169 /*******************************************************************************
170 **
171 ** Function         HAL_NfcPrmDownloadStart
172 **
173 ** Description      Initiate patch download
174 **
175 ** Input Params
176 **                  format_type     patch format type
177 **                                  (NFC_HAL_PRM_FORMAT_BIN, NFC_HAL_PRM_FORMAT_HCD, or
178 **                                   NFC_HAL_PRM_FORMAT_NCD)
179 **
180 **                  dest_address    destination adderess (needed for BIN format only)
181 **
182 **                  p_patchram_buf  pointer to patchram buffer. If NULL,
183 **                                  then app must call HAL_NfcPrmDownloadContinue when
184 **                                  NFC_HAL_PRM_CONTINUE_EVT is received, to send the next
185 **                                  segment of patchram
186 **
187 **                  patchram_len    size of p_patchram_buf (if non-NULL)
188 **
189 **                  patchram_delay  The delay after each patch.
190 **                                  If the given value is less than the size of the patchram,
191 **                                  the size of patchram is used instead.
192 **
193 **                  p_cback         callback for download status
194 **
195 **
196 ** Returns          TRUE if successful, otherwise FALSE
197 **
198 **
199 *******************************************************************************/
200 BOOLEAN HAL_NfcPrmDownloadStart (tNFC_HAL_PRM_FORMAT format_type,
201                                  UINT32              dest_address,
202                                  UINT8               *p_patchram_buf,
203                                  UINT32              patchram_len,
204                                  UINT32              patchram_delay,
205                                  tNFC_HAL_PRM_CBACK  *p_cback);
206 
207 /*******************************************************************************
208 **
209 ** Function         HAL_NfcPrmDownloadContinue
210 **
211 ** Description      Send next segment of patchram to controller. Called when
212 **                  NFC_HAL_PRM_CONTINUE_EVT is received.
213 **
214 **                  Only needed if HAL_NfcPrmDownloadStart was called with
215 **                  p_patchram_buf=NULL
216 **
217 ** Input Params     p_patch_data    pointer to patch data
218 **                  patch_data_len  patch data len
219 **
220 ** Returns          TRUE if successful, otherwise FALSE
221 **
222 *******************************************************************************/
223 BOOLEAN HAL_NfcPrmDownloadContinue (UINT8 *p_patch_data,
224                                     UINT16 patch_data_len);
225 
226 /*******************************************************************************
227 **
228 ** Function         HAL_NfcPrmSetI2cPatch
229 **
230 ** Description      Specify patchfile for BCM20791B3 I2C fix. This fix
231 **                  must be downloaded prior to initial patch download for I2C
232 **                  transport
233 **
234 ** Input Params     p_i2c_patchfile_buf: pointer to patch for i2c fix
235 **                  i2c_patchfile_len: length of patch
236 **                  prei2c_delay: the delay before downloading main patch
237 **                                if 0 is given, NFC_HAL_PRM_POST_I2C_FIX_DELAY is used instead.
238 **
239 ** Returns          Nothing
240 **
241 **
242 *******************************************************************************/
243 void HAL_NfcPrmSetI2cPatch (UINT8 *p_i2c_patchfile_buf,
244                       UINT16 i2c_patchfile_len, UINT32 prei2c_delay);
245 
246 /*******************************************************************************
247 **
248 ** Function         HAL_NfcPrmSetSpdNciCmdPayloadSize
249 **
250 ** Description      Set Host-to-NFCC NCI message size for secure patch download
251 **
252 **                  This API must be called before calling HAL_NfcPrmDownloadStart.
253 **                  If the API is not called, then PRM will use the default
254 **                  message size.
255 **
256 **                  Typically, this API is only called for platforms that have
257 **                  message-size limitations in the transport/driver.
258 **
259 **                  Valid message size range: NFC_HAL_PRM_MIN_NCI_CMD_PAYLOAD_SIZE to 255.
260 **
261 ** Returns          HAL_NFC_STATUS_OK if successful
262 **                  HAL_NFC_STATUS_FAILED otherwise
263 **
264 **
265 *******************************************************************************/
266 tHAL_NFC_STATUS HAL_NfcPrmSetSpdNciCmdPayloadSize (UINT8 max_payload_size);
267 
268 /*******************************************************************************
269 **
270 ** Function         HAL_NfcSetMaxRfDataCredits
271 **
272 ** Description      This function sets the maximum RF data credit for HAL.
273 **                  If 0, use the value reported from NFCC.
274 **
275 ** Returns          none
276 **
277 *******************************************************************************/
278 void HAL_NfcSetMaxRfDataCredits (UINT8 max_credits);
279 
280 /*******************************************************************************
281 **
282 ** Function         HAL_NfcSetTraceLevel
283 **
284 ** Description      This function sets the trace level for HAL.  If called with
285 **                  a value of 0xFF, it simply returns the current trace level.
286 **
287 ** Returns          The new or current trace level
288 **
289 *******************************************************************************/
290 UINT8 HAL_NfcSetTraceLevel (UINT8 new_level);
291 
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif /* NFC_HAL_INT_API_H */
298 
299