1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2020 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
16 *
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
21 *
22 * Larry Finger <Larry.Finger@lwfinger.net>
23 *
24 *****************************************************************************/
25 #include "halrf_precomp.h"
26
27 #if 1
28
halrf_chl_rfk_trigger(void * rf_void,enum phl_phy_idx phy_idx,bool force)29 enum rtw_hal_status halrf_chl_rfk_trigger(void *rf_void,
30 enum phl_phy_idx phy_idx,
31 bool force)
32 {
33 struct rf_info *rf = (struct rf_info *)rf_void;
34 u32 start_time, finish_time;
35
36 #if 0
37 struct rtw_hal_com_t *hal_i = rf->hal_com;
38
39 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
40 (hal_i->is_con_tx ||
41 hal_i->is_single_tone ||
42 hal_i->is_carrier_suppresion))
43 return;
44
45 if (hal_i->rfk_forbidden)
46 return;
47 #endif
48
49 start_time = _os_get_cur_time_us();
50
51 /*[RX Gain K]*/
52 halrf_do_rx_gain_k(rf, phy_idx);
53
54 /*[TX GAP K]*/
55 halrf_gapk_trigger(rf, phy_idx, true);
56
57 /*[RX dck]*/
58 halrf_rx_dck_trigger(rf, phy_idx, true);
59
60 /*[LOK, IQK]*/
61 halrf_iqk_trigger(rf, phy_idx, force);
62
63 /*[TSSI Trk]*/
64 halrf_tssi_trigger(rf, phy_idx);
65
66 /*[DPK]*/
67 halrf_dpk_trigger(rf, phy_idx, force);
68 halrf_fw_ntfy(rf, phy_idx);
69
70 finish_time = _os_get_cur_time_us();
71 RF_DBG(rf, DBG_RF_RFK, "[RX_DCK] halrf_chl_rfk_trigger processing time = %d.%dms\n",
72 HALRF_ABS(finish_time, start_time) / 1000,
73 HALRF_ABS(finish_time, start_time) % 1000);
74 return RTW_HAL_STATUS_SUCCESS;
75 }
76
halrf_dack_recover(void * rf_void,u8 offset,enum rf_path path,u32 val,bool reload)77 void halrf_dack_recover(void *rf_void,
78 u8 offset,
79 enum rf_path path,
80 u32 val,
81 bool reload)
82 {
83
84 struct rf_info *rf = (struct rf_info *)rf_void;
85 struct rtw_hal_com_t *hal_i = rf->hal_com;
86 #if 0
87 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
88 (hal_i->is_con_tx ||
89 hal_i->is_single_tone ||
90 hal_i->is_carrier_suppresion))
91 return;
92
93 if (hal_i->rfk_forbidden)
94 return;
95 #endif
96
97 switch (hal_i->chip_id) {
98 #ifdef RF_8852A_SUPPORT
99 case CHIP_WIFI6_8852A:
100 if (hal_i->cv == CAV)
101 halrf_dack_recover_8852a(rf, offset, path, val, reload);
102 break;
103 #endif
104 default:
105 break;
106 }
107 }
108
halrf_dack_trigger(void * rf_void,bool force)109 enum rtw_hal_status halrf_dack_trigger(void *rf_void, bool force)
110 {
111
112 struct rf_info *rf = (struct rf_info *)rf_void;
113 struct rtw_hal_com_t *hal_i = rf->hal_com;
114 struct halrf_dack_info *dack = &rf->dack;
115 u32 start_time, finish_time;
116
117 #if 0
118 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
119 (hal_i->is_con_tx ||
120 hal_i->is_single_tone ||
121 hal_i->is_carrier_suppresion))
122 return;
123
124 if (hal_i->rfk_forbidden)
125 return;
126 #endif
127
128 if (!(rf->support_ability & HAL_RF_DACK))
129 return RTW_HAL_STATUS_SUCCESS;
130
131 halrf_btc_rfk_ntfy(rf, (BIT(HW_PHY_0) << 4), RF_BTC_DACK, RFK_START);
132 start_time = _os_get_cur_time_us();
133 switch (hal_i->chip_id) {
134 #ifdef RF_8852A_SUPPORT
135 case CHIP_WIFI6_8852A:
136 if (hal_i->cv == CAV)
137 halrf_dac_cal_8852a(rf, force);
138 else
139 halrf_dac_cal_8852a_b(rf, force);
140 break;
141 #endif
142 #ifdef RF_8852B_SUPPORT
143 case CHIP_WIFI6_8852B:
144 halrf_dac_cal_8852b(rf, force);
145 break;
146 #endif
147 default:
148 break;
149 }
150 finish_time = _os_get_cur_time_us();
151 halrf_btc_rfk_ntfy(rf, (BIT(HW_PHY_0) << 4), RF_BTC_DACK, RFK_STOP);
152 dack->dack_time = HALRF_ABS(finish_time, start_time) / 1000;
153 RF_DBG(rf, DBG_RF_RFK, "[RX_DCK] DACK processing time = %d.%dms\n",
154 HALRF_ABS(finish_time, start_time) / 1000,
155 HALRF_ABS(finish_time, start_time) % 1000);
156 return RTW_HAL_STATUS_SUCCESS;
157 }
158
halrf_rx_dck_trigger(void * rf_void,enum phl_phy_idx phy_idx,bool is_afe)159 enum rtw_hal_status halrf_rx_dck_trigger(void *rf_void,
160 enum phl_phy_idx phy_idx, bool is_afe)
161 {
162
163 struct rf_info *rf = (struct rf_info *)rf_void;
164 struct rtw_hal_com_t *hal_i = rf->hal_com;
165
166 u32 start_time, finish_time;
167 #if 0
168 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
169 (hal_i->is_con_tx ||
170 hal_i->is_single_tone ||
171 hal_i->is_carrier_suppresion))
172 return;
173
174 if (hal_i->rfk_forbidden)
175 return;
176 #endif
177
178 if (!(rf->support_ability & HAL_RF_RXDCK))
179 return RTW_HAL_STATUS_SUCCESS;
180
181 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_RXDCK, RFK_START);
182
183 halrf_tmac_tx_pause(rf, phy_idx, true);
184
185 #if 0
186 for (i = 0; i < 2000; i++)
187 halrf_delay_us(rf, 10); /*delay 20ms*/
188 #endif
189
190 start_time = _os_get_cur_time_us();
191
192 switch (hal_i->chip_id) {
193 #ifdef RF_8852A_SUPPORT
194 case CHIP_WIFI6_8852A:
195 halrf_rx_dck_8852a(rf, phy_idx, is_afe);
196 break;
197 #endif
198 #ifdef RF_8852B_SUPPORT
199 case CHIP_WIFI6_8852B:
200 halrf_rx_dck_8852b(rf, phy_idx, false);
201 break;
202 #endif
203
204 default:
205 break;
206 }
207
208 halrf_tmac_tx_pause(rf, phy_idx, false);
209
210 finish_time = _os_get_cur_time_us();
211
212 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_RXDCK, RFK_STOP);
213
214 RF_DBG(rf, DBG_RF_RXDCK, "[RX_DCK] RX_DCK processing time = %d.%dms\n",
215 HALRF_ABS(finish_time, start_time) / 1000,
216 HALRF_ABS(finish_time, start_time) % 1000);
217
218 return RTW_HAL_STATUS_SUCCESS;
219 }
220
halrf_iqk_trigger(void * rf_void,enum phl_phy_idx phy_idx,bool force)221 enum rtw_hal_status halrf_iqk_trigger(void *rf_void,
222 enum phl_phy_idx phy_idx,
223 bool force)
224 {
225 struct rf_info *rf = (struct rf_info *)rf_void;
226 struct rtw_hal_com_t *hal_i = rf->hal_com;
227 u32 start_time, finish_time;
228
229 #if 0
230 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
231 (hal_i->is_con_tx ||
232 hal_i->is_single_tone ||
233 hal_i->is_carrier_suppresion))
234 return;
235
236 if (hal_i->rfk_forbidden)
237 return;
238 #endif
239
240 if (!(rf->support_ability & HAL_RF_IQK))
241 return RTW_HAL_STATUS_SUCCESS;
242 rf->rfk_is_processing = true;
243 start_time = _os_get_cur_time_us();
244
245 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_IQK, RFK_START);
246
247 halrf_tmac_tx_pause(rf, phy_idx, true);
248
249 halrf_iqk_init(rf);
250 halrf_iqk(rf, phy_idx, force);
251
252 halrf_tmac_tx_pause(rf, phy_idx, false);
253 rf->rfk_is_processing = false;
254 finish_time = _os_get_cur_time_us();
255
256 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_IQK, RFK_STOP);
257 RF_DBG(rf, DBG_RF_IQK, "[IQK] IQK processing time = %d.%dms\n",
258 HALRF_ABS(finish_time, start_time) / 1000,
259 HALRF_ABS(finish_time, start_time) % 1000);
260
261 return RTW_HAL_STATUS_SUCCESS;
262 }
263
halrf_lck_trigger(void * rf_void)264 void halrf_lck_trigger(void *rf_void)
265 {
266 struct rf_info *rf = (struct rf_info *)rf_void;
267 struct rtw_hal_com_t *hal_i = rf->hal_com;
268
269 #if 0
270 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
271 (hal_i->is_con_tx ||
272 hal_i->is_single_tone ||
273 hal_i->is_carrier_suppresion))
274 return;
275
276 if (hal_i->rfk_forbidden)
277 return;
278 #endif
279
280 if (!(rf->support_ability & HAL_RF_LCK))
281 return;
282
283 #if 0
284 while (*dm->is_scan_in_process) {
285 RF_DBG(dm, DBG_RF_IQK, "[LCK]scan is in process, bypass LCK\n");
286 return;
287 }
288 #endif
289
290 switch (hal_i->chip_id) {
291 #ifdef RF_8852A_SUPPORT
292 case CHIP_WIFI6_8852A:
293 break;
294 #endif
295 default:
296 break;
297 }
298
299
300 }
301
halrf_dpk_trigger(void * rf_void,enum phl_phy_idx phy_idx,bool force)302 enum rtw_hal_status halrf_dpk_trigger(void *rf_void,
303 enum phl_phy_idx phy_idx,
304 bool force)
305 {
306 struct rf_info *rf = (struct rf_info *)rf_void;
307 struct rtw_hal_com_t *hal_i = rf->hal_com;
308
309 u32 start_time, finish_time;
310 #if 0
311 if ((rf->phl_com->drv_mode == RTW_DRV_MODE_MP) &
312 (hal_i->is_con_tx ||
313 hal_i->is_single_tone ||
314 hal_i->is_carrier_suppresion))
315 return;
316
317 if (hal_i->rfk_forbidden)
318 return;
319 #endif
320
321 if (!(rf->support_ability & HAL_RF_DPK) || rf->phl_com->id.id == 0x1010a) /*USB buffalo*/
322 return RTW_HAL_STATUS_SUCCESS;
323
324 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_DPK, RFK_START);
325
326 halrf_tmac_tx_pause(rf, phy_idx, true);
327
328 rf->rfk_is_processing = true;
329
330 start_time = _os_get_cur_time_us();
331
332 switch (hal_i->chip_id) {
333 #ifdef RF_8852A_SUPPORT
334 case CHIP_WIFI6_8852A:
335 halrf_dpk_8852a(rf, phy_idx, force);
336 break;
337 #endif
338 #ifdef RF_8852B_SUPPORT
339 case CHIP_WIFI6_8852B:
340 halrf_dpk_8852b(rf, phy_idx, force);
341 break;
342 #endif
343 default:
344 break;
345 }
346
347 rf->rfk_is_processing = false;
348
349 finish_time = _os_get_cur_time_us();
350
351 halrf_tmac_tx_pause(rf, phy_idx, false);
352
353 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_DPK, RFK_STOP);
354
355 RF_DBG(rf, DBG_RF_DPK, "[DPK] DPK processing time = %d.%dms\n",
356 HALRF_ABS(finish_time, start_time) / 1000,
357 HALRF_ABS(finish_time, start_time) % 1000);
358
359 return RTW_HAL_STATUS_SUCCESS;
360 }
361
halrf_dpk_tracking(void * rf_void)362 enum rtw_hal_status halrf_dpk_tracking(void *rf_void)
363 {
364 struct rf_info *rf = (struct rf_info *)rf_void;
365 struct rtw_hal_com_t *hal_i = rf->hal_com;
366 struct halrf_dpk_info *dpk = &rf->dpk;
367
368 if (!(rf->support_ability & HAL_RF_DPK_TRACK) || rf->rfk_is_processing ||
369 rf->is_watchdog_stop || rf->psd.psd_progress)
370 return RTW_HAL_STATUS_SUCCESS;
371
372 rf->is_watchdog_stop = true; /*avoid race condition*/
373
374 switch (hal_i->chip_id) {
375 #ifdef RF_8852A_SUPPORT
376 case CHIP_WIFI6_8852A:
377 halrf_dpk_track_8852a(rf);
378 break;
379 #endif
380 #ifdef RF_8852B_SUPPORT
381 case CHIP_WIFI6_8852B:
382 halrf_dpk_track_8852b(rf);
383 break;
384 #endif
385 default:
386 break;
387 }
388
389 rf->is_watchdog_stop = false;
390
391 return RTW_HAL_STATUS_SUCCESS;
392 }
393
halrf_tssi_tracking(void * rf_void)394 enum rtw_hal_status halrf_tssi_tracking(void *rf_void)
395 {
396 struct rf_info *rf = (struct rf_info *)rf_void;
397 struct rtw_hal_com_t *hal_i = rf->hal_com;
398
399 if ((!(rf->support_ability & HAL_RF_TX_PWR_TRACK)) || (!(rf->support_ability & HAL_RF_TSSI_TRK))
400 || rf->rfk_is_processing || rf->is_watchdog_stop || rf->psd.psd_progress)
401 return RTW_HAL_STATUS_SUCCESS;
402
403 rf->is_watchdog_stop = true; /*avoid race condition*/
404
405 switch (hal_i->chip_id) {
406 #ifdef RF_8852A_SUPPORT
407 case CHIP_WIFI6_8852A:
408 halrf_tssi_tracking_8852a(rf);
409 break;
410 #endif
411 default:
412 break;
413 }
414
415 rf->is_watchdog_stop = false;
416
417 return RTW_HAL_STATUS_SUCCESS;
418 }
419
halrf_tssi_tracking_clean(void * rf_void,s16 power_dbm)420 enum rtw_hal_status halrf_tssi_tracking_clean(void *rf_void, s16 power_dbm)
421 {
422 struct rf_info *rf = (struct rf_info *)rf_void;
423 struct rtw_hal_com_t *hal_i = rf->hal_com;
424
425 if ((!(rf->support_ability & HAL_RF_TX_PWR_TRACK)) || (!(rf->support_ability & HAL_RF_TSSI_TRK))
426 || rf->rfk_is_processing || rf->is_watchdog_stop || rf->psd.psd_progress)
427 return RTW_HAL_STATUS_SUCCESS;
428
429 rf->is_watchdog_stop = true; /*avoid race condition*/
430
431 switch (hal_i->chip_id) {
432 #ifdef RF_8852A_SUPPORT
433 case CHIP_WIFI6_8852A:
434 halrf_tssi_tracking_clean_8852ab(rf, power_dbm);
435 break;
436 #endif
437 default:
438 break;
439 }
440
441 rf->is_watchdog_stop = false;
442
443 return RTW_HAL_STATUS_SUCCESS;
444 }
445
halrf_tssi_ant_open(void * rf_void)446 enum rtw_hal_status halrf_tssi_ant_open(void *rf_void)
447 {
448 struct rf_info *rf = (struct rf_info *)rf_void;
449 struct rtw_hal_com_t *hal_i = rf->hal_com;
450
451 if ((!(rf->support_ability & HAL_RF_TX_PWR_TRACK)) || (!(rf->support_ability & HAL_RF_TSSI_TRK))
452 || rf->rfk_is_processing || rf->is_watchdog_stop || rf->psd.psd_progress)
453 return RTW_HAL_STATUS_SUCCESS;
454
455 rf->is_watchdog_stop = true; /*avoid race condition*/
456
457 switch (hal_i->chip_id) {
458 #ifdef RF_8852A_SUPPORT
459 case CHIP_WIFI6_8852A:
460 halrf_tssi_ant_open_8852a(rf);
461 break;
462 #endif
463 default:
464 break;
465 }
466
467 rf->is_watchdog_stop = false;
468
469 return RTW_HAL_STATUS_SUCCESS;
470 }
471
halrf_tssi_trigger(void * rf_void,enum phl_phy_idx phy_idx)472 enum rtw_hal_status halrf_tssi_trigger(void *rf_void, enum phl_phy_idx phy_idx)
473 {
474 struct rf_info *rf = (struct rf_info *)rf_void;
475 struct rtw_hal_com_t *hal_i = rf->hal_com;
476 struct halrf_tssi_info *tssi_info = &rf->tssi;
477 u32 start_time, finish_time;
478
479 start_time = _os_get_cur_time_us();
480
481 if (rf->phl_com->drv_mode == RTW_DRV_MODE_MP) {
482 if (tssi_info->tssi_type == TSSI_OFF ) {
483 rf->support_ability = rf->support_ability & ~HAL_RF_TX_PWR_TRACK;
484 }
485 }
486
487 if (!(rf->support_ability & HAL_RF_TX_PWR_TRACK)) {
488 switch (hal_i->chip_id) {
489 #ifdef RF_8852A_SUPPORT
490 case CHIP_WIFI6_8852A:
491 halrf_tssi_disable_8852a(rf, phy_idx);
492 break;
493 #endif
494 #ifdef RF_8852B_SUPPORT
495 case CHIP_WIFI6_8852B:
496 halrf_tssi_disable_8852b(rf, phy_idx);
497 break;
498 #endif
499
500 default:
501 break;
502 }
503
504 return RTW_HAL_STATUS_SUCCESS;
505 }
506
507 rf->rfk_is_processing = true;
508
509 switch (hal_i->chip_id) {
510 #ifdef RF_8852A_SUPPORT
511 case CHIP_WIFI6_8852A:
512 halrf_do_tssi_8852a(rf, phy_idx);
513 break;
514 #endif
515 #ifdef RF_8852B_SUPPORT
516 case CHIP_WIFI6_8852B:
517 halrf_do_tssi_8852b(rf, phy_idx);
518 break;
519 #endif
520 default:
521 break;
522 }
523
524 rf->rfk_is_processing = false;
525
526 finish_time = _os_get_cur_time_us();
527 RF_DBG(rf, DBG_RF_RFK, "[TSSI] %s processing time = %d.%dms\n",
528 __func__,
529 HALRF_ABS(finish_time, start_time) / 1000,
530 HALRF_ABS(finish_time, start_time) % 1000);
531
532 return RTW_HAL_STATUS_SUCCESS;
533 }
534
halrf_do_tssi_scan(void * rf_void,enum phl_phy_idx phy_idx)535 void halrf_do_tssi_scan(void *rf_void, enum phl_phy_idx phy_idx)
536 {
537 struct rf_info *rf = (struct rf_info *)rf_void;
538 struct rtw_hal_com_t *hal_i = rf->hal_com;
539 u32 start_time, finish_time;
540
541 if (!(rf->support_ability & HAL_RF_TX_PWR_TRACK))
542 return;
543
544 start_time = _os_get_cur_time_us();
545
546 rf->rfk_is_processing = true;
547 switch (hal_i->chip_id) {
548 #ifdef RF_8852A_SUPPORT
549 case CHIP_WIFI6_8852A:
550 halrf_do_tssi_scan_8852a(rf, phy_idx);
551 break;
552 #endif
553 #ifdef RF_8852B_SUPPORT
554 case CHIP_WIFI6_8852B:
555 halrf_do_tssi_scan_8852b(rf, phy_idx);
556 break;
557 #endif
558
559 default:
560 break;
561 }
562 rf->rfk_is_processing = false;
563
564 finish_time = _os_get_cur_time_us();
565
566 RF_DBG(rf, DBG_RF_RFK, "[TSSI] %s processing time = %d.%dms\n",
567 __func__,
568 HALRF_ABS(finish_time, start_time) / 1000,
569 HALRF_ABS(finish_time, start_time) % 1000);
570 }
571
halrf_tssi_set_avg(void * rf_void,enum phl_phy_idx phy_idx,bool enable)572 void halrf_tssi_set_avg(void *rf_void,
573 enum phl_phy_idx phy_idx, bool enable)
574 {
575 struct rf_info *rf = (struct rf_info *)rf_void;
576 struct rtw_hal_com_t *hal_i = rf->hal_com;
577
578 if (!(rf->support_ability & HAL_RF_TX_PWR_TRACK))
579 return;
580
581 rf->rfk_is_processing = true;
582 switch (hal_i->chip_id) {
583 #ifdef RF_8852A_SUPPORT
584 case CHIP_WIFI6_8852A:
585 halrf_tssi_set_avg_8852ab(rf, phy_idx, enable);
586 break;
587 #endif
588 default:
589 break;
590 }
591 rf->rfk_is_processing = false;
592 }
593
halrf_tssi_default_txagc(void * rf_void,enum phl_phy_idx phy_idx,bool enable)594 void halrf_tssi_default_txagc(void *rf_void,
595 enum phl_phy_idx phy_idx, bool enable)
596 {
597 struct rf_info *rf = (struct rf_info *)rf_void;
598 struct rtw_hal_com_t *hal_i = rf->hal_com;
599
600 if (!(rf->support_ability & HAL_RF_TX_PWR_TRACK))
601 return;
602
603 rf->rfk_is_processing = true;
604 switch (hal_i->chip_id) {
605 #ifdef RF_8852A_SUPPORT
606 case CHIP_WIFI6_8852A:
607 halrf_tssi_default_txagc_8852ab(rf, phy_idx, enable);
608 break;
609 #endif
610
611 #ifdef RF_8852B_SUPPORT
612 case CHIP_WIFI6_8852B:
613 halrf_tssi_default_txagc_8852b(rf, phy_idx, enable);
614 break;
615 #endif
616
617 default:
618 break;
619 }
620 rf->rfk_is_processing = false;
621 }
622
halrf_tssi_set_efuse_to_de(void * rf_void,enum phl_phy_idx phy_idx)623 void halrf_tssi_set_efuse_to_de(void *rf_void,
624 enum phl_phy_idx phy_idx)
625 {
626 struct rf_info *rf = (struct rf_info *)rf_void;
627 struct rtw_hal_com_t *hal_i = rf->hal_com;
628
629 if (!(rf->support_ability & HAL_RF_TX_PWR_TRACK))
630 return;
631
632 rf->rfk_is_processing = true;
633 switch (hal_i->chip_id) {
634 #ifdef RF_8852A_SUPPORT
635 case CHIP_WIFI6_8852A:
636 halrf_tssi_set_efuse_to_de_8852ab(rf, phy_idx);
637 break;
638 #endif
639
640 #ifdef RF_8852B_SUPPORT
641 case CHIP_WIFI6_8852B:
642 halrf_tssi_set_efuse_to_de_8852b(rf, phy_idx);
643 break;
644 #endif
645 default:
646 break;
647 }
648 rf->rfk_is_processing = false;
649 }
650
halrf_tssi_scan_ch(void * rf_void,enum rf_path path)651 void halrf_tssi_scan_ch(void *rf_void, enum rf_path path)
652 {
653 struct rf_info *rf = (struct rf_info *)rf_void;
654 struct rtw_hal_com_t *hal_i = rf->hal_com;
655
656 if (!(rf->support_ability & HAL_RF_TX_PWR_TRACK))
657 return;
658
659 rf->rfk_is_processing = true;
660 switch (hal_i->chip_id) {
661 #ifdef RF_8852A_SUPPORT
662 case CHIP_WIFI6_8852A:
663 halrf_tssi_scan_ch_8852ab(rf, path);
664 break;
665 #endif
666
667 #ifdef RF_8852B_SUPPORT
668 case CHIP_WIFI6_8852B:
669 halrf_tssi_scan_ch_8852b(rf, path);
670 break;
671 #endif
672 default:
673 break;
674 }
675 rf->rfk_is_processing = false;
676 }
677
halrf_hw_tx(void * rf_void,u8 path,u16 cnt,s16 dbm,u32 rate,u8 bw,bool enable)678 void halrf_hw_tx(void *rf_void, u8 path, u16 cnt, s16 dbm, u32 rate, u8 bw,
679 bool enable)
680
681 {
682 struct rf_info *rf = (struct rf_info *)rf_void;
683 struct rtw_hal_com_t *hal_i = rf->hal_com;
684
685 switch (hal_i->chip_id) {
686 #ifdef RF_8852A_SUPPORT
687 case CHIP_WIFI6_8852A:
688 halrf_tssi_hw_tx_8852a(rf, HW_PHY_0, path, cnt, dbm, T_HT_MF, 0, enable);
689 break;
690 #endif
691 default:
692 break;
693 }
694 }
695
halrf_txgapk_init(void * rf_void)696 void halrf_txgapk_init(void *rf_void)
697 {
698 struct rf_info *rf = (struct rf_info *)rf_void;
699 struct rtw_hal_com_t *hal_i = rf->hal_com;
700
701 switch (hal_i->chip_id) {
702 #ifdef RF_8852A_SUPPORT
703 case CHIP_WIFI6_8852A:
704 //halrf_txgapk_init_8852a(rf);
705 break;
706 #endif
707 #ifdef RF_8852B_SUPPORT
708 case CHIP_WIFI6_8852B:
709 halrf_txgapk_init_8852b(rf);
710 break;
711 #endif
712 default:
713 break;
714 }
715 }
716
halrf_gapk_trigger(void * rf_void,enum phl_phy_idx phy_idx,bool force)717 enum rtw_hal_status halrf_gapk_trigger(void *rf_void,
718 enum phl_phy_idx phy_idx,
719 bool force)
720 {
721 struct rf_info *rf = (struct rf_info *)rf_void;
722 struct rtw_hal_com_t *hal_i = rf->hal_com;
723
724 u32 start_time, finish_time;
725 if (!(rf->support_ability & HAL_RF_TXGAPK))
726 return RTW_HAL_STATUS_SUCCESS;
727
728 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_TXGAPK, RFK_START);
729 halrf_tmac_tx_pause(rf, phy_idx, true);
730
731 rf->rfk_is_processing = true;
732
733 start_time = _os_get_cur_time_us();
734
735 halrf_txgapk_init(rf);
736
737 switch (hal_i->chip_id) {
738 #ifdef RF_8852A_SUPPORT
739 case CHIP_WIFI6_8852A:
740 halrf_do_txgapk_8852a(rf, phy_idx);
741 break;
742 #endif
743 #ifdef RF_8852B_SUPPORT
744 case CHIP_WIFI6_8852B:
745 halrf_do_txgapk_8852b(rf, phy_idx);
746 break;
747 #endif
748
749 default:
750 break;
751 }
752
753 rf->rfk_is_processing = false;
754
755 finish_time = _os_get_cur_time_us();
756
757 halrf_tmac_tx_pause(rf, phy_idx, false);
758 halrf_btc_rfk_ntfy(rf, (BIT(phy_idx) << 4), RF_BTC_TXGAPK, RFK_STOP);
759
760 RF_DBG(rf, DBG_RF_TXGAPK, "[TXGAPK] %s processing time = %d.%dms\n",
761 __func__,
762 HALRF_ABS(finish_time, start_time) / 1000,
763 HALRF_ABS(finish_time, start_time) % 1000);
764
765 return RTW_HAL_STATUS_SUCCESS;
766 }
767
halrf_gapk_enable(void * rf_void,enum phl_phy_idx phy_idx)768 enum rtw_hal_status halrf_gapk_enable(void *rf_void,
769 enum phl_phy_idx phy_idx)
770 {
771 struct rf_info *rf = (struct rf_info *)rf_void;
772 struct rtw_hal_com_t *hal_i = rf->hal_com;
773
774 rf->rfk_is_processing = true;
775
776 switch (hal_i->chip_id) {
777 #ifdef RF_8852A_SUPPORT
778 case CHIP_WIFI6_8852A:
779 halrf_txgapk_enable_8852a(rf, phy_idx);
780 break;
781 #endif
782 #ifdef RF_8852B_SUPPORT
783 case CHIP_WIFI6_8852B:
784 halrf_txgapk_enable_8852b(rf, phy_idx);
785 break;
786 #endif
787 default:
788 break;
789 }
790
791 rf->rfk_is_processing = false;
792
793 return RTW_HAL_STATUS_SUCCESS;
794 }
795
796
halrf_gapk_disable(void * rf_void,enum phl_phy_idx phy_idx)797 enum rtw_hal_status halrf_gapk_disable(void *rf_void,
798 enum phl_phy_idx phy_idx)
799 {
800 struct rf_info *rf = (struct rf_info *)rf_void;
801 struct rtw_hal_com_t *hal_i = rf->hal_com;
802
803 rf->rfk_is_processing = true;
804
805 switch (hal_i->chip_id) {
806 #ifdef RF_8852A_SUPPORT
807 case CHIP_WIFI6_8852A:
808 halrf_txgapk_write_table_default_8852a(rf, phy_idx);
809 break;
810 #endif
811 #ifdef RF_8852B_SUPPORT
812 case CHIP_WIFI6_8852B:
813 halrf_txgapk_write_table_default_8852b(rf, phy_idx);
814 break;
815 #endif
816 default:
817 break;
818 }
819
820 rf->rfk_is_processing = false;
821
822 return RTW_HAL_STATUS_SUCCESS;
823 }
824
825
halrf_rck_trigger(void * rf_void,enum phl_phy_idx phy_idx)826 void halrf_rck_trigger(void *rf_void,
827 enum phl_phy_idx phy_idx)
828 {
829 struct rf_info *rf = (struct rf_info *)rf_void;
830 struct rtw_hal_com_t *hal_i = rf->hal_com;
831
832 u8 path = 0;
833
834 switch (hal_i->chip_id) {
835 #ifdef RF_8852A_SUPPORT
836 case CHIP_WIFI6_8852A:
837 for (path = 0; path < 2; path++)
838 halrf_rck_8852a(rf, path);
839 break;
840 #endif
841 #ifdef RF_8852B_SUPPORT
842 case CHIP_WIFI6_8852B:
843 for (path = 0; path < 2; path++)
844 halrf_rck_8852b(rf, path);
845 break;
846 #endif
847 default:
848 break;
849 }
850 }
851
halrf_gapk_save_tx_gain(struct rf_info * rf)852 void halrf_gapk_save_tx_gain(struct rf_info *rf)
853 {
854 struct rtw_hal_com_t *hal_i = rf->hal_com;
855
856 switch (hal_i->chip_id) {
857 #ifdef RF_8852A_SUPPORT
858 case CHIP_WIFI6_8852A:
859 //halrf_gapk_save_tx_gain_8852a(rf);
860 break;
861 #endif
862 default:
863 break;
864 }
865 }
866
halrf_gapk_reload_tx_gain(struct rf_info * rf)867 void halrf_gapk_reload_tx_gain(struct rf_info *rf)
868 {
869 struct rtw_hal_com_t *hal_i = rf->hal_com;
870
871 switch (hal_i->chip_id) {
872 #ifdef RF_8852A_SUPPORT
873 case CHIP_WIFI6_8852A:
874 //halrf_gapk_reload_tx_gain_8852a(rf);
875 break;
876 #endif
877 default:
878 break;
879 }
880 }
881
882
883
halrf_lo_test(void * rf_void,bool is_on,enum rf_path path)884 void halrf_lo_test(void *rf_void, bool is_on, enum rf_path path)
885 {
886
887 struct rf_info *rf = (struct rf_info *)rf_void;
888 struct rtw_hal_com_t *hal_i = rf->hal_com;
889 #if 0
890 if (hal_i->is_mp_mode &&
891 hal_i->is_con_tx &&
892 hal_i->is_single_tone &&
893 hal_i->is_carrier_suppresion)
894 return;
895
896 if (hal_i->rfk_forbidden)
897 return;
898 #endif
899
900 switch (hal_i->chip_id) {
901 #ifdef RF_8852A_SUPPORT
902 case CHIP_WIFI6_8852A:
903 halrf_lo_test_8852a(rf, is_on, path);
904 break;
905 #endif
906 #ifdef RF_8852B_SUPPORT
907 case CHIP_WIFI6_8852B:
908 halrf_lo_test_8852b(rf, is_on, path);
909 break;
910 #endif
911 default:
912 break;
913 }
914 }
915
halrf_iqk_onoff(void * rf_void,bool is_enable)916 void halrf_iqk_onoff(void *rf_void, bool is_enable)
917 {
918 /*signal go throughput iqk or not*/
919 struct rf_info *rf = (struct rf_info *)rf_void;
920 struct rtw_hal_com_t *hal_i = rf->hal_com;
921 u8 path = 0x0;
922
923 if (!(rf->support_ability & HAL_RF_DPK))
924 return;
925
926 rf->rfk_is_processing = true;
927
928 switch (hal_i->chip_id) {
929 #ifdef RF_8852A_SUPPORT
930 case CHIP_WIFI6_8852A:
931 halrf_iqk_onoff_8852ab(rf, is_enable);
932 break;
933 #endif
934 default:
935 break;
936 }
937 rf->rfk_is_processing = false;
938
939 }
940
halrf_dpk_onoff(void * rf_void,bool is_enable)941 void halrf_dpk_onoff(void *rf_void, bool is_enable)
942 {
943 /*signal go throughput dpk or not*/
944 struct rf_info *rf = (struct rf_info *)rf_void;
945 struct rtw_hal_com_t *hal_i = rf->hal_com;
946 struct halrf_dpk_info *dpk = &rf->dpk;
947
948 u8 path = 0;
949 #if 0
950 if (hal_i->is_mp_mode &&
951 hal_i->is_con_tx &&
952 hal_i->is_single_tone &&
953 hal_i->is_carrier_suppresion)
954 return;
955
956 if (hal_i->rfk_forbidden)
957 return;
958 #endif
959 if (!(rf->support_ability & HAL_RF_DPK))
960 return;
961
962 rf->rfk_is_processing = true;
963
964 dpk->is_dpk_enable = is_enable;
965
966 switch (hal_i->chip_id) {
967 #ifdef RF_8852A_SUPPORT
968 case CHIP_WIFI6_8852A:
969 for (path = 0; path < 2; path++)
970 halrf_dpk_onoff_8852a(rf, path, false);
971 break;
972 #endif
973 #ifdef RF_8852B_SUPPORT
974 case CHIP_WIFI6_8852B:
975 for (path = 0; path < 2; path++)
976 halrf_dpk_onoff_8852b(rf, path, false);
977 break;
978 #endif
979 default:
980 break;
981 }
982 rf->rfk_is_processing = false;
983 }
984
halrf_dpk_track_onoff(void * rf_void,bool is_enable)985 void halrf_dpk_track_onoff(void *rf_void, bool is_enable)
986 {
987 struct rf_info *rf = (struct rf_info *)rf_void;
988
989 if (is_enable)
990 rf->support_ability = rf->support_ability | HAL_RF_DPK_TRACK;
991 else
992 rf->support_ability = rf->support_ability & ~HAL_RF_DPK_TRACK;
993 }
994
halrf_dpk_switch(void * rf_void,bool is_enable)995 void halrf_dpk_switch(void *rf_void, bool is_enable)
996 {
997 struct rf_info *rf = (struct rf_info *)rf_void;
998
999 if (is_enable) {
1000 halrf_dpk_onoff(rf, true);
1001 halrf_dpk_trigger(rf, HW_PHY_0, true);
1002 halrf_dpk_track_onoff(rf, true);
1003 halrf_wl_tx_power_control(rf, 0xffffeeee);
1004 } else {
1005 halrf_wl_tx_power_control(rf, 0xffff8034);
1006 halrf_dpk_track_onoff(rf, false);
1007 halrf_dpk_onoff(rf, false);
1008 }
1009 }
1010
halrf_dpk_init(void * rf_void)1011 void halrf_dpk_init(void *rf_void)
1012 {
1013 struct rf_info *rf = (struct rf_info *)rf_void;
1014 struct rtw_hal_com_t *hal_i = rf->hal_com;
1015 struct halrf_dpk_info *dpk = &rf->dpk;
1016
1017 u8 path, idx;
1018
1019 for (path = 0; path < KPATH; path++) {
1020 dpk->cur_idx[path] = 0;
1021 for (idx = 0; idx < DPK_BKUP_NUM; idx++) {
1022 dpk->bp[path][idx].band = 0;
1023 dpk->bp[path][idx].bw = 0;
1024 dpk->bp[path][idx].ch = 0;
1025 dpk->bp[path][idx].path_ok = 0;
1026 dpk->bp[path][idx].txagc_dpk = 0;
1027 dpk->bp[path][idx].ther_dpk = 0;
1028 dpk->bp[path][idx].gs = 0;
1029 dpk->bp[path][idx].pwsf = 0;
1030 }
1031 }
1032
1033 dpk->is_dpk_enable = true;
1034 dpk->is_dpk_reload_en = false;
1035
1036 switch (hal_i->chip_id) {
1037 #ifdef RF_8852A_SUPPORT
1038 case CHIP_WIFI6_8852A:
1039 halrf_dpk_init_8852a(rf);
1040 break;
1041 #endif
1042 #ifdef RF_8852B_SUPPORT
1043 case CHIP_WIFI6_8852B:
1044 halrf_dpk_init_8852b(rf);
1045 break;
1046 #endif
1047 default:
1048 break;
1049 }
1050 }
1051
halrf_rx_dck_onoff(void * rf_void,bool is_enable)1052 void halrf_rx_dck_onoff(void *rf_void, bool is_enable)
1053 {
1054 /*signal go throughput dpk or not*/
1055 struct rf_info *rf = (struct rf_info *)rf_void;
1056 struct rtw_hal_com_t *hal_i = rf->hal_com;
1057 #if 0
1058 if (hal_i->is_mp_mode &&
1059 hal_i->is_con_tx &&
1060 hal_i->is_single_tone &&
1061 hal_i->is_carrier_suppresion)
1062 return;
1063
1064 if (hal_i->rfk_forbidden)
1065 return;
1066 #endif
1067 if (!(rf->support_ability & HAL_RF_RXDCK))
1068 return;
1069
1070 switch (hal_i->chip_id) {
1071 #ifdef RF_8852A_SUPPORT
1072 case CHIP_WIFI6_8852A:
1073 halrf_rx_dck_onoff_8852a(rf, is_enable);
1074 break;
1075 #endif
1076 #ifdef RF_8852B_SUPPORT
1077 case CHIP_WIFI6_8852B:
1078 halrf_rx_dck_onoff_8852b(rf, is_enable);
1079 break;
1080 #endif
1081 default:
1082 break;
1083 }
1084 }
1085
halrf_gapk_onoff(void * rf_void,bool is_enable)1086 void halrf_gapk_onoff(void *rf_void, bool is_enable)
1087 {
1088 /*parameter to default or not*/
1089
1090 }
1091
halrf_dack_onoff(void * rf_void,bool is_enable)1092 void halrf_dack_onoff(void *rf_void, bool is_enable)
1093 {
1094 /*parameter to default or not*/
1095
1096 }
1097
halrf_tssi_onoff(void * rf_void,bool is_enable)1098 void halrf_tssi_onoff(void *rf_void, bool is_enable)
1099 {
1100 /*parameter to default or not*/
1101
1102 }
1103
halrf_get_iqk_onoff(void * rf_void)1104 bool halrf_get_iqk_onoff(void *rf_void)
1105 {
1106 return 1;
1107 }
1108
halrf_get_dpk_onoff(void * rf_void)1109 bool halrf_get_dpk_onoff(void *rf_void)
1110 {
1111 struct rf_info *rf = (struct rf_info *)rf_void;
1112 struct halrf_dpk_info *dpk = &rf->dpk;
1113
1114 return dpk->is_dpk_enable;
1115 }
1116
halrf_get_dpk_track_onoff(void * rf_void)1117 bool halrf_get_dpk_track_onoff(void *rf_void)
1118 {
1119 struct rf_info *rf = (struct rf_info *)rf_void;
1120
1121 if (rf->support_ability & HAL_RF_DPK_TRACK)
1122 return 1;
1123 else
1124 return 0;
1125 }
1126
halrf_get_gapk_onoff(void * rf_void)1127 bool halrf_get_gapk_onoff(void *rf_void)
1128 {
1129 return 1;
1130 }
halrf_get_dack_onoff(void * rf_void)1131 bool halrf_get_dack_onoff(void *rf_void)
1132 {
1133 return 1;
1134 }
halrf_get_tssi_onoff(void * rf_void)1135 bool halrf_get_tssi_onoff(void *rf_void)
1136 {
1137 return 1;
1138 }
1139
halrf_get_thermal(void * rf_void,u8 rf_path)1140 u8 halrf_get_thermal(void *rf_void, u8 rf_path)
1141 {
1142 struct rf_info *rf = (struct rf_info *)rf_void;
1143 struct rtw_hal_com_t *hal_com = rf->hal_com;
1144
1145 #ifdef RF_8852A_SUPPORT
1146 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1147 return halrf_get_thermal_8852a(rf, rf_path);
1148 #endif
1149
1150 #ifdef RF_8852B_SUPPORT
1151 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1152 return halrf_get_thermal_8852b(rf, rf_path);
1153 #endif
1154
1155 return 0;
1156
1157 }
1158
halrf_get_tssi_de(void * rf_void,enum phl_phy_idx phy_idx,u8 path)1159 u32 halrf_get_tssi_de(void *rf_void, enum phl_phy_idx phy_idx, u8 path)
1160 {
1161 return 0;
1162 }
1163
halrf_get_online_tssi_de(void * rf_void,enum phl_phy_idx phy_idx,u8 path,s32 dbm,s32 puot)1164 s32 halrf_get_online_tssi_de(void *rf_void, enum phl_phy_idx phy_idx, u8 path, s32 dbm, s32 puot)
1165 {
1166 struct rf_info *rf = (struct rf_info *)rf_void;
1167 struct rtw_hal_com_t *hal_i = rf->hal_com;
1168 s32 tmp = 0;
1169
1170 switch (hal_i->chip_id) {
1171 #ifdef RF_8852A_SUPPORT
1172 case CHIP_WIFI6_8852A:
1173 tmp = halrf_get_online_tssi_de_8852a(rf, phy_idx, path, dbm, puot);
1174 break;
1175 #endif
1176 #ifdef RF_8852B_SUPPORT
1177 case CHIP_WIFI6_8852B:
1178 tmp = halrf_get_online_tssi_de_8852b(rf, phy_idx, path, dbm, puot);
1179 break;
1180 #endif
1181
1182 default:
1183 break;
1184 }
1185
1186 return tmp;
1187 }
1188
halrf_tssi_enable(void * rf_void,enum phl_phy_idx phy_idx)1189 void halrf_tssi_enable(void *rf_void, enum phl_phy_idx phy_idx)
1190 {
1191 struct rf_info *rf = (struct rf_info *)rf_void;
1192 struct rtw_hal_com_t *hal_i = rf->hal_com;
1193
1194 switch (hal_i->chip_id) {
1195 #ifdef RF_8852A_SUPPORT
1196 case CHIP_WIFI6_8852A:
1197 halrf_tssi_enable_8852a(rf, phy_idx);
1198 break;
1199 #endif
1200 #ifdef RF_8852B_SUPPORT
1201 case CHIP_WIFI6_8852B:
1202 halrf_tssi_enable_8852b(rf, phy_idx);
1203 break;
1204 #endif
1205
1206 default:
1207 break;
1208 }
1209 }
1210
halrf_tssi_disable(void * rf_void,enum phl_phy_idx phy_idx)1211 void halrf_tssi_disable(void *rf_void, enum phl_phy_idx phy_idx)
1212 {
1213 struct rf_info *rf = (struct rf_info *)rf_void;
1214 struct rtw_hal_com_t *hal_i = rf->hal_com;
1215
1216 switch (hal_i->chip_id) {
1217 #ifdef RF_8852A_SUPPORT
1218 case CHIP_WIFI6_8852A:
1219 halrf_tssi_disable_8852a(rf, phy_idx);
1220 break;
1221 #endif
1222 #ifdef RF_8852B_SUPPORT
1223 case CHIP_WIFI6_8852B:
1224 halrf_tssi_disable_8852b(rf, phy_idx);
1225 break;
1226 #endif
1227 default:
1228 break;
1229 }
1230 }
1231
halrf_get_ther_protected_threshold(void * rf_void)1232 s8 halrf_get_ther_protected_threshold(void *rf_void)
1233 {
1234 struct rf_info *rf = (struct rf_info *)rf_void;
1235 struct rtw_hal_com_t *hal_i = rf->hal_com;
1236
1237 switch (hal_i->chip_id) {
1238 #ifdef RF_8852A_SUPPORT
1239 case CHIP_WIFI6_8852A:
1240 return halrf_get_ther_protected_threshold_8852a(rf);
1241 break;
1242 #endif
1243
1244 #ifdef RF_8852B_SUPPORT
1245 case CHIP_WIFI6_8852B:
1246 return halrf_get_ther_protected_threshold_8852b(rf);
1247 break;
1248 #endif
1249
1250 default:
1251 break;
1252 }
1253
1254 return 0;
1255 }
1256
halrf_set_tssi_de_for_tx_verify(void * rf_void,enum phl_phy_idx phy_idx,u32 tssi_de,u8 path)1257 void halrf_set_tssi_de_for_tx_verify(void *rf_void, enum phl_phy_idx phy_idx, u32 tssi_de, u8 path)
1258 {
1259 struct rf_info *rf = (struct rf_info *)rf_void;
1260 struct rtw_hal_com_t *hal_i = rf->hal_com;
1261
1262 switch (hal_i->chip_id) {
1263 #ifdef RF_8852A_SUPPORT
1264 case CHIP_WIFI6_8852A:
1265 halrf_set_tssi_de_for_tx_verify_8852a(rf, phy_idx, tssi_de, path);
1266 break;
1267 #endif
1268 #ifdef RF_8852B_SUPPORT
1269 case CHIP_WIFI6_8852B:
1270 halrf_set_tssi_de_for_tx_verify_8852b(rf, phy_idx, tssi_de, path);
1271 break;
1272 #endif
1273
1274 default:
1275 break;
1276 }
1277 }
1278
halrf_tssi_get_final(void * rf_void,enum phl_phy_idx phy_idx,u8 path)1279 u32 halrf_tssi_get_final(void *rf_void, enum phl_phy_idx phy_idx, u8 path)
1280 {
1281 struct rf_info *rf = (struct rf_info *)rf_void;
1282 struct rtw_hal_com_t *hal_i = rf->hal_com;
1283
1284 switch (hal_i->chip_id) {
1285 #ifdef RF_8852A_SUPPORT
1286 case CHIP_WIFI6_8852A:
1287 return halrf_tssi_get_final_8852ab(rf, path);
1288 break;
1289 #endif
1290
1291 #ifdef RF_8852B_SUPPORT
1292 case CHIP_WIFI6_8852B:
1293 return halrf_tssi_get_final_8852b(rf, path);
1294 break;
1295 #endif
1296
1297 default:
1298 break;
1299 }
1300
1301 return 0;
1302 }
1303
halrf_set_tssi_de_offset(void * rf_void,enum phl_phy_idx phy_idx,u32 tssi_de_offset,u8 path)1304 void halrf_set_tssi_de_offset(void *rf_void, enum phl_phy_idx phy_idx, u32 tssi_de_offset, u8 path)
1305 {
1306 struct rf_info *rf = (struct rf_info *)rf_void;
1307 struct rtw_hal_com_t *hal_i = rf->hal_com;
1308
1309 switch (hal_i->chip_id) {
1310 #ifdef RF_8852A_SUPPORT
1311 case CHIP_WIFI6_8852A:
1312 halrf_set_tssi_de_offset_8852a(rf, phy_idx, tssi_de_offset, path);
1313 break;
1314 #endif
1315 #ifdef RF_8852B_SUPPORT
1316 case CHIP_WIFI6_8852B:
1317 halrf_set_tssi_de_offset_8852b(rf, phy_idx, tssi_de_offset, path);
1318 break;
1319 #endif
1320
1321 default:
1322 break;
1323 }
1324 }
1325
halrf_set_tssi_avg_mp(void * rf_void,enum phl_phy_idx phy_idx,s32 xdbm)1326 void halrf_set_tssi_avg_mp(void *rf_void,
1327 enum phl_phy_idx phy_idx, s32 xdbm)
1328 {
1329 struct rf_info *rf = (struct rf_info *)rf_void;
1330 struct rtw_hal_com_t *hal_i = rf->hal_com;
1331
1332 switch (hal_i->chip_id) {
1333 #ifdef RF_8852A_SUPPORT
1334 case CHIP_WIFI6_8852A:
1335 halrf_set_tssi_avg_mp_8852a(rf, phy_idx, xdbm);
1336 break;
1337 #endif
1338 default:
1339 break;
1340 }
1341 }
1342
halrf_set_rx_gain_offset_for_rx_verify(void * rf_void,enum phl_phy_idx phy,s8 rx_gain_offset,u8 path)1343 void halrf_set_rx_gain_offset_for_rx_verify(void *rf_void,
1344 enum phl_phy_idx phy,
1345 s8 rx_gain_offset, u8 path)
1346 {
1347 #if 0
1348 struct rf_info *rf = (struct rf_info *)rf_void;
1349 struct rtw_hal_com_t *hal_i = rf->hal_com;
1350
1351 switch (hal_i->chip_id) {
1352 #ifdef RF_8852A_SUPPORT
1353 case CHIP_WIFI6_8852A:
1354 halrf_set_rx_gain_offset_for_rx_verify_8852a(rf, phy, rx_gain_offset, path);
1355 break;
1356 #endif
1357 default:
1358 break;
1359 }
1360 #endif
1361 }
1362
halrf_set_power_track(void * rf_void,enum phl_phy_idx phy_idx,u8 value)1363 void halrf_set_power_track(void *rf_void, enum phl_phy_idx phy_idx, u8 value)
1364 {
1365 struct rf_info *rf = (struct rf_info *)rf_void;
1366 struct halrf_tssi_info *tssi_info = &rf->tssi;
1367
1368 tssi_info->tssi_type = value;
1369
1370 if (value == TSSI_OFF) {
1371 halrf_tssi_trigger(rf, phy_idx);
1372 rf->support_ability = rf->support_ability & ~HAL_RF_TX_PWR_TRACK;
1373 } else if (value == TSSI_ON) {
1374 rf->support_ability = rf->support_ability | HAL_RF_TX_PWR_TRACK;
1375 halrf_tssi_trigger(rf, phy_idx);
1376 } else if (value == TSSI_CAL) {
1377 rf->support_ability = rf->support_ability | HAL_RF_TX_PWR_TRACK;
1378 halrf_tssi_trigger(rf, phy_idx);
1379 } else
1380 rf->support_ability = rf->support_ability & ~HAL_RF_TX_PWR_TRACK;
1381
1382
1383 }
1384
halrf_get_power_track(void * rf_void)1385 u8 halrf_get_power_track(void *rf_void)
1386 {
1387 struct rf_info *rf = (struct rf_info *)rf_void;
1388 struct halrf_tssi_info *tssi_info = &rf->tssi;
1389
1390 return tssi_info->tssi_type;
1391 }
1392
halrf_tssi_get_efuse_ex(void * rf_void,enum phl_phy_idx phy_idx)1393 void halrf_tssi_get_efuse_ex(void *rf_void, enum phl_phy_idx phy_idx)
1394 {
1395 struct rf_info *rf = (struct rf_info *)rf_void;
1396 struct rtw_hal_com_t *hal_i = rf->hal_com;
1397
1398 switch (hal_i->chip_id) {
1399 #ifdef RF_8852A_SUPPORT
1400 case CHIP_WIFI6_8852A:
1401 halrf_tssi_get_efuse_8852a(rf, phy_idx);
1402 break;
1403 #endif
1404 #ifdef RF_8852B_SUPPORT
1405 case CHIP_WIFI6_8852B:
1406 halrf_tssi_get_efuse_8852b(rf, phy_idx);
1407 break;
1408 #endif
1409
1410 default:
1411 break;
1412 }
1413 halrf_get_efuse_power_table_switch(rf, phy_idx);
1414 }
1415
halrf_tssi_check_efuse_data(void * rf_void,enum phl_phy_idx phy_idx)1416 bool halrf_tssi_check_efuse_data(void *rf_void, enum phl_phy_idx phy_idx)
1417 {
1418 struct rf_info *rf = (struct rf_info *)rf_void;
1419 struct rtw_hal_com_t *hal_i = rf->hal_com;
1420
1421 switch (hal_i->chip_id) {
1422 #ifdef RF_8852A_SUPPORT
1423 case CHIP_WIFI6_8852A:
1424 return halrf_tssi_check_efuse_data_8852a(rf, phy_idx);
1425 break;
1426 #endif
1427 #ifdef RF_8852B_SUPPORT
1428 case CHIP_WIFI6_8852B:
1429 return halrf_tssi_check_efuse_data_8852b(rf, phy_idx);
1430 break;
1431 #endif
1432
1433 default:
1434 break;
1435 }
1436 return false;
1437 }
1438
halrf_set_ref_power_to_struct(void * rf_void,enum phl_phy_idx phy_idx)1439 void halrf_set_ref_power_to_struct(void *rf_void, enum phl_phy_idx phy_idx)
1440 {
1441 struct rf_info *rf = (struct rf_info *)rf_void;
1442 struct rtw_hal_com_t *hal_i = rf->hal_com;
1443
1444 switch (hal_i->chip_id) {
1445 #ifdef RF_8852A_SUPPORT
1446 case CHIP_WIFI6_8852A:
1447 halrf_set_ref_power_to_struct_8852a(rf, phy_idx);
1448 break;
1449 #endif
1450
1451 #ifdef RF_8852B_SUPPORT
1452 case CHIP_WIFI6_8852B:
1453 halrf_set_ref_power_to_struct_8852b(rf, phy_idx);
1454 break;
1455 #endif
1456
1457 default:
1458 break;
1459 }
1460 }
1461
halrf_set_regulation_init(void * rf_void,enum phl_phy_idx phy_idx)1462 void halrf_set_regulation_init(void *rf_void, enum phl_phy_idx phy_idx)
1463 {
1464 struct rf_info *rf = (struct rf_info *)rf_void;
1465 struct rtw_hal_com_t *hal_i = rf->hal_com;
1466 struct halrf_pwr_info *pwr = &rf->pwr_info;
1467
1468 switch (hal_i->chip_id) {
1469 #ifdef RF_8852A_SUPPORT
1470 case CHIP_WIFI6_8852A:
1471 pwr->regulation_idx = 0xff;
1472 break;
1473 #endif
1474 default:
1475 break;
1476 }
1477 }
1478
halrf_bf_config_rf(void * rf_void)1479 void halrf_bf_config_rf(void *rf_void)
1480 {
1481 struct rf_info *rf = (struct rf_info *)rf_void;
1482 struct rtw_hal_com_t *hal_i = rf->hal_com;
1483
1484 switch (hal_i->chip_id) {
1485 #ifdef RF_8852A_SUPPORT
1486 case CHIP_WIFI6_8852A:
1487 halrf_bf_config_rf_8852a(rf);
1488 break;
1489 #endif
1490 default:
1491 break;
1492 }
1493 }
1494
halrf_get_efuse_info(void * rf_void,u8 * efuse_map,enum rtw_efuse_info id,void * value,u32 length,u8 autoload_status)1495 bool halrf_get_efuse_info(void *rf_void, u8 *efuse_map,
1496 enum rtw_efuse_info id, void *value, u32 length,
1497 u8 autoload_status)
1498 {
1499 struct rf_info *rf = (struct rf_info *)rf_void;
1500 struct rtw_hal_com_t *hal_com = rf->hal_com;
1501
1502 #ifdef RF_8852A_SUPPORT
1503 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1504 return halrf_get_efuse_info_8852a(rf, efuse_map, id, value, length,
1505 autoload_status);
1506 #endif
1507
1508 #ifdef RF_8852B_SUPPORT
1509 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1510 return halrf_get_efuse_info_8852b(rf, efuse_map, id, value, length,
1511 autoload_status);
1512 #endif
1513
1514 return 0;
1515 }
1516
halrf_get_efuse_rx_gain_k(void * rf_void,enum phl_phy_idx phy_idx)1517 void halrf_get_efuse_rx_gain_k(void *rf_void, enum phl_phy_idx phy_idx)
1518 {
1519 #if 0
1520 struct rf_info *rf = (struct rf_info *)rf_void;
1521 struct rtw_hal_com_t *hal_com = rf->hal_com;
1522
1523 #ifdef RF_8852A_SUPPORT
1524 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1525 halrf_get_efuse_rx_gain_k_8852a(rf, phy_idx);
1526 #endif
1527 #endif
1528
1529 }
1530
halrf_get_efuse_trim(void * rf_void,enum phl_phy_idx phy_idx)1531 void halrf_get_efuse_trim(void *rf_void, enum phl_phy_idx phy_idx)
1532 {
1533 struct rf_info *rf = (struct rf_info *)rf_void;
1534 struct rtw_hal_com_t *hal_com = rf->hal_com;
1535
1536 #ifdef RF_8852A_SUPPORT
1537 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1538 halrf_get_efuse_trim_8852a(rf, phy_idx);
1539 #endif
1540
1541 #ifdef RF_8852B_SUPPORT
1542 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1543 halrf_get_efuse_trim_8852b(rf, phy_idx);
1544 #endif
1545
1546 }
1547
halrf_do_rx_gain_k(void * rf_void,enum phl_phy_idx phy_idx)1548 void halrf_do_rx_gain_k(void *rf_void, enum phl_phy_idx phy_idx)
1549 {
1550 #if 0
1551 struct rf_info *rf = (struct rf_info *)rf_void;
1552 struct rtw_hal_com_t *hal_com = rf->hal_com;
1553
1554 if (!(rf->support_ability & HAL_RF_RXGAINK))
1555 return;
1556
1557 #ifdef RF_8852A_SUPPORT
1558 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1559 halrf_do_rx_gain_k_8852a(rf, phy_idx);
1560 #endif
1561 #endif
1562 }
1563
halrf_set_dbcc(void * rf_void,bool dbcc_en)1564 bool halrf_set_dbcc(void *rf_void, bool dbcc_en)
1565 {
1566 struct rf_info *rf = (struct rf_info *)rf_void;
1567 struct rtw_hal_com_t *hal_com = rf->hal_com;
1568
1569 #ifdef RF_8852A_SUPPORT
1570 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1571 return halrf_set_dbcc_8852a(rf, dbcc_en);
1572 #endif
1573 return 0;
1574 }
1575
halrf_wl_tx_power_control(void * rf_void,u32 tx_power_val)1576 bool halrf_wl_tx_power_control(void *rf_void, u32 tx_power_val)
1577 {
1578 struct rf_info *rf = (struct rf_info *)rf_void;
1579 struct rtw_hal_com_t *hal_com = rf->hal_com;
1580 bool rtn = false;
1581
1582 switch (hal_com->chip_id) {
1583 #ifdef RF_8852A_SUPPORT
1584 case CHIP_WIFI6_8852A:
1585 rtn = halrf_wl_tx_power_control_8852a(rf, tx_power_val);
1586 break;
1587 #endif
1588 #ifdef RF_8852B_SUPPORT
1589 case CHIP_WIFI6_8852B:
1590 rtn = halrf_wl_tx_power_control_8852b(rf, tx_power_val);
1591 break;
1592 #endif
1593 default:
1594 break;
1595 }
1596
1597 return rtn;
1598 }
1599
halrf_watchdog(void * rf_void)1600 void halrf_watchdog(void *rf_void)
1601 {
1602 struct rf_info *rf = (struct rf_info *)rf_void;
1603
1604 /*halrf_thermal_period(rf);*/
1605 halrf_tssi_ant_open(rf);
1606 halrf_tssi_tracking(rf);
1607 halrf_dpk_tracking(rf);
1608 halrf_iqk_tracking(rf);
1609 }
1610
halrf_get_default_rfe_type(void * rf_void)1611 u8 halrf_get_default_rfe_type(void *rf_void)
1612 {
1613 struct rf_info *rf = (struct rf_info *)rf_void;
1614 struct rtw_hal_com_t *hal_com = rf->hal_com;
1615
1616 #ifdef RF_8852A_SUPPORT
1617 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1618 return halrf_get_default_rfe_type_8852a(rf);
1619 #endif
1620 return 1;
1621 }
1622
halrf_get_default_xtal(void * rf_void)1623 u8 halrf_get_default_xtal(void *rf_void)
1624 {
1625 struct rf_info *rf = (struct rf_info *)rf_void;
1626 struct rtw_hal_com_t *hal_com = rf->hal_com;
1627
1628 #ifdef RF_8852A_SUPPORT
1629 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1630 return halrf_get_default_xtal_8852a(rf);
1631 #endif
1632 return 0x3f;
1633 }
1634
halrf_iqk_get_ther_rek(void * rf_void)1635 bool halrf_iqk_get_ther_rek(void *rf_void)
1636 {
1637 struct rf_info *rf = (struct rf_info *)rf_void;
1638 struct rtw_hal_com_t *hal_com = rf->hal_com;
1639
1640 #ifdef RF_8852A_SUPPORT
1641 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1642 return halrf_iqk_get_ther_rek_8852ab(rf);
1643 #endif
1644 #ifdef RF_8852B_SUPPORT
1645 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1646 return halrf_iqk_get_ther_rek_8852b(rf);
1647 #endif
1648
1649 return false;
1650 }
1651
halrf_iqk_tracking(void * rf_void)1652 enum rtw_hal_status halrf_iqk_tracking(void *rf_void)
1653 {
1654 struct rf_info *rf = (struct rf_info *)rf_void;
1655 struct rtw_hal_com_t *hal_i = rf->hal_com;
1656 struct halrf_iqk_info *iqk = &rf->iqk;
1657
1658 if (!(rf->support_ability & HAL_RF_IQK) || rf->rfk_is_processing ||
1659 rf->is_watchdog_stop)
1660 return RTW_HAL_STATUS_SUCCESS;
1661
1662 rf->is_watchdog_stop = true; /*avoid race condition*/
1663
1664 switch (hal_i->chip_id) {
1665 #ifdef RF_8852A_SUPPORT
1666 case CHIP_WIFI6_8852A:
1667 halrf_iqk_track_8852ab(rf);
1668 #if 0
1669 if (halrf_iqk_get_ther_rek(rf))
1670 halrf_iqk(rf, 0x0, false);
1671 #endif
1672 break;
1673 #endif
1674 #ifdef RF_8852B_SUPPORT
1675 case CHIP_WIFI6_8852B:
1676 halrf_iqk_track_8852b(rf);
1677 break;
1678 #endif
1679
1680 default:
1681 break;
1682 }
1683
1684 rf->is_watchdog_stop = false;
1685
1686 return RTW_HAL_STATUS_SUCCESS;
1687 }
1688
halrf_psd_init(void * rf_void,enum phl_phy_idx phy,u8 path,u8 iq_path,u32 avg,u32 fft)1689 void halrf_psd_init(void *rf_void, enum phl_phy_idx phy,
1690 u8 path, u8 iq_path, u32 avg, u32 fft)
1691 {
1692 struct rf_info *rf = (struct rf_info *)rf_void;
1693 struct rtw_hal_com_t *hal_com = rf->hal_com;
1694
1695 #ifdef RF_8852A_SUPPORT
1696 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1697 halrf_psd_init_8852a(rf, phy, path, iq_path, avg, fft);
1698 #endif
1699
1700 #ifdef RF_8852B_SUPPORT
1701 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1702 halrf_psd_init_8852b(rf, phy, path, iq_path, avg, fft);
1703 #endif
1704 }
1705
halrf_psd_restore(void * rf_void,enum phl_phy_idx phy)1706 void halrf_psd_restore(void *rf_void, enum phl_phy_idx phy)
1707 {
1708 struct rf_info *rf = (struct rf_info *)rf_void;
1709 struct rtw_hal_com_t *hal_com = rf->hal_com;
1710
1711 #ifdef RF_8852A_SUPPORT
1712 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1713 halrf_psd_restore_8852a(rf, phy);
1714 #endif
1715
1716 #ifdef RF_8852B_SUPPORT
1717 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1718 halrf_psd_restore_8852b(rf, phy);
1719 #endif
1720 }
1721
halrf_psd_get_point_data(void * rf_void,enum phl_phy_idx phy,s32 point)1722 u32 halrf_psd_get_point_data(void *rf_void, enum phl_phy_idx phy, s32 point)
1723 {
1724 struct rf_info *rf = (struct rf_info *)rf_void;
1725 struct rtw_hal_com_t *hal_com = rf->hal_com;
1726
1727 #ifdef RF_8852A_SUPPORT
1728 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1729 return halrf_psd_get_point_data_8852a(rf, phy, point);
1730 #endif
1731
1732 #ifdef RF_8852B_SUPPORT
1733 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1734 return halrf_psd_get_point_data_8852b(rf, phy, point);
1735 #endif
1736
1737 return 0;
1738 }
1739
halrf_psd_query(void * rf_void,enum phl_phy_idx phy,u32 point,u32 start_point,u32 stop_point,u32 * outbuf)1740 void halrf_psd_query(void *rf_void, enum phl_phy_idx phy,
1741 u32 point, u32 start_point, u32 stop_point, u32 *outbuf)
1742 {
1743 struct rf_info *rf = (struct rf_info *)rf_void;
1744 struct rtw_hal_com_t *hal_com = rf->hal_com;
1745
1746 #ifdef RF_8852A_SUPPORT
1747 if (hal_com->chip_id == CHIP_WIFI6_8852A)
1748 halrf_psd_query_8852a(rf, phy, point, start_point, stop_point, outbuf);
1749 #endif
1750
1751 #ifdef RF_8852B_SUPPORT
1752 if (hal_com->chip_id == CHIP_WIFI6_8852B)
1753 halrf_psd_query_8852b(rf, phy, point, start_point, stop_point, outbuf);
1754 #endif
1755
1756 }
1757
halrf_set_fix_power_to_struct(void * rf_void,enum phl_phy_idx phy,s8 dbm)1758 void halrf_set_fix_power_to_struct(void *rf_void,
1759 enum phl_phy_idx phy, s8 dbm)
1760 {
1761 struct rf_info *rf = (struct rf_info *)rf_void;
1762 struct halrf_pwr_info *pwr = &rf->pwr_info;
1763 struct rtw_hal_com_t *hal_i = rf->hal_com;
1764
1765 pwr->fix_power[RF_PATH_A] = true;
1766 pwr->fix_power_dbm[RF_PATH_A] = dbm * 2;
1767
1768 pwr->fix_power[RF_PATH_B] = true;
1769 pwr->fix_power_dbm[RF_PATH_B] = dbm * 2;
1770
1771 switch (hal_i->chip_id) {
1772 #ifdef RF_8852A_SUPPORT
1773 case CHIP_WIFI6_8852A:
1774 halrf_set_fix_power_to_struct_8852ab(rf, phy, dbm);
1775 break;
1776 #endif
1777 default:
1778 break;
1779 }
1780 }
1781
halrf_pwr_by_rate_info(struct rf_info * rf,char input[][16],u32 * _used,char * output,u32 * _out_len)1782 void halrf_pwr_by_rate_info(struct rf_info *rf, char input[][16], u32 *_used,
1783 char *output, u32 *_out_len)
1784 {
1785 struct rtw_hal_com_t *hal_i = rf->hal_com;
1786 u32 used = *_used;
1787 u32 out_len = *_out_len;
1788
1789 switch (hal_i->chip_id) {
1790 #ifdef RF_8852A_SUPPORT
1791 case CHIP_WIFI6_8852A:
1792 halrf_pwr_by_rate_info_8852a(rf, input, &used,
1793 output, &out_len);
1794 break;
1795 #endif
1796
1797 #ifdef RF_8852B_SUPPORT
1798 case CHIP_WIFI6_8852B:
1799 halrf_pwr_by_rate_info_8852b(rf, input, &used,
1800 output, &out_len);
1801 break;
1802 #endif
1803
1804 default:
1805 break;
1806 }
1807 }
1808
halrf_pwr_limit_info(struct rf_info * rf,char input[][16],u32 * _used,char * output,u32 * _out_len)1809 void halrf_pwr_limit_info(struct rf_info *rf, char input[][16], u32 *_used,
1810 char *output, u32 *_out_len)
1811 {
1812 struct rtw_hal_com_t *hal_i = rf->hal_com;
1813 u32 used = *_used;
1814 u32 out_len = *_out_len;
1815
1816 switch (hal_i->chip_id) {
1817 #ifdef RF_8852A_SUPPORT
1818 case CHIP_WIFI6_8852A:
1819 halrf_pwr_limit_info_8852a(rf, input, &used,
1820 output, &out_len);
1821 break;
1822 #endif
1823
1824 #ifdef RF_8852B_SUPPORT
1825 case CHIP_WIFI6_8852B:
1826 halrf_pwr_limit_info_8852b(rf, input, &used,
1827 output, &out_len);
1828 break;
1829 #endif
1830
1831 default:
1832 break;
1833 }
1834 }
1835
halrf_pwr_limit_ru_info(struct rf_info * rf,char input[][16],u32 * _used,char * output,u32 * _out_len)1836 void halrf_pwr_limit_ru_info(struct rf_info *rf, char input[][16], u32 *_used,
1837 char *output, u32 *_out_len)
1838 {
1839 struct rtw_hal_com_t *hal_i = rf->hal_com;
1840 u32 used = *_used;
1841 u32 out_len = *_out_len;
1842
1843 switch (hal_i->chip_id) {
1844 #ifdef RF_8852A_SUPPORT
1845 case CHIP_WIFI6_8852A:
1846 halrf_pwr_limit_ru_info_8852a(rf, input, &used,
1847 output, &out_len);
1848 break;
1849 #endif
1850
1851 #ifdef RF_8852B_SUPPORT
1852 case CHIP_WIFI6_8852B:
1853 halrf_pwr_limit_ru_info_8852b(rf, input, &used,
1854 output, &out_len);
1855 break;
1856 #endif
1857
1858 default:
1859 break;
1860 }
1861 }
1862
halrf_get_tssi_info(struct rf_info * rf,char input[][16],u32 * _used,char * output,u32 * _out_len)1863 void halrf_get_tssi_info(struct rf_info *rf, char input[][16], u32 *_used,
1864 char *output, u32 *_out_len)
1865 {
1866 struct rtw_hal_com_t *hal_i = rf->hal_com;
1867 u32 used = *_used;
1868 u32 out_len = *_out_len;
1869
1870 switch (hal_i->chip_id) {
1871 #ifdef RF_8852A_SUPPORT
1872 case CHIP_WIFI6_8852A:
1873 halrf_get_tssi_info_8852a(rf, input, &used,
1874 output, &out_len);
1875 break;
1876 #endif
1877
1878 #ifdef RF_8852B_SUPPORT
1879 case CHIP_WIFI6_8852B:
1880 halrf_get_tssi_info_8852b(rf, input, &used,
1881 output, &out_len);
1882 break;
1883 #endif
1884
1885 default:
1886 break;
1887 }
1888 }
1889
halrf_get_tssi_trk_info(struct rf_info * rf,char input[][16],u32 * _used,char * output,u32 * _out_len)1890 void halrf_get_tssi_trk_info(struct rf_info *rf, char input[][16], u32 *_used,
1891 char *output, u32 *_out_len)
1892 {
1893 struct rtw_hal_com_t *hal_i = rf->hal_com;
1894 u32 used = *_used;
1895 u32 out_len = *_out_len;
1896
1897 switch (hal_i->chip_id) {
1898 #ifdef RF_8852A_SUPPORT
1899 case CHIP_WIFI6_8852A:
1900 halrf_get_tssi_trk_info_8852a(rf, input, &used,
1901 output, &out_len);
1902 break;
1903 #endif
1904 default:
1905 break;
1906 }
1907 }
1908
halrf_tssi_backup_txagc(struct rf_info * rf,enum phl_phy_idx phy,bool enable)1909 void halrf_tssi_backup_txagc(struct rf_info *rf, enum phl_phy_idx phy, bool enable)
1910 {
1911 struct rtw_hal_com_t *hal_i = rf->hal_com;
1912
1913 switch (hal_i->chip_id) {
1914 #ifdef RF_8852B_SUPPORT
1915 case CHIP_WIFI6_8852B:
1916 halrf_tssi_backup_txagc_8852b(rf, phy, enable);
1917 break;
1918 #endif
1919 default:
1920 break;
1921 }
1922 }
1923
halrf_set_tx_shape(struct rf_info * rf,u8 tx_shape_idx)1924 void halrf_set_tx_shape(struct rf_info *rf, u8 tx_shape_idx)
1925 {
1926 struct rtw_hal_com_t *hal_i = rf->hal_com;
1927
1928 switch (hal_i->chip_id) {
1929 #ifdef RF_8852B_SUPPORT
1930 case CHIP_WIFI6_8852B:
1931 halrf_set_tx_shape_8852b(rf, tx_shape_idx);
1932 break;
1933 #endif
1934 default:
1935 break;
1936 }
1937 }
1938
1939
halrf_ctl_bw(void * rf_void,enum channel_width bw)1940 void halrf_ctl_bw(void *rf_void, enum channel_width bw)
1941 {
1942 struct rf_info *rf = (struct rf_info *)rf_void;
1943 struct rtw_hal_com_t *hal_i = rf->hal_com;
1944
1945 switch (hal_i->chip_id) {
1946 #ifdef RF_8852B_SUPPORT
1947 case CHIP_WIFI6_8852B:
1948 halrf_ctrl_bw_8852b(rf, bw);
1949 break;
1950 #endif
1951 default:
1952 break;
1953 }
1954 return;
1955
1956 }
1957
halrf_ctl_ch(void * rf_void,u8 central_ch)1958 void halrf_ctl_ch(void *rf_void, u8 central_ch)
1959 {
1960 struct rf_info *rf = (struct rf_info *)rf_void;
1961 struct rtw_hal_com_t *hal_i = rf->hal_com;
1962
1963 switch (hal_i->chip_id) {
1964 #ifdef RF_8852B_SUPPORT
1965 case CHIP_WIFI6_8852B:
1966 halrf_ctrl_ch_8852b(rf, central_ch);
1967 break;
1968 #endif
1969 default:
1970 break;
1971 }
1972 return;
1973 }
1974
halrf_rxbb_bw(void * rf_void,enum phl_phy_idx phy,enum channel_width bw)1975 void halrf_rxbb_bw(void *rf_void, enum phl_phy_idx phy, enum channel_width bw)
1976 {
1977 struct rf_info *rf = (struct rf_info *)rf_void;
1978 struct rtw_hal_com_t *hal_i = rf->hal_com;
1979
1980 switch (hal_i->chip_id) {
1981 #ifdef RF_8852A_SUPPORT
1982 case CHIP_WIFI6_8852A:
1983 halrf_rxbb_bw_8852a(rf, phy, bw);
1984 break;
1985 #endif
1986 #ifdef RF_8852B_SUPPORT
1987 case CHIP_WIFI6_8852B:
1988 halrf_rxbb_bw_8852b(rf, phy, bw);
1989 break;
1990 #endif
1991 default:
1992 break;
1993 }
1994 return;
1995 }
1996
halrf_config_radio_to_fw(void * rf_void)1997 void halrf_config_radio_to_fw(void *rf_void)
1998 {
1999
2000 struct rf_info *rf = (struct rf_info *)rf_void;
2001 struct rtw_hal_com_t *hal_i = rf->hal_com;
2002
2003 switch (hal_i->chip_id) {
2004 #ifdef RF_8852A_SUPPORT
2005 case CHIP_WIFI6_8852A:
2006 halrf_config_8852a_radio_to_fw(rf);
2007 break;
2008 #endif
2009 #ifdef RF_8852B_SUPPORT
2010 case CHIP_WIFI6_8852B:
2011 halrf_config_8852b_radio_to_fw(rf);
2012 break;
2013 #endif
2014 default:
2015 break;
2016 }
2017 }
2018
halrf_rfc_reg_backup(void * rf_void)2019 void halrf_rfc_reg_backup(void *rf_void)
2020 {
2021 struct rf_info *rf = (struct rf_info *)rf_void;
2022 struct rtw_hal_com_t *hal_i = rf->hal_com;
2023
2024 switch (hal_i->chip_id) {
2025 #ifdef RF_8852A_SUPPORT
2026 case CHIP_WIFI6_8852A:
2027 halrf_rfc_reg_backup_8852a(rf);
2028 break;
2029 #endif
2030 default:
2031 break;
2032 }
2033 }
2034
halrf_rfc_reg_check_fail(void * rf_void)2035 bool halrf_rfc_reg_check_fail(void *rf_void)
2036 {
2037 struct rf_info *rf = (struct rf_info *)rf_void;
2038 struct rtw_hal_com_t *hal_i = rf->hal_com;
2039 bool fail = false;
2040
2041 switch (hal_i->chip_id) {
2042 #ifdef RF_8852A_SUPPORT
2043 case CHIP_WIFI6_8852A:
2044 fail = halrf_rfc_reg_check_fail_8852a(rf);
2045 break;
2046 #endif
2047 default:
2048 break;
2049 }
2050 return fail;
2051 }
2052
halrf_rfk_reg_backup(void * rf_void)2053 void halrf_rfk_reg_backup(void *rf_void)
2054 {
2055 struct rf_info *rf = (struct rf_info *)rf_void;
2056 struct rtw_hal_com_t *hal_i = rf->hal_com;
2057
2058 switch (hal_i->chip_id) {
2059 #ifdef RF_8852A_SUPPORT
2060 case CHIP_WIFI6_8852A:
2061 halrf_rfk_reg_backup_8852a(rf);
2062 break;
2063 #endif
2064 default:
2065 break;
2066 }
2067 }
2068
halrf_rfk_reg_check_fail(void * rf_void)2069 bool halrf_rfk_reg_check_fail(void *rf_void)
2070 {
2071 struct rf_info *rf = (struct rf_info *)rf_void;
2072 struct rtw_hal_com_t *hal_i = rf->hal_com;
2073 bool fail = false;
2074
2075 switch (hal_i->chip_id) {
2076 #ifdef RF_8852A_SUPPORT
2077 case CHIP_WIFI6_8852A:
2078 fail = halrf_rfk_reg_check_fail_8852a(rf);
2079 break;
2080 #endif
2081 default:
2082 break;
2083 }
2084 return fail;
2085 }
2086
halrf_dack_reg_check_fail(void * rf_void)2087 bool halrf_dack_reg_check_fail(void *rf_void)
2088 {
2089 struct rf_info *rf = (struct rf_info *)rf_void;
2090 struct rtw_hal_com_t *hal_i = rf->hal_com;
2091 bool fail = false;
2092
2093 switch (hal_i->chip_id) {
2094 #ifdef RF_8852A_SUPPORT
2095 case CHIP_WIFI6_8852A:
2096 fail = halrf_dack_reg_check_fail_8852a(rf);
2097 break;
2098 #endif
2099 default:
2100 break;
2101 }
2102 return fail;
2103 }
2104
halrf_rfk_chl_thermal(void * rf_void,u8 chl_idx,u8 ther_idx)2105 bool halrf_rfk_chl_thermal(void *rf_void,
2106 u8 chl_idx, u8 ther_idx)
2107 {
2108 struct rf_info *rf = (struct rf_info *)rf_void;
2109 struct rtw_hal_com_t *hal_com = rf->hal_com;
2110 bool fail = false;
2111
2112 #ifdef RF_8852A_SUPPORT
2113 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2114 fail = halrf_rfk_chl_thermal_8852a(rf, chl_idx, ther_idx);
2115 #endif
2116 return fail;
2117
2118 }
2119
halrf_rfk_recovery_chl_thermal(void * rf_void,u8 chl_idx)2120 void halrf_rfk_recovery_chl_thermal(void *rf_void, u8 chl_idx)
2121 {
2122 struct rf_info *rf = (struct rf_info *)rf_void;
2123 struct rtw_hal_com_t *hal_com = rf->hal_com;
2124
2125 #ifdef RF_8852A_SUPPORT
2126 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2127 halrf_rfk_recovery_chl_thermal_8852a(rf, chl_idx);
2128 #endif
2129 }
2130
halrf_fcs_get_thermal_index(void * rf_void)2131 u8 halrf_fcs_get_thermal_index(void *rf_void)
2132 {
2133 struct rf_info *rf = (struct rf_info *)rf_void;
2134 struct rtw_hal_com_t *hal_com = rf->hal_com;
2135 u8 idx = 0;
2136
2137 #ifdef RF_8852A_SUPPORT
2138 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2139 idx = halrf_thermal_index_cal_8852a(rf);
2140 #endif
2141 return idx;
2142 }
2143
halrf_disconnect_notify(void * rf_void,struct rtw_chan_def * chandef)2144 void halrf_disconnect_notify(void *rf_void, struct rtw_chan_def *chandef )
2145 {
2146 struct rf_info *rf = (struct rf_info *)rf_void;
2147 struct rtw_hal_com_t *hal_com = rf->hal_com;
2148 bool fail = false;
2149
2150 #ifdef RF_8852A_SUPPORT
2151 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2152 halrf_disconnect_notify_8852a(rf, chandef);
2153 #endif
2154 #ifdef RF_8852B_SUPPORT
2155 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2156 halrf_disconnect_notify_8852b(rf, chandef);
2157 #endif
2158
2159 return;
2160
2161 }
2162
halrf_check_mcc_ch(void * rf_void,struct rtw_chan_def * chandef)2163 bool halrf_check_mcc_ch(void *rf_void, struct rtw_chan_def *chandef )
2164 {
2165 struct rf_info *rf = (struct rf_info *)rf_void;
2166 struct rtw_hal_com_t *hal_com = rf->hal_com;
2167 bool fail = false;
2168
2169 #ifdef RF_8852A_SUPPORT
2170 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2171 fail = halrf_check_mcc_ch_8852a(rf, chandef);
2172 #endif
2173 #ifdef RF_8852B_SUPPORT
2174 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2175 fail = halrf_check_mcc_ch_8852b(rf, chandef);
2176 #endif
2177
2178 return fail;
2179
2180 }
2181
halrf_fw_ntfy(void * rf_void,enum phl_phy_idx phy_idx)2182 void halrf_fw_ntfy(void *rf_void, enum phl_phy_idx phy_idx)
2183 {
2184 struct rf_info *rf = (struct rf_info *)rf_void;
2185 struct rtw_hal_com_t *hal_com = rf->hal_com;
2186
2187 #ifdef RF_8852A_SUPPORT
2188 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2189 halrf_fw_ntfy_8852a(rf, phy_idx);
2190 #endif
2191 #ifdef RF_8852B_SUPPORT
2192 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2193 halrf_fw_ntfy_8852b(rf, phy_idx);
2194 #endif
2195
2196 return;
2197 }
2198
halrf_set_regulation_from_driver(void * rf_void,u8 regulation_idx)2199 void halrf_set_regulation_from_driver(void *rf_void,
2200 u8 regulation_idx)
2201 {
2202 struct rf_info *rf = (struct rf_info *)rf_void;
2203 struct rtw_hal_com_t *hal_com = rf->hal_com;
2204
2205 #ifdef RF_8852A_SUPPORT
2206 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2207 halrf_set_regulation_from_driver_8852a(rf, regulation_idx);
2208 #endif
2209 return;
2210 }
2211
halrf_get_nctl_reg_ver(struct rf_info * rf)2212 u32 halrf_get_nctl_reg_ver(struct rf_info *rf)
2213 {
2214 struct rtw_hal_com_t *hal_com = rf->hal_com;
2215
2216 #ifdef RF_8852A_SUPPORT
2217 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2218 return halrf_get_8852a_nctl_reg_ver();
2219 #endif
2220 #ifdef RF_8852B_SUPPORT
2221 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2222 return halrf_get_8852b_nctl_reg_ver();
2223 #endif
2224 return 0;
2225
2226 }
2227
halrf_get_radio_reg_ver(struct rf_info * rf)2228 u32 halrf_get_radio_reg_ver(struct rf_info *rf)
2229 {
2230 struct rtw_hal_com_t *hal_com = rf->hal_com;
2231
2232 #ifdef RF_8852A_SUPPORT
2233 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2234 return halrf_get_8852a_radio_reg_ver();
2235 #endif
2236 #ifdef RF_8852B_SUPPORT
2237 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2238 return halrf_get_8852b_radio_reg_ver();
2239 #endif
2240 return 0;
2241 }
2242
halrf_get_radio_ver_from_reg(struct rf_info * rf)2243 u32 halrf_get_radio_ver_from_reg(struct rf_info *rf)
2244 {
2245 struct rtw_hal_com_t *hal_com = rf->hal_com;
2246
2247 #ifdef RF_8852A_SUPPORT
2248 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2249 return halrf_rrf(rf, RF_PATH_A, 0x67, 0xfff);
2250 #endif
2251 #ifdef RF_8852B_SUPPORT
2252 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2253 return halrf_rrf(rf, RF_PATH_A, 0x9F, 0xfff);
2254 #endif
2255 #ifdef RF_8852C_SUPPORT
2256 if (hal_com->chip_id == CHIP_WIFI6_8852C)
2257 return halrf_rrf(rf, RF_PATH_A, 0xFE, 0xfff);
2258 #endif
2259
2260 #if 0 /* TBD */
2261 #ifdef RF_8832BR_SUPPORT
2262 if (hal_com->chip_id == CHIP_WIFI6_8832BR)
2263 return halrf_rrf(rf, RF_PATH_A, 0xFE, 0xfff);
2264 #endif
2265 #ifdef RF_8192XB_SUPPORT
2266 if (hal_com->chip_id == CHIP_WIFI6_8192XB)
2267 return halrf_rrf(rf, RF_PATH_A, 0xFE, 0xfff);
2268 #endif
2269 #endif
2270
2271 return 0;
2272 }
2273
halrf_config_nctl_reg(struct rf_info * rf)2274 void halrf_config_nctl_reg(struct rf_info *rf)
2275 {
2276 struct rtw_hal_com_t *hal_com = rf->hal_com;
2277
2278 #ifdef RF_8852A_SUPPORT
2279 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2280 halrf_config_8852a_nctl_reg(rf);
2281 #endif
2282 #ifdef RF_8852B_SUPPORT
2283 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2284 halrf_config_8852b_nctl_reg(rf);
2285 #endif
2286
2287 return;
2288 }
2289
halrf_set_gpio(void * rf_void,enum phl_phy_idx phy,u8 band)2290 void halrf_set_gpio(void *rf_void, enum phl_phy_idx phy, u8 band)
2291 {
2292 struct rf_info *rf = (struct rf_info *)rf_void;
2293 struct rtw_hal_com_t *hal_com = rf->hal_com;
2294
2295 #ifdef RF_8852A_SUPPORT
2296 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2297 halrf_set_gpio_8852a(rf, phy, band);
2298 #endif
2299 }
2300
halrf_mac_set_pwr_reg(void * rf_void,enum phl_phy_idx phy,u32 addr,u32 mask,u32 val)2301 bool halrf_mac_set_pwr_reg(void *rf_void, enum phl_phy_idx phy,
2302 u32 addr, u32 mask, u32 val)
2303 {
2304 struct rf_info *rf = (struct rf_info *)rf_void;
2305 struct rtw_hal_com_t *hal_com = rf->hal_com;
2306 u32 result = 0;
2307
2308 #ifdef RF_8852A_SUPPORT
2309 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2310 result = halrf_mac_set_pwr_reg_8852a(rf, phy, addr, mask, val);
2311 #endif
2312
2313 #ifdef RF_8852B_SUPPORT
2314 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2315 result = halrf_mac_set_pwr_reg_8852b(rf, phy, addr, mask, val);
2316 #endif
2317
2318 if (result == 0) /*MAC: MACSUCCESS == 0*/
2319 return true;
2320 else
2321 return false;
2322 }
2323
halrf_mac_get_pwr_reg(void * rf_void,enum phl_phy_idx phy,u32 addr,u32 mask)2324 u32 halrf_mac_get_pwr_reg(void *rf_void, enum phl_phy_idx phy,
2325 u32 addr, u32 mask)
2326 {
2327 struct rf_info *rf = (struct rf_info *)rf_void;
2328 struct rtw_hal_com_t *hal_com = rf->hal_com;
2329
2330 #ifdef RF_8852A_SUPPORT
2331 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2332 return halrf_mac_get_pwr_reg_8852a(rf, phy, addr, mask);
2333 #endif
2334
2335 #ifdef RF_8852B_SUPPORT
2336 if (hal_com->chip_id == CHIP_WIFI6_8852B)
2337 return halrf_mac_get_pwr_reg_8852b(rf, phy, addr, mask);
2338 #endif
2339
2340 return 0;
2341 }
2342
halrf_check_efem(void * rf_void,enum phl_phy_idx phy_idx)2343 bool halrf_check_efem(void *rf_void, enum phl_phy_idx phy_idx)
2344 {
2345 struct rf_info *rf = (struct rf_info *)rf_void;
2346 struct rtw_hal_com_t *hal_com = rf->hal_com;
2347
2348 #ifdef RF_8852A_SUPPORT
2349 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2350 return halrf_check_efem_8852a(rf, phy_idx);
2351 #endif
2352 return false;
2353 }
2354
halrf_2g_rxant(void * rf_void,enum halrf_ant ant)2355 void halrf_2g_rxant(void *rf_void, enum halrf_ant ant)
2356 {
2357 struct rf_info *rf = (struct rf_info *)rf_void;
2358 struct rtw_hal_com_t *hal_com = rf->hal_com;
2359
2360 #ifdef RF_8852A_SUPPORT
2361 if (hal_com->chip_id == CHIP_WIFI6_8852A)
2362 halrf_2g_rxant_8852a(rf, ant);
2363 #endif
2364 }
2365
halrf_xtal_tracking_offset(void * rf_void,enum phl_phy_idx phy_idx)2366 s8 halrf_xtal_tracking_offset(void *rf_void, enum phl_phy_idx phy_idx)
2367 {
2368 struct rf_info *rf = (struct rf_info *)rf_void;
2369 struct rtw_hal_com_t *hal_i = rf->hal_com;
2370
2371 if (!(rf->support_ability & HAL_RF_XTAL_TRACK))
2372 return 0;
2373
2374 switch (hal_i->chip_id) {
2375 #ifdef RF_8852A_SUPPORT
2376 case CHIP_WIFI6_8852A:
2377 return halrf_xtal_tracking_offset_8852a(rf, phy_idx);
2378 break;
2379 #endif
2380
2381 #ifdef RF_8852B_SUPPORT
2382 case CHIP_WIFI6_8852B:
2383 return halrf_xtal_tracking_offset_8852b(rf, phy_idx);
2384 break;
2385 #endif
2386
2387 default:
2388 break;
2389 }
2390
2391 return 0;
2392 }
2393
halrf_set_mp_regulation(void * rf_void,enum phl_phy_idx phy,u8 regulation)2394 void halrf_set_mp_regulation(void *rf_void, enum phl_phy_idx phy, u8 regulation)
2395 {
2396 struct rf_info *rf = (struct rf_info *)rf_void;
2397 struct halrf_pwr_info *pwr = &rf->pwr_info;
2398
2399 pwr->mp_regulation = regulation;
2400 }
2401
2402 #endif
2403
2404