162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* Copyright(c) 2012 Realtek Corporation.*/ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci/*************************************************************** 562306a36Sopenharmony_ci * Description: 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * This file is for RTL8723B Co-exist mechanism 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * History 1062306a36Sopenharmony_ci * 2012/11/15 Cosa first check in. 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci ***************************************************************/ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/*************************************************************** 1562306a36Sopenharmony_ci * include files 1662306a36Sopenharmony_ci ***************************************************************/ 1762306a36Sopenharmony_ci#include "halbt_precomp.h" 1862306a36Sopenharmony_ci/*************************************************************** 1962306a36Sopenharmony_ci * Global variables, these are static variables 2062306a36Sopenharmony_ci ***************************************************************/ 2162306a36Sopenharmony_cistatic struct coex_dm_8723b_1ant glcoex_dm_8723b_1ant; 2262306a36Sopenharmony_cistatic struct coex_dm_8723b_1ant *coex_dm = &glcoex_dm_8723b_1ant; 2362306a36Sopenharmony_cistatic struct coex_sta_8723b_1ant glcoex_sta_8723b_1ant; 2462306a36Sopenharmony_cistatic struct coex_sta_8723b_1ant *coex_sta = &glcoex_sta_8723b_1ant; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistatic const char *const glbt_info_src_8723b_1ant[] = { 2762306a36Sopenharmony_ci "BT Info[wifi fw]", 2862306a36Sopenharmony_ci "BT Info[bt rsp]", 2962306a36Sopenharmony_ci "BT Info[bt auto report]", 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistatic u32 glcoex_ver_date_8723b_1ant = 20130918; 3362306a36Sopenharmony_cistatic u32 glcoex_ver_8723b_1ant = 0x47; 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/*************************************************************** 3662306a36Sopenharmony_ci * local function proto type if needed 3762306a36Sopenharmony_ci ***************************************************************/ 3862306a36Sopenharmony_ci/*************************************************************** 3962306a36Sopenharmony_ci * local function start with halbtc8723b1ant_ 4062306a36Sopenharmony_ci ***************************************************************/ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_cistatic void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist, 4362306a36Sopenharmony_ci bool force_exec, u32 dis_rate_mask) 4462306a36Sopenharmony_ci{ 4562306a36Sopenharmony_ci coex_dm->curra_mask = dis_rate_mask; 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci if (force_exec || (coex_dm->prera_mask != coex_dm->curra_mask)) 4862306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_RAMASK, 4962306a36Sopenharmony_ci &coex_dm->curra_mask); 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci coex_dm->prera_mask = coex_dm->curra_mask; 5262306a36Sopenharmony_ci} 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistatic void btc8723b1ant_auto_rate_fb_retry(struct btc_coexist *btcoexist, 5562306a36Sopenharmony_ci bool force_exec, u8 type) 5662306a36Sopenharmony_ci{ 5762306a36Sopenharmony_ci bool wifi_under_bmode = false; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci coex_dm->cur_arfr_type = type; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) { 6262306a36Sopenharmony_ci switch (coex_dm->cur_arfr_type) { 6362306a36Sopenharmony_ci case 0: /* normal mode */ 6462306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x430, 6562306a36Sopenharmony_ci coex_dm->backup_arfr_cnt1); 6662306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x434, 6762306a36Sopenharmony_ci coex_dm->backup_arfr_cnt2); 6862306a36Sopenharmony_ci break; 6962306a36Sopenharmony_ci case 1: 7062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, 7162306a36Sopenharmony_ci BTC_GET_BL_WIFI_UNDER_B_MODE, 7262306a36Sopenharmony_ci &wifi_under_bmode); 7362306a36Sopenharmony_ci if (wifi_under_bmode) { 7462306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 7562306a36Sopenharmony_ci 0x430, 0x0); 7662306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 7762306a36Sopenharmony_ci 0x434, 0x01010101); 7862306a36Sopenharmony_ci } else { 7962306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 8062306a36Sopenharmony_ci 0x430, 0x0); 8162306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 8262306a36Sopenharmony_ci 0x434, 0x04030201); 8362306a36Sopenharmony_ci } 8462306a36Sopenharmony_ci break; 8562306a36Sopenharmony_ci default: 8662306a36Sopenharmony_ci break; 8762306a36Sopenharmony_ci } 8862306a36Sopenharmony_ci } 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci coex_dm->pre_arfr_type = coex_dm->cur_arfr_type; 9162306a36Sopenharmony_ci} 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistatic void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist, 9462306a36Sopenharmony_ci bool force_exec, u8 type) 9562306a36Sopenharmony_ci{ 9662306a36Sopenharmony_ci coex_dm->cur_retry_limit_type = type; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci if (force_exec || (coex_dm->pre_retry_limit_type != 9962306a36Sopenharmony_ci coex_dm->cur_retry_limit_type)) { 10062306a36Sopenharmony_ci switch (coex_dm->cur_retry_limit_type) { 10162306a36Sopenharmony_ci case 0: /* normal mode */ 10262306a36Sopenharmony_ci btcoexist->btc_write_2byte(btcoexist, 0x42a, 10362306a36Sopenharmony_ci coex_dm->backup_retry_limit); 10462306a36Sopenharmony_ci break; 10562306a36Sopenharmony_ci case 1: /* retry limit = 8 */ 10662306a36Sopenharmony_ci btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808); 10762306a36Sopenharmony_ci break; 10862306a36Sopenharmony_ci default: 10962306a36Sopenharmony_ci break; 11062306a36Sopenharmony_ci } 11162306a36Sopenharmony_ci } 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type; 11462306a36Sopenharmony_ci} 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_cistatic void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist, 11762306a36Sopenharmony_ci bool force_exec, u8 type) 11862306a36Sopenharmony_ci{ 11962306a36Sopenharmony_ci coex_dm->cur_ampdu_time_type = type; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci if (force_exec || (coex_dm->pre_ampdu_time_type != 12262306a36Sopenharmony_ci coex_dm->cur_ampdu_time_type)) { 12362306a36Sopenharmony_ci switch (coex_dm->cur_ampdu_time_type) { 12462306a36Sopenharmony_ci case 0: /* normal mode */ 12562306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x456, 12662306a36Sopenharmony_ci coex_dm->backup_ampdu_max_time); 12762306a36Sopenharmony_ci break; 12862306a36Sopenharmony_ci case 1: /* AMPDU timw = 0x38 * 32us */ 12962306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x456, 0x38); 13062306a36Sopenharmony_ci break; 13162306a36Sopenharmony_ci default: 13262306a36Sopenharmony_ci break; 13362306a36Sopenharmony_ci } 13462306a36Sopenharmony_ci } 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type; 13762306a36Sopenharmony_ci} 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_cistatic void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist, 14062306a36Sopenharmony_ci bool force_exec, u8 ra_masktype, 14162306a36Sopenharmony_ci u8 arfr_type, u8 retry_limit_type, 14262306a36Sopenharmony_ci u8 ampdu_time_type) 14362306a36Sopenharmony_ci{ 14462306a36Sopenharmony_ci switch (ra_masktype) { 14562306a36Sopenharmony_ci case 0: /* normal mode */ 14662306a36Sopenharmony_ci halbtc8723b1ant_updatera_mask(btcoexist, force_exec, 0x0); 14762306a36Sopenharmony_ci break; 14862306a36Sopenharmony_ci case 1: /* disable cck 1/2 */ 14962306a36Sopenharmony_ci halbtc8723b1ant_updatera_mask(btcoexist, force_exec, 15062306a36Sopenharmony_ci 0x00000003); 15162306a36Sopenharmony_ci break; 15262306a36Sopenharmony_ci /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */ 15362306a36Sopenharmony_ci case 2: 15462306a36Sopenharmony_ci halbtc8723b1ant_updatera_mask(btcoexist, force_exec, 15562306a36Sopenharmony_ci 0x0001f1f7); 15662306a36Sopenharmony_ci break; 15762306a36Sopenharmony_ci default: 15862306a36Sopenharmony_ci break; 15962306a36Sopenharmony_ci } 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci btc8723b1ant_auto_rate_fb_retry(btcoexist, force_exec, arfr_type); 16262306a36Sopenharmony_ci halbtc8723b1ant_retry_limit(btcoexist, force_exec, retry_limit_type); 16362306a36Sopenharmony_ci halbtc8723b1ant_ampdu_maxtime(btcoexist, force_exec, ampdu_time_type); 16462306a36Sopenharmony_ci} 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_cistatic void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist, 16762306a36Sopenharmony_ci bool force_exec, bool rej_ap_agg_pkt, 16862306a36Sopenharmony_ci bool bt_ctrl_agg_buf_size, 16962306a36Sopenharmony_ci u8 agg_buf_size) 17062306a36Sopenharmony_ci{ 17162306a36Sopenharmony_ci bool reject_rx_agg = rej_ap_agg_pkt; 17262306a36Sopenharmony_ci bool bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size; 17362306a36Sopenharmony_ci u8 rxaggsize = agg_buf_size; 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci /********************************************** 17662306a36Sopenharmony_ci * Rx Aggregation related setting 17762306a36Sopenharmony_ci **********************************************/ 17862306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, 17962306a36Sopenharmony_ci &reject_rx_agg); 18062306a36Sopenharmony_ci /* decide BT control aggregation buf size or not */ 18162306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, 18262306a36Sopenharmony_ci &bt_ctrl_rx_agg_size); 18362306a36Sopenharmony_ci /* aggregation buf size, only work 18462306a36Sopenharmony_ci * when BT control Rx aggregation size. 18562306a36Sopenharmony_ci */ 18662306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxaggsize); 18762306a36Sopenharmony_ci /* real update aggregation setting */ 18862306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); 18962306a36Sopenharmony_ci} 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_cistatic void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist) 19262306a36Sopenharmony_ci{ 19362306a36Sopenharmony_ci u8 h2c_parameter[1] = {0}; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci coex_sta->c2h_bt_info_req_sent = true; 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci /* trigger */ 19862306a36Sopenharmony_ci h2c_parameter[0] |= BIT(0); 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); 20162306a36Sopenharmony_ci} 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_cistatic void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) 20462306a36Sopenharmony_ci{ 20562306a36Sopenharmony_ci u32 reg_hp_txrx, reg_lp_txrx, u32tmp; 20662306a36Sopenharmony_ci u32 reg_hp_tx = 0, reg_hp_rx = 0; 20762306a36Sopenharmony_ci u32 reg_lp_tx = 0, reg_lp_rx = 0; 20862306a36Sopenharmony_ci static u32 num_of_bt_counter_chk; 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci reg_hp_txrx = 0x770; 21162306a36Sopenharmony_ci reg_lp_txrx = 0x774; 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); 21462306a36Sopenharmony_ci reg_hp_tx = u32tmp & MASKLWORD; 21562306a36Sopenharmony_ci reg_hp_rx = (u32tmp & MASKHWORD) >> 16; 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); 21862306a36Sopenharmony_ci reg_lp_tx = u32tmp & MASKLWORD; 21962306a36Sopenharmony_ci reg_lp_rx = (u32tmp & MASKHWORD) >> 16; 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci coex_sta->high_priority_tx = reg_hp_tx; 22262306a36Sopenharmony_ci coex_sta->high_priority_rx = reg_hp_rx; 22362306a36Sopenharmony_ci coex_sta->low_priority_tx = reg_lp_tx; 22462306a36Sopenharmony_ci coex_sta->low_priority_rx = reg_lp_rx; 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci if ((coex_sta->low_priority_tx > 1050) && 22762306a36Sopenharmony_ci (!coex_sta->c2h_bt_inquiry_page)) 22862306a36Sopenharmony_ci coex_sta->pop_event_cnt++; 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci /* reset counter */ 23162306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci /* This part is for wifi FW and driver to update BT's status as 23462306a36Sopenharmony_ci * disabled. 23562306a36Sopenharmony_ci * 23662306a36Sopenharmony_ci * The flow is as the following 23762306a36Sopenharmony_ci * 1. disable BT 23862306a36Sopenharmony_ci * 2. if all BT Tx/Rx counter = 0, after 6 sec we query bt info 23962306a36Sopenharmony_ci * 3. Because BT will not rsp from mailbox, so wifi fw will know BT is 24062306a36Sopenharmony_ci * disabled 24162306a36Sopenharmony_ci * 24262306a36Sopenharmony_ci * 4. FW will rsp c2h for BT that driver will know BT is disabled. 24362306a36Sopenharmony_ci */ 24462306a36Sopenharmony_ci if ((reg_hp_tx == 0) && (reg_hp_rx == 0) && (reg_lp_tx == 0) && 24562306a36Sopenharmony_ci (reg_lp_rx == 0)) { 24662306a36Sopenharmony_ci num_of_bt_counter_chk++; 24762306a36Sopenharmony_ci if (num_of_bt_counter_chk == 3) 24862306a36Sopenharmony_ci halbtc8723b1ant_query_bt_info(btcoexist); 24962306a36Sopenharmony_ci } else { 25062306a36Sopenharmony_ci num_of_bt_counter_chk = 0; 25162306a36Sopenharmony_ci } 25262306a36Sopenharmony_ci} 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_cistatic void halbtc8723b1ant_monitor_wifi_ctr(struct btc_coexist *btcoexist) 25562306a36Sopenharmony_ci{ 25662306a36Sopenharmony_ci s32 wifi_rssi = 0; 25762306a36Sopenharmony_ci bool wifi_busy = false, wifi_under_b_mode = false; 25862306a36Sopenharmony_ci static u8 cck_lock_counter; 25962306a36Sopenharmony_ci u32 total_cnt; 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 26262306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); 26362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, 26462306a36Sopenharmony_ci &wifi_under_b_mode); 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci if (coex_sta->under_ips) { 26762306a36Sopenharmony_ci coex_sta->crc_ok_cck = 0; 26862306a36Sopenharmony_ci coex_sta->crc_ok_11g = 0; 26962306a36Sopenharmony_ci coex_sta->crc_ok_11n = 0; 27062306a36Sopenharmony_ci coex_sta->crc_ok_11n_agg = 0; 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ci coex_sta->crc_err_cck = 0; 27362306a36Sopenharmony_ci coex_sta->crc_err_11g = 0; 27462306a36Sopenharmony_ci coex_sta->crc_err_11n = 0; 27562306a36Sopenharmony_ci coex_sta->crc_err_11n_agg = 0; 27662306a36Sopenharmony_ci } else { 27762306a36Sopenharmony_ci coex_sta->crc_ok_cck = 27862306a36Sopenharmony_ci btcoexist->btc_read_4byte(btcoexist, 0xf88); 27962306a36Sopenharmony_ci coex_sta->crc_ok_11g = 28062306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0xf94); 28162306a36Sopenharmony_ci coex_sta->crc_ok_11n = 28262306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0xf90); 28362306a36Sopenharmony_ci coex_sta->crc_ok_11n_agg = 28462306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0xfb8); 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci coex_sta->crc_err_cck = 28762306a36Sopenharmony_ci btcoexist->btc_read_4byte(btcoexist, 0xf84); 28862306a36Sopenharmony_ci coex_sta->crc_err_11g = 28962306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0xf96); 29062306a36Sopenharmony_ci coex_sta->crc_err_11n = 29162306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0xf92); 29262306a36Sopenharmony_ci coex_sta->crc_err_11n_agg = 29362306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0xfba); 29462306a36Sopenharmony_ci } 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci /* reset counter */ 29762306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x1); 29862306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0xf16, 0x1, 0x0); 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci if ((wifi_busy) && (wifi_rssi >= 30) && (!wifi_under_b_mode)) { 30162306a36Sopenharmony_ci total_cnt = coex_sta->crc_ok_cck + coex_sta->crc_ok_11g + 30262306a36Sopenharmony_ci coex_sta->crc_ok_11n + coex_sta->crc_ok_11n_agg; 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci if ((coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) || 30562306a36Sopenharmony_ci (coex_dm->bt_status == 30662306a36Sopenharmony_ci BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) || 30762306a36Sopenharmony_ci (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_SCO_BUSY)) { 30862306a36Sopenharmony_ci if (coex_sta->crc_ok_cck > 30962306a36Sopenharmony_ci (total_cnt - coex_sta->crc_ok_cck)) { 31062306a36Sopenharmony_ci if (cck_lock_counter < 3) 31162306a36Sopenharmony_ci cck_lock_counter++; 31262306a36Sopenharmony_ci } else { 31362306a36Sopenharmony_ci if (cck_lock_counter > 0) 31462306a36Sopenharmony_ci cck_lock_counter--; 31562306a36Sopenharmony_ci } 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci } else { 31862306a36Sopenharmony_ci if (cck_lock_counter > 0) 31962306a36Sopenharmony_ci cck_lock_counter--; 32062306a36Sopenharmony_ci } 32162306a36Sopenharmony_ci } else { 32262306a36Sopenharmony_ci if (cck_lock_counter > 0) 32362306a36Sopenharmony_ci cck_lock_counter--; 32462306a36Sopenharmony_ci } 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_ci if (!coex_sta->pre_ccklock) { 32762306a36Sopenharmony_ci if (cck_lock_counter >= 3) 32862306a36Sopenharmony_ci coex_sta->cck_lock = true; 32962306a36Sopenharmony_ci else 33062306a36Sopenharmony_ci coex_sta->cck_lock = false; 33162306a36Sopenharmony_ci } else { 33262306a36Sopenharmony_ci if (cck_lock_counter == 0) 33362306a36Sopenharmony_ci coex_sta->cck_lock = false; 33462306a36Sopenharmony_ci else 33562306a36Sopenharmony_ci coex_sta->cck_lock = true; 33662306a36Sopenharmony_ci } 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci if (coex_sta->cck_lock) 33962306a36Sopenharmony_ci coex_sta->cck_ever_lock = true; 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci coex_sta->pre_ccklock = coex_sta->cck_lock; 34262306a36Sopenharmony_ci} 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_cistatic bool btc8723b1ant_is_wifi_status_changed(struct btc_coexist *btcoexist) 34562306a36Sopenharmony_ci{ 34662306a36Sopenharmony_ci static bool pre_wifi_busy; 34762306a36Sopenharmony_ci static bool pre_under_4way, pre_bt_hs_on; 34862306a36Sopenharmony_ci bool wifi_busy = false, under_4way = false, bt_hs_on = false; 34962306a36Sopenharmony_ci bool wifi_connected = false; 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 35262306a36Sopenharmony_ci &wifi_connected); 35362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 35462306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 35562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, 35662306a36Sopenharmony_ci &under_4way); 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ci if (wifi_connected) { 35962306a36Sopenharmony_ci if (wifi_busy != pre_wifi_busy) { 36062306a36Sopenharmony_ci pre_wifi_busy = wifi_busy; 36162306a36Sopenharmony_ci return true; 36262306a36Sopenharmony_ci } 36362306a36Sopenharmony_ci if (under_4way != pre_under_4way) { 36462306a36Sopenharmony_ci pre_under_4way = under_4way; 36562306a36Sopenharmony_ci return true; 36662306a36Sopenharmony_ci } 36762306a36Sopenharmony_ci if (bt_hs_on != pre_bt_hs_on) { 36862306a36Sopenharmony_ci pre_bt_hs_on = bt_hs_on; 36962306a36Sopenharmony_ci return true; 37062306a36Sopenharmony_ci } 37162306a36Sopenharmony_ci } 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci return false; 37462306a36Sopenharmony_ci} 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_cistatic void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist) 37762306a36Sopenharmony_ci{ 37862306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 37962306a36Sopenharmony_ci bool bt_hs_on = false; 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci bt_link_info->bt_link_exist = coex_sta->bt_link_exist; 38462306a36Sopenharmony_ci bt_link_info->sco_exist = coex_sta->sco_exist; 38562306a36Sopenharmony_ci bt_link_info->a2dp_exist = coex_sta->a2dp_exist; 38662306a36Sopenharmony_ci bt_link_info->pan_exist = coex_sta->pan_exist; 38762306a36Sopenharmony_ci bt_link_info->hid_exist = coex_sta->hid_exist; 38862306a36Sopenharmony_ci bt_link_info->bt_hi_pri_link_exist = coex_sta->bt_hi_pri_link_exist; 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci /* work around for HS mode. */ 39162306a36Sopenharmony_ci if (bt_hs_on) { 39262306a36Sopenharmony_ci bt_link_info->pan_exist = true; 39362306a36Sopenharmony_ci bt_link_info->bt_link_exist = true; 39462306a36Sopenharmony_ci } 39562306a36Sopenharmony_ci 39662306a36Sopenharmony_ci /* check if Sco only */ 39762306a36Sopenharmony_ci if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist && 39862306a36Sopenharmony_ci !bt_link_info->pan_exist && !bt_link_info->hid_exist) 39962306a36Sopenharmony_ci bt_link_info->sco_only = true; 40062306a36Sopenharmony_ci else 40162306a36Sopenharmony_ci bt_link_info->sco_only = false; 40262306a36Sopenharmony_ci 40362306a36Sopenharmony_ci /* check if A2dp only */ 40462306a36Sopenharmony_ci if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist && 40562306a36Sopenharmony_ci !bt_link_info->pan_exist && !bt_link_info->hid_exist) 40662306a36Sopenharmony_ci bt_link_info->a2dp_only = true; 40762306a36Sopenharmony_ci else 40862306a36Sopenharmony_ci bt_link_info->a2dp_only = false; 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci /* check if Pan only */ 41162306a36Sopenharmony_ci if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && 41262306a36Sopenharmony_ci bt_link_info->pan_exist && !bt_link_info->hid_exist) 41362306a36Sopenharmony_ci bt_link_info->pan_only = true; 41462306a36Sopenharmony_ci else 41562306a36Sopenharmony_ci bt_link_info->pan_only = false; 41662306a36Sopenharmony_ci 41762306a36Sopenharmony_ci /* check if Hid only */ 41862306a36Sopenharmony_ci if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && 41962306a36Sopenharmony_ci !bt_link_info->pan_exist && bt_link_info->hid_exist) 42062306a36Sopenharmony_ci bt_link_info->hid_only = true; 42162306a36Sopenharmony_ci else 42262306a36Sopenharmony_ci bt_link_info->hid_only = false; 42362306a36Sopenharmony_ci} 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_cistatic void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist, 42662306a36Sopenharmony_ci bool enable_auto_report) 42762306a36Sopenharmony_ci{ 42862306a36Sopenharmony_ci u8 h2c_parameter[1] = {0}; 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci h2c_parameter[0] = 0; 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_ci if (enable_auto_report) 43362306a36Sopenharmony_ci h2c_parameter[0] |= BIT(0); 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); 43662306a36Sopenharmony_ci} 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_cistatic void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist, 43962306a36Sopenharmony_ci bool force_exec, 44062306a36Sopenharmony_ci bool enable_auto_report) 44162306a36Sopenharmony_ci{ 44262306a36Sopenharmony_ci coex_dm->cur_bt_auto_report = enable_auto_report; 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci if (!force_exec) { 44562306a36Sopenharmony_ci if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report) 44662306a36Sopenharmony_ci return; 44762306a36Sopenharmony_ci } 44862306a36Sopenharmony_ci halbtc8723b1ant_set_bt_auto_report(btcoexist, 44962306a36Sopenharmony_ci coex_dm->cur_bt_auto_report); 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_ci coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; 45262306a36Sopenharmony_ci} 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_cistatic void btc8723b1ant_set_sw_pen_tx_rate_adapt(struct btc_coexist *btcoexist, 45562306a36Sopenharmony_ci bool low_penalty_ra) 45662306a36Sopenharmony_ci{ 45762306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 45862306a36Sopenharmony_ci u8 h2c_parameter[6] = {0}; 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ci h2c_parameter[0] = 0x6; /* opCode, 0x6= Retry_Penalty */ 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci if (low_penalty_ra) { 46362306a36Sopenharmony_ci h2c_parameter[1] |= BIT0; 46462306a36Sopenharmony_ci /* normal rate except MCS7/6/5, OFDM54/48/36 */ 46562306a36Sopenharmony_ci h2c_parameter[2] = 0x00; 46662306a36Sopenharmony_ci h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */ 46762306a36Sopenharmony_ci h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */ 46862306a36Sopenharmony_ci h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */ 46962306a36Sopenharmony_ci } 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 47262306a36Sopenharmony_ci "[BTCoex], set WiFi Low-Penalty Retry: %s", 47362306a36Sopenharmony_ci (low_penalty_ra ? "ON!!" : "OFF!!")); 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); 47662306a36Sopenharmony_ci} 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_cistatic void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, 47962306a36Sopenharmony_ci bool force_exec, bool low_penalty_ra) 48062306a36Sopenharmony_ci{ 48162306a36Sopenharmony_ci coex_dm->cur_low_penalty_ra = low_penalty_ra; 48262306a36Sopenharmony_ci 48362306a36Sopenharmony_ci if (!force_exec) { 48462306a36Sopenharmony_ci if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) 48562306a36Sopenharmony_ci return; 48662306a36Sopenharmony_ci } 48762306a36Sopenharmony_ci btc8723b1ant_set_sw_pen_tx_rate_adapt(btcoexist, 48862306a36Sopenharmony_ci coex_dm->cur_low_penalty_ra); 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_ci coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; 49162306a36Sopenharmony_ci} 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_cistatic void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, 49462306a36Sopenharmony_ci u32 val0x6c0, u32 val0x6c4, 49562306a36Sopenharmony_ci u32 val0x6c8, u8 val0x6cc) 49662306a36Sopenharmony_ci{ 49762306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 50062306a36Sopenharmony_ci "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); 50162306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 50462306a36Sopenharmony_ci "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); 50562306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 50862306a36Sopenharmony_ci "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); 50962306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 51262306a36Sopenharmony_ci "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); 51362306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); 51462306a36Sopenharmony_ci} 51562306a36Sopenharmony_ci 51662306a36Sopenharmony_cistatic void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist, 51762306a36Sopenharmony_ci bool force_exec, u32 val0x6c0, 51862306a36Sopenharmony_ci u32 val0x6c4, u32 val0x6c8, 51962306a36Sopenharmony_ci u8 val0x6cc) 52062306a36Sopenharmony_ci{ 52162306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 52462306a36Sopenharmony_ci "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6cc = 0x%x\n", 52562306a36Sopenharmony_ci (force_exec ? "force to" : ""), 52662306a36Sopenharmony_ci val0x6c0, val0x6c4, val0x6cc); 52762306a36Sopenharmony_ci coex_dm->cur_val0x6c0 = val0x6c0; 52862306a36Sopenharmony_ci coex_dm->cur_val0x6c4 = val0x6c4; 52962306a36Sopenharmony_ci coex_dm->cur_val0x6c8 = val0x6c8; 53062306a36Sopenharmony_ci coex_dm->cur_val0x6cc = val0x6cc; 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_ci if (!force_exec) { 53362306a36Sopenharmony_ci if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && 53462306a36Sopenharmony_ci (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && 53562306a36Sopenharmony_ci (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && 53662306a36Sopenharmony_ci (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) 53762306a36Sopenharmony_ci return; 53862306a36Sopenharmony_ci } 53962306a36Sopenharmony_ci halbtc8723b1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, 54062306a36Sopenharmony_ci val0x6c8, val0x6cc); 54162306a36Sopenharmony_ci 54262306a36Sopenharmony_ci coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; 54362306a36Sopenharmony_ci coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; 54462306a36Sopenharmony_ci coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; 54562306a36Sopenharmony_ci coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; 54662306a36Sopenharmony_ci} 54762306a36Sopenharmony_ci 54862306a36Sopenharmony_cistatic void halbtc8723b1ant_coex_table_with_type(struct btc_coexist *btcoexist, 54962306a36Sopenharmony_ci bool force_exec, u8 type) 55062306a36Sopenharmony_ci{ 55162306a36Sopenharmony_ci coex_sta->coex_table_type = type; 55262306a36Sopenharmony_ci 55362306a36Sopenharmony_ci switch (type) { 55462306a36Sopenharmony_ci case 0: 55562306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, 55662306a36Sopenharmony_ci 0x55555555, 0xffffff, 0x3); 55762306a36Sopenharmony_ci break; 55862306a36Sopenharmony_ci case 1: 55962306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, 56062306a36Sopenharmony_ci 0x5a5a5a5a, 0xffffff, 0x3); 56162306a36Sopenharmony_ci break; 56262306a36Sopenharmony_ci case 2: 56362306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, 56462306a36Sopenharmony_ci 0x5a5a5a5a, 0xffffff, 0x3); 56562306a36Sopenharmony_ci break; 56662306a36Sopenharmony_ci case 3: 56762306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, 56862306a36Sopenharmony_ci 0x5a5a5a5a, 0xffffff, 0x3); 56962306a36Sopenharmony_ci break; 57062306a36Sopenharmony_ci case 4: 57162306a36Sopenharmony_ci if ((coex_sta->cck_ever_lock) && (coex_sta->scan_ap_num <= 5)) 57262306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 57362306a36Sopenharmony_ci 0x55555555, 0xaaaa5a5a, 57462306a36Sopenharmony_ci 0xffffff, 0x3); 57562306a36Sopenharmony_ci else 57662306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 57762306a36Sopenharmony_ci 0x55555555, 0x5a5a5a5a, 57862306a36Sopenharmony_ci 0xffffff, 0x3); 57962306a36Sopenharmony_ci break; 58062306a36Sopenharmony_ci case 5: 58162306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, 58262306a36Sopenharmony_ci 0x5aaa5a5a, 0xffffff, 0x3); 58362306a36Sopenharmony_ci break; 58462306a36Sopenharmony_ci case 6: 58562306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, 58662306a36Sopenharmony_ci 0xaaaaaaaa, 0xffffff, 0x3); 58762306a36Sopenharmony_ci break; 58862306a36Sopenharmony_ci case 7: 58962306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa, 59062306a36Sopenharmony_ci 0xaaaaaaaa, 0xffffff, 0x3); 59162306a36Sopenharmony_ci break; 59262306a36Sopenharmony_ci case 8: 59362306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55dd55dd, 59462306a36Sopenharmony_ci 0x5ada5ada, 0xffffff, 0x3); 59562306a36Sopenharmony_ci break; 59662306a36Sopenharmony_ci case 9: 59762306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55dd55dd, 59862306a36Sopenharmony_ci 0x5ada5ada, 0xffffff, 0x3); 59962306a36Sopenharmony_ci break; 60062306a36Sopenharmony_ci case 10: 60162306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55dd55dd, 60262306a36Sopenharmony_ci 0x5ada5ada, 0xffffff, 0x3); 60362306a36Sopenharmony_ci break; 60462306a36Sopenharmony_ci case 11: 60562306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55dd55dd, 60662306a36Sopenharmony_ci 0x5ada5ada, 0xffffff, 0x3); 60762306a36Sopenharmony_ci break; 60862306a36Sopenharmony_ci case 12: 60962306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55dd55dd, 61062306a36Sopenharmony_ci 0x5ada5ada, 0xffffff, 0x3); 61162306a36Sopenharmony_ci break; 61262306a36Sopenharmony_ci case 13: 61362306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5fff5fff, 61462306a36Sopenharmony_ci 0xaaaaaaaa, 0xffffff, 0x3); 61562306a36Sopenharmony_ci break; 61662306a36Sopenharmony_ci case 14: 61762306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5fff5fff, 61862306a36Sopenharmony_ci 0x5ada5ada, 0xffffff, 0x3); 61962306a36Sopenharmony_ci break; 62062306a36Sopenharmony_ci case 15: 62162306a36Sopenharmony_ci halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55dd55dd, 62262306a36Sopenharmony_ci 0xaaaaaaaa, 0xffffff, 0x3); 62362306a36Sopenharmony_ci break; 62462306a36Sopenharmony_ci default: 62562306a36Sopenharmony_ci break; 62662306a36Sopenharmony_ci } 62762306a36Sopenharmony_ci} 62862306a36Sopenharmony_ci 62962306a36Sopenharmony_cistatic void 63062306a36Sopenharmony_cihalbtc8723b1ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, 63162306a36Sopenharmony_ci bool enable) 63262306a36Sopenharmony_ci{ 63362306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 63462306a36Sopenharmony_ci u8 h2c_parameter[1] = {0}; 63562306a36Sopenharmony_ci 63662306a36Sopenharmony_ci if (enable) 63762306a36Sopenharmony_ci h2c_parameter[0] |= BIT0; /* function enable */ 63862306a36Sopenharmony_ci 63962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 64062306a36Sopenharmony_ci "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", 64162306a36Sopenharmony_ci h2c_parameter[0]); 64262306a36Sopenharmony_ci 64362306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); 64462306a36Sopenharmony_ci} 64562306a36Sopenharmony_ci 64662306a36Sopenharmony_cistatic void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist, 64762306a36Sopenharmony_ci bool force_exec, bool enable) 64862306a36Sopenharmony_ci{ 64962306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 65062306a36Sopenharmony_ci 65162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 65262306a36Sopenharmony_ci "[BTCoex], %s turn Ignore WlanAct %s\n", 65362306a36Sopenharmony_ci (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); 65462306a36Sopenharmony_ci coex_dm->cur_ignore_wlan_act = enable; 65562306a36Sopenharmony_ci 65662306a36Sopenharmony_ci if (!force_exec) { 65762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 65862306a36Sopenharmony_ci "[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", 65962306a36Sopenharmony_ci coex_dm->pre_ignore_wlan_act, 66062306a36Sopenharmony_ci coex_dm->cur_ignore_wlan_act); 66162306a36Sopenharmony_ci 66262306a36Sopenharmony_ci if (coex_dm->pre_ignore_wlan_act == 66362306a36Sopenharmony_ci coex_dm->cur_ignore_wlan_act) 66462306a36Sopenharmony_ci return; 66562306a36Sopenharmony_ci } 66662306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ignore_wlan_act(btcoexist, enable); 66762306a36Sopenharmony_ci 66862306a36Sopenharmony_ci coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; 66962306a36Sopenharmony_ci} 67062306a36Sopenharmony_ci 67162306a36Sopenharmony_cistatic void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, 67262306a36Sopenharmony_ci u8 byte1, u8 byte2, u8 byte3, 67362306a36Sopenharmony_ci u8 byte4, u8 byte5) 67462306a36Sopenharmony_ci{ 67562306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 67662306a36Sopenharmony_ci u8 h2c_parameter[5] = {0}; 67762306a36Sopenharmony_ci u8 real_byte1 = byte1, real_byte5 = byte5; 67862306a36Sopenharmony_ci bool ap_enable = false; 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, 68162306a36Sopenharmony_ci &ap_enable); 68262306a36Sopenharmony_ci 68362306a36Sopenharmony_ci if (ap_enable) { 68462306a36Sopenharmony_ci if ((byte1 & BIT4) && !(byte1 & BIT5)) { 68562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 68662306a36Sopenharmony_ci "[BTCoex], FW for 1Ant AP mode\n"); 68762306a36Sopenharmony_ci real_byte1 &= ~BIT4; 68862306a36Sopenharmony_ci real_byte1 |= BIT5; 68962306a36Sopenharmony_ci 69062306a36Sopenharmony_ci real_byte5 |= BIT5; 69162306a36Sopenharmony_ci real_byte5 &= ~BIT6; 69262306a36Sopenharmony_ci } 69362306a36Sopenharmony_ci } 69462306a36Sopenharmony_ci 69562306a36Sopenharmony_ci h2c_parameter[0] = real_byte1; 69662306a36Sopenharmony_ci h2c_parameter[1] = byte2; 69762306a36Sopenharmony_ci h2c_parameter[2] = byte3; 69862306a36Sopenharmony_ci h2c_parameter[3] = byte4; 69962306a36Sopenharmony_ci h2c_parameter[4] = real_byte5; 70062306a36Sopenharmony_ci 70162306a36Sopenharmony_ci coex_dm->ps_tdma_para[0] = real_byte1; 70262306a36Sopenharmony_ci coex_dm->ps_tdma_para[1] = byte2; 70362306a36Sopenharmony_ci coex_dm->ps_tdma_para[2] = byte3; 70462306a36Sopenharmony_ci coex_dm->ps_tdma_para[3] = byte4; 70562306a36Sopenharmony_ci coex_dm->ps_tdma_para[4] = real_byte5; 70662306a36Sopenharmony_ci 70762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 70862306a36Sopenharmony_ci "[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", 70962306a36Sopenharmony_ci h2c_parameter[0], 71062306a36Sopenharmony_ci h2c_parameter[1] << 24 | 71162306a36Sopenharmony_ci h2c_parameter[2] << 16 | 71262306a36Sopenharmony_ci h2c_parameter[3] << 8 | 71362306a36Sopenharmony_ci h2c_parameter[4]); 71462306a36Sopenharmony_ci 71562306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); 71662306a36Sopenharmony_ci} 71762306a36Sopenharmony_ci 71862306a36Sopenharmony_cistatic void halbtc8723b1ant_set_lps_rpwm(struct btc_coexist *btcoexist, 71962306a36Sopenharmony_ci u8 lps_val, u8 rpwm_val) 72062306a36Sopenharmony_ci{ 72162306a36Sopenharmony_ci u8 lps = lps_val; 72262306a36Sopenharmony_ci u8 rpwm = rpwm_val; 72362306a36Sopenharmony_ci 72462306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps); 72562306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm); 72662306a36Sopenharmony_ci} 72762306a36Sopenharmony_ci 72862306a36Sopenharmony_cistatic void halbtc8723b1ant_lps_rpwm(struct btc_coexist *btcoexist, 72962306a36Sopenharmony_ci bool force_exec, 73062306a36Sopenharmony_ci u8 lps_val, u8 rpwm_val) 73162306a36Sopenharmony_ci{ 73262306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 73362306a36Sopenharmony_ci 73462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 73562306a36Sopenharmony_ci "[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n", 73662306a36Sopenharmony_ci (force_exec ? "force to" : ""), lps_val, rpwm_val); 73762306a36Sopenharmony_ci coex_dm->cur_lps = lps_val; 73862306a36Sopenharmony_ci coex_dm->cur_rpwm = rpwm_val; 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_ci if (!force_exec) { 74162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 74262306a36Sopenharmony_ci "[BTCoex], LPS-RxBeaconMode = 0x%x , LPS-RPWM = 0x%x!!\n", 74362306a36Sopenharmony_ci coex_dm->cur_lps, coex_dm->cur_rpwm); 74462306a36Sopenharmony_ci 74562306a36Sopenharmony_ci if ((coex_dm->pre_lps == coex_dm->cur_lps) && 74662306a36Sopenharmony_ci (coex_dm->pre_rpwm == coex_dm->cur_rpwm)) { 74762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 74862306a36Sopenharmony_ci "[BTCoex], LPS-RPWM_Last = 0x%x , LPS-RPWM_Now = 0x%x!!\n", 74962306a36Sopenharmony_ci coex_dm->pre_rpwm, coex_dm->cur_rpwm); 75062306a36Sopenharmony_ci 75162306a36Sopenharmony_ci return; 75262306a36Sopenharmony_ci } 75362306a36Sopenharmony_ci } 75462306a36Sopenharmony_ci halbtc8723b1ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val); 75562306a36Sopenharmony_ci 75662306a36Sopenharmony_ci coex_dm->pre_lps = coex_dm->cur_lps; 75762306a36Sopenharmony_ci coex_dm->pre_rpwm = coex_dm->cur_rpwm; 75862306a36Sopenharmony_ci} 75962306a36Sopenharmony_ci 76062306a36Sopenharmony_cistatic void halbtc8723b1ant_sw_mechanism(struct btc_coexist *btcoexist, 76162306a36Sopenharmony_ci bool low_penalty_ra) 76262306a36Sopenharmony_ci{ 76362306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 76662306a36Sopenharmony_ci "[BTCoex], SM[LpRA] = %d\n", low_penalty_ra); 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_ci halbtc8723b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); 76962306a36Sopenharmony_ci} 77062306a36Sopenharmony_ci 77162306a36Sopenharmony_cistatic void halbtc8723b1ant_set_ant_path(struct btc_coexist *btcoexist, 77262306a36Sopenharmony_ci u8 ant_pos_type, bool force_exec, 77362306a36Sopenharmony_ci bool init_hw_cfg, bool wifi_off) 77462306a36Sopenharmony_ci{ 77562306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 77662306a36Sopenharmony_ci struct btc_board_info *board_info = &btcoexist->board_info; 77762306a36Sopenharmony_ci u32 fw_ver = 0, u32tmp = 0, cnt_bt_cal_chk = 0; 77862306a36Sopenharmony_ci bool pg_ext_switch = false; 77962306a36Sopenharmony_ci bool use_ext_switch = false; 78062306a36Sopenharmony_ci bool is_in_mp_mode = false; 78162306a36Sopenharmony_ci u8 h2c_parameter[2] = {0}, u8tmp = 0; 78262306a36Sopenharmony_ci 78362306a36Sopenharmony_ci coex_dm->cur_ant_pos_type = ant_pos_type; 78462306a36Sopenharmony_ci 78562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_EXT_SWITCH, &pg_ext_switch); 78662306a36Sopenharmony_ci /* [31:16] = fw ver, [15:0] = fw sub ver */ 78762306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); 78862306a36Sopenharmony_ci 78962306a36Sopenharmony_ci if ((fw_ver < 0xc0000) || pg_ext_switch) 79062306a36Sopenharmony_ci use_ext_switch = true; 79162306a36Sopenharmony_ci 79262306a36Sopenharmony_ci if (init_hw_cfg) { 79362306a36Sopenharmony_ci /* WiFi TRx Mask on */ 79462306a36Sopenharmony_ci btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 79562306a36Sopenharmony_ci 0x780); 79662306a36Sopenharmony_ci /* remove due to interrupt is disabled that polling c2h will 79762306a36Sopenharmony_ci * fail and delay 100ms. 79862306a36Sopenharmony_ci */ 79962306a36Sopenharmony_ci 80062306a36Sopenharmony_ci if (fw_ver >= 0x180000) { 80162306a36Sopenharmony_ci /* Use H2C to set GNT_BT to HIGH */ 80262306a36Sopenharmony_ci h2c_parameter[0] = 1; 80362306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x6E, 1, 80462306a36Sopenharmony_ci h2c_parameter); 80562306a36Sopenharmony_ci } else { 80662306a36Sopenharmony_ci /* set grant_bt to high */ 80762306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x765, 0x18); 80862306a36Sopenharmony_ci } 80962306a36Sopenharmony_ci /* set wlan_act control by PTA */ 81062306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); 81162306a36Sopenharmony_ci 81262306a36Sopenharmony_ci /* BT select s0/s1 is controlled by BT */ 81362306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0); 81462306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x39, 0x8, 0x1); 81562306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff); 81662306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x944, 0x3, 0x3); 81762306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x930, 0x77); 81862306a36Sopenharmony_ci } else if (wifi_off) { 81962306a36Sopenharmony_ci if (fw_ver >= 0x180000) { 82062306a36Sopenharmony_ci /* Use H2C to set GNT_BT to HIGH */ 82162306a36Sopenharmony_ci h2c_parameter[0] = 1; 82262306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x6E, 1, 82362306a36Sopenharmony_ci h2c_parameter); 82462306a36Sopenharmony_ci } else { 82562306a36Sopenharmony_ci /* set grant_bt to high */ 82662306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x765, 0x18); 82762306a36Sopenharmony_ci } 82862306a36Sopenharmony_ci /* set wlan_act to always low */ 82962306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); 83062306a36Sopenharmony_ci 83162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, 83262306a36Sopenharmony_ci &is_in_mp_mode); 83362306a36Sopenharmony_ci if (!is_in_mp_mode) 83462306a36Sopenharmony_ci /* BT select s0/s1 is controlled by BT */ 83562306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 83662306a36Sopenharmony_ci 0x20, 0x0); 83762306a36Sopenharmony_ci else 83862306a36Sopenharmony_ci /* BT select s0/s1 is controlled by WiFi */ 83962306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 84062306a36Sopenharmony_ci 0x20, 0x1); 84162306a36Sopenharmony_ci 84262306a36Sopenharmony_ci /* 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL 84362306a36Sopenharmony_ci * BT Vendor 0xac=0xf002 84462306a36Sopenharmony_ci */ 84562306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); 84662306a36Sopenharmony_ci u32tmp &= ~BIT23; 84762306a36Sopenharmony_ci u32tmp &= ~BIT24; 84862306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); 84962306a36Sopenharmony_ci } else { 85062306a36Sopenharmony_ci /* Use H2C to set GNT_BT to LOW */ 85162306a36Sopenharmony_ci if (fw_ver >= 0x180000) { 85262306a36Sopenharmony_ci if (btcoexist->btc_read_1byte(btcoexist, 0x765) != 0) { 85362306a36Sopenharmony_ci h2c_parameter[0] = 0; 85462306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x6E, 1, 85562306a36Sopenharmony_ci h2c_parameter); 85662306a36Sopenharmony_ci } 85762306a36Sopenharmony_ci } else { 85862306a36Sopenharmony_ci /* BT calibration check */ 85962306a36Sopenharmony_ci while (cnt_bt_cal_chk <= 20) { 86062306a36Sopenharmony_ci u8tmp = btcoexist->btc_read_1byte(btcoexist, 86162306a36Sopenharmony_ci 0x49d); 86262306a36Sopenharmony_ci cnt_bt_cal_chk++; 86362306a36Sopenharmony_ci if (u8tmp & BIT(0)) { 86462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, 86562306a36Sopenharmony_ci DBG_LOUD, 86662306a36Sopenharmony_ci "[BTCoex], ########### BT is calibrating (wait cnt=%d) ###########\n", 86762306a36Sopenharmony_ci cnt_bt_cal_chk); 86862306a36Sopenharmony_ci mdelay(50); 86962306a36Sopenharmony_ci } else { 87062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, 87162306a36Sopenharmony_ci DBG_LOUD, 87262306a36Sopenharmony_ci "[BTCoex], ********** BT is NOT calibrating (wait cnt=%d)**********\n", 87362306a36Sopenharmony_ci cnt_bt_cal_chk); 87462306a36Sopenharmony_ci break; 87562306a36Sopenharmony_ci } 87662306a36Sopenharmony_ci } 87762306a36Sopenharmony_ci 87862306a36Sopenharmony_ci /* set grant_bt to PTA */ 87962306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x765, 0x0); 88062306a36Sopenharmony_ci } 88162306a36Sopenharmony_ci 88262306a36Sopenharmony_ci if (btcoexist->btc_read_1byte(btcoexist, 0x76e) != 0xc) { 88362306a36Sopenharmony_ci /* set wlan_act control by PTA */ 88462306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); 88562306a36Sopenharmony_ci } 88662306a36Sopenharmony_ci 88762306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 88862306a36Sopenharmony_ci btcoexist, 0x67, 0x20, 88962306a36Sopenharmony_ci 0x1); /* BT select s0/s1 is controlled by WiFi */ 89062306a36Sopenharmony_ci } 89162306a36Sopenharmony_ci 89262306a36Sopenharmony_ci if (use_ext_switch) { 89362306a36Sopenharmony_ci if (init_hw_cfg) { 89462306a36Sopenharmony_ci /* 0x4c[23] = 0, 0x4c[24] = 1 89562306a36Sopenharmony_ci * Antenna control by WL/BT 89662306a36Sopenharmony_ci */ 89762306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); 89862306a36Sopenharmony_ci u32tmp &= ~BIT23; 89962306a36Sopenharmony_ci u32tmp |= BIT24; 90062306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); 90162306a36Sopenharmony_ci 90262306a36Sopenharmony_ci /* fixed internal switch S1->WiFi, S0->BT */ 90362306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x948, 0x0); 90462306a36Sopenharmony_ci 90562306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 90662306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) { 90762306a36Sopenharmony_ci /* tell firmware "no antenna inverse" */ 90862306a36Sopenharmony_ci h2c_parameter[0] = 0; 90962306a36Sopenharmony_ci /* ext switch type */ 91062306a36Sopenharmony_ci h2c_parameter[1] = 1; 91162306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, 91262306a36Sopenharmony_ci h2c_parameter); 91362306a36Sopenharmony_ci } else { 91462306a36Sopenharmony_ci /* tell firmware "antenna inverse" */ 91562306a36Sopenharmony_ci h2c_parameter[0] = 1; 91662306a36Sopenharmony_ci /* ext switch type */ 91762306a36Sopenharmony_ci h2c_parameter[1] = 1; 91862306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, 91962306a36Sopenharmony_ci h2c_parameter); 92062306a36Sopenharmony_ci } 92162306a36Sopenharmony_ci } 92262306a36Sopenharmony_ci 92362306a36Sopenharmony_ci if (force_exec || 92462306a36Sopenharmony_ci (coex_dm->cur_ant_pos_type != coex_dm->pre_ant_pos_type)) { 92562306a36Sopenharmony_ci /* ext switch setting */ 92662306a36Sopenharmony_ci switch (ant_pos_type) { 92762306a36Sopenharmony_ci case BTC_ANT_PATH_WIFI: 92862306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 92962306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) 93062306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 93162306a36Sopenharmony_ci btcoexist, 0x92c, 0x3, 0x1); 93262306a36Sopenharmony_ci else 93362306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 93462306a36Sopenharmony_ci btcoexist, 0x92c, 0x3, 0x2); 93562306a36Sopenharmony_ci break; 93662306a36Sopenharmony_ci case BTC_ANT_PATH_BT: 93762306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 93862306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) 93962306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 94062306a36Sopenharmony_ci btcoexist, 0x92c, 0x3, 0x2); 94162306a36Sopenharmony_ci else 94262306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 94362306a36Sopenharmony_ci btcoexist, 0x92c, 0x3, 0x1); 94462306a36Sopenharmony_ci break; 94562306a36Sopenharmony_ci default: 94662306a36Sopenharmony_ci case BTC_ANT_PATH_PTA: 94762306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 94862306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) 94962306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 95062306a36Sopenharmony_ci btcoexist, 0x92c, 0x3, 0x1); 95162306a36Sopenharmony_ci else 95262306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask( 95362306a36Sopenharmony_ci btcoexist, 0x92c, 0x3, 0x2); 95462306a36Sopenharmony_ci break; 95562306a36Sopenharmony_ci } 95662306a36Sopenharmony_ci } 95762306a36Sopenharmony_ci } else { 95862306a36Sopenharmony_ci if (init_hw_cfg) { 95962306a36Sopenharmony_ci /* 0x4c[23] = 1, 0x4c[24] = 0, 96062306a36Sopenharmony_ci * Antenna control by 0x64 96162306a36Sopenharmony_ci */ 96262306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); 96362306a36Sopenharmony_ci u32tmp |= BIT23; 96462306a36Sopenharmony_ci u32tmp &= ~BIT24; 96562306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); 96662306a36Sopenharmony_ci 96762306a36Sopenharmony_ci /* Fix Ext switch Main->S1, Aux->S0 */ 96862306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x64, 0x1, 96962306a36Sopenharmony_ci 0x0); 97062306a36Sopenharmony_ci 97162306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 97262306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) { 97362306a36Sopenharmony_ci /* tell firmware "no antenna inverse" */ 97462306a36Sopenharmony_ci h2c_parameter[0] = 0; 97562306a36Sopenharmony_ci /* internal switch type */ 97662306a36Sopenharmony_ci h2c_parameter[1] = 0; 97762306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, 97862306a36Sopenharmony_ci h2c_parameter); 97962306a36Sopenharmony_ci } else { 98062306a36Sopenharmony_ci /* tell firmware "antenna inverse" */ 98162306a36Sopenharmony_ci h2c_parameter[0] = 1; 98262306a36Sopenharmony_ci /* internal switch type */ 98362306a36Sopenharmony_ci h2c_parameter[1] = 0; 98462306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, 98562306a36Sopenharmony_ci h2c_parameter); 98662306a36Sopenharmony_ci } 98762306a36Sopenharmony_ci } 98862306a36Sopenharmony_ci 98962306a36Sopenharmony_ci if (force_exec || 99062306a36Sopenharmony_ci (coex_dm->cur_ant_pos_type != coex_dm->pre_ant_pos_type)) { 99162306a36Sopenharmony_ci /* internal switch setting */ 99262306a36Sopenharmony_ci switch (ant_pos_type) { 99362306a36Sopenharmony_ci case BTC_ANT_PATH_WIFI: 99462306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 99562306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) 99662306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 99762306a36Sopenharmony_ci 0x948, 0x0); 99862306a36Sopenharmony_ci else 99962306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 100062306a36Sopenharmony_ci 0x948, 0x280); 100162306a36Sopenharmony_ci break; 100262306a36Sopenharmony_ci case BTC_ANT_PATH_BT: 100362306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 100462306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) 100562306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 100662306a36Sopenharmony_ci 0x948, 0x280); 100762306a36Sopenharmony_ci else 100862306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 100962306a36Sopenharmony_ci 0x948, 0x0); 101062306a36Sopenharmony_ci break; 101162306a36Sopenharmony_ci default: 101262306a36Sopenharmony_ci case BTC_ANT_PATH_PTA: 101362306a36Sopenharmony_ci if (board_info->btdm_ant_pos == 101462306a36Sopenharmony_ci BTC_ANTENNA_AT_MAIN_PORT) 101562306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 101662306a36Sopenharmony_ci 0x948, 0x200); 101762306a36Sopenharmony_ci else 101862306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 101962306a36Sopenharmony_ci 0x948, 0x80); 102062306a36Sopenharmony_ci break; 102162306a36Sopenharmony_ci } 102262306a36Sopenharmony_ci } 102362306a36Sopenharmony_ci } 102462306a36Sopenharmony_ci 102562306a36Sopenharmony_ci coex_dm->pre_ant_pos_type = coex_dm->cur_ant_pos_type; 102662306a36Sopenharmony_ci} 102762306a36Sopenharmony_ci 102862306a36Sopenharmony_cistatic void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, 102962306a36Sopenharmony_ci bool force_exec, bool turn_on, u8 type) 103062306a36Sopenharmony_ci{ 103162306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 103262306a36Sopenharmony_ci bool wifi_busy = false; 103362306a36Sopenharmony_ci u8 rssi_adjust_val = 0; 103462306a36Sopenharmony_ci u8 ps_tdma_byte0_val = 0x51; 103562306a36Sopenharmony_ci u8 ps_tdma_byte3_val = 0x10; 103662306a36Sopenharmony_ci u8 ps_tdma_byte4_val = 0x50; 103762306a36Sopenharmony_ci s8 wifi_duration_adjust = 0x0; 103862306a36Sopenharmony_ci static bool pre_wifi_busy; 103962306a36Sopenharmony_ci 104062306a36Sopenharmony_ci coex_dm->cur_ps_tdma_on = turn_on; 104162306a36Sopenharmony_ci coex_dm->cur_ps_tdma = type; 104262306a36Sopenharmony_ci 104362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 104462306a36Sopenharmony_ci 104562306a36Sopenharmony_ci if (wifi_busy != pre_wifi_busy) { 104662306a36Sopenharmony_ci force_exec = true; 104762306a36Sopenharmony_ci pre_wifi_busy = wifi_busy; 104862306a36Sopenharmony_ci } 104962306a36Sopenharmony_ci 105062306a36Sopenharmony_ci if (!force_exec) { 105162306a36Sopenharmony_ci if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && 105262306a36Sopenharmony_ci (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) 105362306a36Sopenharmony_ci return; 105462306a36Sopenharmony_ci } 105562306a36Sopenharmony_ci 105662306a36Sopenharmony_ci if (coex_sta->scan_ap_num <= 5) { 105762306a36Sopenharmony_ci wifi_duration_adjust = 5; 105862306a36Sopenharmony_ci 105962306a36Sopenharmony_ci if (coex_sta->a2dp_bit_pool >= 35) 106062306a36Sopenharmony_ci wifi_duration_adjust = -10; 106162306a36Sopenharmony_ci else if (coex_sta->a2dp_bit_pool >= 45) 106262306a36Sopenharmony_ci wifi_duration_adjust = -15; 106362306a36Sopenharmony_ci } else if (coex_sta->scan_ap_num >= 40) { 106462306a36Sopenharmony_ci wifi_duration_adjust = -15; 106562306a36Sopenharmony_ci 106662306a36Sopenharmony_ci if (coex_sta->a2dp_bit_pool < 35) 106762306a36Sopenharmony_ci wifi_duration_adjust = -5; 106862306a36Sopenharmony_ci else if (coex_sta->a2dp_bit_pool < 45) 106962306a36Sopenharmony_ci wifi_duration_adjust = -10; 107062306a36Sopenharmony_ci } else if (coex_sta->scan_ap_num >= 20) { 107162306a36Sopenharmony_ci wifi_duration_adjust = -10; 107262306a36Sopenharmony_ci 107362306a36Sopenharmony_ci if (coex_sta->a2dp_bit_pool >= 45) 107462306a36Sopenharmony_ci wifi_duration_adjust = -15; 107562306a36Sopenharmony_ci } else { 107662306a36Sopenharmony_ci wifi_duration_adjust = 0; 107762306a36Sopenharmony_ci 107862306a36Sopenharmony_ci if (coex_sta->a2dp_bit_pool >= 35) 107962306a36Sopenharmony_ci wifi_duration_adjust = -10; 108062306a36Sopenharmony_ci else if (coex_sta->a2dp_bit_pool >= 45) 108162306a36Sopenharmony_ci wifi_duration_adjust = -15; 108262306a36Sopenharmony_ci } 108362306a36Sopenharmony_ci 108462306a36Sopenharmony_ci if ((type == 1) || (type == 2) || (type == 9) || (type == 11) || 108562306a36Sopenharmony_ci (type == 101) || (type == 102) || (type == 109) || (type == 111)) { 108662306a36Sopenharmony_ci if (!coex_sta->force_lps_on) { 108762306a36Sopenharmony_ci /* Native power save TDMA, only for A2DP-only case 108862306a36Sopenharmony_ci * 1/2/9/11 while wifi noisy threshold > 30 108962306a36Sopenharmony_ci */ 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci /* no null-pkt */ 109262306a36Sopenharmony_ci ps_tdma_byte0_val = 0x61; 109362306a36Sopenharmony_ci /* no tx-pause at BT-slot */ 109462306a36Sopenharmony_ci ps_tdma_byte3_val = 0x11; 109562306a36Sopenharmony_ci /* 0x778 = d/1 toggle, no dynamic slot */ 109662306a36Sopenharmony_ci ps_tdma_byte4_val = 0x10; 109762306a36Sopenharmony_ci } else { 109862306a36Sopenharmony_ci /* null-pkt */ 109962306a36Sopenharmony_ci ps_tdma_byte0_val = 0x51; 110062306a36Sopenharmony_ci /* tx-pause at BT-slot */ 110162306a36Sopenharmony_ci ps_tdma_byte3_val = 0x10; 110262306a36Sopenharmony_ci /* 0x778 = d/1 toggle, dynamic slot */ 110362306a36Sopenharmony_ci ps_tdma_byte4_val = 0x50; 110462306a36Sopenharmony_ci } 110562306a36Sopenharmony_ci } else if ((type == 3) || (type == 13) || (type == 14) || 110662306a36Sopenharmony_ci (type == 103) || (type == 113) || (type == 114)) { 110762306a36Sopenharmony_ci /* null-pkt */ 110862306a36Sopenharmony_ci ps_tdma_byte0_val = 0x51; 110962306a36Sopenharmony_ci /* tx-pause at BT-slot */ 111062306a36Sopenharmony_ci ps_tdma_byte3_val = 0x10; 111162306a36Sopenharmony_ci /* 0x778 = d/1 toggle, no dynamic slot */ 111262306a36Sopenharmony_ci ps_tdma_byte4_val = 0x10; 111362306a36Sopenharmony_ci } else { /* native power save case */ 111462306a36Sopenharmony_ci /* no null-pkt */ 111562306a36Sopenharmony_ci ps_tdma_byte0_val = 0x61; 111662306a36Sopenharmony_ci /* no tx-pause at BT-slot */ 111762306a36Sopenharmony_ci ps_tdma_byte3_val = 0x11; 111862306a36Sopenharmony_ci /* 0x778 = d/1 toggle, no dynamic slot */ 111962306a36Sopenharmony_ci ps_tdma_byte4_val = 0x11; 112062306a36Sopenharmony_ci /* psTdmaByte4Va is not define for 0x778 = d/1, 1/1 case */ 112162306a36Sopenharmony_ci } 112262306a36Sopenharmony_ci 112362306a36Sopenharmony_ci /* if (bt_link_info->slave_role) */ 112462306a36Sopenharmony_ci if ((bt_link_info->slave_role) && (bt_link_info->a2dp_exist)) 112562306a36Sopenharmony_ci /* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */ 112662306a36Sopenharmony_ci ps_tdma_byte4_val = ps_tdma_byte4_val | 0x1; 112762306a36Sopenharmony_ci 112862306a36Sopenharmony_ci if (type > 100) { 112962306a36Sopenharmony_ci /* set antenna control by SW */ 113062306a36Sopenharmony_ci ps_tdma_byte0_val = ps_tdma_byte0_val | 0x82; 113162306a36Sopenharmony_ci /* set antenna no toggle, control by antenna diversity */ 113262306a36Sopenharmony_ci ps_tdma_byte3_val = ps_tdma_byte3_val | 0x60; 113362306a36Sopenharmony_ci } 113462306a36Sopenharmony_ci 113562306a36Sopenharmony_ci if (turn_on) { 113662306a36Sopenharmony_ci switch (type) { 113762306a36Sopenharmony_ci default: 113862306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1a, 113962306a36Sopenharmony_ci 0x1a, 0x0, 114062306a36Sopenharmony_ci ps_tdma_byte4_val); 114162306a36Sopenharmony_ci break; 114262306a36Sopenharmony_ci case 1: 114362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 114462306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 114562306a36Sopenharmony_ci 0x3a + wifi_duration_adjust, 0x03, 114662306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 114762306a36Sopenharmony_ci 114862306a36Sopenharmony_ci rssi_adjust_val = 11; 114962306a36Sopenharmony_ci break; 115062306a36Sopenharmony_ci case 2: 115162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 115262306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 115362306a36Sopenharmony_ci 0x2d + wifi_duration_adjust, 0x03, 115462306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 115562306a36Sopenharmony_ci break; 115662306a36Sopenharmony_ci case 3: 115762306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 115862306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x30, 0x03, 115962306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 116062306a36Sopenharmony_ci break; 116162306a36Sopenharmony_ci case 4: 116262306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15, 116362306a36Sopenharmony_ci 0x3, 0x14, 0x0); 116462306a36Sopenharmony_ci break; 116562306a36Sopenharmony_ci case 5: 116662306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 116762306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x1f, 0x3, 116862306a36Sopenharmony_ci ps_tdma_byte3_val, 0x11); 116962306a36Sopenharmony_ci break; 117062306a36Sopenharmony_ci case 6: 117162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 117262306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x20, 0x3, 117362306a36Sopenharmony_ci ps_tdma_byte3_val, 0x11); 117462306a36Sopenharmony_ci break; 117562306a36Sopenharmony_ci case 7: 117662306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xc, 117762306a36Sopenharmony_ci 0x5, 0x0, 0x0); 117862306a36Sopenharmony_ci break; 117962306a36Sopenharmony_ci case 8: 118062306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25, 118162306a36Sopenharmony_ci 0x3, 0x10, 0x0); 118262306a36Sopenharmony_ci break; 118362306a36Sopenharmony_ci case 9: 118462306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 118562306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x3, 118662306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 118762306a36Sopenharmony_ci break; 118862306a36Sopenharmony_ci case 10: 118962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa, 119062306a36Sopenharmony_ci 0xa, 0x0, 0x40); 119162306a36Sopenharmony_ci break; 119262306a36Sopenharmony_ci case 11: 119362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 119462306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x03, 119562306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 119662306a36Sopenharmony_ci break; 119762306a36Sopenharmony_ci case 12: 119862306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x0a, 119962306a36Sopenharmony_ci 0x0a, 0x0, 0x50); 120062306a36Sopenharmony_ci break; 120162306a36Sopenharmony_ci case 13: 120262306a36Sopenharmony_ci if (coex_sta->scan_ap_num <= 3) 120362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 120462306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x40, 0x3, 120562306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 120662306a36Sopenharmony_ci else 120762306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 120862306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x3, 120962306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 121062306a36Sopenharmony_ci break; 121162306a36Sopenharmony_ci case 14: 121262306a36Sopenharmony_ci if (coex_sta->scan_ap_num <= 3) 121362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 121462306a36Sopenharmony_ci btcoexist, 0x51, 0x30, 0x3, 0x10, 0x50); 121562306a36Sopenharmony_ci else 121662306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 121762306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x3, 121862306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 121962306a36Sopenharmony_ci break; 122062306a36Sopenharmony_ci case 15: 122162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa, 122262306a36Sopenharmony_ci 0x3, 0x8, 0x0); 122362306a36Sopenharmony_ci break; 122462306a36Sopenharmony_ci case 16: 122562306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15, 122662306a36Sopenharmony_ci 0x3, 0x10, 0x0); 122762306a36Sopenharmony_ci break; 122862306a36Sopenharmony_ci case 18: 122962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25, 123062306a36Sopenharmony_ci 0x3, 0x10, 0x0); 123162306a36Sopenharmony_ci break; 123262306a36Sopenharmony_ci case 20: 123362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 123462306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x3f, 0x03, 123562306a36Sopenharmony_ci ps_tdma_byte3_val, 0x10); 123662306a36Sopenharmony_ci break; 123762306a36Sopenharmony_ci case 21: 123862306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25, 123962306a36Sopenharmony_ci 0x03, 0x11, 0x11); 124062306a36Sopenharmony_ci break; 124162306a36Sopenharmony_ci case 22: 124262306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 124362306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x25, 0x03, 124462306a36Sopenharmony_ci ps_tdma_byte3_val, 0x10); 124562306a36Sopenharmony_ci break; 124662306a36Sopenharmony_ci case 23: 124762306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25, 124862306a36Sopenharmony_ci 0x3, 0x31, 0x18); 124962306a36Sopenharmony_ci break; 125062306a36Sopenharmony_ci case 24: 125162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15, 125262306a36Sopenharmony_ci 0x3, 0x31, 0x18); 125362306a36Sopenharmony_ci break; 125462306a36Sopenharmony_ci case 25: 125562306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, 125662306a36Sopenharmony_ci 0x3, 0x31, 0x18); 125762306a36Sopenharmony_ci break; 125862306a36Sopenharmony_ci case 26: 125962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, 126062306a36Sopenharmony_ci 0x3, 0x31, 0x18); 126162306a36Sopenharmony_ci break; 126262306a36Sopenharmony_ci case 27: 126362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25, 126462306a36Sopenharmony_ci 0x3, 0x31, 0x98); 126562306a36Sopenharmony_ci break; 126662306a36Sopenharmony_ci case 28: 126762306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x69, 0x25, 126862306a36Sopenharmony_ci 0x3, 0x31, 0x0); 126962306a36Sopenharmony_ci break; 127062306a36Sopenharmony_ci case 29: 127162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xab, 0x1a, 127262306a36Sopenharmony_ci 0x1a, 0x1, 0x10); 127362306a36Sopenharmony_ci break; 127462306a36Sopenharmony_ci case 30: 127562306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x30, 127662306a36Sopenharmony_ci 0x3, 0x10, 0x10); 127762306a36Sopenharmony_ci break; 127862306a36Sopenharmony_ci case 31: 127962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x1a, 128062306a36Sopenharmony_ci 0x1a, 0, 0x58); 128162306a36Sopenharmony_ci break; 128262306a36Sopenharmony_ci case 32: 128362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 128462306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x35, 0x3, 128562306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 128662306a36Sopenharmony_ci break; 128762306a36Sopenharmony_ci case 33: 128862306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 128962306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x35, 0x3, 129062306a36Sopenharmony_ci ps_tdma_byte3_val, 0x10); 129162306a36Sopenharmony_ci break; 129262306a36Sopenharmony_ci case 34: 129362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x53, 0x1a, 129462306a36Sopenharmony_ci 0x1a, 0x0, 0x10); 129562306a36Sopenharmony_ci break; 129662306a36Sopenharmony_ci case 35: 129762306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x63, 0x1a, 129862306a36Sopenharmony_ci 0x1a, 0x0, 0x10); 129962306a36Sopenharmony_ci break; 130062306a36Sopenharmony_ci case 36: 130162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12, 130262306a36Sopenharmony_ci 0x3, 0x14, 0x50); 130362306a36Sopenharmony_ci break; 130462306a36Sopenharmony_ci case 40: 130562306a36Sopenharmony_ci /* SoftAP only with no sta associated,BT disable ,TDMA 130662306a36Sopenharmony_ci * mode for power saving 130762306a36Sopenharmony_ci * 130862306a36Sopenharmony_ci * here softap mode screen off will cost 70-80mA for 130962306a36Sopenharmony_ci * phone 131062306a36Sopenharmony_ci */ 131162306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x23, 0x18, 131262306a36Sopenharmony_ci 0x00, 0x10, 0x24); 131362306a36Sopenharmony_ci break; 131462306a36Sopenharmony_ci 131562306a36Sopenharmony_ci case 101: 131662306a36Sopenharmony_ci /* for 1-Ant translate to 2-Ant */ 131762306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 131862306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 131962306a36Sopenharmony_ci 0x3a + wifi_duration_adjust, 0x03, 132062306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 132162306a36Sopenharmony_ci break; 132262306a36Sopenharmony_ci case 102: 132362306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 132462306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 132562306a36Sopenharmony_ci 0x2d + wifi_duration_adjust, 0x03, 132662306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 132762306a36Sopenharmony_ci break; 132862306a36Sopenharmony_ci case 103: 132962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 133062306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x3a, 0x03, 133162306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 133262306a36Sopenharmony_ci break; 133362306a36Sopenharmony_ci case 105: 133462306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 133562306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x15, 0x3, 133662306a36Sopenharmony_ci ps_tdma_byte3_val, 0x11); 133762306a36Sopenharmony_ci break; 133862306a36Sopenharmony_ci case 106: 133962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 134062306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x20, 0x3, 134162306a36Sopenharmony_ci ps_tdma_byte3_val, 0x11); 134262306a36Sopenharmony_ci break; 134362306a36Sopenharmony_ci case 109: 134462306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 134562306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x3, 134662306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 134762306a36Sopenharmony_ci break; 134862306a36Sopenharmony_ci case 111: 134962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 135062306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x03, 135162306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 135262306a36Sopenharmony_ci break; 135362306a36Sopenharmony_ci case 113: 135462306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 135562306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x3, 135662306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 135762306a36Sopenharmony_ci break; 135862306a36Sopenharmony_ci case 114: 135962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 136062306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x21, 0x3, 136162306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 136262306a36Sopenharmony_ci break; 136362306a36Sopenharmony_ci case 120: 136462306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 136562306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x3f, 0x03, 136662306a36Sopenharmony_ci ps_tdma_byte3_val, 0x10); 136762306a36Sopenharmony_ci break; 136862306a36Sopenharmony_ci case 122: 136962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 137062306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x25, 0x03, 137162306a36Sopenharmony_ci ps_tdma_byte3_val, 0x10); 137262306a36Sopenharmony_ci break; 137362306a36Sopenharmony_ci case 132: 137462306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 137562306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x25, 0x03, 137662306a36Sopenharmony_ci ps_tdma_byte3_val, ps_tdma_byte4_val); 137762306a36Sopenharmony_ci break; 137862306a36Sopenharmony_ci case 133: 137962306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma( 138062306a36Sopenharmony_ci btcoexist, ps_tdma_byte0_val, 0x25, 0x03, 138162306a36Sopenharmony_ci ps_tdma_byte3_val, 0x11); 138262306a36Sopenharmony_ci break; 138362306a36Sopenharmony_ci } 138462306a36Sopenharmony_ci } else { 138562306a36Sopenharmony_ci /* disable PS tdma */ 138662306a36Sopenharmony_ci switch (type) { 138762306a36Sopenharmony_ci case 8: /* PTA Control */ 138862306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x8, 0x0, 138962306a36Sopenharmony_ci 0x0, 0x0, 0x0); 139062306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, 139162306a36Sopenharmony_ci BTC_ANT_PATH_PTA, 139262306a36Sopenharmony_ci FORCE_EXEC, 139362306a36Sopenharmony_ci false, false); 139462306a36Sopenharmony_ci break; 139562306a36Sopenharmony_ci case 0: 139662306a36Sopenharmony_ci default: 139762306a36Sopenharmony_ci /* Software control, Antenna at BT side */ 139862306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 139962306a36Sopenharmony_ci 0x0, 0x0, 0x0); 140062306a36Sopenharmony_ci break; 140162306a36Sopenharmony_ci case 1: /* 2-Ant, 0x778=3, antenna control by ant diversity */ 140262306a36Sopenharmony_ci halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0, 140362306a36Sopenharmony_ci 0x48, 0x0); 140462306a36Sopenharmony_ci break; 140562306a36Sopenharmony_ci } 140662306a36Sopenharmony_ci } 140762306a36Sopenharmony_ci rssi_adjust_val = 0; 140862306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, 140962306a36Sopenharmony_ci BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, 141062306a36Sopenharmony_ci &rssi_adjust_val); 141162306a36Sopenharmony_ci 141262306a36Sopenharmony_ci /* update pre state */ 141362306a36Sopenharmony_ci coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; 141462306a36Sopenharmony_ci coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; 141562306a36Sopenharmony_ci} 141662306a36Sopenharmony_ci 141762306a36Sopenharmony_cistatic 141862306a36Sopenharmony_civoid btc8723b1ant_tdma_dur_adj_for_acl(struct btc_coexist *btcoexist, 141962306a36Sopenharmony_ci u8 wifi_status) 142062306a36Sopenharmony_ci{ 142162306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 142262306a36Sopenharmony_ci static s32 up, dn, m, n, wait_count; 142362306a36Sopenharmony_ci /* 0: no change, +1: increase WiFi duration, 142462306a36Sopenharmony_ci * -1: decrease WiFi duration 142562306a36Sopenharmony_ci */ 142662306a36Sopenharmony_ci s32 result; 142762306a36Sopenharmony_ci u8 retry_count = 0; 142862306a36Sopenharmony_ci 142962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 143062306a36Sopenharmony_ci "[BTCoex], TdmaDurationAdjustForAcl()\n"); 143162306a36Sopenharmony_ci 143262306a36Sopenharmony_ci if ((wifi_status == 143362306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN) || 143462306a36Sopenharmony_ci (wifi_status == BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN) || 143562306a36Sopenharmony_ci (wifi_status == BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT)) { 143662306a36Sopenharmony_ci if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 && 143762306a36Sopenharmony_ci coex_dm->cur_ps_tdma != 3 && coex_dm->cur_ps_tdma != 9) { 143862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 143962306a36Sopenharmony_ci true, 9); 144062306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 9; 144162306a36Sopenharmony_ci 144262306a36Sopenharmony_ci up = 0; 144362306a36Sopenharmony_ci dn = 0; 144462306a36Sopenharmony_ci m = 1; 144562306a36Sopenharmony_ci n = 3; 144662306a36Sopenharmony_ci result = 0; 144762306a36Sopenharmony_ci wait_count = 0; 144862306a36Sopenharmony_ci } 144962306a36Sopenharmony_ci return; 145062306a36Sopenharmony_ci } 145162306a36Sopenharmony_ci 145262306a36Sopenharmony_ci if (!coex_dm->auto_tdma_adjust) { 145362306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = true; 145462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 145562306a36Sopenharmony_ci "[BTCoex], first run TdmaDurationAdjust()!!\n"); 145662306a36Sopenharmony_ci 145762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2); 145862306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 2; 145962306a36Sopenharmony_ci 146062306a36Sopenharmony_ci up = 0; 146162306a36Sopenharmony_ci dn = 0; 146262306a36Sopenharmony_ci m = 1; 146362306a36Sopenharmony_ci n = 3; 146462306a36Sopenharmony_ci result = 0; 146562306a36Sopenharmony_ci wait_count = 0; 146662306a36Sopenharmony_ci } else { 146762306a36Sopenharmony_ci /* acquire the BT TRx retry count from BT_Info byte2 */ 146862306a36Sopenharmony_ci retry_count = coex_sta->bt_retry_cnt; 146962306a36Sopenharmony_ci 147062306a36Sopenharmony_ci if ((coex_sta->low_priority_tx) > 1050 || 147162306a36Sopenharmony_ci (coex_sta->low_priority_rx) > 1250) 147262306a36Sopenharmony_ci retry_count++; 147362306a36Sopenharmony_ci 147462306a36Sopenharmony_ci result = 0; 147562306a36Sopenharmony_ci wait_count++; 147662306a36Sopenharmony_ci /* no retry in the last 2-second duration */ 147762306a36Sopenharmony_ci if (retry_count == 0) { 147862306a36Sopenharmony_ci up++; 147962306a36Sopenharmony_ci dn--; 148062306a36Sopenharmony_ci 148162306a36Sopenharmony_ci if (dn <= 0) 148262306a36Sopenharmony_ci dn = 0; 148362306a36Sopenharmony_ci 148462306a36Sopenharmony_ci if (up >= n) { 148562306a36Sopenharmony_ci /* if retry count during continuous n*2 seconds 148662306a36Sopenharmony_ci * is 0, enlarge WiFi duration 148762306a36Sopenharmony_ci */ 148862306a36Sopenharmony_ci wait_count = 0; 148962306a36Sopenharmony_ci n = 3; 149062306a36Sopenharmony_ci up = 0; 149162306a36Sopenharmony_ci dn = 0; 149262306a36Sopenharmony_ci result = 1; 149362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 149462306a36Sopenharmony_ci "[BTCoex], Increase wifi duration!!\n"); 149562306a36Sopenharmony_ci } 149662306a36Sopenharmony_ci } else if (retry_count <= 3) { 149762306a36Sopenharmony_ci /* <=3 retry in the last 2-second duration */ 149862306a36Sopenharmony_ci up--; 149962306a36Sopenharmony_ci dn++; 150062306a36Sopenharmony_ci 150162306a36Sopenharmony_ci if (up <= 0) 150262306a36Sopenharmony_ci up = 0; 150362306a36Sopenharmony_ci 150462306a36Sopenharmony_ci if (dn == 2) { 150562306a36Sopenharmony_ci /* if continuous 2 retry count(every 2 seconds) 150662306a36Sopenharmony_ci * >0 and < 3, reduce WiFi duration 150762306a36Sopenharmony_ci */ 150862306a36Sopenharmony_ci if (wait_count <= 2) 150962306a36Sopenharmony_ci /* avoid loop between the two levels */ 151062306a36Sopenharmony_ci m++; 151162306a36Sopenharmony_ci else 151262306a36Sopenharmony_ci m = 1; 151362306a36Sopenharmony_ci 151462306a36Sopenharmony_ci if (m >= 20) 151562306a36Sopenharmony_ci /* maximum of m = 20 ' will recheck if 151662306a36Sopenharmony_ci * need to adjust wifi duration in 151762306a36Sopenharmony_ci * maximum time interval 120 seconds 151862306a36Sopenharmony_ci */ 151962306a36Sopenharmony_ci m = 20; 152062306a36Sopenharmony_ci 152162306a36Sopenharmony_ci n = 3 * m; 152262306a36Sopenharmony_ci up = 0; 152362306a36Sopenharmony_ci dn = 0; 152462306a36Sopenharmony_ci wait_count = 0; 152562306a36Sopenharmony_ci result = -1; 152662306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 152762306a36Sopenharmony_ci "[BTCoex], Decrease wifi duration for retryCounter<3!!\n"); 152862306a36Sopenharmony_ci } 152962306a36Sopenharmony_ci } else { 153062306a36Sopenharmony_ci /* retry count > 3, once retry count > 3, to reduce 153162306a36Sopenharmony_ci * WiFi duration 153262306a36Sopenharmony_ci */ 153362306a36Sopenharmony_ci if (wait_count == 1) 153462306a36Sopenharmony_ci /* to avoid loop between the two levels */ 153562306a36Sopenharmony_ci m++; 153662306a36Sopenharmony_ci else 153762306a36Sopenharmony_ci m = 1; 153862306a36Sopenharmony_ci 153962306a36Sopenharmony_ci if (m >= 20) 154062306a36Sopenharmony_ci /* maximum of m = 20 ' will recheck if need to 154162306a36Sopenharmony_ci * adjust wifi duration in maximum time interval 154262306a36Sopenharmony_ci * 120 seconds 154362306a36Sopenharmony_ci */ 154462306a36Sopenharmony_ci m = 20; 154562306a36Sopenharmony_ci 154662306a36Sopenharmony_ci n = 3 * m; 154762306a36Sopenharmony_ci up = 0; 154862306a36Sopenharmony_ci dn = 0; 154962306a36Sopenharmony_ci wait_count = 0; 155062306a36Sopenharmony_ci result = -1; 155162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 155262306a36Sopenharmony_ci "[BTCoex], Decrease wifi duration for retryCounter>3!!\n"); 155362306a36Sopenharmony_ci } 155462306a36Sopenharmony_ci 155562306a36Sopenharmony_ci if (result == -1) { 155662306a36Sopenharmony_ci if (coex_dm->cur_ps_tdma == 1) { 155762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 155862306a36Sopenharmony_ci true, 2); 155962306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 2; 156062306a36Sopenharmony_ci } else if (coex_dm->cur_ps_tdma == 2) { 156162306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 156262306a36Sopenharmony_ci true, 9); 156362306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 9; 156462306a36Sopenharmony_ci } else if (coex_dm->cur_ps_tdma == 9) { 156562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 156662306a36Sopenharmony_ci true, 11); 156762306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 11; 156862306a36Sopenharmony_ci } 156962306a36Sopenharmony_ci } else if (result == 1) { 157062306a36Sopenharmony_ci if (coex_dm->cur_ps_tdma == 11) { 157162306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 157262306a36Sopenharmony_ci true, 9); 157362306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 9; 157462306a36Sopenharmony_ci } else if (coex_dm->cur_ps_tdma == 9) { 157562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 157662306a36Sopenharmony_ci true, 2); 157762306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 2; 157862306a36Sopenharmony_ci } else if (coex_dm->cur_ps_tdma == 2) { 157962306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 158062306a36Sopenharmony_ci true, 1); 158162306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type = 1; 158262306a36Sopenharmony_ci } 158362306a36Sopenharmony_ci } 158462306a36Sopenharmony_ci 158562306a36Sopenharmony_ci if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 && 158662306a36Sopenharmony_ci coex_dm->cur_ps_tdma != 9 && coex_dm->cur_ps_tdma != 11) { 158762306a36Sopenharmony_ci /* recover to previous adjust type */ 158862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 158962306a36Sopenharmony_ci coex_dm->ps_tdma_du_adj_type); 159062306a36Sopenharmony_ci } 159162306a36Sopenharmony_ci } 159262306a36Sopenharmony_ci} 159362306a36Sopenharmony_ci 159462306a36Sopenharmony_cistatic void halbtc8723b1ant_ps_tdma_chk_pwr_save(struct btc_coexist *btcoexist, 159562306a36Sopenharmony_ci bool new_ps_state) 159662306a36Sopenharmony_ci{ 159762306a36Sopenharmony_ci u8 lps_mode = 0x0; 159862306a36Sopenharmony_ci 159962306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode); 160062306a36Sopenharmony_ci 160162306a36Sopenharmony_ci if (lps_mode) { 160262306a36Sopenharmony_ci /* already under LPS state */ 160362306a36Sopenharmony_ci if (new_ps_state) { 160462306a36Sopenharmony_ci /* keep state under LPS, do nothing. */ 160562306a36Sopenharmony_ci } else { 160662306a36Sopenharmony_ci /* will leave LPS state, turn off psTdma first */ 160762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 160862306a36Sopenharmony_ci false, 0); 160962306a36Sopenharmony_ci } 161062306a36Sopenharmony_ci } else { 161162306a36Sopenharmony_ci /* NO PS state */ 161262306a36Sopenharmony_ci if (new_ps_state) { 161362306a36Sopenharmony_ci /* will enter LPS state, turn off psTdma first */ 161462306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 161562306a36Sopenharmony_ci false, 0); 161662306a36Sopenharmony_ci } else { 161762306a36Sopenharmony_ci /* keep state under NO PS state, do nothing. */ 161862306a36Sopenharmony_ci } 161962306a36Sopenharmony_ci } 162062306a36Sopenharmony_ci} 162162306a36Sopenharmony_ci 162262306a36Sopenharmony_cistatic void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, 162362306a36Sopenharmony_ci u8 ps_type, u8 lps_val, 162462306a36Sopenharmony_ci u8 rpwm_val) 162562306a36Sopenharmony_ci{ 162662306a36Sopenharmony_ci bool low_pwr_disable = false; 162762306a36Sopenharmony_ci 162862306a36Sopenharmony_ci switch (ps_type) { 162962306a36Sopenharmony_ci case BTC_PS_WIFI_NATIVE: 163062306a36Sopenharmony_ci /* recover to original 32k low power setting */ 163162306a36Sopenharmony_ci low_pwr_disable = false; 163262306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, 163362306a36Sopenharmony_ci &low_pwr_disable); 163462306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL); 163562306a36Sopenharmony_ci coex_sta->force_lps_on = false; 163662306a36Sopenharmony_ci break; 163762306a36Sopenharmony_ci case BTC_PS_LPS_ON: 163862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma_chk_pwr_save(btcoexist, true); 163962306a36Sopenharmony_ci halbtc8723b1ant_lps_rpwm(btcoexist, NORMAL_EXEC, lps_val, 164062306a36Sopenharmony_ci rpwm_val); 164162306a36Sopenharmony_ci /* when coex force to enter LPS, do not enter 32k low power */ 164262306a36Sopenharmony_ci low_pwr_disable = true; 164362306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, 164462306a36Sopenharmony_ci &low_pwr_disable); 164562306a36Sopenharmony_ci /* power save must executed before psTdma */ 164662306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL); 164762306a36Sopenharmony_ci coex_sta->force_lps_on = true; 164862306a36Sopenharmony_ci break; 164962306a36Sopenharmony_ci case BTC_PS_LPS_OFF: 165062306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma_chk_pwr_save(btcoexist, false); 165162306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL); 165262306a36Sopenharmony_ci coex_sta->force_lps_on = false; 165362306a36Sopenharmony_ci break; 165462306a36Sopenharmony_ci default: 165562306a36Sopenharmony_ci break; 165662306a36Sopenharmony_ci } 165762306a36Sopenharmony_ci} 165862306a36Sopenharmony_ci 165962306a36Sopenharmony_cistatic void halbtc8723b1ant_action_wifi_only(struct btc_coexist *btcoexist) 166062306a36Sopenharmony_ci{ 166162306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); 166262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); 166362306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 166462306a36Sopenharmony_ci FORCE_EXEC, false, false); 166562306a36Sopenharmony_ci} 166662306a36Sopenharmony_ci 166762306a36Sopenharmony_ci/* check if BT is disabled */ 166862306a36Sopenharmony_cistatic void halbtc8723b1ant_monitor_bt_enable_disable(struct btc_coexist 166962306a36Sopenharmony_ci *btcoexist) 167062306a36Sopenharmony_ci{ 167162306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 167262306a36Sopenharmony_ci static u32 bt_disable_cnt; 167362306a36Sopenharmony_ci bool bt_active = true, bt_disabled = false; 167462306a36Sopenharmony_ci 167562306a36Sopenharmony_ci if (coex_sta->high_priority_tx == 0 && 167662306a36Sopenharmony_ci coex_sta->high_priority_rx == 0 && coex_sta->low_priority_tx == 0 && 167762306a36Sopenharmony_ci coex_sta->low_priority_rx == 0) 167862306a36Sopenharmony_ci bt_active = false; 167962306a36Sopenharmony_ci if (coex_sta->high_priority_tx == 0xffff && 168062306a36Sopenharmony_ci coex_sta->high_priority_rx == 0xffff && 168162306a36Sopenharmony_ci coex_sta->low_priority_tx == 0xffff && 168262306a36Sopenharmony_ci coex_sta->low_priority_rx == 0xffff) 168362306a36Sopenharmony_ci bt_active = false; 168462306a36Sopenharmony_ci if (bt_active) { 168562306a36Sopenharmony_ci bt_disable_cnt = 0; 168662306a36Sopenharmony_ci bt_disabled = false; 168762306a36Sopenharmony_ci } else { 168862306a36Sopenharmony_ci bt_disable_cnt++; 168962306a36Sopenharmony_ci if (bt_disable_cnt >= 2) 169062306a36Sopenharmony_ci bt_disabled = true; 169162306a36Sopenharmony_ci } 169262306a36Sopenharmony_ci if (coex_sta->bt_disabled != bt_disabled) { 169362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 169462306a36Sopenharmony_ci "[BTCoex], BT is from %s to %s!!\n", 169562306a36Sopenharmony_ci (coex_sta->bt_disabled ? "disabled" : "enabled"), 169662306a36Sopenharmony_ci (bt_disabled ? "disabled" : "enabled")); 169762306a36Sopenharmony_ci 169862306a36Sopenharmony_ci coex_sta->bt_disabled = bt_disabled; 169962306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, 170062306a36Sopenharmony_ci &bt_disabled); 170162306a36Sopenharmony_ci if (bt_disabled) { 170262306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_only(btcoexist); 170362306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, 170462306a36Sopenharmony_ci NULL); 170562306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, 170662306a36Sopenharmony_ci NULL); 170762306a36Sopenharmony_ci } 170862306a36Sopenharmony_ci } 170962306a36Sopenharmony_ci} 171062306a36Sopenharmony_ci 171162306a36Sopenharmony_ci/***************************************************** 171262306a36Sopenharmony_ci * 171362306a36Sopenharmony_ci * Non-Software Coex Mechanism start 171462306a36Sopenharmony_ci * 171562306a36Sopenharmony_ci *****************************************************/ 171662306a36Sopenharmony_ci 171762306a36Sopenharmony_cistatic void halbtc8723b1ant_action_bt_whck_test(struct btc_coexist *btcoexist) 171862306a36Sopenharmony_ci{ 171962306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 172062306a36Sopenharmony_ci 0x0); 172162306a36Sopenharmony_ci 172262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 172362306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, 172462306a36Sopenharmony_ci false, false); 172562306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); 172662306a36Sopenharmony_ci} 172762306a36Sopenharmony_ci 172862306a36Sopenharmony_cistatic void halbtc8723b1ant_action_wifi_multiport(struct btc_coexist *btcoexist) 172962306a36Sopenharmony_ci{ 173062306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 173162306a36Sopenharmony_ci 0x0, 0x0); 173262306a36Sopenharmony_ci 173362306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 173462306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, 173562306a36Sopenharmony_ci false, false); 173662306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); 173762306a36Sopenharmony_ci} 173862306a36Sopenharmony_ci 173962306a36Sopenharmony_cistatic void halbtc8723b1ant_action_hs(struct btc_coexist *btcoexist) 174062306a36Sopenharmony_ci{ 174162306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); 174262306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); 174362306a36Sopenharmony_ci} 174462306a36Sopenharmony_ci 174562306a36Sopenharmony_cistatic void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist) 174662306a36Sopenharmony_ci{ 174762306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 174862306a36Sopenharmony_ci bool wifi_connected = false, ap_enable = false; 174962306a36Sopenharmony_ci bool wifi_busy = false, bt_busy = false; 175062306a36Sopenharmony_ci 175162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, 175262306a36Sopenharmony_ci &ap_enable); 175362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 175462306a36Sopenharmony_ci &wifi_connected); 175562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 175662306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); 175762306a36Sopenharmony_ci 175862306a36Sopenharmony_ci if (coex_sta->bt_abnormal_scan) { 175962306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 33); 176062306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7); 176162306a36Sopenharmony_ci } else if (!wifi_connected && !coex_sta->wifi_is_high_pri_task) { 176262306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 176362306a36Sopenharmony_ci 0x0, 0x0); 176462306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 176562306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 176662306a36Sopenharmony_ci NORMAL_EXEC, false, false); 176762306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); 176862306a36Sopenharmony_ci } else if (bt_link_info->sco_exist || bt_link_info->hid_exist || 176962306a36Sopenharmony_ci bt_link_info->a2dp_exist) { 177062306a36Sopenharmony_ci /* SCO/HID/A2DP busy */ 177162306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 177262306a36Sopenharmony_ci 0x0, 0x0); 177362306a36Sopenharmony_ci if (coex_sta->c2h_bt_remote_name_req) 177462306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 177562306a36Sopenharmony_ci 33); 177662306a36Sopenharmony_ci else 177762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 177862306a36Sopenharmony_ci 32); 177962306a36Sopenharmony_ci 178062306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 178162306a36Sopenharmony_ci } else if (bt_link_info->pan_exist || wifi_busy) { 178262306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 178362306a36Sopenharmony_ci 0x0, 0x0); 178462306a36Sopenharmony_ci if (coex_sta->c2h_bt_remote_name_req) 178562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 178662306a36Sopenharmony_ci 33); 178762306a36Sopenharmony_ci else 178862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 178962306a36Sopenharmony_ci 32); 179062306a36Sopenharmony_ci 179162306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 179262306a36Sopenharmony_ci } else { 179362306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 179462306a36Sopenharmony_ci 0x0, 0x0); 179562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 179662306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 179762306a36Sopenharmony_ci NORMAL_EXEC, false, false); 179862306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7); 179962306a36Sopenharmony_ci } 180062306a36Sopenharmony_ci} 180162306a36Sopenharmony_ci 180262306a36Sopenharmony_cistatic void btc8723b1ant_act_bt_sco_hid_only_busy(struct btc_coexist *btcoexist, 180362306a36Sopenharmony_ci u8 wifi_status) 180462306a36Sopenharmony_ci{ 180562306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 180662306a36Sopenharmony_ci bool wifi_connected = false; 180762306a36Sopenharmony_ci 180862306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 180962306a36Sopenharmony_ci &wifi_connected); 181062306a36Sopenharmony_ci 181162306a36Sopenharmony_ci /* tdma and coex table */ 181262306a36Sopenharmony_ci if (bt_link_info->sco_exist) { 181362306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); 181462306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5); 181562306a36Sopenharmony_ci } else { 181662306a36Sopenharmony_ci /* HID */ 181762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 6); 181862306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5); 181962306a36Sopenharmony_ci } 182062306a36Sopenharmony_ci} 182162306a36Sopenharmony_ci 182262306a36Sopenharmony_cistatic void halbtc8723b1ant_action_wifi_connected_bt_acl_busy( 182362306a36Sopenharmony_ci struct btc_coexist *btcoexist, 182462306a36Sopenharmony_ci u8 wifi_status) 182562306a36Sopenharmony_ci{ 182662306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 182762306a36Sopenharmony_ci 182862306a36Sopenharmony_ci if ((coex_sta->low_priority_rx >= 950) && (!coex_sta->under_ips)) 182962306a36Sopenharmony_ci bt_link_info->slave_role = true; 183062306a36Sopenharmony_ci else 183162306a36Sopenharmony_ci bt_link_info->slave_role = false; 183262306a36Sopenharmony_ci 183362306a36Sopenharmony_ci if (bt_link_info->hid_only) { /* HID */ 183462306a36Sopenharmony_ci btc8723b1ant_act_bt_sco_hid_only_busy(btcoexist, wifi_status); 183562306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 183662306a36Sopenharmony_ci return; 183762306a36Sopenharmony_ci } else if (bt_link_info->a2dp_only) { /* A2DP */ 183862306a36Sopenharmony_ci if (wifi_status == BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE) { 183962306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 184062306a36Sopenharmony_ci true, 32); 184162306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 184262306a36Sopenharmony_ci NORMAL_EXEC, 4); 184362306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 184462306a36Sopenharmony_ci } else { 184562306a36Sopenharmony_ci btc8723b1ant_tdma_dur_adj_for_acl(btcoexist, 184662306a36Sopenharmony_ci wifi_status); 184762306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 184862306a36Sopenharmony_ci NORMAL_EXEC, 1); 184962306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = true; 185062306a36Sopenharmony_ci } 185162306a36Sopenharmony_ci } else if (((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) || 185262306a36Sopenharmony_ci (bt_link_info->hid_exist && bt_link_info->a2dp_exist && 185362306a36Sopenharmony_ci bt_link_info->pan_exist)) { 185462306a36Sopenharmony_ci /* A2DP + PAN(OPP,FTP), HID + A2DP + PAN(OPP,FTP) */ 185562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); 185662306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 185762306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 185862306a36Sopenharmony_ci } else if (bt_link_info->hid_exist && bt_link_info->a2dp_exist) { 185962306a36Sopenharmony_ci /* HID + A2DP */ 186062306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14); 186162306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 186262306a36Sopenharmony_ci 186362306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 186462306a36Sopenharmony_ci } else if (bt_link_info->pan_only || 186562306a36Sopenharmony_ci (bt_link_info->hid_exist && bt_link_info->pan_exist)) { 186662306a36Sopenharmony_ci /* PAN(OPP,FTP), HID + PAN(OPP,FTP) */ 186762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3); 186862306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 186962306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 187062306a36Sopenharmony_ci } else { 187162306a36Sopenharmony_ci /* BT no-profile busy (0x9) */ 187262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 33); 187362306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 187462306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 187562306a36Sopenharmony_ci } 187662306a36Sopenharmony_ci} 187762306a36Sopenharmony_ci 187862306a36Sopenharmony_cistatic void btc8723b1ant_action_wifi_not_conn(struct btc_coexist *btcoexist) 187962306a36Sopenharmony_ci{ 188062306a36Sopenharmony_ci /* power save state */ 188162306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 188262306a36Sopenharmony_ci 0x0, 0x0); 188362306a36Sopenharmony_ci 188462306a36Sopenharmony_ci /* tdma and coex table */ 188562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); 188662306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, 188762306a36Sopenharmony_ci false, false); 188862306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); 188962306a36Sopenharmony_ci} 189062306a36Sopenharmony_ci 189162306a36Sopenharmony_cistatic void 189262306a36Sopenharmony_cibtc8723b1ant_action_wifi_not_conn_scan(struct btc_coexist *btcoexist) 189362306a36Sopenharmony_ci{ 189462306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 189562306a36Sopenharmony_ci 189662306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 189762306a36Sopenharmony_ci 0x0, 0x0); 189862306a36Sopenharmony_ci 189962306a36Sopenharmony_ci /* tdma and coex table */ 190062306a36Sopenharmony_ci if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) { 190162306a36Sopenharmony_ci if (bt_link_info->a2dp_exist) { 190262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 190362306a36Sopenharmony_ci true, 32); 190462306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 190562306a36Sopenharmony_ci NORMAL_EXEC, 4); 190662306a36Sopenharmony_ci } else if (bt_link_info->pan_exist) { 190762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 190862306a36Sopenharmony_ci true, 22); 190962306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 191062306a36Sopenharmony_ci NORMAL_EXEC, 4); 191162306a36Sopenharmony_ci } else { 191262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 191362306a36Sopenharmony_ci true, 20); 191462306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 191562306a36Sopenharmony_ci NORMAL_EXEC, 1); 191662306a36Sopenharmony_ci } 191762306a36Sopenharmony_ci } else if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_SCO_BUSY || 191862306a36Sopenharmony_ci coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY){ 191962306a36Sopenharmony_ci btc8723b1ant_act_bt_sco_hid_only_busy(btcoexist, 192062306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); 192162306a36Sopenharmony_ci } else { 192262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 192362306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 192462306a36Sopenharmony_ci NORMAL_EXEC, false, false); 192562306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); 192662306a36Sopenharmony_ci } 192762306a36Sopenharmony_ci} 192862306a36Sopenharmony_ci 192962306a36Sopenharmony_cistatic void 193062306a36Sopenharmony_cibtc8723b1ant_act_wifi_not_conn_asso_auth(struct btc_coexist *btcoexist) 193162306a36Sopenharmony_ci{ 193262306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 193362306a36Sopenharmony_ci 193462306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 193562306a36Sopenharmony_ci 0x0, 0x0); 193662306a36Sopenharmony_ci 193762306a36Sopenharmony_ci /* tdma and coex table */ 193862306a36Sopenharmony_ci if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist) || 193962306a36Sopenharmony_ci (bt_link_info->a2dp_exist)) { 194062306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32); 194162306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 4); 194262306a36Sopenharmony_ci } else if (bt_link_info->pan_exist) { 194362306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); 194462306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 4); 194562306a36Sopenharmony_ci } else { 194662306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 194762306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 194862306a36Sopenharmony_ci NORMAL_EXEC, false, false); 194962306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2); 195062306a36Sopenharmony_ci } 195162306a36Sopenharmony_ci} 195262306a36Sopenharmony_ci 195362306a36Sopenharmony_cistatic void btc8723b1ant_action_wifi_conn_scan(struct btc_coexist *btcoexist) 195462306a36Sopenharmony_ci{ 195562306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 195662306a36Sopenharmony_ci 195762306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 195862306a36Sopenharmony_ci 0x0, 0x0); 195962306a36Sopenharmony_ci 196062306a36Sopenharmony_ci /* tdma and coex table */ 196162306a36Sopenharmony_ci if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) { 196262306a36Sopenharmony_ci if (bt_link_info->a2dp_exist) { 196362306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 196462306a36Sopenharmony_ci true, 32); 196562306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 196662306a36Sopenharmony_ci NORMAL_EXEC, 4); 196762306a36Sopenharmony_ci } else if (bt_link_info->pan_exist) { 196862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 196962306a36Sopenharmony_ci true, 22); 197062306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 197162306a36Sopenharmony_ci NORMAL_EXEC, 4); 197262306a36Sopenharmony_ci } else { 197362306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 197462306a36Sopenharmony_ci true, 20); 197562306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 197662306a36Sopenharmony_ci NORMAL_EXEC, 4); 197762306a36Sopenharmony_ci } 197862306a36Sopenharmony_ci } else if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_SCO_BUSY || 197962306a36Sopenharmony_ci coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) { 198062306a36Sopenharmony_ci btc8723b1ant_act_bt_sco_hid_only_busy(btcoexist, 198162306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); 198262306a36Sopenharmony_ci } else { 198362306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 198462306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 198562306a36Sopenharmony_ci NORMAL_EXEC, false, false); 198662306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); 198762306a36Sopenharmony_ci } 198862306a36Sopenharmony_ci} 198962306a36Sopenharmony_ci 199062306a36Sopenharmony_cistatic void halbtc8723b1ant_action_wifi_connected_special_packet( 199162306a36Sopenharmony_ci struct btc_coexist *btcoexist) 199262306a36Sopenharmony_ci{ 199362306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 199462306a36Sopenharmony_ci bool wifi_busy = false; 199562306a36Sopenharmony_ci 199662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 199762306a36Sopenharmony_ci 199862306a36Sopenharmony_ci /* no special packet process for both WiFi and BT very busy */ 199962306a36Sopenharmony_ci if ((wifi_busy) && 200062306a36Sopenharmony_ci ((bt_link_info->pan_exist) || (coex_sta->num_of_profile >= 2))) 200162306a36Sopenharmony_ci return; 200262306a36Sopenharmony_ci 200362306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 200462306a36Sopenharmony_ci 0x0, 0x0); 200562306a36Sopenharmony_ci 200662306a36Sopenharmony_ci /* tdma and coex table */ 200762306a36Sopenharmony_ci if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist)) { 200862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32); 200962306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5); 201062306a36Sopenharmony_ci } else if (bt_link_info->a2dp_exist) { 201162306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32); 201262306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 201362306a36Sopenharmony_ci } else if (bt_link_info->pan_exist) { 201462306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); 201562306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); 201662306a36Sopenharmony_ci } else { 201762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); 201862306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 201962306a36Sopenharmony_ci NORMAL_EXEC, false, false); 202062306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); 202162306a36Sopenharmony_ci } 202262306a36Sopenharmony_ci} 202362306a36Sopenharmony_ci 202462306a36Sopenharmony_cistatic void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist) 202562306a36Sopenharmony_ci{ 202662306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 202762306a36Sopenharmony_ci bool wifi_busy = false; 202862306a36Sopenharmony_ci bool scan = false, link = false, roam = false; 202962306a36Sopenharmony_ci bool under_4way = false, ap_enable = false; 203062306a36Sopenharmony_ci 203162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 203262306a36Sopenharmony_ci "[BTCoex], CoexForWifiConnect()===>\n"); 203362306a36Sopenharmony_ci 203462306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, 203562306a36Sopenharmony_ci &under_4way); 203662306a36Sopenharmony_ci if (under_4way) { 203762306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected_special_packet(btcoexist); 203862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 203962306a36Sopenharmony_ci "[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"); 204062306a36Sopenharmony_ci return; 204162306a36Sopenharmony_ci } 204262306a36Sopenharmony_ci 204362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); 204462306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); 204562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); 204662306a36Sopenharmony_ci 204762306a36Sopenharmony_ci if (scan || link || roam) { 204862306a36Sopenharmony_ci if (scan) 204962306a36Sopenharmony_ci btc8723b1ant_action_wifi_conn_scan(btcoexist); 205062306a36Sopenharmony_ci else 205162306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected_special_packet( 205262306a36Sopenharmony_ci btcoexist); 205362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 205462306a36Sopenharmony_ci "[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"); 205562306a36Sopenharmony_ci return; 205662306a36Sopenharmony_ci } 205762306a36Sopenharmony_ci 205862306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, 205962306a36Sopenharmony_ci &ap_enable); 206062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 206162306a36Sopenharmony_ci /* power save state */ 206262306a36Sopenharmony_ci if (!ap_enable && 206362306a36Sopenharmony_ci coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY && 206462306a36Sopenharmony_ci !btcoexist->bt_link_info.hid_only) { 206562306a36Sopenharmony_ci if (btcoexist->bt_link_info.a2dp_only) { 206662306a36Sopenharmony_ci if (!wifi_busy) { 206762306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, 206862306a36Sopenharmony_ci BTC_PS_WIFI_NATIVE, 206962306a36Sopenharmony_ci 0x0, 0x0); 207062306a36Sopenharmony_ci } else { /* busy */ 207162306a36Sopenharmony_ci if (coex_sta->scan_ap_num >= 207262306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_NOISY_THRESH) 207362306a36Sopenharmony_ci /* no force LPS, no PS-TDMA, 207462306a36Sopenharmony_ci * use pure TDMA 207562306a36Sopenharmony_ci */ 207662306a36Sopenharmony_ci halbtc8723b1ant_power_save_state( 207762306a36Sopenharmony_ci btcoexist, BTC_PS_WIFI_NATIVE, 207862306a36Sopenharmony_ci 0x0, 0x0); 207962306a36Sopenharmony_ci else 208062306a36Sopenharmony_ci halbtc8723b1ant_power_save_state( 208162306a36Sopenharmony_ci btcoexist, BTC_PS_LPS_ON, 0x50, 208262306a36Sopenharmony_ci 0x4); 208362306a36Sopenharmony_ci } 208462306a36Sopenharmony_ci } else if ((!coex_sta->pan_exist) && (!coex_sta->a2dp_exist) && 208562306a36Sopenharmony_ci (!coex_sta->hid_exist)) 208662306a36Sopenharmony_ci halbtc8723b1ant_power_save_state( 208762306a36Sopenharmony_ci btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); 208862306a36Sopenharmony_ci else 208962306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, 209062306a36Sopenharmony_ci BTC_PS_LPS_ON, 209162306a36Sopenharmony_ci 0x50, 0x4); 209262306a36Sopenharmony_ci } else { 209362306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 209462306a36Sopenharmony_ci 0x0, 0x0); 209562306a36Sopenharmony_ci } 209662306a36Sopenharmony_ci /* tdma and coex table */ 209762306a36Sopenharmony_ci if (!wifi_busy) { 209862306a36Sopenharmony_ci if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) { 209962306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected_bt_acl_busy( 210062306a36Sopenharmony_ci btcoexist, 210162306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); 210262306a36Sopenharmony_ci } else if (coex_dm->bt_status == 210362306a36Sopenharmony_ci BT_8723B_1ANT_BT_STATUS_SCO_BUSY || 210462306a36Sopenharmony_ci coex_dm->bt_status == 210562306a36Sopenharmony_ci BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) { 210662306a36Sopenharmony_ci btc8723b1ant_act_bt_sco_hid_only_busy(btcoexist, 210762306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); 210862306a36Sopenharmony_ci } else { 210962306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 211062306a36Sopenharmony_ci false, 8); 211162306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, 211262306a36Sopenharmony_ci BTC_ANT_PATH_PTA, 211362306a36Sopenharmony_ci NORMAL_EXEC, false, false); 211462306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 211562306a36Sopenharmony_ci NORMAL_EXEC, 2); 211662306a36Sopenharmony_ci } 211762306a36Sopenharmony_ci } else { 211862306a36Sopenharmony_ci if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) { 211962306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected_bt_acl_busy( 212062306a36Sopenharmony_ci btcoexist, 212162306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); 212262306a36Sopenharmony_ci } else if (coex_dm->bt_status == 212362306a36Sopenharmony_ci BT_8723B_1ANT_BT_STATUS_SCO_BUSY || 212462306a36Sopenharmony_ci coex_dm->bt_status == 212562306a36Sopenharmony_ci BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) { 212662306a36Sopenharmony_ci btc8723b1ant_act_bt_sco_hid_only_busy(btcoexist, 212762306a36Sopenharmony_ci BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); 212862306a36Sopenharmony_ci } else { 212962306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, 213062306a36Sopenharmony_ci true, 32); 213162306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, 213262306a36Sopenharmony_ci BTC_ANT_PATH_PTA, 213362306a36Sopenharmony_ci NORMAL_EXEC, false, false); 213462306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 213562306a36Sopenharmony_ci NORMAL_EXEC, 4); 213662306a36Sopenharmony_ci } 213762306a36Sopenharmony_ci } 213862306a36Sopenharmony_ci} 213962306a36Sopenharmony_ci 214062306a36Sopenharmony_cistatic void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) 214162306a36Sopenharmony_ci{ 214262306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 214362306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 214462306a36Sopenharmony_ci bool wifi_connected = false, bt_hs_on = false, wifi_busy = false; 214562306a36Sopenharmony_ci bool increase_scan_dev_num = false; 214662306a36Sopenharmony_ci bool bt_ctrl_agg_buf_size = false; 214762306a36Sopenharmony_ci bool miracast_plus_bt = false; 214862306a36Sopenharmony_ci u8 agg_buf_size = 5; 214962306a36Sopenharmony_ci u8 iot_peer = BTC_IOT_PEER_UNKNOWN; 215062306a36Sopenharmony_ci u32 wifi_link_status = 0; 215162306a36Sopenharmony_ci u32 num_of_wifi_link = 0; 215262306a36Sopenharmony_ci u32 wifi_bw; 215362306a36Sopenharmony_ci 215462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 215562306a36Sopenharmony_ci "[BTCoex], RunCoexistMechanism()===>\n"); 215662306a36Sopenharmony_ci 215762306a36Sopenharmony_ci if (btcoexist->manual_control) { 215862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 215962306a36Sopenharmony_ci "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"); 216062306a36Sopenharmony_ci return; 216162306a36Sopenharmony_ci } 216262306a36Sopenharmony_ci 216362306a36Sopenharmony_ci if (btcoexist->stop_coex_dm) { 216462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 216562306a36Sopenharmony_ci "[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"); 216662306a36Sopenharmony_ci return; 216762306a36Sopenharmony_ci } 216862306a36Sopenharmony_ci 216962306a36Sopenharmony_ci if (coex_sta->under_ips) { 217062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 217162306a36Sopenharmony_ci "[BTCoex], wifi is under IPS !!!\n"); 217262306a36Sopenharmony_ci return; 217362306a36Sopenharmony_ci } 217462306a36Sopenharmony_ci 217562306a36Sopenharmony_ci if (coex_sta->bt_whck_test) { 217662306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 217762306a36Sopenharmony_ci "[BTCoex], wifi is under IPS !!!\n"); 217862306a36Sopenharmony_ci halbtc8723b1ant_action_bt_whck_test(btcoexist); 217962306a36Sopenharmony_ci return; 218062306a36Sopenharmony_ci } 218162306a36Sopenharmony_ci 218262306a36Sopenharmony_ci if (coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_BUSY || 218362306a36Sopenharmony_ci coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_SCO_BUSY || 218462306a36Sopenharmony_ci coex_dm->bt_status == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) 218562306a36Sopenharmony_ci increase_scan_dev_num = true; 218662306a36Sopenharmony_ci 218762306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, 218862306a36Sopenharmony_ci &increase_scan_dev_num); 218962306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 219062306a36Sopenharmony_ci &wifi_connected); 219162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 219262306a36Sopenharmony_ci 219362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, 219462306a36Sopenharmony_ci &wifi_link_status); 219562306a36Sopenharmony_ci num_of_wifi_link = wifi_link_status >> 16; 219662306a36Sopenharmony_ci 219762306a36Sopenharmony_ci if (num_of_wifi_link >= 2 || 219862306a36Sopenharmony_ci wifi_link_status & WIFI_P2P_GO_CONNECTED) { 219962306a36Sopenharmony_ci if (bt_link_info->bt_link_exist) { 220062306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 1, 220162306a36Sopenharmony_ci 0, 1); 220262306a36Sopenharmony_ci miracast_plus_bt = true; 220362306a36Sopenharmony_ci } else { 220462306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 220562306a36Sopenharmony_ci 0, 0); 220662306a36Sopenharmony_ci miracast_plus_bt = false; 220762306a36Sopenharmony_ci } 220862306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_MIRACAST_PLUS_BT, 220962306a36Sopenharmony_ci &miracast_plus_bt); 221062306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, 221162306a36Sopenharmony_ci bt_ctrl_agg_buf_size, agg_buf_size); 221262306a36Sopenharmony_ci 221362306a36Sopenharmony_ci if ((bt_link_info->a2dp_exist || wifi_busy) && 221462306a36Sopenharmony_ci (coex_sta->c2h_bt_inquiry_page)) 221562306a36Sopenharmony_ci halbtc8723b1ant_action_bt_inquiry(btcoexist); 221662306a36Sopenharmony_ci else 221762306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_multiport(btcoexist); 221862306a36Sopenharmony_ci 221962306a36Sopenharmony_ci return; 222062306a36Sopenharmony_ci } 222162306a36Sopenharmony_ci 222262306a36Sopenharmony_ci miracast_plus_bt = false; 222362306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_MIRACAST_PLUS_BT, 222462306a36Sopenharmony_ci &miracast_plus_bt); 222562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); 222662306a36Sopenharmony_ci 222762306a36Sopenharmony_ci if (bt_link_info->bt_link_exist && wifi_connected) { 222862306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 1, 0, 1); 222962306a36Sopenharmony_ci 223062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U1_IOT_PEER, &iot_peer); 223162306a36Sopenharmony_ci 223262306a36Sopenharmony_ci if (iot_peer != BTC_IOT_PEER_CISCO && 223362306a36Sopenharmony_ci iot_peer != BTC_IOT_PEER_BROADCOM) { 223462306a36Sopenharmony_ci bool sco_exist = bt_link_info->sco_exist; 223562306a36Sopenharmony_ci 223662306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, 223762306a36Sopenharmony_ci NORMAL_EXEC, sco_exist, 223862306a36Sopenharmony_ci false, 0x5); 223962306a36Sopenharmony_ci } else { 224062306a36Sopenharmony_ci if (bt_link_info->sco_exist) { 224162306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, 224262306a36Sopenharmony_ci NORMAL_EXEC, true, 224362306a36Sopenharmony_ci false, 0x5); 224462306a36Sopenharmony_ci } else { 224562306a36Sopenharmony_ci if (wifi_bw == BTC_WIFI_BW_HT40) 224662306a36Sopenharmony_ci halbtc8723b1ant_limited_rx( 224762306a36Sopenharmony_ci btcoexist, NORMAL_EXEC, false, 224862306a36Sopenharmony_ci true, 0x10); 224962306a36Sopenharmony_ci else 225062306a36Sopenharmony_ci halbtc8723b1ant_limited_rx( 225162306a36Sopenharmony_ci btcoexist, NORMAL_EXEC, false, 225262306a36Sopenharmony_ci true, 0x8); 225362306a36Sopenharmony_ci } 225462306a36Sopenharmony_ci } 225562306a36Sopenharmony_ci 225662306a36Sopenharmony_ci halbtc8723b1ant_sw_mechanism(btcoexist, true); 225762306a36Sopenharmony_ci } else { 225862306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); 225962306a36Sopenharmony_ci 226062306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 226162306a36Sopenharmony_ci 0x5); 226262306a36Sopenharmony_ci 226362306a36Sopenharmony_ci halbtc8723b1ant_sw_mechanism(btcoexist, false); 226462306a36Sopenharmony_ci } 226562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 226662306a36Sopenharmony_ci 226762306a36Sopenharmony_ci if (coex_sta->c2h_bt_inquiry_page) { 226862306a36Sopenharmony_ci halbtc8723b1ant_action_bt_inquiry(btcoexist); 226962306a36Sopenharmony_ci return; 227062306a36Sopenharmony_ci } else if (bt_hs_on) { 227162306a36Sopenharmony_ci halbtc8723b1ant_action_hs(btcoexist); 227262306a36Sopenharmony_ci return; 227362306a36Sopenharmony_ci } 227462306a36Sopenharmony_ci 227562306a36Sopenharmony_ci if (!wifi_connected) { 227662306a36Sopenharmony_ci bool scan = false, link = false, roam = false; 227762306a36Sopenharmony_ci 227862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 227962306a36Sopenharmony_ci "[BTCoex], wifi is non connected-idle !!!\n"); 228062306a36Sopenharmony_ci 228162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); 228262306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); 228362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); 228462306a36Sopenharmony_ci 228562306a36Sopenharmony_ci if (scan || link || roam) { 228662306a36Sopenharmony_ci if (scan) 228762306a36Sopenharmony_ci btc8723b1ant_action_wifi_not_conn_scan( 228862306a36Sopenharmony_ci btcoexist); 228962306a36Sopenharmony_ci else 229062306a36Sopenharmony_ci btc8723b1ant_act_wifi_not_conn_asso_auth( 229162306a36Sopenharmony_ci btcoexist); 229262306a36Sopenharmony_ci } else { 229362306a36Sopenharmony_ci btc8723b1ant_action_wifi_not_conn(btcoexist); 229462306a36Sopenharmony_ci } 229562306a36Sopenharmony_ci } else { /* wifi LPS/Busy */ 229662306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected(btcoexist); 229762306a36Sopenharmony_ci } 229862306a36Sopenharmony_ci} 229962306a36Sopenharmony_ci 230062306a36Sopenharmony_ci/* force coex mechanism to reset */ 230162306a36Sopenharmony_cistatic void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) 230262306a36Sopenharmony_ci{ 230362306a36Sopenharmony_ci /* sw all off */ 230462306a36Sopenharmony_ci halbtc8723b1ant_sw_mechanism(btcoexist, false); 230562306a36Sopenharmony_ci 230662306a36Sopenharmony_ci coex_sta->pop_event_cnt = 0; 230762306a36Sopenharmony_ci} 230862306a36Sopenharmony_ci 230962306a36Sopenharmony_cistatic void halbtc8723b1ant_init_hw_config(struct btc_coexist *btcoexist, 231062306a36Sopenharmony_ci bool backup, bool wifi_only) 231162306a36Sopenharmony_ci{ 231262306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 231362306a36Sopenharmony_ci u32 u32tmp = 0; 231462306a36Sopenharmony_ci u8 u8tmpa = 0, u8tmpb = 0; 231562306a36Sopenharmony_ci 231662306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 231762306a36Sopenharmony_ci "[BTCoex], 1Ant Init HW Config!!\n"); 231862306a36Sopenharmony_ci 231962306a36Sopenharmony_ci /* 0xf0[15:12] --> Chip Cut information */ 232062306a36Sopenharmony_ci coex_sta->cut_version = 232162306a36Sopenharmony_ci (btcoexist->btc_read_1byte(btcoexist, 0xf1) & 0xf0) >> 4; 232262306a36Sopenharmony_ci /* enable TBTT interrupt */ 232362306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x550, 0x8, 0x1); 232462306a36Sopenharmony_ci 232562306a36Sopenharmony_ci /* 0x790[5:0] = 0x5 */ 232662306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x790, 0x5); 232762306a36Sopenharmony_ci 232862306a36Sopenharmony_ci /* Enable counter statistics */ 232962306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1); 233062306a36Sopenharmony_ci btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); 233162306a36Sopenharmony_ci 233262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); 233362306a36Sopenharmony_ci 233462306a36Sopenharmony_ci /* Antenna config */ 233562306a36Sopenharmony_ci if (wifi_only) 233662306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_WIFI, 233762306a36Sopenharmony_ci FORCE_EXEC, true, false); 233862306a36Sopenharmony_ci else 233962306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, 234062306a36Sopenharmony_ci FORCE_EXEC, true, false); 234162306a36Sopenharmony_ci 234262306a36Sopenharmony_ci /* PTA parameter */ 234362306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); 234462306a36Sopenharmony_ci 234562306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x948); 234662306a36Sopenharmony_ci u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765); 234762306a36Sopenharmony_ci u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x67); 234862306a36Sopenharmony_ci 234962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 235062306a36Sopenharmony_ci "############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", 235162306a36Sopenharmony_ci u32tmp, u8tmpa, u8tmpb); 235262306a36Sopenharmony_ci} 235362306a36Sopenharmony_ci 235462306a36Sopenharmony_ci/************************************************************** 235562306a36Sopenharmony_ci * extern function start with ex_btc8723b1ant_ 235662306a36Sopenharmony_ci **************************************************************/ 235762306a36Sopenharmony_civoid ex_btc8723b1ant_power_on_setting(struct btc_coexist *btcoexist) 235862306a36Sopenharmony_ci{ 235962306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 236062306a36Sopenharmony_ci struct btc_board_info *board_info = &btcoexist->board_info; 236162306a36Sopenharmony_ci u8 u8tmp = 0x0; 236262306a36Sopenharmony_ci u16 u16tmp = 0x0; 236362306a36Sopenharmony_ci u32 value; 236462306a36Sopenharmony_ci 236562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 236662306a36Sopenharmony_ci "xxxxxxxxxxxxxxxx Execute 8723b 1-Ant PowerOn Setting xxxxxxxxxxxxxxxx!!\n"); 236762306a36Sopenharmony_ci 236862306a36Sopenharmony_ci btcoexist->stop_coex_dm = true; 236962306a36Sopenharmony_ci 237062306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x67, 0x20); 237162306a36Sopenharmony_ci 237262306a36Sopenharmony_ci /* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */ 237362306a36Sopenharmony_ci u16tmp = btcoexist->btc_read_2byte(btcoexist, 0x2); 237462306a36Sopenharmony_ci btcoexist->btc_write_2byte(btcoexist, 0x2, u16tmp | BIT0 | BIT1); 237562306a36Sopenharmony_ci 237662306a36Sopenharmony_ci /* set GRAN_BT = 1 */ 237762306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x765, 0x18); 237862306a36Sopenharmony_ci /* set WLAN_ACT = 0 */ 237962306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); 238062306a36Sopenharmony_ci 238162306a36Sopenharmony_ci /* S0 or S1 setting and Local register setting(By the setting fw can get 238262306a36Sopenharmony_ci * ant number, S0/S1, ... info) 238362306a36Sopenharmony_ci * 238462306a36Sopenharmony_ci * Local setting bit define 238562306a36Sopenharmony_ci * BIT0: "0" for no antenna inverse; "1" for antenna inverse 238662306a36Sopenharmony_ci * BIT1: "0" for internal switch; "1" for external switch 238762306a36Sopenharmony_ci * BIT2: "0" for one antenna; "1" for two antenna 238862306a36Sopenharmony_ci * NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and 238962306a36Sopenharmony_ci * BIT2 = 0 239062306a36Sopenharmony_ci */ 239162306a36Sopenharmony_ci if (btcoexist->chip_interface == BTC_INTF_USB) { 239262306a36Sopenharmony_ci /* fixed at S0 for USB interface */ 239362306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x948, 0x0); 239462306a36Sopenharmony_ci 239562306a36Sopenharmony_ci u8tmp |= 0x1; /* antenna inverse */ 239662306a36Sopenharmony_ci btcoexist->btc_write_local_reg_1byte(btcoexist, 0xfe08, u8tmp); 239762306a36Sopenharmony_ci 239862306a36Sopenharmony_ci board_info->btdm_ant_pos = BTC_ANTENNA_AT_AUX_PORT; 239962306a36Sopenharmony_ci } else { 240062306a36Sopenharmony_ci /* for PCIE and SDIO interface, we check efuse 0xc3[6] */ 240162306a36Sopenharmony_ci if (board_info->single_ant_path == 0) { 240262306a36Sopenharmony_ci /* set to S1 */ 240362306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x948, 0x280); 240462306a36Sopenharmony_ci board_info->btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT; 240562306a36Sopenharmony_ci value = 1; 240662306a36Sopenharmony_ci } else if (board_info->single_ant_path == 1) { 240762306a36Sopenharmony_ci /* set to S0 */ 240862306a36Sopenharmony_ci btcoexist->btc_write_4byte(btcoexist, 0x948, 0x0); 240962306a36Sopenharmony_ci u8tmp |= 0x1; /* antenna inverse */ 241062306a36Sopenharmony_ci board_info->btdm_ant_pos = BTC_ANTENNA_AT_AUX_PORT; 241162306a36Sopenharmony_ci value = 0; 241262306a36Sopenharmony_ci } 241362306a36Sopenharmony_ci 241462306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_ACT_ANTPOSREGRISTRY_CTRL, 241562306a36Sopenharmony_ci &value); 241662306a36Sopenharmony_ci 241762306a36Sopenharmony_ci if (btcoexist->chip_interface == BTC_INTF_PCI) 241862306a36Sopenharmony_ci btcoexist->btc_write_local_reg_1byte(btcoexist, 0x384, 241962306a36Sopenharmony_ci u8tmp); 242062306a36Sopenharmony_ci else if (btcoexist->chip_interface == BTC_INTF_SDIO) 242162306a36Sopenharmony_ci btcoexist->btc_write_local_reg_1byte(btcoexist, 0x60, 242262306a36Sopenharmony_ci u8tmp); 242362306a36Sopenharmony_ci } 242462306a36Sopenharmony_ci} 242562306a36Sopenharmony_ci 242662306a36Sopenharmony_ci 242762306a36Sopenharmony_civoid ex_btc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist, 242862306a36Sopenharmony_ci bool wifi_only) 242962306a36Sopenharmony_ci{ 243062306a36Sopenharmony_ci halbtc8723b1ant_init_hw_config(btcoexist, true, wifi_only); 243162306a36Sopenharmony_ci btcoexist->stop_coex_dm = false; 243262306a36Sopenharmony_ci} 243362306a36Sopenharmony_ci 243462306a36Sopenharmony_civoid ex_btc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) 243562306a36Sopenharmony_ci{ 243662306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 243762306a36Sopenharmony_ci 243862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 243962306a36Sopenharmony_ci "[BTCoex], Coex Mechanism Init!!\n"); 244062306a36Sopenharmony_ci 244162306a36Sopenharmony_ci btcoexist->stop_coex_dm = false; 244262306a36Sopenharmony_ci 244362306a36Sopenharmony_ci halbtc8723b1ant_init_coex_dm(btcoexist); 244462306a36Sopenharmony_ci 244562306a36Sopenharmony_ci halbtc8723b1ant_query_bt_info(btcoexist); 244662306a36Sopenharmony_ci} 244762306a36Sopenharmony_ci 244862306a36Sopenharmony_civoid ex_btc8723b1ant_display_coex_info(struct btc_coexist *btcoexist, 244962306a36Sopenharmony_ci struct seq_file *m) 245062306a36Sopenharmony_ci{ 245162306a36Sopenharmony_ci struct btc_board_info *board_info = &btcoexist->board_info; 245262306a36Sopenharmony_ci struct btc_stack_info *stack_info = &btcoexist->stack_info; 245362306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 245462306a36Sopenharmony_ci u8 u8tmp[4], i, bt_info_ext, pstdmacase = 0; 245562306a36Sopenharmony_ci u16 u16tmp[4]; 245662306a36Sopenharmony_ci u32 u32tmp[4]; 245762306a36Sopenharmony_ci bool roam = false, scan = false; 245862306a36Sopenharmony_ci bool link = false, wifi_under_5g = false; 245962306a36Sopenharmony_ci bool bt_hs_on = false, wifi_busy = false; 246062306a36Sopenharmony_ci s32 wifi_rssi = 0, bt_hs_rssi = 0; 246162306a36Sopenharmony_ci u32 wifi_bw, wifi_traffic_dir, fa_ofdm, fa_cck, wifi_link_status; 246262306a36Sopenharmony_ci u8 wifi_dot11_chnl, wifi_hs_chnl; 246362306a36Sopenharmony_ci u32 fw_ver = 0, bt_patch_ver = 0; 246462306a36Sopenharmony_ci 246562306a36Sopenharmony_ci seq_puts(m, "\n ============[BT Coexist info]============"); 246662306a36Sopenharmony_ci 246762306a36Sopenharmony_ci if (btcoexist->manual_control) { 246862306a36Sopenharmony_ci seq_puts(m, "\n ============[Under Manual Control]=========="); 246962306a36Sopenharmony_ci seq_puts(m, "\n =========================================="); 247062306a36Sopenharmony_ci } 247162306a36Sopenharmony_ci if (btcoexist->stop_coex_dm) { 247262306a36Sopenharmony_ci seq_puts(m, "\n ============[Coex is STOPPED]============"); 247362306a36Sopenharmony_ci seq_puts(m, "\n =========================================="); 247462306a36Sopenharmony_ci } 247562306a36Sopenharmony_ci 247662306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/ %d/ %d", 247762306a36Sopenharmony_ci "Ant PG Num/ Ant Mech/ Ant Pos:", 247862306a36Sopenharmony_ci board_info->pg_ant_num, board_info->btdm_ant_num, 247962306a36Sopenharmony_ci board_info->btdm_ant_pos); 248062306a36Sopenharmony_ci 248162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %s / %d", 248262306a36Sopenharmony_ci "BT stack/ hci ext ver", 248362306a36Sopenharmony_ci ((stack_info->profile_notified) ? "Yes" : "No"), 248462306a36Sopenharmony_ci stack_info->hci_version); 248562306a36Sopenharmony_ci 248662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); 248762306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); 248862306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", 248962306a36Sopenharmony_ci "CoexVer/ FwVer/ PatchVer", 249062306a36Sopenharmony_ci glcoex_ver_date_8723b_1ant, glcoex_ver_8723b_1ant, 249162306a36Sopenharmony_ci fw_ver, bt_patch_ver, bt_patch_ver); 249262306a36Sopenharmony_ci 249362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 249462306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, 249562306a36Sopenharmony_ci &wifi_dot11_chnl); 249662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); 249762306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d / %d(%d)", 249862306a36Sopenharmony_ci "Dot11 channel / HsChnl(HsMode)", 249962306a36Sopenharmony_ci wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on); 250062306a36Sopenharmony_ci 250162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %3ph ", 250262306a36Sopenharmony_ci "H2C Wifi inform bt chnl Info", 250362306a36Sopenharmony_ci coex_dm->wifi_chnl_info); 250462306a36Sopenharmony_ci 250562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); 250662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); 250762306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/ %d", 250862306a36Sopenharmony_ci "Wifi rssi/ HS rssi", wifi_rssi, bt_hs_rssi); 250962306a36Sopenharmony_ci 251062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); 251162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); 251262306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); 251362306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/ %d/ %d ", 251462306a36Sopenharmony_ci "Wifi link/ roam/ scan", link, roam, scan); 251562306a36Sopenharmony_ci 251662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist , BTC_GET_BL_WIFI_UNDER_5G, 251762306a36Sopenharmony_ci &wifi_under_5g); 251862306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); 251962306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); 252062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, 252162306a36Sopenharmony_ci &wifi_traffic_dir); 252262306a36Sopenharmony_ci 252362306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %s / %s/ %s ", 252462306a36Sopenharmony_ci "Wifi status", (wifi_under_5g ? "5G" : "2.4G"), 252562306a36Sopenharmony_ci ((wifi_bw == BTC_WIFI_BW_LEGACY) ? "Legacy" : 252662306a36Sopenharmony_ci ((wifi_bw == BTC_WIFI_BW_HT40) ? "HT40" : "HT20")), 252762306a36Sopenharmony_ci ((!wifi_busy) ? "idle" : 252862306a36Sopenharmony_ci ((wifi_traffic_dir == BTC_WIFI_TRAFFIC_TX) ? 252962306a36Sopenharmony_ci "uplink" : "downlink"))); 253062306a36Sopenharmony_ci 253162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, 253262306a36Sopenharmony_ci &wifi_link_status); 253362306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/ %d/ %d/ %d/ %d", 253462306a36Sopenharmony_ci "sta/vwifi/hs/p2pGo/p2pGc", 253562306a36Sopenharmony_ci ((wifi_link_status & WIFI_STA_CONNECTED) ? 1 : 0), 253662306a36Sopenharmony_ci ((wifi_link_status & WIFI_AP_CONNECTED) ? 1 : 0), 253762306a36Sopenharmony_ci ((wifi_link_status & WIFI_HS_CONNECTED) ? 1 : 0), 253862306a36Sopenharmony_ci ((wifi_link_status & WIFI_P2P_GO_CONNECTED) ? 1 : 0), 253962306a36Sopenharmony_ci ((wifi_link_status & WIFI_P2P_GC_CONNECTED) ? 1 : 0)); 254062306a36Sopenharmony_ci 254162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = [%s/ %d/ %d] ", 254262306a36Sopenharmony_ci "BT [status/ rssi/ retryCnt]", 254362306a36Sopenharmony_ci ((coex_sta->bt_disabled) ? ("disabled") : 254462306a36Sopenharmony_ci ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") : 254562306a36Sopenharmony_ci ((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == 254662306a36Sopenharmony_ci coex_dm->bt_status) ? 254762306a36Sopenharmony_ci "non-connected idle" : 254862306a36Sopenharmony_ci ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == 254962306a36Sopenharmony_ci coex_dm->bt_status) ? 255062306a36Sopenharmony_ci "connected-idle" : "busy")))), 255162306a36Sopenharmony_ci coex_sta->bt_rssi, coex_sta->bt_retry_cnt); 255262306a36Sopenharmony_ci 255362306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d / %d / %d / %d", 255462306a36Sopenharmony_ci "SCO/HID/PAN/A2DP", bt_link_info->sco_exist, 255562306a36Sopenharmony_ci bt_link_info->hid_exist, bt_link_info->pan_exist, 255662306a36Sopenharmony_ci bt_link_info->a2dp_exist); 255762306a36Sopenharmony_ci btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO, m); 255862306a36Sopenharmony_ci 255962306a36Sopenharmony_ci bt_info_ext = coex_sta->bt_info_ext; 256062306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %s", 256162306a36Sopenharmony_ci "BT Info A2DP rate", 256262306a36Sopenharmony_ci (bt_info_ext & BIT0) ? "Basic rate" : "EDR rate"); 256362306a36Sopenharmony_ci 256462306a36Sopenharmony_ci for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) { 256562306a36Sopenharmony_ci if (coex_sta->bt_info_c2h_cnt[i]) { 256662306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %7ph(%d)", 256762306a36Sopenharmony_ci glbt_info_src_8723b_1ant[i], 256862306a36Sopenharmony_ci coex_sta->bt_info_c2h[i], 256962306a36Sopenharmony_ci coex_sta->bt_info_c2h_cnt[i]); 257062306a36Sopenharmony_ci } 257162306a36Sopenharmony_ci } 257262306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %s/%s, (0x%x/0x%x)", 257362306a36Sopenharmony_ci "PS state, IPS/LPS, (lps/rpwm)", 257462306a36Sopenharmony_ci ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), 257562306a36Sopenharmony_ci ((coex_sta->under_lps ? "LPS ON" : "LPS OFF")), 257662306a36Sopenharmony_ci btcoexist->bt_info.lps_val, 257762306a36Sopenharmony_ci btcoexist->bt_info.rpwm_val); 257862306a36Sopenharmony_ci btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD, m); 257962306a36Sopenharmony_ci 258062306a36Sopenharmony_ci if (!btcoexist->manual_control) { 258162306a36Sopenharmony_ci /* Sw mechanism */ 258262306a36Sopenharmony_ci seq_printf(m, "\n %-35s", 258362306a36Sopenharmony_ci "============[Sw mechanism]============"); 258462306a36Sopenharmony_ci 258562306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/", 258662306a36Sopenharmony_ci "SM[LowPenaltyRA]", coex_dm->cur_low_penalty_ra); 258762306a36Sopenharmony_ci 258862306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %s/ %s/ %d ", 258962306a36Sopenharmony_ci "DelBA/ BtCtrlAgg/ AggSize", 259062306a36Sopenharmony_ci (btcoexist->bt_info.reject_agg_pkt ? "Yes" : "No"), 259162306a36Sopenharmony_ci (btcoexist->bt_info.bt_ctrl_buf_size ? "Yes" : "No"), 259262306a36Sopenharmony_ci btcoexist->bt_info.agg_buf_size); 259362306a36Sopenharmony_ci 259462306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x ", 259562306a36Sopenharmony_ci "Rate Mask", btcoexist->bt_info.ra_mask); 259662306a36Sopenharmony_ci 259762306a36Sopenharmony_ci /* Fw mechanism */ 259862306a36Sopenharmony_ci seq_printf(m, "\n %-35s", 259962306a36Sopenharmony_ci "============[Fw mechanism]============"); 260062306a36Sopenharmony_ci 260162306a36Sopenharmony_ci pstdmacase = coex_dm->cur_ps_tdma; 260262306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %5ph case-%d (auto:%d)", 260362306a36Sopenharmony_ci "PS TDMA", coex_dm->ps_tdma_para, 260462306a36Sopenharmony_ci pstdmacase, coex_dm->auto_tdma_adjust); 260562306a36Sopenharmony_ci 260662306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d ", 260762306a36Sopenharmony_ci "IgnWlanAct", coex_dm->cur_ignore_wlan_act); 260862306a36Sopenharmony_ci 260962306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x ", 261062306a36Sopenharmony_ci "Latest error condition(should be 0)", 261162306a36Sopenharmony_ci coex_dm->error_condition); 261262306a36Sopenharmony_ci } 261362306a36Sopenharmony_ci 261462306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d", 261562306a36Sopenharmony_ci "Coex Table Type", coex_sta->coex_table_type); 261662306a36Sopenharmony_ci 261762306a36Sopenharmony_ci /* Hw setting */ 261862306a36Sopenharmony_ci seq_printf(m, "\n %-35s", 261962306a36Sopenharmony_ci "============[Hw setting]============"); 262062306a36Sopenharmony_ci 262162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/0x%x/0x%x/0x%x", 262262306a36Sopenharmony_ci "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm->backup_arfr_cnt1, 262362306a36Sopenharmony_ci coex_dm->backup_arfr_cnt2, coex_dm->backup_retry_limit, 262462306a36Sopenharmony_ci coex_dm->backup_ampdu_max_time); 262562306a36Sopenharmony_ci 262662306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430); 262762306a36Sopenharmony_ci u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434); 262862306a36Sopenharmony_ci u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a); 262962306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456); 263062306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/0x%x/0x%x/0x%x", 263162306a36Sopenharmony_ci "0x430/0x434/0x42a/0x456", 263262306a36Sopenharmony_ci u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]); 263362306a36Sopenharmony_ci 263462306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); 263562306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6cc); 263662306a36Sopenharmony_ci u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x880); 263762306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x", 263862306a36Sopenharmony_ci "0x778/0x6cc/0x880[29:25]", u8tmp[0], u32tmp[0], 263962306a36Sopenharmony_ci (u32tmp[1] & 0x3e000000) >> 25); 264062306a36Sopenharmony_ci 264162306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x948); 264262306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x67); 264362306a36Sopenharmony_ci u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x765); 264462306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x", 264562306a36Sopenharmony_ci "0x948/ 0x67[5] / 0x765", 264662306a36Sopenharmony_ci u32tmp[0], ((u8tmp[0] & 0x20) >> 5), u8tmp[1]); 264762306a36Sopenharmony_ci 264862306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x92c); 264962306a36Sopenharmony_ci u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x930); 265062306a36Sopenharmony_ci u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x944); 265162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x", 265262306a36Sopenharmony_ci "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", 265362306a36Sopenharmony_ci u32tmp[0] & 0x3, u32tmp[1] & 0xff, u32tmp[2] & 0x3); 265462306a36Sopenharmony_ci 265562306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x39); 265662306a36Sopenharmony_ci u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40); 265762306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); 265862306a36Sopenharmony_ci u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0x64); 265962306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", 266062306a36Sopenharmony_ci "0x38[11]/0x40/0x4c[24:23]/0x64[0]", 266162306a36Sopenharmony_ci ((u8tmp[0] & 0x8) >> 3), u8tmp[1], 266262306a36Sopenharmony_ci ((u32tmp[0] & 0x01800000) >> 23), u8tmp[2] & 0x1); 266362306a36Sopenharmony_ci 266462306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); 266562306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); 266662306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x", 266762306a36Sopenharmony_ci "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]); 266862306a36Sopenharmony_ci 266962306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); 267062306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c); 267162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x", 267262306a36Sopenharmony_ci "0xc50(dig)/0x49c(null-drop)", u32tmp[0] & 0xff, u8tmp[0]); 267362306a36Sopenharmony_ci 267462306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0); 267562306a36Sopenharmony_ci u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4); 267662306a36Sopenharmony_ci u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8); 267762306a36Sopenharmony_ci u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0); 267862306a36Sopenharmony_ci 267962306a36Sopenharmony_ci u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b); 268062306a36Sopenharmony_ci u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); 268162306a36Sopenharmony_ci 268262306a36Sopenharmony_ci fa_ofdm = ((u32tmp[0] & 0xffff0000) >> 16) + 268362306a36Sopenharmony_ci ((u32tmp[1] & 0xffff0000) >> 16) + 268462306a36Sopenharmony_ci (u32tmp[1] & 0xffff) + 268562306a36Sopenharmony_ci (u32tmp[2] & 0xffff) + 268662306a36Sopenharmony_ci ((u32tmp[3] & 0xffff0000) >> 16) + 268762306a36Sopenharmony_ci (u32tmp[3] & 0xffff); 268862306a36Sopenharmony_ci fa_cck = (u8tmp[0] << 8) + u8tmp[1]; 268962306a36Sopenharmony_ci 269062306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x", 269162306a36Sopenharmony_ci "OFDM-CCA/OFDM-FA/CCK-FA", 269262306a36Sopenharmony_ci u32tmp[0] & 0xffff, fa_ofdm, fa_cck); 269362306a36Sopenharmony_ci 269462306a36Sopenharmony_ci u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); 269562306a36Sopenharmony_ci u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); 269662306a36Sopenharmony_ci u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); 269762306a36Sopenharmony_ci seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x", 269862306a36Sopenharmony_ci "0x6c0/0x6c4/0x6c8(coexTable)", 269962306a36Sopenharmony_ci u32tmp[0], u32tmp[1], u32tmp[2]); 270062306a36Sopenharmony_ci 270162306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/ %d", 270262306a36Sopenharmony_ci "0x770(high-pri rx/tx)", coex_sta->high_priority_rx, 270362306a36Sopenharmony_ci coex_sta->high_priority_tx); 270462306a36Sopenharmony_ci seq_printf(m, "\n %-35s = %d/ %d", 270562306a36Sopenharmony_ci "0x774(low-pri rx/tx)", coex_sta->low_priority_rx, 270662306a36Sopenharmony_ci coex_sta->low_priority_tx); 270762306a36Sopenharmony_ci if (btcoexist->auto_report_1ant) 270862306a36Sopenharmony_ci halbtc8723b1ant_monitor_bt_ctr(btcoexist); 270962306a36Sopenharmony_ci btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS, m); 271062306a36Sopenharmony_ci} 271162306a36Sopenharmony_ci 271262306a36Sopenharmony_civoid ex_btc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type) 271362306a36Sopenharmony_ci{ 271462306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 271562306a36Sopenharmony_ci 271662306a36Sopenharmony_ci if (btcoexist->manual_control || btcoexist->stop_coex_dm) 271762306a36Sopenharmony_ci return; 271862306a36Sopenharmony_ci 271962306a36Sopenharmony_ci if (BTC_IPS_ENTER == type) { 272062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 272162306a36Sopenharmony_ci "[BTCoex], IPS ENTER notify\n"); 272262306a36Sopenharmony_ci coex_sta->under_ips = true; 272362306a36Sopenharmony_ci 272462306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, 272562306a36Sopenharmony_ci FORCE_EXEC, false, true); 272662306a36Sopenharmony_ci /* set PTA control */ 272762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); 272862306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, 272962306a36Sopenharmony_ci NORMAL_EXEC, 0); 273062306a36Sopenharmony_ci } else if (BTC_IPS_LEAVE == type) { 273162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 273262306a36Sopenharmony_ci "[BTCoex], IPS LEAVE notify\n"); 273362306a36Sopenharmony_ci coex_sta->under_ips = false; 273462306a36Sopenharmony_ci 273562306a36Sopenharmony_ci halbtc8723b1ant_init_hw_config(btcoexist, false, false); 273662306a36Sopenharmony_ci halbtc8723b1ant_init_coex_dm(btcoexist); 273762306a36Sopenharmony_ci halbtc8723b1ant_query_bt_info(btcoexist); 273862306a36Sopenharmony_ci } 273962306a36Sopenharmony_ci} 274062306a36Sopenharmony_ci 274162306a36Sopenharmony_civoid ex_btc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type) 274262306a36Sopenharmony_ci{ 274362306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 274462306a36Sopenharmony_ci 274562306a36Sopenharmony_ci if (btcoexist->manual_control || btcoexist->stop_coex_dm) 274662306a36Sopenharmony_ci return; 274762306a36Sopenharmony_ci 274862306a36Sopenharmony_ci if (BTC_LPS_ENABLE == type) { 274962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 275062306a36Sopenharmony_ci "[BTCoex], LPS ENABLE notify\n"); 275162306a36Sopenharmony_ci coex_sta->under_lps = true; 275262306a36Sopenharmony_ci } else if (BTC_LPS_DISABLE == type) { 275362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 275462306a36Sopenharmony_ci "[BTCoex], LPS DISABLE notify\n"); 275562306a36Sopenharmony_ci coex_sta->under_lps = false; 275662306a36Sopenharmony_ci } 275762306a36Sopenharmony_ci} 275862306a36Sopenharmony_ci 275962306a36Sopenharmony_civoid ex_btc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type) 276062306a36Sopenharmony_ci{ 276162306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 276262306a36Sopenharmony_ci bool wifi_connected = false, bt_hs_on = false; 276362306a36Sopenharmony_ci u8 u8tmpa, u8tmpb; 276462306a36Sopenharmony_ci u32 u32tmp; 276562306a36Sopenharmony_ci u32 wifi_link_status = 0; 276662306a36Sopenharmony_ci u32 num_of_wifi_link = 0; 276762306a36Sopenharmony_ci bool bt_ctrl_agg_buf_size = false; 276862306a36Sopenharmony_ci u8 agg_buf_size = 5; 276962306a36Sopenharmony_ci 277062306a36Sopenharmony_ci if (btcoexist->manual_control || btcoexist->stop_coex_dm) 277162306a36Sopenharmony_ci return; 277262306a36Sopenharmony_ci 277362306a36Sopenharmony_ci if (type == BTC_SCAN_START) { 277462306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = true; 277562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 277662306a36Sopenharmony_ci "[BTCoex], SCAN START notify\n"); 277762306a36Sopenharmony_ci /* Force antenna setup for no scan result issue */ 277862306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); 277962306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 278062306a36Sopenharmony_ci FORCE_EXEC, false, false); 278162306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x948); 278262306a36Sopenharmony_ci u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765); 278362306a36Sopenharmony_ci u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x67); 278462306a36Sopenharmony_ci 278562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 278662306a36Sopenharmony_ci "[BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", 278762306a36Sopenharmony_ci u32tmp, u8tmpa, u8tmpb); 278862306a36Sopenharmony_ci } else { 278962306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = false; 279062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 279162306a36Sopenharmony_ci "[BTCoex], SCAN FINISH notify\n"); 279262306a36Sopenharmony_ci 279362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, 279462306a36Sopenharmony_ci &coex_sta->scan_ap_num); 279562306a36Sopenharmony_ci } 279662306a36Sopenharmony_ci 279762306a36Sopenharmony_ci if (coex_sta->bt_disabled) 279862306a36Sopenharmony_ci return; 279962306a36Sopenharmony_ci 280062306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 280162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 280262306a36Sopenharmony_ci &wifi_connected); 280362306a36Sopenharmony_ci 280462306a36Sopenharmony_ci halbtc8723b1ant_query_bt_info(btcoexist); 280562306a36Sopenharmony_ci 280662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, 280762306a36Sopenharmony_ci &wifi_link_status); 280862306a36Sopenharmony_ci num_of_wifi_link = wifi_link_status >> 16; 280962306a36Sopenharmony_ci if (num_of_wifi_link >= 2) { 281062306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); 281162306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, 281262306a36Sopenharmony_ci bt_ctrl_agg_buf_size, agg_buf_size); 281362306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_multiport(btcoexist); 281462306a36Sopenharmony_ci return; 281562306a36Sopenharmony_ci } 281662306a36Sopenharmony_ci 281762306a36Sopenharmony_ci if (coex_sta->c2h_bt_inquiry_page) { 281862306a36Sopenharmony_ci halbtc8723b1ant_action_bt_inquiry(btcoexist); 281962306a36Sopenharmony_ci return; 282062306a36Sopenharmony_ci } else if (bt_hs_on) { 282162306a36Sopenharmony_ci halbtc8723b1ant_action_hs(btcoexist); 282262306a36Sopenharmony_ci return; 282362306a36Sopenharmony_ci } 282462306a36Sopenharmony_ci 282562306a36Sopenharmony_ci if (BTC_SCAN_START == type) { 282662306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 282762306a36Sopenharmony_ci "[BTCoex], SCAN START notify\n"); 282862306a36Sopenharmony_ci if (!wifi_connected) 282962306a36Sopenharmony_ci /* non-connected scan */ 283062306a36Sopenharmony_ci btc8723b1ant_action_wifi_not_conn_scan(btcoexist); 283162306a36Sopenharmony_ci else 283262306a36Sopenharmony_ci /* wifi is connected */ 283362306a36Sopenharmony_ci btc8723b1ant_action_wifi_conn_scan(btcoexist); 283462306a36Sopenharmony_ci } else if (BTC_SCAN_FINISH == type) { 283562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 283662306a36Sopenharmony_ci "[BTCoex], SCAN FINISH notify\n"); 283762306a36Sopenharmony_ci if (!wifi_connected) 283862306a36Sopenharmony_ci /* non-connected scan */ 283962306a36Sopenharmony_ci btc8723b1ant_action_wifi_not_conn(btcoexist); 284062306a36Sopenharmony_ci else 284162306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected(btcoexist); 284262306a36Sopenharmony_ci } 284362306a36Sopenharmony_ci} 284462306a36Sopenharmony_ci 284562306a36Sopenharmony_civoid ex_btc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type) 284662306a36Sopenharmony_ci{ 284762306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 284862306a36Sopenharmony_ci bool wifi_connected = false, bt_hs_on = false; 284962306a36Sopenharmony_ci u32 wifi_link_status = 0; 285062306a36Sopenharmony_ci u32 num_of_wifi_link = 0; 285162306a36Sopenharmony_ci bool bt_ctrl_agg_buf_size = false, under_4way = false; 285262306a36Sopenharmony_ci u8 agg_buf_size = 5; 285362306a36Sopenharmony_ci 285462306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, 285562306a36Sopenharmony_ci &under_4way); 285662306a36Sopenharmony_ci 285762306a36Sopenharmony_ci if (btcoexist->manual_control || btcoexist->stop_coex_dm || 285862306a36Sopenharmony_ci coex_sta->bt_disabled) 285962306a36Sopenharmony_ci return; 286062306a36Sopenharmony_ci 286162306a36Sopenharmony_ci if (type == BTC_ASSOCIATE_START) { 286262306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = true; 286362306a36Sopenharmony_ci 286462306a36Sopenharmony_ci /* Force antenna setup for no scan result issue */ 286562306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); 286662306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 286762306a36Sopenharmony_ci FORCE_EXEC, false, false); 286862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 286962306a36Sopenharmony_ci "[BTCoex], CONNECT START notify\n"); 287062306a36Sopenharmony_ci coex_dm->arp_cnt = 0; 287162306a36Sopenharmony_ci } else { 287262306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = false; 287362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 287462306a36Sopenharmony_ci "[BTCoex], CONNECT FINISH notify\n"); 287562306a36Sopenharmony_ci } 287662306a36Sopenharmony_ci 287762306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, 287862306a36Sopenharmony_ci &wifi_link_status); 287962306a36Sopenharmony_ci num_of_wifi_link = wifi_link_status>>16; 288062306a36Sopenharmony_ci if (num_of_wifi_link >= 2) { 288162306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); 288262306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, 288362306a36Sopenharmony_ci bt_ctrl_agg_buf_size, agg_buf_size); 288462306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_multiport(btcoexist); 288562306a36Sopenharmony_ci return; 288662306a36Sopenharmony_ci } 288762306a36Sopenharmony_ci 288862306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 288962306a36Sopenharmony_ci if (coex_sta->c2h_bt_inquiry_page) { 289062306a36Sopenharmony_ci halbtc8723b1ant_action_bt_inquiry(btcoexist); 289162306a36Sopenharmony_ci return; 289262306a36Sopenharmony_ci } else if (bt_hs_on) { 289362306a36Sopenharmony_ci halbtc8723b1ant_action_hs(btcoexist); 289462306a36Sopenharmony_ci return; 289562306a36Sopenharmony_ci } 289662306a36Sopenharmony_ci 289762306a36Sopenharmony_ci if (BTC_ASSOCIATE_START == type) { 289862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 289962306a36Sopenharmony_ci "[BTCoex], CONNECT START notify\n"); 290062306a36Sopenharmony_ci btc8723b1ant_act_wifi_not_conn_asso_auth(btcoexist); 290162306a36Sopenharmony_ci } else if (BTC_ASSOCIATE_FINISH == type) { 290262306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 290362306a36Sopenharmony_ci "[BTCoex], CONNECT FINISH notify\n"); 290462306a36Sopenharmony_ci 290562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 290662306a36Sopenharmony_ci &wifi_connected); 290762306a36Sopenharmony_ci if (!wifi_connected) 290862306a36Sopenharmony_ci /* non-connected scan */ 290962306a36Sopenharmony_ci btc8723b1ant_action_wifi_not_conn(btcoexist); 291062306a36Sopenharmony_ci else 291162306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected(btcoexist); 291262306a36Sopenharmony_ci } 291362306a36Sopenharmony_ci} 291462306a36Sopenharmony_ci 291562306a36Sopenharmony_civoid ex_btc8723b1ant_media_status_notify(struct btc_coexist *btcoexist, 291662306a36Sopenharmony_ci u8 type) 291762306a36Sopenharmony_ci{ 291862306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 291962306a36Sopenharmony_ci u8 h2c_parameter[3] = {0}; 292062306a36Sopenharmony_ci u32 wifi_bw; 292162306a36Sopenharmony_ci u8 wifi_central_chnl; 292262306a36Sopenharmony_ci bool wifi_under_b_mode = false; 292362306a36Sopenharmony_ci 292462306a36Sopenharmony_ci if (btcoexist->manual_control || btcoexist->stop_coex_dm || 292562306a36Sopenharmony_ci coex_sta->bt_disabled) 292662306a36Sopenharmony_ci return; 292762306a36Sopenharmony_ci 292862306a36Sopenharmony_ci if (type == BTC_MEDIA_CONNECT) { 292962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 293062306a36Sopenharmony_ci "[BTCoex], MEDIA connect notify\n"); 293162306a36Sopenharmony_ci /* Force antenna setup for no scan result issue */ 293262306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); 293362306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, 293462306a36Sopenharmony_ci FORCE_EXEC, false, false); 293562306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, 293662306a36Sopenharmony_ci &wifi_under_b_mode); 293762306a36Sopenharmony_ci 293862306a36Sopenharmony_ci /* Set CCK Tx/Rx high Pri except 11b mode */ 293962306a36Sopenharmony_ci if (wifi_under_b_mode) { 294062306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cd, 294162306a36Sopenharmony_ci 0x00); /* CCK Tx */ 294262306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cf, 294362306a36Sopenharmony_ci 0x00); /* CCK Rx */ 294462306a36Sopenharmony_ci } else { 294562306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cd, 294662306a36Sopenharmony_ci 0x00); /* CCK Tx */ 294762306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cf, 294862306a36Sopenharmony_ci 0x10); /* CCK Rx */ 294962306a36Sopenharmony_ci } 295062306a36Sopenharmony_ci 295162306a36Sopenharmony_ci coex_dm->backup_arfr_cnt1 = 295262306a36Sopenharmony_ci btcoexist->btc_read_4byte(btcoexist, 0x430); 295362306a36Sopenharmony_ci coex_dm->backup_arfr_cnt2 = 295462306a36Sopenharmony_ci btcoexist->btc_read_4byte(btcoexist, 0x434); 295562306a36Sopenharmony_ci coex_dm->backup_retry_limit = 295662306a36Sopenharmony_ci btcoexist->btc_read_2byte(btcoexist, 0x42a); 295762306a36Sopenharmony_ci coex_dm->backup_ampdu_max_time = 295862306a36Sopenharmony_ci btcoexist->btc_read_1byte(btcoexist, 0x456); 295962306a36Sopenharmony_ci } else { 296062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 296162306a36Sopenharmony_ci "[BTCoex], MEDIA disconnect notify\n"); 296262306a36Sopenharmony_ci coex_dm->arp_cnt = 0; 296362306a36Sopenharmony_ci 296462306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cd, 0x0); /* CCK Tx */ 296562306a36Sopenharmony_ci btcoexist->btc_write_1byte(btcoexist, 0x6cf, 0x0); /* CCK Rx */ 296662306a36Sopenharmony_ci 296762306a36Sopenharmony_ci coex_sta->cck_ever_lock = false; 296862306a36Sopenharmony_ci } 296962306a36Sopenharmony_ci 297062306a36Sopenharmony_ci /* only 2.4G we need to inform bt the chnl mask */ 297162306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, 297262306a36Sopenharmony_ci &wifi_central_chnl); 297362306a36Sopenharmony_ci 297462306a36Sopenharmony_ci if (type == BTC_MEDIA_CONNECT && wifi_central_chnl <= 14) { 297562306a36Sopenharmony_ci h2c_parameter[0] = 0x0; 297662306a36Sopenharmony_ci h2c_parameter[1] = wifi_central_chnl; 297762306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); 297862306a36Sopenharmony_ci if (BTC_WIFI_BW_HT40 == wifi_bw) 297962306a36Sopenharmony_ci h2c_parameter[2] = 0x30; 298062306a36Sopenharmony_ci else 298162306a36Sopenharmony_ci h2c_parameter[2] = 0x20; 298262306a36Sopenharmony_ci } 298362306a36Sopenharmony_ci 298462306a36Sopenharmony_ci coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; 298562306a36Sopenharmony_ci coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; 298662306a36Sopenharmony_ci coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; 298762306a36Sopenharmony_ci 298862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 298962306a36Sopenharmony_ci "[BTCoex], FW write 0x66 = 0x%x\n", 299062306a36Sopenharmony_ci h2c_parameter[0] << 16 | h2c_parameter[1] << 8 | 299162306a36Sopenharmony_ci h2c_parameter[2]); 299262306a36Sopenharmony_ci 299362306a36Sopenharmony_ci btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); 299462306a36Sopenharmony_ci} 299562306a36Sopenharmony_ci 299662306a36Sopenharmony_civoid ex_btc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist, 299762306a36Sopenharmony_ci u8 type) 299862306a36Sopenharmony_ci{ 299962306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 300062306a36Sopenharmony_ci bool bt_hs_on = false; 300162306a36Sopenharmony_ci u32 wifi_link_status = 0; 300262306a36Sopenharmony_ci u32 num_of_wifi_link = 0; 300362306a36Sopenharmony_ci bool bt_ctrl_agg_buf_size = false, under_4way = false; 300462306a36Sopenharmony_ci u8 agg_buf_size = 5; 300562306a36Sopenharmony_ci 300662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, 300762306a36Sopenharmony_ci &under_4way); 300862306a36Sopenharmony_ci 300962306a36Sopenharmony_ci if (btcoexist->manual_control || btcoexist->stop_coex_dm || 301062306a36Sopenharmony_ci coex_sta->bt_disabled) 301162306a36Sopenharmony_ci return; 301262306a36Sopenharmony_ci 301362306a36Sopenharmony_ci if (type == BTC_PACKET_DHCP || type == BTC_PACKET_EAPOL || 301462306a36Sopenharmony_ci type == BTC_PACKET_ARP) { 301562306a36Sopenharmony_ci if (type == BTC_PACKET_ARP) { 301662306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 301762306a36Sopenharmony_ci "[BTCoex], special Packet ARP notify\n"); 301862306a36Sopenharmony_ci 301962306a36Sopenharmony_ci coex_dm->arp_cnt++; 302062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 302162306a36Sopenharmony_ci "[BTCoex], ARP Packet Count = %d\n", 302262306a36Sopenharmony_ci coex_dm->arp_cnt); 302362306a36Sopenharmony_ci 302462306a36Sopenharmony_ci if ((coex_dm->arp_cnt >= 10) && (!under_4way)) 302562306a36Sopenharmony_ci /* if APR PKT > 10 after connect, do not go to 302662306a36Sopenharmony_ci * ActionWifiConnectedSpecificPacket(btcoexist) 302762306a36Sopenharmony_ci */ 302862306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = false; 302962306a36Sopenharmony_ci else 303062306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = true; 303162306a36Sopenharmony_ci } else { 303262306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = true; 303362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 303462306a36Sopenharmony_ci "[BTCoex], special Packet DHCP or EAPOL notify\n"); 303562306a36Sopenharmony_ci } 303662306a36Sopenharmony_ci } else { 303762306a36Sopenharmony_ci coex_sta->wifi_is_high_pri_task = false; 303862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 303962306a36Sopenharmony_ci "[BTCoex], special Packet [Type = %d] notify\n", 304062306a36Sopenharmony_ci type); 304162306a36Sopenharmony_ci } 304262306a36Sopenharmony_ci 304362306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, 304462306a36Sopenharmony_ci &wifi_link_status); 304562306a36Sopenharmony_ci num_of_wifi_link = wifi_link_status >> 16; 304662306a36Sopenharmony_ci if (num_of_wifi_link >= 2) { 304762306a36Sopenharmony_ci halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); 304862306a36Sopenharmony_ci halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, 304962306a36Sopenharmony_ci bt_ctrl_agg_buf_size, agg_buf_size); 305062306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_multiport(btcoexist); 305162306a36Sopenharmony_ci return; 305262306a36Sopenharmony_ci } 305362306a36Sopenharmony_ci 305462306a36Sopenharmony_ci coex_sta->special_pkt_period_cnt = 0; 305562306a36Sopenharmony_ci 305662306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); 305762306a36Sopenharmony_ci if (coex_sta->c2h_bt_inquiry_page) { 305862306a36Sopenharmony_ci halbtc8723b1ant_action_bt_inquiry(btcoexist); 305962306a36Sopenharmony_ci return; 306062306a36Sopenharmony_ci } else if (bt_hs_on) { 306162306a36Sopenharmony_ci halbtc8723b1ant_action_hs(btcoexist); 306262306a36Sopenharmony_ci return; 306362306a36Sopenharmony_ci } 306462306a36Sopenharmony_ci 306562306a36Sopenharmony_ci if (BTC_PACKET_DHCP == type || 306662306a36Sopenharmony_ci BTC_PACKET_EAPOL == type) { 306762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 306862306a36Sopenharmony_ci "[BTCoex], special Packet(%d) notify\n", type); 306962306a36Sopenharmony_ci halbtc8723b1ant_action_wifi_connected_special_packet(btcoexist); 307062306a36Sopenharmony_ci } 307162306a36Sopenharmony_ci} 307262306a36Sopenharmony_ci 307362306a36Sopenharmony_civoid ex_btc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist, 307462306a36Sopenharmony_ci u8 *tmp_buf, u8 length) 307562306a36Sopenharmony_ci{ 307662306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 307762306a36Sopenharmony_ci u8 bt_info = 0; 307862306a36Sopenharmony_ci u8 i, rsp_source = 0; 307962306a36Sopenharmony_ci bool wifi_connected = false; 308062306a36Sopenharmony_ci bool bt_busy = false; 308162306a36Sopenharmony_ci 308262306a36Sopenharmony_ci coex_sta->c2h_bt_info_req_sent = false; 308362306a36Sopenharmony_ci 308462306a36Sopenharmony_ci rsp_source = tmp_buf[0] & 0xf; 308562306a36Sopenharmony_ci if (rsp_source >= BT_INFO_SRC_8723B_1ANT_MAX) 308662306a36Sopenharmony_ci rsp_source = BT_INFO_SRC_8723B_1ANT_WIFI_FW; 308762306a36Sopenharmony_ci coex_sta->bt_info_c2h_cnt[rsp_source]++; 308862306a36Sopenharmony_ci 308962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 309062306a36Sopenharmony_ci "[BTCoex], Bt info[%d], length=%d, hex data = [", 309162306a36Sopenharmony_ci rsp_source, length); 309262306a36Sopenharmony_ci for (i = 0; i < length; i++) { 309362306a36Sopenharmony_ci coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i]; 309462306a36Sopenharmony_ci if (i == 1) 309562306a36Sopenharmony_ci bt_info = tmp_buf[i]; 309662306a36Sopenharmony_ci if (i == length - 1) 309762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 309862306a36Sopenharmony_ci "0x%02x]\n", tmp_buf[i]); 309962306a36Sopenharmony_ci else 310062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 310162306a36Sopenharmony_ci "0x%02x, ", tmp_buf[i]); 310262306a36Sopenharmony_ci } 310362306a36Sopenharmony_ci 310462306a36Sopenharmony_ci /* if 0xff, it means BT is under WHCK test */ 310562306a36Sopenharmony_ci if (bt_info == 0xff) 310662306a36Sopenharmony_ci coex_sta->bt_whck_test = true; 310762306a36Sopenharmony_ci else 310862306a36Sopenharmony_ci coex_sta->bt_whck_test = false; 310962306a36Sopenharmony_ci 311062306a36Sopenharmony_ci if (rsp_source != BT_INFO_SRC_8723B_1ANT_WIFI_FW) { 311162306a36Sopenharmony_ci coex_sta->bt_retry_cnt = /* [3:0] */ 311262306a36Sopenharmony_ci coex_sta->bt_info_c2h[rsp_source][2] & 0xf; 311362306a36Sopenharmony_ci 311462306a36Sopenharmony_ci if (coex_sta->bt_retry_cnt >= 1) 311562306a36Sopenharmony_ci coex_sta->pop_event_cnt++; 311662306a36Sopenharmony_ci 311762306a36Sopenharmony_ci if (coex_sta->bt_info_c2h[rsp_source][2] & 0x20) 311862306a36Sopenharmony_ci coex_sta->c2h_bt_remote_name_req = true; 311962306a36Sopenharmony_ci else 312062306a36Sopenharmony_ci coex_sta->c2h_bt_remote_name_req = false; 312162306a36Sopenharmony_ci 312262306a36Sopenharmony_ci coex_sta->bt_rssi = 312362306a36Sopenharmony_ci coex_sta->bt_info_c2h[rsp_source][3] * 2 - 90; 312462306a36Sopenharmony_ci 312562306a36Sopenharmony_ci coex_sta->bt_info_ext = 312662306a36Sopenharmony_ci coex_sta->bt_info_c2h[rsp_source][4]; 312762306a36Sopenharmony_ci 312862306a36Sopenharmony_ci if (coex_sta->bt_info_c2h[rsp_source][1] == 0x49) { 312962306a36Sopenharmony_ci coex_sta->a2dp_bit_pool = 313062306a36Sopenharmony_ci coex_sta->bt_info_c2h[rsp_source][6]; 313162306a36Sopenharmony_ci } else { 313262306a36Sopenharmony_ci coex_sta->a2dp_bit_pool = 0; 313362306a36Sopenharmony_ci } 313462306a36Sopenharmony_ci 313562306a36Sopenharmony_ci coex_sta->bt_tx_rx_mask = 313662306a36Sopenharmony_ci (coex_sta->bt_info_c2h[rsp_source][2] & 0x40); 313762306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TX_RX_MASK, 313862306a36Sopenharmony_ci &coex_sta->bt_tx_rx_mask); 313962306a36Sopenharmony_ci 314062306a36Sopenharmony_ci if (!coex_sta->bt_tx_rx_mask) { 314162306a36Sopenharmony_ci /* BT into is responded by BT FW and BT RF REG 314262306a36Sopenharmony_ci * 0x3C != 0x15 => Need to switch BT TRx Mask 314362306a36Sopenharmony_ci */ 314462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 314562306a36Sopenharmony_ci "[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n"); 314662306a36Sopenharmony_ci btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF, 314762306a36Sopenharmony_ci 0x3c, 0x15); 314862306a36Sopenharmony_ci 314962306a36Sopenharmony_ci /* BT TRx Mask lock 0x2c[0], 0x30[0] = 0 */ 315062306a36Sopenharmony_ci btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF, 315162306a36Sopenharmony_ci 0x2c, 0x7c44); 315262306a36Sopenharmony_ci btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF, 315362306a36Sopenharmony_ci 0x30, 0x7c44); 315462306a36Sopenharmony_ci } 315562306a36Sopenharmony_ci 315662306a36Sopenharmony_ci /* Here we need to resend some wifi info to BT 315762306a36Sopenharmony_ci * because bt is reset and loss of the info. 315862306a36Sopenharmony_ci */ 315962306a36Sopenharmony_ci if (coex_sta->bt_info_ext & BIT1) { 316062306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 316162306a36Sopenharmony_ci "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"); 316262306a36Sopenharmony_ci btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, 316362306a36Sopenharmony_ci &wifi_connected); 316462306a36Sopenharmony_ci if (wifi_connected) 316562306a36Sopenharmony_ci ex_btc8723b1ant_media_status_notify(btcoexist, 316662306a36Sopenharmony_ci BTC_MEDIA_CONNECT); 316762306a36Sopenharmony_ci else 316862306a36Sopenharmony_ci ex_btc8723b1ant_media_status_notify(btcoexist, 316962306a36Sopenharmony_ci BTC_MEDIA_DISCONNECT); 317062306a36Sopenharmony_ci } 317162306a36Sopenharmony_ci 317262306a36Sopenharmony_ci if (coex_sta->bt_info_ext & BIT3) { 317362306a36Sopenharmony_ci if (!btcoexist->manual_control && 317462306a36Sopenharmony_ci !btcoexist->stop_coex_dm) { 317562306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 317662306a36Sopenharmony_ci "[BTCoex], BT ext info bit3 check, set BT NOT ignore Wlan active!!\n"); 317762306a36Sopenharmony_ci halbtc8723b1ant_ignore_wlan_act(btcoexist, 317862306a36Sopenharmony_ci FORCE_EXEC, 317962306a36Sopenharmony_ci false); 318062306a36Sopenharmony_ci } 318162306a36Sopenharmony_ci } else { 318262306a36Sopenharmony_ci /* BT already NOT ignore Wlan active, do nothing here.*/ 318362306a36Sopenharmony_ci } 318462306a36Sopenharmony_ci if (!btcoexist->auto_report_1ant) { 318562306a36Sopenharmony_ci if (coex_sta->bt_info_ext & BIT4) { 318662306a36Sopenharmony_ci /* BT auto report already enabled, do nothing */ 318762306a36Sopenharmony_ci } else { 318862306a36Sopenharmony_ci halbtc8723b1ant_bt_auto_report(btcoexist, 318962306a36Sopenharmony_ci FORCE_EXEC, 319062306a36Sopenharmony_ci true); 319162306a36Sopenharmony_ci } 319262306a36Sopenharmony_ci } 319362306a36Sopenharmony_ci } 319462306a36Sopenharmony_ci 319562306a36Sopenharmony_ci /* check BIT2 first ==> check if bt is under inquiry or page scan */ 319662306a36Sopenharmony_ci if (bt_info & BT_INFO_8723B_1ANT_B_INQ_PAGE) 319762306a36Sopenharmony_ci coex_sta->c2h_bt_inquiry_page = true; 319862306a36Sopenharmony_ci else 319962306a36Sopenharmony_ci coex_sta->c2h_bt_inquiry_page = false; 320062306a36Sopenharmony_ci 320162306a36Sopenharmony_ci coex_sta->num_of_profile = 0; 320262306a36Sopenharmony_ci 320362306a36Sopenharmony_ci /* set link exist status */ 320462306a36Sopenharmony_ci if (!(bt_info & BT_INFO_8723B_1ANT_B_CONNECTION)) { 320562306a36Sopenharmony_ci coex_sta->bt_link_exist = false; 320662306a36Sopenharmony_ci coex_sta->pan_exist = false; 320762306a36Sopenharmony_ci coex_sta->a2dp_exist = false; 320862306a36Sopenharmony_ci coex_sta->hid_exist = false; 320962306a36Sopenharmony_ci coex_sta->sco_exist = false; 321062306a36Sopenharmony_ci 321162306a36Sopenharmony_ci coex_sta->bt_hi_pri_link_exist = false; 321262306a36Sopenharmony_ci } else { 321362306a36Sopenharmony_ci /* connection exists */ 321462306a36Sopenharmony_ci coex_sta->bt_link_exist = true; 321562306a36Sopenharmony_ci if (bt_info & BT_INFO_8723B_1ANT_B_FTP) { 321662306a36Sopenharmony_ci coex_sta->pan_exist = true; 321762306a36Sopenharmony_ci coex_sta->num_of_profile++; 321862306a36Sopenharmony_ci } else { 321962306a36Sopenharmony_ci coex_sta->pan_exist = false; 322062306a36Sopenharmony_ci } 322162306a36Sopenharmony_ci if (bt_info & BT_INFO_8723B_1ANT_B_A2DP) { 322262306a36Sopenharmony_ci coex_sta->a2dp_exist = true; 322362306a36Sopenharmony_ci coex_sta->num_of_profile++; 322462306a36Sopenharmony_ci } else { 322562306a36Sopenharmony_ci coex_sta->a2dp_exist = false; 322662306a36Sopenharmony_ci } 322762306a36Sopenharmony_ci if (bt_info & BT_INFO_8723B_1ANT_B_HID) { 322862306a36Sopenharmony_ci coex_sta->hid_exist = true; 322962306a36Sopenharmony_ci coex_sta->num_of_profile++; 323062306a36Sopenharmony_ci } else { 323162306a36Sopenharmony_ci coex_sta->hid_exist = false; 323262306a36Sopenharmony_ci } 323362306a36Sopenharmony_ci if (bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) { 323462306a36Sopenharmony_ci coex_sta->sco_exist = true; 323562306a36Sopenharmony_ci coex_sta->num_of_profile++; 323662306a36Sopenharmony_ci } else { 323762306a36Sopenharmony_ci coex_sta->sco_exist = false; 323862306a36Sopenharmony_ci } 323962306a36Sopenharmony_ci 324062306a36Sopenharmony_ci if ((!coex_sta->hid_exist) && 324162306a36Sopenharmony_ci (!coex_sta->c2h_bt_inquiry_page) && 324262306a36Sopenharmony_ci (!coex_sta->sco_exist)) { 324362306a36Sopenharmony_ci if (coex_sta->high_priority_tx + 324462306a36Sopenharmony_ci coex_sta->high_priority_rx >= 324562306a36Sopenharmony_ci 160) { 324662306a36Sopenharmony_ci coex_sta->hid_exist = true; 324762306a36Sopenharmony_ci coex_sta->wrong_profile_notification++; 324862306a36Sopenharmony_ci coex_sta->num_of_profile++; 324962306a36Sopenharmony_ci bt_info = bt_info | 0x28; 325062306a36Sopenharmony_ci } 325162306a36Sopenharmony_ci } 325262306a36Sopenharmony_ci 325362306a36Sopenharmony_ci /* Add Hi-Pri Tx/Rx counter to avoid false detection */ 325462306a36Sopenharmony_ci if (((coex_sta->hid_exist) || (coex_sta->sco_exist)) && 325562306a36Sopenharmony_ci (coex_sta->high_priority_tx + coex_sta->high_priority_rx >= 325662306a36Sopenharmony_ci 160) && 325762306a36Sopenharmony_ci (!coex_sta->c2h_bt_inquiry_page)) 325862306a36Sopenharmony_ci coex_sta->bt_hi_pri_link_exist = true; 325962306a36Sopenharmony_ci 326062306a36Sopenharmony_ci if ((bt_info & BT_INFO_8723B_1ANT_B_ACL_BUSY) && 326162306a36Sopenharmony_ci (coex_sta->num_of_profile == 0)) { 326262306a36Sopenharmony_ci if (coex_sta->low_priority_tx + 326362306a36Sopenharmony_ci coex_sta->low_priority_rx >= 326462306a36Sopenharmony_ci 160) { 326562306a36Sopenharmony_ci coex_sta->pan_exist = true; 326662306a36Sopenharmony_ci coex_sta->num_of_profile++; 326762306a36Sopenharmony_ci coex_sta->wrong_profile_notification++; 326862306a36Sopenharmony_ci bt_info = bt_info | 0x88; 326962306a36Sopenharmony_ci } 327062306a36Sopenharmony_ci } 327162306a36Sopenharmony_ci } 327262306a36Sopenharmony_ci 327362306a36Sopenharmony_ci halbtc8723b1ant_update_bt_link_info(btcoexist); 327462306a36Sopenharmony_ci 327562306a36Sopenharmony_ci /* mask profile bit for connect-ilde identification 327662306a36Sopenharmony_ci * ( for CSR case: A2DP idle --> 0x41) 327762306a36Sopenharmony_ci */ 327862306a36Sopenharmony_ci bt_info = bt_info & 0x1f; 327962306a36Sopenharmony_ci 328062306a36Sopenharmony_ci if (!(bt_info & BT_INFO_8723B_1ANT_B_CONNECTION)) { 328162306a36Sopenharmony_ci coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE; 328262306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 328362306a36Sopenharmony_ci "[BTCoex], BtInfoNotify(), BT Non-Connected idle!\n"); 328462306a36Sopenharmony_ci /* connection exists but no busy */ 328562306a36Sopenharmony_ci } else if (bt_info == BT_INFO_8723B_1ANT_B_CONNECTION) { 328662306a36Sopenharmony_ci coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE; 328762306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 328862306a36Sopenharmony_ci "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"); 328962306a36Sopenharmony_ci } else if ((bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) || 329062306a36Sopenharmony_ci (bt_info & BT_INFO_8723B_1ANT_B_SCO_BUSY)) { 329162306a36Sopenharmony_ci coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_SCO_BUSY; 329262306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 329362306a36Sopenharmony_ci "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"); 329462306a36Sopenharmony_ci } else if (bt_info & BT_INFO_8723B_1ANT_B_ACL_BUSY) { 329562306a36Sopenharmony_ci if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status) 329662306a36Sopenharmony_ci coex_dm->auto_tdma_adjust = false; 329762306a36Sopenharmony_ci 329862306a36Sopenharmony_ci coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_ACL_BUSY; 329962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 330062306a36Sopenharmony_ci "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"); 330162306a36Sopenharmony_ci } else { 330262306a36Sopenharmony_ci coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_MAX; 330362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 330462306a36Sopenharmony_ci "[BTCoex], BtInfoNotify(), BT Non-Defined state!!\n"); 330562306a36Sopenharmony_ci } 330662306a36Sopenharmony_ci 330762306a36Sopenharmony_ci if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || 330862306a36Sopenharmony_ci (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || 330962306a36Sopenharmony_ci (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) 331062306a36Sopenharmony_ci bt_busy = true; 331162306a36Sopenharmony_ci else 331262306a36Sopenharmony_ci bt_busy = false; 331362306a36Sopenharmony_ci btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); 331462306a36Sopenharmony_ci 331562306a36Sopenharmony_ci halbtc8723b1ant_run_coexist_mechanism(btcoexist); 331662306a36Sopenharmony_ci} 331762306a36Sopenharmony_ci 331862306a36Sopenharmony_civoid ex_btc8723b1ant_rf_status_notify(struct btc_coexist *btcoexist, u8 type) 331962306a36Sopenharmony_ci{ 332062306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 332162306a36Sopenharmony_ci u32 u32tmp; 332262306a36Sopenharmony_ci u8 u8tmpa, u8tmpb, u8tmpc; 332362306a36Sopenharmony_ci 332462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 332562306a36Sopenharmony_ci "[BTCoex], RF Status notify\n"); 332662306a36Sopenharmony_ci 332762306a36Sopenharmony_ci if (type == BTC_RF_ON) { 332862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 332962306a36Sopenharmony_ci "[BTCoex], RF is turned ON!!\n"); 333062306a36Sopenharmony_ci btcoexist->stop_coex_dm = false; 333162306a36Sopenharmony_ci } else if (type == BTC_RF_OFF) { 333262306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 333362306a36Sopenharmony_ci "[BTCoex], RF is turned OFF!!\n"); 333462306a36Sopenharmony_ci 333562306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 333662306a36Sopenharmony_ci 0x0, 0x0); 333762306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); 333862306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, 333962306a36Sopenharmony_ci FORCE_EXEC, false, true); 334062306a36Sopenharmony_ci 334162306a36Sopenharmony_ci halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); 334262306a36Sopenharmony_ci btcoexist->stop_coex_dm = true; 334362306a36Sopenharmony_ci 334462306a36Sopenharmony_ci u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x948); 334562306a36Sopenharmony_ci u8tmpa = btcoexist->btc_read_1byte(btcoexist, 0x765); 334662306a36Sopenharmony_ci u8tmpb = btcoexist->btc_read_1byte(btcoexist, 0x67); 334762306a36Sopenharmony_ci u8tmpc = btcoexist->btc_read_1byte(btcoexist, 0x76e); 334862306a36Sopenharmony_ci 334962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 335062306a36Sopenharmony_ci "############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x, 0x76e=0x%x\n", 335162306a36Sopenharmony_ci u32tmp, u8tmpa, u8tmpb, u8tmpc); 335262306a36Sopenharmony_ci } 335362306a36Sopenharmony_ci} 335462306a36Sopenharmony_ci 335562306a36Sopenharmony_civoid ex_btc8723b1ant_halt_notify(struct btc_coexist *btcoexist) 335662306a36Sopenharmony_ci{ 335762306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 335862306a36Sopenharmony_ci 335962306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, "[BTCoex], Halt notify\n"); 336062306a36Sopenharmony_ci 336162306a36Sopenharmony_ci btcoexist->stop_coex_dm = true; 336262306a36Sopenharmony_ci 336362306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, FORCE_EXEC, 336462306a36Sopenharmony_ci false, true); 336562306a36Sopenharmony_ci 336662306a36Sopenharmony_ci halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); 336762306a36Sopenharmony_ci 336862306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 336962306a36Sopenharmony_ci 0x0, 0x0); 337062306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); 337162306a36Sopenharmony_ci 337262306a36Sopenharmony_ci ex_btc8723b1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); 337362306a36Sopenharmony_ci 337462306a36Sopenharmony_ci btcoexist->stop_coex_dm = true; 337562306a36Sopenharmony_ci} 337662306a36Sopenharmony_ci 337762306a36Sopenharmony_civoid ex_btc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) 337862306a36Sopenharmony_ci{ 337962306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 338062306a36Sopenharmony_ci 338162306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, "[BTCoex], Pnp notify\n"); 338262306a36Sopenharmony_ci 338362306a36Sopenharmony_ci if (BTC_WIFI_PNP_SLEEP == pnp_state) { 338462306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 338562306a36Sopenharmony_ci "[BTCoex], Pnp notify to SLEEP\n"); 338662306a36Sopenharmony_ci halbtc8723b1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, 338762306a36Sopenharmony_ci FORCE_EXEC, false, true); 338862306a36Sopenharmony_ci halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 338962306a36Sopenharmony_ci 0x0, 0x0); 339062306a36Sopenharmony_ci halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); 339162306a36Sopenharmony_ci halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); 339262306a36Sopenharmony_ci 339362306a36Sopenharmony_ci /* Driver do not leave IPS/LPS when driver is going to sleep, so 339462306a36Sopenharmony_ci * BTCoexistence think wifi is still under IPS/LPS 339562306a36Sopenharmony_ci * 339662306a36Sopenharmony_ci * BT should clear UnderIPS/UnderLPS state to avoid mismatch 339762306a36Sopenharmony_ci * state after wakeup. 339862306a36Sopenharmony_ci */ 339962306a36Sopenharmony_ci coex_sta->under_ips = false; 340062306a36Sopenharmony_ci coex_sta->under_lps = false; 340162306a36Sopenharmony_ci btcoexist->stop_coex_dm = true; 340262306a36Sopenharmony_ci } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) { 340362306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 340462306a36Sopenharmony_ci "[BTCoex], Pnp notify to WAKE UP\n"); 340562306a36Sopenharmony_ci btcoexist->stop_coex_dm = false; 340662306a36Sopenharmony_ci halbtc8723b1ant_init_hw_config(btcoexist, false, false); 340762306a36Sopenharmony_ci halbtc8723b1ant_init_coex_dm(btcoexist); 340862306a36Sopenharmony_ci halbtc8723b1ant_query_bt_info(btcoexist); 340962306a36Sopenharmony_ci } 341062306a36Sopenharmony_ci} 341162306a36Sopenharmony_ci 341262306a36Sopenharmony_civoid ex_btc8723b1ant_coex_dm_reset(struct btc_coexist *btcoexist) 341362306a36Sopenharmony_ci{ 341462306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 341562306a36Sopenharmony_ci 341662306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 341762306a36Sopenharmony_ci "[BTCoex], *****************Coex DM Reset****************\n"); 341862306a36Sopenharmony_ci 341962306a36Sopenharmony_ci halbtc8723b1ant_init_hw_config(btcoexist, false, false); 342062306a36Sopenharmony_ci halbtc8723b1ant_init_coex_dm(btcoexist); 342162306a36Sopenharmony_ci} 342262306a36Sopenharmony_ci 342362306a36Sopenharmony_civoid ex_btc8723b1ant_periodical(struct btc_coexist *btcoexist) 342462306a36Sopenharmony_ci{ 342562306a36Sopenharmony_ci struct rtl_priv *rtlpriv = btcoexist->adapter; 342662306a36Sopenharmony_ci struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; 342762306a36Sopenharmony_ci 342862306a36Sopenharmony_ci rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, 342962306a36Sopenharmony_ci "[BTCoex], ==========================Periodical===========================\n"); 343062306a36Sopenharmony_ci 343162306a36Sopenharmony_ci if (!btcoexist->auto_report_1ant) { 343262306a36Sopenharmony_ci halbtc8723b1ant_query_bt_info(btcoexist); 343362306a36Sopenharmony_ci halbtc8723b1ant_monitor_bt_enable_disable(btcoexist); 343462306a36Sopenharmony_ci } else { 343562306a36Sopenharmony_ci halbtc8723b1ant_monitor_bt_ctr(btcoexist); 343662306a36Sopenharmony_ci halbtc8723b1ant_monitor_wifi_ctr(btcoexist); 343762306a36Sopenharmony_ci 343862306a36Sopenharmony_ci if ((coex_sta->high_priority_tx + coex_sta->high_priority_rx < 50) && 343962306a36Sopenharmony_ci bt_link_info->hid_exist) 344062306a36Sopenharmony_ci bt_link_info->hid_exist = false; 344162306a36Sopenharmony_ci 344262306a36Sopenharmony_ci if (btc8723b1ant_is_wifi_status_changed(btcoexist) || 344362306a36Sopenharmony_ci coex_dm->auto_tdma_adjust) { 344462306a36Sopenharmony_ci halbtc8723b1ant_run_coexist_mechanism(btcoexist); 344562306a36Sopenharmony_ci } 344662306a36Sopenharmony_ci coex_sta->special_pkt_period_cnt++; 344762306a36Sopenharmony_ci } 344862306a36Sopenharmony_ci} 3449