• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @file    wm_efuse.h
18  *
19  * @brief   virtual efuse Driver Module
20  *
21  * @author  dave
22  *
23  * Copyright (c) 2014 Winner Microelectronics Co., Ltd.
24  */
25 #ifndef WM_EFUSE_H
26 #define WM_EFUSE_H
27 
28 #define TLS_EFUSE_STATUS_OK      (0)
29 #define TLS_EFUSE_STATUS_EINVALID      (1)
30 #define TLS_EFUSE_STATUS_EIO      (2)
31 
32 enum {
33     CMD_WIFI_MAC = 0x01,
34     CMD_BT_MAC,
35     CMD_TX_DC,
36     CMD_RX_DC,
37     CMD_TX_IQ_GAIN,
38     CMD_RX_IQ_GAIN,
39     CMD_TX_IQ_PHASE,
40     CMD_RX_IQ_PHASE,
41     CMD_TX_GAIN,
42     CMD_ALL,
43 };
44 
45 #define FREQERR_ADDR  (FT_MAGICNUM_ADDR + sizeof(FT_PARAM_ST))
46 #define FREQERR_LEN  (4)
47 #define CAL_FLAG_ADDR  (FT_MAGICNUM_ADDR + sizeof(FT_PARAM_ST)+4)
48 #define CAL_FLAG_LEN    (4)
49 
50 #define TX_GAIN_LEN   (28*3)
51 
52 /**
53  * @defgroup Driver_APIs Driver APIs
54  * @brief Driver APIs
55  */
56 
57 /**
58  * @addtogroup Driver_APIs
59  * @{
60  */
61 
62 /**
63  * @defgroup EFUSE_Driver_APIs EFUSE Driver APIs
64  * @brief EFUSE driver APIs
65  */
66 
67 /**
68  * @addtogroup EFUSE_Driver_APIs
69  * @{
70  */
71 
72 /**
73 * @brief 	This function is used to init ft param.
74 *
75 * @param[in]	None
76 *
77 * @retval	 	TRUE			init success
78 * @retval		FALSE			init failed
79 */
80 int tls_ft_param_init(void);
81 
82 /**
83 * @brief 	This function is used to write ft_param.
84 *
85 * @param[in]	opnum  ft cmd
86 * @param[in]	data   data pointer
87 * @param[in]	len  len to write data
88 *
89 * @retval	 	TLS_EFUSE_STATUS_OK			set success
90 * @retval		TLS_EFUSE_STATUS_EIO			set failed
91 */
92 int tls_ft_param_set(unsigned int opnum, void *data, unsigned int len);
93 
94 /**
95 * @brief 	This function is used to read ft_param.
96 *
97 * @param[in]	opnum  ft cmd
98 * @param[in]	data   data pointer
99 * @param[in]	len  len to read data
100 *
101 * @retval	 	TLS_EFUSE_STATUS_OK			get success
102 * @retval		TLS_EFUSE_STATUS_EIO			get failed
103 */
104 int tls_ft_param_get(unsigned int opnum, void *data, unsigned int rdlen);
105 
106 /**
107 * @brief 	This function is used to get mac addr
108 *
109 * @param[in]	mac		mac addr,6 byte
110 *
111 * @retval	 	TLS_EFUSE_STATUS_OK			get success
112 * @retval		TLS_EFUSE_STATUS_EIO			get failed
113 */
114 int tls_get_mac_addr(u8 *mac);
115 
116 /**
117 * @brief 	This function is used to set mac addr
118 *
119 * @param[in]	mac		mac addr,6 byte
120 *
121 * @retval	 	TLS_EFUSE_STATUS_OK			set success
122 * @retval		TLS_EFUSE_STATUS_EIO			set failed
123 */
124 int tls_set_mac_addr(u8 *mac);
125 /**
126 * @brief 	This function is used to get bluetooth mac addr
127 *
128 * @param[in]	mac		mac addr,6 byte
129 *
130 * @retval	 	TLS_EFUSE_STATUS_OK			get success
131 * @retval		TLS_EFUSE_STATUS_EIO			get failed
132 */
133 int tls_get_bt_mac_addr(u8 *mac);
134 
135 /**
136 * @brief 	This function is used to set bluetooth mac addr
137 *
138 * @param[in]	mac		mac addr,6 byte
139 *
140 * @retval	 	TLS_EFUSE_STATUS_OK			set success
141 * @retval		TLS_EFUSE_STATUS_EIO			set failed
142 */
143 int tls_set_bt_mac_addr(u8 *mac);
144 
145 /**
146 * @brief 	This function is used to get tx gain
147 *
148 * @param[in]	txgain		tx gain,12 byte
149 *
150 * @retval	 	TLS_EFUSE_STATUS_OK			get success
151 * @retval		TLS_EFUSE_STATUS_EIO		get failed
152 */
153 int tls_get_tx_gain(u8 *txgain);
154 
155 /**
156 * @brief 	This function is used to set tx gain
157 *
158 * @param[in]	txgain		tx gain,12 byte
159 *
160 * @retval	 	TLS_EFUSE_STATUS_OK			set success
161 * @retval		TLS_EFUSE_STATUS_EIO		set failed
162 */
163 int tls_set_tx_gain(u8 *txgain);
164 
165 /**
166 * @brief 	This function is used to get tx lod
167 *
168 * @param[in]	txlo		tx lod
169 *
170 * @retval	 	TLS_EFUSE_STATUS_OK			get success
171 * @retval		TLS_EFUSE_STATUS_EIO		get failed
172 */
173 int tls_get_tx_lo(u8 *txlo);
174 
175 /**
176 * @brief 	This function is used to set tx lod
177 *
178 * @param[in]	txlo		tx lod
179 *
180 * @retval	 	TLS_EFUSE_STATUS_OK			set success
181 * @retval		TLS_EFUSE_STATUS_EIO		set failed
182 */
183 
184 int tls_set_tx_lo(u8 *txlo);
185 
186 /**
187 * @brief 	This function is used to get tx iq gain
188 *
189 * @param[in]	txGain
190 *
191 * @retval	 	TLS_EFUSE_STATUS_OK			get success
192 * @retval		TLS_EFUSE_STATUS_EIO		get failed
193 */
194 int tls_get_tx_iq_gain(u8 *txGain);
195 
196 /**
197 * @brief 	This function is used to set tx iq gain
198 *
199 * @param[in]	txGain
200 *
201 * @retval	 	TLS_EFUSE_STATUS_OK			set success
202 * @retval		TLS_EFUSE_STATUS_EIO		set failed
203 */
204 int tls_set_tx_iq_gain(u8 *txGain);
205 
206 /**
207 * @brief 	This function is used to get rx iq gain
208 *
209 * @param[in]	rxGain
210 *
211 * @retval	 	TLS_EFUSE_STATUS_OK			get success
212 * @retval		TLS_EFUSE_STATUS_EIO		get failed
213 */
214 int tls_get_rx_iq_gain(u8 *rxGain);
215 
216 /**
217 * @brief 	This function is used to get rx iq gain
218 *
219 * @param[in]	rxGain
220 *
221 * @retval	 	TLS_EFUSE_STATUS_OK			set success
222 * @retval		TLS_EFUSE_STATUS_EIO		set failed
223 */
224 int tls_set_rx_iq_gain(u8 *rxGain);
225 
226 /**
227 * @brief 	This function is used to get tx iq phase
228 *
229 * @param[in]	txPhase
230 *
231 * @retval	 	TLS_EFUSE_STATUS_OK			get success
232 * @retval		TLS_EFUSE_STATUS_EIO		get failed
233 */
234 int tls_get_tx_iq_phase(u8 *txPhase);
235 
236 /**
237 * @brief 	This function is used to set tx iq phase
238 *
239 * @param[in]	txPhase
240 *
241 * @retval	 	TLS_EFUSE_STATUS_OK			set success
242 * @retval		TLS_EFUSE_STATUS_EIO		set failed
243 */
244 int tls_set_tx_iq_phase(u8 *txPhase);
245 
246 /**
247 * @brief 	This function is used to get rx iq phase
248 *
249 * @param[in]	rxPhase
250 *
251 * @retval	 	TLS_EFUSE_STATUS_OK			get success
252 * @retval		TLS_EFUSE_STATUS_EIO		get failed
253 */
254 int tls_get_rx_iq_phase(u8 *rxPhase);
255 
256 /**
257 * @brief 	This function is used to set rx iq phase
258 *
259 * @param[in]	rxPhase
260 *
261 * @retval	 	TLS_EFUSE_STATUS_OK			set success
262 * @retval		TLS_EFUSE_STATUS_EIO		set failed
263 */
264 int tls_set_rx_iq_phase(u8 *rxPhase);
265 
266 /**
267 * @brief 	This function is used to set/get freq err
268 *
269 * @param[in]	freqerr	(Unit:Hz),relative to base frequency(chan 1,2,3,4,5......13,14)
270 * @param[in]    flag  1-set  0-get
271 * @retval	 	TLS_EFUSE_STATUS_OK			set/get success
272 * @retval		TLS_EFUSE_STATUS_EIO		set/get failed
273 */
274 int tls_freq_err_op(u8 *freqerr, u8 flag);
275 
276 /**
277 * @brief 	This function is used to set/get cal finish flag
278 *
279 * @param[in]	calflag 1- finish calibration, non-1-do not calibration
280 * @param[in]    flag  1-set  0-get
281 *
282 * @retval	 	TLS_EFUSE_STATUS_OK		set/get success
283 * @retval		TLS_EFUSE_STATUS_EIO		set/get failed
284 */
285 int tls_rf_cal_finish_op(u8 *calflag, u8 flag);
286 
287 /**
288  * @}
289  */
290 
291 /**
292  * @}
293  */
294 
295 #endif /* WM_EFUSE_H */
296 
297