1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /****************************************************************************** 3 * 4 * Copyright(c) 2016 - 2017 Realtek Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of version 2 of the GNU General Public License as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 * 15 *****************************************************************************/ 16 17 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1) 18 19 #if (RTL8821A_SUPPORT == 1) 20 21 /* ******************************************* 22 * The following is for 8821A 2Ant BT Co-exist definition 23 * ******************************************* */ 24 #define BT_AUTO_REPORT_ONLY_8821A_2ANT 1 25 26 27 #define BT_INFO_8821A_2ANT_B_FTP BIT(7) 28 #define BT_INFO_8821A_2ANT_B_A2DP BIT(6) 29 #define BT_INFO_8821A_2ANT_B_HID BIT(5) 30 #define BT_INFO_8821A_2ANT_B_SCO_BUSY BIT(4) 31 #define BT_INFO_8821A_2ANT_B_ACL_BUSY BIT(3) 32 #define BT_INFO_8821A_2ANT_B_INQ_PAGE BIT(2) 33 #define BT_INFO_8821A_2ANT_B_SCO_ESCO BIT(1) 34 #define BT_INFO_8821A_2ANT_B_CONNECTION BIT(0) 35 36 #define BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT 2 37 38 39 #define BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42 /* WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */ 40 #define BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES 46 /* BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */ 41 42 enum bt_info_src_8821a_2ant { 43 BT_INFO_SRC_8821A_2ANT_WIFI_FW = 0x0, 44 BT_INFO_SRC_8821A_2ANT_BT_RSP = 0x1, 45 BT_INFO_SRC_8821A_2ANT_BT_ACTIVE_SEND = 0x2, 46 BT_INFO_SRC_8821A_2ANT_MAX 47 }; 48 49 enum bt_8821a_2ant_bt_status { 50 BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, 51 BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, 52 BT_8821A_2ANT_BT_STATUS_INQ_PAGE = 0x2, 53 BT_8821A_2ANT_BT_STATUS_ACL_BUSY = 0x3, 54 BT_8821A_2ANT_BT_STATUS_SCO_BUSY = 0x4, 55 BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, 56 BT_8821A_2ANT_BT_STATUS_MAX 57 }; 58 59 enum bt_8821a_2ant_coex_algo { 60 BT_8821A_2ANT_COEX_ALGO_UNDEFINED = 0x0, 61 BT_8821A_2ANT_COEX_ALGO_SCO = 0x1, 62 BT_8821A_2ANT_COEX_ALGO_HID = 0x2, 63 BT_8821A_2ANT_COEX_ALGO_A2DP = 0x3, 64 BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, 65 BT_8821A_2ANT_COEX_ALGO_PANEDR = 0x5, 66 BT_8821A_2ANT_COEX_ALGO_PANHS = 0x6, 67 BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, 68 BT_8821A_2ANT_COEX_ALGO_PANEDR_HID = 0x8, 69 BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, 70 BT_8821A_2ANT_COEX_ALGO_HID_A2DP = 0xa, 71 BT_8821A_2ANT_COEX_ALGO_MAX = 0xb, 72 }; 73 74 struct coex_dm_8821a_2ant { 75 /* fw mechanism */ 76 u8 pre_bt_dec_pwr_lvl; 77 u8 cur_bt_dec_pwr_lvl; 78 u8 pre_fw_dac_swing_lvl; 79 u8 cur_fw_dac_swing_lvl; 80 boolean cur_ignore_wlan_act; 81 boolean pre_ignore_wlan_act; 82 u8 pre_ps_tdma; 83 u8 cur_ps_tdma; 84 u8 ps_tdma_para[5]; 85 u8 ps_tdma_du_adj_type; 86 boolean reset_tdma_adjust; 87 boolean auto_tdma_adjust; 88 boolean pre_ps_tdma_on; 89 boolean cur_ps_tdma_on; 90 boolean pre_bt_auto_report; 91 boolean cur_bt_auto_report; 92 93 /* sw mechanism */ 94 boolean pre_rf_rx_lpf_shrink; 95 boolean cur_rf_rx_lpf_shrink; 96 u32 bt_rf_0x1e_backup; 97 boolean pre_low_penalty_ra; 98 boolean cur_low_penalty_ra; 99 boolean pre_dac_swing_on; 100 u32 pre_dac_swing_lvl; 101 boolean cur_dac_swing_on; 102 u32 cur_dac_swing_lvl; 103 boolean pre_adc_back_off; 104 boolean cur_adc_back_off; 105 boolean pre_agc_table_en; 106 boolean cur_agc_table_en; 107 u32 pre_val0x6c0; 108 u32 cur_val0x6c0; 109 u32 pre_val0x6c4; 110 u32 cur_val0x6c4; 111 u32 pre_val0x6c8; 112 u32 cur_val0x6c8; 113 u8 pre_val0x6cc; 114 u8 cur_val0x6cc; 115 boolean limited_dig; 116 117 /* algorithm related */ 118 u8 pre_algorithm; 119 u8 cur_algorithm; 120 u8 bt_status; 121 u8 wifi_chnl_info[3]; 122 123 boolean need_recover0x948; 124 u32 backup0x948; 125 126 u8 pre_lps; 127 u8 cur_lps; 128 u8 pre_rpwm; 129 u8 cur_rpwm; 130 }; 131 132 struct coex_sta_8821a_2ant { 133 boolean bt_disabled; 134 boolean bt_link_exist; 135 boolean sco_exist; 136 boolean a2dp_exist; 137 boolean hid_exist; 138 boolean pan_exist; 139 140 boolean under_lps; 141 boolean under_ips; 142 u32 high_priority_tx; 143 u32 high_priority_rx; 144 u32 low_priority_tx; 145 u32 low_priority_rx; 146 u8 bt_rssi; 147 boolean bt_tx_rx_mask; 148 u8 pre_bt_rssi_state; 149 u8 pre_wifi_rssi_state[4]; 150 boolean c2h_bt_info_req_sent; 151 u8 bt_info_c2h[BT_INFO_SRC_8821A_2ANT_MAX][10]; 152 u32 bt_info_c2h_cnt[BT_INFO_SRC_8821A_2ANT_MAX]; 153 boolean bt_whck_test; 154 boolean c2h_bt_inquiry_page; 155 u8 bt_retry_cnt; 156 u8 bt_info_ext; 157 u8 scan_ap_num; 158 u32 crc_ok_cck; 159 u32 crc_ok_11g; 160 u32 crc_ok_11n; 161 u32 crc_ok_11n_vht; 162 163 u32 crc_err_cck; 164 u32 crc_err_11g; 165 u32 crc_err_11n; 166 u32 crc_err_11n_vht; 167 168 u32 bt_coex_supported_version; 169 u8 cut_version; 170 u8 coex_table_type; 171 boolean force_lps_on; 172 173 u8 dis_ver_info_cnt; 174 }; 175 176 /* ******************************************* 177 * The following is interface which will notify coex module. 178 * ******************************************* */ 179 void ex_halbtc8821a2ant_power_on_setting(IN struct btc_coexist *btcoexist); 180 void ex_halbtc8821a2ant_pre_load_firmware(IN struct btc_coexist *btcoexist); 181 void ex_halbtc8821a2ant_init_hw_config(IN struct btc_coexist *btcoexist, 182 IN boolean wifi_only); 183 void ex_halbtc8821a2ant_init_coex_dm(IN struct btc_coexist *btcoexist); 184 void ex_halbtc8821a2ant_ips_notify(IN struct btc_coexist *btcoexist, 185 IN u8 type); 186 void ex_halbtc8821a2ant_lps_notify(IN struct btc_coexist *btcoexist, 187 IN u8 type); 188 void ex_halbtc8821a2ant_scan_notify(IN struct btc_coexist *btcoexist, 189 IN u8 type); 190 void ex_halbtc8821a2ant_switchband_notify(IN struct btc_coexist *btcoexist, 191 IN u8 type); 192 void ex_halbtc8821a2ant_connect_notify(IN struct btc_coexist *btcoexist, 193 IN u8 type); 194 void ex_halbtc8821a2ant_media_status_notify(IN struct btc_coexist *btcoexist, 195 IN u8 type); 196 void ex_halbtc8821a2ant_specific_packet_notify(IN struct btc_coexist *btcoexist, 197 IN u8 type); 198 void ex_halbtc8821a2ant_bt_info_notify(IN struct btc_coexist *btcoexist, 199 IN u8 *tmp_buf, IN u8 length); 200 void ex_halbtc8821a2ant_halt_notify(IN struct btc_coexist *btcoexist); 201 void ex_halbtc8821a2ant_pnp_notify(IN struct btc_coexist *btcoexist, 202 IN u8 pnp_state); 203 void ex_halbtc8821a2ant_periodical(IN struct btc_coexist *btcoexist); 204 void ex_halbtc8821a2ant_display_coex_info(IN struct btc_coexist *btcoexist); 205 206 #else 207 #define ex_halbtc8821a2ant_power_on_setting(btcoexist) 208 #define ex_halbtc8821a2ant_pre_load_firmware(btcoexist) 209 #define ex_halbtc8821a2ant_init_hw_config(btcoexist, wifi_only) 210 #define ex_halbtc8821a2ant_init_coex_dm(btcoexist) 211 #define ex_halbtc8821a2ant_ips_notify(btcoexist, type) 212 #define ex_halbtc8821a2ant_lps_notify(btcoexist, type) 213 #define ex_halbtc8821a2ant_scan_notify(btcoexist, type) 214 #define ex_halbtc8821a2ant_switchband_notify(btcoexist, type) 215 #define ex_halbtc8821a2ant_connect_notify(btcoexist, type) 216 #define ex_halbtc8821a2ant_media_status_notify(btcoexist, type) 217 #define ex_halbtc8821a2ant_specific_packet_notify(btcoexist, type) 218 #define ex_halbtc8821a2ant_bt_info_notify(btcoexist, tmp_buf, length) 219 #define ex_halbtc8821a2ant_halt_notify(btcoexist) 220 #define ex_halbtc8821a2ant_pnp_notify(btcoexist, pnp_state) 221 #define ex_halbtc8821a2ant_periodical(btcoexist) 222 #define ex_halbtc8821a2ant_display_coex_info(btcoexist) 223 #endif 224 225 #endif 226 227