1 /****************************************************************************** 2 * 3 * Copyright(c) 2016 - 2017 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 *****************************************************************************/ 15 16 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1) 17 18 #if (RTL8703B_SUPPORT == 1) 19 /* ******************************************* 20 * The following is for 8703B 1ANT BT Co-exist definition 21 * ******************************************* */ 22 #define BT_AUTO_REPORT_ONLY_8703B_1ANT 1 23 #define BT_8703B_1ANT_ENABLE_GNTBT_TO_GPIO14 0 24 25 #define BT_INFO_8703B_1ANT_B_FTP BIT(7) 26 #define BT_INFO_8703B_1ANT_B_A2DP BIT(6) 27 #define BT_INFO_8703B_1ANT_B_HID BIT(5) 28 #define BT_INFO_8703B_1ANT_B_SCO_BUSY BIT(4) 29 #define BT_INFO_8703B_1ANT_B_ACL_BUSY BIT(3) 30 #define BT_INFO_8703B_1ANT_B_INQ_PAGE BIT(2) 31 #define BT_INFO_8703B_1ANT_B_SCO_ESCO BIT(1) 32 #define BT_INFO_8703B_1ANT_B_CONNECTION BIT(0) 33 34 #define BT_INFO_8703B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ 35 (((_BT_INFO_EXT_&BIT(0))) ? TRUE : FALSE) 36 37 #define BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT 2 38 39 #define BT_8703B_1ANT_WIFI_NOISY_THRESH 50 /* max: 255 */ 40 41 /* for Antenna detection */ 42 #define BT_8703B_1ANT_ANTDET_PSDTHRES_BACKGROUND 50 43 #define BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION 70 44 #define BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION 55 45 #define BT_8703B_1ANT_ANTDET_PSDTHRES_1ANT 35 46 #define BT_8703B_1ANT_ANTDET_RETRY_INTERVAL 10 /* retry timer if ant det is fail, unit: second */ 47 #define BT_8703B_1ANT_ANTDET_SWEEPPOINT_DELAY 40000 48 #define BT_8703B_1ANT_ANTDET_ENABLE 0 49 #define BT_8703B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE 0 50 51 #define BT_8703B_1ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT 30000 52 53 enum bt_8703b_1ant_signal_state { 54 BT_8703B_1ANT_SIG_STA_SET_TO_LOW = 0x0, 55 BT_8703B_1ANT_SIG_STA_SET_BY_HW = 0x0, 56 BT_8703B_1ANT_SIG_STA_SET_TO_HIGH = 0x1, 57 BT_8703B_1ANT_SIG_STA_MAX 58 }; 59 60 enum bt_8703b_1ant_path_ctrl_owner { 61 BT_8703B_1ANT_PCO_BTSIDE = 0x0, 62 BT_8703B_1ANT_PCO_WLSIDE = 0x1, 63 BT_8703B_1ANT_PCO_MAX 64 }; 65 66 enum bt_8703b_1ant_gnt_ctrl_type { 67 BT_8703B_1ANT_GNT_TYPE_CTRL_BY_PTA = 0x0, 68 BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW = 0x1, 69 BT_8703B_1ANT_GNT_TYPE_MAX 70 }; 71 72 enum bt_8703b_1ant_gnt_ctrl_block { 73 BT_8703B_1ANT_GNT_BLOCK_RFC_BB = 0x0, 74 BT_8703B_1ANT_GNT_BLOCK_RFC = 0x1, 75 BT_8703B_1ANT_GNT_BLOCK_BB = 0x2, 76 BT_8703B_1ANT_GNT_BLOCK_MAX 77 }; 78 79 enum bt_8703b_1ant_lte_coex_table_type { 80 BT_8703B_1ANT_CTT_WL_VS_LTE = 0x0, 81 BT_8703B_1ANT_CTT_BT_VS_LTE = 0x1, 82 BT_8703B_1ANT_CTT_MAX 83 }; 84 85 enum bt_8703b_1ant_lte_break_table_type { 86 BT_8703B_1ANT_LBTT_WL_BREAK_LTE = 0x0, 87 BT_8703B_1ANT_LBTT_BT_BREAK_LTE = 0x1, 88 BT_8703B_1ANT_LBTT_LTE_BREAK_WL = 0x2, 89 BT_8703B_1ANT_LBTT_LTE_BREAK_BT = 0x3, 90 BT_8703B_1ANT_LBTT_MAX 91 }; 92 93 enum bt_info_src_8703b_1ant { 94 BT_INFO_SRC_8703B_1ANT_WIFI_FW = 0x0, 95 BT_INFO_SRC_8703B_1ANT_BT_RSP = 0x1, 96 BT_INFO_SRC_8703B_1ANT_BT_ACTIVE_SEND = 0x2, 97 BT_INFO_SRC_8703B_1ANT_MAX 98 }; 99 100 enum bt_8703b_1ant_bt_status { 101 BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, 102 BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, 103 BT_8703B_1ANT_BT_STATUS_INQ_PAGE = 0x2, 104 BT_8703B_1ANT_BT_STATUS_ACL_BUSY = 0x3, 105 BT_8703B_1ANT_BT_STATUS_SCO_BUSY = 0x4, 106 BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, 107 BT_8703B_1ANT_BT_STATUS_MAX 108 }; 109 110 enum bt_8703b_1ant_wifi_status { 111 BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, 112 BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, 113 BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, 114 BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SPECIFIC_PKT = 0x3, 115 BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, 116 BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, 117 BT_8703B_1ANT_WIFI_STATUS_MAX 118 }; 119 120 enum bt_8703b_1ant_coex_algo { 121 BT_8703B_1ANT_COEX_ALGO_UNDEFINED = 0x0, 122 BT_8703B_1ANT_COEX_ALGO_SCO = 0x1, 123 BT_8703B_1ANT_COEX_ALGO_HID = 0x2, 124 BT_8703B_1ANT_COEX_ALGO_A2DP = 0x3, 125 BT_8703B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, 126 BT_8703B_1ANT_COEX_ALGO_PANEDR = 0x5, 127 BT_8703B_1ANT_COEX_ALGO_PANHS = 0x6, 128 BT_8703B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, 129 BT_8703B_1ANT_COEX_ALGO_PANEDR_HID = 0x8, 130 BT_8703B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, 131 BT_8703B_1ANT_COEX_ALGO_HID_A2DP = 0xa, 132 BT_8703B_1ANT_COEX_ALGO_MAX = 0xb, 133 }; 134 135 enum bt_8703b_1ant_phase { 136 BT_8703B_1ANT_PHASE_COEX_INIT = 0x0, 137 BT_8703B_1ANT_PHASE_WLANONLY_INIT = 0x1, 138 BT_8703B_1ANT_PHASE_WLAN_OFF = 0x2, 139 BT_8703B_1ANT_PHASE_2G_RUNTIME = 0x3, 140 BT_8703B_1ANT_PHASE_5G_RUNTIME = 0x4, 141 BT_8703B_1ANT_PHASE_BTMPMODE = 0x5, 142 BT_8703B_1ANT_PHASE_ANTENNA_DET = 0x6, 143 BT_8703B_1ANT_PHASE_MAX 144 }; 145 146 enum bt_8703b_1ant_Scoreboard { 147 BT_8703B_1ANT_SCOREBOARD_ACTIVE = BIT(0), 148 BT_8703B_1ANT_SCOREBOARD_ONOFF = BIT(1), 149 BT_8703B_1ANT_SCOREBOARD_SCAN = BIT(2), 150 BT_8703B_1ANT_SCOREBOARD_UNDERTEST = BIT(3), 151 BT_8703B_1ANT_SCOREBOARD_WLBUSY = BIT(6) 152 }; 153 154 155 struct coex_dm_8703b_1ant { 156 /* hw setting */ 157 u8 pre_ant_pos_type; 158 u8 cur_ant_pos_type; 159 /* fw mechanism */ 160 boolean cur_ignore_wlan_act; 161 boolean pre_ignore_wlan_act; 162 u8 pre_ps_tdma; 163 u8 cur_ps_tdma; 164 u8 ps_tdma_para[5]; 165 u8 ps_tdma_du_adj_type; 166 boolean auto_tdma_adjust; 167 boolean pre_ps_tdma_on; 168 boolean cur_ps_tdma_on; 169 boolean pre_bt_auto_report; 170 boolean cur_bt_auto_report; 171 u8 pre_lps; 172 u8 cur_lps; 173 u8 pre_rpwm; 174 u8 cur_rpwm; 175 176 /* sw mechanism */ 177 boolean pre_low_penalty_ra; 178 boolean cur_low_penalty_ra; 179 u32 pre_val0x6c0; 180 u32 cur_val0x6c0; 181 u32 pre_val0x6c4; 182 u32 cur_val0x6c4; 183 u32 pre_val0x6c8; 184 u32 cur_val0x6c8; 185 u8 pre_val0x6cc; 186 u8 cur_val0x6cc; 187 boolean limited_dig; 188 189 u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */ 190 u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */ 191 u16 backup_retry_limit; 192 u8 backup_ampdu_max_time; 193 194 /* algorithm related */ 195 u8 pre_algorithm; 196 u8 cur_algorithm; 197 u8 bt_status; 198 u8 wifi_chnl_info[3]; 199 200 u32 pre_ra_mask; 201 u32 cur_ra_mask; 202 u8 pre_arfr_type; 203 u8 cur_arfr_type; 204 u8 pre_retry_limit_type; 205 u8 cur_retry_limit_type; 206 u8 pre_ampdu_time_type; 207 u8 cur_ampdu_time_type; 208 u32 arp_cnt; 209 210 u8 error_condition; 211 }; 212 213 struct coex_sta_8703b_1ant { 214 boolean bt_disabled; 215 boolean bt_link_exist; 216 boolean sco_exist; 217 boolean a2dp_exist; 218 boolean hid_exist; 219 boolean pan_exist; 220 boolean bt_hi_pri_link_exist; 221 u8 num_of_profile; 222 223 boolean under_lps; 224 boolean under_ips; 225 u32 specific_pkt_period_cnt; 226 u32 high_priority_tx; 227 u32 high_priority_rx; 228 u32 low_priority_tx; 229 u32 low_priority_rx; 230 boolean is_hiPri_rx_overhead; 231 s8 bt_rssi; 232 boolean bt_tx_rx_mask; 233 u8 pre_bt_rssi_state; 234 u8 pre_wifi_rssi_state[4]; 235 u8 bt_info_c2h[BT_INFO_SRC_8703B_1ANT_MAX][10]; 236 u32 bt_info_c2h_cnt[BT_INFO_SRC_8703B_1ANT_MAX]; 237 boolean bt_whck_test; 238 boolean c2h_bt_inquiry_page; 239 boolean c2h_bt_remote_name_req; 240 boolean c2h_bt_page; /* Add for win8.1 page out issue */ 241 boolean wifi_is_high_pri_task; /* Add for win8.1 page out issue */ 242 u8 bt_retry_cnt; 243 u8 bt_info_ext; 244 u8 bt_info_ext2; 245 u32 pop_event_cnt; 246 u8 scan_ap_num; 247 248 u32 crc_ok_cck; 249 u32 crc_ok_11g; 250 u32 crc_ok_11n; 251 u32 crc_ok_11n_vht; 252 253 u32 crc_err_cck; 254 u32 crc_err_11g; 255 u32 crc_err_11n; 256 u32 crc_err_11n_vht; 257 258 boolean cck_lock; 259 boolean cck_lock_ever; 260 boolean cck_lock_warn; 261 262 u8 coex_table_type; 263 boolean force_lps_ctrl; 264 265 boolean concurrent_rx_mode_on; 266 267 u16 score_board; 268 u8 isolation_btween_wb; /* 0~ 50 */ 269 270 u8 a2dp_bit_pool; 271 u8 cut_version; 272 boolean acl_busy; 273 boolean bt_create_connection; 274 275 u32 bt_coex_supported_feature; 276 u32 bt_coex_supported_version; 277 278 u8 bt_ble_scan_type; 279 u32 bt_ble_scan_para[3]; 280 281 boolean run_time_state; 282 boolean freeze_coexrun_by_btinfo; 283 284 boolean is_A2DP_3M; 285 boolean voice_over_HOGP; 286 u8 bt_info; 287 boolean is_autoslot; 288 u8 forbidden_slot; 289 u8 hid_busy_num; 290 u8 hid_pair_cnt; 291 292 u32 cnt_RemoteNameReq; 293 u32 cnt_setupLink; 294 u32 cnt_ReInit; 295 u32 cnt_IgnWlanAct; 296 u32 cnt_Page; 297 u32 cnt_RoleSwitch; 298 299 u16 bt_reg_vendor_ac; 300 u16 bt_reg_vendor_ae; 301 302 boolean is_setupLink; 303 u8 wl_noisy_level; 304 u32 gnt_error_cnt; 305 306 u8 bt_afh_map[10]; 307 u8 bt_relink_downcount; 308 boolean is_tdma_btautoslot; 309 boolean is_tdma_btautoslot_hang; 310 311 boolean is_rf_state_off; 312 313 boolean is_hid_low_pri_tx_overhead; 314 boolean is_bt_multi_link; 315 boolean is_bt_a2dp_sink; 316 317 u8 wl_fw_dbg_info[10]; 318 u8 wl_rx_rate; 319 u8 wl_rts_rx_rate; 320 321 u16 score_board_WB; 322 boolean is_hid_rcu; 323 u16 legacy_forbidden_slot; 324 u16 le_forbidden_slot; 325 u8 bt_a2dp_vendor_id; 326 u32 bt_a2dp_device_name; 327 boolean is_ble_scan_toggle; 328 329 boolean is_bt_opp_exist; 330 }; 331 332 #define BT_8703B_1ANT_ANTDET_PSD_POINTS 256 /* MAX:1024 */ 333 #define BT_8703B_1ANT_ANTDET_PSD_AVGNUM 1 /* MAX:3 */ 334 #define BT_8703B_1ANT_ANTDET_BUF_LEN 16 335 336 struct psdscan_sta_8703b_1ant { 337 338 u32 ant_det_bt_le_channel; /* BT LE Channel ex:2412 */ 339 u32 ant_det_bt_tx_time; 340 u32 ant_det_pre_psdscan_peak_val; 341 boolean ant_det_is_ant_det_available; 342 u32 ant_det_psd_scan_peak_val; 343 boolean ant_det_is_btreply_available; 344 u32 ant_det_psd_scan_peak_freq; 345 346 u8 ant_det_result; 347 u8 ant_det_peak_val[BT_8703B_1ANT_ANTDET_BUF_LEN]; 348 u8 ant_det_peak_freq[BT_8703B_1ANT_ANTDET_BUF_LEN]; 349 u32 ant_det_try_count; 350 u32 ant_det_fail_count; 351 u32 ant_det_inteval_count; 352 u32 ant_det_thres_offset; 353 354 u32 real_cent_freq; 355 s32 real_offset; 356 u32 real_span; 357 358 u32 psd_band_width; /* unit: Hz */ 359 u32 psd_point; /* 128/256/512/1024 */ 360 u32 psd_report[1024]; /* unit:dB (20logx), 0~255 */ 361 u32 psd_report_max_hold[1024]; /* unit:dB (20logx), 0~255 */ 362 u32 psd_start_point; 363 u32 psd_stop_point; 364 u32 psd_max_value_point; 365 u32 psd_max_value; 366 u32 psd_start_base; 367 u32 psd_avg_num; /* 1/8/16/32 */ 368 u32 psd_gen_count; 369 boolean is_psd_running; 370 boolean is_psd_show_max_only; 371 }; 372 373 /* ******************************************* 374 * The following is interface which will notify coex module. 375 * ******************************************* */ 376 void ex_halbtc8703b1ant_power_on_setting(IN struct btc_coexist *btcoexist); 377 void ex_halbtc8703b1ant_pre_load_firmware(IN struct btc_coexist *btcoexist); 378 void ex_halbtc8703b1ant_init_hw_config(IN struct btc_coexist *btcoexist, 379 IN boolean wifi_only); 380 void ex_halbtc8703b1ant_init_coex_dm(IN struct btc_coexist *btcoexist); 381 void ex_halbtc8703b1ant_ips_notify(IN struct btc_coexist *btcoexist, 382 IN u8 type); 383 void ex_halbtc8703b1ant_lps_notify(IN struct btc_coexist *btcoexist, 384 IN u8 type); 385 void ex_halbtc8703b1ant_scan_notify(IN struct btc_coexist *btcoexist, 386 IN u8 type); 387 void ex_halbtc8703b1ant_connect_notify(IN struct btc_coexist *btcoexist, 388 IN u8 type); 389 void ex_halbtc8703b1ant_media_status_notify(IN struct btc_coexist *btcoexist, 390 IN u8 type); 391 void ex_halbtc8703b1ant_specific_packet_notify(IN struct btc_coexist *btcoexist, 392 IN u8 type); 393 void ex_halbtc8703b1ant_bt_info_notify(IN struct btc_coexist *btcoexist, 394 IN u8 *tmp_buf, IN u8 length); 395 void ex_halbtc8703b1ant_wl_fwdbginfo_notify(IN struct btc_coexist *btcoexist, 396 IN u8 *tmp_buf, IN u8 length); 397 void ex_halbtc8703b1ant_rx_rate_change_notify(IN struct btc_coexist *btcoexist, 398 IN BOOLEAN is_data_frame, IN u8 btc_rate_id); 399 void ex_halbtc8703b1ant_rf_status_notify(IN struct btc_coexist *btcoexist, 400 IN u8 type); 401 void ex_halbtc8703b1ant_halt_notify(IN struct btc_coexist *btcoexist); 402 void ex_halbtc8703b1ant_pnp_notify(IN struct btc_coexist *btcoexist, 403 IN u8 pnp_state); 404 void ex_halbtc8703b1ant_coex_dm_reset(IN struct btc_coexist *btcoexist); 405 void ex_halbtc8703b1ant_periodical(IN struct btc_coexist *btcoexist); 406 void ex_halbtc8703b1ant_display_coex_info(IN struct btc_coexist *btcoexist); 407 void ex_halbtc8703b1ant_antenna_detection(IN struct btc_coexist *btcoexist, 408 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds); 409 void ex_halbtc8703b1ant_antenna_isolation(IN struct btc_coexist *btcoexist, 410 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds); 411 412 void ex_halbtc8703b1ant_psd_scan(IN struct btc_coexist *btcoexist, 413 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds); 414 void ex_halbtc8703b1ant_display_ant_detection(IN struct btc_coexist *btcoexist); 415 416 #else 417 #define ex_halbtc8703b1ant_power_on_setting(btcoexist) 418 #define ex_halbtc8703b1ant_pre_load_firmware(btcoexist) 419 #define ex_halbtc8703b1ant_init_hw_config(btcoexist, wifi_only) 420 #define ex_halbtc8703b1ant_init_coex_dm(btcoexist) 421 #define ex_halbtc8703b1ant_ips_notify(btcoexist, type) 422 #define ex_halbtc8703b1ant_lps_notify(btcoexist, type) 423 #define ex_halbtc8703b1ant_scan_notify(btcoexist, type) 424 #define ex_halbtc8703b1ant_connect_notify(btcoexist, type) 425 #define ex_halbtc8703b1ant_media_status_notify(btcoexist, type) 426 #define ex_halbtc8703b1ant_specific_packet_notify(btcoexist, type) 427 #define ex_halbtc8703b1ant_bt_info_notify(btcoexist, tmp_buf, length) 428 #define ex_halbtc8703b1ant_wl_fwdbginfo_notify(btcoexist, tmp_buf, length) 429 #define ex_halbtc8703b1ant_rx_rate_change_notify(btcoexist, is_data_frame, btc_rate_id) 430 #define ex_halbtc8703b1ant_rf_status_notify(btcoexist, type) 431 #define ex_halbtc8703b1ant_halt_notify(btcoexist) 432 #define ex_halbtc8703b1ant_pnp_notify(btcoexist, pnp_state) 433 #define ex_halbtc8703b1ant_coex_dm_reset(btcoexist) 434 #define ex_halbtc8703b1ant_periodical(btcoexist) 435 #define ex_halbtc8703b1ant_display_coex_info(btcoexist) 436 #define ex_halbtc8703b1ant_antenna_detection(btcoexist, cent_freq, offset, span, seconds) 437 #define ex_halbtc8703b1ant_antenna_isolation(btcoexist, cent_freq, offset, span, seconds) 438 #define ex_halbtc8703b1ant_psd_scan(btcoexist, cent_freq, offset, span, seconds) 439 #define ex_halbtc8703b1ant_display_ant_detection(btcoexist) 440 441 #endif 442 443 444 #endif 445 446