1 /******************************************************************************
3 * Copyright(c) 2009-2010 Realtek Corporation.
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 *****************************************************************************/
25 #include <linux/vmalloc.h>
26 #include <linux/module.h>
29 #include "halbt_precomp.h"
31 static struct rtl_btc_ops rtl_btc_operation = {
32 .btc_init_variables = rtl92e_btc_init_variables,
33 .btc_init_hal_vars = rtl92e_btc_init_hal_vars,
34 .btc_init_hw_config = rtl92e_btc_init_hw_config,
35 .btc_ips_notify = rtl92e_btc_ips_notify,
36 .btc_lps_notify = rtl_btc_lps_notify,
37 .btc_scan_notify = rtl92e_btc_scan_notify,
38 .btc_connect_notify = rtl92e_btc_connect_notify,
39 .btc_mediastatus_notify = rtl92e_btc_mediastatus_notify,
40 .btc_periodical = rtl92e_btc_periodical,
41 .btc_halt_notify = rtl92e_btc_halt_notify,
42 .btc_btinfo_notify = rtl92e_btc_btinfo_notify,
43 .btc_is_limited_dig = rtl92e_btc_is_limited_dig,
44 .btc_is_disable_edca_turbo = rtl92e_btc_is_disable_edca_turbo,
45 .btc_is_bt_disabled = rtl92e_btc_is_bt_disabled,
46 .btc_special_packet_notify = rtl_btc_special_packet_notify,
49 void rtl92e_btc_init_variables(struct rtl_priv *rtlpriv)
51 exhalbtc92e_initlize_variables(rtlpriv);
54 void rtl92e_btc_init_hal_vars(struct rtl_priv *rtlpriv)
59 ant_num = rtl92e_get_hwpg_ant_num(rtlpriv);
60 RT_TRACE(COMP_INIT, DBG_DMESG, "antNum is %d\n", ant_num);
62 bt_exist = rtl92e_get_hwpg_bt_exist(rtlpriv);
63 RT_TRACE(COMP_INIT, DBG_DMESG, "bt_exist is %d\n", bt_exist);
64 exhalbtc92e_set_bt_exist(bt_exist);
66 bt_type = rtl92e_get_hwpg_bt_type(rtlpriv);
67 RT_TRACE(COMP_INIT, DBG_DMESG, "bt_type is %d\n", bt_type);
68 exhalbtc92e_set_chip_type(bt_type);
70 exhalbtc92e_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
73 void rtl92e_btc_init_hw_config(struct rtl_priv *rtlpriv)
75 exhalbtc92e_init_hw_config(&gl92e_bt_coexist);
76 exhalbtc92e_init_coex_dm(&gl92e_bt_coexist);
79 void rtl92e_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
81 exhalbtc92e_ips_notify(&gl92e_bt_coexist, type);
84 void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type)
86 exhalbtc92e_lps_notify(&gl92e_bt_coexist, type);
89 void rtl92e_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
91 exhalbtc92e_scan_notify(&gl92e_bt_coexist, scantype);
94 void rtl92e_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
96 exhalbtc92e_connect_notify(&gl92e_bt_coexist, action);
99 void rtl92e_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
100 enum rt_media_status mstatus)
102 exhalbtc92e_mediastatus_notify(&gl92e_bt_coexist, mstatus);
105 void rtl92e_btc_periodical(struct rtl_priv *rtlpriv)
107 exhalbtc92e_periodical(&gl92e_bt_coexist);
110 void rtl92e_btc_halt_notify(void)
112 exhalbtc92e_halt_notify(&gl92e_bt_coexist);
115 void rtl92e_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
117 exhalbtc92e_bt_info_notify(&gl92e_bt_coexist, tmp_buf, length);
120 bool rtl92e_btc_is_limited_dig(struct rtl_priv *rtlpriv)
122 return gl92e_bt_coexist.bt_info.limited_dig;
125 bool rtl92e_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
127 bool bt_change_edca = false;
129 u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b;
131 u32 edca_addr = 0x504;
133 cur_edca_val = rtl_read_dword(rtlpriv, edca_addr);
134 if (halbtc92e_is_wifi_uplink(rtlpriv)) {
135 if (cur_edca_val != edca_bt_hs_uplink) {
136 edca_hs = edca_bt_hs_uplink;
137 bt_change_edca = true;
140 if (cur_edca_val != edca_bt_hs_downlink) {
141 edca_hs = edca_bt_hs_downlink;
142 bt_change_edca = true;
147 rtl_write_dword(rtlpriv, edca_addr, edca_hs);
152 bool rtl92e_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
154 /* It seems 'bt_disabled' is never be initialized or set. */
155 if (gl92e_bt_coexist.bt_info.bt_disabled)
161 void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type)
163 return exhalbtc92e_special_packet_notify(&gl92e_bt_coexist, pkt_type);
166 struct rtl_btc_ops *stg_rtl_btc_get_ops_pointer(void)
168 return &rtl_btc_operation;
170 EXPORT_SYMBOL(stg_rtl_btc_get_ops_pointer);
172 u8 rtl92e_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
176 if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
183 u8 rtl92e_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
185 return rtlpriv->btcoexist.btc_info.btcoexist;
188 u8 rtl92e_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
190 return rtlpriv->btcoexist.btc_info.bt_type;