Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[deliverable/linux.git] / drivers / staging / rtl8192ee / btcoexist / rtl_btc.c
CommitLineData
e22f4eda
LF
1/******************************************************************************
2 *
3 * Copyright(c) 2009-2010 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 <linux/vmalloc.h>
26#include <linux/module.h>
27
28#include "rtl_btc.h"
29#include "halbt_precomp.h"
30
31static 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,
47};
48
49void rtl92e_btc_init_variables(struct rtl_priv *rtlpriv)
50{
51 exhalbtc92e_initlize_variables(rtlpriv);
52}
53
54void rtl92e_btc_init_hal_vars(struct rtl_priv *rtlpriv)
55{
56 u8 ant_num;
57 u8 bt_exist;
58 u8 bt_type;
59 ant_num = rtl92e_get_hwpg_ant_num(rtlpriv);
60 RT_TRACE(COMP_INIT, DBG_DMESG,
61 ("%s, antNum is %d\n", __func__, ant_num));
62
63 bt_exist = rtl92e_get_hwpg_bt_exist(rtlpriv);
64 RT_TRACE(COMP_INIT, DBG_DMESG,
65 ("%s, bt_exist is %d\n", __func__, bt_exist));
66 exhalbtc92e_set_bt_exist(bt_exist);
67
68 bt_type = rtl92e_get_hwpg_bt_type(rtlpriv);
69 RT_TRACE(COMP_INIT, DBG_DMESG,
70 ("%s, bt_type is %d\n", __func__, bt_type));
71 exhalbtc92e_set_chip_type(bt_type);
72
73 exhalbtc92e_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
74}
75
76void rtl92e_btc_init_hw_config(struct rtl_priv *rtlpriv)
77{
78 exhalbtc92e_init_hw_config(&gl92e_bt_coexist);
79 exhalbtc92e_init_coex_dm(&gl92e_bt_coexist);
80}
81
82void rtl92e_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
83{
84 exhalbtc92e_ips_notify(&gl92e_bt_coexist, type);
85}
86
87void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type)
88{
89 exhalbtc92e_lps_notify(&gl92e_bt_coexist, type);
90}
91
92void rtl92e_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
93{
94 exhalbtc92e_scan_notify(&gl92e_bt_coexist, scantype);
95}
96
97void rtl92e_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
98{
99 exhalbtc92e_connect_notify(&gl92e_bt_coexist, action);
100}
101
102void rtl92e_btc_mediastatus_notify(struct rtl_priv *rtlpriv,
103 enum rt_media_status mstatus)
104{
105 exhalbtc92e_mediastatus_notify(&gl92e_bt_coexist, mstatus);
106}
107
108void rtl92e_btc_periodical(struct rtl_priv *rtlpriv)
109{
110 exhalbtc92e_periodical(&gl92e_bt_coexist);
111}
112
113void rtl92e_btc_halt_notify(void)
114{
115 exhalbtc92e_halt_notify(&gl92e_bt_coexist);
116}
117
118void rtl92e_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length)
119{
120 exhalbtc92e_bt_info_notify(&gl92e_bt_coexist, tmp_buf, length);
121}
122
123bool rtl92e_btc_is_limited_dig(struct rtl_priv *rtlpriv)
124{
125 return gl92e_bt_coexist.bt_info.limited_dig;
126}
127
128bool rtl92e_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
129{
130 bool bt_change_edca = false;
131 u32 cur_edca_val;
132 u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b;
133 u32 edca_hs;
134 u32 edca_addr = 0x504;
135
136 cur_edca_val = rtl_read_dword(rtlpriv, edca_addr);
137 if (halbtc92e_is_wifi_uplink(rtlpriv)) {
138 if (cur_edca_val != edca_bt_hs_uplink) {
139 edca_hs = edca_bt_hs_uplink;
140 bt_change_edca = true;
141 }
142 } else {
143 if (cur_edca_val != edca_bt_hs_downlink) {
144 edca_hs = edca_bt_hs_downlink;
145 bt_change_edca = true;
146 }
147 }
148
149 if (bt_change_edca)
150 rtl_write_dword(rtlpriv, edca_addr, edca_hs);
151
152 return true;
153}
154
155bool rtl92e_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
156{
157 /* It seems 'bt_disabled' is never be initialized or set. */
158 if (gl92e_bt_coexist.bt_info.bt_disabled)
159 return true;
160 else
161 return false;
162}
163
164void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type)
165{
166 return exhalbtc92e_special_packet_notify(&gl92e_bt_coexist, pkt_type);
167}
168
169struct rtl_btc_ops *stg_rtl_btc_get_ops_pointer(void)
170{
171 return &rtl_btc_operation;
172}
173EXPORT_SYMBOL(stg_rtl_btc_get_ops_pointer);
174
175u8 rtl92e_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
176{
177 u8 num;
178
179 if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
180 num = 2;
181 else
182 num = 1;
183
184 return num;
185}
186u8 rtl92e_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
187{
188 return rtlpriv->btcoexist.btc_info.btcoexist;
189}
190
191u8 rtl92e_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
192{
193 return rtlpriv->btcoexist.btc_info.bt_type;
194}
This page took 0.057176 seconds and 5 git commands to generate.