1f1d2b4d3SLarry Finger /****************************************************************************** 2f1d2b4d3SLarry Finger * 3f1d2b4d3SLarry Finger * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved. 4f1d2b4d3SLarry Finger * 5f1d2b4d3SLarry Finger * This program is free software; you can redistribute it and/or modify it 6f1d2b4d3SLarry Finger * under the terms of version 2 of the GNU General Public License as 7f1d2b4d3SLarry Finger * published by the Free Software Foundation. 8f1d2b4d3SLarry Finger * 9f1d2b4d3SLarry Finger * This program is distributed in the hope that it will be useful, but WITHOUT 10f1d2b4d3SLarry Finger * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11f1d2b4d3SLarry Finger * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12f1d2b4d3SLarry Finger * more details. 13f1d2b4d3SLarry Finger * 14f1d2b4d3SLarry Finger * The full GNU General Public License is included in this distribution in the 15f1d2b4d3SLarry Finger * file called LICENSE. 16f1d2b4d3SLarry Finger * 17f1d2b4d3SLarry Finger * Contact Information: 18f1d2b4d3SLarry Finger * wlanfae <wlanfae@realtek.com> 19f1d2b4d3SLarry Finger * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20f1d2b4d3SLarry Finger * Hsinchu 300, Taiwan. 21f1d2b4d3SLarry Finger * 22f1d2b4d3SLarry Finger * Larry Finger <Larry.Finger@lwfinger.net> 23f1d2b4d3SLarry Finger * 24f1d2b4d3SLarry Finger ******************************************************************************/ 25f1d2b4d3SLarry Finger 26f1d2b4d3SLarry Finger #include "halbt_precomp.h" 27f1d2b4d3SLarry Finger 28f1d2b4d3SLarry Finger /*********************************************** 29f1d2b4d3SLarry Finger * Global variables 30f1d2b4d3SLarry Finger ***********************************************/ 31f1d2b4d3SLarry Finger 32f1d2b4d3SLarry Finger struct btc_coexist gl_bt_coexist; 33f1d2b4d3SLarry Finger 34f1d2b4d3SLarry Finger u32 btc_dbg_type[BTC_MSG_MAX]; 35f1d2b4d3SLarry Finger 36f1d2b4d3SLarry Finger /*************************************************** 37f1d2b4d3SLarry Finger * Debug related function 38f1d2b4d3SLarry Finger ***************************************************/ 39f1d2b4d3SLarry Finger static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist) 40f1d2b4d3SLarry Finger { 41f1d2b4d3SLarry Finger if (!btcoexist->binded || NULL == btcoexist->adapter) 42f1d2b4d3SLarry Finger return false; 43f1d2b4d3SLarry Finger 44f1d2b4d3SLarry Finger return true; 45f1d2b4d3SLarry Finger } 46f1d2b4d3SLarry Finger 47f1d2b4d3SLarry Finger static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv) 48f1d2b4d3SLarry Finger { 49f1d2b4d3SLarry Finger if (rtlpriv->link_info.busytraffic) 50f1d2b4d3SLarry Finger return true; 51f1d2b4d3SLarry Finger else 52f1d2b4d3SLarry Finger return false; 53f1d2b4d3SLarry Finger } 54f1d2b4d3SLarry Finger 55f1d2b4d3SLarry Finger static void halbtc_dbg_init(void) 56f1d2b4d3SLarry Finger { 57f1d2b4d3SLarry Finger u8 i; 58f1d2b4d3SLarry Finger 59f1d2b4d3SLarry Finger for (i = 0; i < BTC_MSG_MAX; i++) 60f1d2b4d3SLarry Finger btc_dbg_type[i] = 0; 61f1d2b4d3SLarry Finger 62f1d2b4d3SLarry Finger btc_dbg_type[BTC_MSG_INTERFACE] = 63f1d2b4d3SLarry Finger /* INTF_INIT | */ 64f1d2b4d3SLarry Finger /* INTF_NOTIFY | */ 65f1d2b4d3SLarry Finger 0; 66f1d2b4d3SLarry Finger 67f1d2b4d3SLarry Finger btc_dbg_type[BTC_MSG_ALGORITHM] = 68f1d2b4d3SLarry Finger /* ALGO_BT_RSSI_STATE | */ 69f1d2b4d3SLarry Finger /* ALGO_WIFI_RSSI_STATE | */ 70f1d2b4d3SLarry Finger /* ALGO_BT_MONITOR | */ 71f1d2b4d3SLarry Finger /* ALGO_TRACE | */ 72f1d2b4d3SLarry Finger /* ALGO_TRACE_FW | */ 73f1d2b4d3SLarry Finger /* ALGO_TRACE_FW_DETAIL | */ 74f1d2b4d3SLarry Finger /* ALGO_TRACE_FW_EXEC | */ 75f1d2b4d3SLarry Finger /* ALGO_TRACE_SW | */ 76f1d2b4d3SLarry Finger /* ALGO_TRACE_SW_DETAIL | */ 77f1d2b4d3SLarry Finger /* ALGO_TRACE_SW_EXEC | */ 78f1d2b4d3SLarry Finger 0; 79f1d2b4d3SLarry Finger } 80f1d2b4d3SLarry Finger 81f1d2b4d3SLarry Finger static bool halbtc_is_bt40(struct rtl_priv *adapter) 82f1d2b4d3SLarry Finger { 83f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = adapter; 84f1d2b4d3SLarry Finger struct rtl_phy *rtlphy = &(rtlpriv->phy); 85f1d2b4d3SLarry Finger bool is_ht40 = true; 86f1d2b4d3SLarry Finger enum ht_channel_width bw = rtlphy->current_chan_bw; 87f1d2b4d3SLarry Finger 88f1d2b4d3SLarry Finger if (bw == HT_CHANNEL_WIDTH_20) 89f1d2b4d3SLarry Finger is_ht40 = false; 90f1d2b4d3SLarry Finger else if (bw == HT_CHANNEL_WIDTH_20_40) 91f1d2b4d3SLarry Finger is_ht40 = true; 92f1d2b4d3SLarry Finger 93f1d2b4d3SLarry Finger return is_ht40; 94f1d2b4d3SLarry Finger } 95f1d2b4d3SLarry Finger 96f1d2b4d3SLarry Finger static bool halbtc_legacy(struct rtl_priv *adapter) 97f1d2b4d3SLarry Finger { 98f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = adapter; 99f1d2b4d3SLarry Finger struct rtl_mac *mac = rtl_mac(rtlpriv); 100f1d2b4d3SLarry Finger 101f1d2b4d3SLarry Finger bool is_legacy = false; 102f1d2b4d3SLarry Finger 103f1d2b4d3SLarry Finger if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_G)) 104f1d2b4d3SLarry Finger is_legacy = true; 105f1d2b4d3SLarry Finger 106f1d2b4d3SLarry Finger return is_legacy; 107f1d2b4d3SLarry Finger } 108f1d2b4d3SLarry Finger 109f1d2b4d3SLarry Finger bool halbtc_is_wifi_uplink(struct rtl_priv *adapter) 110f1d2b4d3SLarry Finger { 111f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = adapter; 112f1d2b4d3SLarry Finger 113f1d2b4d3SLarry Finger if (rtlpriv->link_info.tx_busy_traffic) 114f1d2b4d3SLarry Finger return true; 115f1d2b4d3SLarry Finger else 116f1d2b4d3SLarry Finger return false; 117f1d2b4d3SLarry Finger } 118f1d2b4d3SLarry Finger 119f1d2b4d3SLarry Finger static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist) 120f1d2b4d3SLarry Finger { 121f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = 122f1d2b4d3SLarry Finger (struct rtl_priv *)btcoexist->adapter; 123f1d2b4d3SLarry Finger u32 wifi_bw = BTC_WIFI_BW_HT20; 124f1d2b4d3SLarry Finger 125f1d2b4d3SLarry Finger if (halbtc_is_bt40(rtlpriv)) { 126f1d2b4d3SLarry Finger wifi_bw = BTC_WIFI_BW_HT40; 127f1d2b4d3SLarry Finger } else { 128f1d2b4d3SLarry Finger if (halbtc_legacy(rtlpriv)) 129f1d2b4d3SLarry Finger wifi_bw = BTC_WIFI_BW_LEGACY; 130f1d2b4d3SLarry Finger else 131f1d2b4d3SLarry Finger wifi_bw = BTC_WIFI_BW_HT20; 132f1d2b4d3SLarry Finger } 133f1d2b4d3SLarry Finger return wifi_bw; 134f1d2b4d3SLarry Finger } 135f1d2b4d3SLarry Finger 136f1d2b4d3SLarry Finger static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist) 137f1d2b4d3SLarry Finger { 138f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 139f1d2b4d3SLarry Finger struct rtl_phy *rtlphy = &(rtlpriv->phy); 140f1d2b4d3SLarry Finger u8 chnl = 1; 141f1d2b4d3SLarry Finger 142f1d2b4d3SLarry Finger if (rtlphy->current_channel != 0) 143f1d2b4d3SLarry Finger chnl = rtlphy->current_channel; 14441880bb3SLarry Finger RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 145f1d2b4d3SLarry Finger "static halbtc_get_wifi_central_chnl:%d\n", chnl); 146f1d2b4d3SLarry Finger return chnl; 147f1d2b4d3SLarry Finger } 148f1d2b4d3SLarry Finger 149db8cb009SPing-Ke Shih u8 rtl_get_hwpg_single_ant_path(struct rtl_priv *rtlpriv) 150db8cb009SPing-Ke Shih { 151db8cb009SPing-Ke Shih return rtlpriv->btcoexist.btc_info.single_ant_path; 152db8cb009SPing-Ke Shih } 153db8cb009SPing-Ke Shih 154e0215c14SPing-Ke Shih u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv) 155e0215c14SPing-Ke Shih { 156e0215c14SPing-Ke Shih return rtlpriv->btcoexist.btc_info.bt_type; 157e0215c14SPing-Ke Shih } 158e0215c14SPing-Ke Shih 1590de9b5dbSPing-Ke Shih u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv) 1600de9b5dbSPing-Ke Shih { 1610de9b5dbSPing-Ke Shih u8 num; 1620de9b5dbSPing-Ke Shih 1630de9b5dbSPing-Ke Shih if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2) 1640de9b5dbSPing-Ke Shih num = 2; 1650de9b5dbSPing-Ke Shih else 1660de9b5dbSPing-Ke Shih num = 1; 1670de9b5dbSPing-Ke Shih 1680de9b5dbSPing-Ke Shih return num; 1690de9b5dbSPing-Ke Shih } 1700de9b5dbSPing-Ke Shih 1717fe1fe75SPing-Ke Shih u8 rtl_get_hwpg_package_type(struct rtl_priv *rtlpriv) 1727fe1fe75SPing-Ke Shih { 1737fe1fe75SPing-Ke Shih struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 1747fe1fe75SPing-Ke Shih 1757fe1fe75SPing-Ke Shih return rtlhal->package_type; 1767fe1fe75SPing-Ke Shih } 1777fe1fe75SPing-Ke Shih 178f1d2b4d3SLarry Finger static void halbtc_leave_lps(struct btc_coexist *btcoexist) 179f1d2b4d3SLarry Finger { 180f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv; 181f1d2b4d3SLarry Finger struct rtl_ps_ctl *ppsc; 182f1d2b4d3SLarry Finger bool ap_enable = false; 183f1d2b4d3SLarry Finger 184f1d2b4d3SLarry Finger rtlpriv = btcoexist->adapter; 185f1d2b4d3SLarry Finger ppsc = rtl_psc(rtlpriv); 186f1d2b4d3SLarry Finger 187f1d2b4d3SLarry Finger btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, 188f1d2b4d3SLarry Finger &ap_enable); 189f1d2b4d3SLarry Finger 190f1d2b4d3SLarry Finger if (ap_enable) { 191f1d2b4d3SLarry Finger pr_info("halbtc_leave_lps()<--dont leave lps under AP mode\n"); 192f1d2b4d3SLarry Finger return; 193f1d2b4d3SLarry Finger } 194f1d2b4d3SLarry Finger 195f1d2b4d3SLarry Finger btcoexist->bt_info.bt_ctrl_lps = true; 196f1d2b4d3SLarry Finger btcoexist->bt_info.bt_lps_on = false; 197f1d2b4d3SLarry Finger } 198f1d2b4d3SLarry Finger 199f1d2b4d3SLarry Finger static void halbtc_enter_lps(struct btc_coexist *btcoexist) 200f1d2b4d3SLarry Finger { 201f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv; 202f1d2b4d3SLarry Finger struct rtl_ps_ctl *ppsc; 203f1d2b4d3SLarry Finger bool ap_enable = false; 204f1d2b4d3SLarry Finger 205f1d2b4d3SLarry Finger rtlpriv = btcoexist->adapter; 206f1d2b4d3SLarry Finger ppsc = rtl_psc(rtlpriv); 207f1d2b4d3SLarry Finger 208f1d2b4d3SLarry Finger btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, 209f1d2b4d3SLarry Finger &ap_enable); 210f1d2b4d3SLarry Finger 211f1d2b4d3SLarry Finger if (ap_enable) { 212f1d2b4d3SLarry Finger pr_info("halbtc_enter_lps()<--dont enter lps under AP mode\n"); 213f1d2b4d3SLarry Finger return; 214f1d2b4d3SLarry Finger } 215f1d2b4d3SLarry Finger 216f1d2b4d3SLarry Finger btcoexist->bt_info.bt_ctrl_lps = true; 217f1d2b4d3SLarry Finger btcoexist->bt_info.bt_lps_on = false; 218f1d2b4d3SLarry Finger } 219f1d2b4d3SLarry Finger 220f1d2b4d3SLarry Finger static void halbtc_normal_lps(struct btc_coexist *btcoexist) 221f1d2b4d3SLarry Finger { 222f1d2b4d3SLarry Finger if (btcoexist->bt_info.bt_ctrl_lps) { 223f1d2b4d3SLarry Finger btcoexist->bt_info.bt_lps_on = false; 224f1d2b4d3SLarry Finger btcoexist->bt_info.bt_ctrl_lps = false; 225f1d2b4d3SLarry Finger } 226f1d2b4d3SLarry Finger } 227f1d2b4d3SLarry Finger 2287937f02dSYan-Hsuan Chuang static void halbtc_leave_low_power(struct btc_coexist *btcoexist) 229f1d2b4d3SLarry Finger { 230f1d2b4d3SLarry Finger } 231f1d2b4d3SLarry Finger 2327937f02dSYan-Hsuan Chuang static void halbtc_normal_low_power(struct btc_coexist *btcoexist) 233f1d2b4d3SLarry Finger { 234f1d2b4d3SLarry Finger } 235f1d2b4d3SLarry Finger 236f1d2b4d3SLarry Finger static void halbtc_disable_low_power(void) 237f1d2b4d3SLarry Finger { 238f1d2b4d3SLarry Finger } 239f1d2b4d3SLarry Finger 240f1d2b4d3SLarry Finger static void halbtc_aggregation_check(void) 241f1d2b4d3SLarry Finger { 242f1d2b4d3SLarry Finger } 243f1d2b4d3SLarry Finger 244f1d2b4d3SLarry Finger static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist) 245f1d2b4d3SLarry Finger { 246f1d2b4d3SLarry Finger return 0; 247f1d2b4d3SLarry Finger } 248f1d2b4d3SLarry Finger 249f1d2b4d3SLarry Finger static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter) 250f1d2b4d3SLarry Finger { 251f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = adapter; 252f1d2b4d3SLarry Finger s32 undec_sm_pwdb = 0; 253f1d2b4d3SLarry Finger 254f1d2b4d3SLarry Finger if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) 255f1d2b4d3SLarry Finger undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; 256f1d2b4d3SLarry Finger else /* associated entry pwdb */ 257f1d2b4d3SLarry Finger undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; 258f1d2b4d3SLarry Finger return undec_sm_pwdb; 259f1d2b4d3SLarry Finger } 260f1d2b4d3SLarry Finger 261f1d2b4d3SLarry Finger static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) 262f1d2b4d3SLarry Finger { 263f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; 264f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 265f1d2b4d3SLarry Finger struct rtl_phy *rtlphy = &(rtlpriv->phy); 266f1d2b4d3SLarry Finger struct rtl_mac *mac = rtl_mac(rtlpriv); 267f1d2b4d3SLarry Finger struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 268f1d2b4d3SLarry Finger bool *bool_tmp = (bool *)out_buf; 269f1d2b4d3SLarry Finger int *s32_tmp = (int *)out_buf; 270f1d2b4d3SLarry Finger u32 *u32_tmp = (u32 *)out_buf; 271f1d2b4d3SLarry Finger u8 *u8_tmp = (u8 *)out_buf; 272f1d2b4d3SLarry Finger bool tmp = false; 273f1d2b4d3SLarry Finger 274f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 275f1d2b4d3SLarry Finger return false; 276f1d2b4d3SLarry Finger 277f1d2b4d3SLarry Finger switch (get_type) { 278f1d2b4d3SLarry Finger case BTC_GET_BL_HS_OPERATION: 279f1d2b4d3SLarry Finger *bool_tmp = false; 280f1d2b4d3SLarry Finger break; 281f1d2b4d3SLarry Finger case BTC_GET_BL_HS_CONNECTING: 282f1d2b4d3SLarry Finger *bool_tmp = false; 283f1d2b4d3SLarry Finger break; 284f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_CONNECTED: 285f1d2b4d3SLarry Finger if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) 286f1d2b4d3SLarry Finger tmp = true; 287f1d2b4d3SLarry Finger *bool_tmp = tmp; 288f1d2b4d3SLarry Finger break; 289f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_BUSY: 290f1d2b4d3SLarry Finger if (halbtc_is_wifi_busy(rtlpriv)) 291f1d2b4d3SLarry Finger *bool_tmp = true; 292f1d2b4d3SLarry Finger else 293f1d2b4d3SLarry Finger *bool_tmp = false; 294f1d2b4d3SLarry Finger break; 295f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_SCAN: 296f1d2b4d3SLarry Finger if (mac->act_scanning) 297f1d2b4d3SLarry Finger *bool_tmp = true; 298f1d2b4d3SLarry Finger else 299f1d2b4d3SLarry Finger *bool_tmp = false; 300f1d2b4d3SLarry Finger break; 301f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_LINK: 302f1d2b4d3SLarry Finger if (mac->link_state == MAC80211_LINKING) 303f1d2b4d3SLarry Finger *bool_tmp = true; 304f1d2b4d3SLarry Finger else 305f1d2b4d3SLarry Finger *bool_tmp = false; 306f1d2b4d3SLarry Finger break; 307f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_ROAM: /*TODO*/ 308f1d2b4d3SLarry Finger if (mac->link_state == MAC80211_LINKING) 309f1d2b4d3SLarry Finger *bool_tmp = true; 310f1d2b4d3SLarry Finger else 311f1d2b4d3SLarry Finger *bool_tmp = false; 312f1d2b4d3SLarry Finger break; 313f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_4_WAY_PROGRESS: /*TODO*/ 314f1d2b4d3SLarry Finger *bool_tmp = false; 315f1d2b4d3SLarry Finger 316f1d2b4d3SLarry Finger break; 317f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_UNDER_5G: 318f1d2b4d3SLarry Finger *bool_tmp = false; /*TODO*/ 319f1d2b4d3SLarry Finger 320f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_DHCP: /*TODO*/ 321f1d2b4d3SLarry Finger break; 322f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_SOFTAP_IDLE: 323f1d2b4d3SLarry Finger *bool_tmp = true; 324f1d2b4d3SLarry Finger break; 325f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_SOFTAP_LINKING: 326f1d2b4d3SLarry Finger *bool_tmp = false; 327f1d2b4d3SLarry Finger break; 328f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_IN_EARLY_SUSPEND: 329f1d2b4d3SLarry Finger *bool_tmp = false; 330f1d2b4d3SLarry Finger break; 331f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_AP_MODE_ENABLE: 332f1d2b4d3SLarry Finger *bool_tmp = false; 333f1d2b4d3SLarry Finger break; 334f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION: 335f1d2b4d3SLarry Finger if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm) 336f1d2b4d3SLarry Finger *bool_tmp = false; 337f1d2b4d3SLarry Finger else 338f1d2b4d3SLarry Finger *bool_tmp = true; 339f1d2b4d3SLarry Finger break; 340f1d2b4d3SLarry Finger case BTC_GET_BL_WIFI_UNDER_B_MODE: 341f1d2b4d3SLarry Finger *bool_tmp = false; /*TODO*/ 342f1d2b4d3SLarry Finger break; 343f1d2b4d3SLarry Finger case BTC_GET_BL_EXT_SWITCH: 344f1d2b4d3SLarry Finger *bool_tmp = false; 345f1d2b4d3SLarry Finger break; 346f1d2b4d3SLarry Finger case BTC_GET_S4_WIFI_RSSI: 347f1d2b4d3SLarry Finger *s32_tmp = halbtc_get_wifi_rssi(rtlpriv); 348f1d2b4d3SLarry Finger break; 349f1d2b4d3SLarry Finger case BTC_GET_S4_HS_RSSI: /*TODO*/ 350f1d2b4d3SLarry Finger *s32_tmp = halbtc_get_wifi_rssi(rtlpriv); 351f1d2b4d3SLarry Finger break; 352f1d2b4d3SLarry Finger case BTC_GET_U4_WIFI_BW: 353f1d2b4d3SLarry Finger *u32_tmp = halbtc_get_wifi_bw(btcoexist); 354f1d2b4d3SLarry Finger break; 355f1d2b4d3SLarry Finger case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION: 356f1d2b4d3SLarry Finger if (halbtc_is_wifi_uplink(rtlpriv)) 357f1d2b4d3SLarry Finger *u32_tmp = BTC_WIFI_TRAFFIC_TX; 358f1d2b4d3SLarry Finger else 359f1d2b4d3SLarry Finger *u32_tmp = BTC_WIFI_TRAFFIC_RX; 360f1d2b4d3SLarry Finger break; 361f1d2b4d3SLarry Finger case BTC_GET_U4_WIFI_FW_VER: 362f1d2b4d3SLarry Finger *u32_tmp = rtlhal->fw_version; 363f1d2b4d3SLarry Finger break; 364f1d2b4d3SLarry Finger case BTC_GET_U4_BT_PATCH_VER: 365f1d2b4d3SLarry Finger *u32_tmp = halbtc_get_bt_patch_version(btcoexist); 366f1d2b4d3SLarry Finger break; 3671a281473SPing-Ke Shih case BTC_GET_U4_VENDOR: 3681a281473SPing-Ke Shih *u32_tmp = BTC_VENDOR_OTHER; 3691a281473SPing-Ke Shih break; 370f1d2b4d3SLarry Finger case BTC_GET_U1_WIFI_DOT11_CHNL: 371f1d2b4d3SLarry Finger *u8_tmp = rtlphy->current_channel; 372f1d2b4d3SLarry Finger break; 373f1d2b4d3SLarry Finger case BTC_GET_U1_WIFI_CENTRAL_CHNL: 374f1d2b4d3SLarry Finger *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist); 375f1d2b4d3SLarry Finger break; 376f1d2b4d3SLarry Finger case BTC_GET_U1_WIFI_HS_CHNL: 377f1d2b4d3SLarry Finger *u8_tmp = 1;/*BT_OperateChnl(rtlpriv);*/ 378f1d2b4d3SLarry Finger break; 379f1d2b4d3SLarry Finger case BTC_GET_U1_MAC_PHY_MODE: 380f1d2b4d3SLarry Finger *u8_tmp = BTC_MP_UNKNOWN; 381f1d2b4d3SLarry Finger break; 382f1d2b4d3SLarry Finger 383f1d2b4d3SLarry Finger /************* 1Ant **************/ 384f1d2b4d3SLarry Finger case BTC_GET_U1_LPS_MODE: 385f1d2b4d3SLarry Finger *u8_tmp = btcoexist->pwr_mode_val[0]; 386f1d2b4d3SLarry Finger break; 387f1d2b4d3SLarry Finger 388f1d2b4d3SLarry Finger default: 389f1d2b4d3SLarry Finger break; 390f1d2b4d3SLarry Finger } 391f1d2b4d3SLarry Finger 392f1d2b4d3SLarry Finger return true; 393f1d2b4d3SLarry Finger } 394f1d2b4d3SLarry Finger 395f1d2b4d3SLarry Finger static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf) 396f1d2b4d3SLarry Finger { 397f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; 398f1d2b4d3SLarry Finger bool *bool_tmp = (bool *)in_buf; 399f1d2b4d3SLarry Finger u8 *u8_tmp = (u8 *)in_buf; 400f1d2b4d3SLarry Finger u32 *u32_tmp = (u32 *)in_buf; 401f1d2b4d3SLarry Finger 402f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 403f1d2b4d3SLarry Finger return false; 404f1d2b4d3SLarry Finger 405f1d2b4d3SLarry Finger switch (set_type) { 406f1d2b4d3SLarry Finger /* set some bool type variables. */ 407f1d2b4d3SLarry Finger case BTC_SET_BL_BT_DISABLE: 408f1d2b4d3SLarry Finger btcoexist->bt_info.bt_disabled = *bool_tmp; 409f1d2b4d3SLarry Finger break; 410f1d2b4d3SLarry Finger case BTC_SET_BL_BT_TRAFFIC_BUSY: 411f1d2b4d3SLarry Finger btcoexist->bt_info.bt_busy = *bool_tmp; 412f1d2b4d3SLarry Finger break; 413f1d2b4d3SLarry Finger case BTC_SET_BL_BT_LIMITED_DIG: 414f1d2b4d3SLarry Finger btcoexist->bt_info.limited_dig = *bool_tmp; 415f1d2b4d3SLarry Finger break; 416f1d2b4d3SLarry Finger case BTC_SET_BL_FORCE_TO_ROAM: 417f1d2b4d3SLarry Finger btcoexist->bt_info.force_to_roam = *bool_tmp; 418f1d2b4d3SLarry Finger break; 419f1d2b4d3SLarry Finger case BTC_SET_BL_TO_REJ_AP_AGG_PKT: 420f1d2b4d3SLarry Finger btcoexist->bt_info.reject_agg_pkt = *bool_tmp; 421f1d2b4d3SLarry Finger break; 422f1d2b4d3SLarry Finger case BTC_SET_BL_BT_CTRL_AGG_SIZE: 423f1d2b4d3SLarry Finger btcoexist->bt_info.bt_ctrl_buf_size = *bool_tmp; 424f1d2b4d3SLarry Finger break; 425f1d2b4d3SLarry Finger case BTC_SET_BL_INC_SCAN_DEV_NUM: 426f1d2b4d3SLarry Finger btcoexist->bt_info.increase_scan_dev_num = *bool_tmp; 427f1d2b4d3SLarry Finger break; 428f1d2b4d3SLarry Finger /* set some u1Byte type variables. */ 429f1d2b4d3SLarry Finger case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON: 430f1d2b4d3SLarry Finger btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp; 431f1d2b4d3SLarry Finger break; 432f1d2b4d3SLarry Finger case BTC_SET_U1_AGG_BUF_SIZE: 433f1d2b4d3SLarry Finger btcoexist->bt_info.agg_buf_size = *u8_tmp; 434f1d2b4d3SLarry Finger break; 435f1d2b4d3SLarry Finger /* the following are some action which will be triggered */ 436f1d2b4d3SLarry Finger case BTC_SET_ACT_GET_BT_RSSI: 437f1d2b4d3SLarry Finger /*BTHCI_SendGetBtRssiEvent(rtlpriv);*/ 438f1d2b4d3SLarry Finger break; 439f1d2b4d3SLarry Finger case BTC_SET_ACT_AGGREGATE_CTRL: 440f1d2b4d3SLarry Finger halbtc_aggregation_check(); 441f1d2b4d3SLarry Finger break; 442f1d2b4d3SLarry Finger 443f1d2b4d3SLarry Finger /* 1Ant */ 444f1d2b4d3SLarry Finger case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE: 445f1d2b4d3SLarry Finger btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp; 446f1d2b4d3SLarry Finger break; 447f1d2b4d3SLarry Finger case BTC_SET_UI_SCAN_SIG_COMPENSATION: 448f1d2b4d3SLarry Finger /* rtlpriv->mlmepriv.scan_compensation = *u8_tmp; */ 449f1d2b4d3SLarry Finger break; 450f1d2b4d3SLarry Finger case BTC_SET_U1_1ANT_LPS: 451f1d2b4d3SLarry Finger btcoexist->bt_info.lps_val = *u8_tmp; 452f1d2b4d3SLarry Finger break; 453f1d2b4d3SLarry Finger case BTC_SET_U1_1ANT_RPWM: 454f1d2b4d3SLarry Finger btcoexist->bt_info.rpwm_val = *u8_tmp; 455f1d2b4d3SLarry Finger break; 456f1d2b4d3SLarry Finger /* the following are some action which will be triggered */ 457f1d2b4d3SLarry Finger case BTC_SET_ACT_LEAVE_LPS: 458f1d2b4d3SLarry Finger halbtc_leave_lps(btcoexist); 459f1d2b4d3SLarry Finger break; 460f1d2b4d3SLarry Finger case BTC_SET_ACT_ENTER_LPS: 461f1d2b4d3SLarry Finger halbtc_enter_lps(btcoexist); 462f1d2b4d3SLarry Finger break; 463f1d2b4d3SLarry Finger case BTC_SET_ACT_NORMAL_LPS: 464f1d2b4d3SLarry Finger halbtc_normal_lps(btcoexist); 465f1d2b4d3SLarry Finger break; 466f1d2b4d3SLarry Finger case BTC_SET_ACT_DISABLE_LOW_POWER: 467f1d2b4d3SLarry Finger halbtc_disable_low_power(); 468f1d2b4d3SLarry Finger break; 469c6821613SYan-Hsuan Chuang case BTC_SET_ACT_UPDATE_RAMASK: 470f1d2b4d3SLarry Finger btcoexist->bt_info.ra_mask = *u32_tmp; 471f1d2b4d3SLarry Finger break; 472f1d2b4d3SLarry Finger case BTC_SET_ACT_SEND_MIMO_PS: 473f1d2b4d3SLarry Finger break; 474f1d2b4d3SLarry Finger case BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT: 475f1d2b4d3SLarry Finger btcoexist->bt_info.force_exec_pwr_cmd_cnt++; 476f1d2b4d3SLarry Finger break; 477f1d2b4d3SLarry Finger case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/ 478f1d2b4d3SLarry Finger break; 479f1d2b4d3SLarry Finger case BTC_SET_ACT_CTRL_BT_COEX: 480f1d2b4d3SLarry Finger break; 481f1d2b4d3SLarry Finger default: 482f1d2b4d3SLarry Finger break; 483f1d2b4d3SLarry Finger } 484f1d2b4d3SLarry Finger 485f1d2b4d3SLarry Finger return true; 486f1d2b4d3SLarry Finger } 487f1d2b4d3SLarry Finger 488f1d2b4d3SLarry Finger static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist) 489f1d2b4d3SLarry Finger { 490f1d2b4d3SLarry Finger } 491f1d2b4d3SLarry Finger 492f1d2b4d3SLarry Finger static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist) 493f1d2b4d3SLarry Finger { 494f1d2b4d3SLarry Finger } 495f1d2b4d3SLarry Finger 496f1d2b4d3SLarry Finger static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist) 497f1d2b4d3SLarry Finger { 498f1d2b4d3SLarry Finger } 499f1d2b4d3SLarry Finger 500f1d2b4d3SLarry Finger static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist) 501f1d2b4d3SLarry Finger { 502f1d2b4d3SLarry Finger } 503f1d2b4d3SLarry Finger 504f1d2b4d3SLarry Finger /************************************************************ 505f1d2b4d3SLarry Finger * IO related function 506f1d2b4d3SLarry Finger ************************************************************/ 507f1d2b4d3SLarry Finger static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr) 508f1d2b4d3SLarry Finger { 509f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 510f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 511f1d2b4d3SLarry Finger 512f1d2b4d3SLarry Finger return rtl_read_byte(rtlpriv, reg_addr); 513f1d2b4d3SLarry Finger } 514f1d2b4d3SLarry Finger 515f1d2b4d3SLarry Finger static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr) 516f1d2b4d3SLarry Finger { 517f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 518f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 519f1d2b4d3SLarry Finger 520f1d2b4d3SLarry Finger return rtl_read_word(rtlpriv, reg_addr); 521f1d2b4d3SLarry Finger } 522f1d2b4d3SLarry Finger 523f1d2b4d3SLarry Finger static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr) 524f1d2b4d3SLarry Finger { 525f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 526f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 527f1d2b4d3SLarry Finger 528f1d2b4d3SLarry Finger return rtl_read_dword(rtlpriv, reg_addr); 529f1d2b4d3SLarry Finger } 530f1d2b4d3SLarry Finger 531f1d2b4d3SLarry Finger static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u32 data) 532f1d2b4d3SLarry Finger { 533f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 534f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 535f1d2b4d3SLarry Finger 536f1d2b4d3SLarry Finger rtl_write_byte(rtlpriv, reg_addr, data); 537f1d2b4d3SLarry Finger } 538f1d2b4d3SLarry Finger 539f1d2b4d3SLarry Finger static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr, 540f1d2b4d3SLarry Finger u32 bit_mask, u8 data) 541f1d2b4d3SLarry Finger { 542f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 543f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 544f1d2b4d3SLarry Finger u8 original_value, bit_shift = 0; 545f1d2b4d3SLarry Finger u8 i; 546f1d2b4d3SLarry Finger 547f1d2b4d3SLarry Finger if (bit_mask != MASKDWORD) {/*if not "double word" write*/ 548f1d2b4d3SLarry Finger original_value = rtl_read_byte(rtlpriv, reg_addr); 549f1d2b4d3SLarry Finger for (i = 0; i <= 7; i++) { 550f1d2b4d3SLarry Finger if ((bit_mask>>i) & 0x1) 551f1d2b4d3SLarry Finger break; 552f1d2b4d3SLarry Finger } 553f1d2b4d3SLarry Finger bit_shift = i; 554f1d2b4d3SLarry Finger data = (original_value & (~bit_mask)) | 555f1d2b4d3SLarry Finger ((data << bit_shift) & bit_mask); 556f1d2b4d3SLarry Finger } 557f1d2b4d3SLarry Finger rtl_write_byte(rtlpriv, reg_addr, data); 558f1d2b4d3SLarry Finger } 559f1d2b4d3SLarry Finger 560f1d2b4d3SLarry Finger static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data) 561f1d2b4d3SLarry Finger { 562f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 563f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 564f1d2b4d3SLarry Finger 565f1d2b4d3SLarry Finger rtl_write_word(rtlpriv, reg_addr, data); 566f1d2b4d3SLarry Finger } 567f1d2b4d3SLarry Finger 568f1d2b4d3SLarry Finger static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) 569f1d2b4d3SLarry Finger { 570f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = 571f1d2b4d3SLarry Finger (struct btc_coexist *)bt_context; 572f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 573f1d2b4d3SLarry Finger 574f1d2b4d3SLarry Finger rtl_write_dword(rtlpriv, reg_addr, data); 575f1d2b4d3SLarry Finger } 576f1d2b4d3SLarry Finger 577f1d2b4d3SLarry Finger static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask, 578f1d2b4d3SLarry Finger u32 data) 579f1d2b4d3SLarry Finger { 580f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 581f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 582f1d2b4d3SLarry Finger 583f1d2b4d3SLarry Finger rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data); 584f1d2b4d3SLarry Finger } 585f1d2b4d3SLarry Finger 586f1d2b4d3SLarry Finger static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask) 587f1d2b4d3SLarry Finger { 588f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 589f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 590f1d2b4d3SLarry Finger 591f1d2b4d3SLarry Finger return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask); 592f1d2b4d3SLarry Finger } 593f1d2b4d3SLarry Finger 594f1d2b4d3SLarry Finger static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, 595f1d2b4d3SLarry Finger u32 bit_mask, u32 data) 596f1d2b4d3SLarry Finger { 597f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 598f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 599f1d2b4d3SLarry Finger 600f1d2b4d3SLarry Finger rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data); 601f1d2b4d3SLarry Finger } 602f1d2b4d3SLarry Finger 603f1d2b4d3SLarry Finger static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, 604f1d2b4d3SLarry Finger u32 bit_mask) 605f1d2b4d3SLarry Finger { 606f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 607f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 608f1d2b4d3SLarry Finger 609f1d2b4d3SLarry Finger return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask); 610f1d2b4d3SLarry Finger } 611f1d2b4d3SLarry Finger 612f1d2b4d3SLarry Finger static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id, 613f1d2b4d3SLarry Finger u32 cmd_len, u8 *cmd_buf) 614f1d2b4d3SLarry Finger { 615f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 616f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 617f1d2b4d3SLarry Finger 618f1d2b4d3SLarry Finger rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id, 619f1d2b4d3SLarry Finger cmd_len, cmd_buf); 620f1d2b4d3SLarry Finger } 621f1d2b4d3SLarry Finger 622f1d2b4d3SLarry Finger static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) 623f1d2b4d3SLarry Finger { 624f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; 625f1d2b4d3SLarry Finger switch (disp_type) { 626f1d2b4d3SLarry Finger case BTC_DBG_DISP_COEX_STATISTICS: 627f1d2b4d3SLarry Finger halbtc_display_coex_statistics(btcoexist); 628f1d2b4d3SLarry Finger break; 629f1d2b4d3SLarry Finger case BTC_DBG_DISP_BT_LINK_INFO: 630f1d2b4d3SLarry Finger halbtc_display_bt_link_info(btcoexist); 631f1d2b4d3SLarry Finger break; 632f1d2b4d3SLarry Finger case BTC_DBG_DISP_BT_FW_VER: 633f1d2b4d3SLarry Finger halbtc_display_bt_fw_info(btcoexist); 634f1d2b4d3SLarry Finger break; 635f1d2b4d3SLarry Finger case BTC_DBG_DISP_FW_PWR_MODE_CMD: 636f1d2b4d3SLarry Finger halbtc_display_fw_pwr_mode_cmd(btcoexist); 637f1d2b4d3SLarry Finger break; 638f1d2b4d3SLarry Finger default: 639f1d2b4d3SLarry Finger break; 640f1d2b4d3SLarry Finger } 641f1d2b4d3SLarry Finger } 642f1d2b4d3SLarry Finger 6437937f02dSYan-Hsuan Chuang bool halbtc_under_ips(struct btc_coexist *btcoexist) 6447937f02dSYan-Hsuan Chuang { 6457937f02dSYan-Hsuan Chuang struct rtl_priv *rtlpriv = btcoexist->adapter; 6467937f02dSYan-Hsuan Chuang struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); 6477937f02dSYan-Hsuan Chuang enum rf_pwrstate rtstate; 6487937f02dSYan-Hsuan Chuang 6497937f02dSYan-Hsuan Chuang if (ppsc->inactiveps) { 6507937f02dSYan-Hsuan Chuang rtstate = ppsc->rfpwr_state; 6517937f02dSYan-Hsuan Chuang 6527937f02dSYan-Hsuan Chuang if (rtstate != ERFON && 6537937f02dSYan-Hsuan Chuang ppsc->rfoff_reason == RF_CHANGE_BY_IPS) { 6547937f02dSYan-Hsuan Chuang return true; 6557937f02dSYan-Hsuan Chuang } 6567937f02dSYan-Hsuan Chuang } 6577937f02dSYan-Hsuan Chuang 6587937f02dSYan-Hsuan Chuang return false; 6597937f02dSYan-Hsuan Chuang } 6607937f02dSYan-Hsuan Chuang 661f1d2b4d3SLarry Finger /***************************************************************** 662f1d2b4d3SLarry Finger * Extern functions called by other module 663f1d2b4d3SLarry Finger *****************************************************************/ 664f1d2b4d3SLarry Finger bool exhalbtc_initlize_variables(struct rtl_priv *adapter) 665f1d2b4d3SLarry Finger { 666f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = &gl_bt_coexist; 667f1d2b4d3SLarry Finger 668f1d2b4d3SLarry Finger btcoexist->statistics.cnt_bind++; 669f1d2b4d3SLarry Finger 670f1d2b4d3SLarry Finger halbtc_dbg_init(); 671f1d2b4d3SLarry Finger 672f1d2b4d3SLarry Finger if (btcoexist->binded) 673f1d2b4d3SLarry Finger return false; 674f1d2b4d3SLarry Finger else 675f1d2b4d3SLarry Finger btcoexist->binded = true; 676f1d2b4d3SLarry Finger 677f1d2b4d3SLarry Finger btcoexist->chip_interface = BTC_INTF_UNKNOWN; 678f1d2b4d3SLarry Finger 679f1d2b4d3SLarry Finger if (NULL == btcoexist->adapter) 680f1d2b4d3SLarry Finger btcoexist->adapter = adapter; 681f1d2b4d3SLarry Finger 682f1d2b4d3SLarry Finger btcoexist->stack_info.profile_notified = false; 683f1d2b4d3SLarry Finger 684f1d2b4d3SLarry Finger btcoexist->btc_read_1byte = halbtc_read_1byte; 685f1d2b4d3SLarry Finger btcoexist->btc_write_1byte = halbtc_write_1byte; 686f1d2b4d3SLarry Finger btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte; 687f1d2b4d3SLarry Finger btcoexist->btc_read_2byte = halbtc_read_2byte; 688f1d2b4d3SLarry Finger btcoexist->btc_write_2byte = halbtc_write_2byte; 689f1d2b4d3SLarry Finger btcoexist->btc_read_4byte = halbtc_read_4byte; 690f1d2b4d3SLarry Finger btcoexist->btc_write_4byte = halbtc_write_4byte; 691f1d2b4d3SLarry Finger 692f1d2b4d3SLarry Finger btcoexist->btc_set_bb_reg = halbtc_set_bbreg; 693f1d2b4d3SLarry Finger btcoexist->btc_get_bb_reg = halbtc_get_bbreg; 694f1d2b4d3SLarry Finger 695f1d2b4d3SLarry Finger btcoexist->btc_set_rf_reg = halbtc_set_rfreg; 696f1d2b4d3SLarry Finger btcoexist->btc_get_rf_reg = halbtc_get_rfreg; 697f1d2b4d3SLarry Finger 698f1d2b4d3SLarry Finger btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd; 699f1d2b4d3SLarry Finger btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg; 700f1d2b4d3SLarry Finger 701f1d2b4d3SLarry Finger btcoexist->btc_get = halbtc_get; 702f1d2b4d3SLarry Finger btcoexist->btc_set = halbtc_set; 703f1d2b4d3SLarry Finger 704f1d2b4d3SLarry Finger btcoexist->bt_info.bt_ctrl_buf_size = false; 705f1d2b4d3SLarry Finger btcoexist->bt_info.agg_buf_size = 5; 706f1d2b4d3SLarry Finger 707f1d2b4d3SLarry Finger btcoexist->bt_info.increase_scan_dev_num = false; 708f1d2b4d3SLarry Finger return true; 709f1d2b4d3SLarry Finger } 710f1d2b4d3SLarry Finger 7110199103eSYan-Hsuan Chuang bool exhalbtc_bind_bt_coex_withadapter(void *adapter) 7120199103eSYan-Hsuan Chuang { 7130199103eSYan-Hsuan Chuang struct btc_coexist *btcoexist = &gl_bt_coexist; 7140199103eSYan-Hsuan Chuang struct rtl_priv *rtlpriv = adapter; 7150199103eSYan-Hsuan Chuang u8 ant_num = 2, chip_type, single_ant_path = 0; 7160199103eSYan-Hsuan Chuang 7170199103eSYan-Hsuan Chuang if (btcoexist->binded) 7180199103eSYan-Hsuan Chuang return false; 7190199103eSYan-Hsuan Chuang 7200199103eSYan-Hsuan Chuang btcoexist->binded = true; 7210199103eSYan-Hsuan Chuang btcoexist->statistics.cnt_bind++; 7220199103eSYan-Hsuan Chuang 7230199103eSYan-Hsuan Chuang btcoexist->adapter = adapter; 7240199103eSYan-Hsuan Chuang 7250199103eSYan-Hsuan Chuang btcoexist->stack_info.profile_notified = false; 7260199103eSYan-Hsuan Chuang 7270199103eSYan-Hsuan Chuang btcoexist->bt_info.bt_ctrl_agg_buf_size = false; 7280199103eSYan-Hsuan Chuang btcoexist->bt_info.agg_buf_size = 5; 7290199103eSYan-Hsuan Chuang 7300199103eSYan-Hsuan Chuang btcoexist->bt_info.increase_scan_dev_num = false; 7310199103eSYan-Hsuan Chuang btcoexist->bt_info.miracast_plus_bt = false; 7320199103eSYan-Hsuan Chuang 7330199103eSYan-Hsuan Chuang chip_type = rtl_get_hwpg_bt_type(rtlpriv); 7340199103eSYan-Hsuan Chuang exhalbtc_set_chip_type(chip_type); 7350199103eSYan-Hsuan Chuang ant_num = rtl_get_hwpg_ant_num(rtlpriv); 7360199103eSYan-Hsuan Chuang exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num); 7370199103eSYan-Hsuan Chuang 7380199103eSYan-Hsuan Chuang /* set default antenna position to main port */ 7390199103eSYan-Hsuan Chuang btcoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT; 7400199103eSYan-Hsuan Chuang 7410199103eSYan-Hsuan Chuang single_ant_path = rtl_get_hwpg_single_ant_path(rtlpriv); 7420199103eSYan-Hsuan Chuang exhalbtc_set_single_ant_path(single_ant_path); 7430199103eSYan-Hsuan Chuang 7440199103eSYan-Hsuan Chuang if (rtl_get_hwpg_package_type(rtlpriv) == 0) 7450199103eSYan-Hsuan Chuang btcoexist->board_info.tfbga_package = false; 7460199103eSYan-Hsuan Chuang else if (rtl_get_hwpg_package_type(rtlpriv) == 1) 7470199103eSYan-Hsuan Chuang btcoexist->board_info.tfbga_package = false; 7480199103eSYan-Hsuan Chuang else 7490199103eSYan-Hsuan Chuang btcoexist->board_info.tfbga_package = true; 7500199103eSYan-Hsuan Chuang 7510199103eSYan-Hsuan Chuang if (btcoexist->board_info.tfbga_package) 7520199103eSYan-Hsuan Chuang RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 7530199103eSYan-Hsuan Chuang "[BTCoex], Package Type = TFBGA\n"); 7540199103eSYan-Hsuan Chuang else 7550199103eSYan-Hsuan Chuang RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 7560199103eSYan-Hsuan Chuang "[BTCoex], Package Type = Non-TFBGA\n"); 7570199103eSYan-Hsuan Chuang 7580199103eSYan-Hsuan Chuang return true; 7590199103eSYan-Hsuan Chuang } 7600199103eSYan-Hsuan Chuang 76160f44100SYan-Hsuan Chuang void exhalbtc_power_on_setting(struct btc_coexist *btcoexist) 76260f44100SYan-Hsuan Chuang { 76360f44100SYan-Hsuan Chuang if (!halbtc_is_bt_coexist_available(btcoexist)) 76460f44100SYan-Hsuan Chuang return; 76560f44100SYan-Hsuan Chuang 76660f44100SYan-Hsuan Chuang btcoexist->statistics.cnt_power_on++; 76760f44100SYan-Hsuan Chuang 76860f44100SYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 76960f44100SYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 77060f44100SYan-Hsuan Chuang ex_btc8723b2ant_power_on_setting(btcoexist); 77160f44100SYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 77260f44100SYan-Hsuan Chuang ex_btc8723b1ant_power_on_setting(btcoexist); 77360f44100SYan-Hsuan Chuang } 77460f44100SYan-Hsuan Chuang } 77560f44100SYan-Hsuan Chuang 7766fbbc82aSYan-Hsuan Chuang void exhalbtc_pre_load_firmware(struct btc_coexist *btcoexist) 7776fbbc82aSYan-Hsuan Chuang { 7786fbbc82aSYan-Hsuan Chuang if (!halbtc_is_bt_coexist_available(btcoexist)) 7796fbbc82aSYan-Hsuan Chuang return; 7806fbbc82aSYan-Hsuan Chuang 7816fbbc82aSYan-Hsuan Chuang btcoexist->statistics.cnt_pre_load_firmware++; 7826fbbc82aSYan-Hsuan Chuang 7836fbbc82aSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 7846fbbc82aSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 7856fbbc82aSYan-Hsuan Chuang ex_btc8723b2ant_pre_load_firmware(btcoexist); 7866fbbc82aSYan-Hsuan Chuang } 7876fbbc82aSYan-Hsuan Chuang } 7886fbbc82aSYan-Hsuan Chuang 789f1d2b4d3SLarry Finger void exhalbtc_init_hw_config(struct btc_coexist *btcoexist) 790f1d2b4d3SLarry Finger { 7917937f02dSYan-Hsuan Chuang bool wifi_only = true; 792f1d2b4d3SLarry Finger 793f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 794f1d2b4d3SLarry Finger return; 795f1d2b4d3SLarry Finger 796f1d2b4d3SLarry Finger btcoexist->statistics.cnt_init_hw_config++; 797f1d2b4d3SLarry Finger 7987937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 7997937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8007937f02dSYan-Hsuan Chuang ex_btc8821a2ant_init_hwconfig(btcoexist); 8017937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8027937f02dSYan-Hsuan Chuang ex_btc8821a1ant_init_hwconfig(btcoexist, wifi_only); 8037937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 8047937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 805f1d2b4d3SLarry Finger ex_btc8723b2ant_init_hwconfig(btcoexist); 8067937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8077937f02dSYan-Hsuan Chuang ex_btc8723b1ant_init_hwconfig(btcoexist, wifi_only); 8087937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723A(btcoexist->adapter)) { 8097937f02dSYan-Hsuan Chuang /* 8723A has no this function */ 8107937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 8117937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8127937f02dSYan-Hsuan Chuang ex_btc8192e2ant_init_hwconfig(btcoexist); 8137937f02dSYan-Hsuan Chuang } 814f1d2b4d3SLarry Finger } 815f1d2b4d3SLarry Finger 816f1d2b4d3SLarry Finger void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist) 817f1d2b4d3SLarry Finger { 818f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 819f1d2b4d3SLarry Finger return; 820f1d2b4d3SLarry Finger 821f1d2b4d3SLarry Finger btcoexist->statistics.cnt_init_coex_dm++; 822f1d2b4d3SLarry Finger 8237937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 8247937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8257937f02dSYan-Hsuan Chuang ex_btc8821a2ant_init_coex_dm(btcoexist); 8267937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8277937f02dSYan-Hsuan Chuang ex_btc8821a1ant_init_coex_dm(btcoexist); 8287937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 8297937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 830f1d2b4d3SLarry Finger ex_btc8723b2ant_init_coex_dm(btcoexist); 8317937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8327937f02dSYan-Hsuan Chuang ex_btc8723b1ant_init_coex_dm(btcoexist); 8337937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 8347937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8357937f02dSYan-Hsuan Chuang ex_btc8192e2ant_init_coex_dm(btcoexist); 8367937f02dSYan-Hsuan Chuang } 837f1d2b4d3SLarry Finger 838f1d2b4d3SLarry Finger btcoexist->initilized = true; 839f1d2b4d3SLarry Finger } 840f1d2b4d3SLarry Finger 841f1d2b4d3SLarry Finger void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type) 842f1d2b4d3SLarry Finger { 843f1d2b4d3SLarry Finger u8 ips_type; 844f1d2b4d3SLarry Finger 845f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 846f1d2b4d3SLarry Finger return; 847f1d2b4d3SLarry Finger btcoexist->statistics.cnt_ips_notify++; 848f1d2b4d3SLarry Finger if (btcoexist->manual_control) 849f1d2b4d3SLarry Finger return; 850f1d2b4d3SLarry Finger 851f1d2b4d3SLarry Finger if (ERFOFF == type) 852f1d2b4d3SLarry Finger ips_type = BTC_IPS_ENTER; 853f1d2b4d3SLarry Finger else 854f1d2b4d3SLarry Finger ips_type = BTC_IPS_LEAVE; 855f1d2b4d3SLarry Finger 8567937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 857f1d2b4d3SLarry Finger 8587937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 8597937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8607937f02dSYan-Hsuan Chuang ex_btc8821a2ant_ips_notify(btcoexist, ips_type); 8617937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8627937f02dSYan-Hsuan Chuang ex_btc8821a1ant_ips_notify(btcoexist, ips_type); 8637937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 8647937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 865f1d2b4d3SLarry Finger ex_btc8723b2ant_ips_notify(btcoexist, ips_type); 8667937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8677937f02dSYan-Hsuan Chuang ex_btc8723b1ant_ips_notify(btcoexist, ips_type); 8687937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 8697937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8707937f02dSYan-Hsuan Chuang ex_btc8192e2ant_ips_notify(btcoexist, ips_type); 8717937f02dSYan-Hsuan Chuang } 872f1d2b4d3SLarry Finger 8737937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 874f1d2b4d3SLarry Finger } 875f1d2b4d3SLarry Finger 876f1d2b4d3SLarry Finger void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type) 877f1d2b4d3SLarry Finger { 878f1d2b4d3SLarry Finger u8 lps_type; 879f1d2b4d3SLarry Finger 880f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 881f1d2b4d3SLarry Finger return; 882f1d2b4d3SLarry Finger btcoexist->statistics.cnt_lps_notify++; 883f1d2b4d3SLarry Finger if (btcoexist->manual_control) 884f1d2b4d3SLarry Finger return; 885f1d2b4d3SLarry Finger 886f1d2b4d3SLarry Finger if (EACTIVE == type) 887f1d2b4d3SLarry Finger lps_type = BTC_LPS_DISABLE; 888f1d2b4d3SLarry Finger else 889f1d2b4d3SLarry Finger lps_type = BTC_LPS_ENABLE; 890f1d2b4d3SLarry Finger 8917937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 8927937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 8937937f02dSYan-Hsuan Chuang ex_btc8821a2ant_lps_notify(btcoexist, lps_type); 8947937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 8957937f02dSYan-Hsuan Chuang ex_btc8821a1ant_lps_notify(btcoexist, lps_type); 8967937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 8977937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 898f1d2b4d3SLarry Finger ex_btc8723b2ant_lps_notify(btcoexist, lps_type); 8997937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 9007937f02dSYan-Hsuan Chuang ex_btc8723b1ant_lps_notify(btcoexist, lps_type); 9017937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 9027937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 9037937f02dSYan-Hsuan Chuang ex_btc8192e2ant_lps_notify(btcoexist, lps_type); 9047937f02dSYan-Hsuan Chuang } 905f1d2b4d3SLarry Finger } 906f1d2b4d3SLarry Finger 907f1d2b4d3SLarry Finger void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type) 908f1d2b4d3SLarry Finger { 909f1d2b4d3SLarry Finger u8 scan_type; 910f1d2b4d3SLarry Finger 911f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 912f1d2b4d3SLarry Finger return; 913f1d2b4d3SLarry Finger btcoexist->statistics.cnt_scan_notify++; 914f1d2b4d3SLarry Finger if (btcoexist->manual_control) 915f1d2b4d3SLarry Finger return; 916f1d2b4d3SLarry Finger 917f1d2b4d3SLarry Finger if (type) 918f1d2b4d3SLarry Finger scan_type = BTC_SCAN_START; 919f1d2b4d3SLarry Finger else 920f1d2b4d3SLarry Finger scan_type = BTC_SCAN_FINISH; 921f1d2b4d3SLarry Finger 9227937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 923f1d2b4d3SLarry Finger 9247937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 9257937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 9267937f02dSYan-Hsuan Chuang ex_btc8821a2ant_scan_notify(btcoexist, scan_type); 9277937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 9287937f02dSYan-Hsuan Chuang ex_btc8821a1ant_scan_notify(btcoexist, scan_type); 9297937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 9307937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 931f1d2b4d3SLarry Finger ex_btc8723b2ant_scan_notify(btcoexist, scan_type); 9327937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 9337937f02dSYan-Hsuan Chuang ex_btc8723b1ant_scan_notify(btcoexist, scan_type); 9347937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 9357937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 9367937f02dSYan-Hsuan Chuang ex_btc8192e2ant_scan_notify(btcoexist, scan_type); 9377937f02dSYan-Hsuan Chuang } 938f1d2b4d3SLarry Finger 9397937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 940f1d2b4d3SLarry Finger } 941f1d2b4d3SLarry Finger 942f1d2b4d3SLarry Finger void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action) 943f1d2b4d3SLarry Finger { 944f1d2b4d3SLarry Finger u8 asso_type; 945f1d2b4d3SLarry Finger 946f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 947f1d2b4d3SLarry Finger return; 948f1d2b4d3SLarry Finger btcoexist->statistics.cnt_connect_notify++; 949f1d2b4d3SLarry Finger if (btcoexist->manual_control) 950f1d2b4d3SLarry Finger return; 951f1d2b4d3SLarry Finger 952f1d2b4d3SLarry Finger if (action) 953f1d2b4d3SLarry Finger asso_type = BTC_ASSOCIATE_START; 954f1d2b4d3SLarry Finger else 955f1d2b4d3SLarry Finger asso_type = BTC_ASSOCIATE_FINISH; 956f1d2b4d3SLarry Finger 9577937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 958f1d2b4d3SLarry Finger 9597937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 9607937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 9617937f02dSYan-Hsuan Chuang ex_btc8821a2ant_connect_notify(btcoexist, asso_type); 9627937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 9637937f02dSYan-Hsuan Chuang ex_btc8821a1ant_connect_notify(btcoexist, asso_type); 9647937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 9657937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 966f1d2b4d3SLarry Finger ex_btc8723b2ant_connect_notify(btcoexist, asso_type); 9677937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 9687937f02dSYan-Hsuan Chuang ex_btc8723b1ant_connect_notify(btcoexist, asso_type); 9697937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 9707937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 9717937f02dSYan-Hsuan Chuang ex_btc8192e2ant_connect_notify(btcoexist, asso_type); 9727937f02dSYan-Hsuan Chuang } 9737937f02dSYan-Hsuan Chuang 9747937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 975f1d2b4d3SLarry Finger } 976f1d2b4d3SLarry Finger 977f1d2b4d3SLarry Finger void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist, 978f1d2b4d3SLarry Finger enum rt_media_status media_status) 979f1d2b4d3SLarry Finger { 980f1d2b4d3SLarry Finger u8 status; 981f1d2b4d3SLarry Finger 982f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 983f1d2b4d3SLarry Finger return; 984f1d2b4d3SLarry Finger btcoexist->statistics.cnt_media_status_notify++; 985f1d2b4d3SLarry Finger if (btcoexist->manual_control) 986f1d2b4d3SLarry Finger return; 987f1d2b4d3SLarry Finger 988f1d2b4d3SLarry Finger if (RT_MEDIA_CONNECT == media_status) 989f1d2b4d3SLarry Finger status = BTC_MEDIA_CONNECT; 990f1d2b4d3SLarry Finger else 991f1d2b4d3SLarry Finger status = BTC_MEDIA_DISCONNECT; 992f1d2b4d3SLarry Finger 9937937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 994f1d2b4d3SLarry Finger 9957937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 9967937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 9977937f02dSYan-Hsuan Chuang ex_btc8821a2ant_media_status_notify(btcoexist, status); 9987937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 9997937f02dSYan-Hsuan Chuang ex_btc8821a1ant_media_status_notify(btcoexist, status); 10007937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 10017937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10027937f02dSYan-Hsuan Chuang ex_btc8723b2ant_media_status_notify(btcoexist, status); 10037937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 10047937f02dSYan-Hsuan Chuang ex_btc8723b1ant_media_status_notify(btcoexist, status); 10057937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 10067937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10077937f02dSYan-Hsuan Chuang ex_btc8192e2ant_media_status_notify(btcoexist, status); 10087937f02dSYan-Hsuan Chuang } 10097937f02dSYan-Hsuan Chuang 10107937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 1011f1d2b4d3SLarry Finger } 1012f1d2b4d3SLarry Finger 1013f1d2b4d3SLarry Finger void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type) 1014f1d2b4d3SLarry Finger { 1015f1d2b4d3SLarry Finger u8 packet_type; 1016f1d2b4d3SLarry Finger 1017f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1018f1d2b4d3SLarry Finger return; 1019f1d2b4d3SLarry Finger btcoexist->statistics.cnt_special_packet_notify++; 1020f1d2b4d3SLarry Finger if (btcoexist->manual_control) 1021f1d2b4d3SLarry Finger return; 1022f1d2b4d3SLarry Finger 10237937f02dSYan-Hsuan Chuang if (pkt_type == PACKET_DHCP) { 1024f1d2b4d3SLarry Finger packet_type = BTC_PACKET_DHCP; 10257937f02dSYan-Hsuan Chuang } else if (pkt_type == PACKET_EAPOL) { 10267937f02dSYan-Hsuan Chuang packet_type = BTC_PACKET_EAPOL; 10277937f02dSYan-Hsuan Chuang } else if (pkt_type == PACKET_ARP) { 10287937f02dSYan-Hsuan Chuang packet_type = BTC_PACKET_ARP; 10297937f02dSYan-Hsuan Chuang } else { 10307937f02dSYan-Hsuan Chuang packet_type = BTC_PACKET_UNKNOWN; 10317937f02dSYan-Hsuan Chuang return; 10327937f02dSYan-Hsuan Chuang } 1033f1d2b4d3SLarry Finger 10347937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 1035f1d2b4d3SLarry Finger 10367937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 10377937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10387937f02dSYan-Hsuan Chuang ex_btc8821a2ant_special_packet_notify(btcoexist, 10397937f02dSYan-Hsuan Chuang packet_type); 10407937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 10417937f02dSYan-Hsuan Chuang ex_btc8821a1ant_special_packet_notify(btcoexist, 10427937f02dSYan-Hsuan Chuang packet_type); 10437937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 10447937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 1045f1d2b4d3SLarry Finger ex_btc8723b2ant_special_packet_notify(btcoexist, 1046f1d2b4d3SLarry Finger packet_type); 10477937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 10487937f02dSYan-Hsuan Chuang ex_btc8723b1ant_special_packet_notify(btcoexist, 10497937f02dSYan-Hsuan Chuang packet_type); 10507937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 10517937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10527937f02dSYan-Hsuan Chuang ex_btc8192e2ant_special_packet_notify(btcoexist, 10537937f02dSYan-Hsuan Chuang packet_type); 10547937f02dSYan-Hsuan Chuang } 1055f1d2b4d3SLarry Finger 10567937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 1057f1d2b4d3SLarry Finger } 1058f1d2b4d3SLarry Finger 1059f1d2b4d3SLarry Finger void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist, 1060f1d2b4d3SLarry Finger u8 *tmp_buf, u8 length) 1061f1d2b4d3SLarry Finger { 1062f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1063f1d2b4d3SLarry Finger return; 1064f1d2b4d3SLarry Finger btcoexist->statistics.cnt_bt_info_notify++; 1065f1d2b4d3SLarry Finger 10667937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 10677937f02dSYan-Hsuan Chuang 10687937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 10697937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10707937f02dSYan-Hsuan Chuang ex_btc8821a2ant_bt_info_notify(btcoexist, tmp_buf, 10717937f02dSYan-Hsuan Chuang length); 10727937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 10737937f02dSYan-Hsuan Chuang ex_btc8821a1ant_bt_info_notify(btcoexist, tmp_buf, 10747937f02dSYan-Hsuan Chuang length); 10757937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 10767937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10777937f02dSYan-Hsuan Chuang ex_btc8723b2ant_bt_info_notify(btcoexist, tmp_buf, 10787937f02dSYan-Hsuan Chuang length); 10797937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 10807937f02dSYan-Hsuan Chuang ex_btc8723b1ant_bt_info_notify(btcoexist, tmp_buf, 10817937f02dSYan-Hsuan Chuang length); 10827937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 10837937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 10847937f02dSYan-Hsuan Chuang ex_btc8192e2ant_bt_info_notify(btcoexist, tmp_buf, 10857937f02dSYan-Hsuan Chuang length); 10867937f02dSYan-Hsuan Chuang } 10877937f02dSYan-Hsuan Chuang 10887937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 10897937f02dSYan-Hsuan Chuang } 10907937f02dSYan-Hsuan Chuang 10917937f02dSYan-Hsuan Chuang void exhalbtc_rf_status_notify(struct btc_coexist *btcoexist, u8 type) 10927937f02dSYan-Hsuan Chuang { 10937937f02dSYan-Hsuan Chuang if (!halbtc_is_bt_coexist_available(btcoexist)) 10947937f02dSYan-Hsuan Chuang return; 10957937f02dSYan-Hsuan Chuang 10967937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 10977937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 10987937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 1) 10997937f02dSYan-Hsuan Chuang ex_btc8723b1ant_rf_status_notify(btcoexist, type); 11007937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 11017937f02dSYan-Hsuan Chuang } 1102f1d2b4d3SLarry Finger } 1103f1d2b4d3SLarry Finger 1104f1d2b4d3SLarry Finger void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type) 1105f1d2b4d3SLarry Finger { 1106f1d2b4d3SLarry Finger u8 stack_op_type; 1107f1d2b4d3SLarry Finger 1108f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1109f1d2b4d3SLarry Finger return; 1110f1d2b4d3SLarry Finger btcoexist->statistics.cnt_stack_operation_notify++; 1111f1d2b4d3SLarry Finger if (btcoexist->manual_control) 1112f1d2b4d3SLarry Finger return; 1113f1d2b4d3SLarry Finger 11147937f02dSYan-Hsuan Chuang if ((type == HCI_BT_OP_INQUIRY_START) || 11157937f02dSYan-Hsuan Chuang (type == HCI_BT_OP_PAGING_START) || 11167937f02dSYan-Hsuan Chuang (type == HCI_BT_OP_PAIRING_START)) { 11177937f02dSYan-Hsuan Chuang stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_START; 11187937f02dSYan-Hsuan Chuang } else if ((type == HCI_BT_OP_INQUIRY_FINISH) || 11197937f02dSYan-Hsuan Chuang (type == HCI_BT_OP_PAGING_SUCCESS) || 11207937f02dSYan-Hsuan Chuang (type == HCI_BT_OP_PAGING_UNSUCCESS) || 11217937f02dSYan-Hsuan Chuang (type == HCI_BT_OP_PAIRING_FINISH)) { 11227937f02dSYan-Hsuan Chuang stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH; 11237937f02dSYan-Hsuan Chuang } else { 1124f1d2b4d3SLarry Finger stack_op_type = BTC_STACK_OP_NONE; 11257937f02dSYan-Hsuan Chuang } 1126f1d2b4d3SLarry Finger } 1127f1d2b4d3SLarry Finger 1128f1d2b4d3SLarry Finger void exhalbtc_halt_notify(struct btc_coexist *btcoexist) 1129f1d2b4d3SLarry Finger { 1130f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1131f1d2b4d3SLarry Finger return; 1132f1d2b4d3SLarry Finger 11337937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 11347937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 11357937f02dSYan-Hsuan Chuang ex_btc8821a2ant_halt_notify(btcoexist); 11367937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 11377937f02dSYan-Hsuan Chuang ex_btc8821a1ant_halt_notify(btcoexist); 11387937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 11397937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 1140f1d2b4d3SLarry Finger ex_btc8723b2ant_halt_notify(btcoexist); 11417937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 11427937f02dSYan-Hsuan Chuang ex_btc8723b1ant_halt_notify(btcoexist); 11437937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 11447937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 11457937f02dSYan-Hsuan Chuang ex_btc8192e2ant_halt_notify(btcoexist); 11467937f02dSYan-Hsuan Chuang } 11477937f02dSYan-Hsuan Chuang 11487937f02dSYan-Hsuan Chuang btcoexist->binded = false; 1149f1d2b4d3SLarry Finger } 1150f1d2b4d3SLarry Finger 1151f1d2b4d3SLarry Finger void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) 1152f1d2b4d3SLarry Finger { 1153f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1154f1d2b4d3SLarry Finger return; 115586f9ab2eSYan-Hsuan Chuang 115686f9ab2eSYan-Hsuan Chuang /* currently only 1ant we have to do the notification, 115786f9ab2eSYan-Hsuan Chuang * once pnp is notified to sleep state, we have to leave LPS that 115886f9ab2eSYan-Hsuan Chuang * we can sleep normally. 115986f9ab2eSYan-Hsuan Chuang */ 116086f9ab2eSYan-Hsuan Chuang 116186f9ab2eSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 116286f9ab2eSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 1) 116386f9ab2eSYan-Hsuan Chuang ex_btc8723b1ant_pnp_notify(btcoexist, pnp_state); 116486f9ab2eSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 2) 116586f9ab2eSYan-Hsuan Chuang ex_btc8723b2ant_pnp_notify(btcoexist, pnp_state); 116686f9ab2eSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 116786f9ab2eSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 1) 116886f9ab2eSYan-Hsuan Chuang ex_btc8821a1ant_pnp_notify(btcoexist, pnp_state); 116986f9ab2eSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 2) 117086f9ab2eSYan-Hsuan Chuang ex_btc8821a2ant_pnp_notify(btcoexist, pnp_state); 117186f9ab2eSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 117286f9ab2eSYan-Hsuan Chuang } 1173f1d2b4d3SLarry Finger } 1174f1d2b4d3SLarry Finger 11757937f02dSYan-Hsuan Chuang void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist) 1176f1d2b4d3SLarry Finger { 1177f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 11787937f02dSYan-Hsuan Chuang 11797937f02dSYan-Hsuan Chuang if (!halbtc_is_bt_coexist_available(btcoexist)) 11807937f02dSYan-Hsuan Chuang return; 11817937f02dSYan-Hsuan Chuang btcoexist->statistics.cnt_coex_dm_switch++; 11827937f02dSYan-Hsuan Chuang 11837937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 11847937f02dSYan-Hsuan Chuang 11857937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 11867937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 1) { 11877937f02dSYan-Hsuan Chuang btcoexist->stop_coex_dm = true; 11887937f02dSYan-Hsuan Chuang ex_btc8723b1ant_coex_dm_reset(btcoexist); 11897937f02dSYan-Hsuan Chuang exhalbtc_set_ant_num(rtlpriv, 11907937f02dSYan-Hsuan Chuang BT_COEX_ANT_TYPE_DETECTED, 2); 11917937f02dSYan-Hsuan Chuang ex_btc8723b2ant_init_hwconfig(btcoexist); 11927937f02dSYan-Hsuan Chuang ex_btc8723b2ant_init_coex_dm(btcoexist); 11937937f02dSYan-Hsuan Chuang btcoexist->stop_coex_dm = false; 11947937f02dSYan-Hsuan Chuang } 11957937f02dSYan-Hsuan Chuang } 11967937f02dSYan-Hsuan Chuang 11977937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 11987937f02dSYan-Hsuan Chuang } 11997937f02dSYan-Hsuan Chuang 12007937f02dSYan-Hsuan Chuang void exhalbtc_periodical(struct btc_coexist *btcoexist) 12017937f02dSYan-Hsuan Chuang { 1202f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1203f1d2b4d3SLarry Finger return; 1204f1d2b4d3SLarry Finger btcoexist->statistics.cnt_periodical++; 1205f1d2b4d3SLarry Finger 12067937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 1207f1d2b4d3SLarry Finger 12087937f02dSYan-Hsuan Chuang if (IS_HARDWARE_TYPE_8821(btcoexist->adapter)) { 12097937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 12107937f02dSYan-Hsuan Chuang ex_btc8821a2ant_periodical(btcoexist); 12117937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 12127937f02dSYan-Hsuan Chuang if (!halbtc_under_ips(btcoexist)) 12137937f02dSYan-Hsuan Chuang ex_btc8821a1ant_periodical(btcoexist); 12147937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8723B(btcoexist->adapter)) { 12157937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 1216f1d2b4d3SLarry Finger ex_btc8723b2ant_periodical(btcoexist); 12177937f02dSYan-Hsuan Chuang else if (btcoexist->board_info.btdm_ant_num == 1) 12187937f02dSYan-Hsuan Chuang ex_btc8723b1ant_periodical(btcoexist); 12197937f02dSYan-Hsuan Chuang } else if (IS_HARDWARE_TYPE_8192E(btcoexist->adapter)) { 12207937f02dSYan-Hsuan Chuang if (btcoexist->board_info.btdm_ant_num == 2) 12217937f02dSYan-Hsuan Chuang ex_btc8192e2ant_periodical(btcoexist); 12227937f02dSYan-Hsuan Chuang } 1223f1d2b4d3SLarry Finger 12247937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 1225f1d2b4d3SLarry Finger } 1226f1d2b4d3SLarry Finger 1227f1d2b4d3SLarry Finger void exhalbtc_dbg_control(struct btc_coexist *btcoexist, 1228f1d2b4d3SLarry Finger u8 code, u8 len, u8 *data) 1229f1d2b4d3SLarry Finger { 1230f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1231f1d2b4d3SLarry Finger return; 1232f1d2b4d3SLarry Finger btcoexist->statistics.cnt_dbg_ctrl++; 12337937f02dSYan-Hsuan Chuang 12347937f02dSYan-Hsuan Chuang halbtc_leave_low_power(btcoexist); 12357937f02dSYan-Hsuan Chuang 12367937f02dSYan-Hsuan Chuang halbtc_normal_low_power(btcoexist); 12377937f02dSYan-Hsuan Chuang } 12387937f02dSYan-Hsuan Chuang 12397937f02dSYan-Hsuan Chuang void exhalbtc_antenna_detection(struct btc_coexist *btcoexist, u32 cent_freq, 12407937f02dSYan-Hsuan Chuang u32 offset, u32 span, u32 seconds) 12417937f02dSYan-Hsuan Chuang { 12427937f02dSYan-Hsuan Chuang if (!halbtc_is_bt_coexist_available(btcoexist)) 12437937f02dSYan-Hsuan Chuang return; 1244f1d2b4d3SLarry Finger } 1245f1d2b4d3SLarry Finger 1246f1d2b4d3SLarry Finger void exhalbtc_stack_update_profile_info(void) 1247f1d2b4d3SLarry Finger { 1248f1d2b4d3SLarry Finger } 1249f1d2b4d3SLarry Finger 125008aba42fSArnd Bergmann void exhalbtc_update_min_bt_rssi(s8 bt_rssi) 1251f1d2b4d3SLarry Finger { 1252f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = &gl_bt_coexist; 1253f1d2b4d3SLarry Finger 1254f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1255f1d2b4d3SLarry Finger return; 1256f1d2b4d3SLarry Finger 1257f1d2b4d3SLarry Finger btcoexist->stack_info.min_bt_rssi = bt_rssi; 1258f1d2b4d3SLarry Finger } 1259f1d2b4d3SLarry Finger 1260f1d2b4d3SLarry Finger void exhalbtc_set_hci_version(u16 hci_version) 1261f1d2b4d3SLarry Finger { 1262f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = &gl_bt_coexist; 1263f1d2b4d3SLarry Finger 1264f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1265f1d2b4d3SLarry Finger return; 1266f1d2b4d3SLarry Finger 1267f1d2b4d3SLarry Finger btcoexist->stack_info.hci_version = hci_version; 1268f1d2b4d3SLarry Finger } 1269f1d2b4d3SLarry Finger 1270f1d2b4d3SLarry Finger void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version) 1271f1d2b4d3SLarry Finger { 1272f1d2b4d3SLarry Finger struct btc_coexist *btcoexist = &gl_bt_coexist; 1273f1d2b4d3SLarry Finger 1274f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1275f1d2b4d3SLarry Finger return; 1276f1d2b4d3SLarry Finger 1277f1d2b4d3SLarry Finger btcoexist->bt_info.bt_real_fw_ver = bt_patch_version; 1278f1d2b4d3SLarry Finger btcoexist->bt_info.bt_hci_ver = bt_hci_version; 1279f1d2b4d3SLarry Finger } 1280f1d2b4d3SLarry Finger 1281f1d2b4d3SLarry Finger void exhalbtc_set_bt_exist(bool bt_exist) 1282f1d2b4d3SLarry Finger { 1283f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_exist = bt_exist; 1284f1d2b4d3SLarry Finger } 1285f1d2b4d3SLarry Finger 1286f1d2b4d3SLarry Finger void exhalbtc_set_chip_type(u8 chip_type) 1287f1d2b4d3SLarry Finger { 1288f1d2b4d3SLarry Finger switch (chip_type) { 1289f1d2b4d3SLarry Finger default: 1290f1d2b4d3SLarry Finger case BT_2WIRE: 1291f1d2b4d3SLarry Finger case BT_ISSC_3WIRE: 1292f1d2b4d3SLarry Finger case BT_ACCEL: 1293f1d2b4d3SLarry Finger case BT_RTL8756: 1294f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF; 1295f1d2b4d3SLarry Finger break; 1296f1d2b4d3SLarry Finger case BT_CSR_BC4: 1297f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4; 1298f1d2b4d3SLarry Finger break; 1299f1d2b4d3SLarry Finger case BT_CSR_BC8: 1300f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8; 1301f1d2b4d3SLarry Finger break; 1302f1d2b4d3SLarry Finger case BT_RTL8723A: 1303f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A; 1304f1d2b4d3SLarry Finger break; 1305f1d2b4d3SLarry Finger case BT_RTL8821A: 1306f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821; 1307f1d2b4d3SLarry Finger break; 1308f1d2b4d3SLarry Finger case BT_RTL8723B: 1309f1d2b4d3SLarry Finger gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B; 1310f1d2b4d3SLarry Finger break; 1311f1d2b4d3SLarry Finger } 1312f1d2b4d3SLarry Finger } 1313f1d2b4d3SLarry Finger 1314baa17022SLarry Finger void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num) 1315f1d2b4d3SLarry Finger { 1316f1d2b4d3SLarry Finger if (BT_COEX_ANT_TYPE_PG == type) { 1317f1d2b4d3SLarry Finger gl_bt_coexist.board_info.pg_ant_num = ant_num; 1318f1d2b4d3SLarry Finger gl_bt_coexist.board_info.btdm_ant_num = ant_num; 1319baa17022SLarry Finger /* The antenna position: 1320baa17022SLarry Finger * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1. 1321baa17022SLarry Finger * The antenna position should be determined by 1322baa17022SLarry Finger * auto-detect mechanism. 1323baa17022SLarry Finger * The following is assumed to main, 1324baa17022SLarry Finger * and those must be modified 1325baa17022SLarry Finger * if y auto-detect mechanism is ready 1326baa17022SLarry Finger */ 1327baa17022SLarry Finger if ((gl_bt_coexist.board_info.pg_ant_num == 2) && 1328baa17022SLarry Finger (gl_bt_coexist.board_info.btdm_ant_num == 1)) 1329baa17022SLarry Finger gl_bt_coexist.board_info.btdm_ant_pos = 1330baa17022SLarry Finger BTC_ANTENNA_AT_MAIN_PORT; 1331baa17022SLarry Finger else 1332baa17022SLarry Finger gl_bt_coexist.board_info.btdm_ant_pos = 1333baa17022SLarry Finger BTC_ANTENNA_AT_MAIN_PORT; 1334f1d2b4d3SLarry Finger } else if (BT_COEX_ANT_TYPE_ANTDIV == type) { 1335f1d2b4d3SLarry Finger gl_bt_coexist.board_info.btdm_ant_num = ant_num; 1336baa17022SLarry Finger gl_bt_coexist.board_info.btdm_ant_pos = 1337baa17022SLarry Finger BTC_ANTENNA_AT_MAIN_PORT; 1338baa17022SLarry Finger } else if (type == BT_COEX_ANT_TYPE_DETECTED) { 1339baa17022SLarry Finger gl_bt_coexist.board_info.btdm_ant_num = ant_num; 1340baa17022SLarry Finger if (rtlpriv->cfg->mod_params->ant_sel == 1) 1341baa17022SLarry Finger gl_bt_coexist.board_info.btdm_ant_pos = 1342baa17022SLarry Finger BTC_ANTENNA_AT_AUX_PORT; 1343baa17022SLarry Finger else 1344baa17022SLarry Finger gl_bt_coexist.board_info.btdm_ant_pos = 1345baa17022SLarry Finger BTC_ANTENNA_AT_MAIN_PORT; 1346f1d2b4d3SLarry Finger } 1347f1d2b4d3SLarry Finger } 1348f1d2b4d3SLarry Finger 13490199103eSYan-Hsuan Chuang /* Currently used by 8723b only, S0 or S1 */ 13500199103eSYan-Hsuan Chuang void exhalbtc_set_single_ant_path(u8 single_ant_path) 13510199103eSYan-Hsuan Chuang { 13520199103eSYan-Hsuan Chuang gl_bt_coexist.board_info.single_ant_path = single_ant_path; 13530199103eSYan-Hsuan Chuang } 13540199103eSYan-Hsuan Chuang 1355f1d2b4d3SLarry Finger void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist) 1356f1d2b4d3SLarry Finger { 1357f1d2b4d3SLarry Finger struct rtl_priv *rtlpriv = btcoexist->adapter; 1358f1d2b4d3SLarry Finger struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 1359f1d2b4d3SLarry Finger if (!halbtc_is_bt_coexist_available(btcoexist)) 1360f1d2b4d3SLarry Finger return; 1361f1d2b4d3SLarry Finger 1362f1d2b4d3SLarry Finger if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) 1363f1d2b4d3SLarry Finger ex_btc8723b2ant_display_coex_info(btcoexist); 1364f1d2b4d3SLarry Finger } 1365