]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c
rtlwifi: btcoex: 21a 2ant: monitor wifi counter to check network status
[mirror_ubuntu-bionic-kernel.git] / drivers / net / wireless / realtek / rtlwifi / btcoexist / halbtc8821a2ant.c
1 /******************************************************************************
2 *
3 * Copyright(c) 2012 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
26 /************************************************************
27 * Description:
28 *
29 * This file is for RTL8821A Co-exist mechanism
30 *
31 * History
32 * 2012/08/22 Cosa first check in.
33 * 2012/11/14 Cosa Revise for 8821A 2Ant out sourcing.
34 *
35 ************************************************************/
36
37 /************************************************************
38 * include files
39 ************************************************************/
40 #include "halbt_precomp.h"
41 /************************************************************
42 * Global variables, these are static variables
43 ************************************************************/
44 static struct coex_dm_8821a_2ant glcoex_dm_8821a_2ant;
45 static struct coex_dm_8821a_2ant *coex_dm = &glcoex_dm_8821a_2ant;
46 static struct coex_sta_8821a_2ant glcoex_sta_8821a_2ant;
47 static struct coex_sta_8821a_2ant *coex_sta = &glcoex_sta_8821a_2ant;
48
49 static const char *const glbt_info_src_8821a_2ant[] = {
50 "BT Info[wifi fw]",
51 "BT Info[bt rsp]",
52 "BT Info[bt auto report]",
53 };
54
55 static u32 glcoex_ver_date_8821a_2ant = 20130618;
56 static u32 glcoex_ver_8821a_2ant = 0x5050;
57
58 /************************************************************
59 * local function proto type if needed
60 *
61 * local function start with btc8821a2ant_
62 ************************************************************/
63 static u8 btc8821a2ant_bt_rssi_state(struct btc_coexist *btcoexist,
64 u8 level_num, u8 rssi_thresh,
65 u8 rssi_thresh1)
66 {
67 struct rtl_priv *rtlpriv = btcoexist->adapter;
68 long bt_rssi = 0;
69 u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
70
71 bt_rssi = coex_sta->bt_rssi;
72
73 if (level_num == 2) {
74 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
75 (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
76 if (bt_rssi >=
77 rssi_thresh + BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT) {
78 bt_rssi_state = BTC_RSSI_STATE_HIGH;
79 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
80 "[BTCoex], BT Rssi state switch to High\n");
81 } else {
82 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
83 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
84 "[BTCoex], BT Rssi state stay at Low\n");
85 }
86 } else {
87 if (bt_rssi < rssi_thresh) {
88 bt_rssi_state = BTC_RSSI_STATE_LOW;
89 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
90 "[BTCoex], BT Rssi state switch to Low\n");
91 } else {
92 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
93 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
94 "[BTCoex], BT Rssi state stay at High\n");
95 }
96 }
97 } else if (level_num == 3) {
98 if (rssi_thresh > rssi_thresh1) {
99 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
100 "[BTCoex], BT Rssi thresh error!!\n");
101 return coex_sta->pre_bt_rssi_state;
102 }
103
104 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
105 (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
106 if (bt_rssi >=
107 (rssi_thresh +
108 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) {
109 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
110 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
111 "[BTCoex], BT Rssi state switch to Medium\n");
112 } else {
113 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
114 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
115 "[BTCoex], BT Rssi state stay at Low\n");
116 }
117 } else if ((coex_sta->pre_bt_rssi_state ==
118 BTC_RSSI_STATE_MEDIUM) ||
119 (coex_sta->pre_bt_rssi_state ==
120 BTC_RSSI_STATE_STAY_MEDIUM)) {
121 if (bt_rssi >=
122 (rssi_thresh1 +
123 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) {
124 bt_rssi_state = BTC_RSSI_STATE_HIGH;
125 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
126 "[BTCoex], BT Rssi state switch to High\n");
127 } else if (bt_rssi < rssi_thresh) {
128 bt_rssi_state = BTC_RSSI_STATE_LOW;
129 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
130 "[BTCoex], BT Rssi state switch to Low\n");
131 } else {
132 bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
133 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
134 "[BTCoex], BT Rssi state stay at Medium\n");
135 }
136 } else {
137 if (bt_rssi < rssi_thresh1) {
138 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
139 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
140 "[BTCoex], BT Rssi state switch to Medium\n");
141 } else {
142 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
143 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
144 "[BTCoex], BT Rssi state stay at High\n");
145 }
146 }
147 }
148
149 coex_sta->pre_bt_rssi_state = bt_rssi_state;
150
151 return bt_rssi_state;
152 }
153
154 static u8 btc8821a2ant_wifi_rssi_state(struct btc_coexist *btcoexist,
155 u8 index, u8 level_num,
156 u8 rssi_thresh, u8 rssi_thresh1)
157 {
158 struct rtl_priv *rtlpriv = btcoexist->adapter;
159 long wifi_rssi = 0;
160 u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
161
162 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
163
164 if (level_num == 2) {
165 if ((coex_sta->pre_wifi_rssi_state[index] ==
166 BTC_RSSI_STATE_LOW) ||
167 (coex_sta->pre_wifi_rssi_state[index] ==
168 BTC_RSSI_STATE_STAY_LOW)) {
169 if (wifi_rssi >=
170 (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) {
171 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
172 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
173 "[BTCoex], wifi RSSI state switch to High\n");
174 } else {
175 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
176 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
177 "[BTCoex], wifi RSSI state stay at Low\n");
178 }
179 } else {
180 if (wifi_rssi < rssi_thresh) {
181 wifi_rssi_state = BTC_RSSI_STATE_LOW;
182 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
183 "[BTCoex], wifi RSSI state switch to Low\n");
184 } else {
185 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
186 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
187 "[BTCoex], wifi RSSI state stay at High\n");
188 }
189 }
190 } else if (level_num == 3) {
191 if (rssi_thresh > rssi_thresh1) {
192 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
193 "[BTCoex], wifi RSSI thresh error!!\n");
194 return coex_sta->pre_wifi_rssi_state[index];
195 }
196
197 if ((coex_sta->pre_wifi_rssi_state[index] ==
198 BTC_RSSI_STATE_LOW) ||
199 (coex_sta->pre_wifi_rssi_state[index] ==
200 BTC_RSSI_STATE_STAY_LOW)) {
201 if (wifi_rssi >=
202 (rssi_thresh +
203 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) {
204 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
205 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
206 "[BTCoex], wifi RSSI state switch to Medium\n");
207 } else {
208 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
209 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
210 "[BTCoex], wifi RSSI state stay at Low\n");
211 }
212 } else if ((coex_sta->pre_wifi_rssi_state[index] ==
213 BTC_RSSI_STATE_MEDIUM) ||
214 (coex_sta->pre_wifi_rssi_state[index] ==
215 BTC_RSSI_STATE_STAY_MEDIUM)) {
216 if (wifi_rssi >= (rssi_thresh1 +
217 BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) {
218 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
219 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
220 "[BTCoex], wifi RSSI state switch to High\n");
221 } else if (wifi_rssi < rssi_thresh) {
222 wifi_rssi_state = BTC_RSSI_STATE_LOW;
223 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
224 "[BTCoex], wifi RSSI state switch to Low\n");
225 } else {
226 wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
227 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
228 "[BTCoex], wifi RSSI state stay at Medium\n");
229 }
230 } else {
231 if (wifi_rssi < rssi_thresh1) {
232 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
233 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
234 "[BTCoex], wifi RSSI state switch to Medium\n");
235 } else {
236 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
237 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
238 "[BTCoex], wifi RSSI state stay at High\n");
239 }
240 }
241 }
242 coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
243
244 return wifi_rssi_state;
245 }
246
247 static
248 void btc8821a2ant_limited_rx(struct btc_coexist *btcoexist, bool force_exec,
249 bool rej_ap_agg_pkt, bool bt_ctrl_agg_buf_size,
250 u8 agg_buf_size)
251 {
252 bool reject_rx_agg = rej_ap_agg_pkt;
253 bool bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size;
254 u8 rx_agg_size = agg_buf_size;
255
256 /* Rx Aggregation related setting */
257 btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
258 &reject_rx_agg);
259 /* decide BT control aggregation buf size or not */
260 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
261 &bt_ctrl_rx_agg_size);
262 /* aggregation buf size, works when BT control Rx aggregation size */
263 btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
264 /* real update aggregation setting */
265 btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
266 }
267
268 static void btc8821a2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
269 {
270 struct rtl_priv *rtlpriv = btcoexist->adapter;
271 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
272 u32 reg_hp_txrx, reg_lp_txrx, u4tmp;
273 u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
274
275 reg_hp_txrx = 0x770;
276 reg_lp_txrx = 0x774;
277
278 u4tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
279 reg_hp_tx = u4tmp & MASKLWORD;
280 reg_hp_rx = (u4tmp & MASKHWORD) >> 16;
281
282 u4tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
283 reg_lp_tx = u4tmp & MASKLWORD;
284 reg_lp_rx = (u4tmp & MASKHWORD) >> 16;
285
286 coex_sta->high_priority_tx = reg_hp_tx;
287 coex_sta->high_priority_rx = reg_hp_rx;
288 coex_sta->low_priority_tx = reg_lp_tx;
289 coex_sta->low_priority_rx = reg_lp_rx;
290
291 if ((coex_sta->low_priority_rx >= 950) &&
292 (coex_sta->low_priority_rx >= coex_sta->low_priority_tx) &&
293 (!coex_sta->under_ips))
294 bt_link_info->slave_role = true;
295 else
296 bt_link_info->slave_role = false;
297
298 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
299 "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
300 reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx);
301 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
302 "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n",
303 reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx);
304
305 /* reset counter */
306 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
307 }
308
309 static void btc8821a2ant_monitor_wifi_ctr(struct btc_coexist *btcoexist)
310 {
311 if (coex_sta->under_ips) {
312 coex_sta->crc_ok_cck = 0;
313 coex_sta->crc_ok_11g = 0;
314 coex_sta->crc_ok_11n = 0;
315 coex_sta->crc_ok_11n_agg = 0;
316
317 coex_sta->crc_err_cck = 0;
318 coex_sta->crc_err_11g = 0;
319 coex_sta->crc_err_11n = 0;
320 coex_sta->crc_err_11n_agg = 0;
321 } else {
322 coex_sta->crc_ok_cck =
323 btcoexist->btc_read_4byte(btcoexist, 0xf88);
324 coex_sta->crc_ok_11g =
325 btcoexist->btc_read_2byte(btcoexist, 0xf94);
326 coex_sta->crc_ok_11n =
327 btcoexist->btc_read_2byte(btcoexist, 0xf90);
328 coex_sta->crc_ok_11n_agg =
329 btcoexist->btc_read_2byte(btcoexist, 0xfb8);
330
331 coex_sta->crc_err_cck =
332 btcoexist->btc_read_4byte(btcoexist, 0xf84);
333 coex_sta->crc_err_11g =
334 btcoexist->btc_read_2byte(btcoexist, 0xf96);
335 coex_sta->crc_err_11n =
336 btcoexist->btc_read_2byte(btcoexist, 0xf92);
337 coex_sta->crc_err_11n_agg =
338 btcoexist->btc_read_2byte(btcoexist, 0xfba);
339 }
340
341 /* reset counter */
342 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x1);
343 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x0);
344 }
345
346 static void btc8821a2ant_query_bt_info(struct btc_coexist *btcoexist)
347 {
348 struct rtl_priv *rtlpriv = btcoexist->adapter;
349 u8 h2c_parameter[1] = {0};
350
351 coex_sta->c2h_bt_info_req_sent = true;
352
353 h2c_parameter[0] |= BIT0; /* trigger */
354
355 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
356 "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n",
357 h2c_parameter[0]);
358
359 btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
360 }
361
362 static u8 btc8821a2ant_action_algorithm(struct btc_coexist *btcoexist)
363 {
364 struct rtl_priv *rtlpriv = btcoexist->adapter;
365 struct btc_stack_info *stack_info = &btcoexist->stack_info;
366 bool bt_hs_on = false;
367 u8 algorithm = BT_8821A_2ANT_COEX_ALGO_UNDEFINED;
368 u8 num_of_diff_profile = 0;
369
370 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
371
372 /* sync BTInfo with BT firmware and stack */
373 if (!stack_info->hid_exist)
374 stack_info->hid_exist = coex_sta->hid_exist;
375 /* when stack HID report error, here we use the info from bt fw. */
376 if (!stack_info->bt_link_exist)
377 stack_info->bt_link_exist = coex_sta->bt_link_exist;
378
379 if (!coex_sta->bt_link_exist) {
380 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
381 "[BTCoex], No profile exists!!!\n");
382 return algorithm;
383 }
384
385 if (coex_sta->sco_exist)
386 num_of_diff_profile++;
387 if (coex_sta->hid_exist)
388 num_of_diff_profile++;
389 if (coex_sta->pan_exist)
390 num_of_diff_profile++;
391 if (coex_sta->a2dp_exist)
392 num_of_diff_profile++;
393
394 if (num_of_diff_profile == 1) {
395 if (coex_sta->sco_exist) {
396 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
397 "[BTCoex], SCO only\n");
398 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
399 } else {
400 if (coex_sta->hid_exist) {
401 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
402 "[BTCoex], HID only\n");
403 algorithm = BT_8821A_2ANT_COEX_ALGO_HID;
404 } else if (coex_sta->a2dp_exist) {
405 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
406 "[BTCoex], A2DP only\n");
407 algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP;
408 } else if (coex_sta->pan_exist) {
409 if (bt_hs_on) {
410 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
411 DBG_LOUD,
412 "[BTCoex], PAN(HS) only\n");
413 algorithm = BT_8821A_2ANT_COEX_ALGO_PANHS;
414 } else {
415 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
416 DBG_LOUD,
417 "[BTCoex], PAN(EDR) only\n");
418 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR;
419 }
420 }
421 }
422 } else if (num_of_diff_profile == 2) {
423 if (coex_sta->sco_exist) {
424 if (coex_sta->hid_exist) {
425 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
426 "[BTCoex], SCO + HID\n");
427 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
428 } else if (coex_sta->a2dp_exist) {
429 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
430 "[BTCoex], SCO + A2DP ==> SCO\n");
431 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
432 } else if (coex_sta->pan_exist) {
433 if (bt_hs_on) {
434 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
435 DBG_LOUD,
436 "[BTCoex], SCO + PAN(HS)\n");
437 algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;
438 } else {
439 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
440 DBG_LOUD,
441 "[BTCoex], SCO + PAN(EDR)\n");
442 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
443 }
444 }
445 } else {
446 if (coex_sta->hid_exist &&
447 coex_sta->a2dp_exist) {
448 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
449 "[BTCoex], HID + A2DP\n");
450 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP;
451 } else if (coex_sta->hid_exist &&
452 coex_sta->pan_exist) {
453 if (bt_hs_on) {
454 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
455 DBG_LOUD,
456 "[BTCoex], HID + PAN(HS)\n");
457 algorithm = BT_8821A_2ANT_COEX_ALGO_HID;
458 } else {
459 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
460 DBG_LOUD,
461 "[BTCoex], HID + PAN(EDR)\n");
462 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
463 }
464 } else if (coex_sta->pan_exist &&
465 coex_sta->a2dp_exist) {
466 if (bt_hs_on) {
467 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
468 DBG_LOUD,
469 "[BTCoex], A2DP + PAN(HS)\n");
470 algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS;
471 } else {
472 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
473 DBG_LOUD,
474 "[BTCoex], A2DP + PAN(EDR)\n");
475 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP;
476 }
477 }
478 }
479 } else if (num_of_diff_profile == 3) {
480 if (coex_sta->sco_exist) {
481 if (coex_sta->hid_exist &&
482 coex_sta->a2dp_exist) {
483 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
484 "[BTCoex], SCO + HID + A2DP ==> HID\n");
485 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
486 } else if (coex_sta->hid_exist &&
487 coex_sta->pan_exist) {
488 if (bt_hs_on) {
489 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
490 DBG_LOUD,
491 "[BTCoex], SCO + HID + PAN(HS)\n");
492 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
493 } else {
494 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
495 DBG_LOUD,
496 "[BTCoex], SCO + HID + PAN(EDR)\n");
497 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
498 }
499 } else if (coex_sta->pan_exist &&
500 coex_sta->a2dp_exist) {
501 if (bt_hs_on) {
502 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
503 DBG_LOUD,
504 "[BTCoex], SCO + A2DP + PAN(HS)\n");
505 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
506 } else {
507 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
508 DBG_LOUD,
509 "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n");
510 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
511 }
512 }
513 } else {
514 if (coex_sta->hid_exist &&
515 coex_sta->pan_exist &&
516 coex_sta->a2dp_exist) {
517 if (bt_hs_on) {
518 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
519 DBG_LOUD,
520 "[BTCoex], HID + A2DP + PAN(HS)\n");
521 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP;
522 } else {
523 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
524 DBG_LOUD,
525 "[BTCoex], HID + A2DP + PAN(EDR)\n");
526 algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
527 }
528 }
529 }
530 } else if (num_of_diff_profile >= 3) {
531 if (coex_sta->sco_exist) {
532 if (coex_sta->hid_exist &&
533 coex_sta->pan_exist &&
534 coex_sta->a2dp_exist) {
535 if (bt_hs_on) {
536 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
537 DBG_LOUD,
538 "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n");
539
540 } else {
541 RT_TRACE(rtlpriv, COMP_BT_COEXIST,
542 DBG_LOUD,
543 "[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
544 algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;
545 }
546 }
547 }
548 }
549 return algorithm;
550 }
551
552 static void btc8821a2ant_set_fw_dac_swing_lvl(struct btc_coexist *btcoexist,
553 u8 dac_swing_lvl)
554 {
555 struct rtl_priv *rtlpriv = btcoexist->adapter;
556 u8 h2c_parameter[1] = {0};
557
558 /* There are several type of dacswing
559 * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
560 */
561 h2c_parameter[0] = dac_swing_lvl;
562
563 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
564 "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swing_lvl);
565 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
566 "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter[0]);
567
568 btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
569 }
570
571 static void btc8821a2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist,
572 bool dec_bt_pwr)
573 {
574 struct rtl_priv *rtlpriv = btcoexist->adapter;
575 u8 h2c_parameter[1] = {0};
576
577 h2c_parameter[0] = 0;
578
579 if (dec_bt_pwr)
580 h2c_parameter[0] |= BIT1;
581
582 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
583 "[BTCoex], decrease Bt Power : %s, FW write 0x62 = 0x%x\n",
584 (dec_bt_pwr ? "Yes!!" : "No!!"), h2c_parameter[0]);
585
586 btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter);
587 }
588
589 static void btc8821a2ant_dec_bt_pwr(struct btc_coexist *btcoexist,
590 bool force_exec, bool dec_bt_pwr)
591 {
592 struct rtl_priv *rtlpriv = btcoexist->adapter;
593
594 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
595 "[BTCoex], %s Dec BT power = %s\n",
596 (force_exec ? "force to" : ""),
597 ((dec_bt_pwr) ? "ON" : "OFF"));
598 coex_dm->cur_dec_bt_pwr = dec_bt_pwr;
599
600 if (!force_exec) {
601 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
602 "[BTCoex], pre_dec_bt_pwr = %d, cur_dec_bt_pwr = %d\n",
603 coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr);
604
605 if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr)
606 return;
607 }
608 btc8821a2ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr);
609
610 coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr;
611 }
612
613 static void btc8821a2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist,
614 bool force_exec, u8 fw_dac_swing_lvl)
615 {
616 struct rtl_priv *rtlpriv = btcoexist->adapter;
617
618 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
619 "[BTCoex], %s set FW Dac Swing level = %d\n",
620 (force_exec ? "force to" : ""), fw_dac_swing_lvl);
621 coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl;
622
623 if (!force_exec) {
624 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
625 "[BTCoex], pre_fw_dac_swing_lvl = %d, cur_fw_dac_swing_lvl = %d\n",
626 coex_dm->pre_fw_dac_swing_lvl,
627 coex_dm->cur_fw_dac_swing_lvl);
628
629 if (coex_dm->pre_fw_dac_swing_lvl ==
630 coex_dm->cur_fw_dac_swing_lvl)
631 return;
632 }
633
634 btc8821a2ant_set_fw_dac_swing_lvl(btcoexist,
635 coex_dm->cur_fw_dac_swing_lvl);
636
637 coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
638 }
639
640 static void btc8821a2ant_set_sw_penalty_tx_rate_adaptive(
641 struct btc_coexist *btcoexist, bool low_penalty_ra)
642 {
643 struct rtl_priv *rtlpriv = btcoexist->adapter;
644 u8 h2c_parameter[6] = {0};
645
646 h2c_parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */
647
648 if (low_penalty_ra) {
649 h2c_parameter[1] |= BIT0;
650 /* normal rate except MCS7/6/5, OFDM54/48/36 */
651 h2c_parameter[2] = 0x00;
652 /* MCS7 or OFDM54 */
653 h2c_parameter[3] = 0xf7;
654 /* MCS6 or OFDM48 */
655 h2c_parameter[4] = 0xf8;
656 /* MCS5 or OFDM36 */
657 h2c_parameter[5] = 0xf9;
658 }
659
660 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
661 "[BTCoex], set WiFi Low-Penalty Retry: %s",
662 (low_penalty_ra ? "ON!!" : "OFF!!"));
663
664 btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
665 }
666
667 static void btc8821a2ant_low_penalty_ra(struct btc_coexist *btcoexist,
668 bool force_exec, bool low_penalty_ra)
669 {
670 struct rtl_priv *rtlpriv = btcoexist->adapter;
671
672 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
673 "[BTCoex], %s turn LowPenaltyRA = %s\n",
674 (force_exec ? "force to" : ""),
675 ((low_penalty_ra) ? "ON" : "OFF"));
676 coex_dm->cur_low_penalty_ra = low_penalty_ra;
677
678 if (!force_exec) {
679 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
680 "[BTCoex], pre_low_penalty_ra = %d, cur_low_penalty_ra = %d\n",
681 coex_dm->pre_low_penalty_ra,
682 coex_dm->cur_low_penalty_ra);
683
684 if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
685 return;
686 }
687 btc8821a2ant_set_sw_penalty_tx_rate_adaptive(btcoexist,
688 coex_dm->cur_low_penalty_ra);
689
690 coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
691 }
692
693 static void btc8821a2ant_set_dac_swing_reg(struct btc_coexist *btcoexist,
694 u32 level)
695 {
696 struct rtl_priv *rtlpriv = btcoexist->adapter;
697 u8 val = (u8)level;
698
699 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
700 "[BTCoex], Write SwDacSwing = 0x%x\n", level);
701 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc5b, 0x3e, val);
702 }
703
704 static void btc8821a2ant_set_sw_full_dac_swing(struct btc_coexist *btcoexist,
705 bool sw_dac_swing_on,
706 u32 sw_dac_swing_lvl)
707 {
708 if (sw_dac_swing_on)
709 btc8821a2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl);
710 else
711 btc8821a2ant_set_dac_swing_reg(btcoexist, 0x18);
712 }
713
714 static void btc8821a2ant_dac_swing(struct btc_coexist *btcoexist,
715 bool force_exec, bool dac_swing_on,
716 u32 dac_swing_lvl)
717 {
718 struct rtl_priv *rtlpriv = btcoexist->adapter;
719
720 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
721 "[BTCoex], %s turn DacSwing = %s, dac_swing_lvl = 0x%x\n",
722 (force_exec ? "force to" : ""),
723 ((dac_swing_on) ? "ON" : "OFF"),
724 dac_swing_lvl);
725 coex_dm->cur_dac_swing_on = dac_swing_on;
726 coex_dm->cur_dac_swing_lvl = dac_swing_lvl;
727
728 if (!force_exec) {
729 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
730 "[BTCoex], pre_dac_swing_on = %d, pre_dac_swing_lvl = 0x%x, cur_dac_swing_on = %d, cur_dac_swing_lvl = 0x%x\n",
731 coex_dm->pre_dac_swing_on,
732 coex_dm->pre_dac_swing_lvl,
733 coex_dm->cur_dac_swing_on,
734 coex_dm->cur_dac_swing_lvl);
735
736 if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) &&
737 (coex_dm->pre_dac_swing_lvl ==
738 coex_dm->cur_dac_swing_lvl))
739 return;
740 }
741 mdelay(30);
742 btc8821a2ant_set_sw_full_dac_swing(btcoexist, dac_swing_on,
743 dac_swing_lvl);
744
745 coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on;
746 coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
747 }
748
749 static void btc8821a2ant_set_coex_table(struct btc_coexist *btcoexist,
750 u32 val0x6c0, u32 val0x6c4,
751 u32 val0x6c8, u8 val0x6cc)
752 {
753 struct rtl_priv *rtlpriv = btcoexist->adapter;
754
755 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
756 "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0);
757 btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
758
759 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
760 "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4);
761 btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
762
763 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
764 "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8);
765 btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
766
767 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
768 "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc);
769 btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
770 }
771
772 static void btc8821a2ant_coex_table(struct btc_coexist *btcoexist,
773 bool force_exec, u32 val0x6c0,
774 u32 val0x6c4, u32 val0x6c8, u8 val0x6cc)
775 {
776 struct rtl_priv *rtlpriv = btcoexist->adapter;
777
778 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
779 "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
780 (force_exec ? "force to" : ""),
781 val0x6c0, val0x6c4, val0x6c8, val0x6cc);
782 coex_dm->cur_val0x6c0 = val0x6c0;
783 coex_dm->cur_val0x6c4 = val0x6c4;
784 coex_dm->cur_val0x6c8 = val0x6c8;
785 coex_dm->cur_val0x6cc = val0x6cc;
786
787 if (!force_exec) {
788 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
789 "[BTCoex], pre_val0x6c0 = 0x%x, pre_val0x6c4 = 0x%x, pre_val0x6c8 = 0x%x, pre_val0x6cc = 0x%x !!\n",
790 coex_dm->pre_val0x6c0,
791 coex_dm->pre_val0x6c4,
792 coex_dm->pre_val0x6c8,
793 coex_dm->pre_val0x6cc);
794 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
795 "[BTCoex], cur_val0x6c0 = 0x%x, cur_val0x6c4 = 0x%x, cur_val0x6c8 = 0x%x, cur_val0x6cc = 0x%x !!\n",
796 coex_dm->cur_val0x6c0,
797 coex_dm->cur_val0x6c4,
798 coex_dm->cur_val0x6c8,
799 coex_dm->cur_val0x6cc);
800
801 if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
802 (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
803 (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
804 (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
805 return;
806 }
807 btc8821a2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, val0x6c8,
808 val0x6cc);
809
810 coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
811 coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
812 coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
813 coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
814 }
815
816 static void btc8821a2ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoex,
817 bool enable)
818 {
819 struct rtl_priv *rtlpriv = btcoex->adapter;
820 u8 h2c_parameter[1] = {0};
821
822 if (enable)
823 h2c_parameter[0] |= BIT0; /* function enable */
824
825 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
826 "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
827 h2c_parameter[0]);
828
829 btcoex->btc_fill_h2c(btcoex, 0x63, 1, h2c_parameter);
830 }
831
832 static void btc8821a2ant_ignore_wlan_act(struct btc_coexist *btcoexist,
833 bool force_exec, bool enable)
834 {
835 struct rtl_priv *rtlpriv = btcoexist->adapter;
836
837 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
838 "[BTCoex], %s turn Ignore WlanAct %s\n",
839 (force_exec ? "force to" : ""), (enable ? "ON" : "OFF"));
840 coex_dm->cur_ignore_wlan_act = enable;
841
842 if (!force_exec) {
843 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
844 "[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n",
845 coex_dm->pre_ignore_wlan_act,
846 coex_dm->cur_ignore_wlan_act);
847
848 if (coex_dm->pre_ignore_wlan_act ==
849 coex_dm->cur_ignore_wlan_act)
850 return;
851 }
852 btc8821a2ant_set_fw_ignore_wlan_act(btcoexist, enable);
853
854 coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
855 }
856
857 static void btc8821a2ant_set_fw_ps_tdma(struct btc_coexist *btcoexist,
858 u8 byte1, u8 byte2, u8 byte3,
859 u8 byte4, u8 byte5)
860 {
861 struct rtl_priv *rtlpriv = btcoexist->adapter;
862 u8 h2c_parameter[5];
863
864 h2c_parameter[0] = byte1;
865 h2c_parameter[1] = byte2;
866 h2c_parameter[2] = byte3;
867 h2c_parameter[3] = byte4;
868 h2c_parameter[4] = byte5;
869
870 coex_dm->ps_tdma_para[0] = byte1;
871 coex_dm->ps_tdma_para[1] = byte2;
872 coex_dm->ps_tdma_para[2] = byte3;
873 coex_dm->ps_tdma_para[3] = byte4;
874 coex_dm->ps_tdma_para[4] = byte5;
875
876 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
877 "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
878 h2c_parameter[0],
879 h2c_parameter[1] << 24 |
880 h2c_parameter[2] << 16 |
881 h2c_parameter[3] << 8 |
882 h2c_parameter[4]);
883
884 btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
885 }
886
887 static void btc8821a2ant_sw_mechanism1(struct btc_coexist *btcoexist,
888 bool shrink_rx_lpf, bool low_penalty_ra,
889 bool limited_dig, bool bt_lna_constrain)
890 {
891 u32 wifi_bw;
892
893 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
894
895 if (BTC_WIFI_BW_HT40 != wifi_bw) {
896 /*only shrink RF Rx LPF for HT40*/
897 if (shrink_rx_lpf)
898 shrink_rx_lpf = false;
899 }
900
901 btc8821a2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
902 }
903
904 static void btc8821a2ant_sw_mechanism2(struct btc_coexist *btcoexist,
905 bool agc_table_shift, bool adc_back_off,
906 bool sw_dac_swing, u32 dac_swing_lvl)
907 {
908 btc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing,
909 sw_dac_swing);
910 }
911
912 static void btc8821a2ant_set_ant_path(struct btc_coexist *btcoexist,
913 u8 ant_pos_type, bool init_hw_cfg,
914 bool wifi_off)
915 {
916 struct btc_board_info *board_info = &btcoexist->board_info;
917 u32 u4tmp = 0;
918 u8 h2c_parameter[2] = {0};
919
920 if (init_hw_cfg) {
921 /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */
922 u4tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
923 u4tmp &= ~BIT23;
924 u4tmp |= BIT24;
925 btcoexist->btc_write_4byte(btcoexist, 0x4c, u4tmp);
926
927 btcoexist->btc_write_4byte(btcoexist, 0x974, 0x3ff);
928 btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77);
929
930 if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
931 /* tell firmware "antenna inverse" ==> WRONG firmware
932 * antenna control code ==>need fw to fix
933 */
934 h2c_parameter[0] = 1;
935 h2c_parameter[1] = 1;
936 btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
937 h2c_parameter);
938 } else {
939 /* tell firmware "no antenna inverse" ==> WRONG firmware
940 * antenna control code ==>need fw to fix
941 */
942 h2c_parameter[0] = 0;
943 h2c_parameter[1] = 1;
944 btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
945 h2c_parameter);
946 }
947 }
948
949 /* ext switch setting */
950 switch (ant_pos_type) {
951 case BTC_ANT_WIFI_AT_MAIN:
952 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x1);
953 break;
954 case BTC_ANT_WIFI_AT_AUX:
955 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x2);
956 break;
957 }
958 }
959
960 static void btc8821a2ant_ps_tdma(struct btc_coexist *btcoexist,
961 bool force_exec, bool turn_on, u8 type)
962 {
963 struct rtl_priv *rtlpriv = btcoexist->adapter;
964
965 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
966 "[BTCoex], %s turn %s PS TDMA, type = %d\n",
967 (force_exec ? "force to" : ""), (turn_on ? "ON" : "OFF"),
968 type);
969 coex_dm->cur_ps_tdma_on = turn_on;
970 coex_dm->cur_ps_tdma = type;
971
972 if (!force_exec) {
973 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
974 "[BTCoex], pre_ps_tdma_on = %d, cur_ps_tdma_on = %d!!\n",
975 coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on);
976 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
977 "[BTCoex], pre_ps_tdma = %d, cur_ps_tdma = %d!!\n",
978 coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma);
979
980 if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
981 (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
982 return;
983 }
984 if (turn_on) {
985 switch (type) {
986 case 1:
987 default:
988 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
989 0x1a, 0xe1, 0x90);
990 break;
991 case 2:
992 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
993 0x12, 0xe1, 0x90);
994 break;
995 case 3:
996 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
997 0x3, 0xf1, 0x90);
998 break;
999 case 4:
1000 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x10,
1001 0x03, 0xf1, 0x90);
1002 break;
1003 case 5:
1004 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
1005 0x1a, 0x60, 0x90);
1006 break;
1007 case 6:
1008 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
1009 0x12, 0x60, 0x90);
1010 break;
1011 case 7:
1012 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
1013 0x3, 0x70, 0x90);
1014 break;
1015 case 8:
1016 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x10,
1017 0x3, 0x70, 0x90);
1018 break;
1019 case 9:
1020 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
1021 0x1a, 0xe1, 0x90);
1022 break;
1023 case 10:
1024 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
1025 0x12, 0xe1, 0x90);
1026 break;
1027 case 11:
1028 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
1029 0xa, 0xe1, 0x90);
1030 break;
1031 case 12:
1032 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5,
1033 0x5, 0xe1, 0x90);
1034 break;
1035 case 13:
1036 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
1037 0x1a, 0x60, 0x90);
1038 break;
1039 case 14:
1040 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3,
1041 0x12, 0x12, 0x60, 0x90);
1042 break;
1043 case 15:
1044 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
1045 0xa, 0x60, 0x90);
1046 break;
1047 case 16:
1048 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5,
1049 0x5, 0x60, 0x90);
1050 break;
1051 case 17:
1052 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x2f,
1053 0x2f, 0x60, 0x90);
1054 break;
1055 case 18:
1056 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5,
1057 0x5, 0xe1, 0x90);
1058 break;
1059 case 19:
1060 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
1061 0x25, 0xe1, 0x90);
1062 break;
1063 case 20:
1064 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
1065 0x25, 0x60, 0x90);
1066 break;
1067 case 21:
1068 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15,
1069 0x03, 0x70, 0x90);
1070 break;
1071 case 71:
1072 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
1073 0x1a, 0xe1, 0x90);
1074 break;
1075 }
1076 } else {
1077 /* disable PS tdma */
1078 switch (type) {
1079 case 0:
1080 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
1081 0x40, 0x0);
1082 break;
1083 case 1:
1084 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
1085 0x48, 0x0);
1086 break;
1087 default:
1088 btc8821a2ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
1089 0x40, 0x0);
1090 break;
1091 }
1092 }
1093
1094 /* update pre state */
1095 coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
1096 coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
1097 }
1098
1099 static void btc8821a2ant_coex_all_off(struct btc_coexist *btcoexist)
1100 {
1101 /* fw all off */
1102 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1103 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1104 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1105
1106 /* sw all off */
1107 btc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1108 btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1109
1110 /* hw all off */
1111 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC,
1112 0x55555555, 0x55555555, 0xffff, 0x3);
1113 }
1114
1115 static void btc8821a2ant_coex_under_5g(struct btc_coexist *btcoexist)
1116 {
1117 btc8821a2ant_coex_all_off(btcoexist);
1118 }
1119
1120 static void btc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist)
1121 {
1122 /* force to reset coex mechanism */
1123 btc8821a2ant_coex_table(btcoexist, FORCE_EXEC, 0x55555555,
1124 0x55555555, 0xffff, 0x3);
1125
1126 btc8821a2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
1127 btc8821a2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
1128 btc8821a2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false);
1129
1130 btc8821a2ant_sw_mechanism1(btcoexist, false, false, false, false);
1131 btc8821a2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
1132 }
1133
1134 static void btc8821a2ant_bt_inquiry_page(struct btc_coexist *btcoexist)
1135 {
1136 bool low_pwr_disable = true;
1137
1138 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1139 &low_pwr_disable);
1140
1141 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1142 0x5afa5afa, 0xffff, 0x3);
1143 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
1144 }
1145
1146 static bool btc8821a2ant_is_common_action(struct btc_coexist *btcoexist)
1147 {
1148 struct rtl_priv *rtlpriv = btcoexist->adapter;
1149 bool common = false, wifi_connected = false, wifi_busy = false;
1150 bool low_pwr_disable = false;
1151
1152 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
1153 &wifi_connected);
1154 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
1155
1156 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1157 0x5afa5afa, 0xffff, 0x3);
1158
1159 if (!wifi_connected &&
1160 BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status) {
1161 low_pwr_disable = false;
1162 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1163 &low_pwr_disable);
1164
1165 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1166 "[BTCoex], Wifi IPS + BT IPS!!\n");
1167
1168 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1169 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1170 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1171
1172 btc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1173 false);
1174 btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1175 0x18);
1176
1177 common = true;
1178 } else if (wifi_connected &&
1179 (BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status)) {
1180 low_pwr_disable = false;
1181 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1182 &low_pwr_disable);
1183
1184 if (wifi_busy) {
1185 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1186 "[BTCoex], Wifi Busy + BT IPS!!\n");
1187 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1188 false, 1);
1189 } else {
1190 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1191 "[BTCoex], Wifi LPS + BT IPS!!\n");
1192 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1193 false, 1);
1194 }
1195
1196 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1197 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1198
1199 btc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1200 false);
1201 btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1202 0x18);
1203
1204 common = true;
1205 } else if (!wifi_connected &&
1206 (BT_8821A_2ANT_BT_STATUS_CON_IDLE == coex_dm->bt_status)) {
1207 low_pwr_disable = true;
1208 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1209 &low_pwr_disable);
1210 btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
1211 0x8);
1212
1213 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1214 "[BTCoex], Wifi IPS + BT LPS!!\n");
1215
1216 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1217 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1218 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1219
1220 btc8821a2ant_sw_mechanism1(btcoexist, false, false, false,
1221 false);
1222 btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1223 0x18);
1224 common = true;
1225 } else if (wifi_connected &&
1226 (BT_8821A_2ANT_BT_STATUS_CON_IDLE == coex_dm->bt_status)) {
1227 low_pwr_disable = true;
1228 btcoexist->btc_set(btcoexist,
1229 BTC_SET_ACT_DISABLE_LOW_POWER, &low_pwr_disable);
1230
1231 if (wifi_busy) {
1232 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1233 "[BTCoex], Wifi Busy + BT LPS!!\n");
1234 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1235 false, 1);
1236 } else {
1237 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1238 "[BTCoex], Wifi LPS + BT LPS!!\n");
1239 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1240 false, 1);
1241 }
1242
1243 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1244 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1245
1246 btc8821a2ant_sw_mechanism1(btcoexist, true, true, true, true);
1247 btc8821a2ant_sw_mechanism2(btcoexist, false, false, false,
1248 0x18);
1249
1250 common = true;
1251 } else if (!wifi_connected &&
1252 (coex_dm->bt_status == BT_8821A_2ANT_BT_STATUS_NON_IDLE)) {
1253 low_pwr_disable = false;
1254 btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
1255 &low_pwr_disable);
1256
1257 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1258 "[BTCoex], Wifi IPS + BT Busy!!\n");
1259
1260 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1261 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1262 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1263
1264 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1265 false, false);
1266 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1267 false, 0x18);
1268
1269 common = true;
1270 } else {
1271 low_pwr_disable = true;
1272 btcoexist->btc_set(btcoexist,
1273 BTC_SET_ACT_DISABLE_LOW_POWER,
1274 &low_pwr_disable);
1275
1276 if (wifi_busy) {
1277 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1278 "[BTCoex], Wifi Busy + BT Busy!!\n");
1279 common = false;
1280 } else {
1281 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1282 "[BTCoex], Wifi LPS + BT Busy!!\n");
1283 btc8821a2ant_ps_tdma(btcoexist,
1284 NORMAL_EXEC, true, 21);
1285
1286 common = true;
1287 }
1288 btc8821a2ant_sw_mechanism1(btcoexist, true, true, true, true);
1289 }
1290 return common;
1291 }
1292
1293 static void btc8821a2ant_tdma_dur_adj(struct btc_coexist *btcoexist,
1294 bool sco_hid, bool tx_pause,
1295 u8 max_interval)
1296 {
1297 struct rtl_priv *rtlpriv = btcoexist->adapter;
1298 static long up, dn, m, n, wait_count;
1299 /* 0 : no change
1300 * +1: increase WiFi duration
1301 * -1: decrease WiFi duration
1302 */
1303 int result;
1304 u8 retry_count = 0;
1305
1306 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1307 "[BTCoex], TdmaDurationAdjust()\n");
1308
1309 if (coex_dm->reset_tdma_adjust) {
1310 coex_dm->reset_tdma_adjust = false;
1311 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1312 "[BTCoex], first run TdmaDurationAdjust()!!\n");
1313 if (sco_hid) {
1314 if (tx_pause) {
1315 if (max_interval == 1) {
1316 btc8821a2ant_ps_tdma(btcoexist,
1317 NORMAL_EXEC,
1318 true, 13);
1319 coex_dm->tdma_adj_type = 13;
1320 } else if (max_interval == 2) {
1321 btc8821a2ant_ps_tdma(btcoexist,
1322 NORMAL_EXEC,
1323 true, 14);
1324 coex_dm->tdma_adj_type = 14;
1325 } else {
1326 btc8821a2ant_ps_tdma(btcoexist,
1327 NORMAL_EXEC,
1328 true, 15);
1329 coex_dm->tdma_adj_type = 15;
1330 }
1331 } else {
1332 if (max_interval == 1) {
1333 btc8821a2ant_ps_tdma(btcoexist,
1334 NORMAL_EXEC,
1335 true, 9);
1336 coex_dm->tdma_adj_type = 9;
1337 } else if (max_interval == 2) {
1338 btc8821a2ant_ps_tdma(btcoexist,
1339 NORMAL_EXEC,
1340 true, 10);
1341 coex_dm->tdma_adj_type = 10;
1342 } else {
1343 btc8821a2ant_ps_tdma(btcoexist,
1344 NORMAL_EXEC,
1345 true, 11);
1346 coex_dm->tdma_adj_type = 11;
1347 }
1348 }
1349 } else {
1350 if (tx_pause) {
1351 if (max_interval == 1) {
1352 btc8821a2ant_ps_tdma(btcoexist,
1353 NORMAL_EXEC,
1354 true, 5);
1355 coex_dm->tdma_adj_type = 5;
1356 } else if (max_interval == 2) {
1357 btc8821a2ant_ps_tdma(btcoexist,
1358 NORMAL_EXEC,
1359 true, 6);
1360 coex_dm->tdma_adj_type = 6;
1361 } else {
1362 btc8821a2ant_ps_tdma(btcoexist,
1363 NORMAL_EXEC,
1364 true, 7);
1365 coex_dm->tdma_adj_type = 7;
1366 }
1367 } else {
1368 if (max_interval == 1) {
1369 btc8821a2ant_ps_tdma(btcoexist,
1370 NORMAL_EXEC,
1371 true, 1);
1372 coex_dm->tdma_adj_type = 1;
1373 } else if (max_interval == 2) {
1374 btc8821a2ant_ps_tdma(btcoexist,
1375 NORMAL_EXEC,
1376 true, 2);
1377 coex_dm->tdma_adj_type = 2;
1378 } else {
1379 btc8821a2ant_ps_tdma(btcoexist,
1380 NORMAL_EXEC,
1381 true, 3);
1382 coex_dm->tdma_adj_type = 3;
1383 }
1384 }
1385 }
1386
1387 up = 0;
1388 dn = 0;
1389 m = 1;
1390 n = 3;
1391 result = 0;
1392 wait_count = 0;
1393 } else {
1394 /* accquire the BT TRx retry count from BT_Info byte2 */
1395 retry_count = coex_sta->bt_retry_cnt;
1396 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1397 "[BTCoex], retry_count = %d\n", retry_count);
1398 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1399 "[BTCoex], up = %d, dn = %d, m = %d, n = %d, wait_count = %d\n",
1400 (int)up, (int)dn, (int)m, (int)n, (int)wait_count);
1401 result = 0;
1402 wait_count++;
1403
1404 if (retry_count == 0) {
1405 /* no retry in the last 2-second duration */
1406 up++;
1407 dn--;
1408
1409 if (dn <= 0)
1410 dn = 0;
1411
1412 if (up >= n) {
1413 /* if (retry count == 0) for 2*n seconds,
1414 * make WiFi duration wider
1415 */
1416 wait_count = 0;
1417 n = 3;
1418 up = 0;
1419 dn = 0;
1420 result = 1;
1421 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1422 "[BTCoex], Increase wifi duration!!\n");
1423 }
1424 } else if (retry_count <= 3) {
1425 /* <=3 retry in the last 2-second duration */
1426 up--;
1427 dn++;
1428
1429 if (up <= 0)
1430 up = 0;
1431
1432 if (dn == 2) {
1433 /* if retry count < 3 for 2*2 seconds,
1434 * shrink wifi duration
1435 */
1436 if (wait_count <= 2)
1437 m++; /* avoid bounce in two levels */
1438 else
1439 m = 1;
1440 /* m max value is 20, max time is 120 second,
1441 * recheck if adjust WiFi duration.
1442 */
1443 if (m >= 20)
1444 m = 20;
1445
1446 n = 3 * m;
1447 up = 0;
1448 dn = 0;
1449 wait_count = 0;
1450 result = -1;
1451 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1452 "[BTCoex], Decrease wifi duration for retryCounter<3!!\n");
1453 }
1454 } else {
1455 /* retry count > 3, if retry count > 3 happens once,
1456 * shrink WiFi duration
1457 */
1458 if (wait_count == 1)
1459 m++; /* avoid bounce in two levels */
1460 else
1461 m = 1;
1462 /* m max value is 20, max time is 120 second,
1463 * recheck if adjust WiFi duration.
1464 */
1465 if (m >= 20)
1466 m = 20;
1467
1468 n = 3 * m;
1469 up = 0;
1470 dn = 0;
1471 wait_count = 0;
1472 result = -1;
1473 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1474 "[BTCoex], Decrease wifi duration for retryCounter>3!!\n");
1475 }
1476
1477 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1478 "[BTCoex], max Interval = %d\n", max_interval);
1479 }
1480
1481 /* if current PsTdma not match with the recorded one
1482 * (when scan, dhcp...), then we have to adjust it back to
1483 * the previous recorded one.
1484 */
1485 if (coex_dm->cur_ps_tdma != coex_dm->tdma_adj_type) {
1486 bool scan = false, link = false, roam = false;
1487
1488 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1489 "[BTCoex], PsTdma type dismatch!!!, cur_ps_tdma = %d, recordPsTdma = %d\n",
1490 coex_dm->cur_ps_tdma, coex_dm->tdma_adj_type);
1491
1492 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
1493 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
1494 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
1495
1496 if (!scan && !link && !roam) {
1497 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
1498 coex_dm->tdma_adj_type);
1499 } else {
1500 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
1501 "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n");
1502 }
1503 }
1504
1505 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 0x6);
1506 }
1507
1508 /* SCO only or SCO+PAN(HS)*/
1509 static void btc8821a2ant_action_sco(struct btc_coexist *btcoexist)
1510 {
1511 u8 wifi_rssi_state, bt_rssi_state;
1512 u32 wifi_bw;
1513
1514 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2,
1515 15, 0);
1516 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1517
1518 btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
1519 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4);
1520
1521 if (BTC_RSSI_HIGH(bt_rssi_state))
1522 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1523 else
1524 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1525
1526 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1527
1528 if (wifi_bw == BTC_WIFI_BW_LEGACY) {
1529 /* for SCO quality at 11b/g mode */
1530 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC,
1531 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
1532 } else {
1533 /* for SCO quality & wifi performance balance at 11n mode */
1534 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC,
1535 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
1536 }
1537
1538 if (wifi_bw == BTC_WIFI_BW_HT40) {
1539
1540 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1541 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1542 /* for voice quality */
1543 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1544 false, 0);
1545 } else {
1546 /* for voice quality */
1547 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1548 false, 0);
1549 }
1550
1551 /* sw mechanism */
1552 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1553 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1554 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
1555 false, false);
1556 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1557 false, 0x18);
1558 } else {
1559 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
1560 false, false);
1561 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1562 false, 0x18);
1563 }
1564 } else {
1565 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1566 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1567 /* for voice quality */
1568 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
1569 } else {
1570 /* for voice quality */
1571 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
1572 }
1573
1574 /* sw mechanism */
1575 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1576 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1577 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
1578 false, false);
1579 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1580 false, 0x18);
1581 } else {
1582 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
1583 false, false);
1584 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1585 false, 0x18);
1586 }
1587 }
1588 }
1589
1590 static void btc8821a2ant_action_hid(struct btc_coexist *btcoexist)
1591 {
1592 u8 wifi_rssi_state, bt_rssi_state;
1593 u32 wifi_bw;
1594
1595 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
1596 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1597
1598 btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
1599 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1600
1601 if (BTC_RSSI_HIGH(bt_rssi_state))
1602 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1603 else
1604 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1605
1606 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1607
1608 if (wifi_bw == BTC_WIFI_BW_LEGACY) {
1609 /* for HID at 11b/g mode */
1610 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1611 0x5a5a5a5a, 0xffff, 0x3);
1612 } else {
1613 /* for HID quality & wifi performance balance at 11n mode */
1614 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1615 0x5aea5aea, 0xffff, 0x3);
1616 }
1617
1618 if (wifi_bw == BTC_WIFI_BW_HT40) {
1619 /* fw mechanism */
1620 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1621 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1622 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1623 true, 9);
1624 } else {
1625 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1626 true, 13);
1627 }
1628
1629 /* sw mechanism */
1630 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1631 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1632 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
1633 false, false);
1634 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1635 false, 0x18);
1636 } else {
1637 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
1638 false, false);
1639 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1640 false, 0x18);
1641 }
1642 } else {
1643 /* fw mechanism */
1644 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1645 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1646 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1647 true, 9);
1648 } else {
1649 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1650 true, 13);
1651 }
1652
1653 /* sw mechanism */
1654 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1655 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1656 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
1657 false, false);
1658 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1659 false, 0x18);
1660 } else {
1661 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
1662 false, false);
1663 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1664 false, 0x18);
1665 }
1666 }
1667 }
1668
1669 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
1670 static void btc8821a2ant_action_a2dp(struct btc_coexist *btcoexist)
1671 {
1672 u8 wifi_rssi_state, bt_rssi_state;
1673 u32 wifi_bw;
1674
1675 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2,
1676 15, 0);
1677 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1678
1679 /* fw dac swing is called in btc8821a2ant_tdma_dur_adj()
1680 * btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1681 */
1682
1683 if (BTC_RSSI_HIGH(bt_rssi_state))
1684 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1685 else
1686 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1687
1688 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1689
1690 if (BTC_WIFI_BW_HT40 == wifi_bw) {
1691 /* fw mechanism */
1692 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1693 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1694 btc8821a2ant_tdma_dur_adj(btcoexist, false, false, 1);
1695 } else {
1696 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 1);
1697 }
1698
1699 /* sw mechanism */
1700 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1701 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1702 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1703 false, false);
1704 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1705 false, 0x18);
1706 } else {
1707 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1708 false, false);
1709 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1710 false, 0x18);
1711 }
1712 } else {
1713 /* fw mechanism */
1714 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1715 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1716 btc8821a2ant_tdma_dur_adj(btcoexist, false, false, 1);
1717 } else {
1718 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 1);
1719 }
1720
1721 /* sw mechanism */
1722 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1723 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1724 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1725 false, false);
1726 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1727 false, 0x18);
1728 } else {
1729 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1730 false, false);
1731 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1732 false, 0x18);
1733 }
1734 }
1735 }
1736
1737 static void btc8821a2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
1738 {
1739 u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
1740 u32 wifi_bw;
1741
1742 bt_info_ext = coex_sta->bt_info_ext;
1743 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
1744 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1745
1746 if (BTC_RSSI_HIGH(bt_rssi_state))
1747 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1748 else
1749 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1750
1751 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1752
1753 if (wifi_bw == BTC_WIFI_BW_HT40) {
1754 /* fw mechanism */
1755 if (bt_info_ext&BIT0) {
1756 /* a2dp basic rate */
1757 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 2);
1758 } else {
1759 /* a2dp edr rate */
1760 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 1);
1761 }
1762
1763 /* sw mechanism */
1764 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1765 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1766 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1767 false, false);
1768 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1769 false, 0x18);
1770 } else {
1771 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1772 false, false);
1773 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1774 false, 0x18);
1775 }
1776 } else {
1777 /* fw mechanism */
1778 if (bt_info_ext&BIT0) {
1779 /* a2dp basic rate */
1780 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 2);
1781 } else {
1782 /* a2dp edr rate */
1783 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 1);
1784 }
1785
1786 /* sw mechanism */
1787 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1788 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1789 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1790 false, false);
1791 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1792 false, 0x18);
1793 } else {
1794 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1795 false, false);
1796 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1797 false, 0x18);
1798 }
1799 }
1800 }
1801
1802 static void btc8821a2ant_action_pan_edr(struct btc_coexist *btcoexist)
1803 {
1804 u8 wifi_rssi_state, bt_rssi_state;
1805 u32 wifi_bw;
1806
1807 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
1808 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1809
1810 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1811
1812 if (BTC_RSSI_HIGH(bt_rssi_state))
1813 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1814 else
1815 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1816
1817 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1818
1819 if (BTC_WIFI_BW_LEGACY == wifi_bw) {
1820 /* for HID at 11b/g mode */
1821 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1822 0x5aff5aff, 0xffff, 0x3);
1823 } else {
1824 /* for HID quality & wifi performance balance at 11n mode */
1825 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1826 0x5aff5aff, 0xffff, 0x3);
1827 }
1828
1829 if (BTC_WIFI_BW_HT40 == wifi_bw) {
1830 /* fw mechanism */
1831 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1832 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1833 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1834 true, 1);
1835 } else {
1836 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1837 true, 5);
1838 }
1839
1840 /* sw mechanism */
1841 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1842 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1843 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1844 false, false);
1845 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1846 false, 0x18);
1847 } else {
1848 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1849 false, false);
1850 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1851 false, 0x18);
1852 }
1853 } else {
1854 /* fw mechanism */
1855 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1856 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1857 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1858 true, 1);
1859 } else {
1860 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
1861 true, 5);
1862 }
1863
1864 /* sw mechanism */
1865 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1866 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1867 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1868 false, false);
1869 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1870 false, 0x18);
1871 } else {
1872 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1873 false, false);
1874 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1875 false, 0x18);
1876 }
1877 }
1878 }
1879
1880 /* PAN(HS) only */
1881 static void btc8821a2ant_action_pan_hs(struct btc_coexist *btcoexist)
1882 {
1883 u8 wifi_rssi_state, bt_rssi_state;
1884 u32 wifi_bw;
1885
1886 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
1887 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1888
1889 btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
1890 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1891
1892 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1893
1894 if (BTC_WIFI_BW_HT40 == wifi_bw) {
1895 /* fw mechanism */
1896 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1897 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1898 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1899 } else {
1900 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1901 }
1902 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1903
1904 /* sw mechanism */
1905 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1906 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1907 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1908 false, false);
1909 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1910 false, 0x18);
1911 } else {
1912 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1913 false, false);
1914 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1915 false, 0x18);
1916 }
1917 } else {
1918 /* fw mechanism */
1919 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1920 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1921 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1922 } else {
1923 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1924 }
1925
1926 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1927 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1928 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1929 } else {
1930 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
1931 }
1932
1933 /* sw mechanism */
1934 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1935 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1936 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1937 false, false);
1938 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1939 false, 0x18);
1940 } else {
1941 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
1942 false, false);
1943 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1944 false, 0x18);
1945 }
1946 }
1947 }
1948
1949 /* PAN(EDR)+A2DP */
1950 static void btc8821a2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
1951 {
1952 u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
1953 u32 wifi_bw;
1954
1955 bt_info_ext = coex_sta->bt_info_ext;
1956 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
1957 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
1958
1959 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
1960
1961 if (BTC_RSSI_HIGH(bt_rssi_state))
1962 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
1963 else
1964 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
1965
1966 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
1967
1968 if (wifi_bw == BTC_WIFI_BW_LEGACY) {
1969 /* for HID at 11b/g mode */
1970 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1971 0x5afa5afa, 0xffff, 0x3);
1972 } else {
1973 /* for HID quality & wifi performance balance at 11n mode */
1974 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
1975 0x5afa5afa, 0xffff, 0x3);
1976 }
1977
1978 if (BTC_WIFI_BW_HT40 == wifi_bw) {
1979 /* fw mechanism */
1980 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
1981 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
1982 btc8821a2ant_tdma_dur_adj(btcoexist, false,
1983 false, 3);
1984 else
1985 btc8821a2ant_tdma_dur_adj(btcoexist, false,
1986 true, 3);
1987
1988 /* sw mechanism */
1989 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
1990 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
1991 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1992 false, false);
1993 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
1994 false, 0x18);
1995 } else {
1996 btc8821a2ant_sw_mechanism1(btcoexist, true, false,
1997 false, false);
1998 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
1999 false, 0x18);
2000 };
2001 } else {
2002 /* fw mechanism */
2003 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
2004 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
2005 btc8821a2ant_tdma_dur_adj(btcoexist, false, false, 3);
2006 else
2007 btc8821a2ant_tdma_dur_adj(btcoexist, false, true, 3);
2008
2009 /* sw mechanism */
2010 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2011 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2012 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
2013 false, false);
2014 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2015 false, 0x18);
2016 } else {
2017 btc8821a2ant_sw_mechanism1(btcoexist, false, false,
2018 false, false);
2019 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2020 false, 0x18);
2021 }
2022 }
2023 }
2024
2025 static void btc8821a2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
2026 {
2027 u8 wifi_rssi_state, bt_rssi_state;
2028 u32 wifi_bw;
2029
2030 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
2031 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
2032
2033 btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
2034 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2035
2036 if (BTC_RSSI_HIGH(bt_rssi_state))
2037 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
2038 else
2039 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
2040
2041 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2042
2043 if (wifi_bw == BTC_WIFI_BW_LEGACY) {
2044 /* for HID at 11b/g mode */
2045 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
2046 0x5a5f5a5f, 0xffff, 0x3);
2047 } else {
2048 /* for HID quality & wifi performance balance at 11n mode */
2049 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
2050 0x5a5f5a5f, 0xffff, 0x3);
2051 }
2052
2053 if (wifi_bw == BTC_WIFI_BW_HT40) {
2054 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 3);
2055 /* fw mechanism */
2056 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
2057 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2058 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC,
2059 true, 10);
2060 } else {
2061 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
2062 }
2063
2064 /* sw mechanism */
2065 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2066 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2067 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
2068 false, false);
2069 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2070 false, 0x18);
2071 } else {
2072 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
2073 false, false);
2074 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2075 false, 0x18);
2076 }
2077 } else {
2078 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2079 /* fw mechanism */
2080 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
2081 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2082 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
2083 } else {
2084 btc8821a2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
2085 }
2086
2087 /* sw mechanism */
2088 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2089 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2090 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
2091 false, false);
2092 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2093 false, 0x18);
2094 } else {
2095 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
2096 false, false);
2097 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2098 false, 0x18);
2099 }
2100 }
2101 }
2102
2103 /* HID+A2DP+PAN(EDR) */
2104 static void btc8821a2ant_act_hid_a2dp_pan_edr(struct btc_coexist *btcoexist)
2105 {
2106 u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
2107 u32 wifi_bw;
2108
2109 bt_info_ext = coex_sta->bt_info_ext;
2110 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
2111 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
2112
2113 btc8821a2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
2114 btc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
2115
2116 if (BTC_RSSI_HIGH(bt_rssi_state))
2117 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
2118 else
2119 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
2120
2121 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2122
2123 if (wifi_bw == BTC_WIFI_BW_LEGACY) {
2124 /* for HID at 11b/g mode */
2125 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
2126 0x5a5a5a5a, 0xffff, 0x3);
2127 } else {
2128 /* for HID quality & wifi performance balance at 11n mode */
2129 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
2130 0x5a5a5a5a, 0xffff, 0x3);
2131 }
2132
2133 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2134 /* fw mechanism */
2135 btc8821a2ant_tdma_dur_adj(btcoexist, true, true, 3);
2136
2137 /* sw mechanism */
2138 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2139 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2140 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
2141 false, false);
2142 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2143 false, 0x18);
2144 } else {
2145 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
2146 false, false);
2147 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2148 false, 0x18);
2149 }
2150 } else {
2151 /* fw mechanism */
2152 if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
2153 (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2154 if (bt_info_ext&BIT0) {
2155 /* a2dp basic rate */
2156 btc8821a2ant_tdma_dur_adj(btcoexist, true,
2157 false, 3);
2158 } else {
2159 /* a2dp edr rate */
2160 btc8821a2ant_tdma_dur_adj(btcoexist, true,
2161 false, 3);
2162 }
2163 } else {
2164 if (bt_info_ext&BIT0) {
2165 /* a2dp basic rate */
2166 btc8821a2ant_tdma_dur_adj(btcoexist, true,
2167 true, 3);
2168 } else {
2169 /* a2dp edr rate */
2170 btc8821a2ant_tdma_dur_adj(btcoexist, true,
2171 true, 3);
2172 }
2173 }
2174
2175 /* sw mechanism */
2176 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2177 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2178 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
2179 false, false);
2180 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2181 false, 0x18);
2182 } else {
2183 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
2184 false, false);
2185 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2186 false, 0x18);
2187 }
2188 }
2189 }
2190
2191 static void btc8821a2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
2192 {
2193 u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
2194 u32 wifi_bw;
2195
2196 bt_info_ext = coex_sta->bt_info_ext;
2197 wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 0, 2, 15, 0);
2198 bt_rssi_state = btc8821a2ant_bt_rssi_state(btcoexist, 2, 35, 0);
2199
2200 if (BTC_RSSI_HIGH(bt_rssi_state))
2201 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
2202 else
2203 btc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
2204
2205 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2206
2207 if (wifi_bw == BTC_WIFI_BW_LEGACY) {
2208 /* for HID at 11b/g mode */
2209 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
2210 0x5f5b5f5b, 0xffffff, 0x3);
2211 } else {
2212 /* for HID quality & wifi performance balance at 11n mode */
2213 btc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff,
2214 0x5f5b5f5b, 0xffffff, 0x3);
2215 }
2216
2217 if (BTC_WIFI_BW_HT40 == wifi_bw) {
2218 /* fw mechanism */
2219 btc8821a2ant_tdma_dur_adj(btcoexist, true, true, 2);
2220
2221 /* sw mechanism */
2222 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2223 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2224 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
2225 false, false);
2226 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2227 false, 0x18);
2228 } else {
2229 btc8821a2ant_sw_mechanism1(btcoexist, true, true,
2230 false, false);
2231 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2232 false, 0x18);
2233 }
2234 } else {
2235 /* fw mechanism */
2236 btc8821a2ant_tdma_dur_adj(btcoexist, true, true, 2);
2237
2238 /* sw mechanism */
2239 if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
2240 (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
2241 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
2242 false, false);
2243 btc8821a2ant_sw_mechanism2(btcoexist, true, false,
2244 false, 0x18);
2245 } else {
2246 btc8821a2ant_sw_mechanism1(btcoexist, false, true,
2247 false, false);
2248 btc8821a2ant_sw_mechanism2(btcoexist, false, false,
2249 false, 0x18);
2250 }
2251 }
2252 }
2253
2254 static void btc8821a2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
2255 {
2256 struct rtl_priv *rtlpriv = btcoexist->adapter;
2257 bool wifi_under_5g = false;
2258 u8 algorithm = 0;
2259
2260 if (btcoexist->manual_control) {
2261 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2262 "[BTCoex], Manual control!!!\n");
2263 return;
2264 }
2265
2266 btcoexist->btc_get(btcoexist,
2267 BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
2268
2269 if (wifi_under_5g) {
2270 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2271 "[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n");
2272 btc8821a2ant_coex_under_5g(btcoexist);
2273 return;
2274 }
2275
2276 algorithm = btc8821a2ant_action_algorithm(btcoexist);
2277 if (coex_sta->c2h_bt_inquiry_page &&
2278 (BT_8821A_2ANT_COEX_ALGO_PANHS != algorithm)) {
2279 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2280 "[BTCoex], BT is under inquiry/page scan !!\n");
2281 btc8821a2ant_bt_inquiry_page(btcoexist);
2282 return;
2283 }
2284
2285 coex_dm->cur_algorithm = algorithm;
2286 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2287 "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm);
2288
2289 if (btc8821a2ant_is_common_action(btcoexist)) {
2290 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2291 "[BTCoex], Action 2-Ant common\n");
2292 coex_dm->reset_tdma_adjust = true;
2293 } else {
2294 if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) {
2295 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2296 "[BTCoex], pre_algorithm = %d, cur_algorithm = %d\n",
2297 coex_dm->pre_algorithm,
2298 coex_dm->cur_algorithm);
2299 coex_dm->reset_tdma_adjust = true;
2300 }
2301 switch (coex_dm->cur_algorithm) {
2302 case BT_8821A_2ANT_COEX_ALGO_SCO:
2303 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2304 "[BTCoex], Action 2-Ant, algorithm = SCO\n");
2305 btc8821a2ant_action_sco(btcoexist);
2306 break;
2307 case BT_8821A_2ANT_COEX_ALGO_HID:
2308 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2309 "[BTCoex], Action 2-Ant, algorithm = HID\n");
2310 btc8821a2ant_action_hid(btcoexist);
2311 break;
2312 case BT_8821A_2ANT_COEX_ALGO_A2DP:
2313 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2314 "[BTCoex], Action 2-Ant, algorithm = A2DP\n");
2315 btc8821a2ant_action_a2dp(btcoexist);
2316 break;
2317 case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS:
2318 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2319 "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS)\n");
2320 btc8821a2ant_action_a2dp_pan_hs(btcoexist);
2321 break;
2322 case BT_8821A_2ANT_COEX_ALGO_PANEDR:
2323 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2324 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)\n");
2325 btc8821a2ant_action_pan_edr(btcoexist);
2326 break;
2327 case BT_8821A_2ANT_COEX_ALGO_PANHS:
2328 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2329 "[BTCoex], Action 2-Ant, algorithm = HS mode\n");
2330 btc8821a2ant_action_pan_hs(btcoexist);
2331 break;
2332 case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP:
2333 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2334 "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP\n");
2335 btc8821a2ant_action_pan_edr_a2dp(btcoexist);
2336 break;
2337 case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID:
2338 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2339 "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID\n");
2340 btc8821a2ant_action_pan_edr_hid(btcoexist);
2341 break;
2342 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
2343 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2344 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN\n");
2345 btc8821a2ant_act_hid_a2dp_pan_edr(btcoexist);
2346 break;
2347 case BT_8821A_2ANT_COEX_ALGO_HID_A2DP:
2348 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2349 "[BTCoex], Action 2-Ant, algorithm = HID+A2DP\n");
2350 btc8821a2ant_action_hid_a2dp(btcoexist);
2351 break;
2352 default:
2353 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2354 "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n");
2355 btc8821a2ant_coex_all_off(btcoexist);
2356 break;
2357 }
2358 coex_dm->pre_algorithm = coex_dm->cur_algorithm;
2359 }
2360 }
2361
2362 /**************************************************************
2363 * extern function start with ex_btc8821a2ant_
2364 **************************************************************/
2365 void ex_btc8821a2ant_init_hwconfig(struct btc_coexist *btcoexist)
2366 {
2367 struct rtl_priv *rtlpriv = btcoexist->adapter;
2368 u8 u1tmp = 0;
2369
2370 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2371 "[BTCoex], 2Ant Init HW Config!!\n");
2372
2373 /* backup rf 0x1e value */
2374 coex_dm->bt_rf0x1e_backup =
2375 btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff);
2376
2377 /* 0x790[5:0] = 0x5 */
2378 u1tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
2379 u1tmp &= 0xc0;
2380 u1tmp |= 0x5;
2381 btcoexist->btc_write_1byte(btcoexist, 0x790, u1tmp);
2382
2383 /*Antenna config */
2384 btc8821a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN, true, false);
2385
2386 /* PTA parameter */
2387 btc8821a2ant_coex_table(btcoexist, FORCE_EXEC, 0x55555555, 0x55555555,
2388 0xffff, 0x3);
2389
2390 /* Enable counter statistics */
2391 /*0x76e[3] = 1, WLAN_Act control by PTA*/
2392 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
2393 btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3);
2394 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
2395 }
2396
2397 void ex_btc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist)
2398 {
2399 struct rtl_priv *rtlpriv = btcoexist->adapter;
2400
2401 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2402 "[BTCoex], Coex Mechanism Init!!\n");
2403
2404 btc8821a2ant_init_coex_dm(btcoexist);
2405 }
2406
2407 void ex_btc8821a2ant_display_coex_info(struct btc_coexist *btcoexist)
2408 {
2409 struct btc_board_info *board_info = &btcoexist->board_info;
2410 struct btc_stack_info *stack_info = &btcoexist->stack_info;
2411 struct rtl_priv *rtlpriv = btcoexist->adapter;
2412 u8 u1tmp[4], i, bt_info_ext, ps_tdma_case = 0;
2413 u32 u4tmp[4];
2414 bool roam = false, scan = false, link = false, wifi_under_5g = false;
2415 bool bt_hs_on = false, wifi_busy = false;
2416 long wifi_rssi = 0, bt_hs_rssi = 0;
2417 u32 wifi_bw, wifi_traffic_dir;
2418 u8 wifi_dot_11_chnl, wifi_hs_chnl;
2419 u32 fw_ver = 0, bt_patch_ver = 0;
2420
2421 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2422 "\r\n ============[BT Coexist info]============");
2423
2424 if (!board_info->bt_exist) {
2425 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n BT not exists !!!");
2426 return;
2427 }
2428
2429 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2430 "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:",
2431 board_info->pg_ant_num, board_info->btdm_ant_num);
2432
2433 if (btcoexist->manual_control) {
2434 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2435 "\r\n %-35s", "[Action Manual control]!!");
2436 }
2437
2438 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2439 "\r\n %-35s = %s / %d", "BT stack/ hci ext ver",
2440 ((stack_info->profile_notified) ? "Yes" : "No"),
2441 stack_info->hci_version);
2442
2443 btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
2444 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
2445 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2446 "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
2447 "CoexVer/ FwVer/ PatchVer",
2448 glcoex_ver_date_8821a_2ant, glcoex_ver_8821a_2ant,
2449 fw_ver, bt_patch_ver, bt_patch_ver);
2450
2451 btcoexist->btc_get(btcoexist,
2452 BTC_GET_BL_HS_OPERATION, &bt_hs_on);
2453 btcoexist->btc_get(btcoexist,
2454 BTC_GET_U1_WIFI_DOT11_CHNL, &wifi_dot_11_chnl);
2455 btcoexist->btc_get(btcoexist,
2456 BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl);
2457 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2458 "\r\n %-35s = %d / %d(%d)",
2459 "Dot11 channel / HsMode(HsChnl)",
2460 wifi_dot_11_chnl, bt_hs_on, wifi_hs_chnl);
2461
2462 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2463 "\r\n %-35s = %3ph ",
2464 "H2C Wifi inform bt chnl Info",
2465 coex_dm->wifi_chnl_info);
2466
2467 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
2468 btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
2469 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2470 "\r\n %-35s = %ld/ %ld", "Wifi rssi/ HS rssi",
2471 wifi_rssi, bt_hs_rssi);
2472
2473 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
2474 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
2475 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
2476 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2477 "\r\n %-35s = %d/ %d/ %d ", "Wifi link/ roam/ scan",
2478 link, roam, scan);
2479
2480 btcoexist->btc_get(btcoexist,
2481 BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
2482 btcoexist->btc_get(btcoexist,
2483 BTC_GET_U4_WIFI_BW, &wifi_bw);
2484 btcoexist->btc_get(btcoexist,
2485 BTC_GET_BL_WIFI_BUSY, &wifi_busy);
2486 btcoexist->btc_get(btcoexist,
2487 BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifi_traffic_dir);
2488 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2489 "\r\n %-35s = %s / %s/ %s ", "Wifi status",
2490 (wifi_under_5g ? "5G" : "2.4G"),
2491 ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" :
2492 (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))),
2493 ((!wifi_busy) ? "idle" :
2494 ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ?
2495 "uplink" : "downlink")));
2496
2497 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2498 "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]",
2499 ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") :
2500 ((BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status)
2501 ? "idle" : ((BT_8821A_2ANT_BT_STATUS_CON_IDLE ==
2502 coex_dm->bt_status) ? "connected-idle" : "busy"))),
2503 coex_sta->bt_rssi, coex_sta->bt_retry_cnt);
2504
2505 if (stack_info->profile_notified) {
2506 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2507 "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP",
2508 stack_info->sco_exist, stack_info->hid_exist,
2509 stack_info->pan_exist, stack_info->a2dp_exist);
2510
2511 btcoexist->btc_disp_dbg_msg(btcoexist,
2512 BTC_DBG_DISP_BT_LINK_INFO);
2513 }
2514
2515 bt_info_ext = coex_sta->bt_info_ext;
2516 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = %s",
2517 "BT Info A2DP rate",
2518 (bt_info_ext&BIT0) ? "Basic rate" : "EDR rate");
2519
2520 for (i = 0; i < BT_INFO_SRC_8821A_2ANT_MAX; i++) {
2521 if (coex_sta->bt_info_c2h_cnt[i]) {
2522 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2523 "\r\n %-35s = %7ph(%d)",
2524 glbt_info_src_8821a_2ant[i],
2525 coex_sta->bt_info_c2h[i],
2526 coex_sta->bt_info_c2h_cnt[i]);
2527 }
2528 }
2529
2530 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = %s/%s",
2531 "PS state, IPS/LPS",
2532 ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")),
2533 ((coex_sta->under_lps ? "LPS ON" : "LPS OFF")));
2534 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
2535
2536 /* Sw mechanism*/
2537 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s",
2538 "============[Sw mechanism]============");
2539 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2540 "\r\n %-35s = %d/ %d/ %d/ %d ",
2541 "SM1[ShRf/ LpRA/ LimDig/ btLna]",
2542 coex_dm->cur_rf_rx_lpf_shrink, coex_dm->cur_low_penalty_ra,
2543 coex_dm->limited_dig, coex_dm->cur_bt_lna_constrain);
2544 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2545 "\r\n %-35s = %d/ %d/ %d(0x%x) ",
2546 "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
2547 coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off,
2548 coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl);
2549
2550 /* Fw mechanism*/
2551 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s",
2552 "============[Fw mechanism]============");
2553
2554 if (!btcoexist->manual_control) {
2555 ps_tdma_case = coex_dm->cur_ps_tdma;
2556 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2557 "\r\n %-35s = %5ph case-%d",
2558 "PS TDMA",
2559 coex_dm->ps_tdma_para, ps_tdma_case);
2560
2561 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2562 "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct",
2563 coex_dm->cur_dec_bt_pwr,
2564 coex_dm->cur_ignore_wlan_act);
2565 }
2566
2567 /* Hw setting*/
2568 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2569 "\r\n %-35s", "============[Hw setting]============");
2570
2571 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
2572 "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal",
2573 coex_dm->bt_rf0x1e_backup);
2574
2575 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
2576 u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
2577 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x ",
2578 "0x778 (W_Act)/ 0x6cc (CoTab Sel)",
2579 u1tmp[0], u1tmp[1]);
2580
2581 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x8db);
2582 u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xc5b);
2583 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x",
2584 "0x8db(ADC)/0xc5b[29:25](DAC)",
2585 ((u1tmp[0] & 0x60) >> 5), ((u1tmp[1] & 0x3e) >> 1));
2586
2587 u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
2588 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x",
2589 "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)",
2590 u4tmp[0] & 0xff, ((u4tmp[0] & 0x30000000) >> 28));
2591
2592 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40);
2593 u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
2594 u4tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x974);
2595 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
2596 "0x40/ 0x4c[24:23]/ 0x974",
2597 u1tmp[0], ((u4tmp[0] & 0x01800000) >> 23), u4tmp[1]);
2598
2599 u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
2600 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
2601 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x",
2602 "0x550(bcn ctrl)/0x522",
2603 u4tmp[0], u1tmp[0]);
2604
2605 u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
2606 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa0a);
2607 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x",
2608 "0xc50(DIG)/0xa0a(CCK-TH)",
2609 u4tmp[0], u1tmp[0]);
2610
2611 u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48);
2612 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b);
2613 u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
2614 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x",
2615 "OFDM-FA/ CCK-FA",
2616 u4tmp[0], (u1tmp[0] << 8) + u1tmp[1]);
2617
2618 u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
2619 u4tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
2620 u4tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
2621 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
2622 "0x6c0/0x6c4/0x6c8",
2623 u4tmp[0], u4tmp[1], u4tmp[2]);
2624
2625 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = %d/ %d",
2626 "0x770 (hi-pri Rx/Tx)",
2627 coex_sta->high_priority_rx, coex_sta->high_priority_tx);
2628 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = %d/ %d",
2629 "0x774(low-pri Rx/Tx)",
2630 coex_sta->low_priority_rx, coex_sta->low_priority_tx);
2631
2632 /* Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang*/
2633 u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x41b);
2634 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "\r\n %-35s = 0x%x",
2635 "0x41b (mgntQ hang chk == 0xf)",
2636 u1tmp[0]);
2637
2638 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
2639 }
2640
2641 void ex_btc8821a2ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
2642 {
2643 struct rtl_priv *rtlpriv = btcoexist->adapter;
2644
2645 if (BTC_IPS_ENTER == type) {
2646 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2647 "[BTCoex], IPS ENTER notify\n");
2648 coex_sta->under_ips = true;
2649 btc8821a2ant_coex_all_off(btcoexist);
2650 } else if (BTC_IPS_LEAVE == type) {
2651 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2652 "[BTCoex], IPS LEAVE notify\n");
2653 coex_sta->under_ips = false;
2654 }
2655 }
2656
2657 void ex_btc8821a2ant_lps_notify(struct btc_coexist *btcoexist, u8 type)
2658 {
2659 struct rtl_priv *rtlpriv = btcoexist->adapter;
2660
2661 if (BTC_LPS_ENABLE == type) {
2662 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2663 "[BTCoex], LPS ENABLE notify\n");
2664 coex_sta->under_lps = true;
2665 } else if (BTC_LPS_DISABLE == type) {
2666 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2667 "[BTCoex], LPS DISABLE notify\n");
2668 coex_sta->under_lps = false;
2669 }
2670 }
2671
2672 void ex_btc8821a2ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
2673 {
2674 struct rtl_priv *rtlpriv = btcoexist->adapter;
2675
2676 if (BTC_SCAN_START == type) {
2677 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2678 "[BTCoex], SCAN START notify\n");
2679 } else if (BTC_SCAN_FINISH == type) {
2680 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2681 "[BTCoex], SCAN FINISH notify\n");
2682 }
2683 }
2684
2685 void ex_btc8821a2ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
2686 {
2687 struct rtl_priv *rtlpriv = btcoexist->adapter;
2688
2689 if (BTC_ASSOCIATE_START == type) {
2690 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2691 "[BTCoex], CONNECT START notify\n");
2692 } else if (BTC_ASSOCIATE_FINISH == type) {
2693 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2694 "[BTCoex], CONNECT FINISH notify\n");
2695 }
2696 }
2697
2698 void ex_btc8821a2ant_media_status_notify(struct btc_coexist *btcoexist,
2699 u8 type)
2700 {
2701 struct rtl_priv *rtlpriv = btcoexist->adapter;
2702 u8 h2c_parameter[3] = {0};
2703 u32 wifi_bw;
2704 u8 wifi_central_chnl;
2705
2706 if (BTC_MEDIA_CONNECT == type) {
2707 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2708 "[BTCoex], MEDIA connect notify\n");
2709 } else {
2710 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2711 "[BTCoex], MEDIA disconnect notify\n");
2712 }
2713
2714 /* only 2.4G we need to inform bt the chnl mask */
2715 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
2716 &wifi_central_chnl);
2717 if ((BTC_MEDIA_CONNECT == type) &&
2718 (wifi_central_chnl <= 14)) {
2719 h2c_parameter[0] = 0x1;
2720 h2c_parameter[1] = wifi_central_chnl;
2721 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
2722 if (BTC_WIFI_BW_HT40 == wifi_bw)
2723 h2c_parameter[2] = 0x30;
2724 else
2725 h2c_parameter[2] = 0x20;
2726 }
2727
2728 coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
2729 coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
2730 coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
2731
2732 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2733 "[BTCoex], FW write 0x66 = 0x%x\n",
2734 h2c_parameter[0] << 16 |
2735 h2c_parameter[1] << 8 |
2736 h2c_parameter[2]);
2737
2738 btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
2739 }
2740
2741 void ex_btc8821a2ant_special_packet_notify(struct btc_coexist *btcoexist,
2742 u8 type)
2743 {
2744 struct rtl_priv *rtlpriv = btcoexist->adapter;
2745
2746 if (type == BTC_PACKET_DHCP) {
2747 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2748 "[BTCoex], DHCP Packet notify\n");
2749 }
2750 }
2751
2752 void ex_btc8821a2ant_bt_info_notify(struct btc_coexist *btcoexist,
2753 u8 *tmp_buf, u8 length)
2754 {
2755 struct rtl_priv *rtlpriv = btcoexist->adapter;
2756 u8 bt_info = 0;
2757 u8 i, rsp_source = 0;
2758 bool bt_busy = false, limited_dig = false;
2759 bool wifi_connected = false, bt_hs_on = false;
2760
2761 coex_sta->c2h_bt_info_req_sent = false;
2762
2763 rsp_source = tmp_buf[0] & 0xf;
2764 if (rsp_source >= BT_INFO_SRC_8821A_2ANT_MAX)
2765 rsp_source = BT_INFO_SRC_8821A_2ANT_WIFI_FW;
2766 coex_sta->bt_info_c2h_cnt[rsp_source]++;
2767
2768 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2769 "[BTCoex], Bt info[%d], length = %d, hex data = [",
2770 rsp_source, length);
2771 for (i = 0; i < length; i++) {
2772 coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
2773 if (i == 1)
2774 bt_info = tmp_buf[i];
2775 if (i == length - 1) {
2776 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2777 "0x%02x]\n", tmp_buf[i]);
2778 } else {
2779 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2780 "0x%02x, ", tmp_buf[i]);
2781 }
2782 }
2783
2784 if (BT_INFO_SRC_8821A_2ANT_WIFI_FW != rsp_source) {
2785 /* [3:0] */
2786 coex_sta->bt_retry_cnt =
2787 coex_sta->bt_info_c2h[rsp_source][2]&0xf;
2788
2789 coex_sta->bt_rssi =
2790 coex_sta->bt_info_c2h[rsp_source][3]*2+10;
2791
2792 coex_sta->bt_info_ext =
2793 coex_sta->bt_info_c2h[rsp_source][4];
2794
2795 /* Here we need to resend some wifi info to BT
2796 * because bt is reset and loss of the info
2797 */
2798 if ((coex_sta->bt_info_ext & BIT1)) {
2799 btcoexist->btc_get(btcoexist,
2800 BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
2801 if (wifi_connected) {
2802 ex_btc8821a2ant_media_status_notify(btcoexist,
2803 BTC_MEDIA_CONNECT);
2804 } else {
2805 ex_btc8821a2ant_media_status_notify(btcoexist,
2806 BTC_MEDIA_DISCONNECT);
2807 }
2808
2809 }
2810
2811 if ((coex_sta->bt_info_ext & BIT3)) {
2812 btc8821a2ant_ignore_wlan_act(btcoexist,
2813 FORCE_EXEC, false);
2814 } else {
2815 /* BT already NOT ignore Wlan active, do nothing here.*/
2816 }
2817 }
2818
2819 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
2820 /* check BIT2 first ==> check if bt is under inquiry or page scan*/
2821 if (bt_info & BT_INFO_8821A_2ANT_B_INQ_PAGE) {
2822 coex_sta->c2h_bt_inquiry_page = true;
2823 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE;
2824 } else {
2825 coex_sta->c2h_bt_inquiry_page = false;
2826 if (bt_info == 0x1) {
2827 /* connection exists but not busy*/
2828 coex_sta->bt_link_exist = true;
2829 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_CON_IDLE;
2830 } else if (bt_info & BT_INFO_8821A_2ANT_B_CONNECTION) {
2831 /* connection exists and some link is busy*/
2832 coex_sta->bt_link_exist = true;
2833 if (bt_info & BT_INFO_8821A_2ANT_B_FTP)
2834 coex_sta->pan_exist = true;
2835 else
2836 coex_sta->pan_exist = false;
2837 if (bt_info & BT_INFO_8821A_2ANT_B_A2DP)
2838 coex_sta->a2dp_exist = true;
2839 else
2840 coex_sta->a2dp_exist = false;
2841 if (bt_info & BT_INFO_8821A_2ANT_B_HID)
2842 coex_sta->hid_exist = true;
2843 else
2844 coex_sta->hid_exist = false;
2845 if (bt_info & BT_INFO_8821A_2ANT_B_SCO_ESCO)
2846 coex_sta->sco_exist = true;
2847 else
2848 coex_sta->sco_exist = false;
2849 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE;
2850 } else {
2851 coex_sta->bt_link_exist = false;
2852 coex_sta->pan_exist = false;
2853 coex_sta->a2dp_exist = false;
2854 coex_sta->hid_exist = false;
2855 coex_sta->sco_exist = false;
2856 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_IDLE;
2857 }
2858
2859 if (bt_hs_on)
2860 coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE;
2861 }
2862
2863 if (BT_8821A_2ANT_BT_STATUS_NON_IDLE == coex_dm->bt_status)
2864 bt_busy = true;
2865 else
2866 bt_busy = false;
2867 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
2868
2869 if (BT_8821A_2ANT_BT_STATUS_IDLE != coex_dm->bt_status)
2870 limited_dig = true;
2871 else
2872 limited_dig = false;
2873 coex_dm->limited_dig = limited_dig;
2874 btcoexist->btc_set(btcoexist,
2875 BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
2876
2877 btc8821a2ant_run_coexist_mechanism(btcoexist);
2878 }
2879
2880 void ex_btc8821a2ant_halt_notify(struct btc_coexist *btcoexist)
2881 {
2882 struct rtl_priv *rtlpriv = btcoexist->adapter;
2883
2884 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2885 "[BTCoex], Halt notify\n");
2886
2887 btc8821a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
2888 ex_btc8821a2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
2889 }
2890
2891 void ex_btc8821a2ant_periodical(struct btc_coexist *btcoexist)
2892 {
2893 struct rtl_priv *rtlpriv = btcoexist->adapter;
2894 static u8 dis_ver_info_cnt;
2895 struct btc_board_info *board_info = &btcoexist->board_info;
2896 struct btc_stack_info *stack_info = &btcoexist->stack_info;
2897 u32 fw_ver = 0, bt_patch_ver = 0;
2898
2899 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2900 "[BTCoex], ==========================Periodical===========================\n");
2901
2902 if (dis_ver_info_cnt <= 5) {
2903 dis_ver_info_cnt += 1;
2904 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2905 "[BTCoex], ****************************************************************\n");
2906 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2907 "[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
2908 board_info->pg_ant_num,
2909 board_info->btdm_ant_num,
2910 board_info->btdm_ant_pos);
2911 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2912 "[BTCoex], BT stack/ hci ext ver = %s / %d\n",
2913 stack_info->profile_notified ? "Yes" : "No",
2914 stack_info->hci_version);
2915 btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER,
2916 &bt_patch_ver);
2917 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
2918 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2919 "[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
2920 glcoex_ver_date_8821a_2ant, glcoex_ver_8821a_2ant,
2921 fw_ver, bt_patch_ver, bt_patch_ver);
2922 RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
2923 "[BTCoex], ****************************************************************\n");
2924 }
2925
2926 btc8821a2ant_query_bt_info(btcoexist);
2927 btc8821a2ant_monitor_bt_ctr(btcoexist);
2928 btc8821a2ant_monitor_wifi_ctr(btcoexist);
2929 }