1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* ************************************************************
3 * Description:
4 *
5 * This file is for RTL8822B Co-exist mechanism
6 *
7 * History
8 * 2012/11/15 Cosa first check in.
9 *
10 * ************************************************************ */
11
12 /* ************************************************************
13 * include files
14 * ************************************************************ */
15 /*only for rf4ce*/
16 #include "Mp_Precomp.h"
17
18 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
19
20 #if (RTL8822B_SUPPORT == 1)
21 /* ************************************************************
22 * Global variables, these are static variables
23 * ************************************************************ */
24 static u8 *trace_buf = &gl_btc_trace_buf[0];
25 static struct coex_dm_8822b_1ant glcoex_dm_8822b_1ant;
26 static struct coex_dm_8822b_1ant *coex_dm = &glcoex_dm_8822b_1ant;
27 static struct coex_sta_8822b_1ant glcoex_sta_8822b_1ant;
28 static struct coex_sta_8822b_1ant *coex_sta = &glcoex_sta_8822b_1ant;
29 static struct psdscan_sta_8822b_1ant gl_psd_scan_8822b_1ant;
30 static struct psdscan_sta_8822b_1ant *psd_scan = &gl_psd_scan_8822b_1ant;
31 static struct rfe_type_8822b_1ant gl_rfe_type_8822b_1ant;
32 static struct rfe_type_8822b_1ant *rfe_type = &gl_rfe_type_8822b_1ant;
33
34
35
36 const char *const glbt_info_src_8822b_1ant[] = {
37 "BT Info[wifi fw]",
38 "BT Info[bt rsp]",
39 "BT Info[bt auto report]",
40 };
41
42 u32 glcoex_ver_date_8822b_1ant = 20170113;
43 u32 glcoex_ver_8822b_1ant = 0x41;
44 u32 glcoex_ver_btdesired_8822b_1ant = 0x41;
45
46
47 /* ************************************************************
48 * local function proto type if needed
49 * ************************************************************
50 * ************************************************************
51 * local function start with halbtc8822b1ant_
52 * ************************************************************ */
halbtc8822b1ant_bt_rssi_state(u8 level_num,u8 rssi_thresh,u8 rssi_thresh1)53 u8 halbtc8822b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1)
54 {
55 s32 bt_rssi = 0;
56 u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
57
58 bt_rssi = coex_sta->bt_rssi;
59
60 if (level_num == 2) {
61 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
62 (coex_sta->pre_bt_rssi_state ==
63 BTC_RSSI_STATE_STAY_LOW)) {
64 if (bt_rssi >= (rssi_thresh +
65 BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
66 bt_rssi_state = BTC_RSSI_STATE_HIGH;
67 else
68 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
69 } else {
70 if (bt_rssi < rssi_thresh)
71 bt_rssi_state = BTC_RSSI_STATE_LOW;
72 else
73 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
74 }
75 } else if (level_num == 3) {
76 if (rssi_thresh > rssi_thresh1) {
77 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
78 "[BTCoex], BT Rssi thresh error!!\n");
79 BTC_TRACE(trace_buf);
80 return coex_sta->pre_bt_rssi_state;
81 }
82
83 if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
84 (coex_sta->pre_bt_rssi_state ==
85 BTC_RSSI_STATE_STAY_LOW)) {
86 if (bt_rssi >= (rssi_thresh +
87 BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
88 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
89 else
90 bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
91 } else if ((coex_sta->pre_bt_rssi_state ==
92 BTC_RSSI_STATE_MEDIUM) ||
93 (coex_sta->pre_bt_rssi_state ==
94 BTC_RSSI_STATE_STAY_MEDIUM)) {
95 if (bt_rssi >= (rssi_thresh1 +
96 BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
97 bt_rssi_state = BTC_RSSI_STATE_HIGH;
98 else if (bt_rssi < rssi_thresh)
99 bt_rssi_state = BTC_RSSI_STATE_LOW;
100 else
101 bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
102 } else {
103 if (bt_rssi < rssi_thresh1)
104 bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
105 else
106 bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
107 }
108 }
109
110 coex_sta->pre_bt_rssi_state = bt_rssi_state;
111
112 return bt_rssi_state;
113 }
114
halbtc8822b1ant_wifi_rssi_state(IN struct btc_coexist * btcoexist,IN u8 index,IN u8 level_num,IN u8 rssi_thresh,IN u8 rssi_thresh1)115 u8 halbtc8822b1ant_wifi_rssi_state(IN struct btc_coexist *btcoexist,
116 IN u8 index, IN u8 level_num, IN u8 rssi_thresh, IN u8 rssi_thresh1)
117 {
118 s32 wifi_rssi = 0;
119 u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
120
121 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
122
123 if (level_num == 2) {
124 if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW)
125 ||
126 (coex_sta->pre_wifi_rssi_state[index] ==
127 BTC_RSSI_STATE_STAY_LOW)) {
128 if (wifi_rssi >= (rssi_thresh +
129 BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
130 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
131 else
132 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
133 } else {
134 if (wifi_rssi < rssi_thresh)
135 wifi_rssi_state = BTC_RSSI_STATE_LOW;
136 else
137 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
138 }
139 } else if (level_num == 3) {
140 if (rssi_thresh > rssi_thresh1) {
141 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
142 "[BTCoex], wifi RSSI thresh error!!\n");
143 BTC_TRACE(trace_buf);
144 return coex_sta->pre_wifi_rssi_state[index];
145 }
146
147 if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW)
148 ||
149 (coex_sta->pre_wifi_rssi_state[index] ==
150 BTC_RSSI_STATE_STAY_LOW)) {
151 if (wifi_rssi >= (rssi_thresh +
152 BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
153 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
154 else
155 wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
156 } else if ((coex_sta->pre_wifi_rssi_state[index] ==
157 BTC_RSSI_STATE_MEDIUM) ||
158 (coex_sta->pre_wifi_rssi_state[index] ==
159 BTC_RSSI_STATE_STAY_MEDIUM)) {
160 if (wifi_rssi >= (rssi_thresh1 +
161 BTC_RSSI_COEX_THRESH_TOL_8822B_1ANT))
162 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
163 else if (wifi_rssi < rssi_thresh)
164 wifi_rssi_state = BTC_RSSI_STATE_LOW;
165 else
166 wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
167 } else {
168 if (wifi_rssi < rssi_thresh1)
169 wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
170 else
171 wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
172 }
173 }
174
175 coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
176
177 return wifi_rssi_state;
178 }
179
halbtc8822b1ant_update_ra_mask(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u32 dis_rate_mask)180 void halbtc8822b1ant_update_ra_mask(IN struct btc_coexist *btcoexist,
181 IN boolean force_exec, IN u32 dis_rate_mask)
182 {
183 coex_dm->cur_ra_mask = dis_rate_mask;
184
185 if (force_exec || (coex_dm->pre_ra_mask != coex_dm->cur_ra_mask))
186 btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_RAMASK,
187 &coex_dm->cur_ra_mask);
188 coex_dm->pre_ra_mask = coex_dm->cur_ra_mask;
189 }
190
halbtc8822b1ant_auto_rate_fallback_retry(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 type)191 void halbtc8822b1ant_auto_rate_fallback_retry(IN struct btc_coexist *btcoexist,
192 IN boolean force_exec, IN u8 type)
193 {
194 boolean wifi_under_b_mode = false;
195
196 coex_dm->cur_arfr_type = type;
197
198 if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) {
199 switch (coex_dm->cur_arfr_type) {
200 case 0: /* normal mode */
201 btcoexist->btc_write_4byte(btcoexist, 0x430,
202 coex_dm->backup_arfr_cnt1);
203 btcoexist->btc_write_4byte(btcoexist, 0x434,
204 coex_dm->backup_arfr_cnt2);
205 break;
206 case 1:
207 btcoexist->btc_get(btcoexist,
208 BTC_GET_BL_WIFI_UNDER_B_MODE,
209 &wifi_under_b_mode);
210 if (wifi_under_b_mode) {
211 btcoexist->btc_write_4byte(btcoexist,
212 0x430, 0x0);
213 btcoexist->btc_write_4byte(btcoexist,
214 0x434, 0x01010101);
215 } else {
216 btcoexist->btc_write_4byte(btcoexist,
217 0x430, 0x0);
218 btcoexist->btc_write_4byte(btcoexist,
219 0x434, 0x04030201);
220 }
221 break;
222 default:
223 break;
224 }
225 }
226
227 coex_dm->pre_arfr_type = coex_dm->cur_arfr_type;
228 }
229
halbtc8822b1ant_retry_limit(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 type)230 void halbtc8822b1ant_retry_limit(IN struct btc_coexist *btcoexist,
231 IN boolean force_exec, IN u8 type)
232 {
233 coex_dm->cur_retry_limit_type = type;
234
235 if (force_exec ||
236 (coex_dm->pre_retry_limit_type !=
237 coex_dm->cur_retry_limit_type)) {
238 switch (coex_dm->cur_retry_limit_type) {
239 case 0: /* normal mode */
240 btcoexist->btc_write_2byte(btcoexist, 0x42a,
241 coex_dm->backup_retry_limit);
242 break;
243 case 1: /* retry limit=8 */
244 btcoexist->btc_write_2byte(btcoexist, 0x42a,
245 0x0808);
246 break;
247 default:
248 break;
249 }
250 }
251
252 coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type;
253 }
254
halbtc8822b1ant_ampdu_max_time(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 type)255 void halbtc8822b1ant_ampdu_max_time(IN struct btc_coexist *btcoexist,
256 IN boolean force_exec, IN u8 type)
257 {
258 coex_dm->cur_ampdu_time_type = type;
259
260 if (force_exec ||
261 (coex_dm->pre_ampdu_time_type != coex_dm->cur_ampdu_time_type)) {
262 switch (coex_dm->cur_ampdu_time_type) {
263 case 0: /* normal mode */
264 btcoexist->btc_write_1byte(btcoexist, 0x456,
265 coex_dm->backup_ampdu_max_time);
266 break;
267 case 1: /* AMPDU timw = 0x38 * 32us */
268 btcoexist->btc_write_1byte(btcoexist, 0x456,
269 0x38);
270 break;
271 default:
272 break;
273 }
274 }
275
276 coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type;
277 }
278
halbtc8822b1ant_limited_tx(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 ra_mask_type,IN u8 arfr_type,IN u8 retry_limit_type,IN u8 ampdu_time_type)279 void halbtc8822b1ant_limited_tx(IN struct btc_coexist *btcoexist,
280 IN boolean force_exec, IN u8 ra_mask_type, IN u8 arfr_type,
281 IN u8 retry_limit_type, IN u8 ampdu_time_type)
282 {
283 switch (ra_mask_type) {
284 case 0: /* normal mode */
285 halbtc8822b1ant_update_ra_mask(btcoexist, force_exec,
286 0x0);
287 break;
288 case 1: /* disable cck 1/2 */
289 halbtc8822b1ant_update_ra_mask(btcoexist, force_exec,
290 0x00000003);
291 break;
292 case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
293 halbtc8822b1ant_update_ra_mask(btcoexist, force_exec,
294 0x0001f1f7);
295 break;
296 default:
297 break;
298 }
299
300 halbtc8822b1ant_auto_rate_fallback_retry(btcoexist, force_exec,
301 arfr_type);
302 halbtc8822b1ant_retry_limit(btcoexist, force_exec, retry_limit_type);
303 halbtc8822b1ant_ampdu_max_time(btcoexist, force_exec, ampdu_time_type);
304 }
305
306 /*
307 rx agg size setting :
308 1: true / don't care / don't care
309 max: false / false / don't care
310 7: false / true / 7
311 */
312
halbtc8822b1ant_limited_rx(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN boolean rej_ap_agg_pkt,IN boolean bt_ctrl_agg_buf_size,IN u8 agg_buf_size)313 void halbtc8822b1ant_limited_rx(IN struct btc_coexist *btcoexist,
314 IN boolean force_exec, IN boolean rej_ap_agg_pkt,
315 IN boolean bt_ctrl_agg_buf_size, IN u8 agg_buf_size)
316 {
317 boolean reject_rx_agg = rej_ap_agg_pkt;
318 boolean bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size;
319 u8 rx_agg_size = agg_buf_size;
320
321 /* ============================================ */
322 /* Rx Aggregation related setting */
323 /* ============================================ */
324 btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
325 &reject_rx_agg);
326 /* decide BT control aggregation buf size or not */
327 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
328 &bt_ctrl_rx_agg_size);
329 /* aggregation buf size, only work when BT control Rx aggregation size. */
330 btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
331 /* real update aggregation setting */
332 btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
333
334
335 }
336
halbtc8822b1ant_query_bt_info(IN struct btc_coexist * btcoexist)337 void halbtc8822b1ant_query_bt_info(IN struct btc_coexist *btcoexist)
338 {
339 u8 h2c_parameter[1] = {0};
340
341 coex_sta->c2h_bt_info_req_sent = true;
342
343 h2c_parameter[0] |= BIT(0); /* trigger */
344
345 btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
346 }
347
halbtc8822b1ant_monitor_bt_ctr(IN struct btc_coexist * btcoexist)348 void halbtc8822b1ant_monitor_bt_ctr(IN struct btc_coexist *btcoexist)
349 {
350 u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
351 u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
352 static u8 num_of_bt_counter_chk = 0, cnt_slave = 0;
353 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
354
355 /* to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS */
356 /* if (! (btcoexist->btc_read_1byte(btcoexist, 0x76e) & 0x8) ) */
357
358 if (coex_sta->under_ips) {
359 /* coex_sta->high_priority_tx = 65535; */
360 /* coex_sta->high_priority_rx = 65535; */
361 /* coex_sta->low_priority_tx = 65535; */
362 /* coex_sta->low_priority_rx = 65535; */
363 /* return; */
364 }
365
366 reg_hp_txrx = 0x770;
367 reg_lp_txrx = 0x774;
368
369 u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
370 reg_hp_tx = u32tmp & MASKLWORD;
371 reg_hp_rx = (u32tmp & MASKHWORD) >> 16;
372
373 u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
374 reg_lp_tx = u32tmp & MASKLWORD;
375 reg_lp_rx = (u32tmp & MASKHWORD) >> 16;
376
377 coex_sta->high_priority_tx = reg_hp_tx;
378 coex_sta->high_priority_rx = reg_hp_rx;
379 coex_sta->low_priority_tx = reg_lp_tx;
380 coex_sta->low_priority_rx = reg_lp_rx;
381
382 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
383 "[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n",
384 reg_hp_rx, reg_hp_tx, reg_lp_rx, reg_lp_tx);
385 BTC_TRACE(trace_buf);
386
387 /* reset counter */
388 btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
389
390 if ((coex_sta->low_priority_tx > 1150) &&
391 (!coex_sta->c2h_bt_inquiry_page))
392 coex_sta->pop_event_cnt++;
393
394 if ((coex_sta->low_priority_rx >= 1150) &&
395 (coex_sta->low_priority_rx >= coex_sta->low_priority_tx)
396 && (!coex_sta->under_ips) &&
397 (!coex_sta->c2h_bt_inquiry_page) &&
398 (coex_sta->bt_link_exist)) {
399 if (cnt_slave >= 3) {
400 bt_link_info->slave_role = true;
401 cnt_slave = 3;
402 } else
403 cnt_slave++;
404 } else {
405 if (cnt_slave == 0) {
406 bt_link_info->slave_role = false;
407 cnt_slave = 0;
408 } else
409 cnt_slave--;
410
411 }
412
413 if ((coex_sta->high_priority_tx == 0) &&
414 (coex_sta->high_priority_rx == 0) &&
415 (coex_sta->low_priority_tx == 0) &&
416 (coex_sta->low_priority_rx == 0)) {
417 num_of_bt_counter_chk++;
418
419 if (num_of_bt_counter_chk >= 3) {
420 halbtc8822b1ant_query_bt_info(
421 btcoexist);
422 num_of_bt_counter_chk = 0;
423 }
424 }
425 #if 0
426 /* Add Hi-Pri Tx/Rx counter to avoid false detection */
427 if (((coex_sta->hid_exist) || (coex_sta->sco_exist)) &&
428 (coex_sta->high_priority_tx + coex_sta->high_priority_rx
429 >= 160)
430 && (!coex_sta->c2h_bt_inquiry_page))
431 coex_sta->bt_hi_pri_link_exist = true;
432 else
433 coex_sta->bt_hi_pri_link_exist = false;
434
435 if ((coex_sta->acl_busy) &&
436 (coex_sta->num_of_profile == 0)) {
437 if (coex_sta->low_priority_tx +
438 coex_sta->low_priority_rx >= 160) {
439 coex_sta->pan_exist = true;
440 coex_sta->num_of_profile++;
441 coex_sta->wrong_profile_notification++;
442 }
443 }
444 #endif
445
446 }
447
448
halbtc8822b1ant_monitor_wifi_ctr(IN struct btc_coexist * btcoexist)449 void halbtc8822b1ant_monitor_wifi_ctr(IN struct btc_coexist *btcoexist)
450 {
451 s32 wifi_rssi = 0;
452 boolean wifi_busy = false, wifi_under_b_mode = false;
453 static u8 cck_lock_counter = 0;
454 u32 total_cnt;
455
456 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
457 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
458 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE,
459 &wifi_under_b_mode);
460
461 if (coex_sta->under_ips) {
462 coex_sta->crc_ok_cck = 0;
463 coex_sta->crc_ok_11g = 0;
464 coex_sta->crc_ok_11n = 0;
465 coex_sta->crc_ok_11n_agg = 0;
466
467 coex_sta->crc_err_cck = 0;
468 coex_sta->crc_err_11g = 0;
469 coex_sta->crc_err_11n = 0;
470 coex_sta->crc_err_11n_agg = 0;
471 } else {
472 coex_sta->crc_ok_cck = btcoexist->btc_read_2byte(
473 btcoexist,
474 0xf04);
475 coex_sta->crc_ok_11g = btcoexist->btc_read_2byte(
476 btcoexist,
477 0xf14);
478 coex_sta->crc_ok_11n = btcoexist->btc_read_2byte(
479 btcoexist,
480 0xf10);
481 coex_sta->crc_ok_11n_agg = btcoexist->btc_read_2byte(
482 btcoexist,
483 0xf0c);
484
485 coex_sta->crc_err_cck = btcoexist->btc_read_2byte(
486 btcoexist, 0xf00) + btcoexist->btc_read_2byte(
487 btcoexist, 0xf06);
488
489 coex_sta->crc_err_11g = btcoexist->btc_read_2byte(
490 btcoexist,
491 0xf16);
492 coex_sta->crc_err_11n = btcoexist->btc_read_2byte(
493 btcoexist,
494 0xf12);
495 coex_sta->crc_err_11n_agg = btcoexist->btc_read_2byte(
496 btcoexist,
497 0xf0e);
498 }
499
500
501 /* reset counter */
502 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xb58, 0x1, 0x1);
503 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xb58, 0x1, 0x0);
504
505 if ((wifi_busy) && (wifi_rssi >= 30) && (!wifi_under_b_mode)) {
506 total_cnt = coex_sta->crc_ok_cck + coex_sta->crc_ok_11g
507 +
508 coex_sta->crc_ok_11n +
509 coex_sta->crc_ok_11n_agg;
510
511 if ((coex_dm->bt_status ==
512 BT_8822B_1ANT_BT_STATUS_ACL_BUSY) ||
513 (coex_dm->bt_status ==
514 BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY) ||
515 (coex_dm->bt_status ==
516 BT_8822B_1ANT_BT_STATUS_SCO_BUSY)) {
517 if (coex_sta->crc_ok_cck > (total_cnt -
518 coex_sta->crc_ok_cck)) {
519 if (cck_lock_counter < 3)
520 cck_lock_counter++;
521 } else {
522 if (cck_lock_counter > 0)
523 cck_lock_counter--;
524 }
525
526 } else {
527 if (cck_lock_counter > 0)
528 cck_lock_counter--;
529 }
530 } else {
531 if (cck_lock_counter > 0)
532 cck_lock_counter--;
533 }
534
535 if (!coex_sta->pre_ccklock) {
536
537 if (cck_lock_counter >= 3)
538 coex_sta->cck_lock = true;
539 else
540 coex_sta->cck_lock = false;
541 } else {
542 if (cck_lock_counter == 0)
543 coex_sta->cck_lock = false;
544 else
545 coex_sta->cck_lock = true;
546 }
547
548 if (coex_sta->cck_lock)
549 coex_sta->cck_ever_lock = true;
550
551 coex_sta->pre_ccklock = coex_sta->cck_lock;
552
553
554 }
555
556
halbtc8822b1ant_is_wifi_status_changed(IN struct btc_coexist * btcoexist)557 boolean halbtc8822b1ant_is_wifi_status_changed(IN struct btc_coexist *btcoexist)
558 {
559 static boolean pre_wifi_busy = false, pre_under_4way = false,
560 pre_bt_hs_on = false, pre_rf4ce_enabled = false, pre_bt_off = false;
561 boolean wifi_busy = false, under_4way = false, bt_hs_on = false, rf4ce_enabled = false;
562 boolean wifi_connected = false;
563
564 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
565 &wifi_connected);
566 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
567 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
568 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
569 &under_4way);
570
571 if (coex_sta->bt_disabled != pre_bt_off) {
572 pre_bt_off = coex_sta->bt_disabled;
573
574 if (coex_sta->bt_disabled)
575 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
576 "[BTCoex], BT is disabled !!\n");
577 else
578 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
579 "[BTCoex], BT is enabled !!\n");
580
581 BTC_TRACE(trace_buf);
582
583 coex_sta->bt_coex_supported_feature = 0;
584 coex_sta->bt_coex_supported_version = 0;
585 return true;
586 }
587 btcoexist->btc_get(btcoexist, BTC_GET_BL_RF4CE_CONNECTED, &rf4ce_enabled);
588
589 if (rf4ce_enabled != pre_rf4ce_enabled) {
590 pre_rf4ce_enabled = rf4ce_enabled;
591
592 if (rf4ce_enabled)
593 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
594 "[BTCoex], rf4ce is enabled !!\n");
595 else
596 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
597 "[BTCoex], rf4ce is disabled !!\n");
598
599 BTC_TRACE(trace_buf);
600
601
602 return true;
603 }
604
605 if (wifi_connected) {
606 if (wifi_busy != pre_wifi_busy) {
607 pre_wifi_busy = wifi_busy;
608 return true;
609 }
610 if (under_4way != pre_under_4way) {
611 pre_under_4way = under_4way;
612 return true;
613 }
614 if (bt_hs_on != pre_bt_hs_on) {
615 pre_bt_hs_on = bt_hs_on;
616 return true;
617 }
618 }
619
620 return false;
621 }
622
halbtc8822b1ant_update_bt_link_info(IN struct btc_coexist * btcoexist)623 void halbtc8822b1ant_update_bt_link_info(IN struct btc_coexist *btcoexist)
624 {
625 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
626 boolean bt_hs_on = false;
627
628 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
629
630 bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
631 bt_link_info->sco_exist = coex_sta->sco_exist;
632 bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
633 bt_link_info->pan_exist = coex_sta->pan_exist;
634 bt_link_info->hid_exist = coex_sta->hid_exist;
635 bt_link_info->bt_hi_pri_link_exist = coex_sta->bt_hi_pri_link_exist;
636 bt_link_info->acl_busy = coex_sta->acl_busy;
637
638 /* work around for HS mode. */
639 if (bt_hs_on) {
640 bt_link_info->pan_exist = true;
641 bt_link_info->bt_link_exist = true;
642 }
643
644 /* check if Sco only */
645 if (bt_link_info->sco_exist &&
646 !bt_link_info->a2dp_exist &&
647 !bt_link_info->pan_exist &&
648 !bt_link_info->hid_exist)
649 bt_link_info->sco_only = true;
650 else
651 bt_link_info->sco_only = false;
652
653 /* check if A2dp only */
654 if (!bt_link_info->sco_exist &&
655 bt_link_info->a2dp_exist &&
656 !bt_link_info->pan_exist &&
657 !bt_link_info->hid_exist)
658 bt_link_info->a2dp_only = true;
659 else
660 bt_link_info->a2dp_only = false;
661
662 /* check if Pan only */
663 if (!bt_link_info->sco_exist &&
664 !bt_link_info->a2dp_exist &&
665 bt_link_info->pan_exist &&
666 !bt_link_info->hid_exist)
667 bt_link_info->pan_only = true;
668 else
669 bt_link_info->pan_only = false;
670
671 /* check if Hid only */
672 if (!bt_link_info->sco_exist &&
673 !bt_link_info->a2dp_exist &&
674 !bt_link_info->pan_exist &&
675 bt_link_info->hid_exist)
676 bt_link_info->hid_only = true;
677 else
678 bt_link_info->hid_only = false;
679 }
680
halbtc8822b1ant_update_wifi_channel_info(IN struct btc_coexist * btcoexist,IN u8 type)681 void halbtc8822b1ant_update_wifi_channel_info(IN struct btc_coexist *btcoexist,
682 IN u8 type)
683 {
684 u8 h2c_parameter[3] = {0};
685 u32 wifi_bw;
686 u8 wifi_central_chnl;
687
688 /* only 2.4G we need to inform bt the chnl mask */
689 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
690 &wifi_central_chnl);
691 if ((BTC_MEDIA_CONNECT == type) &&
692 (wifi_central_chnl <= 14)) {
693
694 h2c_parameter[0] =
695 0x1; /* enable BT AFH skip WL channel for 8822b because BT Rx LO interference */
696 h2c_parameter[1] = wifi_central_chnl;
697
698 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
699
700 if (BTC_WIFI_BW_HT40 == wifi_bw)
701 h2c_parameter[2] = 0x30;
702 else
703 h2c_parameter[2] = 0x20;
704 }
705
706 coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
707 coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
708 coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
709
710 btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
711
712 }
713
halbtc8822b1ant_action_algorithm(IN struct btc_coexist * btcoexist)714 u8 halbtc8822b1ant_action_algorithm(IN struct btc_coexist *btcoexist)
715 {
716 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
717 boolean bt_hs_on = false;
718 u8 algorithm = BT_8822B_1ANT_COEX_ALGO_UNDEFINED;
719 u8 num_of_diff_profile = 0;
720
721 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
722
723 if (!bt_link_info->bt_link_exist) {
724 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
725 "[BTCoex], No BT link exists!!!\n");
726 BTC_TRACE(trace_buf);
727 return algorithm;
728 }
729
730 if (bt_link_info->sco_exist)
731 num_of_diff_profile++;
732 if (bt_link_info->hid_exist)
733 num_of_diff_profile++;
734 if (bt_link_info->pan_exist)
735 num_of_diff_profile++;
736 if (bt_link_info->a2dp_exist)
737 num_of_diff_profile++;
738
739 if (num_of_diff_profile == 1) {
740 if (bt_link_info->sco_exist) {
741 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
742 "[BTCoex], BT Profile = SCO only\n");
743 BTC_TRACE(trace_buf);
744 algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
745 } else {
746 if (bt_link_info->hid_exist) {
747 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
748 "[BTCoex], BT Profile = HID only\n");
749 BTC_TRACE(trace_buf);
750 algorithm = BT_8822B_1ANT_COEX_ALGO_HID;
751 } else if (bt_link_info->a2dp_exist) {
752 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
753 "[BTCoex], BT Profile = A2DP only\n");
754 BTC_TRACE(trace_buf);
755 algorithm = BT_8822B_1ANT_COEX_ALGO_A2DP;
756 } else if (bt_link_info->pan_exist) {
757 if (bt_hs_on) {
758 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
759 "[BTCoex], BT Profile = PAN(HS) only\n");
760 BTC_TRACE(trace_buf);
761 algorithm =
762 BT_8822B_1ANT_COEX_ALGO_PANHS;
763 } else {
764 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
765 "[BTCoex], BT Profile = PAN(EDR) only\n");
766 BTC_TRACE(trace_buf);
767 algorithm =
768 BT_8822B_1ANT_COEX_ALGO_PANEDR;
769 }
770 }
771 }
772 } else if (num_of_diff_profile == 2) {
773 if (bt_link_info->sco_exist) {
774 if (bt_link_info->hid_exist) {
775 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
776 "[BTCoex], BT Profile = SCO + HID\n");
777 BTC_TRACE(trace_buf);
778 algorithm = BT_8822B_1ANT_COEX_ALGO_HID;
779 } else if (bt_link_info->a2dp_exist) {
780 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
781 "[BTCoex], BT Profile = SCO + A2DP ==> SCO\n");
782 BTC_TRACE(trace_buf);
783 algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
784 } else if (bt_link_info->pan_exist) {
785 if (bt_hs_on) {
786 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
787 "[BTCoex], BT Profile = SCO + PAN(HS)\n");
788 BTC_TRACE(trace_buf);
789 algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
790 } else {
791 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
792 "[BTCoex], BT Profile = SCO + PAN(EDR)\n");
793 BTC_TRACE(trace_buf);
794 algorithm =
795 BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
796 }
797 }
798 } else {
799 if (bt_link_info->hid_exist &&
800 bt_link_info->a2dp_exist) {
801 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
802 "[BTCoex], BT Profile = HID + A2DP\n");
803 BTC_TRACE(trace_buf);
804 algorithm = BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
805 } else if (bt_link_info->hid_exist &&
806 bt_link_info->pan_exist) {
807 if (bt_hs_on) {
808 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
809 "[BTCoex], BT Profile = HID + PAN(HS)\n");
810 BTC_TRACE(trace_buf);
811 algorithm =
812 BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
813 } else {
814 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
815 "[BTCoex], BT Profile = HID + PAN(EDR)\n");
816 BTC_TRACE(trace_buf);
817 algorithm =
818 BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
819 }
820 } else if (bt_link_info->pan_exist &&
821 bt_link_info->a2dp_exist) {
822 if (bt_hs_on) {
823 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
824 "[BTCoex], BT Profile = A2DP + PAN(HS)\n");
825 BTC_TRACE(trace_buf);
826 algorithm =
827 BT_8822B_1ANT_COEX_ALGO_A2DP_PANHS;
828 } else {
829 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
830 "[BTCoex], BT Profile = A2DP + PAN(EDR)\n");
831 BTC_TRACE(trace_buf);
832 algorithm =
833 BT_8822B_1ANT_COEX_ALGO_PANEDR_A2DP;
834 }
835 }
836 }
837 } else if (num_of_diff_profile == 3) {
838 if (bt_link_info->sco_exist) {
839 if (bt_link_info->hid_exist &&
840 bt_link_info->a2dp_exist) {
841 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
842 "[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n");
843 BTC_TRACE(trace_buf);
844 algorithm = BT_8822B_1ANT_COEX_ALGO_HID;
845 } else if (bt_link_info->hid_exist &&
846 bt_link_info->pan_exist) {
847 if (bt_hs_on) {
848 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
849 "[BTCoex], BT Profile = SCO + HID + PAN(HS)\n");
850 BTC_TRACE(trace_buf);
851 algorithm =
852 BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
853 } else {
854 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
855 "[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n");
856 BTC_TRACE(trace_buf);
857 algorithm =
858 BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
859 }
860 } else if (bt_link_info->pan_exist &&
861 bt_link_info->a2dp_exist) {
862 if (bt_hs_on) {
863 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
864 "[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n");
865 BTC_TRACE(trace_buf);
866 algorithm = BT_8822B_1ANT_COEX_ALGO_SCO;
867 } else {
868 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
869 "[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n");
870 BTC_TRACE(trace_buf);
871 algorithm =
872 BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
873 }
874 }
875 } else {
876 if (bt_link_info->hid_exist &&
877 bt_link_info->pan_exist &&
878 bt_link_info->a2dp_exist) {
879 if (bt_hs_on) {
880 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
881 "[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n");
882 BTC_TRACE(trace_buf);
883 algorithm =
884 BT_8822B_1ANT_COEX_ALGO_HID_A2DP;
885 } else {
886 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
887 "[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n");
888 BTC_TRACE(trace_buf);
889 algorithm =
890 BT_8822B_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
891 }
892 }
893 }
894 } else if (num_of_diff_profile >= 3) {
895 if (bt_link_info->sco_exist) {
896 if (bt_link_info->hid_exist &&
897 bt_link_info->pan_exist &&
898 bt_link_info->a2dp_exist) {
899 if (bt_hs_on) {
900 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
901 "[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n");
902 BTC_TRACE(trace_buf);
903
904 } else {
905 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
906 "[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
907 BTC_TRACE(trace_buf);
908 algorithm =
909 BT_8822B_1ANT_COEX_ALGO_PANEDR_HID;
910 }
911 }
912 }
913 }
914
915 return algorithm;
916 }
917
halbtc8822b1ant_set_bt_auto_report(IN struct btc_coexist * btcoexist,IN boolean enable_auto_report)918 void halbtc8822b1ant_set_bt_auto_report(IN struct btc_coexist *btcoexist,
919 IN boolean enable_auto_report)
920 {
921 u8 h2c_parameter[1] = {0};
922
923 h2c_parameter[0] = 0;
924
925 if (enable_auto_report)
926 h2c_parameter[0] |= BIT(0);
927
928 btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
929 }
930
halbtc8822b1ant_bt_auto_report(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN boolean enable_auto_report)931 void halbtc8822b1ant_bt_auto_report(IN struct btc_coexist *btcoexist,
932 IN boolean force_exec, IN boolean enable_auto_report)
933 {
934 coex_dm->cur_bt_auto_report = enable_auto_report;
935
936 if (!force_exec) {
937 if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report)
938 return;
939 }
940 halbtc8822b1ant_set_bt_auto_report(btcoexist,
941 coex_dm->cur_bt_auto_report);
942
943 coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
944 }
945
946
947
halbtc8822b1ant_set_sw_penalty_tx_rate_adaptive(IN struct btc_coexist * btcoexist,IN boolean low_penalty_ra)948 void halbtc8822b1ant_set_sw_penalty_tx_rate_adaptive(IN struct btc_coexist
949 *btcoexist, IN boolean low_penalty_ra)
950 {
951 u8 h2c_parameter[6] = {0};
952
953 h2c_parameter[0] = 0x6; /* op_code, 0x6= Retry_Penalty */
954
955 if (low_penalty_ra) {
956 h2c_parameter[1] |= BIT(0);
957 h2c_parameter[2] =
958 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */
959 h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */
960 h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */
961 h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */
962 }
963
964 btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
965 }
966
halbtc8822b1ant_low_penalty_ra(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN boolean low_penalty_ra)967 void halbtc8822b1ant_low_penalty_ra(IN struct btc_coexist *btcoexist,
968 IN boolean force_exec, IN boolean low_penalty_ra)
969 {
970 #if 1
971 coex_dm->cur_low_penalty_ra = low_penalty_ra;
972
973 if (!force_exec) {
974 if (coex_dm->pre_low_penalty_ra ==
975 coex_dm->cur_low_penalty_ra)
976 return;
977 }
978
979 if (low_penalty_ra)
980 btcoexist->btc_phydm_modify_RA_PCR_threshold(btcoexist, 0, 25);
981 else
982 btcoexist->btc_phydm_modify_RA_PCR_threshold(btcoexist, 0, 0);
983
984 coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
985
986 #endif
987 }
988
halbtc8822b1ant_write_score_board(IN struct btc_coexist * btcoexist,IN u16 bitpos,IN boolean state)989 void halbtc8822b1ant_write_score_board(
990 IN struct btc_coexist *btcoexist,
991 IN u16 bitpos,
992 IN boolean state
993 )
994 {
995
996 static u16 originalval = 0x8002;
997
998 if (state)
999 originalval = originalval | bitpos;
1000 else
1001 originalval = originalval & (~bitpos);
1002
1003 btcoexist->btc_write_2byte(btcoexist, 0xaa, originalval);
1004 }
1005
halbtc8822b1ant_read_score_board(IN struct btc_coexist * btcoexist,IN u16 * score_board_val)1006 void halbtc8822b1ant_read_score_board(
1007 IN struct btc_coexist *btcoexist,
1008 IN u16 *score_board_val
1009 )
1010 {
1011
1012 *score_board_val = (btcoexist->btc_read_2byte(btcoexist,
1013 0xaa)) & 0x7fff;
1014 }
1015
halbtc8822b1ant_post_state_to_bt(IN struct btc_coexist * btcoexist,IN u16 type,IN boolean state)1016 void halbtc8822b1ant_post_state_to_bt(
1017 IN struct btc_coexist *btcoexist,
1018 IN u16 type,
1019 IN boolean state
1020 )
1021 {
1022
1023 halbtc8822b1ant_write_score_board(btcoexist, (u16) type, state);
1024
1025 }
1026
1027
halbtc8822b1ant_monitor_bt_enable_disable(IN struct btc_coexist * btcoexist)1028 void halbtc8822b1ant_monitor_bt_enable_disable(IN struct btc_coexist *btcoexist)
1029 {
1030 static u32 bt_disable_cnt = 0;
1031 boolean bt_active = true, bt_disabled = false,
1032 wifi_under_5g = false;
1033 u16 u16tmp;
1034
1035 /* This function check if bt is disabled */
1036 #if 0
1037 if (coex_sta->high_priority_tx == 0 &&
1038 coex_sta->high_priority_rx == 0 &&
1039 coex_sta->low_priority_tx == 0 &&
1040 coex_sta->low_priority_rx == 0)
1041 bt_active = false;
1042 if (coex_sta->high_priority_tx == 0xffff &&
1043 coex_sta->high_priority_rx == 0xffff &&
1044 coex_sta->low_priority_tx == 0xffff &&
1045 coex_sta->low_priority_rx == 0xffff)
1046 bt_active = false;
1047
1048
1049 #else
1050
1051 /* Read BT on/off status from scoreboard[1], enable this only if BT patch support this feature */
1052 halbtc8822b1ant_read_score_board(btcoexist, &u16tmp);
1053
1054 bt_active = u16tmp & BIT(1);
1055
1056
1057 #endif
1058
1059 if (bt_active) {
1060 bt_disable_cnt = 0;
1061 bt_disabled = false;
1062 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
1063 &bt_disabled);
1064 } else {
1065
1066 bt_disable_cnt++;
1067 if (bt_disable_cnt >= 2) {
1068 bt_disabled = true;
1069 bt_disable_cnt = 2;
1070 }
1071
1072 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
1073 &bt_disabled);
1074 }
1075
1076
1077 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G,
1078 &wifi_under_5g);
1079
1080 if ((wifi_under_5g) || (bt_disabled))
1081 halbtc8822b1ant_low_penalty_ra(btcoexist,
1082 NORMAL_EXEC, false);
1083 else
1084 halbtc8822b1ant_low_penalty_ra(btcoexist,
1085 NORMAL_EXEC, true);
1086
1087
1088 if (coex_sta->bt_disabled != bt_disabled) {
1089 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1090 "[BTCoex], BT is from %s to %s!!\n",
1091 (coex_sta->bt_disabled ? "disabled" :
1092 "enabled"),
1093 (bt_disabled ? "disabled" : "enabled"));
1094 BTC_TRACE(trace_buf);
1095 coex_sta->bt_disabled = bt_disabled;
1096 }
1097
1098 }
1099
1100
1101
halbtc8822b1ant_enable_gnt_to_gpio(IN struct btc_coexist * btcoexist,boolean isenable)1102 void halbtc8822b1ant_enable_gnt_to_gpio(IN struct btc_coexist *btcoexist,
1103 boolean isenable)
1104 {
1105 static u8 bitVal[5] = {0, 0, 0, 0, 0};
1106 static boolean state = false;
1107
1108 if (state == isenable)
1109 return;
1110
1111 state = isenable;
1112
1113 if (isenable) {
1114
1115 /* enable GNT_WL, GNT_BT to GPIO for debug */
1116 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x8, 0x1);
1117
1118 /* store original value */
1119 bitVal[0] = (btcoexist->btc_read_1byte(btcoexist,
1120 0x66) & BIT(4)) >> 4; /*0x66[4] */
1121 bitVal[1] = (btcoexist->btc_read_1byte(btcoexist,
1122 0x67) & BIT(0)); /*0x66[8] */
1123 bitVal[2] = (btcoexist->btc_read_1byte(btcoexist,
1124 0x42) & BIT(3)) >> 3; /*0x40[19] */
1125 bitVal[3] = (btcoexist->btc_read_1byte(btcoexist,
1126 0x65) & BIT(7)) >> 7; /*0x64[15] */
1127 bitVal[4] = (btcoexist->btc_read_1byte(btcoexist,
1128 0x72) & BIT(2)) >> 2; /*0x70[18] */
1129
1130 /* switch GPIO Mux */
1131 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x66, BIT(4),
1132 0x0); /*0x66[4] = 0 */
1133 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, BIT(0),
1134 0x0); /*0x66[8] = 0 */
1135 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x42, BIT(3),
1136 0x0); /*0x40[19] = 0 */
1137 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x65, BIT(7),
1138 0x0); /*0x64[15] = 0 */
1139 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x72, BIT(2),
1140 0x0); /*0x70[18] = 0 */
1141
1142
1143 } else {
1144 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x8, 0x0);
1145
1146 /* Restore original value */
1147 /* switch GPIO Mux */
1148 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x66, BIT(4),
1149 bitVal[0]); /*0x66[4] = 0 */
1150 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, BIT(0),
1151 bitVal[1]); /*0x66[8] = 0 */
1152 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x42, BIT(3),
1153 bitVal[2]); /*0x40[19] = 0 */
1154 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x65, BIT(7),
1155 bitVal[3]); /*0x64[15] = 0 */
1156 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x72, BIT(2),
1157 bitVal[4]); /*0x70[18] = 0 */
1158 }
1159
1160 }
1161
1162
halbtc8822b1ant_ltecoex_indirect_read_reg(IN struct btc_coexist * btcoexist,IN u16 reg_addr)1163 u32 halbtc8822b1ant_ltecoex_indirect_read_reg(IN struct btc_coexist *btcoexist,
1164 IN u16 reg_addr)
1165 {
1166 u32 j = 0, delay_count = 0;
1167
1168
1169 /* wait for ready bit before access 0x1700 */
1170 btcoexist->btc_write_4byte(btcoexist, 0x1700, 0x800F0000 | reg_addr);
1171 #if 0
1172 do {
1173 j++;
1174 } while (((btcoexist->btc_read_1byte(btcoexist,
1175 0x1703) & BIT(5)) == 0) &&
1176 (j < BT_8822B_1ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT));
1177 #endif
1178 while (1) {
1179 if ((btcoexist->btc_read_1byte(btcoexist, 0x1703)&BIT(5)) == 0) {
1180 delay_ms(50);
1181 delay_count++;
1182 if (delay_count >= 10) {
1183 delay_count = 0;
1184 break;
1185 }
1186 } else
1187 break;
1188 }
1189 return btcoexist->btc_read_4byte(btcoexist,
1190 0x1708); /* get read data */
1191
1192 }
1193
halbtc8822b1ant_ltecoex_indirect_write_reg(IN struct btc_coexist * btcoexist,IN u16 reg_addr,IN u32 bit_mask,IN u32 reg_value)1194 void halbtc8822b1ant_ltecoex_indirect_write_reg(IN struct btc_coexist
1195 *btcoexist,
1196 IN u16 reg_addr, IN u32 bit_mask, IN u32 reg_value)
1197 {
1198 u32 val, i = 0, j = 0, bitpos = 0, delay_count = 0;
1199
1200
1201 if (bit_mask == 0x0)
1202 return;
1203 if (bit_mask == 0xffffffff) {
1204 btcoexist->btc_write_4byte(btcoexist, 0x1704,
1205 reg_value); /* put write data */
1206
1207 /* wait for ready bit before access 0x1700 */
1208 #if 0
1209 do {
1210 j++;
1211 } while (((btcoexist->btc_read_1byte(btcoexist,
1212 0x1703) & BIT(5)) == 0) &&
1213 (j < BT_8822B_1ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT));
1214 #endif
1215
1216 while (1) {
1217 if ((btcoexist->btc_read_1byte(btcoexist, 0x1703)&BIT(5)) == 0) {
1218 delay_ms(50);
1219 delay_count++;
1220 if (delay_count >= 10) {
1221 delay_count = 0;
1222 break;
1223 }
1224 } else
1225 break;
1226 }
1227 btcoexist->btc_write_4byte(btcoexist, 0x1700,
1228 0xc00F0000 | reg_addr);
1229 } else {
1230 for (i = 0; i <= 31; i++) {
1231 if (((bit_mask >> i) & 0x1) == 0x1) {
1232 bitpos = i;
1233 break;
1234 }
1235 }
1236
1237 /* read back register value before write */
1238 val = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
1239 reg_addr);
1240 val = (val & (~bit_mask)) | (reg_value << bitpos);
1241
1242 /* put write data value */
1243 btcoexist->btc_write_4byte(btcoexist, 0x1704,
1244 val); /* put write data */
1245
1246 /* wait for ready bit before access 0x1700 */
1247 #if 0
1248 do {
1249 j++;
1250 } while (((btcoexist->btc_read_1byte(btcoexist,
1251 0x1703) & BIT(5)) == 0) &&
1252 (j < BT_8822B_1ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT));
1253 #endif
1254
1255 while (1) {
1256 if ((btcoexist->btc_read_1byte(btcoexist, 0x1703)&BIT(5)) == 0) {
1257 delay_ms(50);
1258 delay_count++;
1259 if (delay_count >= 10) {
1260 delay_count = 0;
1261 break;
1262 }
1263 } else
1264 break;
1265 }
1266
1267
1268
1269 btcoexist->btc_write_4byte(btcoexist, 0x1700,
1270 0xc00F0000 | reg_addr);
1271
1272 }
1273
1274 }
1275
halbtc8822b1ant_ltecoex_enable(IN struct btc_coexist * btcoexist,IN boolean enable)1276 void halbtc8822b1ant_ltecoex_enable(IN struct btc_coexist *btcoexist,
1277 IN boolean enable)
1278 {
1279 u8 val;
1280
1281 val = (enable) ? 1 : 0;
1282 /* 0x38[7] */
1283 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist, 0x38, 0x80,
1284 val); /* 0x38[7] */
1285
1286 }
1287
1288
halbtc8822b1ant_ltecoex_pathcontrol_owner(IN struct btc_coexist * btcoexist,IN boolean wifi_control)1289 void halbtc8822b1ant_ltecoex_pathcontrol_owner(IN struct btc_coexist *btcoexist,
1290 IN boolean wifi_control)
1291 {
1292 u8 val;
1293
1294 val = (wifi_control) ? 1 : 0;
1295 /* 0x70[26] */
1296 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x4,
1297 val); /* 0x70[26] */
1298
1299 }
1300
halbtc8822b1ant_ltecoex_set_gnt_bt(IN struct btc_coexist * btcoexist,IN u8 control_block,IN boolean sw_control,IN u8 state)1301 void halbtc8822b1ant_ltecoex_set_gnt_bt(IN struct btc_coexist *btcoexist,
1302 IN u8 control_block, IN boolean sw_control, IN u8 state)
1303 {
1304 u32 val = 0, bit_mask;
1305
1306 state = state & 0x1;
1307 /*LTE indirect 0x38=0xccxx (sw : gnt_wl=1,sw gnt_bt=1)
1308 0x38=0xddxx (sw : gnt_bt=1 , sw gnt_wl=0)
1309 0x38=0x55xx(hw pta :gnt_wl /gnt_bt ) */
1310 val = (sw_control) ? ((state << 1) | 0x1) : 0;
1311
1312 switch (control_block) {
1313 case BT_8822B_1ANT_GNT_BLOCK_RFC_BB:
1314 default:
1315 bit_mask = 0xc000;
1316 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1317 0x38, bit_mask, val); /* 0x38[15:14] */
1318 bit_mask = 0x0c00;
1319 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1320 0x38, bit_mask, val); /* 0x38[11:10] */
1321 break;
1322 case BT_8822B_1ANT_GNT_BLOCK_RFC:
1323 bit_mask = 0xc000;
1324 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1325 0x38, bit_mask, val); /* 0x38[15:14] */
1326 break;
1327 case BT_8822B_1ANT_GNT_BLOCK_BB:
1328 bit_mask = 0x0c00;
1329 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1330 0x38, bit_mask, val); /* 0x38[11:10] */
1331 break;
1332
1333 }
1334
1335 }
1336
halbtc8822b1ant_ltecoex_set_gnt_wl(IN struct btc_coexist * btcoexist,IN u8 control_block,IN boolean sw_control,IN u8 state)1337 void halbtc8822b1ant_ltecoex_set_gnt_wl(IN struct btc_coexist *btcoexist,
1338 IN u8 control_block, IN boolean sw_control, IN u8 state)
1339 {
1340 u32 val = 0, bit_mask;
1341 /*LTE indirect 0x38=0xccxx (sw : gnt_wl=1,sw gnt_bt=1)
1342 0x38=0xddxx (sw : gnt_bt=1 , sw gnt_wl=0)
1343 0x38=0x55xx(hw pta :gnt_wl /gnt_bt ) */
1344
1345 state = state & 0x1;
1346 val = (sw_control) ? ((state << 1) | 0x1) : 0;
1347
1348 switch (control_block) {
1349 case BT_8822B_1ANT_GNT_BLOCK_RFC_BB:
1350 default:
1351 bit_mask = 0x3000;
1352 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1353 0x38, bit_mask, val); /* 0x38[13:12] */
1354 bit_mask = 0x0300;
1355 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1356 0x38, bit_mask, val); /* 0x38[9:8] */
1357 break;
1358 case BT_8822B_1ANT_GNT_BLOCK_RFC:
1359 bit_mask = 0x3000;
1360 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1361 0x38, bit_mask, val); /* 0x38[13:12] */
1362 break;
1363 case BT_8822B_1ANT_GNT_BLOCK_BB:
1364 bit_mask = 0x0300;
1365 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist,
1366 0x38, bit_mask, val); /* 0x38[9:8] */
1367 break;
1368
1369 }
1370
1371 }
1372
halbtc8822b1ant_ltecoex_set_coex_table(IN struct btc_coexist * btcoexist,IN u8 table_type,IN u16 table_content)1373 void halbtc8822b1ant_ltecoex_set_coex_table(IN struct btc_coexist *btcoexist,
1374 IN u8 table_type, IN u16 table_content)
1375 {
1376 u16 reg_addr = 0x0000;
1377
1378 switch (table_type) {
1379 case BT_8822B_1ANT_CTT_WL_VS_LTE:
1380 reg_addr = 0xa0;
1381 break;
1382 case BT_8822B_1ANT_CTT_BT_VS_LTE:
1383 reg_addr = 0xa4;
1384 break;
1385 }
1386
1387 if (reg_addr != 0x0000)
1388 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist, reg_addr,
1389 0xffff, table_content); /* 0xa0[15:0] or 0xa4[15:0] */
1390
1391
1392 }
1393
1394
halbtc8822b1ant_ltcoex_set_break_table(IN struct btc_coexist * btcoexist,IN u8 table_type,IN u8 table_content)1395 void halbtc8822b1ant_ltcoex_set_break_table(IN struct btc_coexist *btcoexist,
1396 IN u8 table_type, IN u8 table_content)
1397 {
1398 u16 reg_addr = 0x0000;
1399
1400 switch (table_type) {
1401 case BT_8822B_1ANT_LBTT_WL_BREAK_LTE:
1402 reg_addr = 0xa8;
1403 break;
1404 case BT_8822B_1ANT_LBTT_BT_BREAK_LTE:
1405 reg_addr = 0xac;
1406 break;
1407 case BT_8822B_1ANT_LBTT_LTE_BREAK_WL:
1408 reg_addr = 0xb0;
1409 break;
1410 case BT_8822B_1ANT_LBTT_LTE_BREAK_BT:
1411 reg_addr = 0xb4;
1412 break;
1413 }
1414
1415 if (reg_addr != 0x0000)
1416 halbtc8822b1ant_ltecoex_indirect_write_reg(btcoexist, reg_addr,
1417 0xff, table_content); /* 0xa8[15:0] or 0xb4[15:0] */
1418
1419
1420 }
1421
halbtc8822b1ant_set_wltoggle_coex_table(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 interval,IN u8 val0x6c4_b0,IN u8 val0x6c4_b1,IN u8 val0x6c4_b2,IN u8 val0x6c4_b3)1422 void halbtc8822b1ant_set_wltoggle_coex_table(IN struct btc_coexist *btcoexist,
1423 IN boolean force_exec, IN u8 interval,
1424 IN u8 val0x6c4_b0, IN u8 val0x6c4_b1, IN u8 val0x6c4_b2,
1425 IN u8 val0x6c4_b3)
1426 {
1427 static u8 pre_h2c_parameter[6] = {0};
1428 u8 cur_h2c_parameter[6] = {0};
1429 u8 i, match_cnt = 0;
1430
1431 cur_h2c_parameter[0] = 0x7; /* op_code, 0x7= wlan toggle slot*/
1432
1433 cur_h2c_parameter[1] = interval;
1434 cur_h2c_parameter[2] = val0x6c4_b0;
1435 cur_h2c_parameter[3] = val0x6c4_b1;
1436 cur_h2c_parameter[4] = val0x6c4_b2;
1437 cur_h2c_parameter[5] = val0x6c4_b3;
1438
1439 if (!force_exec) {
1440 for (i = 1; i <= 5; i++) {
1441 if (cur_h2c_parameter[i] != pre_h2c_parameter[i])
1442 break;
1443
1444 match_cnt++;
1445 }
1446
1447 if (match_cnt == 5)
1448 return;
1449 }
1450
1451 for (i = 1; i <= 5; i++)
1452 pre_h2c_parameter[i] = cur_h2c_parameter[i];
1453
1454 btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, cur_h2c_parameter);
1455 }
1456
halbtc8822b1ant_set_coex_table(IN struct btc_coexist * btcoexist,IN u32 val0x6c0,IN u32 val0x6c4,IN u32 val0x6c8,IN u8 val0x6cc)1457 void halbtc8822b1ant_set_coex_table(IN struct btc_coexist *btcoexist,
1458 IN u32 val0x6c0, IN u32 val0x6c4, IN u32 val0x6c8, IN u8 val0x6cc)
1459 {
1460 btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
1461
1462 btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
1463
1464 btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
1465
1466 btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
1467 }
1468
halbtc8822b1ant_coex_table(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u32 val0x6c0,IN u32 val0x6c4,IN u32 val0x6c8,IN u8 val0x6cc)1469 void halbtc8822b1ant_coex_table(IN struct btc_coexist *btcoexist,
1470 IN boolean force_exec, IN u32 val0x6c0, IN u32 val0x6c4,
1471 IN u32 val0x6c8, IN u8 val0x6cc)
1472 {
1473 coex_dm->cur_val0x6c0 = val0x6c0;
1474 coex_dm->cur_val0x6c4 = val0x6c4;
1475 coex_dm->cur_val0x6c8 = val0x6c8;
1476 coex_dm->cur_val0x6cc = val0x6cc;
1477
1478
1479
1480 if (!force_exec) {
1481 if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
1482 (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
1483 (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
1484 (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
1485 return;
1486 }
1487 halbtc8822b1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, val0x6c8,
1488 val0x6cc);
1489
1490 coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
1491 coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
1492 coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
1493 coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
1494 }
1495
halbtc8822b1ant_coex_table_with_type(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 type)1496 void halbtc8822b1ant_coex_table_with_type(IN struct btc_coexist *btcoexist,
1497 IN boolean force_exec, IN u8 type)
1498 {
1499 u32 break_table;
1500 u8 select_table;
1501
1502
1503
1504 coex_sta->coex_table_type = type;
1505
1506 if (coex_sta->concurrent_rx_mode_on == true) {
1507 break_table = 0xf0ffffff; /* set WL hi-pri can break BT */
1508 select_table = 0x3; /* set Tx response = Hi-Pri (ex: Transmitting ACK,BA,CTS) */
1509 } else {
1510 break_table = 0xffffff;
1511 select_table = 0x3;
1512 }
1513
1514 switch (type) {
1515 case 0:
1516 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1517 0x55555555, 0x55555555, break_table,
1518 select_table);
1519 break;
1520 case 1:
1521 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1522 0x55555555, 0x5a5a5a5a, break_table,
1523 select_table);
1524 break;
1525 case 2:
1526 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1527 0xaa5a5a5a, 0xaa5a5a5a, break_table,
1528 select_table);
1529 break;
1530 case 3:
1531 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1532 0x55555555, 0xaa5a5a5a, break_table,
1533 select_table);
1534 break;
1535 case 4:
1536 halbtc8822b1ant_coex_table(btcoexist,
1537 force_exec, 0xaa555555, 0xaa5a5a5a,
1538 break_table, select_table);
1539 break;
1540 case 5:
1541 halbtc8822b1ant_coex_table(btcoexist,
1542 force_exec, 0x5a5a5a5a, 0x5a5a5a5a,
1543 break_table, select_table);
1544 break;
1545 case 6:
1546 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1547 0x55555555, 0xaaaaaaaa, break_table,
1548 select_table);
1549 break;
1550 case 7:
1551 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1552 0xaaaaaaaa, 0xaaaaaaaa, break_table,
1553 select_table);
1554 break;
1555 case 8:
1556 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1557 0xffffffff, 0xffffffff, break_table,
1558 select_table);
1559 break;
1560 case 9:
1561 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1562 0x5a5a5555, 0xaaaa5a5a, break_table,
1563 select_table);
1564 break;
1565 case 10:
1566 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1567 0xaaaa5aaa, 0xaaaa5aaa, break_table,
1568 select_table);
1569 break;
1570 case 11:
1571 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1572 0xaaaaa5aa, 0xaaaaaaaa, break_table,
1573 select_table);
1574 break;
1575 case 12:
1576 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1577 0xaaaaa5aa, 0xaaaaa5aa, break_table,
1578 select_table);
1579 break;
1580 case 13:
1581 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1582 0x55555555, 0xaaaa5a5a, break_table,
1583 select_table);
1584 break;
1585 case 14:
1586 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1587 0x5a5a555a, 0xaaaa5a5a, break_table,
1588 select_table);
1589 break;
1590 case 15:
1591 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1592 0x55555555, 0xaaaa55aa, break_table,
1593 select_table);
1594 break;
1595 case 16:
1596 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1597 0x5a5a555a, 0x5a5a555a, break_table,
1598 select_table);
1599 break;
1600 case 17:
1601 halbtc8822b1ant_coex_table(btcoexist, force_exec,
1602 0xaaaa55aa, 0xaaaa55aa, break_table,
1603 select_table);
1604 break;
1605
1606 default:
1607 break;
1608 }
1609 }
1610
halbtc8822b1ant_set_fw_ignore_wlan_act(IN struct btc_coexist * btcoexist,IN boolean enable)1611 void halbtc8822b1ant_set_fw_ignore_wlan_act(IN struct btc_coexist *btcoexist,
1612 IN boolean enable)
1613 {
1614
1615
1616 u8 h2c_parameter[1] = {0};
1617
1618 if (enable)
1619 h2c_parameter[0] |= BIT(0); /* function enable */
1620
1621 btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
1622 }
1623
halbtc8822b1ant_ignore_wlan_act(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN boolean enable)1624 void halbtc8822b1ant_ignore_wlan_act(IN struct btc_coexist *btcoexist,
1625 IN boolean force_exec, IN boolean enable)
1626 {
1627
1628 coex_dm->cur_ignore_wlan_act = enable;
1629
1630 if (!force_exec) {
1631 if (coex_dm->pre_ignore_wlan_act ==
1632 coex_dm->cur_ignore_wlan_act) {
1633
1634 coex_dm->pre_ignore_wlan_act =
1635 coex_dm->cur_ignore_wlan_act;
1636 return;
1637 }
1638 }
1639
1640 halbtc8822b1ant_set_fw_ignore_wlan_act(btcoexist, enable);
1641
1642 coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
1643 }
1644
halbtc8822b1ant_set_lps_rpwm(IN struct btc_coexist * btcoexist,IN u8 lps_val,IN u8 rpwm_val)1645 void halbtc8822b1ant_set_lps_rpwm(IN struct btc_coexist *btcoexist,
1646 IN u8 lps_val, IN u8 rpwm_val)
1647 {
1648 u8 lps = lps_val;
1649 u8 rpwm = rpwm_val;
1650
1651 btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps);
1652 btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
1653 }
1654
halbtc8822b1ant_lps_rpwm(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 lps_val,IN u8 rpwm_val)1655 void halbtc8822b1ant_lps_rpwm(IN struct btc_coexist *btcoexist,
1656 IN boolean force_exec, IN u8 lps_val, IN u8 rpwm_val)
1657 {
1658 coex_dm->cur_lps = lps_val;
1659 coex_dm->cur_rpwm = rpwm_val;
1660
1661 if (!force_exec) {
1662 if ((coex_dm->pre_lps == coex_dm->cur_lps) &&
1663 (coex_dm->pre_rpwm == coex_dm->cur_rpwm))
1664 return;
1665 }
1666 halbtc8822b1ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val);
1667
1668 coex_dm->pre_lps = coex_dm->cur_lps;
1669 coex_dm->pre_rpwm = coex_dm->cur_rpwm;
1670 }
1671
halbtc8822b1ant_ps_tdma_check_for_power_save_state(IN struct btc_coexist * btcoexist,IN boolean new_ps_state)1672 void halbtc8822b1ant_ps_tdma_check_for_power_save_state(
1673 IN struct btc_coexist *btcoexist, IN boolean new_ps_state)
1674 {
1675 u8 lps_mode = 0x0;
1676 u8 h2c_parameter[5] = {0x8, 0, 0, 0, 0};
1677
1678 btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode);
1679
1680 if (lps_mode) { /* already under LPS state */
1681 if (new_ps_state) {
1682 /* keep state under LPS, do nothing. */
1683 } else {
1684 /* will leave LPS state, turn off psTdma first */
1685
1686 btcoexist->btc_fill_h2c(btcoexist, 0x60, 5,
1687 h2c_parameter);
1688 }
1689 } else { /* NO PS state */
1690 if (new_ps_state) {
1691 /* will enter LPS state, turn off psTdma first */
1692
1693 btcoexist->btc_fill_h2c(btcoexist, 0x60, 5,
1694 h2c_parameter);
1695 } else {
1696 /* keep state under NO PS state, do nothing. */
1697 }
1698 }
1699 }
1700
1701
halbtc8822b1ant_power_save_state(IN struct btc_coexist * btcoexist,IN u8 ps_type,IN u8 lps_val,IN u8 rpwm_val)1702 void halbtc8822b1ant_power_save_state(IN struct btc_coexist *btcoexist,
1703 IN u8 ps_type, IN u8 lps_val, IN u8 rpwm_val)
1704 {
1705 boolean low_pwr_disable = false;
1706
1707 switch (ps_type) {
1708 case BTC_PS_WIFI_NATIVE:
1709 /* recover to original 32k low power setting */
1710 coex_sta->force_lps_on = false;
1711 low_pwr_disable = false;
1712 btcoexist->btc_set(btcoexist,
1713 BTC_SET_ACT_DISABLE_LOW_POWER,
1714 &low_pwr_disable);
1715 btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS,
1716 NULL);
1717 coex_sta->force_lps_on = false;
1718 break;
1719 case BTC_PS_LPS_ON:
1720
1721 coex_sta->force_lps_on = true;
1722 halbtc8822b1ant_ps_tdma_check_for_power_save_state(
1723 btcoexist, true);
1724 halbtc8822b1ant_lps_rpwm(btcoexist, NORMAL_EXEC,
1725 lps_val, rpwm_val);
1726 /* when coex force to enter LPS, do not enter 32k low power. */
1727 low_pwr_disable = true;
1728 btcoexist->btc_set(btcoexist,
1729 BTC_SET_ACT_DISABLE_LOW_POWER,
1730 &low_pwr_disable);
1731 /* power save must executed before psTdma. */
1732 btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS,
1733 NULL);
1734 coex_sta->force_lps_on = true;
1735 break;
1736 case BTC_PS_LPS_OFF:
1737
1738 coex_sta->force_lps_on = false;
1739 halbtc8822b1ant_ps_tdma_check_for_power_save_state(
1740 btcoexist, false);
1741 btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS,
1742 NULL);
1743 coex_sta->force_lps_on = false;
1744 break;
1745 default:
1746 break;
1747 }
1748 }
1749
1750
halbtc8822b1ant_set_fw_pstdma(IN struct btc_coexist * btcoexist,IN u8 byte1,IN u8 byte2,IN u8 byte3,IN u8 byte4,IN u8 byte5)1751 void halbtc8822b1ant_set_fw_pstdma(IN struct btc_coexist *btcoexist,
1752 IN u8 byte1, IN u8 byte2, IN u8 byte3, IN u8 byte4, IN u8 byte5)
1753 {
1754 u8 h2c_parameter[5] = {0};
1755 u8 real_byte1 = byte1, real_byte5 = byte5;
1756 boolean ap_enable = false;
1757
1758 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
1759 &ap_enable);
1760
1761 /*if (ap_enable) {
1762 if (byte1 & BIT(4) && !(byte1 & BIT(5))) {*/
1763 if ((ap_enable) && (byte1 & BIT(4) && !(byte1 & BIT(5)))) {
1764
1765 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1766 "[BTCoex], FW for 1Ant AP mode\n");
1767 BTC_TRACE(trace_buf);
1768
1769 real_byte1 &= ~BIT(4);
1770 real_byte1 |= BIT(5);
1771
1772 real_byte5 |= BIT(5);
1773 real_byte5 &= ~BIT(6);
1774
1775 halbtc8822b1ant_power_save_state(btcoexist,
1776 BTC_PS_WIFI_NATIVE, 0x0,
1777 0x0);
1778
1779 } else if (byte1 & BIT(4) && !(byte1 & BIT(5))) {
1780
1781 halbtc8822b1ant_power_save_state(btcoexist,
1782 BTC_PS_LPS_ON, 0x50,
1783 0x4);
1784 } else {
1785 halbtc8822b1ant_power_save_state(btcoexist,
1786 BTC_PS_WIFI_NATIVE, 0x0,
1787 0x0);
1788 }
1789
1790
1791 h2c_parameter[0] = real_byte1;
1792 h2c_parameter[1] = byte2;
1793 h2c_parameter[2] = byte3;
1794 h2c_parameter[3] = byte4;
1795 h2c_parameter[4] = real_byte5;
1796
1797 coex_dm->ps_tdma_para[0] = real_byte1;
1798 coex_dm->ps_tdma_para[1] = byte2;
1799 coex_dm->ps_tdma_para[2] = byte3;
1800 coex_dm->ps_tdma_para[3] = byte4;
1801 coex_dm->ps_tdma_para[4] = real_byte5;
1802
1803 btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
1804 }
1805
halbtc8822b1ant_ps_tdma(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN boolean turn_on,IN u8 type)1806 void halbtc8822b1ant_ps_tdma(IN struct btc_coexist *btcoexist,
1807 IN boolean force_exec, IN boolean turn_on, IN u8 type)
1808 {
1809 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
1810 struct btc_board_info *board_info = &btcoexist->board_info;
1811 boolean wifi_busy = false;
1812 static u8 psTdmaByte4Modify = 0x0, pre_psTdmaByte4Modify = 0x0;
1813 static boolean pre_wifi_busy = false;
1814
1815 coex_dm->cur_ps_tdma_on = turn_on;
1816 coex_dm->cur_ps_tdma = type;
1817
1818 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
1819
1820 if (wifi_busy != pre_wifi_busy) {
1821 force_exec = true;
1822 pre_wifi_busy = wifi_busy;
1823 }
1824
1825 /* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */
1826 if ((bt_link_info->slave_role) && (bt_link_info->a2dp_exist))
1827 psTdmaByte4Modify = 0x1;
1828 else
1829 psTdmaByte4Modify = 0x0;
1830
1831 if (pre_psTdmaByte4Modify != psTdmaByte4Modify) {
1832
1833 force_exec = true;
1834 pre_psTdmaByte4Modify = psTdmaByte4Modify;
1835 }
1836
1837 if (coex_dm->cur_ps_tdma_on) {
1838 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1839 "[BTCoex], ********TDMA(on, %d) **********\n",
1840 coex_dm->cur_ps_tdma);
1841 BTC_TRACE(trace_buf);
1842 } else {
1843 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1844 "[BTCoex], **********TDMA(off, %d) **********\n",
1845 coex_dm->cur_ps_tdma);
1846 BTC_TRACE(trace_buf);
1847 }
1848
1849 if (!force_exec) {
1850 if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
1851 (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) {
1852 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
1853 "[BTCoex], return for no-TDMA case change\n");
1854 BTC_TRACE(trace_buf);
1855
1856 return;
1857 }
1858 }
1859
1860
1861 if (turn_on) {
1862
1863 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x550, 0x8,
1864 0x1); /* enable TBTT nterrupt */
1865
1866 switch (type) {
1867 default:
1868 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1869 0x51, 0x1a, 0x1a, 0x0, 0x10);
1870 break;
1871 case 1:
1872 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1873 0x61, 0x3a, 0x03, 0x11, 0x10);
1874 break;
1875 case 3:
1876 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1877 0x51, 0x3a, 0x03, 0x10, 0x10);
1878 break;
1879 case 4:
1880 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1881 0x51, 0x21, 0x03, 0x10, 0x10);
1882 break;
1883 case 5:
1884 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1885 0x61, 0x15, 0x3, 0x11, 0x11);
1886 break;
1887 case 7:
1888 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1889 0x61, 0x10, 0x03, 0x10, 0x14 |
1890 psTdmaByte4Modify);
1891 break;
1892 case 8:
1893 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1894 0x51, 0x10, 0x03, 0x10, 0x14 |
1895 psTdmaByte4Modify);
1896 break;
1897 case 13:
1898 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1899 0x51, 0x25, 0x03, 0x10, 0x10 |
1900 psTdmaByte4Modify);
1901 break;
1902 case 14:
1903 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1904 0x51, 0x15, 0x03, 0x10, 0x10 |
1905 psTdmaByte4Modify);
1906 break;
1907 case 15:
1908 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1909 0x51, 0x20, 0x03, 0x10, 0x10 |
1910 psTdmaByte4Modify);
1911 break;
1912 case 17:
1913 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1914 0x61, 0x10, 0x03, 0x11, 0x14 |
1915 psTdmaByte4Modify);
1916 break;
1917
1918 case 20:
1919 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1920 0x61, 0x30, 0x03, 0x11, 0x10);
1921 break;
1922 case 22:
1923 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1924 0x61, 0x25, 0x03, 0x11, 0x10);
1925 break;
1926 case 32:
1927 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1928 0x61, 0x35, 0x3, 0x11, 0x11);
1929 break;
1930 case 33:
1931 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1932 0x61, 0x35, 0x03, 0x11, 0x10);
1933 break;
1934 case 41:
1935 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1936 0x51, 0x45, 0x3, 0x11, 0x11);
1937 break;
1938 case 42:
1939 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1940 0x51, 0x1e, 0x3, 0x10, 0x14 |
1941 psTdmaByte4Modify);
1942 break;
1943 case 43:
1944 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1945 0x51, 0x45, 0x3, 0x10, 0x14);
1946 break;
1947 case 44:
1948 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1949 0x51, 0x25, 0x3, 0x10, 0x10);
1950 break;
1951 case 45:
1952 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1953 0x51, 0x29, 0x3, 0x10, 0x10);
1954 break;
1955 case 46:
1956 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1957 0x51, 0x1a, 0x3, 0x10, 0x10);
1958 break;
1959 case 47:
1960 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1961 0x51, 0x32, 0x3, 0x10, 0x10);
1962 break;
1963 case 48:
1964 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1965 0x51, 0x29, 0x3, 0x10, 0x10);
1966 break;
1967 case 49:
1968 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1969 0x55, 0x1e, 0x3, 0x10, 0x54);
1970 break;
1971 case 50:
1972 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1973 0x51, 0x4a, 0x3, 0x10, 0x10);
1974 break;
1975
1976 }
1977 } else {
1978
1979 switch (type) {
1980 case 0:
1981 default: /* Software control, Antenna at BT side */
1982 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1983 0x0, 0x0, 0x0, 0x0, 0x0);
1984 /*
1985 halbtc8822b1ant_set_ant_path(btcoexist,
1986 BTC_ANT_PATH_BT, FORCE_EXEC, false,
1987 false); */
1988 break;
1989 case 8: /* PTA Control */
1990 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1991 0x8, 0x0, 0x0, 0x0, 0x0);
1992 /*
1993 halbtc8822b1ant_set_ant_path(btcoexist,
1994 BTC_ANT_PATH_PTA, FORCE_EXEC, false,
1995 false); */
1996 break;
1997 case 9: /* Software control, Antenna at WiFi side */
1998 halbtc8822b1ant_set_fw_pstdma(btcoexist,
1999 0x0, 0x0, 0x0, 0x0, 0x0);
2000 /*
2001 halbtc8822b1ant_set_ant_path(btcoexist,
2002 BTC_ANT_PATH_WIFI, FORCE_EXEC,false,false); */
2003 break;
2004 case 10: /* under 5G , 0x778=1*/
2005 halbtc8822b1ant_set_fw_pstdma(btcoexist,
2006 0x0, 0x0, 0x0, 0x0, 0x0);
2007
2008 /*
2009 halbtc8822b1ant_set_ant_path(btcoexist,
2010 BTC_ANT_PATH_WIFI5G, FORCE_EXEC, false,
2011 false); */
2012
2013 break;
2014 }
2015 }
2016
2017
2018 /* update pre state */
2019 coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
2020 coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
2021 }
2022
2023
halbtc8822b1ant_sw_mechanism(IN struct btc_coexist * btcoexist,IN boolean low_penalty_ra)2024 void halbtc8822b1ant_sw_mechanism(IN struct btc_coexist *btcoexist,
2025 IN boolean low_penalty_ra)
2026 {
2027 halbtc8822b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
2028 }
2029 /*rf4 type by efuse , and for ant at main aux inverse use , because is 2x2 ,and control types are the same ,does not need */
2030
halbtc8822b1ant_set_rfe_type(IN struct btc_coexist * btcoexist)2031 void halbtc8822b1ant_set_rfe_type(IN struct btc_coexist *btcoexist)
2032 {
2033 struct btc_board_info *board_info = &btcoexist->board_info;
2034
2035 /* Ext switch buffer mux */
2036 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
2037 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
2038 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
2039
2040 /* the following setup should be got from Efuse in the future */
2041 rfe_type->rfe_module_type = board_info->rfe_type;
2042
2043 rfe_type->ext_ant_switch_ctrl_polarity = 0;
2044
2045 switch (rfe_type->rfe_module_type) {
2046 case 0:
2047 default:
2048 rfe_type->ext_ant_switch_exist = true;
2049 rfe_type->ext_ant_switch_type =
2050 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2051 break;
2052 case 1:
2053 rfe_type->ext_ant_switch_exist = true;
2054 rfe_type->ext_ant_switch_type =
2055 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2056 break;
2057 case 2:
2058 rfe_type->ext_ant_switch_exist = true;
2059 rfe_type->ext_ant_switch_type =
2060 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2061 break;
2062 case 3:
2063 rfe_type->ext_ant_switch_exist = true;
2064 rfe_type->ext_ant_switch_type =
2065 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2066 break;
2067 case 4:
2068 rfe_type->ext_ant_switch_exist = true;
2069 rfe_type->ext_ant_switch_type =
2070 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2071 break;
2072 case 5:
2073 rfe_type->ext_ant_switch_exist = true;
2074 rfe_type->ext_ant_switch_type =
2075 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2076 break;
2077 case 6:
2078 rfe_type->ext_ant_switch_exist = true;
2079 rfe_type->ext_ant_switch_type =
2080 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2081 break;
2082 case 7:
2083 rfe_type->ext_ant_switch_exist = true;
2084 rfe_type->ext_ant_switch_type =
2085 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT;
2086 break;
2087 }
2088
2089
2090 }
2091
2092 /*anttenna control by bb mac bt antdiv pta to write 0x4c 0xcb4,0xcbd*/
2093
halbtc8822b1ant_set_ext_ant_switch(IN struct btc_coexist * btcoexist,IN boolean force_exec,IN u8 ctrl_type,IN u8 pos_type)2094 void halbtc8822b1ant_set_ext_ant_switch(IN struct btc_coexist *btcoexist,
2095 IN boolean force_exec, IN u8 ctrl_type, IN u8 pos_type)
2096 {
2097 struct btc_board_info *board_info = &btcoexist->board_info;
2098 boolean switch_polatiry_inverse = false;
2099 u8 regval_0xcbd = 0, regval_0x64;
2100 u32 u32tmp1 = 0, u32tmp2 = 0, u32tmp3 = 0;
2101 /* Ext switch buffer mux */
2102 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
2103 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
2104 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
2105
2106 if (!rfe_type->ext_ant_switch_exist)
2107 return;
2108
2109 coex_dm->cur_ext_ant_switch_status = (ctrl_type << 8) + pos_type;
2110
2111 if (!force_exec) {
2112 if (coex_dm->pre_ext_ant_switch_status ==
2113 coex_dm->cur_ext_ant_switch_status)
2114 return;
2115 }
2116
2117 coex_dm->pre_ext_ant_switch_status = coex_dm->cur_ext_ant_switch_status;
2118
2119 /* swap control polarity if use different switch control polarity*/
2120 /* Normal switch polarity for SPDT, 0xcbd[1:0] = 2b'01 => Ant to BTG, 0xcbd[1:0] = 2b'10 => Ant to WLG */
2121 switch_polatiry_inverse = (rfe_type->ext_ant_switch_ctrl_polarity == 1 ?
2122 ~switch_polatiry_inverse : switch_polatiry_inverse);
2123
2124
2125 switch (pos_type) {
2126 default:
2127 case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_BT:
2128 case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_NOCARE:
2129
2130 break;
2131 case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLG:
2132 break;
2133 case BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLA:
2134 break;
2135 }
2136
2137
2138 if (rfe_type->ext_ant_switch_type ==
2139 BT_8822B_1ANT_EXT_ANT_SWITCH_USE_SPDT) {
2140 switch (ctrl_type) {
2141 default:
2142 case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW:
2143 btcoexist->btc_write_1byte_bitmask(
2144 btcoexist, 0x4e, 0x80,
2145 0x0); /* 0x4c[23] = 0 */
2146 btcoexist->btc_write_1byte_bitmask(
2147 btcoexist, 0x4f, 0x01,
2148 0x1); /* 0x4c[24] = 1 */
2149 btcoexist->btc_write_1byte_bitmask(
2150 btcoexist, 0xcb4, 0xff,
2151 0x77); /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as conctrol pin */
2152
2153 regval_0xcbd = (switch_polatiry_inverse
2154 == false ? 0x1 :
2155 0x2); /* 0xcbd[1:0] = 2b'01 for no switch_polatiry_inverse, ANTSWB =1, ANTSW =0 */
2156 btcoexist->btc_write_1byte_bitmask(
2157 btcoexist, 0xcbd, 0x3,
2158 regval_0xcbd);
2159
2160 break;
2161 case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_PTA:
2162 btcoexist->btc_write_1byte_bitmask(
2163 btcoexist, 0x4e, 0x80,
2164 0x0); /* 0x4c[23] = 0 */
2165 btcoexist->btc_write_1byte_bitmask(
2166 btcoexist, 0x4f, 0x01,
2167 0x1); /* 0x4c[24] = 1 */
2168 btcoexist->btc_write_1byte_bitmask(
2169 btcoexist, 0xcb4, 0xff,
2170 0x66); /* PTA, DPDT use RFE_ctrl8 and RFE_ctrl9 as conctrol pin */
2171
2172 regval_0xcbd = (switch_polatiry_inverse
2173 == false ? 0x2 :
2174 0x1); /* 0xcbd[1:0] = 2b'10 for no switch_polatiry_inverse, ANTSWB =1, ANTSW =0 @ GNT_BT=1 */
2175 btcoexist->btc_write_1byte_bitmask(
2176 btcoexist, 0xcbd, 0x3,
2177 regval_0xcbd);
2178
2179 break;
2180 case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_ANTDIV
2181 :
2182 btcoexist->btc_write_1byte_bitmask(
2183 btcoexist, 0x4e, 0x80,
2184 0x0); /* 0x4c[23] = 0 */
2185 btcoexist->btc_write_1byte_bitmask(
2186 btcoexist, 0x4f, 0x01,
2187 0x1); /* 0x4c[24] = 1 */
2188 btcoexist->btc_write_1byte_bitmask(
2189 btcoexist, 0xcb4, 0xff,
2190 0x88); /* */
2191
2192 /* no regval_0xcbd setup required, because antenna switch control value by antenna diversity */
2193
2194 break;
2195 case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_MAC:
2196 btcoexist->btc_write_1byte_bitmask(
2197 btcoexist, 0x4e, 0x80,
2198 0x1); /* 0x4c[23] = 1 */
2199
2200 regval_0x64 = (switch_polatiry_inverse
2201 == false ? 0x0 :
2202 0x1); /* 0x64[0] = 1b'0 for no switch_polatiry_inverse, DPDT_SEL_N =1, DPDT_SEL_P =0 */
2203 btcoexist->btc_write_1byte_bitmask(
2204 btcoexist, 0x64, 0x1,
2205 regval_0x64);
2206 break;
2207 case BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BT:
2208 btcoexist->btc_write_1byte_bitmask(
2209 btcoexist, 0x4e, 0x80,
2210 0x0); /* 0x4c[23] = 0 */
2211 btcoexist->btc_write_1byte_bitmask(
2212 btcoexist, 0x4f, 0x01,
2213 0x0); /* 0x4c[24] = 0 */
2214
2215 /* no setup required, because antenna switch control value by BT vendor 0xac[1:0] */
2216 break;
2217 }
2218 }
2219
2220 u32tmp1 = btcoexist->btc_read_4byte(btcoexist, 0xcbc);
2221 u32tmp2 = btcoexist->btc_read_4byte(btcoexist, 0x4c);
2222 u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0x64) & 0xff;
2223
2224 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2225 "[BTCoex], ********** (After Ext Ant switch setup) 0xcbc = 0x%08x, 0x4c = 0x%08x, 0x64= 0x%02x**********\n",
2226 u32tmp1, u32tmp2, u32tmp3);
2227 BTC_TRACE(trace_buf);
2228
2229
2230 }
2231
2232 /*set gnt_wl gnt_bt control by sw high low , or hwpta while in power on,ini,wlan off,wlan only ,wl2g non-currrent ,wl2g current,wl5g*/
2233
halbtc8822b1ant_set_ant_path(IN struct btc_coexist * btcoexist,IN u8 ant_pos_type,IN boolean force_exec,IN u8 phase)2234 void halbtc8822b1ant_set_ant_path(IN struct btc_coexist *btcoexist,
2235 IN u8 ant_pos_type, IN boolean force_exec,
2236 IN u8 phase)
2237
2238 {
2239 struct btc_board_info *board_info = &btcoexist->board_info;
2240 u8 u8tmp = 0;
2241 u32 u32tmp1 = 0, u32tmp2 = 0, u32tmp3 = 0;
2242 /* Ext switch buffer mux */
2243 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
2244 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
2245 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
2246
2247 coex_dm->cur_ant_pos_type = (ant_pos_type << 8) + phase;
2248
2249 if (!force_exec) {
2250 if (coex_dm->cur_ant_pos_type ==
2251 coex_dm->pre_ant_pos_type)
2252 return;
2253 }
2254
2255 coex_dm->pre_ant_pos_type = coex_dm->cur_ant_pos_type;
2256
2257 #if 1
2258 u32tmp1 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
2259 0x38);
2260 u32tmp2 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
2261 0x54);
2262 u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
2263
2264 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x73);
2265
2266 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2267 "[BTCoex], ********** (Before Ant Setup) 0xcb4 = 0x%x, 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n",
2268 u32tmp3, u8tmp, u32tmp1, u32tmp2);
2269 BTC_TRACE(trace_buf);
2270 #endif
2271
2272 switch (phase) {
2273 case BT_8822B_1ANT_PHASE_COEX_INIT:
2274 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2275 "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_COEX_INIT) **********\n");
2276 BTC_TRACE(trace_buf);
2277
2278 /* Disable LTE Coex Function in WiFi side (this should be on if LTE coex is required) */
2279 halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
2280
2281 /* GNT_WL_LTE always = 1 (this should be config if LTE coex is required) */
2282 halbtc8822b1ant_ltecoex_set_coex_table(btcoexist,
2283 BT_8822B_1ANT_CTT_WL_VS_LTE,
2284 0xffff);
2285
2286 /* GNT_BT_LTE always = 1 (this should be config if LTE coex is required) */
2287 halbtc8822b1ant_ltecoex_set_coex_table(btcoexist,
2288 BT_8822B_1ANT_CTT_BT_VS_LTE,
2289 0xffff);
2290
2291 /* set GNT_BT to SW high */
2292 halbtc8822b1ant_ltecoex_set_gnt_bt(btcoexist,
2293 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2294 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2295 BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
2296
2297 /* set GNT_WL to SW low */
2298 halbtc8822b1ant_ltecoex_set_gnt_wl(btcoexist,
2299 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2300 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2301 BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
2302
2303 /* set Path control owner to WL at initial step */
2304 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
2305 BT_8822B_1ANT_PCO_WLSIDE);
2306
2307 coex_sta->run_time_state = false;
2308
2309 /* Ext switch buffer mux */
2310 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
2311 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991,
2312 0x3, 0x0);
2313 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe,
2314 0x8, 0x0);
2315
2316 if (BTC_ANT_PATH_AUTO == ant_pos_type)
2317 ant_pos_type = BTC_ANT_PATH_BT;
2318
2319 break;
2320 case BT_8822B_1ANT_PHASE_WLANONLY_INIT:
2321 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2322 "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_WLANONLY_INIT) **********\n");
2323 BTC_TRACE(trace_buf);
2324
2325 /* Disable LTE Coex Function in WiFi side (this should be on if LTE coex is required) */
2326 halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
2327
2328 /* GNT_WL_LTE always = 1 (this should be config if LTE coex is required) */
2329 halbtc8822b1ant_ltecoex_set_coex_table(btcoexist,
2330 BT_8822B_1ANT_CTT_WL_VS_LTE,
2331 0xffff);
2332
2333 /* GNT_BT_LTE always = 1 (this should be config if LTE coex is required) */
2334 halbtc8822b1ant_ltecoex_set_coex_table(btcoexist,
2335 BT_8822B_1ANT_CTT_BT_VS_LTE,
2336 0xffff);
2337
2338 /* set GNT_BT to SW Low */
2339 halbtc8822b1ant_ltecoex_set_gnt_bt(btcoexist,
2340 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2341 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2342 BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
2343
2344 /* Set GNT_WL to SW high */
2345 halbtc8822b1ant_ltecoex_set_gnt_wl(btcoexist,
2346 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2347 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2348 BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
2349
2350 /* set Path control owner to WL at initial step */
2351 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
2352 BT_8822B_1ANT_PCO_WLSIDE);
2353
2354 coex_sta->run_time_state = false;
2355
2356 /* Ext switch buffer mux */
2357 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
2358 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991,
2359 0x3, 0x0);
2360 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe,
2361 0x8, 0x0);
2362
2363 if (BTC_ANT_PATH_AUTO == ant_pos_type)
2364 ant_pos_type = BTC_ANT_PATH_WIFI;
2365
2366 break;
2367 case BT_8822B_1ANT_PHASE_WLAN_OFF:
2368 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2369 "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_WLAN_OFF) **********\n");
2370 BTC_TRACE(trace_buf);
2371
2372 /* Disable LTE Coex Function in WiFi side */
2373 halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
2374
2375 /* set Path control owner to BT */
2376 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
2377 BT_8822B_1ANT_PCO_BTSIDE);
2378
2379 /* Set Ext Ant Switch to BT control at wifi off step */
2380 halbtc8822b1ant_set_ext_ant_switch(btcoexist,
2381 FORCE_EXEC,
2382 BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BT,
2383 BT_8822B_1ANT_EXT_ANT_SWITCH_TO_NOCARE);
2384
2385 coex_sta->run_time_state = false;
2386
2387 break;
2388 case BT_8822B_1ANT_PHASE_2G_RUNTIME:
2389 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2390 "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_2G_RUNTIME) **********\n");
2391 BTC_TRACE(trace_buf);
2392
2393 /* set GNT_BT to PTA */
2394 halbtc8822b1ant_ltecoex_set_gnt_bt(btcoexist,
2395 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2396 BT_8822B_1ANT_GNT_CTRL_BY_PTA,
2397 BT_8822B_1ANT_SIG_STA_SET_BY_HW);
2398
2399 /* Set GNT_WL to PTA */
2400 halbtc8822b1ant_ltecoex_set_gnt_wl(btcoexist,
2401 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2402 BT_8822B_1ANT_GNT_CTRL_BY_PTA,
2403 BT_8822B_1ANT_SIG_STA_SET_BY_HW);
2404
2405 /* set Path control owner to WL at runtime step */
2406 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
2407 BT_8822B_1ANT_PCO_WLSIDE);
2408
2409 coex_sta->run_time_state = true;
2410
2411 if (BTC_ANT_PATH_AUTO == ant_pos_type)
2412 ant_pos_type = BTC_ANT_PATH_PTA;
2413
2414 break;
2415 case BT_8822B_1ANT_PHASE_5G_RUNTIME:
2416 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2417 "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_5G_RUNTIME) **********\n");
2418 BTC_TRACE(trace_buf);
2419
2420 /* set GNT_BT to SW Hi */
2421 halbtc8822b1ant_ltecoex_set_gnt_bt(btcoexist,
2422 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2423 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2424 BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
2425
2426 /* Set GNT_WL to SW Hi */
2427 halbtc8822b1ant_ltecoex_set_gnt_wl(btcoexist,
2428 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2429 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2430 BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
2431
2432 /* set Path control owner to WL at runtime step */
2433 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
2434 BT_8822B_1ANT_PCO_WLSIDE);
2435
2436 coex_sta->run_time_state = true;
2437
2438 if (BTC_ANT_PATH_AUTO == ant_pos_type)
2439 ant_pos_type =
2440 BTC_ANT_PATH_WIFI5G;
2441
2442 break;
2443 case BT_8822B_1ANT_PHASE_BTMPMODE:
2444 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2445 "[BTCoex], ********** (set_ant_path - 1ANT_PHASE_BTMPMODE) **********\n");
2446 BTC_TRACE(trace_buf);
2447
2448 /* Disable LTE Coex Function in WiFi side */
2449 halbtc8822b1ant_ltecoex_enable(btcoexist, 0x0);
2450
2451 /* set GNT_BT to SW Hi */
2452 halbtc8822b1ant_ltecoex_set_gnt_bt(btcoexist,
2453 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2454 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2455 BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
2456
2457 /* Set GNT_WL to SW Lo */
2458 halbtc8822b1ant_ltecoex_set_gnt_wl(btcoexist,
2459 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
2460 BT_8822B_1ANT_GNT_CTRL_BY_SW,
2461 BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
2462
2463 /* set Path control owner to WL */
2464 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
2465 BT_8822B_1ANT_PCO_WLSIDE);
2466
2467 coex_sta->run_time_state = false;
2468
2469 /* Set Ext Ant Switch to BT side at BT MP mode */
2470 if (BTC_ANT_PATH_AUTO == ant_pos_type)
2471 ant_pos_type = BTC_ANT_PATH_BT;
2472
2473 break;
2474 }
2475
2476
2477 if (phase != BT_8822B_1ANT_PHASE_WLAN_OFF) {
2478 switch (ant_pos_type) {
2479 case BTC_ANT_PATH_WIFI:
2480 halbtc8822b1ant_set_ext_ant_switch(
2481 btcoexist,
2482 force_exec,
2483 BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW,
2484 BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLG);
2485 break;
2486 case BTC_ANT_PATH_WIFI5G
2487 :
2488 halbtc8822b1ant_set_ext_ant_switch(
2489 btcoexist,
2490 force_exec,
2491 BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW,
2492 BT_8822B_1ANT_EXT_ANT_SWITCH_TO_WLA);
2493 break;
2494 case BTC_ANT_PATH_BT:
2495 halbtc8822b1ant_set_ext_ant_switch(
2496 btcoexist,
2497 force_exec,
2498 BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW,
2499 BT_8822B_1ANT_EXT_ANT_SWITCH_TO_BT);
2500 break;
2501 default:
2502 case BTC_ANT_PATH_PTA:
2503 halbtc8822b1ant_set_ext_ant_switch(
2504 btcoexist,
2505 force_exec,
2506 BT_8822B_1ANT_EXT_ANT_SWITCH_CTRL_BY_PTA,
2507 BT_8822B_1ANT_EXT_ANT_SWITCH_TO_NOCARE);
2508 break;
2509 }
2510
2511 }
2512 #if 1
2513 u32tmp1 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x38);
2514 u32tmp2 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x54);
2515 u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
2516
2517 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x73);
2518
2519 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2520 "[BTCoex], ********** (After Ant Setup) 0xcb4 = 0x%x, 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n",
2521 u32tmp3, u8tmp, u32tmp1, u32tmp2);
2522 BTC_TRACE(trace_buf);
2523
2524 #endif
2525
2526 }
2527
2528
halbtc8822b1ant_coex_all_off(IN struct btc_coexist * btcoexist)2529 void halbtc8822b1ant_coex_all_off(IN struct btc_coexist *btcoexist)
2530 {
2531 /* sw all off */
2532 halbtc8822b1ant_sw_mechanism(btcoexist, false);
2533
2534 /* hw all off */
2535 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2536 }
halbtc8822b1ant_is_common_action(IN struct btc_coexist * btcoexist)2537 boolean halbtc8822b1ant_is_common_action(IN struct btc_coexist *btcoexist)
2538 {
2539 boolean common = false, wifi_connected = false, wifi_busy = false;
2540
2541 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
2542 &wifi_connected);
2543 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
2544
2545 if (!wifi_connected &&
2546 BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
2547 coex_dm->bt_status) {
2548 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2549 "[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n");
2550 BTC_TRACE(trace_buf);
2551
2552 /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
2553
2554 common = true;
2555 } else if (wifi_connected &&
2556 (BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
2557 coex_dm->bt_status)) {
2558 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2559 "[BTCoex], Wifi connected + BT non connected-idle!!\n");
2560 BTC_TRACE(trace_buf);
2561
2562 /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
2563
2564 common = true;
2565 } else if (!wifi_connected &&
2566 (BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE ==
2567 coex_dm->bt_status)) {
2568 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2569 "[BTCoex], Wifi non connected-idle + BT connected-idle!!\n");
2570 BTC_TRACE(trace_buf);
2571
2572 /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
2573
2574 common = true;
2575 } else if (wifi_connected &&
2576 (BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE ==
2577 coex_dm->bt_status)) {
2578 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2579 "[BTCoex], Wifi connected + BT connected-idle!!\n");
2580 BTC_TRACE(trace_buf);
2581
2582 /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
2583
2584 common = true;
2585 } else if (!wifi_connected &&
2586 (BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE !=
2587 coex_dm->bt_status)) {
2588 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2589 "[BTCoex], Wifi non connected-idle + BT Busy!!\n");
2590 BTC_TRACE(trace_buf);
2591
2592 /* halbtc8822b1ant_sw_mechanism(btcoexist, false); */
2593
2594 common = true;
2595 } else {
2596 if (wifi_busy) {
2597 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2598 "[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
2599 BTC_TRACE(trace_buf);
2600 } else {
2601 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2602 "[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
2603 BTC_TRACE(trace_buf);
2604 }
2605
2606 common = false;
2607 }
2608
2609 return common;
2610 }
2611
halbtc8822b1ant_action_wifi_under5g(IN struct btc_coexist * btcoexist)2612 void halbtc8822b1ant_action_wifi_under5g(IN struct btc_coexist *btcoexist)
2613 {
2614 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2615 "[BTCoex], under 5g start\n");
2616 BTC_TRACE(trace_buf);
2617 /* for test : s3 bt disappear , fail rate 1/600*/
2618 /*
2619 halbtc8822b1ant_ignore_wlan_act(btcoexist, NORMAL_EXEC, true);
2620 */
2621 /*set sw gnt wl bt high*/
2622 halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, FORCE_EXEC,
2623 BT_8822B_1ANT_PHASE_5G_RUNTIME);
2624
2625 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
2626 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2627 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
2628 0x3, 1);
2629 /*
2630 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
2631
2632 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 5);
2633 */
2634 }
2635
2636
2637
halbtc8822b1ant_action_wifi_only(IN struct btc_coexist * btcoexist)2638 void halbtc8822b1ant_action_wifi_only(IN struct btc_coexist *btcoexist)
2639 {
2640 boolean wifi_under_5g = false, rf4ce_enabled = false;
2641
2642 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
2643 if (wifi_under_5g) {
2644 halbtc8822b1ant_action_wifi_under5g(btcoexist);
2645
2646 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2647 "[BTCoex], ********** (wlan only -- under 5g ) **********\n");
2648 BTC_TRACE(trace_buf);
2649 return;
2650 }
2651
2652 if (rf4ce_enabled) {
2653 btcoexist->btc_write_1byte_bitmask(
2654 btcoexist, 0x45e, 0x8, 0x1);
2655
2656 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
2657 true,
2658 50);
2659
2660 halbtc8822b1ant_coex_table_with_type(btcoexist,
2661 NORMAL_EXEC, 1);
2662 return;
2663 }
2664 halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
2665 halbtc8822b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
2666
2667 halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO, FORCE_EXEC,
2668 BT_8822B_1ANT_PHASE_2G_RUNTIME);
2669
2670 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2671 "[BTCoex], ********** (wlan only -- under 2g ) **********\n");
2672 BTC_TRACE(trace_buf);
2673
2674 }
2675
2676 /* *********************************************
2677 *
2678 * Software Coex Mechanism start
2679 *
2680 * ********************************************* */
2681
2682 /* SCO only or SCO+PAN(HS) */
2683
2684 /*
2685 void halbtc8822b1ant_action_sco(IN struct btc_coexist* btcoexist)
2686 {
2687 halbtc8822b1ant_sw_mechanism(btcoexist, true);
2688 }
2689
2690
2691 void halbtc8822b1ant_action_hid(IN struct btc_coexist* btcoexist)
2692 {
2693 halbtc8822b1ant_sw_mechanism(btcoexist, true);
2694 }
2695
2696
2697 void halbtc8822b1ant_action_a2dp(IN struct btc_coexist* btcoexist)
2698 {
2699 halbtc8822b1ant_sw_mechanism(btcoexist, false);
2700 }
2701
2702 void halbtc8822b1ant_action_a2dp_pan_hs(IN struct btc_coexist* btcoexist)
2703 {
2704 halbtc8822b1ant_sw_mechanism(btcoexist, false);
2705 }
2706
2707 void halbtc8822b1ant_action_pan_edr(IN struct btc_coexist* btcoexist)
2708 {
2709 halbtc8822b1ant_sw_mechanism(btcoexist, false);
2710 }
2711
2712
2713 void halbtc8822b1ant_action_pan_hs(IN struct btc_coexist* btcoexist)
2714 {
2715 halbtc8822b1ant_sw_mechanism(btcoexist, false);
2716 }
2717
2718
2719 void halbtc8822b1ant_action_pan_edr_a2dp(IN struct btc_coexist* btcoexist)
2720 {
2721 halbtc8822b1ant_sw_mechanism(btcoexist, false);
2722 }
2723
2724 void halbtc8822b1ant_action_pan_edr_hid(IN struct btc_coexist* btcoexist)
2725 {
2726 halbtc8822b1ant_sw_mechanism(btcoexist, true);
2727 }
2728
2729
2730 void halbtc8822b1ant_action_hid_a2dp_pan_edr(IN struct btc_coexist* btcoexist)
2731 {
2732 halbtc8822b1ant_sw_mechanism(btcoexist, true);
2733 }
2734
2735 void halbtc8822b1ant_action_hid_a2dp(IN struct btc_coexist* btcoexist)
2736 {
2737 halbtc8822b1ant_sw_mechanism(btcoexist, true);
2738 }
2739
2740 */
2741
2742 /* *********************************************
2743 *
2744 * Non-Software Coex Mechanism start
2745 *
2746 * ********************************************* */
halbtc8822b1ant_action_bt_whck_test(IN struct btc_coexist * btcoexist)2747 void halbtc8822b1ant_action_bt_whck_test(IN struct btc_coexist *btcoexist)
2748 {
2749 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2750 "[BTCoex],action_bt_whck_test\n");
2751 BTC_TRACE(trace_buf);
2752
2753 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
2754
2755 halbtc8822b1ant_set_ant_path(btcoexist,
2756 BTC_ANT_PATH_AUTO,
2757 NORMAL_EXEC,
2758 BT_8822B_1ANT_PHASE_2G_RUNTIME);
2759
2760 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2761 }
2762
halbtc8822b1ant_action_wifi_multi_port(IN struct btc_coexist * btcoexist)2763 void halbtc8822b1ant_action_wifi_multi_port(IN struct btc_coexist *btcoexist)
2764 {
2765 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2766 "[BTCoex],action_wifi_multi_port\n");
2767 BTC_TRACE(trace_buf);
2768
2769 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
2770
2771 halbtc8822b1ant_set_ant_path(btcoexist,
2772 BTC_ANT_PATH_AUTO,
2773 NORMAL_EXEC,
2774 BT_8822B_1ANT_PHASE_2G_RUNTIME);
2775
2776 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2777 }
2778
halbtc8822b1ant_action_hs(IN struct btc_coexist * btcoexist)2779 void halbtc8822b1ant_action_hs(IN struct btc_coexist *btcoexist)
2780 {
2781 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2782 "[BTCoex], action_hs\n");
2783 BTC_TRACE(trace_buf);
2784
2785 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
2786
2787 halbtc8822b1ant_set_ant_path(btcoexist,
2788 BTC_ANT_PATH_AUTO,
2789 NORMAL_EXEC,
2790 BT_8822B_1ANT_PHASE_2G_RUNTIME);
2791
2792 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
2793 }
2794
2795 /*"""bt inquiry"""" + wifi any + bt any*/
halbtc8822b1ant_action_bt_inquiry(IN struct btc_coexist * btcoexist)2796 void halbtc8822b1ant_action_bt_inquiry(IN struct btc_coexist *btcoexist)
2797 {
2798
2799 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
2800 boolean wifi_connected = false, ap_enable = false, wifi_busy = false,
2801 bt_busy = false, rf4ce_enabled = false;
2802
2803
2804 boolean wifi_scan = false, link = false, roam = false;
2805
2806 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2807 "[BTCoex], ********** (bt inquiry) **********\n");
2808 BTC_TRACE(trace_buf);
2809 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
2810 &ap_enable);
2811 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
2812 &wifi_connected);
2813 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
2814 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
2815
2816
2817 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &wifi_scan);
2818 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
2819 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
2820
2821
2822 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2823 "[BTCoex], ********** scan = %d, link =%d, roam = %d**********\n",
2824 wifi_scan, link, roam);
2825 BTC_TRACE(trace_buf);
2826
2827 if ((link) || (roam) || (coex_sta->wifi_is_high_pri_task)) {
2828
2829 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2830 "[BTCoex], ********** (bt inquiry wifi connect or scan ) **********\n");
2831 BTC_TRACE(trace_buf);
2832
2833 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1);
2834
2835 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
2836
2837 } else if ((wifi_scan) && (coex_sta->bt_create_connection)) {
2838
2839 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
2840 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
2841
2842 } else if ((!wifi_connected) && (!wifi_scan)) {
2843
2844 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2845 "[BTCoex], ********** (bt inquiry wifi non connect) **********\n");
2846 BTC_TRACE(trace_buf);
2847
2848 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
2849
2850 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2851
2852 } else if ((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) {
2853
2854 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
2855 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2856 } else if (bt_link_info->a2dp_exist) {
2857
2858 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
2859
2860 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
2861 } else if (wifi_scan) {
2862
2863 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
2864
2865 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2866 } else if (wifi_busy) {
2867
2868 /* for BT inquiry/page fail after S4 resume */
2869 /* halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); */
2870 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
2871 /*aaaa->55aa for bt connect while wl busy*/
2872 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
2873 15);
2874 if (rf4ce_enabled) {
2875 btcoexist->btc_write_1byte_bitmask(
2876 btcoexist, 0x45e, 0x8, 0x1);
2877
2878 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
2879 true,
2880 50);
2881
2882 halbtc8822b1ant_coex_table_with_type(btcoexist,
2883 NORMAL_EXEC, 0);
2884
2885 }
2886 } else {
2887 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2888 "[BTCoex], ********** (bt inquiry wifi connect) **********\n");
2889 BTC_TRACE(trace_buf);
2890
2891 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
2892
2893 halbtc8822b1ant_set_ant_path(btcoexist,
2894 BTC_ANT_PATH_AUTO,
2895 NORMAL_EXEC,
2896 BT_8822B_1ANT_PHASE_2G_RUNTIME);
2897
2898 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
2899 4);
2900 }
2901
2902 /*
2903 if ((wifi_link) || (wifi_roam) || (coex_sta->wifi_is_high_pri_task)) {
2904
2905 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 33);
2906 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
2907
2908 } else if ((wifi_scan) && (coex_sta->bt_create_connection)) {
2909
2910 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
2911 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
2912
2913 } else if ((!wifi_connected) && (!wifi_scan)) {
2914
2915 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
2916
2917 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
2918 } else if ((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) {
2919
2920 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
2921 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2922
2923 } else if (bt_link_info->a2dp_exist) {
2924
2925 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
2926
2927 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2928 } else if (wifi_scan) {
2929
2930 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
2931
2932 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2933
2934 } else if (wifi_busy) {
2935 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 21);
2936
2937 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2938 } else {
2939 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 19);
2940
2941 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
2942 }
2943 */
2944 }
2945
halbtc8822b1ant_action_bt_sco_hid_only_busy(IN struct btc_coexist * btcoexist,IN u8 wifi_status)2946 void halbtc8822b1ant_action_bt_sco_hid_only_busy(IN struct btc_coexist
2947 *btcoexist, IN u8 wifi_status)
2948 {
2949
2950 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
2951
2952 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
2953
2954 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2955 "[BTCoex], ********** (bt sco hid only busy) **********\n");
2956 BTC_TRACE(trace_buf);
2957
2958 /*SCO + wifi connected idle or busy / 0x778=1@wifi slot*/
2959 if (bt_link_info->sco_exist) {
2960
2961 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
2962 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
2963 /*case16 for connect SCO first then connect a2sp fail issue*/
2964 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 16);
2965
2966 } else { /* HID + wifi connected idle or busy / 0x778=1@wifi slot */
2967
2968 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
2969
2970 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
2971 /*case16 for connect HID first then connect a2sp fail issue*/
2972 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 16);
2973
2974 }
2975 }
2976
2977 /*wifi connected + bt acl busy*/
halbtc8822b1ant_action_wifi_connected_bt_acl_busy(IN struct btc_coexist * btcoexist,IN u8 wifi_status)2978 void halbtc8822b1ant_action_wifi_connected_bt_acl_busy(IN struct btc_coexist
2979 *btcoexist, IN u8 wifi_status)
2980 {
2981
2982 u8 bt_rssi_state;
2983 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
2984 boolean wifi_busy = false, wifi_turbo = false;
2985 u32 wifi_bw = 1;
2986
2987 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW,
2988 &wifi_bw);
2989 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
2990 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM,
2991 &coex_sta->scan_ap_num);
2992 bt_rssi_state = halbtc8822b1ant_bt_rssi_state(2, 28, 0);
2993
2994 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
2995 "[BTCoex], ********** (wifi connect acl busy) **********\n");
2996 BTC_TRACE(trace_buf);
2997
2998
2999
3000 if (bt_link_info->hid_only) { /* HID + wifi connected idle or busy / 0x778=1@wifi slot */
3001
3002
3003
3004
3005 btcoexist->btc_write_1byte_bitmask(
3006 btcoexist, 0x45e, 0x8, 0x1);
3007
3008
3009
3010 halbtc8822b1ant_action_bt_sco_hid_only_busy(btcoexist,
3011 wifi_status);
3012 return;
3013 } else if (
3014 bt_link_info->a2dp_only) { /* A2DP + wifi connected idle or busy */
3015 if (BT_8822B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifi_status) {
3016
3017
3018 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e,
3019 0x8, 0x1);
3020
3021 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3022 32);
3023 halbtc8822b1ant_coex_table_with_type(btcoexist,
3024 NORMAL_EXEC, 0);
3025 } else {
3026 if (coex_sta->scan_ap_num >=
3027 BT_8822B_1ANT_WIFI_NOISY_THRESH) {
3028 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3029 true,
3030 17);
3031 } else {
3032
3033
3034
3035
3036 btcoexist->btc_write_1byte_bitmask(
3037 btcoexist, 0x45e, 0x8, 0x1);
3038
3039 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3040 true,
3041 42);
3042
3043 halbtc8822b1ant_coex_table_with_type(btcoexist,
3044 NORMAL_EXEC, 1);
3045 }
3046 /*
3047 halbtc8822b1ant_coex_table_with_type(btcoexist,
3048 NORMAL_EXEC, 1);
3049 */
3050 coex_dm->auto_tdma_adjust = true;
3051 }
3052
3053 /* A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) */
3054 } else if (((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) ||
3055 (bt_link_info->hid_exist && bt_link_info->a2dp_exist &&
3056 bt_link_info->pan_exist)) { /* A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) */
3057
3058 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
3059 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 47);
3060 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3061 6);
3062 } else if (bt_link_info->hid_exist &&
3063 bt_link_info->a2dp_exist) { /* HID+A2DP */
3064
3065 btcoexist->btc_write_1byte_bitmask(
3066 btcoexist, 0x45e, 0x8, 0x1);
3067 if (!wifi_busy) {
3068 /*a2dp glitch while wl idle , change the 0x6c0=5a5a5a5a->5555or aaaa55aa*/
3069 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3070 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3071 true,
3072 32);
3073 } else if (wifi_bw == 0) { /* 11bg mode */
3074 halbtc8822b1ant_coex_table_with_type(btcoexist,
3075 NORMAL_EXEC, 1);
3076
3077 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3078 true,
3079 42);
3080 } else {
3081 /*if in open space , and ask wl tp , 0x60=6135031111,55555555,aaaa55aa*/
3082 halbtc8822b1ant_coex_table_with_type(btcoexist,
3083 NORMAL_EXEC, 1);
3084 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 42);
3085 }
3086 /*
3087 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3088 1);
3089 */
3090
3091
3092
3093
3094 } else if ((bt_link_info->pan_only) || (bt_link_info->hid_exist &&
3095 bt_link_info->pan_exist)) { /* PAN(OPP,FTP), HID+PAN(OPP,FTP)*/
3096 /*
3097 if (BT_8723D_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifi_status)
3098 halbtc8723d1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3099 4);
3100 else
3101 */
3102
3103 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
3104 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 47);
3105 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3106 1);
3107 } else {
3108 /* BT no-profile busy (0x9) */
3109
3110 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x45e, 0x8, 0x1);
3111 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 33);
3112 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3113 1);
3114 }
3115 }
3116
3117 /*wifi not connected + bt action*/
halbtc8822b1ant_action_wifi_not_connected(IN struct btc_coexist * btcoexist)3118 void halbtc8822b1ant_action_wifi_not_connected(IN struct btc_coexist *btcoexist)
3119 {
3120 boolean wifi_under_5g = false, rf4ce_enabled = false;
3121
3122 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3123 "[BTCoex], ********** (wifi not connect) **********\n");
3124 BTC_TRACE(trace_buf);
3125
3126 /* tdma and coex table */
3127 if (rf4ce_enabled) {
3128 btcoexist->btc_write_1byte_bitmask(
3129 btcoexist, 0x45e, 0x8, 0x1);
3130
3131 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3132 true,
3133 50);
3134
3135 halbtc8822b1ant_coex_table_with_type(btcoexist,
3136 NORMAL_EXEC, 1);
3137 return;
3138 }
3139 halbtc8822b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
3140
3141 halbtc8822b1ant_set_ant_path(btcoexist,
3142 BTC_ANT_PATH_AUTO,
3143 NORMAL_EXEC,
3144 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3145
3146 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
3147 }
3148
3149 /*""""wl not connected scan"""" + bt action*/
halbtc8822b1ant_action_wifi_not_connected_scan(IN struct btc_coexist * btcoexist)3150 void halbtc8822b1ant_action_wifi_not_connected_scan(IN struct btc_coexist
3151 *btcoexist)
3152 {
3153
3154 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3155 boolean wifi_connected = false, bt_hs_on = false;
3156 u32 wifi_link_status = 0;
3157 u32 num_of_wifi_link = 0;
3158 boolean bt_ctrl_agg_buf_size = false;
3159 u8 agg_buf_size = 5;
3160
3161 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3162 "[BTCoex], ********** (wifi non connect scan) **********\n");
3163 BTC_TRACE(trace_buf);
3164
3165 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
3166 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
3167 &wifi_link_status);
3168
3169 num_of_wifi_link = wifi_link_status >> 16;
3170
3171 if (num_of_wifi_link >= 2) {
3172 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
3173 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
3174 bt_ctrl_agg_buf_size, agg_buf_size);
3175
3176 if (coex_sta->c2h_bt_inquiry_page) {
3177 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3178 "############# [BTCoex], BT Is Inquirying\n");
3179 BTC_TRACE(trace_buf);
3180 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3181 } else
3182 halbtc8822b1ant_action_wifi_multi_port(btcoexist);
3183 return;
3184 }
3185
3186 if (coex_sta->c2h_bt_inquiry_page) {
3187 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3188 return;
3189 } else if (bt_hs_on) {
3190 halbtc8822b1ant_action_hs(btcoexist);
3191 return;
3192 }
3193
3194 /* tdma and coex table */
3195 if (BT_8822B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
3196 if (bt_link_info->a2dp_exist) {
3197 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3198 32);
3199 halbtc8822b1ant_coex_table_with_type(btcoexist,
3200 NORMAL_EXEC, 1);
3201 } else if (bt_link_info->a2dp_exist &&
3202 bt_link_info->pan_exist) {
3203 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3204 22);
3205 halbtc8822b1ant_coex_table_with_type(btcoexist,
3206 NORMAL_EXEC, 1);
3207 } else {
3208 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3209 20);
3210 halbtc8822b1ant_coex_table_with_type(btcoexist,
3211 NORMAL_EXEC, 1);
3212 }
3213 } else if ((BT_8822B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
3214 (BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
3215 coex_dm->bt_status)) {
3216 halbtc8822b1ant_action_bt_sco_hid_only_busy(btcoexist,
3217 BT_8822B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
3218 } else {
3219
3220 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
3221
3222 halbtc8822b1ant_set_ant_path(btcoexist,
3223 BTC_ANT_PATH_AUTO,
3224 NORMAL_EXEC,
3225 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3226
3227 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3228 5);
3229 }
3230 }
3231
3232 /*""""wl not connected asso"""" + bt action*/
halbtc8822b1ant_action_wifi_not_connected_asso_auth(IN struct btc_coexist * btcoexist)3233 void halbtc8822b1ant_action_wifi_not_connected_asso_auth(
3234 IN struct btc_coexist *btcoexist)
3235 {
3236
3237 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3238 boolean wifi_connected = false, bt_hs_on = false;
3239 u32 wifi_link_status = 0;
3240 u32 num_of_wifi_link = 0;
3241 boolean bt_ctrl_agg_buf_size = false;
3242 u8 agg_buf_size = 5;
3243
3244 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3245 "[BTCoex], ********** (wifi non connect asso_auth) **********\n");
3246 BTC_TRACE(trace_buf);
3247
3248 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
3249 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
3250 &wifi_link_status);
3251
3252 num_of_wifi_link = wifi_link_status >> 16;
3253
3254 if (num_of_wifi_link >= 2) {
3255
3256 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
3257 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
3258 bt_ctrl_agg_buf_size,
3259 agg_buf_size);
3260
3261 if (coex_sta->c2h_bt_inquiry_page) {
3262 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3263 "############# [BTCoex], BT Is Inquirying\n");
3264 BTC_TRACE(trace_buf);
3265 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3266 } else
3267 halbtc8822b1ant_action_wifi_multi_port(
3268 btcoexist);
3269 return;
3270 }
3271
3272 if (coex_sta->c2h_bt_inquiry_page) {
3273 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3274 return;
3275 } else if (bt_hs_on) {
3276 halbtc8822b1ant_action_hs(btcoexist);
3277 return;
3278 }
3279
3280
3281 /* tdma and coex table */
3282 if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist) ||
3283 (bt_link_info->a2dp_exist)) {
3284
3285 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
3286 halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 4);
3287 } else if (bt_link_info->pan_exist) {
3288 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
3289 halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 4);
3290 } else {
3291
3292 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
3293
3294 halbtc8822b1ant_set_ant_path(btcoexist,
3295 BTC_ANT_PATH_AUTO,
3296 NORMAL_EXEC,
3297 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3298
3299 halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2);
3300 }
3301 }
3302
3303 /*""""wl connected scan"""" + bt action*/
halbtc8822b1ant_action_wifi_connected_scan(IN struct btc_coexist * btcoexist)3304 void halbtc8822b1ant_action_wifi_connected_scan(IN struct btc_coexist
3305 *btcoexist)
3306 {
3307
3308 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3309 boolean wifi_connected = false, bt_hs_on = false;
3310 u32 wifi_link_status = 0;
3311 u32 num_of_wifi_link = 0;
3312 boolean bt_ctrl_agg_buf_size = false;
3313 u8 agg_buf_size = 5;
3314
3315 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3316 "[BTCoex], ********** (wifi connect scan) **********\n");
3317 BTC_TRACE(trace_buf);
3318
3319 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
3320 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
3321 &wifi_link_status);
3322
3323 num_of_wifi_link = wifi_link_status >> 16;
3324
3325 if (num_of_wifi_link >= 2) {
3326 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
3327 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
3328 bt_ctrl_agg_buf_size, agg_buf_size);
3329
3330 if (coex_sta->c2h_bt_inquiry_page) {
3331 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3332 "############# [BTCoex], BT Is Inquirying\n");
3333 BTC_TRACE(trace_buf);
3334 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3335 } else
3336 halbtc8822b1ant_action_wifi_multi_port(btcoexist);
3337 return;
3338 }
3339
3340 if (coex_sta->c2h_bt_inquiry_page) {
3341 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3342 return;
3343 } else if (bt_hs_on) {
3344 halbtc8822b1ant_action_hs(btcoexist);
3345 return;
3346 }
3347
3348 /* tdma and coex table */
3349 if (BT_8822B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
3350 if (bt_link_info->a2dp_exist) {
3351 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3352 32);
3353 halbtc8822b1ant_coex_table_with_type(btcoexist,
3354 NORMAL_EXEC, 1);
3355 } else if (bt_link_info->a2dp_exist &&
3356 bt_link_info->pan_exist) {
3357 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3358 22);
3359 halbtc8822b1ant_coex_table_with_type(btcoexist,
3360 NORMAL_EXEC, 1);
3361 } else {
3362 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3363 20);
3364 halbtc8822b1ant_coex_table_with_type(btcoexist,
3365 NORMAL_EXEC, 1);
3366 }
3367 } else if ((BT_8822B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
3368 (BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
3369 coex_dm->bt_status)) {
3370 halbtc8822b1ant_action_bt_sco_hid_only_busy(btcoexist,
3371 BT_8822B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
3372 } else {
3373
3374 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
3375
3376 halbtc8822b1ant_set_ant_path(btcoexist,
3377 BTC_ANT_PATH_AUTO,
3378 NORMAL_EXEC,
3379 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3380
3381 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3382 6);
3383 }
3384 }
3385
3386 /*""""wl connected specific packet"""" + bt action*/
halbtc8822b1ant_action_wifi_connected_specific_packet(IN struct btc_coexist * btcoexist)3387 void halbtc8822b1ant_action_wifi_connected_specific_packet(
3388 IN struct btc_coexist *btcoexist)
3389 {
3390
3391 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3392 boolean wifi_connected = false, bt_hs_on = false;
3393 u32 wifi_link_status = 0;
3394 u32 num_of_wifi_link = 0;
3395 boolean bt_ctrl_agg_buf_size = false;
3396 u8 agg_buf_size = 5;
3397 boolean wifi_busy = false;
3398
3399 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3400 "[BTCoex], ********** (wifi connect specific packet) **********\n");
3401 BTC_TRACE(trace_buf);
3402
3403 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
3404 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
3405 &wifi_link_status);
3406
3407 num_of_wifi_link = wifi_link_status >> 16;
3408
3409 if (num_of_wifi_link >= 2) {
3410 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
3411 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
3412 bt_ctrl_agg_buf_size, agg_buf_size);
3413
3414 if (coex_sta->c2h_bt_inquiry_page) {
3415 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3416 "############# [BTCoex], BT Is Inquirying\n");
3417 BTC_TRACE(trace_buf);
3418 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3419 } else
3420 halbtc8822b1ant_action_wifi_multi_port(btcoexist);
3421 return;
3422 }
3423
3424 if (coex_sta->c2h_bt_inquiry_page) {
3425 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3426 return;
3427 } else if (bt_hs_on) {
3428 halbtc8822b1ant_action_hs(btcoexist);
3429 return;
3430 }
3431
3432
3433 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
3434
3435 /* no specific packet process for both WiFi and BT very busy */
3436 if ((wifi_busy) && ((bt_link_info->pan_exist) ||
3437 (coex_sta->num_of_profile >= 2)))
3438 return;
3439
3440 /* tdma and coex table */
3441 if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist)) {
3442 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
3443 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
3444 } else if (bt_link_info->a2dp_exist) {
3445 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
3446 /*for a2dp glitch,change from 1 to 15*/
3447 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3448 15);
3449 } else if (bt_link_info->pan_exist) {
3450 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
3451 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3452 1);
3453 } else {
3454
3455 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
3456
3457 halbtc8822b1ant_set_ant_path(btcoexist,
3458 BTC_ANT_PATH_AUTO,
3459 NORMAL_EXEC,
3460 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3461
3462 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
3463 5);
3464 }
3465 }
3466
3467 /*wifi connected input point : to set different ps and tdma case (+bt different case)*/
halbtc8822b1ant_action_wifi_connected(IN struct btc_coexist * btcoexist)3468 void halbtc8822b1ant_action_wifi_connected(IN struct btc_coexist *btcoexist)
3469 {
3470
3471 boolean wifi_busy = false, rf4ce_enabled = false;
3472 boolean scan = false, link = false, roam = false;
3473 boolean under_4way = false, ap_enable = false, wifi_under_5g = false;
3474 u8 wifi_rssi_state;
3475
3476
3477 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3478 "[BTCoex], CoexForWifiConnect()===>\n");
3479 BTC_TRACE(trace_buf);
3480
3481 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
3482
3483 if (wifi_under_5g) {
3484
3485 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3486 "[BTCoex], CoexForWifiConnect(), return for wifi is under 5g<===\n");
3487 BTC_TRACE(trace_buf);
3488
3489 halbtc8822b1ant_action_wifi_under5g(btcoexist);
3490
3491 return;
3492 }
3493
3494 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3495 "[BTCoex], CoexForWifiConnect(), return for wifi is under 2g<===\n");
3496 BTC_TRACE(trace_buf);
3497
3498 halbtc8822b1ant_set_ant_path(btcoexist,
3499 BTC_ANT_PATH_AUTO,
3500 NORMAL_EXEC,
3501 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3502
3503
3504 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
3505 &under_4way);
3506
3507 if (under_4way) {
3508 halbtc8822b1ant_action_wifi_connected_specific_packet(
3509 btcoexist);
3510 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3511 "[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n");
3512 BTC_TRACE(trace_buf);
3513 return;
3514 }
3515
3516 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
3517 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
3518 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
3519 if (scan || link || roam) {
3520 if (scan)
3521 halbtc8822b1ant_action_wifi_connected_scan(btcoexist);
3522 else
3523 halbtc8822b1ant_action_wifi_connected_specific_packet(
3524 btcoexist);
3525 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3526 "[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n");
3527 BTC_TRACE(trace_buf);
3528 return;
3529 }
3530
3531 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
3532 &ap_enable);
3533 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
3534
3535 /* tdma and coex table */
3536 if (!wifi_busy) {
3537 if (BT_8822B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
3538 halbtc8822b1ant_action_wifi_connected_bt_acl_busy(
3539 btcoexist,
3540 BT_8822B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
3541 } else if ((BT_8822B_1ANT_BT_STATUS_SCO_BUSY ==
3542 coex_dm->bt_status) ||
3543 (BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
3544 coex_dm->bt_status)) {
3545 halbtc8822b1ant_action_bt_sco_hid_only_busy(btcoexist,
3546 BT_8822B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
3547 } else {
3548
3549 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
3550 8);
3551
3552 halbtc8822b1ant_set_ant_path(btcoexist,
3553 BTC_ANT_PATH_AUTO,
3554 NORMAL_EXEC,
3555 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3556
3557 if ((coex_sta->high_priority_tx) +
3558 (coex_sta->high_priority_rx) <= 60)
3559 /*sy modify case16 -> case17*/
3560 halbtc8822b1ant_coex_table_with_type(btcoexist,
3561 NORMAL_EXEC, 1);
3562 else
3563 halbtc8822b1ant_coex_table_with_type(btcoexist,
3564 NORMAL_EXEC, 1);
3565 }
3566 } else {
3567 if (BT_8822B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
3568 halbtc8822b1ant_action_wifi_connected_bt_acl_busy(
3569 btcoexist,
3570 BT_8822B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
3571 } else if ((BT_8822B_1ANT_BT_STATUS_SCO_BUSY ==
3572 coex_dm->bt_status) ||
3573 (BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
3574 coex_dm->bt_status)) {
3575 halbtc8822b1ant_action_bt_sco_hid_only_busy(btcoexist,
3576 BT_8822B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
3577 } else {
3578 if (rf4ce_enabled) {
3579 btcoexist->btc_write_1byte_bitmask(
3580 btcoexist, 0x45e, 0x8, 0x1);
3581
3582 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3583 true,
3584 50);
3585
3586 halbtc8822b1ant_coex_table_with_type(btcoexist,
3587 NORMAL_EXEC, 1);
3588 return;
3589 }
3590
3591
3592
3593 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
3594 8);
3595
3596 halbtc8822b1ant_set_ant_path(btcoexist,
3597 BTC_ANT_PATH_AUTO,
3598 NORMAL_EXEC,
3599 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3600
3601 /*
3602
3603 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
3604 32);
3605
3606 halbtc8822b1ant_set_ant_path(btcoexist,
3607 BTC_ANT_PATH_AUTO, NORMAL_EXEC, BT_8822B_1ANT_PHASE_2G_RUNTIME);
3608 */
3609
3610
3611
3612 wifi_rssi_state = halbtc8822b1ant_wifi_rssi_state(
3613 btcoexist, 1, 2, 25, 0);
3614
3615 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3616 "[BTCoex], ********** before **********\n");
3617 BTC_TRACE(trace_buf);
3618 /*
3619 if ((BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
3620 coex_dm->bt_status) &&
3621 (coex_sta->scan_ap_num <= 3) &&
3622 (wifi_rssi_state == BTC_RSSI_STATE_LOW ||
3623 wifi_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
3624 */
3625 if (BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
3626 coex_dm->bt_status) {
3627 if (rf4ce_enabled) {
3628 btcoexist->btc_write_1byte_bitmask(
3629 btcoexist, 0x45e, 0x8, 0x1);
3630
3631 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
3632 true,
3633 50);
3634
3635 halbtc8822b1ant_coex_table_with_type(btcoexist,
3636 NORMAL_EXEC, 1);
3637 return;
3638 }
3639
3640
3641 halbtc8822b1ant_coex_table_with_type(btcoexist,
3642 NORMAL_EXEC, 7);
3643 } else
3644
3645 halbtc8822b1ant_coex_table_with_type(btcoexist,
3646 NORMAL_EXEC, 1);
3647
3648
3649
3650 /*
3651 else if ((coex_sta->high_priority_tx +
3652 coex_sta->high_priority_rx) <= 60)
3653 halbtc8822b1ant_coex_table_with_type(btcoexist,
3654 NORMAL_EXEC, 1);
3655 else
3656 halbtc8822b1ant_coex_table_with_type(btcoexist,
3657 NORMAL_EXEC, 4);
3658 */
3659 }
3660 }
3661 }
3662
halbtc8822b1ant_run_sw_coexist_mechanism(IN struct btc_coexist * btcoexist)3663 void halbtc8822b1ant_run_sw_coexist_mechanism(IN struct btc_coexist *btcoexist)
3664 {
3665
3666 u8 algorithm = 0;
3667
3668 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3669 "[BTCoex], ********** (runswcoexmech) **********\n");
3670 BTC_TRACE(trace_buf);
3671 algorithm = halbtc8822b1ant_action_algorithm(btcoexist);
3672 coex_dm->cur_algorithm = algorithm;
3673
3674 if (halbtc8822b1ant_is_common_action(btcoexist)) {
3675
3676 } else {
3677 switch (coex_dm->cur_algorithm) {
3678 case BT_8822B_1ANT_COEX_ALGO_SCO:
3679 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3680 "[BTCoex], Action algorithm = SCO.\n");
3681 BTC_TRACE(trace_buf);
3682 /* halbtc8822b1ant_action_sco(btcoexist); */
3683 break;
3684 case BT_8822B_1ANT_COEX_ALGO_HID:
3685 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3686 "[BTCoex], Action algorithm = HID.\n");
3687 BTC_TRACE(trace_buf);
3688 /* halbtc8822b1ant_action_hid(btcoexist); */
3689 break;
3690 case BT_8822B_1ANT_COEX_ALGO_A2DP:
3691 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3692 "[BTCoex], Action algorithm = A2DP.\n");
3693 BTC_TRACE(trace_buf);
3694 /* halbtc8822b1ant_action_a2dp(btcoexist); */
3695 break;
3696 case BT_8822B_1ANT_COEX_ALGO_A2DP_PANHS:
3697 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3698 "[BTCoex], Action algorithm = A2DP+PAN(HS).\n");
3699 BTC_TRACE(trace_buf);
3700 /* halbtc8822b1ant_action_a2dp_pan_hs(btcoexist); */
3701 break;
3702 case BT_8822B_1ANT_COEX_ALGO_PANEDR:
3703 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3704 "[BTCoex], Action algorithm = PAN(EDR).\n");
3705 BTC_TRACE(trace_buf);
3706 /* halbtc8822b1ant_action_pan_edr(btcoexist); */
3707 break;
3708 case BT_8822B_1ANT_COEX_ALGO_PANHS:
3709 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3710 "[BTCoex], Action algorithm = HS mode.\n");
3711 BTC_TRACE(trace_buf);
3712 /* halbtc8822b1ant_action_pan_hs(btcoexist); */
3713 break;
3714 case BT_8822B_1ANT_COEX_ALGO_PANEDR_A2DP:
3715 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3716 "[BTCoex], Action algorithm = PAN+A2DP.\n");
3717 BTC_TRACE(trace_buf);
3718 /* halbtc8822b1ant_action_pan_edr_a2dp(btcoexist); */
3719 break;
3720 case BT_8822B_1ANT_COEX_ALGO_PANEDR_HID:
3721 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3722 "[BTCoex], Action algorithm = PAN(EDR)+HID.\n");
3723 BTC_TRACE(trace_buf);
3724 /* halbtc8822b1ant_action_pan_edr_hid(btcoexist); */
3725 break;
3726 case BT_8822B_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
3727 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3728 "[BTCoex], Action algorithm = HID+A2DP+PAN.\n");
3729 BTC_TRACE(trace_buf);
3730 /* halbtc8822b1ant_action_hid_a2dp_pan_edr(btcoexist); */
3731 break;
3732 case BT_8822B_1ANT_COEX_ALGO_HID_A2DP:
3733 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3734 "[BTCoex], Action algorithm = HID+A2DP.\n");
3735 BTC_TRACE(trace_buf);
3736 /* halbtc8822b1ant_action_hid_a2dp(btcoexist); */
3737 break;
3738 default:
3739 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3740 "[BTCoex], Action algorithm = coexist All Off!!\n");
3741 BTC_TRACE(trace_buf);
3742 /* halbtc8822b1ant_coex_all_off(btcoexist); */
3743 break;
3744 }
3745 coex_dm->pre_algorithm = coex_dm->cur_algorithm;
3746 }
3747 }
3748
halbtc8822b1ant_run_coexist_mechanism(IN struct btc_coexist * btcoexist)3749 void halbtc8822b1ant_run_coexist_mechanism(IN struct btc_coexist *btcoexist)
3750 {
3751
3752 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
3753 boolean wifi_connected = false, bt_hs_on = false;
3754 boolean increase_scan_dev_num = false;
3755 boolean bt_ctrl_agg_buf_size = false;
3756 boolean miracast_plus_bt = false;
3757 u8 agg_buf_size = 5;
3758 u32 wifi_link_status = 0;
3759 u32 num_of_wifi_link = 0, wifi_bw;
3760 u8 iot_peer = BTC_IOT_PEER_UNKNOWN;
3761 boolean wifi_under_5g = false;
3762
3763
3764 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3765 "[BTCoex], RunCoexistMechanism()===>\n");
3766 BTC_TRACE(trace_buf);
3767
3768 if (btcoexist->manual_control) {
3769 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3770 "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n");
3771 BTC_TRACE(trace_buf);
3772 return;
3773 }
3774
3775 if (btcoexist->stop_coex_dm) {
3776 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3777 "[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n");
3778 BTC_TRACE(trace_buf);
3779 return;
3780 }
3781
3782
3783
3784 if (coex_sta->under_ips) {
3785 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3786 "[BTCoex], wifi is under IPS !!!\n");
3787 BTC_TRACE(trace_buf);
3788 return;
3789 }
3790
3791 if (!coex_sta->run_time_state) {
3792 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3793 "[BTCoex], return for run_time_state = false !!!\n");
3794 BTC_TRACE(trace_buf);
3795 return;
3796 }
3797
3798 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
3799 if (wifi_under_5g) {
3800 halbtc8822b1ant_action_wifi_under5g(btcoexist);
3801
3802 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3803 "[BTCoex], WiFi is under 5G!!!\n");
3804 BTC_TRACE(trace_buf);
3805 return;
3806 }
3807
3808 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3809 "[BTCoex], WiFi is under 2G!!!\n");
3810 BTC_TRACE(trace_buf);
3811
3812 halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO,
3813 NORMAL_EXEC,
3814 BT_8822B_1ANT_PHASE_2G_RUNTIME);
3815
3816 if (coex_sta->bt_whck_test) {
3817 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3818 "[BTCoex], BT is under WHCK TEST!!!\n");
3819 BTC_TRACE(trace_buf);
3820 halbtc8822b1ant_action_bt_whck_test(btcoexist);
3821 return;
3822 }
3823
3824 if (coex_sta->bt_disabled) {
3825 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3826 "[BTCoex], BT is disabled !!!\n");
3827 halbtc8822b1ant_action_wifi_only(btcoexist);
3828 return;
3829 }
3830
3831 if ((BT_8822B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
3832 (BT_8822B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
3833 (BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status))
3834 increase_scan_dev_num = true;
3835
3836 btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM,
3837 &increase_scan_dev_num);
3838 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
3839 &wifi_connected);
3840
3841 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
3842 &wifi_link_status);
3843 num_of_wifi_link = wifi_link_status >> 16;
3844
3845 if ((num_of_wifi_link >= 2) ||
3846 (wifi_link_status & WIFI_P2P_GO_CONNECTED)) {
3847 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3848 "############# [BTCoex], Multi-Port num_of_wifi_link = %d, wifi_link_status = 0x%x\n",
3849 num_of_wifi_link, wifi_link_status);
3850 BTC_TRACE(trace_buf);
3851
3852 if (bt_link_info->bt_link_exist) {
3853 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 1,
3854 0, 1);
3855 miracast_plus_bt = true;
3856 } else {
3857 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0,
3858 0, 0);
3859 miracast_plus_bt = false;
3860 }
3861 btcoexist->btc_set(btcoexist, BTC_SET_BL_MIRACAST_PLUS_BT,
3862 &miracast_plus_bt);
3863 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
3864 bt_ctrl_agg_buf_size, agg_buf_size);
3865
3866 if ((bt_link_info->a2dp_exist) &&
3867 (coex_sta->c2h_bt_inquiry_page)) {
3868 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3869 "############# [BTCoex], BT Is Inquirying\n");
3870 BTC_TRACE(trace_buf);
3871 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3872 } else
3873 halbtc8822b1ant_action_wifi_multi_port(btcoexist);
3874
3875 return;
3876 }
3877
3878 miracast_plus_bt = false;
3879 btcoexist->btc_set(btcoexist, BTC_SET_BL_MIRACAST_PLUS_BT,
3880 &miracast_plus_bt);
3881
3882 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
3883
3884 if ((bt_link_info->bt_link_exist) && (wifi_connected)) {
3885 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 1, 0, 1);
3886
3887 btcoexist->btc_get(btcoexist, BTC_GET_U1_IOT_PEER, &iot_peer);
3888
3889 if (BTC_IOT_PEER_CISCO != iot_peer) {
3890 if (bt_link_info->sco_exist) /* if (bt_link_info->bt_hi_pri_link_exist) */
3891 halbtc8822b1ant_limited_rx(btcoexist,
3892 NORMAL_EXEC, true, false, 0x5);
3893 else
3894 halbtc8822b1ant_limited_rx(btcoexist,
3895 NORMAL_EXEC, false, false, 0x5);
3896 } else {
3897 if (bt_link_info->sco_exist)
3898 halbtc8822b1ant_limited_rx(btcoexist,
3899 NORMAL_EXEC, true, false, 0x5);
3900 else {
3901 if (BTC_WIFI_BW_HT40 == wifi_bw)
3902 halbtc8822b1ant_limited_rx(btcoexist,
3903 NORMAL_EXEC, false, true, 0x10);
3904 else
3905 halbtc8822b1ant_limited_rx(btcoexist,
3906 NORMAL_EXEC, false, true, 0x8);
3907 }
3908 }
3909
3910 halbtc8822b1ant_sw_mechanism(btcoexist, true);
3911 halbtc8822b1ant_run_sw_coexist_mechanism(
3912 btcoexist); /* just print debug message */
3913 } else {
3914 halbtc8822b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
3915
3916 halbtc8822b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
3917 0x5);
3918
3919 halbtc8822b1ant_sw_mechanism(btcoexist, false);
3920 halbtc8822b1ant_run_sw_coexist_mechanism(
3921 btcoexist); /* just print debug message */
3922 }
3923
3924 btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
3925 if (coex_sta->c2h_bt_inquiry_page) {
3926 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3927 "############# [BTCoex], BT Is Inquirying\n");
3928 BTC_TRACE(trace_buf);
3929 halbtc8822b1ant_action_bt_inquiry(btcoexist);
3930 return;
3931 } else if (bt_hs_on) {
3932 halbtc8822b1ant_action_hs(btcoexist);
3933 return;
3934 }
3935
3936
3937 if (!wifi_connected) {
3938 boolean scan = false, link = false, roam = false;
3939
3940 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
3941 "[BTCoex], wifi is non connected-idle !!!\n");
3942 BTC_TRACE(trace_buf);
3943
3944 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
3945 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
3946 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
3947
3948 if (scan || link || roam) {
3949 if (scan)
3950 halbtc8822b1ant_action_wifi_not_connected_scan(
3951 btcoexist);
3952 else
3953 halbtc8822b1ant_action_wifi_not_connected_asso_auth(
3954 btcoexist);
3955 } else
3956 halbtc8822b1ant_action_wifi_not_connected(btcoexist);
3957 } else /* wifi LPS/Busy */
3958 halbtc8822b1ant_action_wifi_connected(btcoexist);
3959 }
3960
halbtc8822b1ant_psd_log2base(IN struct btc_coexist * btcoexist,IN u32 val)3961 u32 halbtc8822b1ant_psd_log2base(IN struct btc_coexist *btcoexist, IN u32 val)
3962 {
3963 u8 j;
3964 u32 tmp, tmp2, val_integerd_b = 0, tindex, shiftcount = 0;
3965 u32 result, val_fractiond_b = 0, table_fraction[21] = {0, 432, 332, 274, 232, 200,
3966 174, 151, 132, 115, 100, 86, 74, 62, 51, 42,
3967 32, 23, 15, 7, 0
3968 };
3969
3970 if (val == 0)
3971 return 0;
3972
3973 tmp = val;
3974
3975 while (1) {
3976 if (tmp == 1)
3977 break;
3978
3979 tmp = (tmp >> 1);
3980 shiftcount++;
3981 }
3982
3983
3984 val_integerd_b = shiftcount + 1;
3985
3986 tmp2 = 1;
3987 for (j = 1; j <= val_integerd_b; j++)
3988 tmp2 = tmp2 * 2;
3989
3990 tmp = (val * 100) / tmp2;
3991 tindex = tmp / 5;
3992
3993 if (tindex > 20)
3994 tindex = 20;
3995
3996 val_fractiond_b = table_fraction[tindex];
3997
3998 result = val_integerd_b * 100 - val_fractiond_b;
3999
4000 return result;
4001
4002
4003 }
4004
halbtc8822b1ant_init_coex_dm(IN struct btc_coexist * btcoexist)4005 void halbtc8822b1ant_init_coex_dm(IN struct btc_coexist *btcoexist)
4006 {
4007 /* force to reset coex mechanism */
4008
4009 halbtc8822b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, false);
4010
4011 /* sw all off */
4012 halbtc8822b1ant_sw_mechanism(btcoexist, false);
4013
4014 /* halbtc8822b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); */
4015 /* halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); */
4016
4017 coex_sta->pop_event_cnt = 0;
4018 }
4019
halbtc8822b1ant_init_hw_config(IN struct btc_coexist * btcoexist,IN boolean back_up,IN boolean wifi_only)4020 void halbtc8822b1ant_init_hw_config(IN struct btc_coexist *btcoexist,
4021 IN boolean back_up, IN boolean wifi_only)
4022 {
4023
4024 u8 u8tmp = 0;
4025 boolean wifi_under_5g = false;
4026 u32 u32tmp1 = 0, u32tmp2 = 0, u32tmp3 = 0;
4027
4028
4029 u32tmp3 = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
4030 u32tmp1 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x38);
4031 u32tmp2 = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x54);
4032
4033 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4034 "[BTCoex], ********** (Before Init HW config) 0xcb4 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n",
4035 u32tmp3, u32tmp1, u32tmp2);
4036 BTC_TRACE(trace_buf);
4037
4038 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4039 "[BTCoex], 1Ant Init HW Config!!\n");
4040 BTC_TRACE(trace_buf);
4041
4042 coex_sta->bt_coex_supported_feature = 0;
4043 coex_sta->bt_coex_supported_version = 0;
4044
4045 /* Setup RF front end type */
4046 halbtc8822b1ant_set_rfe_type(btcoexist);
4047
4048 /* 0xf0[15:12] --> Chip Cut information */
4049 coex_sta->cut_version = (btcoexist->btc_read_1byte(btcoexist,
4050 0xf1) & 0xf0) >> 4;
4051
4052 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x550, 0x8,
4053 0x1); /* enable TBTT nterrupt */
4054
4055 /* BT report packet sample rate */
4056 /* 0x790[5:0]=0x5 */
4057 u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
4058 u8tmp &= 0xc0;
4059 u8tmp |= 0x5;
4060 btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp);
4061
4062 /* Enable BT counter statistics */
4063 btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1);
4064
4065 /* Enable PTA (3-wire function form BT side) */
4066 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
4067 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x41, 0x02, 0x1);
4068
4069 /* Enable PTA (tx/rx signal form WiFi side) */
4070 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4c6, 0x10, 0x1);
4071 /*GNT_BT=1 while select both */
4072 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x763, 0x10, 0x1);
4073
4074 /* enable GNT_WL/GNT_BT debug signal to GPIO14/15 */
4075 /*btcoexist->btc_write_1byte_bitmask(btcoexist, 0x73, 0x8, 0x1);*/
4076
4077 /* enable GNT_WL */
4078 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e, 0x40, 0x0);
4079 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x1, 0x0);
4080
4081 if (btcoexist->btc_read_1byte(btcoexist, 0x80) == 0xc6)
4082 halbtc8822b1ant_post_state_to_bt(btcoexist,
4083 BT_8822B_1ANT_SCOREBOARD_ONOFF, true);
4084
4085 /* Antenna config */
4086 if (wifi_only) {
4087
4088 coex_sta->concurrent_rx_mode_on = false;
4089 halbtc8822b1ant_set_ant_path(btcoexist,
4090 BTC_ANT_PATH_WIFI,
4091 FORCE_EXEC,
4092 BT_8822B_1ANT_PHASE_WLANONLY_INIT);
4093 } else {
4094
4095 coex_sta->concurrent_rx_mode_on = true;
4096
4097 halbtc8822b1ant_set_ant_path(btcoexist,
4098 BTC_ANT_PATH_AUTO,
4099 FORCE_EXEC,
4100 BT_8822B_1ANT_PHASE_COEX_INIT);
4101 }
4102
4103
4104 /* PTA parameter */
4105 halbtc8822b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
4106
4107 halbtc8822b1ant_enable_gnt_to_gpio(btcoexist, true);
4108
4109 }
4110
4111
halbtc8822b1ant_init_hw_config_without_bt(IN struct btc_coexist * btcoexist,IN boolean back_up,IN boolean wifi_only)4112 void halbtc8822b1ant_init_hw_config_without_bt(IN struct btc_coexist *btcoexist,
4113 IN boolean back_up, IN boolean wifi_only)
4114 {
4115
4116 u8 u8tmp = 0;
4117 boolean wifi_under_5g = false;
4118 u32 u32tmp1 = 0, u32tmp2 = 0, u32tmp3 = 0;
4119
4120
4121 /* 0xf0[15:12] --> Chip Cut information */
4122 coex_sta->cut_version = (btcoexist->btc_read_1byte(btcoexist,
4123 0xf1) & 0xf0) >> 4;
4124
4125 /* enable TBTT interrupt */
4126 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x550, 0x8,
4127 0x1);
4128
4129 /* enable GNT_WL */
4130 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e, 0x40, 0x0);
4131 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x1, 0x0);
4132
4133 /* Antenna config */
4134 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e, 0x80,
4135 0x0); /* 0x4c[23] = 0 */
4136 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4f, 0x01,
4137 0x1); /* 0x4c[24] = 1 */
4138 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb4, 0xff,
4139 0x77); /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as conctrol pin */
4140
4141
4142 /* Ext switch buffer mux */
4143 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
4144 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991, 0x3, 0x0);
4145 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe, 0x8, 0x0);
4146
4147 /*enable sw control gnt_wl=1 / gnt_bt=1 */
4148 btcoexist->btc_write_1byte(btcoexist, 0x73, 0x0e);
4149
4150 btcoexist->btc_write_4byte(btcoexist, 0x1704, 0x0000ff00);
4151
4152 btcoexist->btc_write_4byte(btcoexist, 0x1700, 0xc00f0038);
4153
4154
4155 /* ant switch WL2G or WL5G*/
4156 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G,
4157 &wifi_under_5g);
4158 if (wifi_under_5g)
4159
4160 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
4161 0x3, 1);
4162
4163 else
4164
4165 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
4166 0x3, 2);
4167
4168 }
4169
halbtc8822b1ant_psd_showdata(IN struct btc_coexist * btcoexist)4170 void halbtc8822b1ant_psd_showdata(IN struct btc_coexist *btcoexist)
4171 {
4172 u8 *cli_buf = btcoexist->cli_buf;
4173 u32 delta_freq_per_point;
4174 u32 freq, freq1, freq2, n = 0, i = 0, j = 0, m = 0, psd_rep1, psd_rep2;
4175
4176 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4177 "\r\n\n============[PSD info] (%d)============\n",
4178 psd_scan->psd_gen_count);
4179 CL_PRINTF(cli_buf);
4180
4181 if (psd_scan->psd_gen_count == 0) {
4182 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n No data !!\n");
4183 CL_PRINTF(cli_buf);
4184 return;
4185 }
4186
4187 if (psd_scan->psd_point == 0)
4188 delta_freq_per_point = 0;
4189 else
4190 delta_freq_per_point = psd_scan->psd_band_width /
4191 psd_scan->psd_point;
4192
4193 /* if (psd_scan->is_psd_show_max_only) */
4194 if (0) {
4195 psd_rep1 = psd_scan->psd_max_value / 100;
4196 psd_rep2 = psd_scan->psd_max_value - psd_rep1 * 100;
4197
4198 freq = ((psd_scan->real_cent_freq - 20) * 1000000 +
4199 psd_scan->psd_max_value_point * delta_freq_per_point);
4200 freq1 = freq / 1000000;
4201 freq2 = freq / 1000 - freq1 * 1000;
4202
4203 if (freq2 < 100)
4204 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4205 "\r\n Freq = %d.0%d MHz",
4206 freq1, freq2);
4207 else
4208 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4209 "\r\n Freq = %d.%d MHz",
4210 freq1, freq2);
4211
4212 if (psd_rep2 < 10)
4213 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4214 ", Value = %d.0%d dB, (%d)\n",
4215 psd_rep1, psd_rep2, psd_scan->psd_max_value);
4216 else
4217 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4218 ", Value = %d.%d dB, (%d)\n",
4219 psd_rep1, psd_rep2, psd_scan->psd_max_value);
4220
4221 CL_PRINTF(cli_buf);
4222 } else {
4223 m = psd_scan->psd_start_point;
4224 n = psd_scan->psd_start_point;
4225 i = 1;
4226 j = 1;
4227
4228 while (1) {
4229 do {
4230 freq = ((psd_scan->real_cent_freq - 20) *
4231 1000000 + m *
4232 delta_freq_per_point);
4233 freq1 = freq / 1000000;
4234 freq2 = freq / 1000 - freq1 * 1000;
4235
4236 if (i == 1) {
4237 if (freq2 == 0)
4238 CL_SPRINTF(cli_buf,
4239 BT_TMP_BUF_SIZE,
4240 "\r\n Freq%6d.000",
4241 freq1);
4242 else if (freq2 < 100)
4243 CL_SPRINTF(cli_buf,
4244 BT_TMP_BUF_SIZE,
4245 "\r\n Freq%6d.0%2d",
4246 freq1,
4247 freq2);
4248 else
4249 CL_SPRINTF(cli_buf,
4250 BT_TMP_BUF_SIZE,
4251 "\r\n Freq%6d.%3d",
4252 freq1,
4253 freq2);
4254 } else if ((i % 8 == 0) ||
4255 (m == psd_scan->psd_stop_point)) {
4256 if (freq2 == 0)
4257 CL_SPRINTF(cli_buf,
4258 BT_TMP_BUF_SIZE,
4259 "%6d.000\n", freq1);
4260 else if (freq2 < 100)
4261 CL_SPRINTF(cli_buf,
4262 BT_TMP_BUF_SIZE,
4263 "%6d.0%2d\n", freq1,
4264 freq2);
4265 else
4266 CL_SPRINTF(cli_buf,
4267 BT_TMP_BUF_SIZE,
4268 "%6d.%3d\n", freq1,
4269 freq2);
4270 } else {
4271 if (freq2 == 0)
4272 CL_SPRINTF(cli_buf,
4273 BT_TMP_BUF_SIZE,
4274 "%6d.000", freq1);
4275 else if (freq2 < 100)
4276 CL_SPRINTF(cli_buf,
4277 BT_TMP_BUF_SIZE,
4278 "%6d.0%2d", freq1,
4279 freq2);
4280 else
4281 CL_SPRINTF(cli_buf,
4282 BT_TMP_BUF_SIZE,
4283 "%6d.%3d", freq1,
4284 freq2);
4285 }
4286
4287 i++;
4288 m++;
4289 CL_PRINTF(cli_buf);
4290
4291 } while ((i <= 8) && (m <= psd_scan->psd_stop_point));
4292
4293
4294 do {
4295 psd_rep1 = psd_scan->psd_report_max_hold[n] /
4296 100;
4297 psd_rep2 = psd_scan->psd_report_max_hold[n] -
4298 psd_rep1 *
4299 100;
4300
4301 if (j == 1) {
4302 if (psd_rep2 < 10)
4303 CL_SPRINTF(cli_buf,
4304 BT_TMP_BUF_SIZE,
4305 "\r\n Val %7d.0%d",
4306 psd_rep1,
4307 psd_rep2);
4308 else
4309 CL_SPRINTF(cli_buf,
4310 BT_TMP_BUF_SIZE,
4311 "\r\n Val %7d.%d",
4312 psd_rep1,
4313 psd_rep2);
4314 } else if ((j % 8 == 0) ||
4315 (n == psd_scan->psd_stop_point)) {
4316 if (psd_rep2 < 10)
4317 CL_SPRINTF(cli_buf,
4318 BT_TMP_BUF_SIZE,
4319 "%7d.0%d\n", psd_rep1,
4320 psd_rep2);
4321 else
4322 CL_SPRINTF(cli_buf,
4323 BT_TMP_BUF_SIZE,
4324 "%7d.%d\n", psd_rep1,
4325 psd_rep2);
4326 } else {
4327 if (psd_rep2 < 10)
4328 CL_SPRINTF(cli_buf,
4329 BT_TMP_BUF_SIZE,
4330 "%7d.0%d", psd_rep1,
4331 psd_rep2);
4332 else
4333 CL_SPRINTF(cli_buf,
4334 BT_TMP_BUF_SIZE,
4335 "%7d.%d", psd_rep1,
4336 psd_rep2);
4337 }
4338
4339 j++;
4340 n++;
4341 CL_PRINTF(cli_buf);
4342
4343 } while ((j <= 8) && (n <= psd_scan->psd_stop_point));
4344
4345 if ((m > psd_scan->psd_stop_point) ||
4346 (n > psd_scan->psd_stop_point))
4347 break;
4348
4349 i = 1;
4350 j = 1;
4351
4352 }
4353 }
4354
4355
4356 }
4357
halbtc8822b1ant_psd_max_holddata(IN struct btc_coexist * btcoexist,IN u32 gen_count)4358 void halbtc8822b1ant_psd_max_holddata(IN struct btc_coexist *btcoexist,
4359 IN u32 gen_count)
4360 {
4361 u32 i = 0, i_max = 0, val_max = 0;
4362
4363 if (gen_count == 1) {
4364 memcpy(psd_scan->psd_report_max_hold,
4365 psd_scan->psd_report,
4366 BT_8822B_1ANT_ANTDET_PSD_POINTS * sizeof(u32));
4367
4368 for (i = psd_scan->psd_start_point;
4369 i <= psd_scan->psd_stop_point; i++) {
4370
4371 }
4372
4373 psd_scan->psd_max_value_point = 0;
4374 psd_scan->psd_max_value = 0;
4375
4376 } else {
4377 for (i = psd_scan->psd_start_point;
4378 i <= psd_scan->psd_stop_point; i++) {
4379 if (psd_scan->psd_report[i] >
4380 psd_scan->psd_report_max_hold[i])
4381 psd_scan->psd_report_max_hold[i] =
4382 psd_scan->psd_report[i];
4383
4384 /* search Max Value */
4385 if (i == psd_scan->psd_start_point) {
4386 i_max = i;
4387 val_max = psd_scan->psd_report_max_hold[i];
4388 } else {
4389 if (psd_scan->psd_report_max_hold[i] >
4390 val_max) {
4391 i_max = i;
4392 val_max = psd_scan->psd_report_max_hold[i];
4393 }
4394 }
4395
4396
4397
4398 }
4399
4400 psd_scan->psd_max_value_point = i_max;
4401 psd_scan->psd_max_value = val_max;
4402
4403 }
4404
4405
4406 }
4407
halbtc8822b1ant_psd_getdata(IN struct btc_coexist * btcoexist,IN u32 point)4408 u32 halbtc8822b1ant_psd_getdata(IN struct btc_coexist *btcoexist, IN u32 point)
4409 {
4410 /* reg 0x808[9:0]: FFT data x */
4411 /* reg 0x808[22]: 0-->1 to get 1 FFT data y */
4412 /* reg 0x8b4[15:0]: FFT data y report */
4413
4414 u32 val = 0, psd_report = 0;
4415
4416 val = btcoexist->btc_read_4byte(btcoexist, 0x808);
4417
4418 val &= 0xffbffc00;
4419 val |= point;
4420
4421 btcoexist->btc_write_4byte(btcoexist, 0x808, val);
4422
4423 val |= 0x00400000;
4424 btcoexist->btc_write_4byte(btcoexist, 0x808, val);
4425
4426
4427 val = btcoexist->btc_read_4byte(btcoexist, 0x8b4);
4428
4429 psd_report = val & 0x0000ffff;
4430
4431 return psd_report;
4432 }
4433
4434
halbtc8822b1ant_psd_sweep_point(IN struct btc_coexist * btcoexist,IN u32 cent_freq,IN s32 offset,IN u32 span,IN u32 points,IN u32 avgnum)4435 void halbtc8822b1ant_psd_sweep_point(IN struct btc_coexist *btcoexist,
4436 IN u32 cent_freq, IN s32 offset, IN u32 span, IN u32 points,
4437 IN u32 avgnum)
4438 {
4439 u32 i, val, n, k = 0;
4440 u32 points1 = 0, psd_report = 0;
4441 u32 start_p = 0, stop_p = 0, delta_freq_per_point = 156250;
4442 u32 psd_center_freq = 20 * 10 ^ 6, freq, freq1, freq2;
4443 boolean outloop = false;
4444 u8 flag = 0;
4445 u32 tmp, psd_rep1, psd_rep2;
4446 u32 wifi_original_channel = 1;
4447
4448 psd_scan->is_psd_running = true;
4449
4450 do {
4451 switch (flag) {
4452 case 0: /* Get PSD parameters */
4453 default:
4454
4455 psd_scan->psd_band_width = 40 * 1000000;
4456 psd_scan->psd_point = points;
4457 psd_scan->psd_start_base = points / 2;
4458 psd_scan->psd_avg_num = avgnum;
4459 psd_scan->real_cent_freq = cent_freq;
4460 psd_scan->real_offset = offset;
4461 psd_scan->real_span = span;
4462
4463
4464 points1 = psd_scan->psd_point;
4465 delta_freq_per_point = psd_scan->psd_band_width /
4466 psd_scan->psd_point;
4467
4468 /* PSD point setup */
4469 val = btcoexist->btc_read_4byte(btcoexist, 0x808);
4470 val &= 0xffff0fff;
4471
4472 switch (psd_scan->psd_point) {
4473 case 128:
4474 val |= 0x0;
4475 break;
4476 case 256:
4477 default:
4478 val |= 0x00004000;
4479 break;
4480 case 512:
4481 val |= 0x00008000;
4482 break;
4483 case 1024:
4484 val |= 0x0000c000;
4485 break;
4486 }
4487
4488 switch (psd_scan->psd_avg_num) {
4489 case 1:
4490 val |= 0x0;
4491 break;
4492 case 8:
4493 val |= 0x00001000;
4494 break;
4495 case 16:
4496 val |= 0x00002000;
4497 break;
4498 case 32:
4499 default:
4500 val |= 0x00003000;
4501 break;
4502 }
4503 btcoexist->btc_write_4byte(btcoexist, 0x808, val);
4504
4505 flag = 1;
4506 break;
4507 case 1: /* calculate the PSD point index from freq/offset/span */
4508 psd_center_freq = psd_scan->psd_band_width / 2 +
4509 offset * (1000000);
4510
4511 start_p = psd_scan->psd_start_base + (psd_center_freq -
4512 span * (1000000) / 2) / delta_freq_per_point;
4513 psd_scan->psd_start_point = start_p -
4514 psd_scan->psd_start_base;
4515
4516 stop_p = psd_scan->psd_start_base + (psd_center_freq +
4517 span * (1000000) / 2) / delta_freq_per_point;
4518 psd_scan->psd_stop_point = stop_p -
4519 psd_scan->psd_start_base - 1;
4520
4521 flag = 2;
4522 break;
4523 case 2: /* set RF channel/BW/Mode */
4524
4525 /* set 3-wire off */
4526 val = btcoexist->btc_read_4byte(btcoexist, 0x88c);
4527 val |= 0x00300000;
4528 btcoexist->btc_write_4byte(btcoexist, 0x88c, val);
4529
4530 /* CCK off */
4531 val = btcoexist->btc_read_4byte(btcoexist, 0x800);
4532 val &= 0xfeffffff;
4533 btcoexist->btc_write_4byte(btcoexist, 0x800, val);
4534
4535 /* store WiFi original channel */
4536 wifi_original_channel = btcoexist->btc_get_rf_reg(
4537 btcoexist, BTC_RF_A, 0x18, 0x3ff);
4538
4539 /* Set RF channel */
4540 if (cent_freq == 2484)
4541 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A,
4542 0x18, 0x3ff, 0xe);
4543 else
4544 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A,
4545 0x18, 0x3ff, (cent_freq - 2412) / 5 +
4546 1); /* WiFi TRx Mask on */
4547
4548 /* Set RF mode = Rx, RF Gain = 0x8a0 */
4549 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x0,
4550 0xfffff, 0x308a0);
4551
4552 /* Set RF Rx filter corner */
4553 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
4554 0xfffff, 0x3e4);
4555
4556 /* Set TRx mask off */
4557 /* un-lock TRx Mask setup */
4558 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xdd,
4559 0x80, 0x1);
4560 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xdf,
4561 0x1, 0x1);
4562
4563 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
4564 0xfffff, 0x0);
4565
4566 flag = 3;
4567 break;
4568 case 3:
4569 memset(psd_scan->psd_report, 0,
4570 psd_scan->psd_point * sizeof(u32));
4571 start_p = psd_scan->psd_start_point +
4572 psd_scan->psd_start_base;
4573 stop_p = psd_scan->psd_stop_point +
4574 psd_scan->psd_start_base + 1;
4575
4576 i = start_p;
4577
4578 while (i < stop_p) {
4579 if (i >= points1)
4580 psd_report =
4581 halbtc8822b1ant_psd_getdata(
4582 btcoexist, i - points1);
4583 else
4584 psd_report =
4585 halbtc8822b1ant_psd_getdata(
4586 btcoexist, i);
4587
4588 if (psd_report == 0)
4589 tmp = 0;
4590 else
4591 /* tmp = 20*log10((double)psd_report); */
4592 /* 20*log2(x)/log2(10), log2Base return theresult of the psd_report*100 */
4593 tmp = 6 * halbtc8822b1ant_psd_log2base(
4594 btcoexist, psd_report);
4595
4596 n = i - psd_scan->psd_start_base;
4597 psd_scan->psd_report[n] = tmp;
4598 psd_rep1 = psd_scan->psd_report[n] / 100;
4599 psd_rep2 = psd_scan->psd_report[n] - psd_rep1 *
4600 100;
4601
4602 freq = ((cent_freq - 20) * 1000000 + n *
4603 delta_freq_per_point);
4604 freq1 = freq / 1000000;
4605 freq2 = freq / 1000 - freq1 * 1000;
4606
4607 i++;
4608
4609 k = 0;
4610
4611 /* Add Delay between PSD point */
4612 while (1) {
4613 if (k++ > 20000)
4614 break;
4615 }
4616
4617 }
4618
4619 flag = 100;
4620 break;
4621 case 99: /* error */
4622
4623 outloop = true;
4624 break;
4625 case 100: /* recovery */
4626
4627 /* set 3-wire on */
4628 val = btcoexist->btc_read_4byte(btcoexist, 0x88c);
4629 val &= 0xffcfffff;
4630 btcoexist->btc_write_4byte(btcoexist, 0x88c, val);
4631
4632 /* CCK on */
4633 val = btcoexist->btc_read_4byte(btcoexist, 0x800);
4634 val |= 0x01000000;
4635 btcoexist->btc_write_4byte(btcoexist, 0x800, val);
4636
4637 /* PSD off */
4638 val = btcoexist->btc_read_4byte(btcoexist, 0x808);
4639 val &= 0xffbfffff;
4640 btcoexist->btc_write_4byte(btcoexist, 0x808, val);
4641
4642 /* TRx Mask on */
4643 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
4644 0xfffff, 0x780);
4645
4646 /* lock TRx Mask setup */
4647 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xdd,
4648 0x80, 0x0);
4649 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xdf,
4650 0x1, 0x0);
4651
4652 /* Set RF Rx filter corner */
4653 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
4654 0xfffff, 0x0);
4655
4656 /* restore WiFi original channel */
4657 btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x18,
4658 0x3ff, wifi_original_channel);
4659
4660 outloop = true;
4661 break;
4662
4663 }
4664
4665 } while (!outloop);
4666
4667
4668
4669 psd_scan->is_psd_running = false;
4670
4671
4672 }
4673
4674 #if (BTC_COEX_OFFLOAD == 1)
halbtc8822b1ant_wifi_info_notify(IN struct btc_coexist * btcoexist)4675 void halbtc8822b1ant_wifi_info_notify(IN struct btc_coexist *btcoexist)
4676 {
4677 u8 h2c_para[4] = {0};
4678 u8 opcode_ver = 0;
4679 u8 ap_num = 0;
4680 s32 wifi_rssi = 0;
4681 boolean wifi_busy = false;
4682
4683 btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
4684 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
4685 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
4686
4687 h2c_para[0] = ap_num; /* AP number */
4688 h2c_para[1] = (u8)wifi_busy; /* Busy */
4689 h2c_para[2] = (u8)wifi_rssi; /* RSSI */
4690
4691 btcoexist->btc_coex_h2c_process(btcoexist, COL_OP_WIFI_INFO_NOTIFY,
4692 opcode_ver, &h2c_para[0], 3);
4693 }
4694
halbtc8822b1ant_setManual(IN struct btc_coexist * btcoexist,IN boolean manual)4695 void halbtc8822b1ant_setManual(IN struct btc_coexist *btcoexist,
4696 IN boolean manual)
4697 {
4698 u8 h2c_para[4] = {0};
4699 u8 opcode_ver = 0;
4700 u8 set_type = 0;
4701
4702 if (manual)
4703 set_type = 1;
4704 else
4705 set_type = 0;
4706
4707 h2c_para[0] = set_type; /* set_type */
4708
4709 btcoexist->btc_coex_h2c_process(btcoexist, COL_OP_SET_CONTROL,
4710 opcode_ver,
4711 &h2c_para[0], 1);
4712 }
4713
4714 /* ************************************************************
4715 * work around function start with wa_halbtc8822b1ant_
4716 * ************************************************************
4717 * ************************************************************
4718 * extern function start with ex_halbtc8822b1ant_
4719 * ************************************************************ */
4720
ex_halbtc8822b1ant_power_on_setting(IN struct btc_coexist * btcoexist)4721 void ex_halbtc8822b1ant_power_on_setting(IN struct btc_coexist *btcoexist)
4722 {}
ex_halbtc8822b1ant_pre_load_firmware(IN struct btc_coexist * btcoexist)4723 void ex_halbtc8822b1ant_pre_load_firmware(IN struct btc_coexist *btcoexist)
4724 {}
ex_halbtc8822b1ant_init_hw_config(IN struct btc_coexist * btcoexist,IN boolean wifi_only)4725 void ex_halbtc8822b1ant_init_hw_config(IN struct btc_coexist *btcoexist,
4726 IN boolean wifi_only)
4727 {}
ex_halbtc8822b1ant_init_coex_dm(IN struct btc_coexist * btcoexist)4728 void ex_halbtc8822b1ant_init_coex_dm(IN struct btc_coexist *btcoexist)
4729 {}
ex_halbtc8822b1ant_ips_notify(IN struct btc_coexist * btcoexist,IN u8 type)4730 void ex_halbtc8822b1ant_ips_notify(IN struct btc_coexist *btcoexist, IN u8 type)
4731 {
4732 u8 h2c_para[4] = {0};
4733 u8 opcode_ver = 0;
4734 u8 ips_notify = 0;
4735
4736 if (BTC_IPS_ENTER == type) {
4737 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4738 "[BTCoex], IPS ENTER notify\n");
4739 BTC_TRACE(trace_buf);
4740 ips_notify = 1;
4741 } else if (BTC_IPS_LEAVE == type) {
4742 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4743 "[BTCoex], IPS LEAVE notify\n");
4744 BTC_TRACE(trace_buf);
4745 }
4746
4747 h2c_para[0] = ips_notify; /* IPS notify */
4748 h2c_para[1] = 0xff; /* LPS notify */
4749 h2c_para[2] = 0xff; /* RF state notify */
4750 h2c_para[3] = 0xff; /* pnp notify */
4751
4752 btcoexist->btc_coex_h2c_process(btcoexist,
4753 COL_OP_WIFI_POWER_STATE_NOTIFY,
4754 opcode_ver, &h2c_para[0], 4);
4755 }
ex_halbtc8822b1ant_lps_notify(IN struct btc_coexist * btcoexist,IN u8 type)4756 void ex_halbtc8822b1ant_lps_notify(IN struct btc_coexist *btcoexist, IN u8 type)
4757 {
4758 u8 h2c_para[4] = {0};
4759 u8 opcode_ver = 0;
4760 u8 lps_notify = 0;
4761
4762 if (BTC_LPS_ENABLE == type) {
4763 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4764 "[BTCoex], LPS ENABLE notify\n");
4765 BTC_TRACE(trace_buf);
4766 lps_notify = 1;
4767 } else if (BTC_LPS_DISABLE == type) {
4768 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4769 "[BTCoex], LPS DISABLE notify\n");
4770 BTC_TRACE(trace_buf);
4771 }
4772
4773 h2c_para[0] = 0xff; /* IPS notify */
4774 h2c_para[1] = lps_notify; /* LPS notify */
4775 h2c_para[2] = 0xff; /* RF state notify */
4776 h2c_para[3] = 0xff; /* pnp notify */
4777
4778 btcoexist->btc_coex_h2c_process(btcoexist,
4779 COL_OP_WIFI_POWER_STATE_NOTIFY,
4780 opcode_ver, &h2c_para[0], 4);
4781 }
4782
ex_halbtc8822b1ant_scan_notify(IN struct btc_coexist * btcoexist,IN u8 type)4783 void ex_halbtc8822b1ant_scan_notify(IN struct btc_coexist *btcoexist,
4784 IN u8 type)
4785 {
4786 u8 h2c_para[4] = {0};
4787 u8 opcode_ver = 0;
4788 u8 scan_start = 0;
4789 boolean under_4way = false;
4790
4791 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
4792 &under_4way);
4793 if (BTC_SCAN_START == type) {
4794 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4795 "[BTCoex], SCAN START notify\n");
4796 BTC_TRACE(trace_buf);
4797 scan_start = 1;
4798 } else {
4799 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4800 "[BTCoex], SCAN FINISH notify\n");
4801 BTC_TRACE(trace_buf);
4802 }
4803
4804 h2c_para[0] = scan_start; /* scan notify */
4805 h2c_para[1] = 0xff; /* connect notify */
4806 h2c_para[2] = 0xff; /* specific packet notify */
4807 if (under_4way)
4808 h2c_para[3] = 1; /* under 4way progress */
4809 else
4810 h2c_para[3] = 0;
4811
4812 btcoexist->btc_coex_h2c_process(btcoexist, COL_OP_WIFI_PROGRESS_NOTIFY,
4813 opcode_ver, &h2c_para[0], 4);
4814 }
4815
ex_halbtc8822b1ant_connect_notify(IN struct btc_coexist * btcoexist,IN u8 type)4816 void ex_halbtc8822b1ant_connect_notify(IN struct btc_coexist *btcoexist,
4817 IN u8 type)
4818 {
4819 u8 h2c_para[4] = {0};
4820 u8 opcode_ver = 0;
4821 u8 connect_start = 0;
4822 boolean under_4way = false;
4823
4824 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
4825 &under_4way);
4826 if (BTC_ASSOCIATE_START == type) {
4827 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4828 "[BTCoex], CONNECT START notify\n");
4829 BTC_TRACE(trace_buf);
4830 connect_start = 1;
4831 } else {
4832 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4833 "[BTCoex], CONNECT FINISH notify\n");
4834 BTC_TRACE(trace_buf);
4835 }
4836
4837 h2c_para[0] = 0xff; /* scan notify */
4838 h2c_para[1] = connect_start; /* connect notify */
4839 h2c_para[2] = 0xff; /* specific packet notify */
4840 if (under_4way)
4841 h2c_para[3] = 1; /* under 4way progress */
4842 else
4843 h2c_para[3] = 0;
4844
4845 btcoexist->btc_coex_h2c_process(btcoexist, COL_OP_WIFI_PROGRESS_NOTIFY,
4846 opcode_ver, &h2c_para[0], 4);
4847 }
4848
ex_halbtc8822b1ant_media_status_notify(IN struct btc_coexist * btcoexist,IN u8 type)4849 void ex_halbtc8822b1ant_media_status_notify(IN struct btc_coexist *btcoexist,
4850 IN u8 type)
4851 {
4852 u32 wifi_bw;
4853 u8 wifi_central_chnl;
4854 u8 h2c_para[5] = {0};
4855 u8 opcode_ver = 0;
4856 u8 port = 0, connected = 0, freq = 0, bandwidth = 0, iot_peer = 0;
4857 boolean wifi_under_5g = false;
4858
4859 if (BTC_MEDIA_CONNECT == type)
4860 connected = 1;
4861
4862 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
4863 bandwidth = (u8)wifi_bw;
4864 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
4865 if (wifi_under_5g)
4866 freq = 1;
4867 else
4868 freq = 0;
4869 btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
4870 &wifi_central_chnl);
4871 btcoexist->btc_get(btcoexist, BTC_GET_U1_IOT_PEER, &iot_peer);
4872
4873 h2c_para[0] = (connected << 4) |
4874 port; /* port need to be implemented in the future (p2p port, ...) */
4875 h2c_para[1] = (freq << 4) | bandwidth;
4876 h2c_para[2] = wifi_central_chnl;
4877 h2c_para[3] = iot_peer;
4878 btcoexist->btc_coex_h2c_process(btcoexist, COL_OP_WIFI_STATUS_NOTIFY,
4879 opcode_ver, &h2c_para[0], 4);
4880 }
4881
ex_halbtc8822b1ant_specific_packet_notify(IN struct btc_coexist * btcoexist,IN u8 type)4882 void ex_halbtc8822b1ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
4883 IN u8 type)
4884 {
4885 u8 h2c_para[4] = {0};
4886 u8 opcode_ver = 0;
4887 u8 connect_start = 0;
4888 boolean under_4way = false;
4889
4890 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
4891 &under_4way);
4892
4893 h2c_para[0] = 0xff; /* scan notify */
4894 h2c_para[1] = 0xff; /* connect notify */
4895 h2c_para[2] = type; /* specific packet notify */
4896 if (under_4way)
4897 h2c_para[3] = 1; /* under 4way progress */
4898 else
4899 h2c_para[3] = 0;
4900
4901 btcoexist->btc_coex_h2c_process(btcoexist, COL_OP_WIFI_PROGRESS_NOTIFY,
4902 opcode_ver, &h2c_para[0], 4);
4903 }
4904
ex_halbtc8822b1ant_bt_info_notify(IN struct btc_coexist * btcoexist,IN u8 * tmp_buf,IN u8 length)4905 void ex_halbtc8822b1ant_bt_info_notify(IN struct btc_coexist *btcoexist,
4906 IN u8 *tmp_buf, IN u8 length)
4907 {}
ex_halbtc8822b1ant_rf_status_notify(IN struct btc_coexist * btcoexist,IN u8 type)4908 void ex_halbtc8822b1ant_rf_status_notify(IN struct btc_coexist *btcoexist,
4909 IN u8 type)
4910 {
4911 u8 h2c_para[4] = {0};
4912 u8 opcode_ver = 0;
4913 u8 rfstate_notify = 0;
4914
4915 if (BTC_RF_ON == type) {
4916 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4917 "[BTCoex], RF is turned ON!!\n");
4918 BTC_TRACE(trace_buf);
4919 rfstate_notify = 1;
4920 } else if (BTC_RF_OFF == type) {
4921 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4922 "[BTCoex], RF is turned OFF!!\n");
4923 BTC_TRACE(trace_buf);
4924 }
4925
4926 h2c_para[0] = 0xff; /* IPS notify */
4927 h2c_para[1] = 0xff; /* LPS notify */
4928 h2c_para[2] = rfstate_notify; /* RF state notify */
4929 h2c_para[3] = 0xff; /* pnp notify */
4930
4931 btcoexist->btc_coex_h2c_process(btcoexist,
4932 COL_OP_WIFI_POWER_STATE_NOTIFY,
4933 opcode_ver, &h2c_para[0], 4);
4934 }
4935
ex_halbtc8822b1ant_halt_notify(IN struct btc_coexist * btcoexist)4936 void ex_halbtc8822b1ant_halt_notify(IN struct btc_coexist *btcoexist)
4937 {}
ex_halbtc8822b1ant_pnp_notify(IN struct btc_coexist * btcoexist,IN u8 pnp_state)4938 void ex_halbtc8822b1ant_pnp_notify(IN struct btc_coexist *btcoexist,
4939 IN u8 pnp_state)
4940 {
4941 u8 h2c_para[4] = {0};
4942 u8 opcode_ver = 0;
4943 u8 pnp_notify = 0;
4944
4945 if (BTC_WIFI_PNP_SLEEP == pnp_state) {
4946 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4947 "[BTCoex], Pnp notify to SLEEP\n");
4948 BTC_TRACE(trace_buf);
4949 pnp_notify = 1;
4950 } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) {
4951 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
4952 "[BTCoex], Pnp notify to WAKE UP\n");
4953 BTC_TRACE(trace_buf);
4954 }
4955
4956 h2c_para[0] = 0xff; /* IPS notify */
4957 h2c_para[1] = 0xff; /* LPS notify */
4958 h2c_para[2] = 0xff; /* RF state notify */
4959 h2c_para[3] = pnp_notify; /* pnp notify */
4960
4961 btcoexist->btc_coex_h2c_process(btcoexist,
4962 COL_OP_WIFI_POWER_STATE_NOTIFY,
4963 opcode_ver, &h2c_para[0], 4);
4964 }
4965
ex_halbtc8822b1ant_coex_dm_reset(IN struct btc_coexist * btcoexist)4966 void ex_halbtc8822b1ant_coex_dm_reset(IN struct btc_coexist *btcoexist)
4967 {}
ex_halbtc8822b1ant_periodical(IN struct btc_coexist * btcoexist)4968 void ex_halbtc8822b1ant_periodical(IN struct btc_coexist *btcoexist)
4969 {
4970
4971 halbtc8822b1ant_wifi_info_notify(btcoexist);
4972 }
4973
ex_halbtc8822b1ant_display_coex_info(IN struct btc_coexist * btcoexist)4974 void ex_halbtc8822b1ant_display_coex_info(IN struct btc_coexist *btcoexist)
4975 {
4976 struct btc_board_info *board_info = &btcoexist->board_info;
4977 struct btc_stack_info *stack_info = &btcoexist->stack_info;
4978 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
4979 u8 *cli_buf = btcoexist->cli_buf;
4980 u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
4981 u16 u16tmp[4];
4982 u32 u32tmp[4];
4983 u32 fa_ofdm, fa_cck, cca_ofdm, cca_cck;
4984 u32 fw_ver = 0, bt_patch_ver = 0, bt_coex_ver = 0;
4985 static u8 pop_report_in_10s = 0;
4986 u32 phyver = 0;
4987 boolean lte_coex_on = false;
4988
4989 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4990 "\r\n ============[BT Coexist info]============");
4991 CL_PRINTF(cli_buf);
4992
4993 if (btcoexist->manual_control) {
4994 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4995 "\r\n ============[Under Manual Control]============");
4996 CL_PRINTF(cli_buf);
4997 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
4998 "\r\n ==========================================");
4999 CL_PRINTF(cli_buf);
5000 }
5001 if (btcoexist->stop_coex_dm) {
5002 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5003 "\r\n ============[Coex is STOPPED]============");
5004 CL_PRINTF(cli_buf);
5005 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5006 "\r\n ==========================================");
5007 CL_PRINTF(cli_buf);
5008 }
5009
5010 if (psd_scan->ant_det_try_count == 0) {
5011 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5012 "\r\n %-35s = %d/ %d/ %s / %d",
5013 "Ant PG Num/ Mech/ Pos/ RFE",
5014 board_info->pg_ant_num, board_info->btdm_ant_num,
5015 (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT
5016 ? "Main" : "Aux"),
5017 rfe_type->rfe_module_type);
5018 CL_PRINTF(cli_buf);
5019 } else {
5020 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5021 "\r\n %-35s = %d/ %d/ %s/ %d (%d/%d/%d)",
5022 "Ant PG Num/ Mech(Ant_Det)/ Pos/ RFE",
5023 board_info->pg_ant_num,
5024 board_info->btdm_ant_num_by_ant_det,
5025 (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT
5026 ? "Main" : "Aux"),
5027 rfe_type->rfe_module_type,
5028 psd_scan->ant_det_try_count,
5029 psd_scan->ant_det_fail_count,
5030 psd_scan->ant_det_result);
5031 CL_PRINTF(cli_buf);
5032
5033 if (board_info->btdm_ant_det_finish) {
5034 if (psd_scan->ant_det_result != 12)
5035 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
5036 "Ant Det PSD Value",
5037 psd_scan->ant_det_peak_val);
5038 else
5039 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5040 "\r\n %-35s = %d",
5041 "Ant Det PSD Value",
5042 psd_scan->ant_det_psd_scan_peak_val / 100);
5043
5044 CL_PRINTF(cli_buf);
5045 }
5046 }
5047
5048 btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
5049 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
5050 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5051 "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)",
5052 "CoexVer/ FwVer/ PatchVer",
5053 glcoex_ver_date_8822b_1ant, glcoex_ver_8822b_1ant, fw_ver,
5054 bt_patch_ver, bt_patch_ver);
5055 CL_PRINTF(cli_buf);
5056
5057 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
5058 "Wifi channel informed to BT",
5059 coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1],
5060 coex_dm->wifi_chnl_info[2]);
5061 CL_PRINTF(cli_buf);
5062 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s",
5063 "WifibHiPri/ Ccklock/ CckEverLock",
5064 (coex_sta->wifi_is_high_pri_task ? "Yes" : "No"),
5065 (coex_sta->cck_lock ? "Yes" : "No"),
5066 (coex_sta->cck_ever_lock ? "Yes" : "No"));
5067 CL_PRINTF(cli_buf);
5068
5069 /* wifi status */
5070 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5071 "============[Wifi Status]============");
5072 CL_PRINTF(cli_buf);
5073 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_WIFI_STATUS);
5074
5075 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5076 "============[BT Status]============");
5077 CL_PRINTF(cli_buf);
5078
5079 pop_report_in_10s++;
5080 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ",
5081 "BT [status/ rssi/ retryCnt/ popCnt]",
5082 ((coex_sta->bt_disabled) ? ("disabled") : ((
5083 coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan")
5084 : ((BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
5085 coex_dm->bt_status) ? "non-connected idle" :
5086 ((BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)
5087 ? "connected-idle" : "busy")))),
5088 coex_sta->bt_rssi - 100, coex_sta->bt_retry_cnt,
5089 coex_sta->pop_event_cnt);
5090 CL_PRINTF(cli_buf);
5091
5092 if (pop_report_in_10s >= 5) {
5093 coex_sta->pop_event_cnt = 0;
5094 pop_report_in_10s = 0;
5095 }
5096
5097 if (coex_sta->num_of_profile != 0)
5098 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5099 "\r\n %-35s = %s%s%s%s%s",
5100 "Profiles",
5101 ((bt_link_info->a2dp_exist) ? "A2DP," : ""),
5102 ((bt_link_info->sco_exist) ? "SCO," : ""),
5103 ((bt_link_info->hid_exist) ?
5104 ((coex_sta->hid_busy_num >= 2) ? "HID(4/18)," : "HID(2/18),") : ""),
5105 ((bt_link_info->pan_exist) ? "PAN," : ""),
5106 ((coex_sta->voice_over_HOGP) ? "Voice" : ""));
5107 else
5108 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5109 "\r\n %-35s = None", "Profiles");
5110
5111 CL_PRINTF(cli_buf);
5112
5113 if (bt_link_info->a2dp_exist) {
5114 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d/ %s",
5115 "A2DP Rate/Bitpool/Auto_Slot",
5116 ((coex_sta->is_A2DP_3M) ? "3M" : "No_3M"),
5117 coex_sta->a2dp_bit_pool,
5118 ((coex_sta->is_autoslot) ? "On" : "Off"));
5119 CL_PRINTF(cli_buf);
5120 }
5121
5122 if (bt_link_info->hid_exist) {
5123 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
5124 "HID PairNum/Forbid_Slot",
5125 coex_sta->hid_pair_cnt,
5126 coex_sta->forbidden_slot
5127 );
5128 CL_PRINTF(cli_buf);
5129 }
5130
5131 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ 0x%x/ 0x%x",
5132 "Role/IgnWlanAct/Feature/BLEScan",
5133 ((bt_link_info->slave_role) ? "Slave" : "Master"),
5134 ((coex_dm->cur_ignore_wlan_act) ? "Yes":"No"),
5135 coex_sta->bt_coex_supported_feature,
5136 coex_sta->bt_ble_scan_type);
5137 CL_PRINTF(cli_buf);
5138
5139 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d",
5140 "ReInit/ReLink/IgnWlact/Page/NameReq",
5141 coex_sta->cnt_ReInit,
5142 coex_sta->cnt_setupLink,
5143 coex_sta->cnt_IgnWlanAct,
5144 coex_sta->cnt_Page,
5145 coex_sta->cnt_RemoteNameReq
5146 );
5147 CL_PRINTF(cli_buf);
5148
5149 halbtc8822b1ant_read_score_board(btcoexist, &u16tmp[0]);
5150
5151 if ((coex_sta->bt_reg_vendor_ae == 0xffff) ||
5152 (coex_sta->bt_reg_vendor_ac == 0xffff))
5153 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = x/ x/ %04x",
5154 "0xae[4]/0xac[1:0]/Scoreboard", u16tmp[0]);
5155 else
5156 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5157 "\r\n %-35s = 0x%x/ 0x%x/ %04x",
5158 "0xae[4]/0xac[1:0]/Scoreboard",
5159 ((coex_sta->bt_reg_vendor_ae & BIT(4))>>4),
5160 coex_sta->bt_reg_vendor_ac & 0x3, u16tmp[0]);
5161 CL_PRINTF(cli_buf);
5162
5163 for (i = 0; i < BT_INFO_SRC_8822B_1ANT_MAX; i++) {
5164 if (coex_sta->bt_info_c2h_cnt[i]) {
5165 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5166 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)",
5167 glbt_info_src_8822b_1ant[i],
5168 coex_sta->bt_info_c2h[i][0],
5169 coex_sta->bt_info_c2h[i][1],
5170 coex_sta->bt_info_c2h[i][2],
5171 coex_sta->bt_info_c2h[i][3],
5172 coex_sta->bt_info_c2h[i][4],
5173 coex_sta->bt_info_c2h[i][5],
5174 coex_sta->bt_info_c2h[i][6],
5175 coex_sta->bt_info_c2h_cnt[i]);
5176 CL_PRINTF(cli_buf);
5177 }
5178 }
5179
5180
5181 if (btcoexist->manual_control)
5182 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5183 "============[mechanisms] (before Manual)============");
5184 else
5185 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5186 "============[mechanisms]============");
5187 CL_PRINTF(cli_buf);
5188
5189 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d",
5190 "SM[LowPenaltyRA]",
5191 coex_dm->cur_low_penalty_ra);
5192 CL_PRINTF(cli_buf);
5193
5194 ps_tdma_case = coex_dm->cur_ps_tdma;
5195 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5196 "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)",
5197 "PS TDMA",
5198 coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1],
5199 coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3],
5200 coex_dm->ps_tdma_para[4], ps_tdma_case,
5201 (coex_dm->cur_ps_tdma_on ? "On" : "Off"),
5202 (coex_dm->auto_tdma_adjust ? "Adj" : "Fix"));
5203
5204 CL_PRINTF(cli_buf);
5205
5206 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d",
5207 "WL/BT Coex Table Type",
5208 coex_sta->coex_table_type);
5209 CL_PRINTF(cli_buf);
5210
5211 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
5212 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
5213 u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
5214 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5215 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
5216 "0x6c0/0x6c4/0x6c8(coexTable)",
5217 u32tmp[0], u32tmp[1], u32tmp[2]);
5218 CL_PRINTF(cli_buf);
5219
5220 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
5221 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6cc);
5222 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5223 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
5224 "0x778/0x6cc/IgnWlanAct",
5225 u8tmp[0], u32tmp[0], coex_dm->cur_ignore_wlan_act);
5226 CL_PRINTF(cli_buf);
5227
5228 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5229 0xa0);
5230 u32tmp[1] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5231 0xa4);
5232
5233 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
5234 "LTE Coex Table W_L/B_L",
5235 u32tmp[0] & 0xffff, u32tmp[1] & 0xffff);
5236 CL_PRINTF(cli_buf);
5237
5238 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5239 0xa8);
5240 u32tmp[1] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5241 0xac);
5242 u32tmp[2] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5243 0xb0);
5244 u32tmp[3] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5245 0xb4);
5246
5247 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5248 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
5249 "LTE Break Table W_L/B_L/L_W/L_B",
5250 u32tmp[0] & 0xffff, u32tmp[1] & 0xffff,
5251 u32tmp[2] & 0xffff, u32tmp[3] & 0xffff);
5252 CL_PRINTF(cli_buf);
5253
5254 /* Hw setting */
5255 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5256 "============[Hw setting]============");
5257 CL_PRINTF(cli_buf);
5258 /*
5259 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430);
5260 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434);
5261 u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a);
5262 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456);
5263 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
5264 "0x430/0x434/0x42a/0x456",
5265 u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]);
5266 CL_PRINTF(cli_buf);
5267 */
5268
5269 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x38);
5270 u32tmp[1] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x54);
5271 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x73);
5272
5273 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %s",
5274 "LTE CoexOn/Path Ctrl Owner",
5275 (int)((u32tmp[0]&BIT(7)) >> 7),
5276 ((u8tmp[0]&BIT(2)) ? "WL" : "BT"));
5277 CL_PRINTF(cli_buf);
5278
5279 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5280 "LTE 3Wire/OPMode/UART/UARTMode",
5281 (int)((u32tmp[0]&BIT(6)) >> 6),
5282 (int)((u32tmp[0] & (BIT(5) | BIT(4))) >> 4),
5283 (int)((u32tmp[0]&BIT(3)) >> 3),
5284 (int)(u32tmp[0] & (BIT(2) | BIT(1) | BIT(0))));
5285 CL_PRINTF(cli_buf);
5286
5287 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %s",
5288 "GNT_WL_SWCtrl/GNT_BT_SWCtrl/Dbg",
5289 (int)((u32tmp[0]&BIT(12)) >> 12),
5290 (int)((u32tmp[0]&BIT(14)) >> 14),
5291 ((u8tmp[0]&BIT(3)) ? "On" : "Off"));
5292 CL_PRINTF(cli_buf);
5293
5294 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x54);
5295
5296 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5297 "GNT_WL/GNT_BT/LTE_Busy/UART_Busy",
5298 (int)((u32tmp[0]&BIT(2)) >> 2),
5299 (int)((u32tmp[0]&BIT(3)) >> 3),
5300 (int)((u32tmp[0]&BIT(1)) >> 1), (int)(u32tmp[0]&BIT(0)));
5301 CL_PRINTF(cli_buf);
5302
5303
5304 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x4c6);
5305 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40);
5306
5307 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
5308 "0x4c6[4]/0x40[5] (WL/BT PTA)",
5309 (int)((u8tmp[0] & BIT(4)) >> 4),
5310 (int)((u8tmp[1] & BIT(5)) >> 5));
5311 CL_PRINTF(cli_buf);
5312
5313 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
5314 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
5315 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x953);
5316 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ %s",
5317 "0x550(bcn ctrl)/0x522/4-RxAGC",
5318 u32tmp[0], u8tmp[0], (u8tmp[1] & 0x2) ? "On" : "Off");
5319 CL_PRINTF(cli_buf);
5320
5321 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0);
5322 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4);
5323 u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8);
5324 u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0);
5325
5326 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b);
5327 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
5328
5329 fa_ofdm = ((u32tmp[0] & 0xffff0000) >> 16) + ((u32tmp[1] & 0xffff0000)
5330 >> 16) + (u32tmp[1] & 0xffff) + (u32tmp[2] & 0xffff) +
5331 ((u32tmp[3] & 0xffff0000) >> 16) + (u32tmp[3] &
5332 0xffff);
5333 fa_cck = (u8tmp[0] << 8) + u8tmp[1];
5334
5335 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
5336
5337 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5338 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
5339 "0xc50/OFDM-CCA/OFDM-FA/CCK-FA",
5340 u32tmp[1] & 0xff, u32tmp[0] & 0xffff, fa_ofdm, fa_cck);
5341 CL_PRINTF(cli_buf);
5342
5343
5344 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5345 "CRC_OK CCK/11g/11n/11n-Agg",
5346 coex_sta->crc_ok_cck, coex_sta->crc_ok_11g,
5347 coex_sta->crc_ok_11n, coex_sta->crc_ok_11n_agg);
5348 CL_PRINTF(cli_buf);
5349
5350 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5351 "CRC_Err CCK/11g/11n/11n-Agg",
5352 coex_sta->crc_err_cck, coex_sta->crc_err_11g,
5353 coex_sta->crc_err_11n, coex_sta->crc_err_11n_agg);
5354 CL_PRINTF(cli_buf);
5355
5356 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
5357 "0x770(high-pri rx/tx)",
5358 coex_sta->high_priority_rx, coex_sta->high_priority_tx);
5359 CL_PRINTF(cli_buf);
5360 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
5361 "0x774(low-pri rx/tx)",
5362 coex_sta->low_priority_rx, coex_sta->low_priority_tx);
5363 CL_PRINTF(cli_buf);
5364 #if (BT_AUTO_REPORT_ONLY_8822B_1ANT == 1)
5365 /* halbtc8822b1ant_monitor_bt_ctr(btcoexist); */
5366 #endif
5367 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
5368 }
ex_halbtc8822b1ant_antenna_detection(IN struct btc_coexist * btcoexist,IN u32 cent_freq,IN u32 offset,IN u32 span,IN u32 seconds)5369 void ex_halbtc8822b1ant_antenna_detection(IN struct btc_coexist *btcoexist,
5370 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds)
5371 {}
ex_halbtc8822b1ant_display_ant_detection(IN struct btc_coexist * btcoexist)5372 void ex_halbtc8822b1ant_display_ant_detection(IN struct btc_coexist *btcoexist)
5373 {}
ex_halbtc8822b1ant_dbg_control(IN struct btc_coexist * btcoexist,IN u8 op_code,IN u8 op_len,IN u8 * pdata)5374 void ex_halbtc8822b1ant_dbg_control(IN struct btc_coexist *btcoexist,
5375 IN u8 op_code, IN u8 op_len, IN u8 *pdata)
5376 {
5377 switch (op_code) {
5378 case BTC_DBG_SET_COEX_MANUAL_CTRL: {
5379 boolean manual = (boolean) *pdata;
5380
5381 halbtc8822b1ant_setManual(btcoexist, manual);
5382 }
5383 break;
5384 default:
5385 break;
5386 }
5387 }
5388
5389 #else
ex_halbtc8822b1ant_power_on_setting(IN struct btc_coexist * btcoexist)5390 void ex_halbtc8822b1ant_power_on_setting(IN struct btc_coexist *btcoexist)
5391 {
5392 struct btc_board_info *board_info = &btcoexist->board_info;
5393 u8 u8tmp = 0x0;
5394 u16 u16tmp = 0x0;
5395
5396 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5397 "xxxxxxxxxxxxxxxx Execute 8822b 1-Ant PowerOn Setting!! xxxxxxxxxxxxxxxx\n");
5398 BTC_TRACE(trace_buf);
5399
5400 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5401 "Ant Det Finish = %s, Ant Det Number = %d\n",
5402 board_info->btdm_ant_det_finish ? "Yes" : "No",
5403 board_info->btdm_ant_num_by_ant_det);
5404 BTC_TRACE(trace_buf);
5405
5406 btcoexist->stop_coex_dm = true;
5407
5408 /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
5409 u16tmp = btcoexist->btc_read_2byte(btcoexist, 0x2);
5410 btcoexist->btc_write_2byte(btcoexist, 0x2, u16tmp | BIT(0) | BIT(1));
5411
5412 /* set Path control owner to WiFi */
5413 halbtc8822b1ant_ltecoex_pathcontrol_owner(btcoexist,
5414 BT_8822B_1ANT_PCO_WLSIDE);
5415
5416 /* set GNT_BT to high */
5417 halbtc8822b1ant_ltecoex_set_gnt_bt(btcoexist,
5418 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
5419 BT_8822B_1ANT_GNT_CTRL_BY_SW,
5420 BT_8822B_1ANT_SIG_STA_SET_TO_HIGH);
5421 /* Set GNT_WL to low */
5422 halbtc8822b1ant_ltecoex_set_gnt_wl(btcoexist,
5423 BT_8822B_1ANT_GNT_BLOCK_RFC_BB,
5424 BT_8822B_1ANT_GNT_CTRL_BY_SW,
5425 BT_8822B_1ANT_SIG_STA_SET_TO_LOW);
5426
5427 /* set WLAN_ACT = 0 */
5428 /* btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); */
5429
5430 /* SD1 Chunchu red x issue */
5431 btcoexist->btc_write_1byte(btcoexist, 0xff1a, 0x0);
5432
5433 halbtc8822b1ant_enable_gnt_to_gpio(btcoexist, true);
5434
5435 /* */
5436 /* S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) */
5437 /* Local setting bit define */
5438 /* BIT0: "0" for no antenna inverse; "1" for antenna inverse */
5439 /* BIT1: "0" for internal switch; "1" for external switch */
5440 /* BIT2: "0" for one antenna; "1" for two antenna */
5441 /* NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 */
5442
5443 u8tmp = 0;
5444 board_info->btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
5445
5446 if (btcoexist->chip_interface == BTC_INTF_USB)
5447 btcoexist->btc_write_local_reg_1byte(btcoexist, 0xfe08, u8tmp);
5448 else if (btcoexist->chip_interface == BTC_INTF_SDIO)
5449 btcoexist->btc_write_local_reg_1byte(btcoexist, 0x60, u8tmp);
5450
5451 BTC_TRACE(trace_buf);
5452
5453
5454 }
5455
ex_halbtc8822b1ant_power_on_setting_without_bt(IN struct btc_coexist * btcoexist)5456 void ex_halbtc8822b1ant_power_on_setting_without_bt(IN struct btc_coexist
5457 *btcoexist)
5458 {
5459 struct btc_board_info *board_info = &btcoexist->board_info;
5460 u8 u8tmp = 0x0;
5461 u16 u16tmp = 0x0;
5462
5463 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5464 " 8822b 1-Ant PowerOn Setting without bt\n");
5465 BTC_TRACE(trace_buf);
5466
5467 btcoexist->stop_coex_dm = true;
5468
5469 /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
5470 u16tmp = btcoexist->btc_read_2byte(btcoexist, 0x2);
5471 btcoexist->btc_write_2byte(btcoexist, 0x2, u16tmp | BIT(0) | BIT(1));
5472
5473
5474 /* SD1 Chunchu red x issue */
5475 btcoexist->btc_write_1byte(btcoexist, 0xff1a, 0x0);
5476
5477 u8tmp = 0;
5478 board_info->btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
5479
5480 if (btcoexist->chip_interface == BTC_INTF_USB)
5481 btcoexist->btc_write_local_reg_1byte(btcoexist, 0xfe08, u8tmp);
5482 else if (btcoexist->chip_interface == BTC_INTF_SDIO)
5483 btcoexist->btc_write_local_reg_1byte(btcoexist, 0x60, u8tmp);
5484
5485
5486
5487 }
5488
5489
ex_halbtc8822b1ant_pre_load_firmware(IN struct btc_coexist * btcoexist)5490 void ex_halbtc8822b1ant_pre_load_firmware(IN struct btc_coexist *btcoexist)
5491 {
5492 }
5493
ex_halbtc8822b1ant_init_hw_config(IN struct btc_coexist * btcoexist,IN boolean wifi_only)5494 void ex_halbtc8822b1ant_init_hw_config(IN struct btc_coexist *btcoexist,
5495 IN boolean wifi_only)
5496 {
5497 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5498 "[BTCoex], ********** (ini hw config) **********\n");
5499
5500 halbtc8822b1ant_init_hw_config(btcoexist, true, wifi_only);
5501 btcoexist->stop_coex_dm = false;
5502 }
5503
ex_halbtc8822b1ant_init_hw_config_without_bt(IN struct btc_coexist * btcoexist,IN boolean wifi_only)5504 void ex_halbtc8822b1ant_init_hw_config_without_bt(IN struct btc_coexist
5505 *btcoexist,
5506 IN boolean wifi_only)
5507 {
5508 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5509 "[BTCoex], ********** (ini hw config) **********\n");
5510
5511 halbtc8822b1ant_init_hw_config_without_bt(btcoexist, true, wifi_only);
5512 btcoexist->stop_coex_dm = true;
5513 }
5514
ex_halbtc8822b1ant_antenna_switch_without_bt(IN struct btc_coexist * btcoexist)5515 void ex_halbtc8822b1ant_antenna_switch_without_bt(IN struct btc_coexist
5516 *btcoexist)
5517 {
5518
5519 boolean wifi_under_5g = false;
5520
5521
5522 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
5523
5524 if (wifi_under_5g)
5525
5526 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
5527 0x3, 1);
5528
5529 else
5530 btcoexist->btc_write_1byte_bitmask(btcoexist,
5531 0xcbd, 0x3, 2);
5532
5533
5534 }
5535
ex_halbtc8822b1ant_init_coex_dm(IN struct btc_coexist * btcoexist)5536 void ex_halbtc8822b1ant_init_coex_dm(IN struct btc_coexist *btcoexist)
5537 {
5538 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5539 "[BTCoex], Coex Mechanism Init!!\n");
5540 BTC_TRACE(trace_buf);
5541
5542 btcoexist->stop_coex_dm = false;
5543
5544 halbtc8822b1ant_init_coex_dm(btcoexist);
5545
5546 halbtc8822b1ant_query_bt_info(btcoexist);
5547 }
5548
ex_halbtc8822b1ant_display_coex_info(IN struct btc_coexist * btcoexist)5549 void ex_halbtc8822b1ant_display_coex_info(IN struct btc_coexist *btcoexist)
5550 {
5551
5552 struct btc_board_info *board_info = &btcoexist->board_info;
5553 struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
5554 u8 *cli_buf = btcoexist->cli_buf;
5555 u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
5556 u16 u16tmp[4];
5557 u32 fa_ofdm, fa_cck, cca_ofdm, cca_cck;
5558 u32 u32tmp[4];
5559 u32 fa_of_dm;
5560 u32 fw_ver = 0, bt_patch_ver = 0;
5561 static u8 pop_report_in_10s = 0;
5562 u32 phyver = 0;
5563 /*u32 pnp_wake_cnt=0;*/
5564
5565 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5566 "[BTCoex], ********** (display coexinfo) **********\n");
5567 BTC_TRACE(trace_buf);
5568 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5569 "[BTCoex], ********** displaycoexinfostart, 0xcb4/0xcbd = 0x%x/0x%x\n",
5570 btcoexist->btc_read_1byte(btcoexist, 0xcb4),
5571 btcoexist->btc_read_1byte(btcoexist, 0xcbd));
5572 BTC_TRACE(trace_buf);
5573
5574 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5575 "\r\n ============[BT Coexist info]============");
5576 CL_PRINTF(cli_buf);
5577
5578 if (btcoexist->manual_control) {
5579 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5580 "\r\n ============[Under Manual Control]============");
5581 CL_PRINTF(cli_buf);
5582 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5583 "\r\n ==========================================");
5584 CL_PRINTF(cli_buf);
5585 }
5586
5587 if (btcoexist->stop_coex_dm) {
5588 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5589 "\r\n ============[Coex is STOPPED]============");
5590 CL_PRINTF(cli_buf);
5591 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5592 "\r\n ==========================================");
5593 CL_PRINTF(cli_buf);
5594 }
5595
5596 if (psd_scan->ant_det_try_count == 0) {
5597 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5598 "\r\n %-35s = %d/ %d/ %d/ %d",
5599 "Ant PG Num/ Mech/ Pos/ RFE",
5600 board_info->pg_ant_num, board_info->btdm_ant_num,
5601 board_info->btdm_ant_pos,
5602 rfe_type->rfe_module_type);
5603 CL_PRINTF(cli_buf);
5604 } else {
5605 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5606 "\r\n %-35s = %d/ %d/ %d/ %d (%d/%d/%d)",
5607 "Ant PG Num/ Mech(Ant_Det)/ Pos/ RFE",
5608 board_info->pg_ant_num,
5609 board_info->btdm_ant_num_by_ant_det,
5610 board_info->btdm_ant_pos,
5611 rfe_type->rfe_module_type,
5612 psd_scan->ant_det_try_count,
5613 psd_scan->ant_det_fail_count,
5614 psd_scan->ant_det_result);
5615 CL_PRINTF(cli_buf);
5616
5617 if (board_info->btdm_ant_det_finish) {
5618 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
5619 "Ant Det PSD Value",
5620 psd_scan->ant_det_peak_val);
5621 CL_PRINTF(cli_buf);
5622 }
5623 }
5624 /*btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);*/
5625 bt_patch_ver = btcoexist->bt_info.bt_get_fw_ver;
5626 btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
5627 phyver = btcoexist->btc_get_bt_phydm_version(btcoexist);
5628 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5629 "\r\n %-35s = %d_%02x/ 0x%02x/ 0x%02x (%s)",
5630 "CoexVer WL/ BT_Desired/ BT_Report",
5631 glcoex_ver_date_8822b_1ant, glcoex_ver_8822b_1ant,
5632 glcoex_ver_btdesired_8822b_1ant,
5633 ((coex_sta->bt_coex_supported_version & 0xff00) >>
5634 8),
5635 (((coex_sta->bt_coex_supported_version & 0xff00) >>
5636 8) >=
5637 glcoex_ver_btdesired_8822b_1ant ? "Match" :
5638 "Mis-Match"));
5639 CL_PRINTF(cli_buf);
5640
5641 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5642 "\r\n %-35s = 0x%x/ 0x%x/ v%d/ %c",
5643 "W_FW/ B_FW/ Phy/ Kt",
5644 fw_ver, bt_patch_ver, phyver,
5645 coex_sta->cut_version + 65);
5646 CL_PRINTF(cli_buf);
5647
5648
5649
5650
5651 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
5652 "Wifi channel informed to BT",
5653 coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1],
5654 coex_dm->wifi_chnl_info[2]);
5655 CL_PRINTF(cli_buf);
5656 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s",
5657 "WifibHiPri/ Ccklock/ CckEverLock",
5658 (coex_sta->wifi_is_high_pri_task ? "Yes" : "No"),
5659 (coex_sta->cck_lock ? "Yes" : "No"),
5660 (coex_sta->cck_ever_lock ? "Yes" : "No"));
5661 CL_PRINTF(cli_buf);
5662
5663 /* wifi status */
5664 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5665 "============[Wifi Status]============");
5666 CL_PRINTF(cli_buf);
5667 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_WIFI_STATUS);
5668
5669 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5670 "============[BT Status]============");
5671 CL_PRINTF(cli_buf);
5672
5673 pop_report_in_10s++;
5674 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ",
5675 "BT [status/ rssi/ retryCnt/ popCnt]",
5676 ((coex_sta->bt_disabled) ? ("disabled") : ((
5677 coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan")
5678 : ((BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
5679 coex_dm->bt_status) ? "non-connected idle" :
5680 ((BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)
5681 ? "connected-idle" : "busy")))),
5682 coex_sta->bt_rssi - 100, coex_sta->bt_retry_cnt,
5683 coex_sta->pop_event_cnt);
5684 CL_PRINTF(cli_buf);
5685 /*bt rssi */
5686 /*bt pop_even_cnt : bt retry*/
5687
5688 if (pop_report_in_10s >= 5) {
5689 coex_sta->pop_event_cnt = 0;
5690 pop_report_in_10s = 0;
5691 }
5692
5693 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5694 "\r\n %-35s = %d / %d / %d / %d / %d",
5695 "SCO/HID/PAN/A2DP/Hi-Pri",
5696 bt_link_info->sco_exist, bt_link_info->hid_exist,
5697 bt_link_info->pan_exist, bt_link_info->a2dp_exist,
5698 bt_link_info->bt_hi_pri_link_exist);
5699 CL_PRINTF(cli_buf);
5700
5701 {
5702 bt_info_ext = coex_sta->bt_info_ext;
5703
5704 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5705 "\r\n %-35s = %s / %s / %d/ %x/ %02x",
5706 "Role/A2DP Rate/Bitpool/Feature/Ver",
5707 ((bt_link_info->slave_role) ? "Slave" : "Master"),
5708 (bt_info_ext & BIT(0)) ? "BR" : "EDR",
5709 coex_sta->a2dp_bit_pool,
5710 coex_sta->bt_coex_supported_feature,
5711 ((coex_sta->bt_coex_supported_version & 0xff00) >> 8));
5712 CL_PRINTF(cli_buf);
5713 }
5714
5715 /*bt info*/
5716 for (i = 0; i < BT_INFO_SRC_8822B_1ANT_MAX; i++) {
5717 if (coex_sta->bt_info_c2h_cnt[i]) {
5718 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5719 "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)",
5720 glbt_info_src_8822b_1ant[i],
5721 coex_sta->bt_info_c2h[i][0],
5722 coex_sta->bt_info_c2h[i][1],
5723 coex_sta->bt_info_c2h[i][2],
5724 coex_sta->bt_info_c2h[i][3],
5725 coex_sta->bt_info_c2h[i][4],
5726 coex_sta->bt_info_c2h[i][5],
5727 coex_sta->bt_info_c2h[i][6],
5728 coex_sta->bt_info_c2h_cnt[i]);
5729 CL_PRINTF(cli_buf);
5730 }
5731 }
5732
5733
5734 if (btcoexist->manual_control)
5735 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5736 "============[mechanisms] (before Manual)============");
5737 else
5738 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5739 "============[mechanisms]============");
5740 CL_PRINTF(cli_buf);
5741
5742 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d",
5743 "SM[LowPenaltyRA]",
5744 coex_dm->cur_low_penalty_ra);
5745 CL_PRINTF(cli_buf);
5746
5747 /*(ps)tdma*/
5748 ps_tdma_case = coex_dm->cur_ps_tdma;
5749 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5750 "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)",
5751 "PS TDMA",
5752 coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1],
5753 coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3],
5754 coex_dm->ps_tdma_para[4], ps_tdma_case,
5755 (coex_dm->cur_ps_tdma_on ? "On" : "Off"),
5756 (coex_dm->auto_tdma_adjust ? "Adj" : "Fix"));
5757
5758 CL_PRINTF(cli_buf);
5759
5760 /*coex table type*/
5761 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d",
5762 "WL/BT Coex Table Type",
5763 coex_sta->coex_table_type);
5764 CL_PRINTF(cli_buf);
5765
5766 /*coex table :0x6c0 0x6c4 , break table: 0x6c8*/
5767 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
5768 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
5769 u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
5770 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5771 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
5772 "0x6c0/0x6c4/0x6c8(coexTable)",
5773 u32tmp[0], u32tmp[1], u32tmp[2]);
5774 CL_PRINTF(cli_buf);
5775
5776 /*PTA : 0x778=1/3/d , WL BA,RTS,CTS :0x6cc H/L pri */
5777 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
5778 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6cc);
5779 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5780 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
5781 "0x778/0x6cc/IgnWlanAct",
5782 u8tmp[0], u32tmp[0], coex_dm->cur_ignore_wlan_act);
5783 CL_PRINTF(cli_buf);
5784
5785
5786 /*LTE : WL/LTE coex table : 0xa0 */
5787
5788 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5789 0xa0);
5790
5791 /*LTE : BT/LTE coex table : 0xa4 */
5792 u32tmp[1] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5793 0xa4);
5794
5795 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
5796 "LTE Coex Table W_L/B_L",
5797 u32tmp[0] & 0xffff, u32tmp[1] & 0xffff);
5798 CL_PRINTF(cli_buf);
5799
5800 /*LTE : WL/LTE break table : 0xa8 */
5801 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5802 0xa8);
5803 /*LTE : WL/LTE break table : 0xac */
5804 u32tmp[1] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5805 0xac);
5806 /*LTE : LTE/WL break table : 0xb0 */
5807 u32tmp[2] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5808 0xb0);
5809 /*LTE : LTE/BT break table : 0xb4 */
5810 u32tmp[3] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist,
5811 0xb4);
5812
5813 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5814 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
5815 "LTE Break Table W_L/B_L/L_W/L_B",
5816 u32tmp[0] & 0xffff, u32tmp[1] & 0xffff,
5817 u32tmp[2] & 0xffff, u32tmp[3] & 0xffff);
5818 CL_PRINTF(cli_buf);
5819
5820 /* Hw setting */
5821 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
5822 "============[Hw setting]============");
5823 CL_PRINTF(cli_buf);
5824
5825
5826 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430);
5827 u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434);
5828 u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a);
5829 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456);
5830 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
5831 "0x430/0x434/0x42a/0x456",
5832 u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]);
5833 CL_PRINTF(cli_buf);
5834
5835 /*ANT setting*/
5836 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xcb4);
5837 u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0xcbd);
5838 u8tmp[3] = btcoexist->btc_read_1byte(btcoexist, 0x1991);
5839
5840 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
5841 "0xcb4/0xcbd/0x1991",
5842 u8tmp[1], u8tmp[2], u8tmp[3]);
5843 CL_PRINTF(cli_buf);
5844
5845 /*LTE on/off , Path ctrl owner*/
5846 /*sy add*/
5847 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
5848 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x73);
5849 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x64);
5850 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
5851 "0x73/ 0x4c/ 0x64[0]", u8tmp[0],
5852 (u32tmp[0] & (BIT(24) | BIT(23))) >> 23,
5853 u8tmp[1] & 0x1);
5854 CL_PRINTF(cli_buf);
5855
5856
5857 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x38);
5858 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %s",
5859 "LTE CoexOn/Path Ctrl Owner",
5860 (int)((u32tmp[0]&BIT(7)) >> 7),
5861 ((u8tmp[0]&BIT(2)) ? "WL" : "BT"));
5862 CL_PRINTF(cli_buf);
5863
5864 /*LTE mode*/
5865 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5866 "LTE 3Wire/OPMode/UART/UARTMode",
5867 (int)((u32tmp[0]&BIT(6)) >> 6),
5868 (int)((u32tmp[0] & (BIT(5) | BIT(4))) >> 4),
5869 (int)((u32tmp[0]&BIT(3)) >> 3),
5870 (int)(u32tmp[0] & (BIT(2) | BIT(1) | BIT(0))));
5871 CL_PRINTF(cli_buf);
5872
5873 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %s",
5874 "GNT_WL_SWCtrl/GNT_BT_SWCtrl/Dbg",
5875 (int)((u32tmp[0]&BIT(12)) >> 12),
5876 (int)((u32tmp[0]&BIT(14)) >> 14),
5877 ((u8tmp[0]&BIT(3)) ? "On" : "Off"));
5878 CL_PRINTF(cli_buf);
5879
5880 u32tmp[0] = halbtc8822b1ant_ltecoex_indirect_read_reg(btcoexist, 0x54);
5881
5882 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5883 "GNT_WL/GNT_BT/LTE_Busy/UART_Busy",
5884 (int)((u32tmp[0]&BIT(2)) >> 2),
5885 (int)((u32tmp[0]&BIT(3)) >> 3),
5886 (int)((u32tmp[0]&BIT(1)) >> 1), (int)(u32tmp[0]&BIT(0)));
5887 CL_PRINTF(cli_buf);
5888
5889
5890 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x4c6);
5891 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40);
5892
5893 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
5894 "0x4c6[4]/0x40[5] (WL/BT PTA)",
5895 (int)((u8tmp[0] & BIT(4)) >> 4),
5896 (int)((u8tmp[1] & BIT(5)) >> 5));
5897 CL_PRINTF(cli_buf);
5898
5899 u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
5900 u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
5901 u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x953);
5902 u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0xc50);
5903 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5904 "\r\n %-35s = 0x%x/ 0x%x/ %s/ 0x%x",
5905 "0x550/0x522/4-RxAGC/0xc50",
5906 u32tmp[0], u8tmp[0], (u8tmp[1] & 0x2) ? "On" : "Off", u8tmp[2]);
5907 CL_PRINTF(cli_buf);
5908
5909 #if 0 /* phydm v008 doesn't support this feature */
5910 fa_ofdm = btcoexist->btc_phydm_query_PHY_counter(btcoexist,
5911 PHYDM_INFO_FA_OFDM);
5912 fa_cck = btcoexist->btc_phydm_query_PHY_counter(btcoexist,
5913 PHYDM_INFO_FA_CCK);
5914 cca_ofdm = btcoexist->btc_phydm_query_PHY_counter(btcoexist,
5915 PHYDM_INFO_CCA_OFDM);
5916 cca_cck = btcoexist->btc_phydm_query_PHY_counter(btcoexist,
5917 PHYDM_INFO_CCA_CCK);
5918
5919 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
5920 "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
5921 "CCK-CCA/CCK-FA/OFDM-CCA/OFDM-FA",
5922 cca_cck, fa_cck, cca_ofdm, fa_ofdm);
5923 CL_PRINTF(cli_buf);
5924 #endif
5925
5926
5927 #if 1
5928 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5929 "CRC_OK CCK/11g/11n/11ac",
5930 coex_sta->crc_ok_cck, coex_sta->crc_ok_11g,
5931 coex_sta->crc_ok_11n, coex_sta->crc_ok_11n_vht);
5932 CL_PRINTF(cli_buf);
5933
5934 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d",
5935 "CRC_Err CCK/11g/11n/11ac",
5936 coex_sta->crc_err_cck, coex_sta->crc_err_11g,
5937 coex_sta->crc_err_11n, coex_sta->crc_err_11n_vht);
5938 CL_PRINTF(cli_buf);
5939 #endif
5940
5941 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s",
5942 "Wifi-HiPri/ Ccklock/ CckEverLock",
5943 (coex_sta->wifi_is_high_pri_task ? "Yes" : "No"),
5944 (coex_sta->cck_lock ? "Yes" : "No"),
5945 (coex_sta->cck_ever_lock ? "Yes" : "No"));
5946 CL_PRINTF(cli_buf);
5947
5948 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
5949 "0x770(high-pri rx/tx)",
5950 coex_sta->high_priority_rx, coex_sta->high_priority_tx);
5951 CL_PRINTF(cli_buf);
5952 /*0x774:bt low pri trx*/
5953 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
5954 "0x774(low-pri rx/tx)",
5955 coex_sta->low_priority_rx, coex_sta->low_priority_tx);
5956 CL_PRINTF(cli_buf);
5957
5958 halbtc8822b1ant_read_score_board(btcoexist, &u16tmp[0]);
5959
5960 CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %04x",
5961 "ScoreBoard[14:0] (from BT)", u16tmp[0]);
5962
5963 btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
5964 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5965 "[BTCoex], ********** displaycoexinfo end, 0xcb4/0xcbd = 0x%x/0x%x\n",
5966 btcoexist->btc_read_1byte(btcoexist, 0xcb4),
5967 btcoexist->btc_read_1byte(btcoexist, 0xcbd));
5968 BTC_TRACE(trace_buf);
5969 /*
5970 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5971 "[BTCoex], ********** pnp_wake_cnt = %d\n", pnp_wake_cnt);
5972 BTC_TRACE(trace_buf);
5973 */
5974 }
5975
5976
ex_halbtc8822b1ant_ips_notify(IN struct btc_coexist * btcoexist,IN u8 type)5977 void ex_halbtc8822b1ant_ips_notify(IN struct btc_coexist *btcoexist, IN u8 type)
5978 {
5979
5980 if (btcoexist->manual_control || btcoexist->stop_coex_dm)
5981 return;
5982
5983
5984 if (BTC_IPS_ENTER == type) {
5985
5986 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
5987 "[BTCoex], IPS ENTER notify\n");
5988 BTC_TRACE(trace_buf);
5989 coex_sta->under_ips = true;
5990
5991 /* Write WL "Active" in Score-board for LPS off */
5992 halbtc8822b1ant_post_state_to_bt(btcoexist,
5993 BT_8822B_1ANT_SCOREBOARD_ACTIVE, false);
5994
5995 halbtc8822b1ant_post_state_to_bt(btcoexist,
5996 BT_8822B_1ANT_SCOREBOARD_ONOFF, false);
5997
5998 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
5999
6000 halbtc8822b1ant_set_ant_path(btcoexist,
6001 BTC_ANT_PATH_AUTO,
6002 FORCE_EXEC,
6003 BT_8822B_1ANT_PHASE_WLAN_OFF);
6004
6005 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
6006 } else if (BTC_IPS_LEAVE == type) {
6007
6008 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6009 "[BTCoex], IPS LEAVE notify\n");
6010 BTC_TRACE(trace_buf);
6011 halbtc8822b1ant_post_state_to_bt(btcoexist,
6012 BT_8822B_1ANT_SCOREBOARD_ACTIVE, true);
6013
6014 halbtc8822b1ant_post_state_to_bt(btcoexist,
6015 BT_8822B_1ANT_SCOREBOARD_ONOFF, true);
6016
6017 /*leave IPS : run ini hw config (exclude wifi only)*/
6018 halbtc8822b1ant_init_hw_config(btcoexist, false, false);
6019 /*sw all off*/
6020 halbtc8822b1ant_init_coex_dm(btcoexist);
6021 /*leave IPS : Query bt info*/
6022 halbtc8822b1ant_query_bt_info(btcoexist);
6023
6024 coex_sta->under_ips = false;
6025 }
6026 }
6027
ex_halbtc8822b1ant_lps_notify(IN struct btc_coexist * btcoexist,IN u8 type)6028 void ex_halbtc8822b1ant_lps_notify(IN struct btc_coexist *btcoexist, IN u8 type)
6029 {
6030 if (btcoexist->manual_control || btcoexist->stop_coex_dm)
6031 return;
6032
6033 if (BTC_LPS_ENABLE == type) {
6034 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6035 "[BTCoex], LPS ENABLE notify\n");
6036 BTC_TRACE(trace_buf);
6037 coex_sta->under_lps = true;
6038
6039 if (coex_sta->force_lps_on == true) { /* LPS No-32K */
6040 /* Write WL "Active" in Score-board for PS-TDMA */
6041 halbtc8822b1ant_post_state_to_bt(btcoexist,
6042 BT_8822B_1ANT_SCOREBOARD_ACTIVE, true);
6043
6044 } else { /* LPS-32K, need check if this h2c 0x71 can work?? (2015/08/28) */
6045 /* Write WL "Non-Active" in Score-board for Native-PS */
6046 halbtc8822b1ant_post_state_to_bt(btcoexist,
6047 BT_8822B_1ANT_SCOREBOARD_ACTIVE, false);
6048
6049 }
6050 } else if (BTC_LPS_DISABLE == type) {
6051 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6052 "[BTCoex], LPS DISABLE notify\n");
6053 BTC_TRACE(trace_buf);
6054 coex_sta->under_lps = false;
6055
6056 /* Write WL "Active" in Score-board for LPS off */
6057 halbtc8822b1ant_post_state_to_bt(btcoexist,
6058 BT_8822B_1ANT_SCOREBOARD_ACTIVE, true);
6059
6060 }
6061 }
6062
6063
ex_halbtc8822b1ant_scan_notify(IN struct btc_coexist * btcoexist,IN u8 type)6064 void ex_halbtc8822b1ant_scan_notify(IN struct btc_coexist *btcoexist,
6065 IN u8 type)
6066 {
6067 boolean wifi_connected = false;
6068 boolean wifi_under_5g = false;
6069
6070 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6071 "[BTCoex], SCAN notify()\n");
6072 BTC_TRACE(trace_buf);
6073
6074 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
6075 &wifi_connected);
6076
6077
6078
6079 if (btcoexist->manual_control ||
6080 btcoexist->stop_coex_dm)
6081 return;
6082
6083 if (BTC_SCAN_START == type) {
6084 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6085
6086 if (wifi_under_5g) {
6087 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6088 "[BTCoex], ********** (scan_notify_5g_scan_start) **********\n");
6089 BTC_TRACE(trace_buf);
6090 halbtc8822b1ant_action_wifi_under5g(btcoexist);
6091 return;
6092 }
6093
6094 /* under 2.4G */
6095 coex_sta->wifi_is_high_pri_task = true;
6096
6097 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6098 "[BTCoex], ********** (scan_notify_2g_scan_start) **********\n");
6099 BTC_TRACE(trace_buf);
6100
6101 if (!wifi_connected) { /* non-connected scan */
6102 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6103 "[BTCoex], ********** wifi is not connected scan **********\n");
6104 BTC_TRACE(trace_buf);
6105 halbtc8822b1ant_action_wifi_not_connected_scan(
6106 btcoexist);
6107 } else { /* wifi is connected */
6108 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6109 "[BTCoex], ********** wifi is connected scan **********\n");
6110 BTC_TRACE(trace_buf);
6111 halbtc8822b1ant_action_wifi_connected_scan(
6112 btcoexist);
6113 }
6114
6115 return;
6116 }
6117
6118 if (BTC_SCAN_START_2G == type) {
6119 coex_sta->wifi_is_high_pri_task = true;
6120
6121 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6122 "[BTCoex], ********** (scan_notify_2g_sacn_start_for_switch_band_used) **********\n");
6123 BTC_TRACE(trace_buf);
6124
6125 if (!wifi_connected) { /* non-connected scan */
6126 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6127 "[BTCoex], ********** wifi is not connected **********\n");
6128 BTC_TRACE(trace_buf);
6129
6130 halbtc8822b1ant_action_wifi_not_connected_scan(
6131 btcoexist);
6132 } else { /* wifi is connected */
6133 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6134 "[BTCoex], ********** wifi is connected **********\n");
6135 BTC_TRACE(trace_buf);
6136 halbtc8822b1ant_action_wifi_connected_scan(btcoexist);
6137 }
6138 } else {
6139 coex_sta->wifi_is_high_pri_task = false;
6140
6141 /*WL scan finish , then get and update sacn ap numbers */
6142 btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM,
6143 &coex_sta->scan_ap_num);
6144
6145 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6146 "[BTCoex], ********** (scan_finish_notify) **********\n");
6147 BTC_TRACE(trace_buf);
6148
6149 if (!wifi_connected) /* non-connected scan */
6150 halbtc8822b1ant_action_wifi_not_connected(btcoexist);
6151 else {
6152 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6153 "[BTCoex], ********** scan_finish_notify wifi is connected **********\n");
6154 BTC_TRACE(trace_buf);
6155 halbtc8822b1ant_action_wifi_connected(btcoexist);
6156 }
6157 }
6158 }
6159
6160
6161
ex_halbtc8822b1ant_scan_notify_without_bt(IN struct btc_coexist * btcoexist,IN u8 type)6162 void ex_halbtc8822b1ant_scan_notify_without_bt(IN struct btc_coexist *btcoexist,
6163 IN u8 type)
6164 {
6165
6166 boolean wifi_under_5g = false;
6167
6168 if (BTC_SCAN_START == type) {
6169 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6170
6171 if (wifi_under_5g) {
6172 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
6173 0x3, 1);
6174 return;
6175 }
6176
6177 /* under 2.4G */
6178 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
6179 0x3, 2);
6180 return;
6181 }
6182 if (BTC_SCAN_START_2G == type)
6183 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd, 0x3, 2);
6184 }
6185
ex_halbtc8822b1ant_switchband_notify(IN struct btc_coexist * btcoexist,IN u8 type)6186 void ex_halbtc8822b1ant_switchband_notify(IN struct btc_coexist *btcoexist,
6187 IN u8 type)
6188 {
6189
6190 boolean wifi_connected = false;
6191
6192
6193 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6194 "[BTCoex], ********** (switchband_notify) **********\n");
6195 BTC_TRACE(trace_buf);
6196
6197 if (btcoexist->manual_control ||
6198 btcoexist->stop_coex_dm)
6199 return;
6200
6201 coex_sta->switch_band_notify_to = type;
6202
6203 if (type == BTC_SWITCH_TO_5G) {
6204 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6205 "[BTCoex], ********** (switchband_notify BTC_SWITCH_TO_5G) **********\n");
6206 BTC_TRACE(trace_buf);
6207
6208 halbtc8822b1ant_action_wifi_under5g(btcoexist);
6209 return;
6210 } else if (type == BTC_SWITCH_TO_24G_NOFORSCAN) {
6211 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6212 "[BTCoex], ********** (switchband_notify BTC_SWITCH_TO_2G (no for scan)) **********\n");
6213 BTC_TRACE(trace_buf);
6214
6215 halbtc8822b1ant_run_coexist_mechanism(btcoexist);
6216
6217 } else {
6218 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6219 "[BTCoex], ********** (switchband_notify BTC_SWITCH_TO_2G) **********\n");
6220 BTC_TRACE(trace_buf);
6221
6222 ex_halbtc8822b1ant_scan_notify(btcoexist,
6223 BTC_SCAN_START_2G);
6224 }
6225 coex_sta->switch_band_notify_to = BTC_NOT_SWITCH;
6226
6227 }
6228
6229
ex_halbtc8822b1ant_switchband_notify_without_bt(IN struct btc_coexist * btcoexist,IN u8 type)6230 void ex_halbtc8822b1ant_switchband_notify_without_bt(IN struct btc_coexist
6231 *btcoexist,
6232 IN u8 type)
6233 {
6234 boolean wifi_under_5g = false;
6235
6236 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6237
6238 if (type == BTC_SWITCH_TO_5G) {
6239
6240 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
6241 0x3, 1);
6242 return;
6243 } else if (type == BTC_SWITCH_TO_24G_NOFORSCAN) {
6244
6245 if (wifi_under_5g)
6246
6247 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd,
6248 0x3, 1);
6249
6250 else
6251 btcoexist->btc_write_1byte_bitmask(btcoexist,
6252 0xcbd, 0x3, 2);
6253 } else {
6254
6255 ex_halbtc8822b1ant_scan_notify_without_bt(btcoexist,
6256 BTC_SCAN_START_2G);
6257 }
6258
6259 }
6260
ex_halbtc8822b1ant_connect_notify(IN struct btc_coexist * btcoexist,IN u8 type)6261 void ex_halbtc8822b1ant_connect_notify(IN struct btc_coexist *btcoexist,
6262 IN u8 type)
6263 {
6264 boolean wifi_connected = false;
6265
6266 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6267 "[BTCoex], ********** (connect notify) **********\n");
6268 BTC_TRACE(trace_buf);
6269
6270 halbtc8822b1ant_post_state_to_bt(btcoexist,
6271 BT_8822B_1ANT_SCOREBOARD_SCAN, true);
6272
6273 if (btcoexist->manual_control ||
6274 btcoexist->stop_coex_dm)
6275 return;
6276
6277
6278 if ((BTC_ASSOCIATE_5G_START == type) ||
6279 (BTC_ASSOCIATE_5G_FINISH == type)) {
6280
6281 if (BTC_ASSOCIATE_5G_START == type) {
6282
6283 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6284 "[BTCoex], ********** (5G associate start notify) **********\n");
6285 BTC_TRACE(trace_buf);
6286
6287 halbtc8822b1ant_action_wifi_under5g(btcoexist);
6288
6289 } else if (BTC_ASSOCIATE_5G_FINISH == type) {
6290
6291 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6292 "[BTCoex], ********** (5G associate finish notify) **********\n");
6293 BTC_TRACE(trace_buf);
6294
6295 }
6296
6297 return;
6298
6299 }
6300
6301
6302 if (BTC_ASSOCIATE_START == type) {
6303
6304 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6305 "[BTCoex], 2G CONNECT START notify\n");
6306 BTC_TRACE(trace_buf);
6307
6308 coex_sta->wifi_is_high_pri_task = true;
6309
6310 halbtc8822b1ant_set_ant_path(btcoexist,
6311 BTC_ANT_PATH_AUTO,
6312 FORCE_EXEC,
6313 BT_8822B_1ANT_PHASE_2G_RUNTIME);
6314
6315 coex_dm->arp_cnt = 0;
6316
6317 halbtc8822b1ant_action_wifi_not_connected_asso_auth(btcoexist);
6318
6319 } else {
6320
6321 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6322 "[BTCoex], 2G CONNECT Finish notify\n");
6323 BTC_TRACE(trace_buf);
6324 coex_sta->wifi_is_high_pri_task = false;
6325
6326 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
6327 &wifi_connected);
6328
6329 if (!wifi_connected) /* non-connected scan */
6330 halbtc8822b1ant_action_wifi_not_connected(btcoexist);
6331 else
6332 halbtc8822b1ant_action_wifi_connected(btcoexist);
6333 }
6334
6335 }
6336
ex_halbtc8822b1ant_media_status_notify(IN struct btc_coexist * btcoexist,IN u8 type)6337 void ex_halbtc8822b1ant_media_status_notify(IN struct btc_coexist *btcoexist,
6338 IN u8 type)
6339 {
6340 boolean wifi_under_b_mode = false;
6341 boolean wifi_under_5g = false;
6342 u32 cnt_bt_cal_chk = 0;
6343 boolean is_in_mp_mode = false;
6344 u8 u8tmp = 0;
6345 u32 u32tmp1 = 0, u32tmp2 = 0;
6346
6347
6348 if (btcoexist->manual_control ||
6349 btcoexist->stop_coex_dm)
6350 return;
6351
6352
6353 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6354
6355
6356
6357
6358 if (BTC_MEDIA_CONNECT == type) {
6359
6360 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6361 "[BTCoex], 2g media connect notify");
6362 BTC_TRACE(trace_buf);
6363
6364 halbtc8822b1ant_post_state_to_bt(btcoexist,
6365 BT_8822B_1ANT_SCOREBOARD_ACTIVE, true);
6366
6367 if (wifi_under_5g) {
6368 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6369 "[BTCoex], 5g media notify\n");
6370 BTC_TRACE(trace_buf);
6371
6372 halbtc8822b1ant_action_wifi_under5g(btcoexist);
6373 return;
6374 }
6375 /* Force antenna setup for no scan result issue */
6376 halbtc8822b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_AUTO,
6377 FORCE_EXEC,
6378 BT_8822B_1ANT_PHASE_2G_RUNTIME);
6379
6380 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE,
6381 &wifi_under_b_mode);
6382
6383 /* Set CCK Tx/Rx high Pri except 11b mode */
6384 if (wifi_under_b_mode) {
6385
6386 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6387 "[BTCoex], ********** (media status notity under b mode) **********\n");
6388 BTC_TRACE(trace_buf);
6389 btcoexist->btc_write_1byte(btcoexist, 0x6cd,
6390 0x00); /* CCK Tx */
6391 btcoexist->btc_write_1byte(btcoexist, 0x6cf,
6392 0x00); /* CCK Rx */
6393 } else {
6394 /* btcoexist->btc_write_1byte(btcoexist, 0x6cd, 0x10); */ /*CCK Tx */
6395 /* btcoexist->btc_write_1byte(btcoexist, 0x6cf, 0x10); */ /*CCK Rx */
6396 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6397 "[BTCoex], ********** (media status notity not under b mode) **********\n");
6398 BTC_TRACE(trace_buf);
6399 btcoexist->btc_write_1byte(btcoexist, 0x6cd,
6400 0x00); /* CCK Tx */
6401 btcoexist->btc_write_1byte(btcoexist, 0x6cf,
6402 0x10); /* CCK Rx */
6403 }
6404
6405 coex_dm->backup_arfr_cnt1 = btcoexist->btc_read_4byte(btcoexist,
6406 0x430);
6407 coex_dm->backup_arfr_cnt2 = btcoexist->btc_read_4byte(btcoexist,
6408 0x434);
6409 coex_dm->backup_retry_limit = btcoexist->btc_read_2byte(
6410 btcoexist, 0x42a);
6411 coex_dm->backup_ampdu_max_time = btcoexist->btc_read_1byte(
6412 btcoexist, 0x456);
6413 } else {
6414 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6415 "[BTCoex], 2g media disconnect notify\n");
6416 BTC_TRACE(trace_buf);
6417 coex_dm->arp_cnt = 0;
6418
6419 halbtc8822b1ant_post_state_to_bt(btcoexist,
6420 BT_8822B_1ANT_SCOREBOARD_ACTIVE, false);
6421
6422 btcoexist->btc_write_1byte(btcoexist, 0x6cd, 0x0); /* CCK Tx */
6423 btcoexist->btc_write_1byte(btcoexist, 0x6cf, 0x0); /* CCK Rx */
6424
6425 coex_sta->cck_ever_lock = false;
6426 }
6427
6428 halbtc8822b1ant_update_wifi_channel_info(btcoexist, type);
6429
6430 }
6431
ex_halbtc8822b1ant_specific_packet_notify(IN struct btc_coexist * btcoexist,IN u8 type)6432 void ex_halbtc8822b1ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
6433 IN u8 type)
6434 {
6435 boolean under_4way = false, wifi_under_5g = false;
6436
6437 if (btcoexist->manual_control ||
6438 btcoexist->stop_coex_dm)
6439 return;
6440
6441 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6442 if (wifi_under_5g) {
6443 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6444 "[BTCoex], 5g special packet notify\n");
6445 BTC_TRACE(trace_buf);
6446
6447 halbtc8822b1ant_action_wifi_under5g(btcoexist);
6448 return;
6449 }
6450
6451 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
6452 &under_4way);
6453
6454 if (under_4way) {
6455
6456 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6457 "[BTCoex], specific Packet ---- under_4way!!\n");
6458 BTC_TRACE(trace_buf);
6459
6460 coex_sta->wifi_is_high_pri_task = true;
6461 coex_sta->specific_pkt_period_cnt = 2;
6462 } else if (BTC_PACKET_ARP == type) {
6463
6464 coex_dm->arp_cnt++;
6465
6466 if (coex_sta->wifi_is_high_pri_task) {
6467 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6468 "[BTCoex], specific Packet ARP notify -cnt = %d\n",
6469 coex_dm->arp_cnt);
6470 BTC_TRACE(trace_buf);
6471 }
6472
6473 } else {
6474
6475 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6476 "[BTCoex], specific Packet DHCP or EAPOL notify [Type = %d]\n",
6477 type);
6478 BTC_TRACE(trace_buf);
6479
6480 coex_sta->wifi_is_high_pri_task = true;
6481 coex_sta->specific_pkt_period_cnt = 2;
6482 }
6483
6484 if (coex_sta->wifi_is_high_pri_task)
6485 halbtc8822b1ant_action_wifi_connected_specific_packet(
6486 btcoexist);
6487
6488 }
6489
ex_halbtc8822b1ant_bt_info_notify(IN struct btc_coexist * btcoexist,IN u8 * tmp_buf,IN u8 length)6490 void ex_halbtc8822b1ant_bt_info_notify(IN struct btc_coexist *btcoexist,
6491 IN u8 *tmp_buf, IN u8 length)
6492 {
6493 u8 bt_info = 0;
6494 u8 i, rsp_source = 0;
6495 boolean bt_busy = false;
6496 boolean wifi_connected = false;
6497 boolean wifi_under_5g = false;
6498
6499
6500 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6501
6502 coex_sta->c2h_bt_info_req_sent = false;
6503 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6504 "[BTCoex], ********** (BtInfo Notify) **********\n");
6505 BTC_TRACE(trace_buf);
6506
6507 rsp_source = tmp_buf[0] & 0xf;
6508 if (rsp_source >= BT_INFO_SRC_8822B_1ANT_MAX)
6509 rsp_source = BT_INFO_SRC_8822B_1ANT_WIFI_FW;
6510 coex_sta->bt_info_c2h_cnt[rsp_source]++;
6511
6512 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6513 "[BTCoex], Bt info[%d], length=%d, hex data=[", rsp_source,
6514 length);
6515 BTC_TRACE(trace_buf);
6516
6517 for (i = 0; i < length; i++) {
6518 coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
6519 if (i == 1)
6520 bt_info = tmp_buf[i];
6521 if (i == length - 1) {
6522 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "0x%02x]\n",
6523 tmp_buf[i]);
6524 BTC_TRACE(trace_buf);
6525 } else {
6526 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "0x%02x, ",
6527 tmp_buf[i]);
6528 BTC_TRACE(trace_buf);
6529 }
6530 }
6531
6532
6533 if (BT_INFO_SRC_8822B_1ANT_WIFI_FW != rsp_source) {
6534
6535 /* if 0xff, it means BT is under WHCK test */
6536 if (bt_info == 0xff)
6537 coex_sta->bt_whck_test = true;
6538 else
6539 coex_sta->bt_whck_test = false;
6540
6541 coex_sta->bt_retry_cnt = /* [3:0] */
6542 coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
6543
6544 if (coex_sta->bt_retry_cnt >= 1)
6545 coex_sta->pop_event_cnt++;
6546
6547 if (coex_sta->bt_info_c2h[rsp_source][2] & 0x20)
6548 coex_sta->c2h_bt_page = true;
6549 else
6550 coex_sta->c2h_bt_page = false;
6551
6552 if (coex_sta->bt_info_c2h[rsp_source][2] & 0x80)
6553 coex_sta->bt_create_connection = true;
6554 else
6555 coex_sta->bt_create_connection = false;
6556
6557 /* unit: %, value-100 to translate to unit: dBm */
6558 coex_sta->bt_rssi = coex_sta->bt_info_c2h[rsp_source][3] * 2 +
6559 10;
6560
6561 /* coex_sta->bt_info_c2h[rsp_source][3] * 2 - 90; */
6562
6563 if ((coex_sta->bt_info_c2h[rsp_source][1] & 0x49) == 0x49) {
6564 coex_sta->a2dp_bit_pool =
6565 coex_sta->bt_info_c2h[rsp_source][6];
6566 } else
6567 coex_sta->a2dp_bit_pool = 0;
6568
6569 if (coex_sta->bt_info_c2h[rsp_source][1] & 0x9)
6570 coex_sta->acl_busy = true;
6571 else
6572 coex_sta->acl_busy = false;
6573
6574 coex_sta->bt_info_ext =
6575 coex_sta->bt_info_c2h[rsp_source][4];
6576
6577 /* Here we need to resend some wifi info to BT */
6578 /* because bt is reset and loss of the info. */
6579
6580 if ((!btcoexist->manual_control) &&
6581 (!btcoexist->stop_coex_dm)) {
6582
6583 /* Re-Init */
6584 if (coex_sta->bt_info_ext & BIT(1)) {
6585 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6586 "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n");
6587 BTC_TRACE(trace_buf);
6588 btcoexist->btc_get(btcoexist,
6589 BTC_GET_BL_WIFI_CONNECTED,
6590 &wifi_connected);
6591 if (wifi_connected)
6592 halbtc8822b1ant_update_wifi_channel_info(
6593 btcoexist,
6594 BTC_MEDIA_CONNECT);
6595 else
6596 halbtc8822b1ant_update_wifi_channel_info(
6597 btcoexist,
6598 BTC_MEDIA_DISCONNECT);
6599 }
6600
6601 /* If Ignore_WLanAct && not SetUp_Link */
6602 if ((coex_sta->bt_info_ext & BIT(3)) &&
6603 (!(coex_sta->bt_info_ext & BIT(2)))) {
6604
6605 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6606 "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n");
6607 BTC_TRACE(trace_buf);
6608 halbtc8822b1ant_ignore_wlan_act(btcoexist,
6609 FORCE_EXEC,
6610 false);
6611 }
6612 }
6613 /* check BIT2 first ==> check if bt is under inquiry or page scan */
6614 if (bt_info & BT_INFO_8822B_1ANT_B_INQ_PAGE)
6615 coex_sta->c2h_bt_inquiry_page = true;
6616 else
6617 coex_sta->c2h_bt_inquiry_page = false;
6618 }
6619
6620 coex_sta->num_of_profile = 0;
6621
6622 /* set link exist status */
6623 if (!(bt_info & BT_INFO_8822B_1ANT_B_CONNECTION)) {
6624 coex_sta->bt_link_exist = false;
6625 coex_sta->pan_exist = false;
6626 coex_sta->a2dp_exist = false;
6627 coex_sta->hid_exist = false;
6628 coex_sta->sco_exist = false;
6629
6630 coex_sta->bt_hi_pri_link_exist = false;
6631 } else { /* connection exists */
6632 coex_sta->bt_link_exist = true;
6633 if (bt_info & BT_INFO_8822B_1ANT_B_FTP) {
6634 coex_sta->pan_exist = true;
6635 coex_sta->num_of_profile++;
6636 } else
6637 coex_sta->pan_exist = false;
6638 if (bt_info & BT_INFO_8822B_1ANT_B_A2DP) {
6639 coex_sta->a2dp_exist = true;
6640 coex_sta->num_of_profile++;
6641 } else
6642 coex_sta->a2dp_exist = false;
6643 if (bt_info & BT_INFO_8822B_1ANT_B_HID) {
6644 coex_sta->hid_exist = true;
6645 coex_sta->num_of_profile++;
6646 } else
6647 coex_sta->hid_exist = false;
6648 if (bt_info & BT_INFO_8822B_1ANT_B_SCO_ESCO) {
6649 coex_sta->sco_exist = true;
6650 coex_sta->num_of_profile++;
6651 } else
6652 coex_sta->sco_exist = false;
6653
6654 }
6655
6656 halbtc8822b1ant_update_bt_link_info(btcoexist);
6657
6658 bt_info = bt_info &
6659 0x1f; /* mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41) */
6660
6661 if (!(bt_info & BT_INFO_8822B_1ANT_B_CONNECTION)) {
6662 coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
6663 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6664 "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
6665 BTC_TRACE(trace_buf);
6666 } else if (bt_info ==
6667 BT_INFO_8822B_1ANT_B_CONNECTION) { /* connection exists but no busy */
6668 coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_CONNECTED_IDLE;
6669 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6670 "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
6671 BTC_TRACE(trace_buf);
6672 } else if ((bt_info & BT_INFO_8822B_1ANT_B_SCO_ESCO) ||
6673 (bt_info & BT_INFO_8822B_1ANT_B_SCO_BUSY)) {
6674 coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_SCO_BUSY;
6675 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6676 "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
6677 BTC_TRACE(trace_buf);
6678 } else if (bt_info & BT_INFO_8822B_1ANT_B_ACL_BUSY) {
6679 if (BT_8822B_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status)
6680 coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_ACL_BUSY;
6681 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6682 "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
6683 BTC_TRACE(trace_buf);
6684 } else {
6685 coex_dm->bt_status = BT_8822B_1ANT_BT_STATUS_MAX;
6686 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6687 "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n");
6688 BTC_TRACE(trace_buf);
6689 }
6690
6691 if ((BT_8822B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
6692 (BT_8822B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
6693 (BT_8822B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status))
6694 bt_busy = true;
6695 else
6696 bt_busy = false;
6697
6698 btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
6699
6700 halbtc8822b1ant_run_coexist_mechanism(btcoexist);
6701 }
6702
ex_halbtc8822b1ant_rf_status_notify(IN struct btc_coexist * btcoexist,IN u8 type)6703 void ex_halbtc8822b1ant_rf_status_notify(IN struct btc_coexist *btcoexist,
6704 IN u8 type)
6705 {
6706 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], RF Status notify\n");
6707 BTC_TRACE(trace_buf);
6708
6709 if (BTC_RF_ON == type) {
6710 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6711 "[BTCoex], RF is turned ON!!\n");
6712 BTC_TRACE(trace_buf);
6713 btcoexist->stop_coex_dm = false;
6714
6715 halbtc8822b1ant_post_state_to_bt(btcoexist,
6716 BT_8822B_1ANT_SCOREBOARD_ACTIVE, true);
6717 halbtc8822b1ant_post_state_to_bt(btcoexist,
6718 BT_8822B_1ANT_SCOREBOARD_ONOFF, true);
6719
6720 } else if (BTC_RF_OFF == type) {
6721 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6722 "[BTCoex], RF is turned OFF!!\n");
6723 BTC_TRACE(trace_buf);
6724
6725 halbtc8822b1ant_post_state_to_bt(btcoexist,
6726 BT_8822B_1ANT_SCOREBOARD_ACTIVE, false);
6727 halbtc8822b1ant_post_state_to_bt(btcoexist,
6728 BT_8822B_1ANT_SCOREBOARD_ONOFF, false);
6729 halbtc8822b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0);
6730
6731 halbtc8822b1ant_set_ant_path(btcoexist,
6732 BTC_ANT_PATH_AUTO,
6733 FORCE_EXEC,
6734 BT_8822B_1ANT_PHASE_WLAN_OFF);
6735 /* for test : s3 bt disppear , fail rate 1/600*/
6736
6737 halbtc8822b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
6738
6739 btcoexist->stop_coex_dm = true;
6740 }
6741 }
6742
ex_halbtc8822b1ant_halt_notify(IN struct btc_coexist * btcoexist)6743 void ex_halbtc8822b1ant_halt_notify(IN struct btc_coexist *btcoexist)
6744 {
6745
6746 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Halt notify\n");
6747 BTC_TRACE(trace_buf);
6748
6749 halbtc8822b1ant_post_state_to_bt(btcoexist,
6750 BT_8822B_1ANT_SCOREBOARD_ACTIVE, false);
6751 halbtc8822b1ant_post_state_to_bt(btcoexist,
6752 BT_8822B_1ANT_SCOREBOARD_ONOFF, false);
6753
6754 halbtc8822b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0);
6755
6756 halbtc8822b1ant_set_ant_path(btcoexist,
6757 BTC_ANT_PATH_AUTO,
6758 FORCE_EXEC,
6759 BT_8822B_1ANT_PHASE_WLAN_OFF);
6760 /* for test : s3 bt disppear , fail rate 1/600*/
6761
6762 halbtc8822b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
6763
6764 ex_halbtc8822b1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
6765
6766 halbtc8822b1ant_enable_gnt_to_gpio(btcoexist, false);
6767
6768 btcoexist->stop_coex_dm = true;
6769 }
6770
6771
ex_halbtc8822b1ant_pnp_notify(IN struct btc_coexist * btcoexist,IN u8 pnp_state)6772 void ex_halbtc8822b1ant_pnp_notify(IN struct btc_coexist *btcoexist,
6773 IN u8 pnp_state)
6774 {
6775 boolean wifi_under_5g = false;
6776
6777 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE, "[BTCoex], Pnp notify\n");
6778 BTC_TRACE(trace_buf);
6779
6780 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
6781 if (BTC_WIFI_PNP_SLEEP == pnp_state) {
6782 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6783 "[BTCoex], Pnp notify to SLEEP\n");
6784 BTC_TRACE(trace_buf);
6785
6786 halbtc8822b1ant_post_state_to_bt(btcoexist,
6787 BT_8822B_1ANT_SCOREBOARD_ACTIVE, false);
6788 halbtc8822b1ant_post_state_to_bt(btcoexist,
6789 BT_8822B_1ANT_SCOREBOARD_ONOFF, false);
6790 /*
6791 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
6792
6793 halbtc8822b1ant_set_ant_path(btcoexist,
6794 BTC_ANT_PATH_AUTO,
6795 FORCE_EXEC,
6796 BT_8822B_1ANT_PHASE_WLAN_OFF);
6797
6798 halbtc8822b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC,
6799 5);
6800
6801 halbtc8822b1ant_enable_gnt_to_gpio(btcoexist, false);
6802 */
6803 btcoexist->stop_coex_dm = true;
6804 } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) {
6805 /*pnp_wake_cnt++;*/
6806 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6807 "[BTCoex], Pnp notify to WAKE UP\n");
6808 BTC_TRACE(trace_buf);
6809
6810 halbtc8822b1ant_post_state_to_bt(btcoexist,
6811 BT_8822B_1ANT_SCOREBOARD_ACTIVE, true);
6812 halbtc8822b1ant_post_state_to_bt(btcoexist,
6813 BT_8822B_1ANT_SCOREBOARD_ONOFF, true);
6814
6815 btcoexist->stop_coex_dm = false;
6816 }
6817 }
6818
ex_halbtc8822b1ant_coex_dm_reset(IN struct btc_coexist * btcoexist)6819 void ex_halbtc8822b1ant_coex_dm_reset(IN struct btc_coexist *btcoexist)
6820 {
6821 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6822 "[BTCoex], *****************Coex DM Reset*****************\n");
6823 BTC_TRACE(trace_buf);
6824
6825 halbtc8822b1ant_init_hw_config(btcoexist, false, false);
6826 halbtc8822b1ant_init_coex_dm(btcoexist);
6827 }
6828
ex_halbtc8822b1ant_periodical(IN struct btc_coexist * btcoexist)6829 void ex_halbtc8822b1ant_periodical(IN struct btc_coexist *btcoexist)
6830 {
6831
6832 struct btc_board_info *board_info = &btcoexist->board_info;
6833 boolean wifi_busy = false;
6834 u16 bt_scoreboard_val = 0;
6835 u32 bt_patch_ver;
6836 static u8 cnt = 0;
6837 boolean bt_relink_finish = false;
6838 boolean rf4ce_connected = false;
6839
6840 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6841 "[BTCoex], ==========================Periodical===========================\n");
6842 BTC_TRACE(trace_buf);
6843
6844 #if (BT_AUTO_REPORT_ONLY_8822B_1ANT == 0)
6845 halbtc8822b1ant_query_bt_info(btcoexist);
6846 #endif
6847
6848 halbtc8822b1ant_monitor_bt_ctr(btcoexist);
6849 halbtc8822b1ant_monitor_wifi_ctr(btcoexist);
6850
6851 halbtc8822b1ant_monitor_bt_enable_disable(btcoexist);
6852
6853 btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
6854 halbtc8822b1ant_read_score_board(btcoexist, &bt_scoreboard_val);
6855
6856 /*RF4CE for arris , rf4ce always on*/
6857 /*
6858 btcoexist->btc_get(btcoexist, BTC_GET_BL_RF4CE_CONNECTED, &rf4ce_connected);
6859 if (rf4ce_connected){
6860 btcoexist->btc_write_1byte_bitmask(
6861 btcoexist, 0x45e, 0x8, 0x1);
6862
6863 halbtc8822b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
6864 true,
6865 50);
6866
6867 halbtc8822b1ant_coex_table_with_type(btcoexist,
6868 NORMAL_EXEC, 1);
6869 return;
6870 }
6871 */
6872
6873 if (wifi_busy) {
6874 /*WL scoreboard to BT,BT see WL Ccoreboard bit[6]=1 WL BUSY*/
6875 halbtc8822b1ant_post_state_to_bt(btcoexist,
6876 BT_8822B_1ANT_SCOREBOARD_WLBUSY, true);
6877 /*BT scoreboard to WL , let WL see BT scoreboard bit[6]=1*/
6878 if (bt_scoreboard_val & BIT(6))
6879 /*btcoexist->btc_set_bt_wake(btcoexist, 45, 1);*/
6880 halbtc8822b1ant_query_bt_info(btcoexist);
6881 } else {
6882 halbtc8822b1ant_post_state_to_bt(btcoexist,
6883 BT_8822B_1ANT_SCOREBOARD_WLBUSY, false);
6884 }
6885
6886 /* for 4-way, DHCP, EAPOL packet */
6887 if (coex_sta->specific_pkt_period_cnt > 0) {
6888
6889 coex_sta->specific_pkt_period_cnt--;
6890
6891 if ((coex_sta->specific_pkt_period_cnt == 0) &&
6892 (coex_sta->wifi_is_high_pri_task))
6893 coex_sta->wifi_is_high_pri_task = false;
6894
6895 BTC_SPRINTF(trace_buf, BT_TMP_BUF_SIZE,
6896 "[BTCoex], ***************** Hi-Pri Task = %s*****************\n",
6897 (coex_sta->wifi_is_high_pri_task ? "Yes" :
6898 "No"));
6899 BTC_TRACE(trace_buf);
6900 }
6901
6902 if (!coex_sta->bt_disabled) {
6903 if (coex_sta->bt_coex_supported_feature == 0)
6904 btcoexist->btc_get(btcoexist, BTC_GET_U4_SUPPORTED_FEATURE, &coex_sta->bt_coex_supported_feature);
6905
6906 if ((coex_sta->bt_coex_supported_version == 0) ||
6907 (coex_sta->bt_coex_supported_version == 0xffff))
6908 btcoexist->btc_get(btcoexist, BTC_GET_U4_SUPPORTED_VERSION, &coex_sta->bt_coex_supported_version);
6909
6910 btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
6911 btcoexist->bt_info.bt_get_fw_ver = bt_patch_ver;
6912
6913 if (halbtc8822b1ant_is_wifi_status_changed(btcoexist))
6914 halbtc8822b1ant_run_coexist_mechanism(btcoexist);
6915
6916 }
6917 }
6918
ex_halbtc8822b1ant_antenna_detection(IN struct btc_coexist * btcoexist,IN u32 cent_freq,IN u32 offset,IN u32 span,IN u32 seconds)6919 void ex_halbtc8822b1ant_antenna_detection(IN struct btc_coexist *btcoexist,
6920 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds)
6921 {
6922 }
6923
ex_halbtc8822b1ant_antenna_isolation(IN struct btc_coexist * btcoexist,IN u32 cent_freq,IN u32 offset,IN u32 span,IN u32 seconds)6924 void ex_halbtc8822b1ant_antenna_isolation(IN struct btc_coexist *btcoexist,
6925 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds)
6926 {
6927
6928
6929 }
6930
ex_halbtc8822b1ant_psd_scan(IN struct btc_coexist * btcoexist,IN u32 cent_freq,IN u32 offset,IN u32 span,IN u32 seconds)6931 void ex_halbtc8822b1ant_psd_scan(IN struct btc_coexist *btcoexist,
6932 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds)
6933 {
6934
6935
6936 }
6937
ex_halbtc8822b1ant_display_ant_detection(IN struct btc_coexist * btcoexist)6938 void ex_halbtc8822b1ant_display_ant_detection(IN struct btc_coexist *btcoexist)
6939 {
6940
6941 }
6942
ex_halbtc8822b1ant_dbg_control(IN struct btc_coexist * btcoexist,IN u8 op_code,IN u8 op_len,IN u8 * pdata)6943 void ex_halbtc8822b1ant_dbg_control(IN struct btc_coexist *btcoexist,
6944 IN u8 op_code, IN u8 op_len, IN u8 *pdata)
6945 {}
6946 #endif /* #if(BTC_COEX_OFFLOAD == 1) */
6947
6948 #endif
6949
6950 #else
6951
ex_halbtc8822b1ant_switch_band_without_bt(IN struct btc_coexist * btcoexist,IN boolean wifi_only_5g)6952 void ex_halbtc8822b1ant_switch_band_without_bt(IN struct btc_coexist *btcoexist,
6953 IN boolean wifi_only_5g)
6954 {
6955 /* ant switch WL2G or WL5G*/
6956 if (wifi_only_5g)
6957
6958 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd, 0x3, 1);
6959
6960 else
6961
6962 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbd, 0x3, 2);
6963
6964 }
6965
ex_halbtc8822b1ant_init_hw_config_without_bt(IN struct btc_coexist * btcoexist)6966 void ex_halbtc8822b1ant_init_hw_config_without_bt(IN struct btc_coexist
6967 *btcoexist)
6968 {
6969 /* enable GNT_WL */
6970
6971 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x1,
6972 0x0);
6973
6974 /* Antenna config */
6975 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4e,
6976 0x80, 0x0); /* 0x4c[23] = 0 */
6977 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x4f,
6978 0x01, 0x1); /* 0x4c[24] = 1 */
6979 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb4,
6980 0xff, 0x77); /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as conctrol pin */
6981
6982
6983 /* Ext switch buffer mux */
6984 btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
6985 btcoexist->btc_write_1byte_bitmask(btcoexist, 0x1991,
6986 0x3, 0x0);
6987 btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcbe,
6988 0x8, 0x0);
6989
6990 /*enable sw control gnt_wl=1 / gnt_bt=1 */
6991 btcoexist->btc_write_1byte(btcoexist, 0x73, 0x0e);
6992
6993 btcoexist->btc_write_4byte(btcoexist, 0x1704,
6994 0x0000ff00);
6995
6996 btcoexist->btc_write_4byte(btcoexist, 0x1700,
6997 0xc00f0038);
6998 }
6999
7000 #endif /* #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1) */
7001
7002
7003
7004