1 /******************************************************************************
3 * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
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.
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
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 ******************************************************************************/
26 #include "halbt_precomp.h"
28 /***************************************************
29 * Debug related function
30 ***************************************************/
32 static const char *const gl_btc_wifi_bw_string[] = {
40 static const char *const gl_btc_wifi_freq_string[] = {
45 static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist)
47 if (!btcoexist->binded || NULL == btcoexist->adapter)
53 static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
55 if (rtlpriv->link_info.busytraffic)
61 static void halbtc_dbg_init(void)
65 /***************************************************
67 ***************************************************/
68 static bool is_any_client_connect_to_ap(struct btc_coexist *btcoexist)
70 struct rtl_priv *rtlpriv = btcoexist->adapter;
71 struct rtl_mac *mac = rtl_mac(rtlpriv);
72 struct rtl_sta_info *drv_priv;
75 if (mac->opmode == NL80211_IFTYPE_ADHOC ||
76 mac->opmode == NL80211_IFTYPE_MESH_POINT ||
77 mac->opmode == NL80211_IFTYPE_AP) {
78 if (in_interrupt() > 0) {
79 list_for_each_entry(drv_priv, &rtlpriv->entry_list,
84 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
85 list_for_each_entry(drv_priv, &rtlpriv->entry_list,
89 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
98 static bool halbtc_legacy(struct rtl_priv *adapter)
100 struct rtl_priv *rtlpriv = adapter;
101 struct rtl_mac *mac = rtl_mac(rtlpriv);
103 bool is_legacy = false;
105 if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_G))
111 bool halbtc_is_wifi_uplink(struct rtl_priv *adapter)
113 struct rtl_priv *rtlpriv = adapter;
115 if (rtlpriv->link_info.tx_busy_traffic)
121 static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist)
123 struct rtl_priv *rtlpriv = btcoexist->adapter;
124 struct rtl_phy *rtlphy = &rtlpriv->phy;
125 u32 wifi_bw = BTC_WIFI_BW_HT20;
127 if (halbtc_legacy(rtlpriv)) {
128 wifi_bw = BTC_WIFI_BW_LEGACY;
130 switch (rtlphy->current_chan_bw) {
131 case HT_CHANNEL_WIDTH_20:
132 wifi_bw = BTC_WIFI_BW_HT20;
134 case HT_CHANNEL_WIDTH_20_40:
135 wifi_bw = BTC_WIFI_BW_HT40;
137 case HT_CHANNEL_WIDTH_80:
138 wifi_bw = BTC_WIFI_BW_HT80;
146 static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
148 struct rtl_priv *rtlpriv = btcoexist->adapter;
149 struct rtl_phy *rtlphy = &(rtlpriv->phy);
152 if (rtlphy->current_channel != 0)
153 chnl = rtlphy->current_channel;
154 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
155 "static halbtc_get_wifi_central_chnl:%d\n", chnl);
159 static u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv)
161 return rtlpriv->btcoexist.btc_info.single_ant_path;
164 static u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
166 return rtlpriv->btcoexist.btc_info.bt_type;
169 static u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
173 if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
181 static u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv)
183 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
185 return rtlhal->package_type;
189 u8 rtl_get_hwpg_rfe_type(struct rtl_priv *rtlpriv)
191 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
193 return rtlhal->rfe_type;
197 bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist)
199 if (IS_HARDWARE_TYPE_8812(btcoexist->adapter))
206 bool halbtc_send_bt_mp_operation(struct btc_coexist *btcoexist, u8 op_code,
207 u8 *cmd, u32 len, unsigned long wait_ms)
209 struct rtl_priv *rtlpriv;
210 const u8 oper_ver = 0;
213 if (!halbtc_is_hw_mailbox_exist(btcoexist))
216 if (wait_ms) /* before h2c to avoid race condition */
217 reinit_completion(&btcoexist->bt_mp_comp);
219 rtlpriv = btcoexist->adapter;
221 /* fill req_num by op_code, and rtl_btc_btmpinfo_notify() use it
222 * to know message type
225 case BT_OP_GET_BT_VERSION:
226 req_num = BT_SEQ_GET_BT_VERSION;
228 case BT_OP_GET_AFH_MAP_L:
229 req_num = BT_SEQ_GET_AFH_MAP_L;
231 case BT_OP_GET_AFH_MAP_M:
232 req_num = BT_SEQ_GET_AFH_MAP_M;
234 case BT_OP_GET_AFH_MAP_H:
235 req_num = BT_SEQ_GET_AFH_MAP_H;
237 case BT_OP_GET_BT_COEX_SUPPORTED_FEATURE:
238 req_num = BT_SEQ_GET_BT_COEX_SUPPORTED_FEATURE;
240 case BT_OP_GET_BT_COEX_SUPPORTED_VERSION:
241 req_num = BT_SEQ_GET_BT_COEX_SUPPORTED_VERSION;
243 case BT_OP_GET_BT_ANT_DET_VAL:
244 req_num = BT_SEQ_GET_BT_ANT_DET_VAL;
246 case BT_OP_GET_BT_BLE_SCAN_PARA:
247 req_num = BT_SEQ_GET_BT_BLE_SCAN_PARA;
249 case BT_OP_GET_BT_BLE_SCAN_TYPE:
250 req_num = BT_SEQ_GET_BT_BLE_SCAN_TYPE;
252 case BT_OP_GET_BT_DEVICE_INFO:
253 req_num = BT_SEQ_GET_BT_DEVICE_INFO;
255 case BT_OP_GET_BT_FORBIDDEN_SLOT_VAL:
256 req_num = BT_SEQ_GET_BT_FORB_SLOT_VAL;
258 case BT_OP_WRITE_REG_ADDR:
259 case BT_OP_WRITE_REG_VALUE:
262 req_num = BT_SEQ_DONT_CARE;
266 cmd[0] |= (oper_ver & 0x0f); /* Set OperVer */
267 cmd[0] |= ((req_num << 4) & 0xf0); /* Set ReqNum */
269 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, len, cmd);
275 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
276 "btmpinfo wait req_num=%d wait=%ld\n", req_num, wait_ms);
281 if (wait_for_completion_timeout(&btcoexist->bt_mp_comp,
282 msecs_to_jiffies(wait_ms)) == 0) {
283 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
284 "btmpinfo wait (req_num=%d) timeout\n", req_num);
286 return false; /* timeout */
292 static void halbtc_leave_lps(struct btc_coexist *btcoexist)
294 struct rtl_priv *rtlpriv;
295 bool ap_enable = false;
297 rtlpriv = btcoexist->adapter;
299 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
303 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
304 "%s()<--dont leave lps under AP mode\n", __func__);
308 btcoexist->bt_info.bt_ctrl_lps = true;
309 btcoexist->bt_info.bt_lps_on = false;
310 rtl_lps_leave(rtlpriv->mac80211.hw);
313 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
315 struct rtl_priv *rtlpriv;
316 bool ap_enable = false;
318 rtlpriv = btcoexist->adapter;
320 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
324 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
325 "%s()<--dont enter lps under AP mode\n", __func__);
329 btcoexist->bt_info.bt_ctrl_lps = true;
330 btcoexist->bt_info.bt_lps_on = true;
331 rtl_lps_enter(rtlpriv->mac80211.hw);
334 static void halbtc_normal_lps(struct btc_coexist *btcoexist)
336 struct rtl_priv *rtlpriv;
338 rtlpriv = btcoexist->adapter;
340 if (btcoexist->bt_info.bt_ctrl_lps) {
341 btcoexist->bt_info.bt_lps_on = false;
342 rtl_lps_leave(rtlpriv->mac80211.hw);
343 btcoexist->bt_info.bt_ctrl_lps = false;
347 static void halbtc_pre_normal_lps(struct btc_coexist *btcoexist)
349 struct rtl_priv *rtlpriv = btcoexist->adapter;
351 if (btcoexist->bt_info.bt_ctrl_lps) {
352 btcoexist->bt_info.bt_lps_on = false;
353 rtl_lps_leave(rtlpriv->mac80211.hw);
357 static void halbtc_post_normal_lps(struct btc_coexist *btcoexist)
359 if (btcoexist->bt_info.bt_ctrl_lps)
360 btcoexist->bt_info.bt_ctrl_lps = false;
363 static void halbtc_leave_low_power(struct btc_coexist *btcoexist)
367 static void halbtc_normal_low_power(struct btc_coexist *btcoexist)
371 static void halbtc_disable_low_power(struct btc_coexist *btcoexist,
372 bool low_pwr_disable)
374 /* TODO: original/leave 32k low power */
375 btcoexist->bt_info.bt_disable_low_pwr = low_pwr_disable;
378 static void halbtc_aggregation_check(struct btc_coexist *btcoexist)
380 bool need_to_act = false;
381 static unsigned long pre_time;
382 unsigned long cur_time = 0;
383 struct rtl_priv *rtlpriv = btcoexist->adapter;
385 /* To void continuous deleteBA=>addBA=>deleteBA=>addBA
386 * This function is not allowed to continuous called
387 * It can only be called after 8 seconds
391 if (jiffies_to_msecs(cur_time - pre_time) <= 8000) {
392 /* over 8 seconds you can execute this function again. */
397 if (btcoexist->bt_info.reject_agg_pkt) {
399 btcoexist->bt_info.pre_reject_agg_pkt =
400 btcoexist->bt_info.reject_agg_pkt;
402 if (btcoexist->bt_info.pre_reject_agg_pkt) {
404 btcoexist->bt_info.pre_reject_agg_pkt =
405 btcoexist->bt_info.reject_agg_pkt;
408 if (btcoexist->bt_info.pre_bt_ctrl_agg_buf_size !=
409 btcoexist->bt_info.bt_ctrl_agg_buf_size) {
411 btcoexist->bt_info.pre_bt_ctrl_agg_buf_size =
412 btcoexist->bt_info.bt_ctrl_agg_buf_size;
415 if (btcoexist->bt_info.bt_ctrl_agg_buf_size) {
416 if (btcoexist->bt_info.pre_agg_buf_size !=
417 btcoexist->bt_info.agg_buf_size) {
420 btcoexist->bt_info.pre_agg_buf_size =
421 btcoexist->bt_info.agg_buf_size;
425 rtl_rx_ampdu_apply(rtlpriv);
429 static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
431 u8 cmd_buffer[4] = {0};
433 if (btcoexist->bt_info.bt_real_fw_ver)
436 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
437 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_VERSION,
441 return btcoexist->bt_info.bt_real_fw_ver;
444 static u32 halbtc_get_bt_coex_supported_feature(void *btc_context)
446 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
447 u8 cmd_buffer[4] = {0};
449 if (btcoexist->bt_info.bt_supported_feature)
452 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
453 halbtc_send_bt_mp_operation(btcoexist,
454 BT_OP_GET_BT_COEX_SUPPORTED_FEATURE,
458 return btcoexist->bt_info.bt_supported_feature;
461 static u32 halbtc_get_bt_coex_supported_version(void *btc_context)
463 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
464 u8 cmd_buffer[4] = {0};
466 if (btcoexist->bt_info.bt_supported_version)
469 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
470 halbtc_send_bt_mp_operation(btcoexist,
471 BT_OP_GET_BT_COEX_SUPPORTED_VERSION,
475 return btcoexist->bt_info.bt_supported_version;
478 static u32 halbtc_get_bt_device_info(void *btc_context)
480 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
481 u8 cmd_buffer[4] = {0};
483 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
484 halbtc_send_bt_mp_operation(btcoexist,
485 BT_OP_GET_BT_DEVICE_INFO,
488 return btcoexist->bt_info.bt_device_info;
491 static u32 halbtc_get_bt_forbidden_slot_val(void *btc_context)
493 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
494 u8 cmd_buffer[4] = {0};
496 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
497 halbtc_send_bt_mp_operation(btcoexist,
498 BT_OP_GET_BT_FORBIDDEN_SLOT_VAL,
501 return btcoexist->bt_info.bt_forb_slot_val;
504 static u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist)
507 * [31:16] => connected port number
508 * [15:0] => port connected bit define
510 struct rtl_priv *rtlpriv = btcoexist->adapter;
511 struct rtl_mac *mac = rtl_mac(rtlpriv);
513 u32 port_connected_status = 0, num_of_connected_port = 0;
515 if (mac->opmode == NL80211_IFTYPE_STATION &&
516 mac->link_state >= MAC80211_LINKED) {
517 port_connected_status |= WIFI_STA_CONNECTED;
518 num_of_connected_port++;
520 /* AP & ADHOC & MESH */
521 if (is_any_client_connect_to_ap(btcoexist)) {
522 port_connected_status |= WIFI_AP_CONNECTED;
523 num_of_connected_port++;
525 /* TODO: P2P Connected Status */
527 ret_val = (num_of_connected_port << 16) | port_connected_status;
532 static s32 halbtc_get_wifi_rssi(struct rtl_priv *rtlpriv)
534 int undec_sm_pwdb = 0;
536 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
537 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
538 else /* associated entry pwdb */
539 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
540 return undec_sm_pwdb;
543 static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
545 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
546 struct rtl_priv *rtlpriv = btcoexist->adapter;
547 struct rtl_phy *rtlphy = &(rtlpriv->phy);
548 struct rtl_mac *mac = rtl_mac(rtlpriv);
549 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
550 bool *bool_tmp = (bool *)out_buf;
551 int *s32_tmp = (int *)out_buf;
552 u32 *u32_tmp = (u32 *)out_buf;
553 u8 *u8_tmp = (u8 *)out_buf;
557 if (!halbtc_is_bt_coexist_available(btcoexist))
561 case BTC_GET_BL_HS_OPERATION:
565 case BTC_GET_BL_HS_CONNECTING:
569 case BTC_GET_BL_WIFI_CONNECTED:
570 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_STATION &&
571 rtlpriv->mac80211.link_state >= MAC80211_LINKED)
573 if (is_any_client_connect_to_ap(btcoexist))
577 case BTC_GET_BL_WIFI_DUAL_BAND_CONNECTED:
578 *u8_tmp = BTC_MULTIPORT_SCC;
580 case BTC_GET_BL_WIFI_BUSY:
581 if (halbtc_is_wifi_busy(rtlpriv))
586 case BTC_GET_BL_WIFI_SCAN:
587 if (mac->act_scanning)
592 case BTC_GET_BL_WIFI_LINK:
593 if (mac->link_state == MAC80211_LINKING)
598 case BTC_GET_BL_WIFI_ROAM:
599 if (mac->link_state == MAC80211_LINKING)
604 case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
605 *bool_tmp = rtlpriv->btcoexist.btc_info.in_4way;
607 case BTC_GET_BL_WIFI_UNDER_5G:
608 if (rtlhal->current_bandtype == BAND_ON_5G)
613 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
614 if (mac->opmode == NL80211_IFTYPE_AP)
619 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
620 if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm)
625 case BTC_GET_BL_WIFI_UNDER_B_MODE:
626 if (rtlpriv->mac80211.mode == WIRELESS_MODE_B)
631 case BTC_GET_BL_EXT_SWITCH:
634 case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
637 case BTC_GET_BL_IS_ASUS_8723B:
640 case BTC_GET_BL_RF4CE_CONNECTED:
643 case BTC_GET_S4_WIFI_RSSI:
644 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
646 case BTC_GET_S4_HS_RSSI:
650 case BTC_GET_U4_WIFI_BW:
651 *u32_tmp = halbtc_get_wifi_bw(btcoexist);
653 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
654 if (halbtc_is_wifi_uplink(rtlpriv))
655 *u32_tmp = BTC_WIFI_TRAFFIC_TX;
657 *u32_tmp = BTC_WIFI_TRAFFIC_RX;
659 case BTC_GET_U4_WIFI_FW_VER:
660 *u32_tmp = (rtlhal->fw_version << 16) | rtlhal->fw_subversion;
662 case BTC_GET_U4_WIFI_LINK_STATUS:
663 *u32_tmp = halbtc_get_wifi_link_status(btcoexist);
665 case BTC_GET_U4_BT_PATCH_VER:
666 *u32_tmp = halbtc_get_bt_patch_version(btcoexist);
668 case BTC_GET_U4_VENDOR:
669 *u32_tmp = BTC_VENDOR_OTHER;
671 case BTC_GET_U4_SUPPORTED_VERSION:
672 *u32_tmp = halbtc_get_bt_coex_supported_version(btcoexist);
674 case BTC_GET_U4_SUPPORTED_FEATURE:
675 *u32_tmp = halbtc_get_bt_coex_supported_feature(btcoexist);
677 case BTC_GET_U4_BT_DEVICE_INFO:
678 *u32_tmp = halbtc_get_bt_device_info(btcoexist);
680 case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL:
681 *u32_tmp = halbtc_get_bt_forbidden_slot_val(btcoexist);
683 case BTC_GET_U4_WIFI_IQK_TOTAL:
685 btcoexist->btc_phydm_query_phy_counter(btcoexist,
688 case BTC_GET_U4_WIFI_IQK_OK:
690 btcoexist->btc_phydm_query_phy_counter(btcoexist,
693 case BTC_GET_U4_WIFI_IQK_FAIL:
695 btcoexist->btc_phydm_query_phy_counter(btcoexist,
698 case BTC_GET_U1_WIFI_DOT11_CHNL:
699 *u8_tmp = rtlphy->current_channel;
701 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
702 *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist);
704 case BTC_GET_U1_WIFI_HS_CHNL:
708 case BTC_GET_U1_AP_NUM:
709 *u8_tmp = rtlpriv->btcoexist.btc_info.ap_num;
711 case BTC_GET_U1_ANT_TYPE:
712 *u8_tmp = (u8)BTC_ANT_TYPE_0;
714 case BTC_GET_U1_IOT_PEER:
718 /************* 1Ant **************/
719 case BTC_GET_U1_LPS_MODE:
720 *u8_tmp = btcoexist->pwr_mode_val[0];
731 static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf)
733 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
734 bool *bool_tmp = (bool *)in_buf;
735 u8 *u8_tmp = (u8 *)in_buf;
736 u32 *u32_tmp = (u32 *)in_buf;
739 if (!halbtc_is_bt_coexist_available(btcoexist))
743 /* set some bool type variables. */
744 case BTC_SET_BL_BT_DISABLE:
745 btcoexist->bt_info.bt_disabled = *bool_tmp;
747 case BTC_SET_BL_BT_TRAFFIC_BUSY:
748 btcoexist->bt_info.bt_busy = *bool_tmp;
750 case BTC_SET_BL_BT_LIMITED_DIG:
751 btcoexist->bt_info.limited_dig = *bool_tmp;
753 case BTC_SET_BL_FORCE_TO_ROAM:
754 btcoexist->bt_info.force_to_roam = *bool_tmp;
756 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
757 btcoexist->bt_info.reject_agg_pkt = *bool_tmp;
759 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
760 btcoexist->bt_info.bt_ctrl_agg_buf_size = *bool_tmp;
762 case BTC_SET_BL_INC_SCAN_DEV_NUM:
763 btcoexist->bt_info.increase_scan_dev_num = *bool_tmp;
765 case BTC_SET_BL_BT_TX_RX_MASK:
766 btcoexist->bt_info.bt_tx_rx_mask = *bool_tmp;
768 case BTC_SET_BL_MIRACAST_PLUS_BT:
769 btcoexist->bt_info.miracast_plus_bt = *bool_tmp;
771 /* set some u1Byte type variables. */
772 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
773 btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp;
775 case BTC_SET_U1_AGG_BUF_SIZE:
776 btcoexist->bt_info.agg_buf_size = *u8_tmp;
779 /* the following are some action which will be triggered */
780 case BTC_SET_ACT_GET_BT_RSSI:
783 case BTC_SET_ACT_AGGREGATE_CTRL:
784 halbtc_aggregation_check(btcoexist);
788 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
789 btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp;
791 case BTC_SET_UI_SCAN_SIG_COMPENSATION:
793 case BTC_SET_U1_LPS_VAL:
794 btcoexist->bt_info.lps_val = *u8_tmp;
796 case BTC_SET_U1_RPWM_VAL:
797 btcoexist->bt_info.rpwm_val = *u8_tmp;
799 /* the following are some action which will be triggered */
800 case BTC_SET_ACT_LEAVE_LPS:
801 halbtc_leave_lps(btcoexist);
803 case BTC_SET_ACT_ENTER_LPS:
804 halbtc_enter_lps(btcoexist);
806 case BTC_SET_ACT_NORMAL_LPS:
807 halbtc_normal_lps(btcoexist);
809 case BTC_SET_ACT_PRE_NORMAL_LPS:
810 halbtc_pre_normal_lps(btcoexist);
812 case BTC_SET_ACT_POST_NORMAL_LPS:
813 halbtc_post_normal_lps(btcoexist);
815 case BTC_SET_ACT_DISABLE_LOW_POWER:
816 halbtc_disable_low_power(btcoexist, *bool_tmp);
818 case BTC_SET_ACT_UPDATE_RAMASK:
819 btcoexist->bt_info.ra_mask = *u32_tmp;
821 case BTC_SET_ACT_SEND_MIMO_PS:
823 case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/
825 case BTC_SET_ACT_CTRL_BT_COEX:
827 case BTC_SET_ACT_CTRL_8723B_ANT:
836 static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist,
841 static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist,
846 static void halbtc_display_wifi_status(struct btc_coexist *btcoexist,
849 struct rtl_priv *rtlpriv = btcoexist->adapter;
850 s32 wifi_rssi = 0, bt_hs_rssi = 0;
851 bool scan = false, link = false, roam = false, wifi_busy = false;
852 bool wifi_under_b_mode = false;
853 bool wifi_under_5g = false;
854 u32 wifi_bw = BTC_WIFI_BW_HT20;
855 u32 wifi_traffic_dir = BTC_WIFI_TRAFFIC_TX;
856 u32 wifi_freq = BTC_FREQ_2_4G;
857 u32 wifi_link_status = 0x0;
858 bool bt_hs_on = false, under_ips = false, under_lps = false;
859 bool low_power = false, dc_mode = false;
860 u8 wifi_chnl = 0, wifi_hs_chnl = 0;
863 wifi_link_status = halbtc_get_wifi_link_status(btcoexist);
864 seq_printf(m, "\n %-35s = %d/ %d/ %d/ %d/ %d",
865 "STA/vWifi/HS/p2pGo/p2pGc",
866 ((wifi_link_status & WIFI_STA_CONNECTED) ? 1 : 0),
867 ((wifi_link_status & WIFI_AP_CONNECTED) ? 1 : 0),
868 ((wifi_link_status & WIFI_HS_CONNECTED) ? 1 : 0),
869 ((wifi_link_status & WIFI_P2P_GO_CONNECTED) ? 1 : 0),
870 ((wifi_link_status & WIFI_P2P_GC_CONNECTED) ? 1 : 0));
872 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
873 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifi_chnl);
874 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl);
875 seq_printf(m, "\n %-35s = %d / %d(%d)",
876 "Dot11 channel / HsChnl(High Speed)",
877 wifi_chnl, wifi_hs_chnl, bt_hs_on);
879 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
880 btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
881 seq_printf(m, "\n %-35s = %d/ %d",
882 "Wifi rssi/ HS rssi",
883 wifi_rssi - 100, bt_hs_rssi - 100);
885 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
886 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
887 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
888 seq_printf(m, "\n %-35s = %d/ %d/ %d ",
889 "Wifi link/ roam/ scan",
892 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
893 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
894 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
895 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
897 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
898 wifi_freq = (wifi_under_5g ? BTC_FREQ_5G : BTC_FREQ_2_4G);
899 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE,
902 seq_printf(m, "\n %-35s = %s / %s/ %s/ AP=%d ",
903 "Wifi freq/ bw/ traffic",
904 gl_btc_wifi_freq_string[wifi_freq],
905 ((wifi_under_b_mode) ? "11b" :
906 gl_btc_wifi_bw_string[wifi_bw]),
907 ((!wifi_busy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX ==
908 wifi_traffic_dir) ? "uplink" :
913 dc_mode = true; /*TODO*/
914 under_ips = rtlpriv->psc.inactive_pwrstate == ERFOFF ? 1 : 0;
915 under_lps = rtlpriv->psc.dot11_psmode == EACTIVE ? 0 : 1;
916 low_power = 0; /*TODO*/
917 seq_printf(m, "\n %-35s = %s%s%s%s",
919 (dc_mode ? "DC mode" : "AC mode"),
920 (under_ips ? ", IPS ON" : ""),
921 (under_lps ? ", LPS ON" : ""),
922 (low_power ? ", 32k" : ""));
925 "\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)",
926 "Power mode cmd(lps/rpwm)",
927 btcoexist->pwr_mode_val[0], btcoexist->pwr_mode_val[1],
928 btcoexist->pwr_mode_val[2], btcoexist->pwr_mode_val[3],
929 btcoexist->pwr_mode_val[4], btcoexist->pwr_mode_val[5],
930 btcoexist->bt_info.lps_val,
931 btcoexist->bt_info.rpwm_val);
934 /************************************************************
935 * IO related function
936 ************************************************************/
937 static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr)
939 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
940 struct rtl_priv *rtlpriv = btcoexist->adapter;
942 return rtl_read_byte(rtlpriv, reg_addr);
945 static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr)
947 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
948 struct rtl_priv *rtlpriv = btcoexist->adapter;
950 return rtl_read_word(rtlpriv, reg_addr);
953 static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr)
955 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
956 struct rtl_priv *rtlpriv = btcoexist->adapter;
958 return rtl_read_dword(rtlpriv, reg_addr);
961 static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u32 data)
963 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
964 struct rtl_priv *rtlpriv = btcoexist->adapter;
966 rtl_write_byte(rtlpriv, reg_addr, data);
969 static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr,
970 u32 bit_mask, u8 data)
972 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
973 struct rtl_priv *rtlpriv = btcoexist->adapter;
974 u8 original_value, bit_shift = 0;
977 if (bit_mask != MASKDWORD) {/*if not "double word" write*/
978 original_value = rtl_read_byte(rtlpriv, reg_addr);
979 for (i = 0; i <= 7; i++) {
980 if ((bit_mask>>i) & 0x1)
984 data = (original_value & (~bit_mask)) |
985 ((data << bit_shift) & bit_mask);
987 rtl_write_byte(rtlpriv, reg_addr, data);
990 static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data)
992 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
993 struct rtl_priv *rtlpriv = btcoexist->adapter;
995 rtl_write_word(rtlpriv, reg_addr, data);
998 static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data)
1000 struct btc_coexist *btcoexist =
1001 (struct btc_coexist *)bt_context;
1002 struct rtl_priv *rtlpriv = btcoexist->adapter;
1004 rtl_write_dword(rtlpriv, reg_addr, data);
1007 static void halbtc_write_local_reg_1byte(void *btc_context, u32 reg_addr,
1010 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1011 struct rtl_priv *rtlpriv = btcoexist->adapter;
1013 if (btcoexist->chip_interface == BTC_INTF_SDIO)
1015 else if (btcoexist->chip_interface == BTC_INTF_PCI)
1016 rtl_write_byte(rtlpriv, reg_addr, data);
1017 else if (btcoexist->chip_interface == BTC_INTF_USB)
1018 rtl_write_byte(rtlpriv, reg_addr, data);
1021 static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask,
1024 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1025 struct rtl_priv *rtlpriv = btcoexist->adapter;
1027 rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data);
1030 static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask)
1032 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1033 struct rtl_priv *rtlpriv = btcoexist->adapter;
1035 return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask);
1038 static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
1039 u32 bit_mask, u32 data)
1041 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1042 struct rtl_priv *rtlpriv = btcoexist->adapter;
1044 rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data);
1047 static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
1050 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1051 struct rtl_priv *rtlpriv = btcoexist->adapter;
1053 return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask);
1056 static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id,
1057 u32 cmd_len, u8 *cmd_buf)
1059 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1060 struct rtl_priv *rtlpriv = btcoexist->adapter;
1062 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id,
1066 void halbtc_send_wifi_port_id_cmd(void *bt_context)
1068 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1069 struct rtl_priv *rtlpriv = btcoexist->adapter;
1070 u8 cmd_buf[1] = {0}; /* port id [2:0] = 0 */
1072 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, H2C_BT_PORT_ID,
1076 void halbtc_set_default_port_id_cmd(void *bt_context)
1078 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1079 struct rtl_priv *rtlpriv = btcoexist->adapter;
1080 struct ieee80211_hw *hw = rtlpriv->mac80211.hw;
1082 if (!rtlpriv->cfg->ops->set_default_port_id_cmd)
1085 rtlpriv->cfg->ops->set_default_port_id_cmd(hw);
1089 void halbtc_set_bt_reg(void *btc_context, u8 reg_type, u32 offset, u32 set_val)
1091 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1092 u8 cmd_buffer1[4] = {0};
1093 u8 cmd_buffer2[4] = {0};
1095 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1096 *((__le16 *)&cmd_buffer1[2]) = cpu_to_le16((u16)set_val);
1097 if (!halbtc_send_bt_mp_operation(btcoexist, BT_OP_WRITE_REG_VALUE,
1098 cmd_buffer1, 4, 200))
1101 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1102 cmd_buffer2[2] = reg_type;
1103 *((u8 *)&cmd_buffer2[3]) = (u8)offset;
1104 halbtc_send_bt_mp_operation(btcoexist, BT_OP_WRITE_REG_ADDR,
1105 cmd_buffer2, 4, 200);
1108 static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type,
1111 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1113 switch (disp_type) {
1114 case BTC_DBG_DISP_COEX_STATISTICS:
1115 halbtc_display_coex_statistics(btcoexist, m);
1117 case BTC_DBG_DISP_BT_LINK_INFO:
1118 halbtc_display_bt_link_info(btcoexist, m);
1120 case BTC_DBG_DISP_WIFI_STATUS:
1121 halbtc_display_wifi_status(btcoexist, m);
1128 static u32 halbtc_get_bt_reg(void *btc_context, u8 reg_type, u32 offset)
1133 static bool halbtc_under_ips(struct btc_coexist *btcoexist)
1135 struct rtl_priv *rtlpriv = btcoexist->adapter;
1136 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
1137 enum rf_pwrstate rtstate;
1139 if (ppsc->inactiveps) {
1140 rtstate = ppsc->rfpwr_state;
1142 if (rtstate != ERFON &&
1143 ppsc->rfoff_reason == RF_CHANGE_BY_IPS) {
1152 u32 halbtc_get_phydm_version(void *btc_context)
1158 void halbtc_phydm_modify_ra_pcr_threshold(void *btc_context,
1159 u8 ra_offset_direction,
1160 u8 ra_threshold_offset)
1165 u32 halbtc_phydm_query_phy_counter(void *btc_context, enum dm_info_query dm_id)
1170 static u8 halbtc_get_ant_det_val_from_bt(void *btc_context)
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_ANT_DET_VAL,
1177 cmd_buffer, 4, 200);
1179 /* need wait completion to return correct value */
1181 return btcoexist->bt_info.bt_ant_det_val;
1184 static u8 halbtc_get_ble_scan_type_from_bt(void *btc_context)
1186 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1187 u8 cmd_buffer[4] = {0};
1189 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1190 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_BLE_SCAN_TYPE,
1191 cmd_buffer, 4, 200);
1193 /* need wait completion to return correct value */
1195 return btcoexist->bt_info.bt_ble_scan_type;
1198 static u32 halbtc_get_ble_scan_para_from_bt(void *btc_context, u8 scan_type)
1200 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1201 u8 cmd_buffer[4] = {0};
1203 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1204 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_BLE_SCAN_PARA,
1205 cmd_buffer, 4, 200);
1207 /* need wait completion to return correct value */
1209 return btcoexist->bt_info.bt_ble_scan_para;
1212 static bool halbtc_get_bt_afh_map_from_bt(void *btc_context, u8 map_type,
1215 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1216 u8 cmd_buffer[2] = {0};
1218 u32 *afh_map_l = (u32 *)afh_map;
1219 u32 *afh_map_m = (u32 *)(afh_map + 4);
1220 u16 *afh_map_h = (u16 *)(afh_map + 8);
1222 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1223 ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_L,
1224 cmd_buffer, 2, 200);
1228 *afh_map_l = btcoexist->bt_info.afh_map_l;
1230 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1231 ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_M,
1232 cmd_buffer, 2, 200);
1236 *afh_map_m = btcoexist->bt_info.afh_map_m;
1238 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1239 ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_H,
1240 cmd_buffer, 2, 200);
1244 *afh_map_h = btcoexist->bt_info.afh_map_h;
1250 /*****************************************************************
1251 * Extern functions called by other module
1252 *****************************************************************/
1253 bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv)
1255 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1262 btcoexist->btc_read_1byte = halbtc_read_1byte;
1263 btcoexist->btc_write_1byte = halbtc_write_1byte;
1264 btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte;
1265 btcoexist->btc_read_2byte = halbtc_read_2byte;
1266 btcoexist->btc_write_2byte = halbtc_write_2byte;
1267 btcoexist->btc_read_4byte = halbtc_read_4byte;
1268 btcoexist->btc_write_4byte = halbtc_write_4byte;
1269 btcoexist->btc_write_local_reg_1byte = halbtc_write_local_reg_1byte;
1271 btcoexist->btc_set_bb_reg = halbtc_set_bbreg;
1272 btcoexist->btc_get_bb_reg = halbtc_get_bbreg;
1274 btcoexist->btc_set_rf_reg = halbtc_set_rfreg;
1275 btcoexist->btc_get_rf_reg = halbtc_get_rfreg;
1277 btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd;
1278 btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg;
1280 btcoexist->btc_get = halbtc_get;
1281 btcoexist->btc_set = halbtc_set;
1282 btcoexist->btc_set_bt_reg = halbtc_set_bt_reg;
1283 btcoexist->btc_get_bt_reg = halbtc_get_bt_reg;
1285 btcoexist->bt_info.bt_ctrl_buf_size = false;
1286 btcoexist->bt_info.agg_buf_size = 5;
1288 btcoexist->bt_info.increase_scan_dev_num = false;
1290 btcoexist->btc_get_bt_coex_supported_feature =
1291 halbtc_get_bt_coex_supported_feature;
1292 btcoexist->btc_get_bt_coex_supported_version =
1293 halbtc_get_bt_coex_supported_version;
1294 btcoexist->btc_get_bt_phydm_version = halbtc_get_phydm_version;
1295 btcoexist->btc_phydm_modify_ra_pcr_threshold =
1296 halbtc_phydm_modify_ra_pcr_threshold;
1297 btcoexist->btc_phydm_query_phy_counter = halbtc_phydm_query_phy_counter;
1298 btcoexist->btc_get_ant_det_val_from_bt = halbtc_get_ant_det_val_from_bt;
1299 btcoexist->btc_get_ble_scan_type_from_bt =
1300 halbtc_get_ble_scan_type_from_bt;
1301 btcoexist->btc_get_ble_scan_para_from_bt =
1302 halbtc_get_ble_scan_para_from_bt;
1303 btcoexist->btc_get_bt_afh_map_from_bt =
1304 halbtc_get_bt_afh_map_from_bt;
1306 init_completion(&btcoexist->bt_mp_comp);
1311 bool exhalbtc_initlize_variables_wifi_only(struct rtl_priv *rtlpriv)
1313 struct wifi_only_cfg *wifionly_cfg = rtl_btc_wifi_only(rtlpriv);
1314 struct wifi_only_haldata *wifionly_haldata;
1319 wifionly_cfg->adapter = rtlpriv;
1321 switch (rtlpriv->rtlhal.interface) {
1323 wifionly_cfg->chip_interface = WIFIONLY_INTF_PCI;
1326 wifionly_cfg->chip_interface = WIFIONLY_INTF_USB;
1329 wifionly_cfg->chip_interface = WIFIONLY_INTF_UNKNOWN;
1333 wifionly_haldata = &wifionly_cfg->haldata_info;
1335 wifionly_haldata->customer_id = CUSTOMER_NORMAL;
1336 wifionly_haldata->efuse_pg_antnum = rtl_get_hwpg_ant_num(rtlpriv);
1337 wifionly_haldata->efuse_pg_antpath =
1338 rtl_get_hwpg_single_ant_path(rtlpriv);
1339 wifionly_haldata->rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
1340 wifionly_haldata->ant_div_cfg = 0;
1345 bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
1347 struct rtl_priv *rtlpriv = adapter;
1348 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1349 u8 ant_num = 2, chip_type, single_ant_path = 0;
1354 if (btcoexist->binded)
1357 switch (rtlpriv->rtlhal.interface) {
1359 btcoexist->chip_interface = BTC_INTF_PCI;
1362 btcoexist->chip_interface = BTC_INTF_USB;
1365 btcoexist->chip_interface = BTC_INTF_UNKNOWN;
1369 btcoexist->binded = true;
1370 btcoexist->statistics.cnt_bind++;
1372 btcoexist->adapter = adapter;
1374 btcoexist->stack_info.profile_notified = false;
1376 btcoexist->bt_info.bt_ctrl_agg_buf_size = false;
1377 btcoexist->bt_info.agg_buf_size = 5;
1379 btcoexist->bt_info.increase_scan_dev_num = false;
1380 btcoexist->bt_info.miracast_plus_bt = false;
1382 chip_type = rtl_get_hwpg_bt_type(rtlpriv);
1383 exhalbtc_set_chip_type(btcoexist, chip_type);
1384 ant_num = rtl_get_hwpg_ant_num(rtlpriv);
1385 exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
1387 /* set default antenna position to main port */
1388 btcoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
1390 single_ant_path = rtl_get_hwpg_single_ant_path(rtlpriv);
1391 exhalbtc_set_single_ant_path(btcoexist, single_ant_path);
1393 if (rtl_get_hwpg_package_type(rtlpriv) == 0)
1394 btcoexist->board_info.tfbga_package = false;
1395 else if (rtl_get_hwpg_package_type(rtlpriv) == 1)
1396 btcoexist->board_info.tfbga_package = false;
1398 btcoexist->board_info.tfbga_package = true;
1400 if (btcoexist->board_info.tfbga_package)
1401 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1402 "[BTCoex], Package Type = TFBGA\n");
1404 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1405 "[BTCoex], Package Type = Non-TFBGA\n");
1407 btcoexist->board_info.rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
1408 btcoexist->board_info.ant_div_cfg = 0;
1413 void exhalbtc_power_on_setting(struct btc_coexist *btcoexist)
1415 if (!halbtc_is_bt_coexist_available(btcoexist))
1418 btcoexist->statistics.cnt_power_on++;
1420 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1421 if (btcoexist->board_info.btdm_ant_num == 2)
1422 ex_btc8723b2ant_power_on_setting(btcoexist);
1423 else if (btcoexist->board_info.btdm_ant_num == 1)
1424 ex_btc8723b1ant_power_on_setting(btcoexist);
1428 void exhalbtc_pre_load_firmware(struct btc_coexist *btcoexist)
1430 if (!halbtc_is_bt_coexist_available(btcoexist))
1433 btcoexist->statistics.cnt_pre_load_firmware++;
1435 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1436 if (btcoexist->board_info.btdm_ant_num == 2)
1437 ex_btc8723b2ant_pre_load_firmware(btcoexist);
1441 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only)
1443 if (!halbtc_is_bt_coexist_available(btcoexist))
1446 btcoexist->statistics.cnt_init_hw_config++;
1448 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1449 if (btcoexist->board_info.btdm_ant_num == 2)
1450 ex_btc8821a2ant_init_hwconfig(btcoexist);
1451 else if (btcoexist->board_info.btdm_ant_num == 1)
1452 ex_btc8821a1ant_init_hwconfig(btcoexist, wifi_only);
1453 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1454 if (btcoexist->board_info.btdm_ant_num == 2)
1455 ex_btc8723b2ant_init_hwconfig(btcoexist);
1456 else if (btcoexist->board_info.btdm_ant_num == 1)
1457 ex_btc8723b1ant_init_hwconfig(btcoexist, wifi_only);
1458 } else if (IS_HARDWARE_TYPE_8723A(btcoexist->adapter)) {
1459 /* 8723A has no this function */
1460 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1461 if (btcoexist->board_info.btdm_ant_num == 2)
1462 ex_btc8192e2ant_init_hwconfig(btcoexist);
1466 void exhalbtc_init_hw_config_wifi_only(struct wifi_only_cfg *wifionly_cfg)
1470 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist)
1472 if (!halbtc_is_bt_coexist_available(btcoexist))
1475 btcoexist->statistics.cnt_init_coex_dm++;
1477 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1478 if (btcoexist->board_info.btdm_ant_num == 2)
1479 ex_btc8821a2ant_init_coex_dm(btcoexist);
1480 else if (btcoexist->board_info.btdm_ant_num == 1)
1481 ex_btc8821a1ant_init_coex_dm(btcoexist);
1482 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1483 if (btcoexist->board_info.btdm_ant_num == 2)
1484 ex_btc8723b2ant_init_coex_dm(btcoexist);
1485 else if (btcoexist->board_info.btdm_ant_num == 1)
1486 ex_btc8723b1ant_init_coex_dm(btcoexist);
1487 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1488 if (btcoexist->board_info.btdm_ant_num == 2)
1489 ex_btc8192e2ant_init_coex_dm(btcoexist);
1492 btcoexist->initilized = true;
1495 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type)
1499 if (!halbtc_is_bt_coexist_available(btcoexist))
1501 btcoexist->statistics.cnt_ips_notify++;
1502 if (btcoexist->manual_control)
1506 ips_type = BTC_IPS_ENTER;
1508 ips_type = BTC_IPS_LEAVE;
1510 halbtc_leave_low_power(btcoexist);
1512 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1513 if (btcoexist->board_info.btdm_ant_num == 2)
1514 ex_btc8821a2ant_ips_notify(btcoexist, ips_type);
1515 else if (btcoexist->board_info.btdm_ant_num == 1)
1516 ex_btc8821a1ant_ips_notify(btcoexist, ips_type);
1517 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1518 if (btcoexist->board_info.btdm_ant_num == 2)
1519 ex_btc8723b2ant_ips_notify(btcoexist, ips_type);
1520 else if (btcoexist->board_info.btdm_ant_num == 1)
1521 ex_btc8723b1ant_ips_notify(btcoexist, ips_type);
1522 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1523 if (btcoexist->board_info.btdm_ant_num == 2)
1524 ex_btc8192e2ant_ips_notify(btcoexist, ips_type);
1527 halbtc_normal_low_power(btcoexist);
1530 void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type)
1534 if (!halbtc_is_bt_coexist_available(btcoexist))
1536 btcoexist->statistics.cnt_lps_notify++;
1537 if (btcoexist->manual_control)
1540 if (EACTIVE == type)
1541 lps_type = BTC_LPS_DISABLE;
1543 lps_type = BTC_LPS_ENABLE;
1545 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1546 if (btcoexist->board_info.btdm_ant_num == 2)
1547 ex_btc8821a2ant_lps_notify(btcoexist, lps_type);
1548 else if (btcoexist->board_info.btdm_ant_num == 1)
1549 ex_btc8821a1ant_lps_notify(btcoexist, lps_type);
1550 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1551 if (btcoexist->board_info.btdm_ant_num == 2)
1552 ex_btc8723b2ant_lps_notify(btcoexist, lps_type);
1553 else if (btcoexist->board_info.btdm_ant_num == 1)
1554 ex_btc8723b1ant_lps_notify(btcoexist, lps_type);
1555 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1556 if (btcoexist->board_info.btdm_ant_num == 2)
1557 ex_btc8192e2ant_lps_notify(btcoexist, lps_type);
1561 void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type)
1565 if (!halbtc_is_bt_coexist_available(btcoexist))
1567 btcoexist->statistics.cnt_scan_notify++;
1568 if (btcoexist->manual_control)
1572 scan_type = BTC_SCAN_START;
1574 scan_type = BTC_SCAN_FINISH;
1576 halbtc_leave_low_power(btcoexist);
1578 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1579 if (btcoexist->board_info.btdm_ant_num == 2)
1580 ex_btc8821a2ant_scan_notify(btcoexist, scan_type);
1581 else if (btcoexist->board_info.btdm_ant_num == 1)
1582 ex_btc8821a1ant_scan_notify(btcoexist, scan_type);
1583 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1584 if (btcoexist->board_info.btdm_ant_num == 2)
1585 ex_btc8723b2ant_scan_notify(btcoexist, scan_type);
1586 else if (btcoexist->board_info.btdm_ant_num == 1)
1587 ex_btc8723b1ant_scan_notify(btcoexist, scan_type);
1588 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1589 if (btcoexist->board_info.btdm_ant_num == 2)
1590 ex_btc8192e2ant_scan_notify(btcoexist, scan_type);
1593 halbtc_normal_low_power(btcoexist);
1596 void exhalbtc_scan_notify_wifi_only(struct wifi_only_cfg *wifionly_cfg,
1601 void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action)
1603 u8 asso_type, asso_type_v2;
1606 if (!halbtc_is_bt_coexist_available(btcoexist))
1608 btcoexist->statistics.cnt_connect_notify++;
1609 if (btcoexist->manual_control)
1612 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
1615 asso_type = BTC_ASSOCIATE_START;
1616 asso_type_v2 = wifi_under_5g ? BTC_ASSOCIATE_5G_START :
1617 BTC_ASSOCIATE_START;
1619 asso_type = BTC_ASSOCIATE_FINISH;
1620 asso_type_v2 = wifi_under_5g ? BTC_ASSOCIATE_5G_FINISH :
1621 BTC_ASSOCIATE_FINISH;
1624 halbtc_leave_low_power(btcoexist);
1626 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1627 if (btcoexist->board_info.btdm_ant_num == 2)
1628 ex_btc8821a2ant_connect_notify(btcoexist, asso_type);
1629 else if (btcoexist->board_info.btdm_ant_num == 1)
1630 ex_btc8821a1ant_connect_notify(btcoexist, asso_type);
1631 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1632 if (btcoexist->board_info.btdm_ant_num == 2)
1633 ex_btc8723b2ant_connect_notify(btcoexist, asso_type);
1634 else if (btcoexist->board_info.btdm_ant_num == 1)
1635 ex_btc8723b1ant_connect_notify(btcoexist, asso_type);
1636 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1637 if (btcoexist->board_info.btdm_ant_num == 2)
1638 ex_btc8192e2ant_connect_notify(btcoexist, asso_type);
1641 halbtc_normal_low_power(btcoexist);
1644 void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
1645 enum rt_media_status media_status)
1649 if (!halbtc_is_bt_coexist_available(btcoexist))
1651 btcoexist->statistics.cnt_media_status_notify++;
1652 if (btcoexist->manual_control)
1655 if (RT_MEDIA_CONNECT == media_status)
1656 status = BTC_MEDIA_CONNECT;
1658 status = BTC_MEDIA_DISCONNECT;
1660 halbtc_leave_low_power(btcoexist);
1662 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1663 if (btcoexist->board_info.btdm_ant_num == 2)
1664 ex_btc8821a2ant_media_status_notify(btcoexist, status);
1665 else if (btcoexist->board_info.btdm_ant_num == 1)
1666 ex_btc8821a1ant_media_status_notify(btcoexist, status);
1667 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1668 if (btcoexist->board_info.btdm_ant_num == 2)
1669 ex_btc8723b2ant_media_status_notify(btcoexist, status);
1670 else if (btcoexist->board_info.btdm_ant_num == 1)
1671 ex_btc8723b1ant_media_status_notify(btcoexist, status);
1672 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1673 if (btcoexist->board_info.btdm_ant_num == 2)
1674 ex_btc8192e2ant_media_status_notify(btcoexist, status);
1677 halbtc_normal_low_power(btcoexist);
1680 void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type)
1684 if (!halbtc_is_bt_coexist_available(btcoexist))
1686 btcoexist->statistics.cnt_special_packet_notify++;
1687 if (btcoexist->manual_control)
1690 if (pkt_type == PACKET_DHCP) {
1691 packet_type = BTC_PACKET_DHCP;
1692 } else if (pkt_type == PACKET_EAPOL) {
1693 packet_type = BTC_PACKET_EAPOL;
1694 } else if (pkt_type == PACKET_ARP) {
1695 packet_type = BTC_PACKET_ARP;
1697 packet_type = BTC_PACKET_UNKNOWN;
1701 halbtc_leave_low_power(btcoexist);
1703 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1704 if (btcoexist->board_info.btdm_ant_num == 2)
1705 ex_btc8821a2ant_special_packet_notify(btcoexist,
1707 else if (btcoexist->board_info.btdm_ant_num == 1)
1708 ex_btc8821a1ant_special_packet_notify(btcoexist,
1710 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1711 if (btcoexist->board_info.btdm_ant_num == 2)
1712 ex_btc8723b2ant_special_packet_notify(btcoexist,
1714 else if (btcoexist->board_info.btdm_ant_num == 1)
1715 ex_btc8723b1ant_special_packet_notify(btcoexist,
1717 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1718 if (btcoexist->board_info.btdm_ant_num == 2)
1719 ex_btc8192e2ant_special_packet_notify(btcoexist,
1723 halbtc_normal_low_power(btcoexist);
1726 void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist,
1727 u8 *tmp_buf, u8 length)
1729 if (!halbtc_is_bt_coexist_available(btcoexist))
1731 btcoexist->statistics.cnt_bt_info_notify++;
1733 halbtc_leave_low_power(btcoexist);
1735 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1736 if (btcoexist->board_info.btdm_ant_num == 2)
1737 ex_btc8821a2ant_bt_info_notify(btcoexist, tmp_buf,
1739 else if (btcoexist->board_info.btdm_ant_num == 1)
1740 ex_btc8821a1ant_bt_info_notify(btcoexist, tmp_buf,
1742 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1743 if (btcoexist->board_info.btdm_ant_num == 2)
1744 ex_btc8723b2ant_bt_info_notify(btcoexist, tmp_buf,
1746 else if (btcoexist->board_info.btdm_ant_num == 1)
1747 ex_btc8723b1ant_bt_info_notify(btcoexist, tmp_buf,
1749 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1750 if (btcoexist->board_info.btdm_ant_num == 2)
1751 ex_btc8192e2ant_bt_info_notify(btcoexist, tmp_buf,
1755 halbtc_normal_low_power(btcoexist);
1758 void exhalbtc_rf_status_notify(struct btc_coexist *btcoexist, u8 type)
1760 if (!halbtc_is_bt_coexist_available(btcoexist))
1763 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1764 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1765 if (btcoexist->board_info.btdm_ant_num == 1)
1766 ex_btc8723b1ant_rf_status_notify(btcoexist, type);
1767 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1771 void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type)
1775 if (!halbtc_is_bt_coexist_available(btcoexist))
1777 btcoexist->statistics.cnt_stack_operation_notify++;
1778 if (btcoexist->manual_control)
1781 if ((type == HCI_BT_OP_INQUIRY_START) ||
1782 (type == HCI_BT_OP_PAGING_START) ||
1783 (type == HCI_BT_OP_PAIRING_START)) {
1784 stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_START;
1785 } else if ((type == HCI_BT_OP_INQUIRY_FINISH) ||
1786 (type == HCI_BT_OP_PAGING_SUCCESS) ||
1787 (type == HCI_BT_OP_PAGING_UNSUCCESS) ||
1788 (type == HCI_BT_OP_PAIRING_FINISH)) {
1789 stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
1791 stack_op_type = BTC_STACK_OP_NONE;
1795 void exhalbtc_halt_notify(struct btc_coexist *btcoexist)
1797 if (!halbtc_is_bt_coexist_available(btcoexist))
1800 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1801 if (btcoexist->board_info.btdm_ant_num == 2)
1802 ex_btc8821a2ant_halt_notify(btcoexist);
1803 else if (btcoexist->board_info.btdm_ant_num == 1)
1804 ex_btc8821a1ant_halt_notify(btcoexist);
1805 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1806 if (btcoexist->board_info.btdm_ant_num == 2)
1807 ex_btc8723b2ant_halt_notify(btcoexist);
1808 else if (btcoexist->board_info.btdm_ant_num == 1)
1809 ex_btc8723b1ant_halt_notify(btcoexist);
1810 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1811 if (btcoexist->board_info.btdm_ant_num == 2)
1812 ex_btc8192e2ant_halt_notify(btcoexist);
1815 btcoexist->binded = false;
1818 void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
1820 if (!halbtc_is_bt_coexist_available(btcoexist))
1823 /* currently only 1ant we have to do the notification,
1824 * once pnp is notified to sleep state, we have to leave LPS that
1825 * we can sleep normally.
1828 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1829 if (btcoexist->board_info.btdm_ant_num == 1)
1830 ex_btc8723b1ant_pnp_notify(btcoexist, pnp_state);
1831 else if (btcoexist->board_info.btdm_ant_num == 2)
1832 ex_btc8723b2ant_pnp_notify(btcoexist, pnp_state);
1833 } else if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1834 if (btcoexist->board_info.btdm_ant_num == 1)
1835 ex_btc8821a1ant_pnp_notify(btcoexist, pnp_state);
1836 else if (btcoexist->board_info.btdm_ant_num == 2)
1837 ex_btc8821a2ant_pnp_notify(btcoexist, pnp_state);
1838 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1842 void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist)
1844 struct rtl_priv *rtlpriv = btcoexist->adapter;
1846 if (!halbtc_is_bt_coexist_available(btcoexist))
1848 btcoexist->statistics.cnt_coex_dm_switch++;
1850 halbtc_leave_low_power(btcoexist);
1852 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1853 if (btcoexist->board_info.btdm_ant_num == 1) {
1854 btcoexist->stop_coex_dm = true;
1855 ex_btc8723b1ant_coex_dm_reset(btcoexist);
1856 exhalbtc_set_ant_num(rtlpriv,
1857 BT_COEX_ANT_TYPE_DETECTED, 2);
1858 ex_btc8723b2ant_init_hwconfig(btcoexist);
1859 ex_btc8723b2ant_init_coex_dm(btcoexist);
1860 btcoexist->stop_coex_dm = false;
1864 halbtc_normal_low_power(btcoexist);
1867 void exhalbtc_periodical(struct btc_coexist *btcoexist)
1869 if (!halbtc_is_bt_coexist_available(btcoexist))
1871 btcoexist->statistics.cnt_periodical++;
1873 halbtc_leave_low_power(btcoexist);
1875 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1876 if (btcoexist->board_info.btdm_ant_num == 2)
1877 ex_btc8821a2ant_periodical(btcoexist);
1878 else if (btcoexist->board_info.btdm_ant_num == 1)
1879 if (!halbtc_under_ips(btcoexist))
1880 ex_btc8821a1ant_periodical(btcoexist);
1881 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1882 if (btcoexist->board_info.btdm_ant_num == 2)
1883 ex_btc8723b2ant_periodical(btcoexist);
1884 else if (btcoexist->board_info.btdm_ant_num == 1)
1885 ex_btc8723b1ant_periodical(btcoexist);
1886 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1887 if (btcoexist->board_info.btdm_ant_num == 2)
1888 ex_btc8192e2ant_periodical(btcoexist);
1891 halbtc_normal_low_power(btcoexist);
1894 void exhalbtc_dbg_control(struct btc_coexist *btcoexist,
1895 u8 code, u8 len, u8 *data)
1897 if (!halbtc_is_bt_coexist_available(btcoexist))
1899 btcoexist->statistics.cnt_dbg_ctrl++;
1901 halbtc_leave_low_power(btcoexist);
1903 halbtc_normal_low_power(btcoexist);
1906 void exhalbtc_antenna_detection(struct btc_coexist *btcoexist, u32 cent_freq,
1907 u32 offset, u32 span, u32 seconds)
1909 if (!halbtc_is_bt_coexist_available(btcoexist))
1913 void exhalbtc_stack_update_profile_info(void)
1917 void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi)
1919 if (!halbtc_is_bt_coexist_available(btcoexist))
1922 btcoexist->stack_info.min_bt_rssi = bt_rssi;
1925 void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version)
1927 if (!halbtc_is_bt_coexist_available(btcoexist))
1930 btcoexist->stack_info.hci_version = hci_version;
1933 void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
1934 u16 bt_hci_version, u16 bt_patch_version)
1936 if (!halbtc_is_bt_coexist_available(btcoexist))
1939 btcoexist->bt_info.bt_real_fw_ver = bt_patch_version;
1940 btcoexist->bt_info.bt_hci_ver = bt_hci_version;
1943 void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type)
1945 switch (chip_type) {
1951 btcoexist->board_info.bt_chip_type = BTC_CHIP_UNDEF;
1954 btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
1957 btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
1960 btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723A;
1963 btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8821;
1966 btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723B;
1971 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
1973 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1978 if (BT_COEX_ANT_TYPE_PG == type) {
1979 btcoexist->board_info.pg_ant_num = ant_num;
1980 btcoexist->board_info.btdm_ant_num = ant_num;
1981 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1982 btcoexist->board_info.btdm_ant_num = ant_num;
1983 } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
1984 btcoexist->board_info.btdm_ant_num = ant_num;
1985 if (rtlpriv->cfg->mod_params->ant_sel == 1)
1986 btcoexist->board_info.btdm_ant_pos =
1987 BTC_ANTENNA_AT_AUX_PORT;
1989 btcoexist->board_info.btdm_ant_pos =
1990 BTC_ANTENNA_AT_MAIN_PORT;
1994 /* Currently used by 8723b only, S0 or S1 */
1995 void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
1998 btcoexist->board_info.single_ant_path = single_ant_path;
2001 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
2004 if (!halbtc_is_bt_coexist_available(btcoexist))
2007 halbtc_leave_low_power(btcoexist);
2009 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
2010 if (btcoexist->board_info.btdm_ant_num == 2)
2011 ex_btc8821a2ant_display_coex_info(btcoexist, m);
2012 else if (btcoexist->board_info.btdm_ant_num == 1)
2013 ex_btc8821a1ant_display_coex_info(btcoexist, m);
2014 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
2015 if (btcoexist->board_info.btdm_ant_num == 2)
2016 ex_btc8723b2ant_display_coex_info(btcoexist, m);
2017 else if (btcoexist->board_info.btdm_ant_num == 1)
2018 ex_btc8723b1ant_display_coex_info(btcoexist, m);
2019 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
2020 if (btcoexist->board_info.btdm_ant_num == 2)
2021 ex_btc8192e2ant_display_coex_info(btcoexist, m);
2024 halbtc_normal_low_power(btcoexist);
2027 void exhalbtc_switch_band_notify(struct btc_coexist *btcoexist, u8 type)
2029 if (!halbtc_is_bt_coexist_available(btcoexist))
2032 if (btcoexist->manual_control)
2035 halbtc_leave_low_power(btcoexist);
2037 halbtc_normal_low_power(btcoexist);
2040 void exhalbtc_switch_band_notify_wifi_only(struct wifi_only_cfg *wifionly_cfg,