2 #if (BT_SUPPORT == 1 && COEX_SUPPORT == 1)
4 #if (RTL8821C_SUPPORT == 1)
6 /* *******************************************
7 * The following is for 8821C 2Ant BT Co-exist definition
8 * ******************************************* */
9 #define BT_AUTO_REPORT_ONLY_8821C_2ANT 1
12 #define BT_INFO_8821C_2ANT_B_FTP BIT(7)
13 #define BT_INFO_8821C_2ANT_B_A2DP BIT(6)
14 #define BT_INFO_8821C_2ANT_B_HID BIT(5)
15 #define BT_INFO_8821C_2ANT_B_SCO_BUSY BIT(4)
16 #define BT_INFO_8821C_2ANT_B_ACL_BUSY BIT(3)
17 #define BT_INFO_8821C_2ANT_B_INQ_PAGE BIT(2)
18 #define BT_INFO_8821C_2ANT_B_SCO_ESCO BIT(1)
19 #define BT_INFO_8821C_2ANT_B_CONNECTION BIT(0)
21 #define BTC_RSSI_COEX_THRESH_TOL_8821C_2ANT 2
24 #define BT_8821C_2ANT_WIFI_RSSI_COEXSWITCH_THRES1 80 /* unit: % WiFi RSSI Threshold for 2-Ant free-run/2-Ant TDMA translation, default = 42 */
25 #define BT_8821C_2ANT_BT_RSSI_COEXSWITCH_THRES1 80 /* unit: % BT RSSI Threshold for 2-Ant free-run/2-Ant TDMA translation, default = 46 */
26 #define BT_8821C_2ANT_WIFI_RSSI_COEXSWITCH_THRES2 80 /* unit: % WiFi RSSI Threshold for 1-Ant TDMA/1-Ant PS-TDMA translation, default = 42 */
27 #define BT_8821C_2ANT_BT_RSSI_COEXSWITCH_THRES2 80 /* unit: % BT RSSI Threshold for 1-Ant TDMA/1-Ant PS-TDMA translation, default = 46 */
28 #define BT_8821C_2ANT_DEFAULT_ISOLATION 15 /* unit: dB */
29 #define BT_8821C_2ANT_WIFI_MAX_TX_POWER 15 /* unit: dBm */
30 #define BT_8821C_2ANT_BT_MAX_TX_POWER 3 /* unit: dBm */
31 #define BT_8821C_2ANT_WIFI_SIR_THRES1 -15 /* unit: dB */
32 #define BT_8821C_2ANT_WIFI_SIR_THRES2 -30 /* unit: dB */
33 #define BT_8821C_2ANT_BT_SIR_THRES1 -15 /* unit: dB */
34 #define BT_8821C_2ANT_BT_SIR_THRES2 -30 /* unit: dB */
37 /* for Antenna detection */
38 #define BT_8821C_2ANT_ANTDET_PSDTHRES_BACKGROUND 50
39 #define BT_8821C_2ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION 70
40 #define BT_8821C_2ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION 52
41 #define BT_8821C_2ANT_ANTDET_PSDTHRES_1ANT 40
42 #define BT_8821C_2ANT_ANTDET_RETRY_INTERVAL 10 /* retry timer if ant det is fail, unit: second */
43 #define BT_8821C_2ANT_ANTDET_SWEEPPOINT_DELAY 40000
44 #define BT_8821C_2ANT_ANTDET_ENABLE 0
45 #define BT_8821C_2ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE 0
46 #define BT_8821C_2ANT_ANTDET_BTTXTIME 100
47 #define BT_8821C_2ANT_ANTDET_BTTXCHANNEL 39
49 #define BT_8821C_2ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT 30000
51 enum bt_8821c_2ant_signal_state {
52 BT_8821C_2ANT_SIG_STA_SET_TO_LOW = 0x0,
53 BT_8821C_2ANT_SIG_STA_SET_BY_HW = 0x0,
54 BT_8821C_2ANT_SIG_STA_SET_TO_HIGH = 0x1,
55 BT_8821C_2ANT_SIG_STA_MAX
58 enum bt_8821c_2ant_path_ctrl_owner {
59 BT_8821C_2ANT_PCO_BTSIDE = 0x0,
60 BT_8821C_2ANT_PCO_WLSIDE = 0x1,
64 enum bt_8821c_2ant_gnt_ctrl_type {
65 BT_8821C_2ANT_GNT_TYPE_CTRL_BY_PTA = 0x0,
66 BT_8821C_2ANT_GNT_TYPE_CTRL_BY_SW = 0x1,
67 BT_8821C_2ANT_GNT_TYPE_MAX
70 enum bt_8821c_2ant_gnt_ctrl_block {
71 BT_8821C_2ANT_GNT_BLOCK_RFC_BB = 0x0,
72 BT_8821C_2ANT_GNT_BLOCK_RFC = 0x1,
73 BT_8821C_2ANT_GNT_BLOCK_BB = 0x2,
74 BT_8821C_2ANT_GNT_BLOCK_MAX
77 enum bt_8821c_2ant_lte_coex_table_type {
78 BT_8821C_2ANT_CTT_WL_VS_LTE = 0x0,
79 BT_8821C_2ANT_CTT_BT_VS_LTE = 0x1,
83 enum bt_8821c_2ant_lte_break_table_type {
84 BT_8821C_2ANT_LBTT_WL_BREAK_LTE = 0x0,
85 BT_8821C_2ANT_LBTT_BT_BREAK_LTE = 0x1,
86 BT_8821C_2ANT_LBTT_LTE_BREAK_WL = 0x2,
87 BT_8821C_2ANT_LBTT_LTE_BREAK_BT = 0x3,
88 BT_8821C_2ANT_LBTT_MAX
91 enum bt_info_src_8821c_2ant {
92 BT_INFO_SRC_8821C_2ANT_WIFI_FW = 0x0,
93 BT_INFO_SRC_8821C_2ANT_BT_RSP = 0x1,
94 BT_INFO_SRC_8821C_2ANT_BT_ACTIVE_SEND = 0x2,
95 BT_INFO_SRC_8821C_2ANT_MAX
98 enum bt_8821c_2ant_bt_status {
99 BT_8821C_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
100 BT_8821C_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
101 BT_8821C_2ANT_BT_STATUS_INQ_PAGE = 0x2,
102 BT_8821C_2ANT_BT_STATUS_ACL_BUSY = 0x3,
103 BT_8821C_2ANT_BT_STATUS_SCO_BUSY = 0x4,
104 BT_8821C_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
105 BT_8821C_2ANT_BT_STATUS_MAX
108 enum bt_8821c_2ant_coex_algo {
109 BT_8821C_2ANT_COEX_ALGO_UNDEFINED = 0x0,
110 BT_8821C_2ANT_COEX_ALGO_SCO = 0x1,
111 BT_8821C_2ANT_COEX_ALGO_HID = 0x2,
112 BT_8821C_2ANT_COEX_ALGO_A2DP = 0x3,
113 BT_8821C_2ANT_COEX_ALGO_A2DP_PANHS = 0x4,
114 BT_8821C_2ANT_COEX_ALGO_PANEDR = 0x5,
115 BT_8821C_2ANT_COEX_ALGO_PANHS = 0x6,
116 BT_8821C_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
117 BT_8821C_2ANT_COEX_ALGO_PANEDR_HID = 0x8,
118 BT_8821C_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
119 BT_8821C_2ANT_COEX_ALGO_HID_A2DP = 0xa,
120 BT_8821C_2ANT_COEX_ALGO_NOPROFILEBUSY = 0xb,
121 BT_8821C_2ANT_COEX_ALGO_MAX
124 enum bt_8821c_2ant_ext_ant_switch_ctrl_type {
125 BT_8821C_2ANT_EXT_ANT_SWITCH_CTRL_BY_BBSW = 0x0,
126 BT_8821C_2ANT_EXT_ANT_SWITCH_CTRL_BY_PTA = 0x1,
127 BT_8821C_2ANT_EXT_ANT_SWITCH_CTRL_BY_ANTDIV = 0x2,
128 BT_8821C_2ANT_EXT_ANT_SWITCH_CTRL_BY_MAC = 0x3,
129 BT_8821C_2ANT_EXT_ANT_SWITCH_CTRL_BY_BT = 0x4,
130 BT_8821C_2ANT_EXT_ANT_SWITCH_CTRL_MAX
133 enum bt_8821c_2ant_ext_ant_switch_pos_type {
134 BT_8821C_2ANT_EXT_ANT_SWITCH_MAIN_TO_BT = 0x0,
135 BT_8821C_2ANT_EXT_ANT_SWITCH_MAIN_TO_WLG = 0x1,
136 BT_8821C_2ANT_EXT_ANT_SWITCH_MAIN_TO_WLA = 0x2,
137 BT_8821C_2ANT_EXT_ANT_SWITCH_MAIN_TO_NOCARE = 0x3,
138 BT_8821C_2ANT_EXT_ANT_SWITCH_MAIN_TO_MAX
141 enum bt_8821c_2ant_ext_band_switch_pos_type {
142 BT_8821C_2ANT_EXT_BAND_SWITCH_TO_WLG = 0x0,
143 BT_8821C_2ANT_EXT_BAND_SWITCH_TO_WLA = 0x1,
144 BT_8821C_2ANT_EXT_BAND_SWITCH_TO_MAX
147 enum bt_8821c_2ant_int_block{
148 BT_8821C_2ANT_INT_BLOCK_SWITCH_TO_WLG_OF_BTG = 0x0,
149 BT_8821C_2ANT_INT_BLOCK_SWITCH_TO_WLG_OF_WLAG = 0x1,
150 BT_8821C_2ANT_INT_BLOCK_SWITCH_TO_WLA_OF_WLAG = 0x2,
151 BT_8821C_2ANT_INT_BLOCK_SWITCH_TO_MAX
154 enum bt_8821c_2ant_phase{
155 BT_8821C_2ANT_PHASE_COEX_INIT = 0x0,
156 BT_8821C_2ANT_PHASE_WLANONLY_INIT = 0x1,
157 BT_8821C_2ANT_PHASE_WLAN_OFF = 0x2,
158 BT_8821C_2ANT_PHASE_2G_RUNTIME = 0x3,
159 BT_8821C_2ANT_PHASE_5G_RUNTIME = 0x4,
160 BT_8821C_2ANT_PHASE_BTMPMODE = 0x5,
161 BT_8821C_2ANT_PHASE_MAX
164 struct coex_dm_8821c_2ant {
166 u32 pre_ant_pos_type;
167 u32 cur_ant_pos_type;
169 u8 pre_bt_dec_pwr_lvl;
170 u8 cur_bt_dec_pwr_lvl;
171 u8 pre_fw_dac_swing_lvl;
172 u8 cur_fw_dac_swing_lvl;
173 boolean cur_ignore_wlan_act;
174 boolean pre_ignore_wlan_act;
178 u8 ps_tdma_du_adj_type;
179 boolean reset_tdma_adjust;
180 boolean auto_tdma_adjust;
181 boolean pre_ps_tdma_on;
182 boolean cur_ps_tdma_on;
183 boolean pre_bt_auto_report;
184 boolean cur_bt_auto_report;
187 boolean pre_rf_rx_lpf_shrink;
188 boolean cur_rf_rx_lpf_shrink;
189 u32 bt_rf_0x1e_backup;
190 boolean pre_low_penalty_ra;
191 boolean cur_low_penalty_ra;
192 boolean pre_dac_swing_on;
193 u32 pre_dac_swing_lvl;
194 boolean cur_dac_swing_on;
195 u32 cur_dac_swing_lvl;
196 boolean pre_adc_back_off;
197 boolean cur_adc_back_off;
198 boolean pre_agc_table_en;
199 boolean cur_agc_table_en;
210 /* algorithm related */
214 u8 wifi_chnl_info[3];
216 boolean need_recover0x948;
224 boolean is_switch_to_1dot5_ant;
225 u8 switch_thres_offset;
228 u32 pre_ext_ant_switch_status;
229 u32 cur_ext_ant_switch_status;
231 u8 pre_ext_band_switch_status;
232 u8 cur_ext_band_switch_status;
234 u8 pre_int_block_status;
235 u8 cur_int_block_status;
238 struct coex_sta_8821c_2ant {
240 boolean bt_link_exist;
248 u32 high_priority_tx;
249 u32 high_priority_rx;
253 boolean bt_tx_rx_mask;
254 u8 pre_bt_rssi_state;
255 u8 pre_wifi_rssi_state[4];
256 boolean c2h_bt_info_req_sent;
257 u8 bt_info_c2h[BT_INFO_SRC_8821C_2ANT_MAX][10];
258 u32 bt_info_c2h_cnt[BT_INFO_SRC_8821C_2ANT_MAX];
259 boolean bt_whck_test;
260 boolean c2h_bt_inquiry_page;
261 boolean c2h_bt_remote_name_req;
280 boolean cck_ever_lock;
283 boolean force_lps_on;
290 boolean concurrent_rx_mode_on;
293 u8 isolation_btween_wb; /* 0~ 50 */
301 boolean wl_rf_off_on_event;
302 boolean bt_create_connection;
303 boolean run_time_state;
304 boolean wifi_is_high_pri_task;
305 u32 specific_pkt_period_cnt;
306 u32 bt_coex_supported_feature;
307 u32 bt_coex_supported_version;
310 #define BT_8821C_2ANT_EXT_ANT_SWITCH_USE_DPDT 0
311 #define BT_8821C_2ANT_EXT_ANT_SWITCH_USE_SPDT 1
313 #define BT_8821C_2ANT_EXT_BAND_SWITCH_USE_DPDT 0
314 #define BT_8821C_2ANT_EXT_BAND_SWITCH_USE_SPDT 1
317 struct rfe_type_8821c_2ant{
320 boolean ext_ant_switch_exist;
321 u8 ext_ant_switch_type; /* 0:DPDT, 1:SPDT */
322 u8 ext_ant_switch_ctrl_polarity; /* iF 0: DPDT_P=0, DPDT_N=1 => BTG to Main, WL_A+G to Aux */
324 boolean ext_band_switch_exist;
325 u8 ext_band_switch_type; /* 0:DPDT, 1:SPDT */
326 u8 ext_band_switch_ctrl_polarity;
328 boolean wlg_Locate_at_btg; /* If true: WLG at BTG, If false: WLG at WLAG */
330 boolean ext_ant_switch_diversity; /* If diversity on */
333 #define BT_8821C_2ANT_ANTDET_PSD_POINTS 256 /* MAX:1024 */
334 #define BT_8821C_2ANT_ANTDET_PSD_AVGNUM 1 /* MAX:3 */
335 #define BT_8821C_2ANT_ANTDET_BUF_LEN 16
337 struct psdscan_sta_8821c_2ant {
339 u32 ant_det_bt_le_channel; /* BT LE Channel ex:2412 */
340 u32 ant_det_bt_tx_time;
341 u32 ant_det_pre_psdscan_peak_val;
342 boolean ant_det_is_ant_det_available;
343 u32 ant_det_psd_scan_peak_val;
344 boolean ant_det_is_btreply_available;
345 u32 ant_det_psd_scan_peak_freq;
348 u8 ant_det_peak_val[BT_8821C_2ANT_ANTDET_BUF_LEN];
349 u8 ant_det_peak_freq[BT_8821C_2ANT_ANTDET_BUF_LEN];
350 u32 ant_det_try_count;
351 u32 ant_det_fail_count;
352 u32 ant_det_inteval_count;
353 u32 ant_det_thres_offset;
359 u32 psd_band_width; /* unit: Hz */
360 u32 psd_point; /* 128/256/512/1024 */
361 u32 psd_report[1024]; /* unit:dB (20logx), 0~255 */
362 u32 psd_report_max_hold[1024]; /* unit:dB (20logx), 0~255 */
365 u32 psd_max_value_point;
368 u32 psd_avg_num; /* 1/8/16/32 */
370 boolean is_psd_running;
371 boolean is_psd_show_max_only;
375 /* *******************************************
376 * The following is interface which will notify coex module.
377 * ******************************************* */
378 void ex_halbtc8821c2ant_power_on_setting(IN struct btc_coexist *btcoexist);
379 void ex_halbtc8821c2ant_pre_load_firmware(IN struct btc_coexist *btcoexist);
380 void ex_halbtc8821c2ant_init_hw_config(IN struct btc_coexist *btcoexist,
381 IN boolean wifi_only);
382 void ex_halbtc8821c2ant_init_coex_dm(IN struct btc_coexist *btcoexist);
383 void ex_halbtc8821c2ant_ips_notify(IN struct btc_coexist *btcoexist,
385 void ex_halbtc8821c2ant_lps_notify(IN struct btc_coexist *btcoexist,
387 void ex_halbtc8821c2ant_scan_notify(IN struct btc_coexist *btcoexist,
389 void ex_halbtc8821c2ant_switchband_notify(IN struct btc_coexist *btcoexist,
391 void ex_halbtc8821c2ant_connect_notify(IN struct btc_coexist *btcoexist,
393 void ex_halbtc8821c2ant_media_status_notify(IN struct btc_coexist *btcoexist,
395 void ex_halbtc8821c2ant_specific_packet_notify(IN struct btc_coexist *btcoexist,
397 void ex_halbtc8821c2ant_bt_info_notify(IN struct btc_coexist *btcoexist,
398 IN u8 *tmp_buf, IN u8 length);
399 void ex_halbtc8821c2ant_rf_status_notify(IN struct btc_coexist *btcoexist,
401 void ex_halbtc8821c2ant_halt_notify(IN struct btc_coexist *btcoexist);
402 void ex_halbtc8821c2ant_pnp_notify(IN struct btc_coexist *btcoexist,
404 void ex_halbtc8821c2ant_periodical(IN struct btc_coexist *btcoexist);
405 void ex_halbtc8821c2ant_display_coex_info(IN struct btc_coexist *btcoexist);
406 void ex_halbtc8821c2ant_antenna_detection(IN struct btc_coexist *btcoexist,
407 IN u32 cent_freq, IN u32 offset, IN u32 span, IN u32 seconds);
408 void ex_halbtc8821c2ant_display_ant_detection(IN struct btc_coexist *btcoexist);
412 #define ex_halbtc8821c2ant_power_on_setting(btcoexist)
413 #define ex_halbtc8821c2ant_pre_load_firmware(btcoexist)
414 #define ex_halbtc8821c2ant_init_hw_config(btcoexist, wifi_only)
415 #define ex_halbtc8821c2ant_init_coex_dm(btcoexist)
416 #define ex_halbtc8821c2ant_ips_notify(btcoexist, type)
417 #define ex_halbtc8821c2ant_lps_notify(btcoexist, type)
418 #define ex_halbtc8821c2ant_scan_notify(btcoexist, type)
419 #define ex_halbtc8821c2ant_switchband_notify(btcoexist,type)
420 #define ex_halbtc8821c2ant_connect_notify(btcoexist, type)
421 #define ex_halbtc8821c2ant_media_status_notify(btcoexist, type)
422 #define ex_halbtc8821c2ant_specific_packet_notify(btcoexist, type)
423 #define ex_halbtc8821c2ant_bt_info_notify(btcoexist, tmp_buf, length)
424 #define ex_halbtc8821c2ant_rf_status_notify(btcoexist, type)
425 #define ex_halbtc8821c2ant_halt_notify(btcoexist)
426 #define ex_halbtc8821c2ant_pnp_notify(btcoexist, pnp_state)
427 #define ex_halbtc8821c2ant_periodical(btcoexist)
428 #define ex_halbtc8821c2ant_display_coex_info(btcoexist)
429 #define ex_halbtc8821c2ant_display_ant_detection(btcoexist)
430 #define ex_halbtc8821c2ant_antenna_detection(btcoexist, centFreq, offset, span, seconds)