1/****************************************************************************** 2 * 3 * Copyright(c) 2009-2013 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * The full GNU General Public License is included in this distribution in the 15 * file called LICENSE. 16 * 17 * Contact Information: 18 * wlanfae <wlanfae@realtek.com> 19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20 * Hsinchu 300, Taiwan. 21 * 22 * Larry Finger <Larry.Finger@lwfinger.net> 23 * 24 *****************************************************************************/ 25#include "../wifi.h" 26#include <linux/vmalloc.h> 27#include <linux/module.h> 28 29#include "rtl_btc.h" 30#include "halbt_precomp.h" 31 32static struct rtl_btc_ops rtl_btc_operation = { 33 .btc_init_variables = rtl_btc_init_variables, 34 .btc_init_hal_vars = rtl_btc_init_hal_vars, 35 .btc_init_hw_config = rtl_btc_init_hw_config, 36 .btc_ips_notify = rtl_btc_ips_notify, 37 .btc_lps_notify = rtl_btc_lps_notify, 38 .btc_scan_notify = rtl_btc_scan_notify, 39 .btc_connect_notify = rtl_btc_connect_notify, 40 .btc_mediastatus_notify = rtl_btc_mediastatus_notify, 41 .btc_periodical = rtl_btc_periodical, 42 .btc_halt_notify = rtl_btc_halt_notify, 43 .btc_btinfo_notify = rtl_btc_btinfo_notify, 44 .btc_is_limited_dig = rtl_btc_is_limited_dig, 45 .btc_is_disable_edca_turbo = rtl_btc_is_disable_edca_turbo, 46 .btc_is_bt_disabled = rtl_btc_is_bt_disabled, 47 .btc_special_packet_notify = rtl_btc_special_packet_notify, 48}; 49 50void rtl_btc_init_variables(struct rtl_priv *rtlpriv) 51{ 52 exhalbtc_initlize_variables(rtlpriv); 53} 54 55void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv) 56{ 57 u8 ant_num; 58 u8 bt_exist; 59 u8 bt_type; 60 61 ant_num = rtl_get_hwpg_ant_num(rtlpriv); 62 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 63 "%s, antNum is %d\n", __func__, ant_num); 64 65 bt_exist = rtl_get_hwpg_bt_exist(rtlpriv); 66 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 67 "%s, bt_exist is %d\n", __func__, bt_exist); 68 exhalbtc_set_bt_exist(bt_exist); 69 70 bt_type = rtl_get_hwpg_bt_type(rtlpriv); 71 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%s, bt_type is %d\n", 72 __func__, bt_type); 73 exhalbtc_set_chip_type(bt_type); 74 75 if (rtlpriv->cfg->mod_params->ant_sel == 1) 76 exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_DETECTED, 1); 77 else 78 exhalbtc_set_ant_num(rtlpriv, BT_COEX_ANT_TYPE_PG, ant_num); 79} 80 81void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv) 82{ 83 exhalbtc_init_hw_config(&gl_bt_coexist); 84 exhalbtc_init_coex_dm(&gl_bt_coexist); 85} 86 87void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type) 88{ 89 exhalbtc_ips_notify(&gl_bt_coexist, type); 90} 91 92void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type) 93{ 94 exhalbtc_lps_notify(&gl_bt_coexist, type); 95} 96 97void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype) 98{ 99 exhalbtc_scan_notify(&gl_bt_coexist, scantype); 100} 101 102void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action) 103{ 104 exhalbtc_connect_notify(&gl_bt_coexist, action); 105} 106 107void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv, 108 enum rt_media_status mstatus) 109{ 110 exhalbtc_mediastatus_notify(&gl_bt_coexist, mstatus); 111} 112 113void rtl_btc_periodical(struct rtl_priv *rtlpriv) 114{ 115 /*rtl_bt_dm_monitor();*/ 116 exhalbtc_periodical(&gl_bt_coexist); 117} 118 119void rtl_btc_halt_notify(void) 120{ 121 exhalbtc_halt_notify(&gl_bt_coexist); 122} 123 124void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length) 125{ 126 exhalbtc_bt_info_notify(&gl_bt_coexist, tmp_buf, length); 127} 128 129bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv) 130{ 131 return gl_bt_coexist.bt_info.limited_dig; 132} 133 134bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv) 135{ 136 bool bt_change_edca = false; 137 u32 cur_edca_val; 138 u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b; 139 u32 edca_hs; 140 u32 edca_addr = 0x504; 141 142 cur_edca_val = rtl_read_dword(rtlpriv, edca_addr); 143 if (halbtc_is_wifi_uplink(rtlpriv)) { 144 if (cur_edca_val != edca_bt_hs_uplink) { 145 edca_hs = edca_bt_hs_uplink; 146 bt_change_edca = true; 147 } 148 } else { 149 if (cur_edca_val != edca_bt_hs_downlink) { 150 edca_hs = edca_bt_hs_downlink; 151 bt_change_edca = true; 152 } 153 } 154 155 if (bt_change_edca) 156 rtl_write_dword(rtlpriv, edca_addr, edca_hs); 157 158 return true; 159} 160 161bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv) 162{ 163 /* It seems 'bt_disabled' is never be initialized or set. */ 164 if (gl_bt_coexist.bt_info.bt_disabled) 165 return true; 166 else 167 return false; 168} 169 170void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type) 171{ 172 return exhalbtc_special_packet_notify(&gl_bt_coexist, pkt_type); 173} 174 175struct rtl_btc_ops *rtl_btc_get_ops_pointer(void) 176{ 177 return &rtl_btc_operation; 178} 179EXPORT_SYMBOL(rtl_btc_get_ops_pointer); 180 181u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv) 182{ 183 u8 num; 184 185 if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2) 186 num = 2; 187 else 188 num = 1; 189 190 return num; 191} 192 193enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw) 194{ 195 struct rtl_priv *rtlpriv = rtl_priv(hw); 196 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 197 enum rt_media_status m_status = RT_MEDIA_DISCONNECT; 198 199 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0; 200 201 if (bibss || rtlpriv->mac80211.link_state >= MAC80211_LINKED) 202 m_status = RT_MEDIA_CONNECT; 203 204 return m_status; 205} 206 207u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv) 208{ 209 return rtlpriv->btcoexist.btc_info.btcoexist; 210} 211 212u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv) 213{ 214 return rtlpriv->btcoexist.btc_info.bt_type; 215} 216 217MODULE_AUTHOR("Page He <page_he@realsil.com.cn>"); 218MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); 219MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>"); 220MODULE_LICENSE("GPL"); 221MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core"); 222 223static int __init rtl_btcoexist_module_init(void) 224{ 225 return 0; 226} 227 228static void __exit rtl_btcoexist_module_exit(void) 229{ 230 return; 231} 232 233module_init(rtl_btcoexist_module_init); 234module_exit(rtl_btcoexist_module_exit); 235