1 /******************************************************************************
2  *
3  *  Copyright (C) 2011-2014 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  *  This file contains compile-time configurable constants for BRCM HAL
22  *  modules
23  *
24  ******************************************************************************/
25 #include "nci_defs.h"
26 #include "nfc_brcm_defs.h"
27 #include "nfc_hal_int.h"
28 
29 /* the SetConfig at start up*/
30 uint8_t nfc_hal_start_up_cfg[] = {
31     /* TLV len */ 31,
32     /* B0 */ NCI_PARAM_ID_EMVCO_ENABLE,
33     /* B1 */ 1,
34     /* B2 */
35     1, /* (1 = enable emvco mode, 0 = disable emvco mode) Default = 0.*/
36     /* B3 */ NCI_PARAM_ID_CONTINUE_MODE, /* NFCC will restart discovery
37                                             after deactivated */
38     /* B4 */ 1,
39     /* B5 */ 1, /* (1 = enable, 0 = disable) Default = 0.*/
40     /* B6 */ NCI_PARAM_ID_RFU_CONFIG,
41     /* B7 */ 0x14,
42     /* B8 */ 0x00,
43     /* B9 */ 0x00,
44     /* B10*/ 0x00,
45     /* B11*/ 0x00,
46     /* B12*/ 0x0E,
47     /* B13*/ 0xE8,
48     /* B14*/ 0xF0,
49     /* B15*/ 0x55,
50     /* B16*/ 0x00,
51     /* B17*/ 0x0F, /* CE3 SO delay in sec */
52     /* B18*/ 0x00,
53     /* B19*/ 0x00,
54     /* B20*/ 0x00,
55     /* B21*/ 0x00,
56     /* B22*/ 0x00,
57     /* B23*/ 0x00,
58     /* B24*/ 0x00,
59     /* B25*/ 0x00,
60     /* B26*/ 0x00,
61     /* B27*/ 0x00,
62     /* B28*/ NCI_PARAM_ID_ACT_ORDER, /* polling sequence */
63     /* B29*/ 1,
64     /* B30*/ 1, /* (1 = active mode polling before passive, 0 = passive
65                    polling first) Default = 0.*/
66 };
67 
68 uint8_t* p_nfc_hal_dm_start_up_cfg = (uint8_t*)nfc_hal_start_up_cfg;
69 
70 /* the VSCs at start up:
71  * The VSCs are specified in TLV format similar to nfa_start_up_cfg[]
72  * first byte is the TLV total len.
73  * B0 is the first T; i.e. the opcode for the VSC
74  * B1 is the len of the VSC parameters/payload
75  * */
76 uint8_t nfc_hal_dm_start_up_vsc_cfg[] = {
77     /* TLV len */ 5,
78     /* B0 */ NCI_MTS_CMD | NCI_GID_PROP,
79     /* B1 */ NCI_MSG_FRAME_LOG,
80     /* B2 */ 2,
81     /* B3 */ 0, /* 1 to enable RF frames */
82     /* B4 */ 1  /* 1 to enable SWP frames */
83 };
84 
85 uint8_t* p_nfc_hal_dm_start_up_vsc_cfg = NULL;
86 
87 /* the SetConfig at HAL_NfcPreDiscover. This is done once after HAL_NfcOpen */
88 uint8_t nfc_hal_pre_discover_cfg[] = {
89     /* TLV len */ 0x0A,
90     /* B0 */ NCI_PARAM_ID_SWPCFG,
91     /* B1 */ 0x08,
92     /* B2 */ 0x01,
93     /* B3 */ 0x08,
94     /* B4 */ 0x00,
95     /* B5 */ 0x04,
96     /* B6 */ 0x80,
97     /* B7 */ 0xC3,
98     /* B8 */ 0xC9,
99     /* B9 */ 0x01};
100 
101 uint8_t* p_nfc_hal_pre_discover_cfg = NULL;
102 
103 /* LPTD parameters (LowPowerTagDetection)
104  * This is typical values for 20791B2
105  * The timing and threshold parameters used for a customer handset/hardware may
106  * vary
107  * depending on antenna and should be verified during a customer testing phase.
108  * the data fields without comments are too complicated. Please see ""
109  * */
110 const uint8_t nfc_hal_dm_lptd_cfg[] = {
111     21,                        /* total TLV length excluding itself */
112     NCI_PARAM_ID_TAGSNIFF_CFG, /* type */
113     19,                        /* length */
114     0x01,                      /* B0 enable: 0/disable, 1/enable*/
115     0x02, /* B1 poll count: number of full power poll before starting lptd
116              poll */
117     0xFF, /* B2 sniff count lsb: number of lptd poll before switching to
118              full power poll */
119     0xFF, /* B3 sniff count msb */
120     0x80, /* B4 threshold: Bigger thresholds give a smaller LPTD range but
121              more immunity to false detections. Smaller thresholds increase
122              LPTD range at the cost of greater likelihood of false
123              detections. */
124     0x40, /* B5 delay lsb: delay (us) to sampling power */
125     0x00, /* B6 delay msb */
126     0x40, /* B7 carrier threshold lsb */
127     0x00, /* B8 carrier threshold msb */
128     0x80, /* B9 mode: Bitwise variable used to enable various algorithm
129              modes.*/
130     0x80, /* B10 0-offset lsb */
131     0x00, /* B11 0-offset msb */
132     0x10, /* B12 field sense time lsb */
133     0x00, /* B13 field sense time msb */
134     0x00, /* B14 false detect threshold lsb: 0x00 to disable LPTD NTF. The
135              number of false tag detections to resport LPTD NTF. */
136     0x00, /* B15 false detect threshold msb. A false tag detect - full poll
137              results in no tag being detected.*/
138     0x75, /* B16 mode1; Bitwise variable used to enable various algorithm
139              modes. */
140     0x0D, /* B17 lptd ant cfg rx */
141     0x30, /* B18 lptd rdr cfg ve */
142 };
143 
144 uint8_t* p_nfc_hal_dm_lptd_cfg = (uint8_t*)&nfc_hal_dm_lptd_cfg[0];
145 
146 /*
147 ** NFCC has a table which has 9 XTAL frequencies: 9.6, 13, 16.2,  19.2, 24, 26,
148 *38.4, 52 and 37.4 in MHz.
149 ** For these 9 xtal frequencies, host doesn't need to configure PLL325.
150 ** For 43341, host doesn't need to configure it at all.
151 */
152 uint8_t* p_nfc_hal_dm_pll_325_cfg = NULL;
153 
154 /*
155 ** Proprietary pre-set is required, if not NULL.
156 */
157 tNFC_HAL_DM_PRE_SET_MEM* p_nfc_hal_dm_pre_set_mem = NULL;
158 
159 tNFC_HAL_CFG nfc_hal_cfg = {
160     false, /* set nfc_hal_prm_nvm_required to TRUE, if the platform wants to
161               abort PRM process without NVM */
162     (uint16_t)NFC_HAL_NFCC_ENABLE_TIMEOUT, /* max time to wait for RESET NTF
163                                          *after setting REG_PU to high
164                                          ** If NFCC doesn't have NVM or cannot
165                                          *load patch from NVM without Xtal
166                                          *setting
167                                          ** then set it to short to optimize
168                                          *bootup time because NFCC cannot send
169                                          *RESET NTF.
170                                          ** Otherwise, it depends on NVM type
171                                          *and size of patchram.
172                                          */
173     (uint16_t)NFC_HAL_NFCC_ENABLE_TIMEOUT  /* max time to wait for RESET NTF
174                                          *after setting Xtal frequency
175                                          ** It depends on NVM type and size of
176                                          *patchram.
177                                          */
178 #if (NFC_HAL_HCI_INCLUDED == TRUE)
179     ,
180     true, /* set nfc_hal_first_boot to TRUE, if platform enables NFC for the
181              first time after bootup */
182     (HAL_NFC_HCI_UICC0_HOST | HAL_NFC_HCI_UICC1_HOST |
183      HAL_NFC_HCI_UICC2_HOST) /* Set bit(s) for supported UICC(s) */
184 #endif
185 };
186 
187 tNFC_HAL_CFG* p_nfc_hal_cfg = (tNFC_HAL_CFG*)&nfc_hal_cfg;
188 
189 const uint8_t nfc_hal_dm_xtal_params_cfg[] = {
190     8,    /* length */
191     0x00, /* B0 Rfpll_cfg_pll_xtal_div_2                  */
192     0x00, /* B1 Rfpll_cfg_pll_vcocal1_0_cal_ref_timeout   */
193     0x00, /* B2 Rfpll_cfg_pll_vcocal2_cal_count           */
194     0x00, /* B3 Rfpll_cfg_pll_vcocal3_cal_count           */
195     0x00, /* B4 Rfpll_cfg_pll_dsm_b_msb_wild_base         */
196     0x00, /* B5 Rfpll_cfg_pll_dsm_b_lsb_3_wild_base_3     */
197     0x00, /* B6 Rfpll_cfg_pll_dsm_b_lsb_2_wild_base_2     */
198     0x00  /* B7 Rfpll_cfg_pll_dsm_b_lsb_1_wild_base_1     */
199 };
200 
201 /* By default, the XTAL command does not need these extra params. */
202 uint8_t* p_nfc_hal_dm_xtal_params_cfg = NULL;
203