1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007-2013 Realtek Corporation.*/
4 #include "halbt_precomp.h"
6 /***************************************************
7 * Debug related function
8 ***************************************************/
10 static const char *const gl_btc_wifi_bw_string
[] = {
18 static const char *const gl_btc_wifi_freq_string
[] = {
23 static bool halbtc_is_bt_coexist_available(struct btc_coexist
*btcoexist
)
25 if (!btcoexist
->binded
|| NULL
== btcoexist
->adapter
)
31 static bool halbtc_is_wifi_busy(struct rtl_priv
*rtlpriv
)
33 if (rtlpriv
->link_info
.busytraffic
)
39 static void halbtc_dbg_init(void)
43 /***************************************************
45 ***************************************************/
46 static bool is_any_client_connect_to_ap(struct btc_coexist
*btcoexist
)
48 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
49 struct rtl_mac
*mac
= rtl_mac(rtlpriv
);
50 struct rtl_sta_info
*drv_priv
;
53 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
||
54 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
||
55 mac
->opmode
== NL80211_IFTYPE_AP
) {
56 if (in_interrupt() > 0) {
57 list_for_each_entry(drv_priv
, &rtlpriv
->entry_list
,
62 spin_lock_bh(&rtlpriv
->locks
.entry_list_lock
);
63 list_for_each_entry(drv_priv
, &rtlpriv
->entry_list
,
67 spin_unlock_bh(&rtlpriv
->locks
.entry_list_lock
);
76 static bool halbtc_legacy(struct rtl_priv
*adapter
)
78 struct rtl_priv
*rtlpriv
= adapter
;
79 struct rtl_mac
*mac
= rtl_mac(rtlpriv
);
81 bool is_legacy
= false;
83 if ((mac
->mode
== WIRELESS_MODE_B
) || (mac
->mode
== WIRELESS_MODE_G
))
89 bool halbtc_is_wifi_uplink(struct rtl_priv
*adapter
)
91 struct rtl_priv
*rtlpriv
= adapter
;
93 if (rtlpriv
->link_info
.tx_busy_traffic
)
99 static u32
halbtc_get_wifi_bw(struct btc_coexist
*btcoexist
)
101 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
102 struct rtl_phy
*rtlphy
= &rtlpriv
->phy
;
103 u32 wifi_bw
= BTC_WIFI_BW_HT20
;
105 if (halbtc_legacy(rtlpriv
)) {
106 wifi_bw
= BTC_WIFI_BW_LEGACY
;
108 switch (rtlphy
->current_chan_bw
) {
109 case HT_CHANNEL_WIDTH_20
:
110 wifi_bw
= BTC_WIFI_BW_HT20
;
112 case HT_CHANNEL_WIDTH_20_40
:
113 wifi_bw
= BTC_WIFI_BW_HT40
;
115 case HT_CHANNEL_WIDTH_80
:
116 wifi_bw
= BTC_WIFI_BW_HT80
;
124 static u8
halbtc_get_wifi_central_chnl(struct btc_coexist
*btcoexist
)
126 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
127 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
130 if (rtlphy
->current_channel
!= 0)
131 chnl
= rtlphy
->current_channel
;
132 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
133 "static halbtc_get_wifi_central_chnl:%d\n", chnl
);
137 static u8
rtl_get_hwpg_single_ant_path(struct rtl_priv
*rtlpriv
)
139 return rtlpriv
->btcoexist
.btc_info
.single_ant_path
;
142 static u8
rtl_get_hwpg_bt_type(struct rtl_priv
*rtlpriv
)
144 return rtlpriv
->btcoexist
.btc_info
.bt_type
;
147 static u8
rtl_get_hwpg_ant_num(struct rtl_priv
*rtlpriv
)
151 if (rtlpriv
->btcoexist
.btc_info
.ant_num
== ANT_X2
)
159 static u8
rtl_get_hwpg_package_type(struct rtl_priv
*rtlpriv
)
161 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
163 return rtlhal
->package_type
;
167 u8
rtl_get_hwpg_rfe_type(struct rtl_priv
*rtlpriv
)
169 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
171 return rtlhal
->rfe_type
;
175 bool halbtc_is_hw_mailbox_exist(struct btc_coexist
*btcoexist
)
177 if (IS_HARDWARE_TYPE_8812(btcoexist
->adapter
))
184 bool halbtc_send_bt_mp_operation(struct btc_coexist
*btcoexist
, u8 op_code
,
185 u8
*cmd
, u32 len
, unsigned long wait_ms
)
187 struct rtl_priv
*rtlpriv
;
188 const u8 oper_ver
= 0;
191 if (!halbtc_is_hw_mailbox_exist(btcoexist
))
194 if (wait_ms
) /* before h2c to avoid race condition */
195 reinit_completion(&btcoexist
->bt_mp_comp
);
197 rtlpriv
= btcoexist
->adapter
;
199 /* fill req_num by op_code, and rtl_btc_btmpinfo_notify() use it
200 * to know message type
203 case BT_OP_GET_BT_VERSION
:
204 req_num
= BT_SEQ_GET_BT_VERSION
;
206 case BT_OP_GET_AFH_MAP_L
:
207 req_num
= BT_SEQ_GET_AFH_MAP_L
;
209 case BT_OP_GET_AFH_MAP_M
:
210 req_num
= BT_SEQ_GET_AFH_MAP_M
;
212 case BT_OP_GET_AFH_MAP_H
:
213 req_num
= BT_SEQ_GET_AFH_MAP_H
;
215 case BT_OP_GET_BT_COEX_SUPPORTED_FEATURE
:
216 req_num
= BT_SEQ_GET_BT_COEX_SUPPORTED_FEATURE
;
218 case BT_OP_GET_BT_COEX_SUPPORTED_VERSION
:
219 req_num
= BT_SEQ_GET_BT_COEX_SUPPORTED_VERSION
;
221 case BT_OP_GET_BT_ANT_DET_VAL
:
222 req_num
= BT_SEQ_GET_BT_ANT_DET_VAL
;
224 case BT_OP_GET_BT_BLE_SCAN_PARA
:
225 req_num
= BT_SEQ_GET_BT_BLE_SCAN_PARA
;
227 case BT_OP_GET_BT_BLE_SCAN_TYPE
:
228 req_num
= BT_SEQ_GET_BT_BLE_SCAN_TYPE
;
230 case BT_OP_GET_BT_DEVICE_INFO
:
231 req_num
= BT_SEQ_GET_BT_DEVICE_INFO
;
233 case BT_OP_GET_BT_FORBIDDEN_SLOT_VAL
:
234 req_num
= BT_SEQ_GET_BT_FORB_SLOT_VAL
;
236 case BT_OP_WRITE_REG_ADDR
:
237 case BT_OP_WRITE_REG_VALUE
:
240 req_num
= BT_SEQ_DONT_CARE
;
244 cmd
[0] |= (oper_ver
& 0x0f); /* Set OperVer */
245 cmd
[0] |= ((req_num
<< 4) & 0xf0); /* Set ReqNum */
247 rtlpriv
->cfg
->ops
->fill_h2c_cmd(rtlpriv
->mac80211
.hw
, 0x67, len
, cmd
);
253 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
254 "btmpinfo wait req_num=%d wait=%ld\n", req_num
, wait_ms
);
259 if (wait_for_completion_timeout(&btcoexist
->bt_mp_comp
,
260 msecs_to_jiffies(wait_ms
)) == 0) {
261 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_DMESG
,
262 "btmpinfo wait (req_num=%d) timeout\n", req_num
);
264 return false; /* timeout */
270 static void halbtc_leave_lps(struct btc_coexist
*btcoexist
)
272 struct rtl_priv
*rtlpriv
;
273 bool ap_enable
= false;
275 rtlpriv
= btcoexist
->adapter
;
277 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_AP_MODE_ENABLE
,
281 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_DMESG
,
282 "%s()<--dont leave lps under AP mode\n", __func__
);
286 btcoexist
->bt_info
.bt_ctrl_lps
= true;
287 btcoexist
->bt_info
.bt_lps_on
= false;
288 rtl_lps_leave(rtlpriv
->mac80211
.hw
);
291 static void halbtc_enter_lps(struct btc_coexist
*btcoexist
)
293 struct rtl_priv
*rtlpriv
;
294 bool ap_enable
= false;
296 rtlpriv
= btcoexist
->adapter
;
298 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_AP_MODE_ENABLE
,
302 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_DMESG
,
303 "%s()<--dont enter lps under AP mode\n", __func__
);
307 btcoexist
->bt_info
.bt_ctrl_lps
= true;
308 btcoexist
->bt_info
.bt_lps_on
= true;
309 rtl_lps_enter(rtlpriv
->mac80211
.hw
);
312 static void halbtc_normal_lps(struct btc_coexist
*btcoexist
)
314 struct rtl_priv
*rtlpriv
;
316 rtlpriv
= btcoexist
->adapter
;
318 if (btcoexist
->bt_info
.bt_ctrl_lps
) {
319 btcoexist
->bt_info
.bt_lps_on
= false;
320 rtl_lps_leave(rtlpriv
->mac80211
.hw
);
321 btcoexist
->bt_info
.bt_ctrl_lps
= false;
325 static void halbtc_pre_normal_lps(struct btc_coexist
*btcoexist
)
327 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
329 if (btcoexist
->bt_info
.bt_ctrl_lps
) {
330 btcoexist
->bt_info
.bt_lps_on
= false;
331 rtl_lps_leave(rtlpriv
->mac80211
.hw
);
335 static void halbtc_post_normal_lps(struct btc_coexist
*btcoexist
)
337 if (btcoexist
->bt_info
.bt_ctrl_lps
)
338 btcoexist
->bt_info
.bt_ctrl_lps
= false;
341 static void halbtc_leave_low_power(struct btc_coexist
*btcoexist
)
345 static void halbtc_normal_low_power(struct btc_coexist
*btcoexist
)
349 static void halbtc_disable_low_power(struct btc_coexist
*btcoexist
,
350 bool low_pwr_disable
)
352 /* TODO: original/leave 32k low power */
353 btcoexist
->bt_info
.bt_disable_low_pwr
= low_pwr_disable
;
356 static void halbtc_aggregation_check(struct btc_coexist
*btcoexist
)
358 bool need_to_act
= false;
359 static unsigned long pre_time
;
360 unsigned long cur_time
= 0;
361 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
363 /* To void continuous deleteBA=>addBA=>deleteBA=>addBA
364 * This function is not allowed to continuous called
365 * It can only be called after 8 seconds
369 if (jiffies_to_msecs(cur_time
- pre_time
) <= 8000) {
370 /* over 8 seconds you can execute this function again. */
375 if (btcoexist
->bt_info
.reject_agg_pkt
) {
377 btcoexist
->bt_info
.pre_reject_agg_pkt
=
378 btcoexist
->bt_info
.reject_agg_pkt
;
380 if (btcoexist
->bt_info
.pre_reject_agg_pkt
) {
382 btcoexist
->bt_info
.pre_reject_agg_pkt
=
383 btcoexist
->bt_info
.reject_agg_pkt
;
386 if (btcoexist
->bt_info
.pre_bt_ctrl_agg_buf_size
!=
387 btcoexist
->bt_info
.bt_ctrl_agg_buf_size
) {
389 btcoexist
->bt_info
.pre_bt_ctrl_agg_buf_size
=
390 btcoexist
->bt_info
.bt_ctrl_agg_buf_size
;
393 if (btcoexist
->bt_info
.bt_ctrl_agg_buf_size
) {
394 if (btcoexist
->bt_info
.pre_agg_buf_size
!=
395 btcoexist
->bt_info
.agg_buf_size
) {
398 btcoexist
->bt_info
.pre_agg_buf_size
=
399 btcoexist
->bt_info
.agg_buf_size
;
403 rtl_rx_ampdu_apply(rtlpriv
);
407 static u32
halbtc_get_bt_patch_version(struct btc_coexist
*btcoexist
)
409 u8 cmd_buffer
[4] = {0};
411 if (btcoexist
->bt_info
.bt_real_fw_ver
)
414 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
415 halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_BT_VERSION
,
419 return btcoexist
->bt_info
.bt_real_fw_ver
;
422 static u32
halbtc_get_bt_coex_supported_feature(void *btc_context
)
424 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
425 u8 cmd_buffer
[4] = {0};
427 if (btcoexist
->bt_info
.bt_supported_feature
)
430 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
431 halbtc_send_bt_mp_operation(btcoexist
,
432 BT_OP_GET_BT_COEX_SUPPORTED_FEATURE
,
436 return btcoexist
->bt_info
.bt_supported_feature
;
439 static u32
halbtc_get_bt_coex_supported_version(void *btc_context
)
441 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
442 u8 cmd_buffer
[4] = {0};
444 if (btcoexist
->bt_info
.bt_supported_version
)
447 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
448 halbtc_send_bt_mp_operation(btcoexist
,
449 BT_OP_GET_BT_COEX_SUPPORTED_VERSION
,
453 return btcoexist
->bt_info
.bt_supported_version
;
456 static u32
halbtc_get_bt_device_info(void *btc_context
)
458 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
459 u8 cmd_buffer
[4] = {0};
461 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
462 halbtc_send_bt_mp_operation(btcoexist
,
463 BT_OP_GET_BT_DEVICE_INFO
,
466 return btcoexist
->bt_info
.bt_device_info
;
469 static u32
halbtc_get_bt_forbidden_slot_val(void *btc_context
)
471 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
472 u8 cmd_buffer
[4] = {0};
474 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
475 halbtc_send_bt_mp_operation(btcoexist
,
476 BT_OP_GET_BT_FORBIDDEN_SLOT_VAL
,
479 return btcoexist
->bt_info
.bt_forb_slot_val
;
482 static u32
halbtc_get_wifi_link_status(struct btc_coexist
*btcoexist
)
485 * [31:16] => connected port number
486 * [15:0] => port connected bit define
488 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
489 struct rtl_mac
*mac
= rtl_mac(rtlpriv
);
491 u32 port_connected_status
= 0, num_of_connected_port
= 0;
493 if (mac
->opmode
== NL80211_IFTYPE_STATION
&&
494 mac
->link_state
>= MAC80211_LINKED
) {
495 port_connected_status
|= WIFI_STA_CONNECTED
;
496 num_of_connected_port
++;
498 /* AP & ADHOC & MESH */
499 if (is_any_client_connect_to_ap(btcoexist
)) {
500 port_connected_status
|= WIFI_AP_CONNECTED
;
501 num_of_connected_port
++;
503 /* TODO: P2P Connected Status */
505 ret_val
= (num_of_connected_port
<< 16) | port_connected_status
;
510 static s32
halbtc_get_wifi_rssi(struct rtl_priv
*rtlpriv
)
512 return rtlpriv
->dm
.undec_sm_pwdb
;
515 static bool halbtc_get(void *void_btcoexist
, u8 get_type
, void *out_buf
)
517 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)void_btcoexist
;
518 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
519 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
520 struct rtl_mac
*mac
= rtl_mac(rtlpriv
);
521 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
522 bool *bool_tmp
= (bool *)out_buf
;
523 int *s32_tmp
= (int *)out_buf
;
524 u32
*u32_tmp
= (u32
*)out_buf
;
525 u8
*u8_tmp
= (u8
*)out_buf
;
529 if (!halbtc_is_bt_coexist_available(btcoexist
))
533 case BTC_GET_BL_HS_OPERATION
:
537 case BTC_GET_BL_HS_CONNECTING
:
541 case BTC_GET_BL_WIFI_CONNECTED
:
542 if (rtlpriv
->mac80211
.opmode
== NL80211_IFTYPE_STATION
&&
543 rtlpriv
->mac80211
.link_state
>= MAC80211_LINKED
)
545 if (is_any_client_connect_to_ap(btcoexist
))
549 case BTC_GET_BL_WIFI_DUAL_BAND_CONNECTED
:
550 *u8_tmp
= BTC_MULTIPORT_SCC
;
552 case BTC_GET_BL_WIFI_BUSY
:
553 if (halbtc_is_wifi_busy(rtlpriv
))
558 case BTC_GET_BL_WIFI_SCAN
:
559 if (mac
->act_scanning
)
564 case BTC_GET_BL_WIFI_LINK
:
565 if (mac
->link_state
== MAC80211_LINKING
)
570 case BTC_GET_BL_WIFI_ROAM
:
571 if (mac
->link_state
== MAC80211_LINKING
)
576 case BTC_GET_BL_WIFI_4_WAY_PROGRESS
:
577 *bool_tmp
= rtlpriv
->btcoexist
.btc_info
.in_4way
;
579 case BTC_GET_BL_WIFI_UNDER_5G
:
580 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
585 case BTC_GET_BL_WIFI_AP_MODE_ENABLE
:
586 if (mac
->opmode
== NL80211_IFTYPE_AP
)
591 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION
:
592 if (NO_ENCRYPTION
== rtlpriv
->sec
.pairwise_enc_algorithm
)
597 case BTC_GET_BL_WIFI_UNDER_B_MODE
:
598 if (rtlpriv
->mac80211
.mode
== WIRELESS_MODE_B
)
603 case BTC_GET_BL_EXT_SWITCH
:
606 case BTC_GET_BL_WIFI_IS_IN_MP_MODE
:
609 case BTC_GET_BL_IS_ASUS_8723B
:
612 case BTC_GET_BL_RF4CE_CONNECTED
:
615 case BTC_GET_S4_WIFI_RSSI
:
616 *s32_tmp
= halbtc_get_wifi_rssi(rtlpriv
);
618 case BTC_GET_S4_HS_RSSI
:
622 case BTC_GET_U4_WIFI_BW
:
623 *u32_tmp
= halbtc_get_wifi_bw(btcoexist
);
625 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
:
626 if (halbtc_is_wifi_uplink(rtlpriv
))
627 *u32_tmp
= BTC_WIFI_TRAFFIC_TX
;
629 *u32_tmp
= BTC_WIFI_TRAFFIC_RX
;
631 case BTC_GET_U4_WIFI_FW_VER
:
632 *u32_tmp
= (rtlhal
->fw_version
<< 16) | rtlhal
->fw_subversion
;
634 case BTC_GET_U4_WIFI_LINK_STATUS
:
635 *u32_tmp
= halbtc_get_wifi_link_status(btcoexist
);
637 case BTC_GET_U4_BT_PATCH_VER
:
638 *u32_tmp
= halbtc_get_bt_patch_version(btcoexist
);
640 case BTC_GET_U4_VENDOR
:
641 *u32_tmp
= BTC_VENDOR_OTHER
;
643 case BTC_GET_U4_SUPPORTED_VERSION
:
644 *u32_tmp
= halbtc_get_bt_coex_supported_version(btcoexist
);
646 case BTC_GET_U4_SUPPORTED_FEATURE
:
647 *u32_tmp
= halbtc_get_bt_coex_supported_feature(btcoexist
);
649 case BTC_GET_U4_BT_DEVICE_INFO
:
650 *u32_tmp
= halbtc_get_bt_device_info(btcoexist
);
652 case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL
:
653 *u32_tmp
= halbtc_get_bt_forbidden_slot_val(btcoexist
);
655 case BTC_GET_U4_WIFI_IQK_TOTAL
:
657 btcoexist
->btc_phydm_query_phy_counter(btcoexist
,
660 case BTC_GET_U4_WIFI_IQK_OK
:
662 btcoexist
->btc_phydm_query_phy_counter(btcoexist
,
665 case BTC_GET_U4_WIFI_IQK_FAIL
:
667 btcoexist
->btc_phydm_query_phy_counter(btcoexist
,
670 case BTC_GET_U1_WIFI_DOT11_CHNL
:
671 *u8_tmp
= rtlphy
->current_channel
;
673 case BTC_GET_U1_WIFI_CENTRAL_CHNL
:
674 *u8_tmp
= halbtc_get_wifi_central_chnl(btcoexist
);
676 case BTC_GET_U1_WIFI_HS_CHNL
:
680 case BTC_GET_U1_AP_NUM
:
681 *u8_tmp
= rtlpriv
->btcoexist
.btc_info
.ap_num
;
683 case BTC_GET_U1_ANT_TYPE
:
684 *u8_tmp
= (u8
)BTC_ANT_TYPE_0
;
686 case BTC_GET_U1_IOT_PEER
:
690 /************* 1Ant **************/
691 case BTC_GET_U1_LPS_MODE
:
692 *u8_tmp
= btcoexist
->pwr_mode_val
[0];
703 static bool halbtc_set(void *void_btcoexist
, u8 set_type
, void *in_buf
)
705 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)void_btcoexist
;
706 bool *bool_tmp
= (bool *)in_buf
;
707 u8
*u8_tmp
= (u8
*)in_buf
;
708 u32
*u32_tmp
= (u32
*)in_buf
;
711 if (!halbtc_is_bt_coexist_available(btcoexist
))
715 /* set some bool type variables. */
716 case BTC_SET_BL_BT_DISABLE
:
717 btcoexist
->bt_info
.bt_disabled
= *bool_tmp
;
719 case BTC_SET_BL_BT_TRAFFIC_BUSY
:
720 btcoexist
->bt_info
.bt_busy
= *bool_tmp
;
722 case BTC_SET_BL_BT_LIMITED_DIG
:
723 btcoexist
->bt_info
.limited_dig
= *bool_tmp
;
725 case BTC_SET_BL_FORCE_TO_ROAM
:
726 btcoexist
->bt_info
.force_to_roam
= *bool_tmp
;
728 case BTC_SET_BL_TO_REJ_AP_AGG_PKT
:
729 btcoexist
->bt_info
.reject_agg_pkt
= *bool_tmp
;
731 case BTC_SET_BL_BT_CTRL_AGG_SIZE
:
732 btcoexist
->bt_info
.bt_ctrl_agg_buf_size
= *bool_tmp
;
734 case BTC_SET_BL_INC_SCAN_DEV_NUM
:
735 btcoexist
->bt_info
.increase_scan_dev_num
= *bool_tmp
;
737 case BTC_SET_BL_BT_TX_RX_MASK
:
738 btcoexist
->bt_info
.bt_tx_rx_mask
= *bool_tmp
;
740 case BTC_SET_BL_MIRACAST_PLUS_BT
:
741 btcoexist
->bt_info
.miracast_plus_bt
= *bool_tmp
;
743 /* set some u1Byte type variables. */
744 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON
:
745 btcoexist
->bt_info
.rssi_adjust_for_agc_table_on
= *u8_tmp
;
747 case BTC_SET_U1_AGG_BUF_SIZE
:
748 btcoexist
->bt_info
.agg_buf_size
= *u8_tmp
;
751 /* the following are some action which will be triggered */
752 case BTC_SET_ACT_GET_BT_RSSI
:
755 case BTC_SET_ACT_AGGREGATE_CTRL
:
756 halbtc_aggregation_check(btcoexist
);
760 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE
:
761 btcoexist
->bt_info
.rssi_adjust_for_1ant_coex_type
= *u8_tmp
;
763 case BTC_SET_UI_SCAN_SIG_COMPENSATION
:
765 case BTC_SET_U1_LPS_VAL
:
766 btcoexist
->bt_info
.lps_val
= *u8_tmp
;
768 case BTC_SET_U1_RPWM_VAL
:
769 btcoexist
->bt_info
.rpwm_val
= *u8_tmp
;
771 /* the following are some action which will be triggered */
772 case BTC_SET_ACT_LEAVE_LPS
:
773 halbtc_leave_lps(btcoexist
);
775 case BTC_SET_ACT_ENTER_LPS
:
776 halbtc_enter_lps(btcoexist
);
778 case BTC_SET_ACT_NORMAL_LPS
:
779 halbtc_normal_lps(btcoexist
);
781 case BTC_SET_ACT_PRE_NORMAL_LPS
:
782 halbtc_pre_normal_lps(btcoexist
);
784 case BTC_SET_ACT_POST_NORMAL_LPS
:
785 halbtc_post_normal_lps(btcoexist
);
787 case BTC_SET_ACT_DISABLE_LOW_POWER
:
788 halbtc_disable_low_power(btcoexist
, *bool_tmp
);
790 case BTC_SET_ACT_UPDATE_RAMASK
:
791 btcoexist
->bt_info
.ra_mask
= *u32_tmp
;
793 case BTC_SET_ACT_SEND_MIMO_PS
:
795 case BTC_SET_ACT_CTRL_BT_INFO
: /*wait for 8812/8821*/
797 case BTC_SET_ACT_CTRL_BT_COEX
:
799 case BTC_SET_ACT_CTRL_8723B_ANT
:
808 static void halbtc_display_coex_statistics(struct btc_coexist
*btcoexist
,
813 static void halbtc_display_bt_link_info(struct btc_coexist
*btcoexist
,
818 static void halbtc_display_wifi_status(struct btc_coexist
*btcoexist
,
821 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
822 s32 wifi_rssi
= 0, bt_hs_rssi
= 0;
823 bool scan
= false, link
= false, roam
= false, wifi_busy
= false;
824 bool wifi_under_b_mode
= false;
825 bool wifi_under_5g
= false;
826 u32 wifi_bw
= BTC_WIFI_BW_HT20
;
827 u32 wifi_traffic_dir
= BTC_WIFI_TRAFFIC_TX
;
828 u32 wifi_freq
= BTC_FREQ_2_4G
;
829 u32 wifi_link_status
= 0x0;
830 bool bt_hs_on
= false, under_ips
= false, under_lps
= false;
831 bool low_power
= false, dc_mode
= false;
832 u8 wifi_chnl
= 0, wifi_hs_chnl
= 0;
835 wifi_link_status
= halbtc_get_wifi_link_status(btcoexist
);
836 seq_printf(m
, "\n %-35s = %d/ %d/ %d/ %d/ %d",
837 "STA/vWifi/HS/p2pGo/p2pGc",
838 ((wifi_link_status
& WIFI_STA_CONNECTED
) ? 1 : 0),
839 ((wifi_link_status
& WIFI_AP_CONNECTED
) ? 1 : 0),
840 ((wifi_link_status
& WIFI_HS_CONNECTED
) ? 1 : 0),
841 ((wifi_link_status
& WIFI_P2P_GO_CONNECTED
) ? 1 : 0),
842 ((wifi_link_status
& WIFI_P2P_GC_CONNECTED
) ? 1 : 0));
844 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_HS_OPERATION
, &bt_hs_on
);
845 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_DOT11_CHNL
, &wifi_chnl
);
846 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_WIFI_HS_CHNL
, &wifi_hs_chnl
);
847 seq_printf(m
, "\n %-35s = %d / %d(%d)",
848 "Dot11 channel / HsChnl(High Speed)",
849 wifi_chnl
, wifi_hs_chnl
, bt_hs_on
);
851 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_WIFI_RSSI
, &wifi_rssi
);
852 btcoexist
->btc_get(btcoexist
, BTC_GET_S4_HS_RSSI
, &bt_hs_rssi
);
853 seq_printf(m
, "\n %-35s = %d/ %d",
854 "Wifi rssi/ HS rssi",
855 wifi_rssi
- 100, bt_hs_rssi
- 100);
857 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_SCAN
, &scan
);
858 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_LINK
, &link
);
859 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_ROAM
, &roam
);
860 seq_printf(m
, "\n %-35s = %d/ %d/ %d ",
861 "Wifi link/ roam/ scan",
864 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
865 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_BW
, &wifi_bw
);
866 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_BUSY
, &wifi_busy
);
867 btcoexist
->btc_get(btcoexist
, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
,
869 btcoexist
->btc_get(btcoexist
, BTC_GET_U1_AP_NUM
, &ap_num
);
870 wifi_freq
= (wifi_under_5g
? BTC_FREQ_5G
: BTC_FREQ_2_4G
);
871 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_B_MODE
,
874 seq_printf(m
, "\n %-35s = %s / %s/ %s/ AP=%d ",
875 "Wifi freq/ bw/ traffic",
876 gl_btc_wifi_freq_string
[wifi_freq
],
877 ((wifi_under_b_mode
) ? "11b" :
878 gl_btc_wifi_bw_string
[wifi_bw
]),
879 ((!wifi_busy
) ? "idle" : ((BTC_WIFI_TRAFFIC_TX
==
880 wifi_traffic_dir
) ? "uplink" :
885 dc_mode
= true; /*TODO*/
886 under_ips
= rtlpriv
->psc
.inactive_pwrstate
== ERFOFF
? 1 : 0;
887 under_lps
= rtlpriv
->psc
.dot11_psmode
== EACTIVE
? 0 : 1;
888 low_power
= 0; /*TODO*/
889 seq_printf(m
, "\n %-35s = %s%s%s%s",
891 (dc_mode
? "DC mode" : "AC mode"),
892 (under_ips
? ", IPS ON" : ""),
893 (under_lps
? ", LPS ON" : ""),
894 (low_power
? ", 32k" : ""));
897 "\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)",
898 "Power mode cmd(lps/rpwm)",
899 btcoexist
->pwr_mode_val
[0], btcoexist
->pwr_mode_val
[1],
900 btcoexist
->pwr_mode_val
[2], btcoexist
->pwr_mode_val
[3],
901 btcoexist
->pwr_mode_val
[4], btcoexist
->pwr_mode_val
[5],
902 btcoexist
->bt_info
.lps_val
,
903 btcoexist
->bt_info
.rpwm_val
);
906 /************************************************************
907 * IO related function
908 ************************************************************/
909 static u8
halbtc_read_1byte(void *bt_context
, u32 reg_addr
)
911 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
912 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
914 return rtl_read_byte(rtlpriv
, reg_addr
);
917 static u16
halbtc_read_2byte(void *bt_context
, u32 reg_addr
)
919 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
920 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
922 return rtl_read_word(rtlpriv
, reg_addr
);
925 static u32
halbtc_read_4byte(void *bt_context
, u32 reg_addr
)
927 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
928 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
930 return rtl_read_dword(rtlpriv
, reg_addr
);
933 static void halbtc_write_1byte(void *bt_context
, u32 reg_addr
, u32 data
)
935 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
936 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
938 rtl_write_byte(rtlpriv
, reg_addr
, data
);
941 static void halbtc_bitmask_write_1byte(void *bt_context
, u32 reg_addr
,
942 u32 bit_mask
, u8 data
)
944 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
945 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
946 u8 original_value
, bit_shift
= 0;
949 if (bit_mask
!= MASKDWORD
) {/*if not "double word" write*/
950 original_value
= rtl_read_byte(rtlpriv
, reg_addr
);
951 for (i
= 0; i
<= 7; i
++) {
952 if ((bit_mask
>>i
) & 0x1)
956 data
= (original_value
& (~bit_mask
)) |
957 ((data
<< bit_shift
) & bit_mask
);
959 rtl_write_byte(rtlpriv
, reg_addr
, data
);
962 static void halbtc_write_2byte(void *bt_context
, u32 reg_addr
, u16 data
)
964 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
965 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
967 rtl_write_word(rtlpriv
, reg_addr
, data
);
970 static void halbtc_write_4byte(void *bt_context
, u32 reg_addr
, u32 data
)
972 struct btc_coexist
*btcoexist
=
973 (struct btc_coexist
*)bt_context
;
974 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
976 rtl_write_dword(rtlpriv
, reg_addr
, data
);
979 static void halbtc_write_local_reg_1byte(void *btc_context
, u32 reg_addr
,
982 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
983 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
985 if (btcoexist
->chip_interface
== BTC_INTF_SDIO
)
987 else if (btcoexist
->chip_interface
== BTC_INTF_PCI
)
988 rtl_write_byte(rtlpriv
, reg_addr
, data
);
989 else if (btcoexist
->chip_interface
== BTC_INTF_USB
)
990 rtl_write_byte(rtlpriv
, reg_addr
, data
);
993 static void halbtc_set_bbreg(void *bt_context
, u32 reg_addr
, u32 bit_mask
,
996 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
997 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
999 rtl_set_bbreg(rtlpriv
->mac80211
.hw
, reg_addr
, bit_mask
, data
);
1002 static u32
halbtc_get_bbreg(void *bt_context
, u32 reg_addr
, u32 bit_mask
)
1004 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1005 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1007 return rtl_get_bbreg(rtlpriv
->mac80211
.hw
, reg_addr
, bit_mask
);
1010 static void halbtc_set_rfreg(void *bt_context
, u8 rf_path
, u32 reg_addr
,
1011 u32 bit_mask
, u32 data
)
1013 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1014 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1016 rtl_set_rfreg(rtlpriv
->mac80211
.hw
, rf_path
, reg_addr
, bit_mask
, data
);
1019 static u32
halbtc_get_rfreg(void *bt_context
, u8 rf_path
, u32 reg_addr
,
1022 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1023 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1025 return rtl_get_rfreg(rtlpriv
->mac80211
.hw
, rf_path
, reg_addr
, bit_mask
);
1028 static void halbtc_fill_h2c_cmd(void *bt_context
, u8 element_id
,
1029 u32 cmd_len
, u8
*cmd_buf
)
1031 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1032 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1034 rtlpriv
->cfg
->ops
->fill_h2c_cmd(rtlpriv
->mac80211
.hw
, element_id
,
1038 void halbtc_send_wifi_port_id_cmd(void *bt_context
)
1040 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1041 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1042 u8 cmd_buf
[1] = {0}; /* port id [2:0] = 0 */
1044 rtlpriv
->cfg
->ops
->fill_h2c_cmd(rtlpriv
->mac80211
.hw
, H2C_BT_PORT_ID
,
1048 void halbtc_set_default_port_id_cmd(void *bt_context
)
1050 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1051 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1052 struct ieee80211_hw
*hw
= rtlpriv
->mac80211
.hw
;
1054 if (!rtlpriv
->cfg
->ops
->set_default_port_id_cmd
)
1057 rtlpriv
->cfg
->ops
->set_default_port_id_cmd(hw
);
1061 void halbtc_set_bt_reg(void *btc_context
, u8 reg_type
, u32 offset
, u32 set_val
)
1063 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
1064 u8 cmd_buffer1
[4] = {0};
1065 u8 cmd_buffer2
[4] = {0};
1067 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1068 *((__le16
*)&cmd_buffer1
[2]) = cpu_to_le16((u16
)set_val
);
1069 if (!halbtc_send_bt_mp_operation(btcoexist
, BT_OP_WRITE_REG_VALUE
,
1070 cmd_buffer1
, 4, 200))
1073 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1074 cmd_buffer2
[2] = reg_type
;
1075 *((u8
*)&cmd_buffer2
[3]) = (u8
)offset
;
1076 halbtc_send_bt_mp_operation(btcoexist
, BT_OP_WRITE_REG_ADDR
,
1077 cmd_buffer2
, 4, 200);
1080 static void halbtc_display_dbg_msg(void *bt_context
, u8 disp_type
,
1083 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)bt_context
;
1085 switch (disp_type
) {
1086 case BTC_DBG_DISP_COEX_STATISTICS
:
1087 halbtc_display_coex_statistics(btcoexist
, m
);
1089 case BTC_DBG_DISP_BT_LINK_INFO
:
1090 halbtc_display_bt_link_info(btcoexist
, m
);
1092 case BTC_DBG_DISP_WIFI_STATUS
:
1093 halbtc_display_wifi_status(btcoexist
, m
);
1100 static u32
halbtc_get_bt_reg(void *btc_context
, u8 reg_type
, u32 offset
)
1105 static bool halbtc_under_ips(struct btc_coexist
*btcoexist
)
1107 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1108 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtlpriv
);
1109 enum rf_pwrstate rtstate
;
1111 if (ppsc
->inactiveps
) {
1112 rtstate
= ppsc
->rfpwr_state
;
1114 if (rtstate
!= ERFON
&&
1115 ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
) {
1124 u32
halbtc_get_phydm_version(void *btc_context
)
1130 void halbtc_phydm_modify_ra_pcr_threshold(void *btc_context
,
1131 u8 ra_offset_direction
,
1132 u8 ra_threshold_offset
)
1137 u32
halbtc_phydm_query_phy_counter(void *btc_context
, enum dm_info_query dm_id
)
1142 static u8
halbtc_get_ant_det_val_from_bt(void *btc_context
)
1144 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
1145 u8 cmd_buffer
[4] = {0};
1147 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1148 halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_BT_ANT_DET_VAL
,
1149 cmd_buffer
, 4, 200);
1151 /* need wait completion to return correct value */
1153 return btcoexist
->bt_info
.bt_ant_det_val
;
1156 static u8
halbtc_get_ble_scan_type_from_bt(void *btc_context
)
1158 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
1159 u8 cmd_buffer
[4] = {0};
1161 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1162 halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_BT_BLE_SCAN_TYPE
,
1163 cmd_buffer
, 4, 200);
1165 /* need wait completion to return correct value */
1167 return btcoexist
->bt_info
.bt_ble_scan_type
;
1170 static u32
halbtc_get_ble_scan_para_from_bt(void *btc_context
, u8 scan_type
)
1172 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
1173 u8 cmd_buffer
[4] = {0};
1175 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1176 halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_BT_BLE_SCAN_PARA
,
1177 cmd_buffer
, 4, 200);
1179 /* need wait completion to return correct value */
1181 return btcoexist
->bt_info
.bt_ble_scan_para
;
1184 static bool halbtc_get_bt_afh_map_from_bt(void *btc_context
, u8 map_type
,
1187 struct btc_coexist
*btcoexist
= (struct btc_coexist
*)btc_context
;
1188 u8 cmd_buffer
[2] = {0};
1190 u32
*afh_map_l
= (u32
*)afh_map
;
1191 u32
*afh_map_m
= (u32
*)(afh_map
+ 4);
1192 u16
*afh_map_h
= (u16
*)(afh_map
+ 8);
1194 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1195 ret
= halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_AFH_MAP_L
,
1196 cmd_buffer
, 2, 200);
1200 *afh_map_l
= btcoexist
->bt_info
.afh_map_l
;
1202 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1203 ret
= halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_AFH_MAP_M
,
1204 cmd_buffer
, 2, 200);
1208 *afh_map_m
= btcoexist
->bt_info
.afh_map_m
;
1210 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1211 ret
= halbtc_send_bt_mp_operation(btcoexist
, BT_OP_GET_AFH_MAP_H
,
1212 cmd_buffer
, 2, 200);
1216 *afh_map_h
= btcoexist
->bt_info
.afh_map_h
;
1222 /*****************************************************************
1223 * Extern functions called by other module
1224 *****************************************************************/
1225 bool exhalbtc_initlize_variables(struct rtl_priv
*rtlpriv
)
1227 struct btc_coexist
*btcoexist
= rtl_btc_coexist(rtlpriv
);
1234 btcoexist
->btc_read_1byte
= halbtc_read_1byte
;
1235 btcoexist
->btc_write_1byte
= halbtc_write_1byte
;
1236 btcoexist
->btc_write_1byte_bitmask
= halbtc_bitmask_write_1byte
;
1237 btcoexist
->btc_read_2byte
= halbtc_read_2byte
;
1238 btcoexist
->btc_write_2byte
= halbtc_write_2byte
;
1239 btcoexist
->btc_read_4byte
= halbtc_read_4byte
;
1240 btcoexist
->btc_write_4byte
= halbtc_write_4byte
;
1241 btcoexist
->btc_write_local_reg_1byte
= halbtc_write_local_reg_1byte
;
1243 btcoexist
->btc_set_bb_reg
= halbtc_set_bbreg
;
1244 btcoexist
->btc_get_bb_reg
= halbtc_get_bbreg
;
1246 btcoexist
->btc_set_rf_reg
= halbtc_set_rfreg
;
1247 btcoexist
->btc_get_rf_reg
= halbtc_get_rfreg
;
1249 btcoexist
->btc_fill_h2c
= halbtc_fill_h2c_cmd
;
1250 btcoexist
->btc_disp_dbg_msg
= halbtc_display_dbg_msg
;
1252 btcoexist
->btc_get
= halbtc_get
;
1253 btcoexist
->btc_set
= halbtc_set
;
1254 btcoexist
->btc_set_bt_reg
= halbtc_set_bt_reg
;
1255 btcoexist
->btc_get_bt_reg
= halbtc_get_bt_reg
;
1257 btcoexist
->bt_info
.bt_ctrl_buf_size
= false;
1258 btcoexist
->bt_info
.agg_buf_size
= 5;
1260 btcoexist
->bt_info
.increase_scan_dev_num
= false;
1262 btcoexist
->btc_get_bt_coex_supported_feature
=
1263 halbtc_get_bt_coex_supported_feature
;
1264 btcoexist
->btc_get_bt_coex_supported_version
=
1265 halbtc_get_bt_coex_supported_version
;
1266 btcoexist
->btc_get_bt_phydm_version
= halbtc_get_phydm_version
;
1267 btcoexist
->btc_phydm_modify_ra_pcr_threshold
=
1268 halbtc_phydm_modify_ra_pcr_threshold
;
1269 btcoexist
->btc_phydm_query_phy_counter
= halbtc_phydm_query_phy_counter
;
1270 btcoexist
->btc_get_ant_det_val_from_bt
= halbtc_get_ant_det_val_from_bt
;
1271 btcoexist
->btc_get_ble_scan_type_from_bt
=
1272 halbtc_get_ble_scan_type_from_bt
;
1273 btcoexist
->btc_get_ble_scan_para_from_bt
=
1274 halbtc_get_ble_scan_para_from_bt
;
1275 btcoexist
->btc_get_bt_afh_map_from_bt
=
1276 halbtc_get_bt_afh_map_from_bt
;
1278 init_completion(&btcoexist
->bt_mp_comp
);
1283 bool exhalbtc_initlize_variables_wifi_only(struct rtl_priv
*rtlpriv
)
1285 struct wifi_only_cfg
*wifionly_cfg
= rtl_btc_wifi_only(rtlpriv
);
1286 struct wifi_only_haldata
*wifionly_haldata
;
1291 wifionly_cfg
->adapter
= rtlpriv
;
1293 switch (rtlpriv
->rtlhal
.interface
) {
1295 wifionly_cfg
->chip_interface
= WIFIONLY_INTF_PCI
;
1298 wifionly_cfg
->chip_interface
= WIFIONLY_INTF_USB
;
1301 wifionly_cfg
->chip_interface
= WIFIONLY_INTF_UNKNOWN
;
1305 wifionly_haldata
= &wifionly_cfg
->haldata_info
;
1307 wifionly_haldata
->customer_id
= CUSTOMER_NORMAL
;
1308 wifionly_haldata
->efuse_pg_antnum
= rtl_get_hwpg_ant_num(rtlpriv
);
1309 wifionly_haldata
->efuse_pg_antpath
=
1310 rtl_get_hwpg_single_ant_path(rtlpriv
);
1311 wifionly_haldata
->rfe_type
= rtl_get_hwpg_rfe_type(rtlpriv
);
1312 wifionly_haldata
->ant_div_cfg
= 0;
1317 bool exhalbtc_bind_bt_coex_withadapter(void *adapter
)
1319 struct rtl_priv
*rtlpriv
= adapter
;
1320 struct btc_coexist
*btcoexist
= rtl_btc_coexist(rtlpriv
);
1321 u8 ant_num
= 2, chip_type
, single_ant_path
= 0;
1326 if (btcoexist
->binded
)
1329 switch (rtlpriv
->rtlhal
.interface
) {
1331 btcoexist
->chip_interface
= BTC_INTF_PCI
;
1334 btcoexist
->chip_interface
= BTC_INTF_USB
;
1337 btcoexist
->chip_interface
= BTC_INTF_UNKNOWN
;
1341 btcoexist
->binded
= true;
1342 btcoexist
->statistics
.cnt_bind
++;
1344 btcoexist
->adapter
= adapter
;
1346 btcoexist
->stack_info
.profile_notified
= false;
1348 btcoexist
->bt_info
.bt_ctrl_agg_buf_size
= false;
1349 btcoexist
->bt_info
.agg_buf_size
= 5;
1351 btcoexist
->bt_info
.increase_scan_dev_num
= false;
1352 btcoexist
->bt_info
.miracast_plus_bt
= false;
1354 chip_type
= rtl_get_hwpg_bt_type(rtlpriv
);
1355 exhalbtc_set_chip_type(btcoexist
, chip_type
);
1356 ant_num
= rtl_get_hwpg_ant_num(rtlpriv
);
1357 exhalbtc_set_ant_num(rtlpriv
, BT_COEX_ANT_TYPE_PG
, ant_num
);
1359 /* set default antenna position to main port */
1360 btcoexist
->board_info
.btdm_ant_pos
= BTC_ANTENNA_AT_MAIN_PORT
;
1362 single_ant_path
= rtl_get_hwpg_single_ant_path(rtlpriv
);
1363 exhalbtc_set_single_ant_path(btcoexist
, single_ant_path
);
1365 if (rtl_get_hwpg_package_type(rtlpriv
) == 0)
1366 btcoexist
->board_info
.tfbga_package
= false;
1367 else if (rtl_get_hwpg_package_type(rtlpriv
) == 1)
1368 btcoexist
->board_info
.tfbga_package
= false;
1370 btcoexist
->board_info
.tfbga_package
= true;
1372 if (btcoexist
->board_info
.tfbga_package
)
1373 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1374 "[BTCoex], Package Type = TFBGA\n");
1376 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
1377 "[BTCoex], Package Type = Non-TFBGA\n");
1379 btcoexist
->board_info
.rfe_type
= rtl_get_hwpg_rfe_type(rtlpriv
);
1380 btcoexist
->board_info
.ant_div_cfg
= 0;
1385 void exhalbtc_power_on_setting(struct btc_coexist
*btcoexist
)
1387 if (!halbtc_is_bt_coexist_available(btcoexist
))
1390 btcoexist
->statistics
.cnt_power_on
++;
1392 if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1393 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1394 ex_btc8723b2ant_power_on_setting(btcoexist
);
1395 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1396 ex_btc8723b1ant_power_on_setting(btcoexist
);
1400 void exhalbtc_pre_load_firmware(struct btc_coexist
*btcoexist
)
1402 if (!halbtc_is_bt_coexist_available(btcoexist
))
1405 btcoexist
->statistics
.cnt_pre_load_firmware
++;
1407 if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1408 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1409 ex_btc8723b2ant_pre_load_firmware(btcoexist
);
1413 void exhalbtc_init_hw_config(struct btc_coexist
*btcoexist
, bool wifi_only
)
1415 if (!halbtc_is_bt_coexist_available(btcoexist
))
1418 btcoexist
->statistics
.cnt_init_hw_config
++;
1420 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1421 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1422 ex_btc8821a2ant_init_hwconfig(btcoexist
);
1423 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1424 ex_btc8821a1ant_init_hwconfig(btcoexist
, wifi_only
);
1425 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1426 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1427 ex_btc8723b2ant_init_hwconfig(btcoexist
);
1428 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1429 ex_btc8723b1ant_init_hwconfig(btcoexist
, wifi_only
);
1430 } else if (IS_HARDWARE_TYPE_8723A(btcoexist
->adapter
)) {
1431 /* 8723A has no this function */
1432 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1433 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1434 ex_btc8192e2ant_init_hwconfig(btcoexist
);
1438 void exhalbtc_init_hw_config_wifi_only(struct wifi_only_cfg
*wifionly_cfg
)
1442 void exhalbtc_init_coex_dm(struct btc_coexist
*btcoexist
)
1444 if (!halbtc_is_bt_coexist_available(btcoexist
))
1447 btcoexist
->statistics
.cnt_init_coex_dm
++;
1449 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1450 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1451 ex_btc8821a2ant_init_coex_dm(btcoexist
);
1452 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1453 ex_btc8821a1ant_init_coex_dm(btcoexist
);
1454 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1455 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1456 ex_btc8723b2ant_init_coex_dm(btcoexist
);
1457 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1458 ex_btc8723b1ant_init_coex_dm(btcoexist
);
1459 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1460 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1461 ex_btc8192e2ant_init_coex_dm(btcoexist
);
1464 btcoexist
->initialized
= true;
1467 void exhalbtc_ips_notify(struct btc_coexist
*btcoexist
, u8 type
)
1471 if (!halbtc_is_bt_coexist_available(btcoexist
))
1473 btcoexist
->statistics
.cnt_ips_notify
++;
1474 if (btcoexist
->manual_control
)
1478 ips_type
= BTC_IPS_ENTER
;
1480 ips_type
= BTC_IPS_LEAVE
;
1482 halbtc_leave_low_power(btcoexist
);
1484 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1485 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1486 ex_btc8821a2ant_ips_notify(btcoexist
, ips_type
);
1487 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1488 ex_btc8821a1ant_ips_notify(btcoexist
, ips_type
);
1489 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1490 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1491 ex_btc8723b2ant_ips_notify(btcoexist
, ips_type
);
1492 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1493 ex_btc8723b1ant_ips_notify(btcoexist
, ips_type
);
1494 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1495 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1496 ex_btc8192e2ant_ips_notify(btcoexist
, ips_type
);
1499 halbtc_normal_low_power(btcoexist
);
1502 void exhalbtc_lps_notify(struct btc_coexist
*btcoexist
, u8 type
)
1506 if (!halbtc_is_bt_coexist_available(btcoexist
))
1508 btcoexist
->statistics
.cnt_lps_notify
++;
1509 if (btcoexist
->manual_control
)
1512 if (EACTIVE
== type
)
1513 lps_type
= BTC_LPS_DISABLE
;
1515 lps_type
= BTC_LPS_ENABLE
;
1517 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1518 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1519 ex_btc8821a2ant_lps_notify(btcoexist
, lps_type
);
1520 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1521 ex_btc8821a1ant_lps_notify(btcoexist
, lps_type
);
1522 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1523 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1524 ex_btc8723b2ant_lps_notify(btcoexist
, lps_type
);
1525 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1526 ex_btc8723b1ant_lps_notify(btcoexist
, lps_type
);
1527 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1528 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1529 ex_btc8192e2ant_lps_notify(btcoexist
, lps_type
);
1533 void exhalbtc_scan_notify(struct btc_coexist
*btcoexist
, u8 type
)
1537 if (!halbtc_is_bt_coexist_available(btcoexist
))
1539 btcoexist
->statistics
.cnt_scan_notify
++;
1540 if (btcoexist
->manual_control
)
1544 scan_type
= BTC_SCAN_START
;
1546 scan_type
= BTC_SCAN_FINISH
;
1548 halbtc_leave_low_power(btcoexist
);
1550 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1551 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1552 ex_btc8821a2ant_scan_notify(btcoexist
, scan_type
);
1553 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1554 ex_btc8821a1ant_scan_notify(btcoexist
, scan_type
);
1555 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1556 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1557 ex_btc8723b2ant_scan_notify(btcoexist
, scan_type
);
1558 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1559 ex_btc8723b1ant_scan_notify(btcoexist
, scan_type
);
1560 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1561 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1562 ex_btc8192e2ant_scan_notify(btcoexist
, scan_type
);
1565 halbtc_normal_low_power(btcoexist
);
1568 void exhalbtc_scan_notify_wifi_only(struct wifi_only_cfg
*wifionly_cfg
,
1573 void exhalbtc_connect_notify(struct btc_coexist
*btcoexist
, u8 action
)
1578 if (!halbtc_is_bt_coexist_available(btcoexist
))
1580 btcoexist
->statistics
.cnt_connect_notify
++;
1581 if (btcoexist
->manual_control
)
1584 btcoexist
->btc_get(btcoexist
, BTC_GET_BL_WIFI_UNDER_5G
, &wifi_under_5g
);
1587 asso_type
= BTC_ASSOCIATE_START
;
1589 asso_type
= BTC_ASSOCIATE_FINISH
;
1591 halbtc_leave_low_power(btcoexist
);
1593 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1594 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1595 ex_btc8821a2ant_connect_notify(btcoexist
, asso_type
);
1596 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1597 ex_btc8821a1ant_connect_notify(btcoexist
, asso_type
);
1598 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1599 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1600 ex_btc8723b2ant_connect_notify(btcoexist
, asso_type
);
1601 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1602 ex_btc8723b1ant_connect_notify(btcoexist
, asso_type
);
1603 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1604 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1605 ex_btc8192e2ant_connect_notify(btcoexist
, asso_type
);
1608 halbtc_normal_low_power(btcoexist
);
1611 void exhalbtc_mediastatus_notify(struct btc_coexist
*btcoexist
,
1612 enum rt_media_status media_status
)
1616 if (!halbtc_is_bt_coexist_available(btcoexist
))
1618 btcoexist
->statistics
.cnt_media_status_notify
++;
1619 if (btcoexist
->manual_control
)
1622 if (RT_MEDIA_CONNECT
== media_status
)
1623 status
= BTC_MEDIA_CONNECT
;
1625 status
= BTC_MEDIA_DISCONNECT
;
1627 halbtc_leave_low_power(btcoexist
);
1629 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1630 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1631 ex_btc8821a2ant_media_status_notify(btcoexist
, status
);
1632 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1633 ex_btc8821a1ant_media_status_notify(btcoexist
, status
);
1634 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1635 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1636 ex_btc8723b2ant_media_status_notify(btcoexist
, status
);
1637 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1638 ex_btc8723b1ant_media_status_notify(btcoexist
, status
);
1639 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1640 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1641 ex_btc8192e2ant_media_status_notify(btcoexist
, status
);
1644 halbtc_normal_low_power(btcoexist
);
1647 void exhalbtc_special_packet_notify(struct btc_coexist
*btcoexist
, u8 pkt_type
)
1651 if (!halbtc_is_bt_coexist_available(btcoexist
))
1653 btcoexist
->statistics
.cnt_special_packet_notify
++;
1654 if (btcoexist
->manual_control
)
1657 if (pkt_type
== PACKET_DHCP
) {
1658 packet_type
= BTC_PACKET_DHCP
;
1659 } else if (pkt_type
== PACKET_EAPOL
) {
1660 packet_type
= BTC_PACKET_EAPOL
;
1661 } else if (pkt_type
== PACKET_ARP
) {
1662 packet_type
= BTC_PACKET_ARP
;
1664 packet_type
= BTC_PACKET_UNKNOWN
;
1668 halbtc_leave_low_power(btcoexist
);
1670 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1671 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1672 ex_btc8821a2ant_special_packet_notify(btcoexist
,
1674 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1675 ex_btc8821a1ant_special_packet_notify(btcoexist
,
1677 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1678 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1679 ex_btc8723b2ant_special_packet_notify(btcoexist
,
1681 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1682 ex_btc8723b1ant_special_packet_notify(btcoexist
,
1684 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1685 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1686 ex_btc8192e2ant_special_packet_notify(btcoexist
,
1690 halbtc_normal_low_power(btcoexist
);
1693 void exhalbtc_bt_info_notify(struct btc_coexist
*btcoexist
,
1694 u8
*tmp_buf
, u8 length
)
1696 if (!halbtc_is_bt_coexist_available(btcoexist
))
1698 btcoexist
->statistics
.cnt_bt_info_notify
++;
1700 halbtc_leave_low_power(btcoexist
);
1702 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1703 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1704 ex_btc8821a2ant_bt_info_notify(btcoexist
, tmp_buf
,
1706 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1707 ex_btc8821a1ant_bt_info_notify(btcoexist
, tmp_buf
,
1709 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1710 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1711 ex_btc8723b2ant_bt_info_notify(btcoexist
, tmp_buf
,
1713 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1714 ex_btc8723b1ant_bt_info_notify(btcoexist
, tmp_buf
,
1716 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1717 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1718 ex_btc8192e2ant_bt_info_notify(btcoexist
, tmp_buf
,
1722 halbtc_normal_low_power(btcoexist
);
1725 void exhalbtc_rf_status_notify(struct btc_coexist
*btcoexist
, u8 type
)
1727 if (!halbtc_is_bt_coexist_available(btcoexist
))
1730 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1731 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1732 if (btcoexist
->board_info
.btdm_ant_num
== 1)
1733 ex_btc8723b1ant_rf_status_notify(btcoexist
, type
);
1734 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1738 void exhalbtc_halt_notify(struct btc_coexist
*btcoexist
)
1740 if (!halbtc_is_bt_coexist_available(btcoexist
))
1743 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1744 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1745 ex_btc8821a2ant_halt_notify(btcoexist
);
1746 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1747 ex_btc8821a1ant_halt_notify(btcoexist
);
1748 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1749 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1750 ex_btc8723b2ant_halt_notify(btcoexist
);
1751 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1752 ex_btc8723b1ant_halt_notify(btcoexist
);
1753 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1754 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1755 ex_btc8192e2ant_halt_notify(btcoexist
);
1758 btcoexist
->binded
= false;
1761 void exhalbtc_pnp_notify(struct btc_coexist
*btcoexist
, u8 pnp_state
)
1763 if (!halbtc_is_bt_coexist_available(btcoexist
))
1766 /* currently only 1ant we have to do the notification,
1767 * once pnp is notified to sleep state, we have to leave LPS that
1768 * we can sleep normally.
1771 if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1772 if (btcoexist
->board_info
.btdm_ant_num
== 1)
1773 ex_btc8723b1ant_pnp_notify(btcoexist
, pnp_state
);
1774 else if (btcoexist
->board_info
.btdm_ant_num
== 2)
1775 ex_btc8723b2ant_pnp_notify(btcoexist
, pnp_state
);
1776 } else if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1777 if (btcoexist
->board_info
.btdm_ant_num
== 1)
1778 ex_btc8821a1ant_pnp_notify(btcoexist
, pnp_state
);
1779 else if (btcoexist
->board_info
.btdm_ant_num
== 2)
1780 ex_btc8821a2ant_pnp_notify(btcoexist
, pnp_state
);
1781 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1785 void exhalbtc_coex_dm_switch(struct btc_coexist
*btcoexist
)
1787 struct rtl_priv
*rtlpriv
= btcoexist
->adapter
;
1789 if (!halbtc_is_bt_coexist_available(btcoexist
))
1791 btcoexist
->statistics
.cnt_coex_dm_switch
++;
1793 halbtc_leave_low_power(btcoexist
);
1795 if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1796 if (btcoexist
->board_info
.btdm_ant_num
== 1) {
1797 btcoexist
->stop_coex_dm
= true;
1798 ex_btc8723b1ant_coex_dm_reset(btcoexist
);
1799 exhalbtc_set_ant_num(rtlpriv
,
1800 BT_COEX_ANT_TYPE_DETECTED
, 2);
1801 ex_btc8723b2ant_init_hwconfig(btcoexist
);
1802 ex_btc8723b2ant_init_coex_dm(btcoexist
);
1803 btcoexist
->stop_coex_dm
= false;
1807 halbtc_normal_low_power(btcoexist
);
1810 void exhalbtc_periodical(struct btc_coexist
*btcoexist
)
1812 if (!halbtc_is_bt_coexist_available(btcoexist
))
1814 btcoexist
->statistics
.cnt_periodical
++;
1816 halbtc_leave_low_power(btcoexist
);
1818 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1819 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1820 ex_btc8821a2ant_periodical(btcoexist
);
1821 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1822 if (!halbtc_under_ips(btcoexist
))
1823 ex_btc8821a1ant_periodical(btcoexist
);
1824 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1825 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1826 ex_btc8723b2ant_periodical(btcoexist
);
1827 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1828 ex_btc8723b1ant_periodical(btcoexist
);
1829 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1830 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1831 ex_btc8192e2ant_periodical(btcoexist
);
1834 halbtc_normal_low_power(btcoexist
);
1837 void exhalbtc_dbg_control(struct btc_coexist
*btcoexist
,
1838 u8 code
, u8 len
, u8
*data
)
1840 if (!halbtc_is_bt_coexist_available(btcoexist
))
1842 btcoexist
->statistics
.cnt_dbg_ctrl
++;
1844 halbtc_leave_low_power(btcoexist
);
1846 halbtc_normal_low_power(btcoexist
);
1849 void exhalbtc_antenna_detection(struct btc_coexist
*btcoexist
, u32 cent_freq
,
1850 u32 offset
, u32 span
, u32 seconds
)
1852 if (!halbtc_is_bt_coexist_available(btcoexist
))
1856 void exhalbtc_stack_update_profile_info(void)
1860 void exhalbtc_update_min_bt_rssi(struct btc_coexist
*btcoexist
, s8 bt_rssi
)
1862 if (!halbtc_is_bt_coexist_available(btcoexist
))
1865 btcoexist
->stack_info
.min_bt_rssi
= bt_rssi
;
1868 void exhalbtc_set_hci_version(struct btc_coexist
*btcoexist
, u16 hci_version
)
1870 if (!halbtc_is_bt_coexist_available(btcoexist
))
1873 btcoexist
->stack_info
.hci_version
= hci_version
;
1876 void exhalbtc_set_bt_patch_version(struct btc_coexist
*btcoexist
,
1877 u16 bt_hci_version
, u16 bt_patch_version
)
1879 if (!halbtc_is_bt_coexist_available(btcoexist
))
1882 btcoexist
->bt_info
.bt_real_fw_ver
= bt_patch_version
;
1883 btcoexist
->bt_info
.bt_hci_ver
= bt_hci_version
;
1886 void exhalbtc_set_chip_type(struct btc_coexist
*btcoexist
, u8 chip_type
)
1888 switch (chip_type
) {
1894 btcoexist
->board_info
.bt_chip_type
= BTC_CHIP_UNDEF
;
1897 btcoexist
->board_info
.bt_chip_type
= BTC_CHIP_CSR_BC4
;
1900 btcoexist
->board_info
.bt_chip_type
= BTC_CHIP_CSR_BC8
;
1903 btcoexist
->board_info
.bt_chip_type
= BTC_CHIP_RTL8723A
;
1906 btcoexist
->board_info
.bt_chip_type
= BTC_CHIP_RTL8821
;
1909 btcoexist
->board_info
.bt_chip_type
= BTC_CHIP_RTL8723B
;
1914 void exhalbtc_set_ant_num(struct rtl_priv
*rtlpriv
, u8 type
, u8 ant_num
)
1916 struct btc_coexist
*btcoexist
= rtl_btc_coexist(rtlpriv
);
1921 if (BT_COEX_ANT_TYPE_PG
== type
) {
1922 btcoexist
->board_info
.pg_ant_num
= ant_num
;
1923 btcoexist
->board_info
.btdm_ant_num
= ant_num
;
1924 } else if (BT_COEX_ANT_TYPE_ANTDIV
== type
) {
1925 btcoexist
->board_info
.btdm_ant_num
= ant_num
;
1926 } else if (type
== BT_COEX_ANT_TYPE_DETECTED
) {
1927 btcoexist
->board_info
.btdm_ant_num
= ant_num
;
1928 if (rtlpriv
->cfg
->mod_params
->ant_sel
== 1)
1929 btcoexist
->board_info
.btdm_ant_pos
=
1930 BTC_ANTENNA_AT_AUX_PORT
;
1932 btcoexist
->board_info
.btdm_ant_pos
=
1933 BTC_ANTENNA_AT_MAIN_PORT
;
1937 /* Currently used by 8723b only, S0 or S1 */
1938 void exhalbtc_set_single_ant_path(struct btc_coexist
*btcoexist
,
1941 btcoexist
->board_info
.single_ant_path
= single_ant_path
;
1944 void exhalbtc_display_bt_coex_info(struct btc_coexist
*btcoexist
,
1947 if (!halbtc_is_bt_coexist_available(btcoexist
))
1950 halbtc_leave_low_power(btcoexist
);
1952 if (IS_HARDWARE_TYPE_8821(btcoexist
->adapter
)) {
1953 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1954 ex_btc8821a2ant_display_coex_info(btcoexist
, m
);
1955 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1956 ex_btc8821a1ant_display_coex_info(btcoexist
, m
);
1957 } else if (IS_HARDWARE_TYPE_8723B(btcoexist
->adapter
)) {
1958 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1959 ex_btc8723b2ant_display_coex_info(btcoexist
, m
);
1960 else if (btcoexist
->board_info
.btdm_ant_num
== 1)
1961 ex_btc8723b1ant_display_coex_info(btcoexist
, m
);
1962 } else if (IS_HARDWARE_TYPE_8192E(btcoexist
->adapter
)) {
1963 if (btcoexist
->board_info
.btdm_ant_num
== 2)
1964 ex_btc8192e2ant_display_coex_info(btcoexist
, m
);
1967 halbtc_normal_low_power(btcoexist
);
1970 void exhalbtc_switch_band_notify(struct btc_coexist
*btcoexist
, u8 type
)
1972 if (!halbtc_is_bt_coexist_available(btcoexist
))
1975 if (btcoexist
->manual_control
)
1978 halbtc_leave_low_power(btcoexist
);
1980 halbtc_normal_low_power(btcoexist
);
1983 void exhalbtc_switch_band_notify_wifi_only(struct wifi_only_cfg
*wifionly_cfg
,