162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright(c) 2012  Realtek Corporation.*/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _HAL8723B_2_ANT
562306a36Sopenharmony_ci#define _HAL8723B_2_ANT
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci/************************************************************************
862306a36Sopenharmony_ci * The following is for 8723B 2Ant BT Co-exist definition
962306a36Sopenharmony_ci ************************************************************************/
1062306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_FTP			BIT7
1162306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_A2DP			BIT6
1262306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_HID			BIT5
1362306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_SCO_BUSY			BIT4
1462306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_ACL_BUSY			BIT3
1562306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_INQ_PAGE			BIT2
1662306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_SCO_ESCO			BIT1
1762306a36Sopenharmony_ci#define	BT_INFO_8723B_2ANT_B_CONNECTION			BIT0
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT		2
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/* WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */
2262306a36Sopenharmony_ci#define BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES	42
2362306a36Sopenharmony_ci/* BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */
2462306a36Sopenharmony_ci#define BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES		46
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cienum BT_INFO_SRC_8723B_2ANT {
2762306a36Sopenharmony_ci	BT_INFO_SRC_8723B_2ANT_WIFI_FW			= 0x0,
2862306a36Sopenharmony_ci	BT_INFO_SRC_8723B_2ANT_BT_RSP			= 0x1,
2962306a36Sopenharmony_ci	BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND		= 0x2,
3062306a36Sopenharmony_ci	BT_INFO_SRC_8723B_2ANT_MAX
3162306a36Sopenharmony_ci};
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cienum BT_8723B_2ANT_BT_STATUS {
3462306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE	= 0x0,
3562306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE		= 0x1,
3662306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_INQ_PAGE		= 0x2,
3762306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_ACL_BUSY		= 0x3,
3862306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_SCO_BUSY		= 0x4,
3962306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY		= 0x5,
4062306a36Sopenharmony_ci	BT_8723B_2ANT_BT_STATUS_MAX
4162306a36Sopenharmony_ci};
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_cienum BT_8723B_2ANT_COEX_ALGO {
4462306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_UNDEFINED		= 0x0,
4562306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_SCO			= 0x1,
4662306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_HID			= 0x2,
4762306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_A2DP			= 0x3,
4862306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS		= 0x4,
4962306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_PANEDR			= 0x5,
5062306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_PANHS			= 0x6,
5162306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP		= 0x7,
5262306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_PANEDR_HID		= 0x8,
5362306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR		= 0x9,
5462306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_HID_A2DP		= 0xa,
5562306a36Sopenharmony_ci	BT_8723B_2ANT_COEX_ALGO_MAX			= 0xb,
5662306a36Sopenharmony_ci};
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_cistruct coex_dm_8723b_2ant {
5962306a36Sopenharmony_ci	/* fw mechanism */
6062306a36Sopenharmony_ci	bool pre_dec_bt_pwr_lvl;
6162306a36Sopenharmony_ci	bool cur_dec_bt_pwr_lvl;
6262306a36Sopenharmony_ci	u8 pre_fw_dac_swing_lvl;
6362306a36Sopenharmony_ci	u8 cur_fw_dac_swing_lvl;
6462306a36Sopenharmony_ci	bool cur_ignore_wlan_act;
6562306a36Sopenharmony_ci	bool pre_ignore_wlan_act;
6662306a36Sopenharmony_ci	u8 pre_ps_tdma;
6762306a36Sopenharmony_ci	u8 cur_ps_tdma;
6862306a36Sopenharmony_ci	u8 ps_tdma_para[5];
6962306a36Sopenharmony_ci	u8 ps_tdma_du_adj_type;
7062306a36Sopenharmony_ci	bool reset_tdma_adjust;
7162306a36Sopenharmony_ci	bool auto_tdma_adjust;
7262306a36Sopenharmony_ci	bool pre_ps_tdma_on;
7362306a36Sopenharmony_ci	bool cur_ps_tdma_on;
7462306a36Sopenharmony_ci	bool pre_bt_auto_report;
7562306a36Sopenharmony_ci	bool cur_bt_auto_report;
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	/* sw mechanism */
7862306a36Sopenharmony_ci	bool pre_rf_rx_lpf_shrink;
7962306a36Sopenharmony_ci	bool cur_rf_rx_lpf_shrink;
8062306a36Sopenharmony_ci	u32 bt_rf0x1e_backup;
8162306a36Sopenharmony_ci	bool pre_low_penalty_ra;
8262306a36Sopenharmony_ci	bool cur_low_penalty_ra;
8362306a36Sopenharmony_ci	bool pre_dac_swing_on;
8462306a36Sopenharmony_ci	u32 pre_dac_swing_lvl;
8562306a36Sopenharmony_ci	bool cur_dac_swing_on;
8662306a36Sopenharmony_ci	u32 cur_dac_swing_lvl;
8762306a36Sopenharmony_ci	bool pre_adc_back_off;
8862306a36Sopenharmony_ci	bool cur_adc_back_off;
8962306a36Sopenharmony_ci	bool pre_agc_table_en;
9062306a36Sopenharmony_ci	bool cur_agc_table_en;
9162306a36Sopenharmony_ci	u32 pre_val0x6c0;
9262306a36Sopenharmony_ci	u32 cur_val0x6c0;
9362306a36Sopenharmony_ci	u32 pre_val0x6c4;
9462306a36Sopenharmony_ci	u32 cur_val0x6c4;
9562306a36Sopenharmony_ci	u32 pre_val0x6c8;
9662306a36Sopenharmony_ci	u32 cur_val0x6c8;
9762306a36Sopenharmony_ci	u8 pre_val0x6cc;
9862306a36Sopenharmony_ci	u8 cur_val0x6cc;
9962306a36Sopenharmony_ci	bool limited_dig;
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci	/* algorithm related */
10262306a36Sopenharmony_ci	u8 pre_algorithm;
10362306a36Sopenharmony_ci	u8 cur_algorithm;
10462306a36Sopenharmony_ci	u8 bt_status;
10562306a36Sopenharmony_ci	u8 wifi_chnl_info[3];
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	u8 pre_lps;
10862306a36Sopenharmony_ci	u8 cur_lps;
10962306a36Sopenharmony_ci	u8 pre_rpwm;
11062306a36Sopenharmony_ci	u8 cur_rpwm;
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	bool is_switch_to_1dot5_ant;
11362306a36Sopenharmony_ci	u8 switch_thres_offset;
11462306a36Sopenharmony_ci};
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_cistruct coex_sta_8723b_2ant {
11762306a36Sopenharmony_ci	bool bt_link_exist;
11862306a36Sopenharmony_ci	bool sco_exist;
11962306a36Sopenharmony_ci	bool a2dp_exist;
12062306a36Sopenharmony_ci	bool hid_exist;
12162306a36Sopenharmony_ci	bool pan_exist;
12262306a36Sopenharmony_ci	bool bt_abnormal_scan;
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci	bool under_lps;
12562306a36Sopenharmony_ci	bool under_ips;
12662306a36Sopenharmony_ci	u32 high_priority_tx;
12762306a36Sopenharmony_ci	u32 high_priority_rx;
12862306a36Sopenharmony_ci	u32 low_priority_tx;
12962306a36Sopenharmony_ci	u32 low_priority_rx;
13062306a36Sopenharmony_ci	u8 bt_rssi;
13162306a36Sopenharmony_ci	bool bt_tx_rx_mask;
13262306a36Sopenharmony_ci	u8 pre_bt_rssi_state;
13362306a36Sopenharmony_ci	u8 pre_wifi_rssi_state[4];
13462306a36Sopenharmony_ci	bool c2h_bt_info_req_sent;
13562306a36Sopenharmony_ci	u8 bt_info_c2h[BT_INFO_SRC_8723B_2ANT_MAX][10];
13662306a36Sopenharmony_ci	u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_2ANT_MAX];
13762306a36Sopenharmony_ci	bool c2h_bt_inquiry_page;
13862306a36Sopenharmony_ci	bool c2h_bt_remote_name_req;
13962306a36Sopenharmony_ci	u8 bt_retry_cnt;
14062306a36Sopenharmony_ci	u8 bt_info_ext;
14162306a36Sopenharmony_ci	u32 pop_event_cnt;
14262306a36Sopenharmony_ci	u8 scan_ap_num;
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci	u32 crc_ok_cck;
14562306a36Sopenharmony_ci	u32 crc_ok_11g;
14662306a36Sopenharmony_ci	u32 crc_ok_11n;
14762306a36Sopenharmony_ci	u32 crc_ok_11n_agg;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci	u32 crc_err_cck;
15062306a36Sopenharmony_ci	u32 crc_err_11g;
15162306a36Sopenharmony_ci	u32 crc_err_11n;
15262306a36Sopenharmony_ci	u32 crc_err_11n_agg;
15362306a36Sopenharmony_ci	bool force_lps_on;
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci	u8 dis_ver_info_cnt;
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci	u8 a2dp_bit_pool;
15862306a36Sopenharmony_ci};
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/*********************************************************************
16162306a36Sopenharmony_ci * The following is interface which will notify coex module.
16262306a36Sopenharmony_ci *********************************************************************/
16362306a36Sopenharmony_civoid ex_btc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist);
16462306a36Sopenharmony_civoid ex_btc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist);
16562306a36Sopenharmony_civoid ex_btc8723b2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
16662306a36Sopenharmony_civoid ex_btc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
16762306a36Sopenharmony_civoid ex_btc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
16862306a36Sopenharmony_civoid ex_btc8723b2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
16962306a36Sopenharmony_civoid ex_btc8723b2ant_media_status_notify(struct btc_coexist *btcoexist,
17062306a36Sopenharmony_ci					 u8 type);
17162306a36Sopenharmony_civoid ex_btc8723b2ant_special_packet_notify(struct btc_coexist *btcoexist,
17262306a36Sopenharmony_ci					   u8 type);
17362306a36Sopenharmony_civoid ex_btc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist,
17462306a36Sopenharmony_ci				    u8 *tmpbuf, u8 length);
17562306a36Sopenharmony_civoid ex_btc8723b2ant_halt_notify(struct btc_coexist *btcoexist);
17662306a36Sopenharmony_civoid ex_btc8723b2ant_periodical(struct btc_coexist *btcoexist);
17762306a36Sopenharmony_civoid ex_btc8723b2ant_display_coex_info(struct btc_coexist *btcoexist,
17862306a36Sopenharmony_ci				       struct seq_file *m);
17962306a36Sopenharmony_civoid ex_btc8723b2ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
18062306a36Sopenharmony_civoid ex_btc8723b2ant_pre_load_firmware(struct btc_coexist *btcoexist);
18162306a36Sopenharmony_civoid ex_btc8723b2ant_power_on_setting(struct btc_coexist *btcoexist);
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#endif
184