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 struct rtl_ps_ctl *ppsc;
296 bool ap_enable = false;
298 rtlpriv = btcoexist->adapter;
299 ppsc = rtl_psc(rtlpriv);
301 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
305 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
306 "%s()<--dont leave lps under AP mode\n", __func__);
310 btcoexist->bt_info.bt_ctrl_lps = true;
311 btcoexist->bt_info.bt_lps_on = false;
312 rtl_lps_leave(rtlpriv->mac80211.hw);
315 static void halbtc_enter_lps(struct btc_coexist *btcoexist)
317 struct rtl_priv *rtlpriv;
318 struct rtl_ps_ctl *ppsc;
319 bool ap_enable = false;
321 rtlpriv = btcoexist->adapter;
322 ppsc = rtl_psc(rtlpriv);
324 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
328 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
329 "%s()<--dont enter lps under AP mode\n", __func__);
333 btcoexist->bt_info.bt_ctrl_lps = true;
334 btcoexist->bt_info.bt_lps_on = true;
335 rtl_lps_enter(rtlpriv->mac80211.hw);
338 static void halbtc_normal_lps(struct btc_coexist *btcoexist)
340 struct rtl_priv *rtlpriv;
342 rtlpriv = btcoexist->adapter;
344 if (btcoexist->bt_info.bt_ctrl_lps) {
345 btcoexist->bt_info.bt_lps_on = false;
346 rtl_lps_leave(rtlpriv->mac80211.hw);
347 btcoexist->bt_info.bt_ctrl_lps = false;
351 static void halbtc_pre_normal_lps(struct btc_coexist *btcoexist)
353 struct rtl_priv *rtlpriv = btcoexist->adapter;
355 if (btcoexist->bt_info.bt_ctrl_lps) {
356 btcoexist->bt_info.bt_lps_on = false;
357 rtl_lps_leave(rtlpriv->mac80211.hw);
361 static void halbtc_post_normal_lps(struct btc_coexist *btcoexist)
363 if (btcoexist->bt_info.bt_ctrl_lps)
364 btcoexist->bt_info.bt_ctrl_lps = false;
367 static void halbtc_leave_low_power(struct btc_coexist *btcoexist)
371 static void halbtc_normal_low_power(struct btc_coexist *btcoexist)
375 static void halbtc_disable_low_power(struct btc_coexist *btcoexist,
376 bool low_pwr_disable)
378 /* TODO: original/leave 32k low power */
379 btcoexist->bt_info.bt_disable_low_pwr = low_pwr_disable;
382 static void halbtc_aggregation_check(struct btc_coexist *btcoexist)
384 bool need_to_act = false;
385 static unsigned long pre_time;
386 unsigned long cur_time = 0;
387 struct rtl_priv *rtlpriv = btcoexist->adapter;
389 /* To void continuous deleteBA=>addBA=>deleteBA=>addBA
390 * This function is not allowed to continuous called
391 * It can only be called after 8 seconds
395 if (jiffies_to_msecs(cur_time - pre_time) <= 8000) {
396 /* over 8 seconds you can execute this function again. */
401 if (btcoexist->bt_info.reject_agg_pkt) {
403 btcoexist->bt_info.pre_reject_agg_pkt =
404 btcoexist->bt_info.reject_agg_pkt;
406 if (btcoexist->bt_info.pre_reject_agg_pkt) {
408 btcoexist->bt_info.pre_reject_agg_pkt =
409 btcoexist->bt_info.reject_agg_pkt;
412 if (btcoexist->bt_info.pre_bt_ctrl_agg_buf_size !=
413 btcoexist->bt_info.bt_ctrl_agg_buf_size) {
415 btcoexist->bt_info.pre_bt_ctrl_agg_buf_size =
416 btcoexist->bt_info.bt_ctrl_agg_buf_size;
419 if (btcoexist->bt_info.bt_ctrl_agg_buf_size) {
420 if (btcoexist->bt_info.pre_agg_buf_size !=
421 btcoexist->bt_info.agg_buf_size) {
424 btcoexist->bt_info.pre_agg_buf_size =
425 btcoexist->bt_info.agg_buf_size;
429 rtl_rx_ampdu_apply(rtlpriv);
433 static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
435 u8 cmd_buffer[4] = {0};
437 if (btcoexist->bt_info.bt_real_fw_ver)
440 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
441 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_VERSION,
445 return btcoexist->bt_info.bt_real_fw_ver;
448 static u32 halbtc_get_bt_coex_supported_feature(void *btc_context)
450 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
451 u8 cmd_buffer[4] = {0};
453 if (btcoexist->bt_info.bt_supported_feature)
456 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
457 halbtc_send_bt_mp_operation(btcoexist,
458 BT_OP_GET_BT_COEX_SUPPORTED_FEATURE,
462 return btcoexist->bt_info.bt_supported_feature;
465 static u32 halbtc_get_bt_coex_supported_version(void *btc_context)
467 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
468 u8 cmd_buffer[4] = {0};
470 if (btcoexist->bt_info.bt_supported_version)
473 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
474 halbtc_send_bt_mp_operation(btcoexist,
475 BT_OP_GET_BT_COEX_SUPPORTED_VERSION,
479 return btcoexist->bt_info.bt_supported_version;
482 static u32 halbtc_get_bt_device_info(void *btc_context)
484 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
485 u8 cmd_buffer[4] = {0};
487 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
488 halbtc_send_bt_mp_operation(btcoexist,
489 BT_OP_GET_BT_DEVICE_INFO,
492 return btcoexist->bt_info.bt_device_info;
495 static u32 halbtc_get_bt_forbidden_slot_val(void *btc_context)
497 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
498 u8 cmd_buffer[4] = {0};
500 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
501 halbtc_send_bt_mp_operation(btcoexist,
502 BT_OP_GET_BT_FORBIDDEN_SLOT_VAL,
505 return btcoexist->bt_info.bt_forb_slot_val;
508 static u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist)
511 * [31:16] => connected port number
512 * [15:0] => port connected bit define
514 struct rtl_priv *rtlpriv = btcoexist->adapter;
515 struct rtl_mac *mac = rtl_mac(rtlpriv);
517 u32 port_connected_status = 0, num_of_connected_port = 0;
519 if (mac->opmode == NL80211_IFTYPE_STATION &&
520 mac->link_state >= MAC80211_LINKED) {
521 port_connected_status |= WIFI_STA_CONNECTED;
522 num_of_connected_port++;
524 /* AP & ADHOC & MESH */
525 if (is_any_client_connect_to_ap(btcoexist)) {
526 port_connected_status |= WIFI_AP_CONNECTED;
527 num_of_connected_port++;
529 /* TODO: P2P Connected Status */
531 ret_val = (num_of_connected_port << 16) | port_connected_status;
536 static s32 halbtc_get_wifi_rssi(struct rtl_priv *rtlpriv)
538 int undec_sm_pwdb = 0;
540 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
541 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
542 else /* associated entry pwdb */
543 undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
544 return undec_sm_pwdb;
547 static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
549 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
550 struct rtl_priv *rtlpriv = btcoexist->adapter;
551 struct rtl_phy *rtlphy = &(rtlpriv->phy);
552 struct rtl_mac *mac = rtl_mac(rtlpriv);
553 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
554 bool *bool_tmp = (bool *)out_buf;
555 int *s32_tmp = (int *)out_buf;
556 u32 *u32_tmp = (u32 *)out_buf;
557 u8 *u8_tmp = (u8 *)out_buf;
561 if (!halbtc_is_bt_coexist_available(btcoexist))
565 case BTC_GET_BL_HS_OPERATION:
569 case BTC_GET_BL_HS_CONNECTING:
573 case BTC_GET_BL_WIFI_CONNECTED:
574 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_STATION &&
575 rtlpriv->mac80211.link_state >= MAC80211_LINKED)
577 if (is_any_client_connect_to_ap(btcoexist))
581 case BTC_GET_BL_WIFI_DUAL_BAND_CONNECTED:
582 *u8_tmp = BTC_MULTIPORT_SCC;
584 case BTC_GET_BL_WIFI_BUSY:
585 if (halbtc_is_wifi_busy(rtlpriv))
590 case BTC_GET_BL_WIFI_SCAN:
591 if (mac->act_scanning)
596 case BTC_GET_BL_WIFI_LINK:
597 if (mac->link_state == MAC80211_LINKING)
602 case BTC_GET_BL_WIFI_ROAM:
603 if (mac->link_state == MAC80211_LINKING)
608 case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
609 *bool_tmp = rtlpriv->btcoexist.btc_info.in_4way;
611 case BTC_GET_BL_WIFI_UNDER_5G:
612 if (rtlhal->current_bandtype == BAND_ON_5G)
617 case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
618 if (mac->opmode == NL80211_IFTYPE_AP)
623 case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
624 if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm)
629 case BTC_GET_BL_WIFI_UNDER_B_MODE:
630 if (rtlpriv->mac80211.mode == WIRELESS_MODE_B)
635 case BTC_GET_BL_EXT_SWITCH:
638 case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
641 case BTC_GET_BL_IS_ASUS_8723B:
644 case BTC_GET_BL_RF4CE_CONNECTED:
647 case BTC_GET_S4_WIFI_RSSI:
648 *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
650 case BTC_GET_S4_HS_RSSI:
654 case BTC_GET_U4_WIFI_BW:
655 *u32_tmp = halbtc_get_wifi_bw(btcoexist);
657 case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
658 if (halbtc_is_wifi_uplink(rtlpriv))
659 *u32_tmp = BTC_WIFI_TRAFFIC_TX;
661 *u32_tmp = BTC_WIFI_TRAFFIC_RX;
663 case BTC_GET_U4_WIFI_FW_VER:
664 *u32_tmp = (rtlhal->fw_version << 16) | rtlhal->fw_subversion;
666 case BTC_GET_U4_WIFI_LINK_STATUS:
667 *u32_tmp = halbtc_get_wifi_link_status(btcoexist);
669 case BTC_GET_U4_BT_PATCH_VER:
670 *u32_tmp = halbtc_get_bt_patch_version(btcoexist);
672 case BTC_GET_U4_VENDOR:
673 *u32_tmp = BTC_VENDOR_OTHER;
675 case BTC_GET_U4_SUPPORTED_VERSION:
676 *u32_tmp = halbtc_get_bt_coex_supported_version(btcoexist);
678 case BTC_GET_U4_SUPPORTED_FEATURE:
679 *u32_tmp = halbtc_get_bt_coex_supported_feature(btcoexist);
681 case BTC_GET_U4_BT_DEVICE_INFO:
682 *u32_tmp = halbtc_get_bt_device_info(btcoexist);
684 case BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL:
685 *u32_tmp = halbtc_get_bt_forbidden_slot_val(btcoexist);
687 case BTC_GET_U4_WIFI_IQK_TOTAL:
689 btcoexist->btc_phydm_query_phy_counter(btcoexist,
692 case BTC_GET_U4_WIFI_IQK_OK:
694 btcoexist->btc_phydm_query_phy_counter(btcoexist,
697 case BTC_GET_U4_WIFI_IQK_FAIL:
699 btcoexist->btc_phydm_query_phy_counter(btcoexist,
702 case BTC_GET_U1_WIFI_DOT11_CHNL:
703 *u8_tmp = rtlphy->current_channel;
705 case BTC_GET_U1_WIFI_CENTRAL_CHNL:
706 *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist);
708 case BTC_GET_U1_WIFI_HS_CHNL:
712 case BTC_GET_U1_AP_NUM:
713 *u8_tmp = rtlpriv->btcoexist.btc_info.ap_num;
715 case BTC_GET_U1_ANT_TYPE:
716 *u8_tmp = (u8)BTC_ANT_TYPE_0;
718 case BTC_GET_U1_IOT_PEER:
722 /************* 1Ant **************/
723 case BTC_GET_U1_LPS_MODE:
724 *u8_tmp = btcoexist->pwr_mode_val[0];
735 static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf)
737 struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
738 bool *bool_tmp = (bool *)in_buf;
739 u8 *u8_tmp = (u8 *)in_buf;
740 u32 *u32_tmp = (u32 *)in_buf;
743 if (!halbtc_is_bt_coexist_available(btcoexist))
747 /* set some bool type variables. */
748 case BTC_SET_BL_BT_DISABLE:
749 btcoexist->bt_info.bt_disabled = *bool_tmp;
751 case BTC_SET_BL_BT_TRAFFIC_BUSY:
752 btcoexist->bt_info.bt_busy = *bool_tmp;
754 case BTC_SET_BL_BT_LIMITED_DIG:
755 btcoexist->bt_info.limited_dig = *bool_tmp;
757 case BTC_SET_BL_FORCE_TO_ROAM:
758 btcoexist->bt_info.force_to_roam = *bool_tmp;
760 case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
761 btcoexist->bt_info.reject_agg_pkt = *bool_tmp;
763 case BTC_SET_BL_BT_CTRL_AGG_SIZE:
764 btcoexist->bt_info.bt_ctrl_agg_buf_size = *bool_tmp;
766 case BTC_SET_BL_INC_SCAN_DEV_NUM:
767 btcoexist->bt_info.increase_scan_dev_num = *bool_tmp;
769 case BTC_SET_BL_BT_TX_RX_MASK:
770 btcoexist->bt_info.bt_tx_rx_mask = *bool_tmp;
772 case BTC_SET_BL_MIRACAST_PLUS_BT:
773 btcoexist->bt_info.miracast_plus_bt = *bool_tmp;
775 /* set some u1Byte type variables. */
776 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
777 btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp;
779 case BTC_SET_U1_AGG_BUF_SIZE:
780 btcoexist->bt_info.agg_buf_size = *u8_tmp;
783 /* the following are some action which will be triggered */
784 case BTC_SET_ACT_GET_BT_RSSI:
787 case BTC_SET_ACT_AGGREGATE_CTRL:
788 halbtc_aggregation_check(btcoexist);
792 case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
793 btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp;
795 case BTC_SET_UI_SCAN_SIG_COMPENSATION:
797 case BTC_SET_U1_LPS_VAL:
798 btcoexist->bt_info.lps_val = *u8_tmp;
800 case BTC_SET_U1_RPWM_VAL:
801 btcoexist->bt_info.rpwm_val = *u8_tmp;
803 /* the following are some action which will be triggered */
804 case BTC_SET_ACT_LEAVE_LPS:
805 halbtc_leave_lps(btcoexist);
807 case BTC_SET_ACT_ENTER_LPS:
808 halbtc_enter_lps(btcoexist);
810 case BTC_SET_ACT_NORMAL_LPS:
811 halbtc_normal_lps(btcoexist);
813 case BTC_SET_ACT_PRE_NORMAL_LPS:
814 halbtc_pre_normal_lps(btcoexist);
816 case BTC_SET_ACT_POST_NORMAL_LPS:
817 halbtc_post_normal_lps(btcoexist);
819 case BTC_SET_ACT_DISABLE_LOW_POWER:
820 halbtc_disable_low_power(btcoexist, *bool_tmp);
822 case BTC_SET_ACT_UPDATE_RAMASK:
823 btcoexist->bt_info.ra_mask = *u32_tmp;
825 case BTC_SET_ACT_SEND_MIMO_PS:
827 case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/
829 case BTC_SET_ACT_CTRL_BT_COEX:
831 case BTC_SET_ACT_CTRL_8723B_ANT:
840 static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist,
845 static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist,
850 static void halbtc_display_wifi_status(struct btc_coexist *btcoexist,
853 struct rtl_priv *rtlpriv = btcoexist->adapter;
854 s32 wifi_rssi = 0, bt_hs_rssi = 0;
855 bool scan = false, link = false, roam = false, wifi_busy = false;
856 bool wifi_under_b_mode = false;
857 bool wifi_under_5g = false;
858 u32 wifi_bw = BTC_WIFI_BW_HT20;
859 u32 wifi_traffic_dir = BTC_WIFI_TRAFFIC_TX;
860 u32 wifi_freq = BTC_FREQ_2_4G;
861 u32 wifi_link_status = 0x0;
862 bool bt_hs_on = false, under_ips = false, under_lps = false;
863 bool low_power = false, dc_mode = false;
864 u8 wifi_chnl = 0, wifi_hs_chnl = 0;
867 wifi_link_status = halbtc_get_wifi_link_status(btcoexist);
868 seq_printf(m, "\n %-35s = %d/ %d/ %d/ %d/ %d",
869 "STA/vWifi/HS/p2pGo/p2pGc",
870 ((wifi_link_status & WIFI_STA_CONNECTED) ? 1 : 0),
871 ((wifi_link_status & WIFI_AP_CONNECTED) ? 1 : 0),
872 ((wifi_link_status & WIFI_HS_CONNECTED) ? 1 : 0),
873 ((wifi_link_status & WIFI_P2P_GO_CONNECTED) ? 1 : 0),
874 ((wifi_link_status & WIFI_P2P_GC_CONNECTED) ? 1 : 0));
876 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
877 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifi_chnl);
878 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl);
879 seq_printf(m, "\n %-35s = %d / %d(%d)",
880 "Dot11 channel / HsChnl(High Speed)",
881 wifi_chnl, wifi_hs_chnl, bt_hs_on);
883 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
884 btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
885 seq_printf(m, "\n %-35s = %d/ %d",
886 "Wifi rssi/ HS rssi",
887 wifi_rssi - 100, bt_hs_rssi - 100);
889 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
890 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
891 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
892 seq_printf(m, "\n %-35s = %d/ %d/ %d ",
893 "Wifi link/ roam/ scan",
896 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
897 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
898 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
899 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
901 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
902 wifi_freq = (wifi_under_5g ? BTC_FREQ_5G : BTC_FREQ_2_4G);
903 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE,
906 seq_printf(m, "\n %-35s = %s / %s/ %s/ AP=%d ",
907 "Wifi freq/ bw/ traffic",
908 gl_btc_wifi_freq_string[wifi_freq],
909 ((wifi_under_b_mode) ? "11b" :
910 gl_btc_wifi_bw_string[wifi_bw]),
911 ((!wifi_busy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX ==
912 wifi_traffic_dir) ? "uplink" :
917 dc_mode = true; /*TODO*/
918 under_ips = rtlpriv->psc.inactive_pwrstate == ERFOFF ? 1 : 0;
919 under_lps = rtlpriv->psc.dot11_psmode == EACTIVE ? 0 : 1;
920 low_power = 0; /*TODO*/
921 seq_printf(m, "\n %-35s = %s%s%s%s",
923 (dc_mode ? "DC mode" : "AC mode"),
924 (under_ips ? ", IPS ON" : ""),
925 (under_lps ? ", LPS ON" : ""),
926 (low_power ? ", 32k" : ""));
929 "\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)",
930 "Power mode cmd(lps/rpwm)",
931 btcoexist->pwr_mode_val[0], btcoexist->pwr_mode_val[1],
932 btcoexist->pwr_mode_val[2], btcoexist->pwr_mode_val[3],
933 btcoexist->pwr_mode_val[4], btcoexist->pwr_mode_val[5],
934 btcoexist->bt_info.lps_val,
935 btcoexist->bt_info.rpwm_val);
938 /************************************************************
939 * IO related function
940 ************************************************************/
941 static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr)
943 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
944 struct rtl_priv *rtlpriv = btcoexist->adapter;
946 return rtl_read_byte(rtlpriv, reg_addr);
949 static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr)
951 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
952 struct rtl_priv *rtlpriv = btcoexist->adapter;
954 return rtl_read_word(rtlpriv, reg_addr);
957 static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr)
959 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
960 struct rtl_priv *rtlpriv = btcoexist->adapter;
962 return rtl_read_dword(rtlpriv, reg_addr);
965 static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u32 data)
967 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
968 struct rtl_priv *rtlpriv = btcoexist->adapter;
970 rtl_write_byte(rtlpriv, reg_addr, data);
973 static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr,
974 u32 bit_mask, u8 data)
976 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
977 struct rtl_priv *rtlpriv = btcoexist->adapter;
978 u8 original_value, bit_shift = 0;
981 if (bit_mask != MASKDWORD) {/*if not "double word" write*/
982 original_value = rtl_read_byte(rtlpriv, reg_addr);
983 for (i = 0; i <= 7; i++) {
984 if ((bit_mask>>i) & 0x1)
988 data = (original_value & (~bit_mask)) |
989 ((data << bit_shift) & bit_mask);
991 rtl_write_byte(rtlpriv, reg_addr, data);
994 static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data)
996 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
997 struct rtl_priv *rtlpriv = btcoexist->adapter;
999 rtl_write_word(rtlpriv, reg_addr, data);
1002 static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data)
1004 struct btc_coexist *btcoexist =
1005 (struct btc_coexist *)bt_context;
1006 struct rtl_priv *rtlpriv = btcoexist->adapter;
1008 rtl_write_dword(rtlpriv, reg_addr, data);
1011 static void halbtc_write_local_reg_1byte(void *btc_context, u32 reg_addr,
1014 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1015 struct rtl_priv *rtlpriv = btcoexist->adapter;
1017 if (btcoexist->chip_interface == BTC_INTF_SDIO)
1019 else if (btcoexist->chip_interface == BTC_INTF_PCI)
1020 rtl_write_byte(rtlpriv, reg_addr, data);
1021 else if (btcoexist->chip_interface == BTC_INTF_USB)
1022 rtl_write_byte(rtlpriv, reg_addr, data);
1025 static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask,
1028 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1029 struct rtl_priv *rtlpriv = btcoexist->adapter;
1031 rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data);
1034 static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask)
1036 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1037 struct rtl_priv *rtlpriv = btcoexist->adapter;
1039 return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask);
1042 static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
1043 u32 bit_mask, u32 data)
1045 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1046 struct rtl_priv *rtlpriv = btcoexist->adapter;
1048 rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data);
1051 static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
1054 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1055 struct rtl_priv *rtlpriv = btcoexist->adapter;
1057 return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask);
1060 static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id,
1061 u32 cmd_len, u8 *cmd_buf)
1063 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1064 struct rtl_priv *rtlpriv = btcoexist->adapter;
1066 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id,
1070 void halbtc_send_wifi_port_id_cmd(void *bt_context)
1072 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1073 struct rtl_priv *rtlpriv = btcoexist->adapter;
1074 u8 cmd_buf[1] = {0}; /* port id [2:0] = 0 */
1076 rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, H2C_BT_PORT_ID,
1080 void halbtc_set_default_port_id_cmd(void *bt_context)
1082 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1083 struct rtl_priv *rtlpriv = btcoexist->adapter;
1084 struct ieee80211_hw *hw = rtlpriv->mac80211.hw;
1086 if (!rtlpriv->cfg->ops->set_default_port_id_cmd)
1089 rtlpriv->cfg->ops->set_default_port_id_cmd(hw);
1093 void halbtc_set_bt_reg(void *btc_context, u8 reg_type, u32 offset, u32 set_val)
1095 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1096 u8 cmd_buffer1[4] = {0};
1097 u8 cmd_buffer2[4] = {0};
1099 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1100 *((__le16 *)&cmd_buffer1[2]) = cpu_to_le16((u16)set_val);
1101 if (!halbtc_send_bt_mp_operation(btcoexist, BT_OP_WRITE_REG_VALUE,
1102 cmd_buffer1, 4, 200))
1105 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1106 cmd_buffer2[2] = reg_type;
1107 *((u8 *)&cmd_buffer2[3]) = (u8)offset;
1108 halbtc_send_bt_mp_operation(btcoexist, BT_OP_WRITE_REG_ADDR,
1109 cmd_buffer2, 4, 200);
1112 static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type,
1115 struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
1117 switch (disp_type) {
1118 case BTC_DBG_DISP_COEX_STATISTICS:
1119 halbtc_display_coex_statistics(btcoexist, m);
1121 case BTC_DBG_DISP_BT_LINK_INFO:
1122 halbtc_display_bt_link_info(btcoexist, m);
1124 case BTC_DBG_DISP_WIFI_STATUS:
1125 halbtc_display_wifi_status(btcoexist, m);
1132 static u32 halbtc_get_bt_reg(void *btc_context, u8 reg_type, u32 offset)
1137 static bool halbtc_under_ips(struct btc_coexist *btcoexist)
1139 struct rtl_priv *rtlpriv = btcoexist->adapter;
1140 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
1141 enum rf_pwrstate rtstate;
1143 if (ppsc->inactiveps) {
1144 rtstate = ppsc->rfpwr_state;
1146 if (rtstate != ERFON &&
1147 ppsc->rfoff_reason == RF_CHANGE_BY_IPS) {
1156 u32 halbtc_get_phydm_version(void *btc_context)
1162 void halbtc_phydm_modify_ra_pcr_threshold(void *btc_context,
1163 u8 ra_offset_direction,
1164 u8 ra_threshold_offset)
1169 u32 halbtc_phydm_query_phy_counter(void *btc_context, enum dm_info_query dm_id)
1174 static u8 halbtc_get_ant_det_val_from_bt(void *btc_context)
1176 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1177 u8 cmd_buffer[4] = {0};
1179 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1180 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_ANT_DET_VAL,
1181 cmd_buffer, 4, 200);
1183 /* need wait completion to return correct value */
1185 return btcoexist->bt_info.bt_ant_det_val;
1188 static u8 halbtc_get_ble_scan_type_from_bt(void *btc_context)
1190 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1191 u8 cmd_buffer[4] = {0};
1193 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1194 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_BLE_SCAN_TYPE,
1195 cmd_buffer, 4, 200);
1197 /* need wait completion to return correct value */
1199 return btcoexist->bt_info.bt_ble_scan_type;
1202 static u32 halbtc_get_ble_scan_para_from_bt(void *btc_context, u8 scan_type)
1204 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1205 u8 cmd_buffer[4] = {0};
1207 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1208 halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_BT_BLE_SCAN_PARA,
1209 cmd_buffer, 4, 200);
1211 /* need wait completion to return correct value */
1213 return btcoexist->bt_info.bt_ble_scan_para;
1216 static bool halbtc_get_bt_afh_map_from_bt(void *btc_context, u8 map_type,
1219 struct btc_coexist *btcoexist = (struct btc_coexist *)btc_context;
1220 u8 cmd_buffer[2] = {0};
1222 u32 *afh_map_l = (u32 *)afh_map;
1223 u32 *afh_map_m = (u32 *)(afh_map + 4);
1224 u16 *afh_map_h = (u16 *)(afh_map + 8);
1226 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1227 ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_L,
1228 cmd_buffer, 2, 200);
1232 *afh_map_l = btcoexist->bt_info.afh_map_l;
1234 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1235 ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_M,
1236 cmd_buffer, 2, 200);
1240 *afh_map_m = btcoexist->bt_info.afh_map_m;
1242 /* cmd_buffer[0] and [1] is filled by halbtc_send_bt_mp_operation() */
1243 ret = halbtc_send_bt_mp_operation(btcoexist, BT_OP_GET_AFH_MAP_H,
1244 cmd_buffer, 2, 200);
1248 *afh_map_h = btcoexist->bt_info.afh_map_h;
1254 /*****************************************************************
1255 * Extern functions called by other module
1256 *****************************************************************/
1257 bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv)
1259 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1266 btcoexist->btc_read_1byte = halbtc_read_1byte;
1267 btcoexist->btc_write_1byte = halbtc_write_1byte;
1268 btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte;
1269 btcoexist->btc_read_2byte = halbtc_read_2byte;
1270 btcoexist->btc_write_2byte = halbtc_write_2byte;
1271 btcoexist->btc_read_4byte = halbtc_read_4byte;
1272 btcoexist->btc_write_4byte = halbtc_write_4byte;
1273 btcoexist->btc_write_local_reg_1byte = halbtc_write_local_reg_1byte;
1275 btcoexist->btc_set_bb_reg = halbtc_set_bbreg;
1276 btcoexist->btc_get_bb_reg = halbtc_get_bbreg;
1278 btcoexist->btc_set_rf_reg = halbtc_set_rfreg;
1279 btcoexist->btc_get_rf_reg = halbtc_get_rfreg;
1281 btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd;
1282 btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg;
1284 btcoexist->btc_get = halbtc_get;
1285 btcoexist->btc_set = halbtc_set;
1286 btcoexist->btc_set_bt_reg = halbtc_set_bt_reg;
1287 btcoexist->btc_get_bt_reg = halbtc_get_bt_reg;
1289 btcoexist->bt_info.bt_ctrl_buf_size = false;
1290 btcoexist->bt_info.agg_buf_size = 5;
1292 btcoexist->bt_info.increase_scan_dev_num = false;
1294 btcoexist->btc_get_bt_coex_supported_feature =
1295 halbtc_get_bt_coex_supported_feature;
1296 btcoexist->btc_get_bt_coex_supported_version =
1297 halbtc_get_bt_coex_supported_version;
1298 btcoexist->btc_get_bt_phydm_version = halbtc_get_phydm_version;
1299 btcoexist->btc_phydm_modify_ra_pcr_threshold =
1300 halbtc_phydm_modify_ra_pcr_threshold;
1301 btcoexist->btc_phydm_query_phy_counter = halbtc_phydm_query_phy_counter;
1302 btcoexist->btc_get_ant_det_val_from_bt = halbtc_get_ant_det_val_from_bt;
1303 btcoexist->btc_get_ble_scan_type_from_bt =
1304 halbtc_get_ble_scan_type_from_bt;
1305 btcoexist->btc_get_ble_scan_para_from_bt =
1306 halbtc_get_ble_scan_para_from_bt;
1307 btcoexist->btc_get_bt_afh_map_from_bt =
1308 halbtc_get_bt_afh_map_from_bt;
1310 init_completion(&btcoexist->bt_mp_comp);
1315 bool exhalbtc_initlize_variables_wifi_only(struct rtl_priv *rtlpriv)
1317 struct wifi_only_cfg *wifionly_cfg = rtl_btc_wifi_only(rtlpriv);
1318 struct wifi_only_haldata *wifionly_haldata;
1323 wifionly_cfg->adapter = rtlpriv;
1325 switch (rtlpriv->rtlhal.interface) {
1327 wifionly_cfg->chip_interface = WIFIONLY_INTF_PCI;
1330 wifionly_cfg->chip_interface = WIFIONLY_INTF_USB;
1333 wifionly_cfg->chip_interface = WIFIONLY_INTF_UNKNOWN;
1337 wifionly_haldata = &wifionly_cfg->haldata_info;
1339 wifionly_haldata->customer_id = CUSTOMER_NORMAL;
1340 wifionly_haldata->efuse_pg_antnum = rtl_get_hwpg_ant_num(rtlpriv);
1341 wifionly_haldata->efuse_pg_antpath =
1342 rtl_get_hwpg_single_ant_path(rtlpriv);
1343 wifionly_haldata->rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
1344 wifionly_haldata->ant_div_cfg = 0;
1349 bool exhalbtc_bind_bt_coex_withadapter(void *adapter)
1351 struct rtl_priv *rtlpriv = adapter;
1352 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1353 u8 ant_num = 2, chip_type, single_ant_path = 0;
1358 if (btcoexist->binded)
1361 switch (rtlpriv->rtlhal.interface) {
1363 btcoexist->chip_interface = BTC_INTF_PCI;
1366 btcoexist->chip_interface = BTC_INTF_USB;
1369 btcoexist->chip_interface = BTC_INTF_UNKNOWN;
1373 btcoexist->binded = true;
1374 btcoexist->statistics.cnt_bind++;
1376 btcoexist->adapter = adapter;
1378 btcoexist->stack_info.profile_notified = false;
1380 btcoexist->bt_info.bt_ctrl_agg_buf_size = false;
1381 btcoexist->bt_info.agg_buf_size = 5;
1383 btcoexist->bt_info.increase_scan_dev_num = false;
1384 btcoexist->bt_info.miracast_plus_bt = false;
1386 chip_type = rtl_get_hwpg_bt_type(rtlpriv);
1387 exhalbtc_set_chip_type(btcoexist, chip_type);
1388 ant_num = rtl_get_hwpg_ant_num(rtlpriv);
1389 exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num);
1391 /* set default antenna position to main port */
1392 btcoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
1394 single_ant_path = rtl_get_hwpg_single_ant_path(rtlpriv);
1395 exhalbtc_set_single_ant_path(btcoexist, single_ant_path);
1397 if (rtl_get_hwpg_package_type(rtlpriv) == 0)
1398 btcoexist->board_info.tfbga_package = false;
1399 else if (rtl_get_hwpg_package_type(rtlpriv) == 1)
1400 btcoexist->board_info.tfbga_package = false;
1402 btcoexist->board_info.tfbga_package = true;
1404 if (btcoexist->board_info.tfbga_package)
1405 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1406 "[BTCoex], Package Type = TFBGA\n");
1408 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1409 "[BTCoex], Package Type = Non-TFBGA\n");
1411 btcoexist->board_info.rfe_type = rtl_get_hwpg_rfe_type(rtlpriv);
1412 btcoexist->board_info.ant_div_cfg = 0;
1417 void exhalbtc_power_on_setting(struct btc_coexist *btcoexist)
1419 if (!halbtc_is_bt_coexist_available(btcoexist))
1422 btcoexist->statistics.cnt_power_on++;
1424 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1425 if (btcoexist->board_info.btdm_ant_num == 2)
1426 ex_btc8723b2ant_power_on_setting(btcoexist);
1427 else if (btcoexist->board_info.btdm_ant_num == 1)
1428 ex_btc8723b1ant_power_on_setting(btcoexist);
1432 void exhalbtc_pre_load_firmware(struct btc_coexist *btcoexist)
1434 if (!halbtc_is_bt_coexist_available(btcoexist))
1437 btcoexist->statistics.cnt_pre_load_firmware++;
1439 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1440 if (btcoexist->board_info.btdm_ant_num == 2)
1441 ex_btc8723b2ant_pre_load_firmware(btcoexist);
1445 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only)
1447 if (!halbtc_is_bt_coexist_available(btcoexist))
1450 btcoexist->statistics.cnt_init_hw_config++;
1452 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1453 if (btcoexist->board_info.btdm_ant_num == 2)
1454 ex_btc8821a2ant_init_hwconfig(btcoexist);
1455 else if (btcoexist->board_info.btdm_ant_num == 1)
1456 ex_btc8821a1ant_init_hwconfig(btcoexist, wifi_only);
1457 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1458 if (btcoexist->board_info.btdm_ant_num == 2)
1459 ex_btc8723b2ant_init_hwconfig(btcoexist);
1460 else if (btcoexist->board_info.btdm_ant_num == 1)
1461 ex_btc8723b1ant_init_hwconfig(btcoexist, wifi_only);
1462 } else if (IS_HARDWARE_TYPE_8723A(btcoexist->adapter)) {
1463 /* 8723A has no this function */
1464 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1465 if (btcoexist->board_info.btdm_ant_num == 2)
1466 ex_btc8192e2ant_init_hwconfig(btcoexist);
1470 void exhalbtc_init_hw_config_wifi_only(struct wifi_only_cfg *wifionly_cfg)
1474 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist)
1476 if (!halbtc_is_bt_coexist_available(btcoexist))
1479 btcoexist->statistics.cnt_init_coex_dm++;
1481 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1482 if (btcoexist->board_info.btdm_ant_num == 2)
1483 ex_btc8821a2ant_init_coex_dm(btcoexist);
1484 else if (btcoexist->board_info.btdm_ant_num == 1)
1485 ex_btc8821a1ant_init_coex_dm(btcoexist);
1486 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1487 if (btcoexist->board_info.btdm_ant_num == 2)
1488 ex_btc8723b2ant_init_coex_dm(btcoexist);
1489 else if (btcoexist->board_info.btdm_ant_num == 1)
1490 ex_btc8723b1ant_init_coex_dm(btcoexist);
1491 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1492 if (btcoexist->board_info.btdm_ant_num == 2)
1493 ex_btc8192e2ant_init_coex_dm(btcoexist);
1496 btcoexist->initilized = true;
1499 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type)
1503 if (!halbtc_is_bt_coexist_available(btcoexist))
1505 btcoexist->statistics.cnt_ips_notify++;
1506 if (btcoexist->manual_control)
1510 ips_type = BTC_IPS_ENTER;
1512 ips_type = BTC_IPS_LEAVE;
1514 halbtc_leave_low_power(btcoexist);
1516 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1517 if (btcoexist->board_info.btdm_ant_num == 2)
1518 ex_btc8821a2ant_ips_notify(btcoexist, ips_type);
1519 else if (btcoexist->board_info.btdm_ant_num == 1)
1520 ex_btc8821a1ant_ips_notify(btcoexist, ips_type);
1521 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1522 if (btcoexist->board_info.btdm_ant_num == 2)
1523 ex_btc8723b2ant_ips_notify(btcoexist, ips_type);
1524 else if (btcoexist->board_info.btdm_ant_num == 1)
1525 ex_btc8723b1ant_ips_notify(btcoexist, ips_type);
1526 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1527 if (btcoexist->board_info.btdm_ant_num == 2)
1528 ex_btc8192e2ant_ips_notify(btcoexist, ips_type);
1531 halbtc_normal_low_power(btcoexist);
1534 void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type)
1538 if (!halbtc_is_bt_coexist_available(btcoexist))
1540 btcoexist->statistics.cnt_lps_notify++;
1541 if (btcoexist->manual_control)
1544 if (EACTIVE == type)
1545 lps_type = BTC_LPS_DISABLE;
1547 lps_type = BTC_LPS_ENABLE;
1549 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1550 if (btcoexist->board_info.btdm_ant_num == 2)
1551 ex_btc8821a2ant_lps_notify(btcoexist, lps_type);
1552 else if (btcoexist->board_info.btdm_ant_num == 1)
1553 ex_btc8821a1ant_lps_notify(btcoexist, lps_type);
1554 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1555 if (btcoexist->board_info.btdm_ant_num == 2)
1556 ex_btc8723b2ant_lps_notify(btcoexist, lps_type);
1557 else if (btcoexist->board_info.btdm_ant_num == 1)
1558 ex_btc8723b1ant_lps_notify(btcoexist, lps_type);
1559 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1560 if (btcoexist->board_info.btdm_ant_num == 2)
1561 ex_btc8192e2ant_lps_notify(btcoexist, lps_type);
1565 void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type)
1569 if (!halbtc_is_bt_coexist_available(btcoexist))
1571 btcoexist->statistics.cnt_scan_notify++;
1572 if (btcoexist->manual_control)
1576 scan_type = BTC_SCAN_START;
1578 scan_type = BTC_SCAN_FINISH;
1580 halbtc_leave_low_power(btcoexist);
1582 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1583 if (btcoexist->board_info.btdm_ant_num == 2)
1584 ex_btc8821a2ant_scan_notify(btcoexist, scan_type);
1585 else if (btcoexist->board_info.btdm_ant_num == 1)
1586 ex_btc8821a1ant_scan_notify(btcoexist, scan_type);
1587 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1588 if (btcoexist->board_info.btdm_ant_num == 2)
1589 ex_btc8723b2ant_scan_notify(btcoexist, scan_type);
1590 else if (btcoexist->board_info.btdm_ant_num == 1)
1591 ex_btc8723b1ant_scan_notify(btcoexist, scan_type);
1592 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1593 if (btcoexist->board_info.btdm_ant_num == 2)
1594 ex_btc8192e2ant_scan_notify(btcoexist, scan_type);
1597 halbtc_normal_low_power(btcoexist);
1600 void exhalbtc_scan_notify_wifi_only(struct wifi_only_cfg *wifionly_cfg,
1605 void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action)
1607 u8 asso_type, asso_type_v2;
1610 if (!halbtc_is_bt_coexist_available(btcoexist))
1612 btcoexist->statistics.cnt_connect_notify++;
1613 if (btcoexist->manual_control)
1616 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
1619 asso_type = BTC_ASSOCIATE_START;
1620 asso_type_v2 = wifi_under_5g ? BTC_ASSOCIATE_5G_START :
1621 BTC_ASSOCIATE_START;
1623 asso_type = BTC_ASSOCIATE_FINISH;
1624 asso_type_v2 = wifi_under_5g ? BTC_ASSOCIATE_5G_FINISH :
1625 BTC_ASSOCIATE_FINISH;
1628 halbtc_leave_low_power(btcoexist);
1630 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1631 if (btcoexist->board_info.btdm_ant_num == 2)
1632 ex_btc8821a2ant_connect_notify(btcoexist, asso_type);
1633 else if (btcoexist->board_info.btdm_ant_num == 1)
1634 ex_btc8821a1ant_connect_notify(btcoexist, asso_type);
1635 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1636 if (btcoexist->board_info.btdm_ant_num == 2)
1637 ex_btc8723b2ant_connect_notify(btcoexist, asso_type);
1638 else if (btcoexist->board_info.btdm_ant_num == 1)
1639 ex_btc8723b1ant_connect_notify(btcoexist, asso_type);
1640 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1641 if (btcoexist->board_info.btdm_ant_num == 2)
1642 ex_btc8192e2ant_connect_notify(btcoexist, asso_type);
1645 halbtc_normal_low_power(btcoexist);
1648 void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
1649 enum rt_media_status media_status)
1653 if (!halbtc_is_bt_coexist_available(btcoexist))
1655 btcoexist->statistics.cnt_media_status_notify++;
1656 if (btcoexist->manual_control)
1659 if (RT_MEDIA_CONNECT == media_status)
1660 status = BTC_MEDIA_CONNECT;
1662 status = BTC_MEDIA_DISCONNECT;
1664 halbtc_leave_low_power(btcoexist);
1666 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1667 if (btcoexist->board_info.btdm_ant_num == 2)
1668 ex_btc8821a2ant_media_status_notify(btcoexist, status);
1669 else if (btcoexist->board_info.btdm_ant_num == 1)
1670 ex_btc8821a1ant_media_status_notify(btcoexist, status);
1671 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1672 if (btcoexist->board_info.btdm_ant_num == 2)
1673 ex_btc8723b2ant_media_status_notify(btcoexist, status);
1674 else if (btcoexist->board_info.btdm_ant_num == 1)
1675 ex_btc8723b1ant_media_status_notify(btcoexist, status);
1676 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1677 if (btcoexist->board_info.btdm_ant_num == 2)
1678 ex_btc8192e2ant_media_status_notify(btcoexist, status);
1681 halbtc_normal_low_power(btcoexist);
1684 void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type)
1688 if (!halbtc_is_bt_coexist_available(btcoexist))
1690 btcoexist->statistics.cnt_special_packet_notify++;
1691 if (btcoexist->manual_control)
1694 if (pkt_type == PACKET_DHCP) {
1695 packet_type = BTC_PACKET_DHCP;
1696 } else if (pkt_type == PACKET_EAPOL) {
1697 packet_type = BTC_PACKET_EAPOL;
1698 } else if (pkt_type == PACKET_ARP) {
1699 packet_type = BTC_PACKET_ARP;
1701 packet_type = BTC_PACKET_UNKNOWN;
1705 halbtc_leave_low_power(btcoexist);
1707 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1708 if (btcoexist->board_info.btdm_ant_num == 2)
1709 ex_btc8821a2ant_special_packet_notify(btcoexist,
1711 else if (btcoexist->board_info.btdm_ant_num == 1)
1712 ex_btc8821a1ant_special_packet_notify(btcoexist,
1714 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1715 if (btcoexist->board_info.btdm_ant_num == 2)
1716 ex_btc8723b2ant_special_packet_notify(btcoexist,
1718 else if (btcoexist->board_info.btdm_ant_num == 1)
1719 ex_btc8723b1ant_special_packet_notify(btcoexist,
1721 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1722 if (btcoexist->board_info.btdm_ant_num == 2)
1723 ex_btc8192e2ant_special_packet_notify(btcoexist,
1727 halbtc_normal_low_power(btcoexist);
1730 void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist,
1731 u8 *tmp_buf, u8 length)
1733 if (!halbtc_is_bt_coexist_available(btcoexist))
1735 btcoexist->statistics.cnt_bt_info_notify++;
1737 halbtc_leave_low_power(btcoexist);
1739 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1740 if (btcoexist->board_info.btdm_ant_num == 2)
1741 ex_btc8821a2ant_bt_info_notify(btcoexist, tmp_buf,
1743 else if (btcoexist->board_info.btdm_ant_num == 1)
1744 ex_btc8821a1ant_bt_info_notify(btcoexist, tmp_buf,
1746 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1747 if (btcoexist->board_info.btdm_ant_num == 2)
1748 ex_btc8723b2ant_bt_info_notify(btcoexist, tmp_buf,
1750 else if (btcoexist->board_info.btdm_ant_num == 1)
1751 ex_btc8723b1ant_bt_info_notify(btcoexist, tmp_buf,
1753 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1754 if (btcoexist->board_info.btdm_ant_num == 2)
1755 ex_btc8192e2ant_bt_info_notify(btcoexist, tmp_buf,
1759 halbtc_normal_low_power(btcoexist);
1762 void exhalbtc_rf_status_notify(struct btc_coexist *btcoexist, u8 type)
1764 if (!halbtc_is_bt_coexist_available(btcoexist))
1767 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1768 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1769 if (btcoexist->board_info.btdm_ant_num == 1)
1770 ex_btc8723b1ant_rf_status_notify(btcoexist, type);
1771 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1775 void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type)
1779 if (!halbtc_is_bt_coexist_available(btcoexist))
1781 btcoexist->statistics.cnt_stack_operation_notify++;
1782 if (btcoexist->manual_control)
1785 if ((type == HCI_BT_OP_INQUIRY_START) ||
1786 (type == HCI_BT_OP_PAGING_START) ||
1787 (type == HCI_BT_OP_PAIRING_START)) {
1788 stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_START;
1789 } else if ((type == HCI_BT_OP_INQUIRY_FINISH) ||
1790 (type == HCI_BT_OP_PAGING_SUCCESS) ||
1791 (type == HCI_BT_OP_PAGING_UNSUCCESS) ||
1792 (type == HCI_BT_OP_PAIRING_FINISH)) {
1793 stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
1795 stack_op_type = BTC_STACK_OP_NONE;
1799 void exhalbtc_halt_notify(struct btc_coexist *btcoexist)
1801 if (!halbtc_is_bt_coexist_available(btcoexist))
1804 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1805 if (btcoexist->board_info.btdm_ant_num == 2)
1806 ex_btc8821a2ant_halt_notify(btcoexist);
1807 else if (btcoexist->board_info.btdm_ant_num == 1)
1808 ex_btc8821a1ant_halt_notify(btcoexist);
1809 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1810 if (btcoexist->board_info.btdm_ant_num == 2)
1811 ex_btc8723b2ant_halt_notify(btcoexist);
1812 else if (btcoexist->board_info.btdm_ant_num == 1)
1813 ex_btc8723b1ant_halt_notify(btcoexist);
1814 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1815 if (btcoexist->board_info.btdm_ant_num == 2)
1816 ex_btc8192e2ant_halt_notify(btcoexist);
1819 btcoexist->binded = false;
1822 void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
1824 if (!halbtc_is_bt_coexist_available(btcoexist))
1827 /* currently only 1ant we have to do the notification,
1828 * once pnp is notified to sleep state, we have to leave LPS that
1829 * we can sleep normally.
1832 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1833 if (btcoexist->board_info.btdm_ant_num == 1)
1834 ex_btc8723b1ant_pnp_notify(btcoexist, pnp_state);
1835 else if (btcoexist->board_info.btdm_ant_num == 2)
1836 ex_btc8723b2ant_pnp_notify(btcoexist, pnp_state);
1837 } else if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1838 if (btcoexist->board_info.btdm_ant_num == 1)
1839 ex_btc8821a1ant_pnp_notify(btcoexist, pnp_state);
1840 else if (btcoexist->board_info.btdm_ant_num == 2)
1841 ex_btc8821a2ant_pnp_notify(btcoexist, pnp_state);
1842 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1846 void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist)
1848 struct rtl_priv *rtlpriv = btcoexist->adapter;
1850 if (!halbtc_is_bt_coexist_available(btcoexist))
1852 btcoexist->statistics.cnt_coex_dm_switch++;
1854 halbtc_leave_low_power(btcoexist);
1856 if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1857 if (btcoexist->board_info.btdm_ant_num == 1) {
1858 btcoexist->stop_coex_dm = true;
1859 ex_btc8723b1ant_coex_dm_reset(btcoexist);
1860 exhalbtc_set_ant_num(rtlpriv,
1861 BT_COEX_ANT_TYPE_DETECTED, 2);
1862 ex_btc8723b2ant_init_hwconfig(btcoexist);
1863 ex_btc8723b2ant_init_coex_dm(btcoexist);
1864 btcoexist->stop_coex_dm = false;
1868 halbtc_normal_low_power(btcoexist);
1871 void exhalbtc_periodical(struct btc_coexist *btcoexist)
1873 if (!halbtc_is_bt_coexist_available(btcoexist))
1875 btcoexist->statistics.cnt_periodical++;
1877 halbtc_leave_low_power(btcoexist);
1879 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
1880 if (btcoexist->board_info.btdm_ant_num == 2)
1881 ex_btc8821a2ant_periodical(btcoexist);
1882 else if (btcoexist->board_info.btdm_ant_num == 1)
1883 if (!halbtc_under_ips(btcoexist))
1884 ex_btc8821a1ant_periodical(btcoexist);
1885 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
1886 if (btcoexist->board_info.btdm_ant_num == 2)
1887 ex_btc8723b2ant_periodical(btcoexist);
1888 else if (btcoexist->board_info.btdm_ant_num == 1)
1889 ex_btc8723b1ant_periodical(btcoexist);
1890 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
1891 if (btcoexist->board_info.btdm_ant_num == 2)
1892 ex_btc8192e2ant_periodical(btcoexist);
1895 halbtc_normal_low_power(btcoexist);
1898 void exhalbtc_dbg_control(struct btc_coexist *btcoexist,
1899 u8 code, u8 len, u8 *data)
1901 if (!halbtc_is_bt_coexist_available(btcoexist))
1903 btcoexist->statistics.cnt_dbg_ctrl++;
1905 halbtc_leave_low_power(btcoexist);
1907 halbtc_normal_low_power(btcoexist);
1910 void exhalbtc_antenna_detection(struct btc_coexist *btcoexist, u32 cent_freq,
1911 u32 offset, u32 span, u32 seconds)
1913 if (!halbtc_is_bt_coexist_available(btcoexist))
1917 void exhalbtc_stack_update_profile_info(void)
1921 void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi)
1923 if (!halbtc_is_bt_coexist_available(btcoexist))
1926 btcoexist->stack_info.min_bt_rssi = bt_rssi;
1929 void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version)
1931 if (!halbtc_is_bt_coexist_available(btcoexist))
1934 btcoexist->stack_info.hci_version = hci_version;
1937 void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
1938 u16 bt_hci_version, u16 bt_patch_version)
1940 if (!halbtc_is_bt_coexist_available(btcoexist))
1943 btcoexist->bt_info.bt_real_fw_ver = bt_patch_version;
1944 btcoexist->bt_info.bt_hci_ver = bt_hci_version;
1947 void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type)
1949 switch (chip_type) {
1955 btcoexist->board_info.bt_chip_type = BTC_CHIP_UNDEF;
1958 btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
1961 btcoexist->board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
1964 btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723A;
1967 btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8821;
1970 btcoexist->board_info.bt_chip_type = BTC_CHIP_RTL8723B;
1975 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
1977 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1982 if (BT_COEX_ANT_TYPE_PG == type) {
1983 btcoexist->board_info.pg_ant_num = ant_num;
1984 btcoexist->board_info.btdm_ant_num = ant_num;
1985 } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1986 btcoexist->board_info.btdm_ant_num = ant_num;
1987 } else if (type == BT_COEX_ANT_TYPE_DETECTED) {
1988 btcoexist->board_info.btdm_ant_num = ant_num;
1989 if (rtlpriv->cfg->mod_params->ant_sel == 1)
1990 btcoexist->board_info.btdm_ant_pos =
1991 BTC_ANTENNA_AT_AUX_PORT;
1993 btcoexist->board_info.btdm_ant_pos =
1994 BTC_ANTENNA_AT_MAIN_PORT;
1998 /* Currently used by 8723b only, S0 or S1 */
1999 void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
2002 btcoexist->board_info.single_ant_path = single_ant_path;
2005 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
2008 if (!halbtc_is_bt_coexist_available(btcoexist))
2011 halbtc_leave_low_power(btcoexist);
2013 if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) {
2014 if (btcoexist->board_info.btdm_ant_num == 2)
2015 ex_btc8821a2ant_display_coex_info(btcoexist, m);
2016 else if (btcoexist->board_info.btdm_ant_num == 1)
2017 ex_btc8821a1ant_display_coex_info(btcoexist, m);
2018 } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) {
2019 if (btcoexist->board_info.btdm_ant_num == 2)
2020 ex_btc8723b2ant_display_coex_info(btcoexist, m);
2021 else if (btcoexist->board_info.btdm_ant_num == 1)
2022 ex_btc8723b1ant_display_coex_info(btcoexist, m);
2023 } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) {
2024 if (btcoexist->board_info.btdm_ant_num == 2)
2025 ex_btc8192e2ant_display_coex_info(btcoexist, m);
2028 halbtc_normal_low_power(btcoexist);
2031 void exhalbtc_switch_band_notify(struct btc_coexist *btcoexist, u8 type)
2033 if (!halbtc_is_bt_coexist_available(btcoexist))
2036 if (btcoexist->manual_control)
2039 halbtc_leave_low_power(btcoexist);
2041 halbtc_normal_low_power(btcoexist);
2044 void exhalbtc_switch_band_notify_wifi_only(struct wifi_only_cfg *wifionly_cfg,