162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright(c) 2012  Realtek Corporation.*/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/*****************************************************************
562306a36Sopenharmony_ci *   The following is for 8192E 2Ant BT Co-exist definition
662306a36Sopenharmony_ci *****************************************************************/
762306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_FTP			BIT7
862306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_A2DP			BIT6
962306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_HID			BIT5
1062306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_SCO_BUSY			BIT4
1162306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_ACL_BUSY			BIT3
1262306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_INQ_PAGE			BIT2
1362306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_SCO_ESCO			BIT1
1462306a36Sopenharmony_ci#define	BT_INFO_8192E_2ANT_B_CONNECTION			BIT0
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT		2
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cienum bt_info_src_8192e_2ant {
1962306a36Sopenharmony_ci	BT_INFO_SRC_8192E_2ANT_WIFI_FW			= 0x0,
2062306a36Sopenharmony_ci	BT_INFO_SRC_8192E_2ANT_BT_RSP			= 0x1,
2162306a36Sopenharmony_ci	BT_INFO_SRC_8192E_2ANT_BT_ACTIVE_SEND		= 0x2,
2262306a36Sopenharmony_ci	BT_INFO_SRC_8192E_2ANT_MAX
2362306a36Sopenharmony_ci};
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_cienum bt_8192e_2ant_bt_status {
2662306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE	= 0x0,
2762306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE		= 0x1,
2862306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_INQ_PAGE		= 0x2,
2962306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_ACL_BUSY		= 0x3,
3062306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_SCO_BUSY		= 0x4,
3162306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY		= 0x5,
3262306a36Sopenharmony_ci	BT_8192E_2ANT_BT_STATUS_MAX
3362306a36Sopenharmony_ci};
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_cienum bt_8192e_2ant_coex_algo {
3662306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_UNDEFINED		= 0x0,
3762306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_SCO			= 0x1,
3862306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_SCO_PAN			= 0x2,
3962306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_HID			= 0x3,
4062306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_A2DP			= 0x4,
4162306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS		= 0x5,
4262306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_PANEDR			= 0x6,
4362306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_PANHS			= 0x7,
4462306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP		= 0x8,
4562306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_PANEDR_HID		= 0x9,
4662306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR		= 0xa,
4762306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_HID_A2DP		= 0xb,
4862306a36Sopenharmony_ci	BT_8192E_2ANT_COEX_ALGO_MAX			= 0xc
4962306a36Sopenharmony_ci};
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_cistruct coex_dm_8192e_2ant {
5262306a36Sopenharmony_ci	/* fw mechanism */
5362306a36Sopenharmony_ci	u8 pre_dec_bt_pwr;
5462306a36Sopenharmony_ci	u8 cur_dec_bt_pwr;
5562306a36Sopenharmony_ci	u8 pre_fw_dac_swing_lvl;
5662306a36Sopenharmony_ci	u8 cur_fw_dac_swing_lvl;
5762306a36Sopenharmony_ci	bool cur_ignore_wlan_act;
5862306a36Sopenharmony_ci	bool pre_ignore_wlan_act;
5962306a36Sopenharmony_ci	u8 pre_ps_tdma;
6062306a36Sopenharmony_ci	u8 cur_ps_tdma;
6162306a36Sopenharmony_ci	u8 ps_tdma_para[5];
6262306a36Sopenharmony_ci	u8 tdma_adj_type;
6362306a36Sopenharmony_ci	bool reset_tdma_adjust;
6462306a36Sopenharmony_ci	bool auto_tdma_adjust;
6562306a36Sopenharmony_ci	bool pre_ps_tdma_on;
6662306a36Sopenharmony_ci	bool cur_ps_tdma_on;
6762306a36Sopenharmony_ci	bool pre_bt_auto_report;
6862306a36Sopenharmony_ci	bool cur_bt_auto_report;
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci	/* sw mechanism */
7162306a36Sopenharmony_ci	bool pre_rf_rx_lpf_shrink;
7262306a36Sopenharmony_ci	bool cur_rf_rx_lpf_shrink;
7362306a36Sopenharmony_ci	u32 bt_rf0x1e_backup;
7462306a36Sopenharmony_ci	bool pre_low_penalty_ra;
7562306a36Sopenharmony_ci	bool cur_low_penalty_ra;
7662306a36Sopenharmony_ci	bool pre_dac_swing_on;
7762306a36Sopenharmony_ci	u32 pre_dac_swing_lvl;
7862306a36Sopenharmony_ci	bool cur_dac_swing_on;
7962306a36Sopenharmony_ci	u32 cur_dac_swing_lvl;
8062306a36Sopenharmony_ci	bool pre_adc_back_off;
8162306a36Sopenharmony_ci	bool cur_adc_back_off;
8262306a36Sopenharmony_ci	bool pre_agc_table_en;
8362306a36Sopenharmony_ci	bool cur_agc_table_en;
8462306a36Sopenharmony_ci	u32 pre_val0x6c0;
8562306a36Sopenharmony_ci	u32 cur_val0x6c0;
8662306a36Sopenharmony_ci	u32 pre_val0x6c4;
8762306a36Sopenharmony_ci	u32 cur_val0x6c4;
8862306a36Sopenharmony_ci	u32 pre_val0x6c8;
8962306a36Sopenharmony_ci	u32 cur_val0x6c8;
9062306a36Sopenharmony_ci	u8 pre_val0x6cc;
9162306a36Sopenharmony_ci	u8 cur_val0x6cc;
9262306a36Sopenharmony_ci	bool limited_dig;
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	u32 backup_arfr_cnt1;	/* Auto Rate Fallback Retry cnt */
9562306a36Sopenharmony_ci	u32 backup_arfr_cnt2;	/* Auto Rate Fallback Retry cnt */
9662306a36Sopenharmony_ci	u16 backup_retry_limit;
9762306a36Sopenharmony_ci	u8 backup_ampdu_maxtime;
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	/* algorithm related */
10062306a36Sopenharmony_ci	u8 pre_algorithm;
10162306a36Sopenharmony_ci	u8 cur_algorithm;
10262306a36Sopenharmony_ci	u8 bt_status;
10362306a36Sopenharmony_ci	u8 wifi_chnl_info[3];
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci	u8 pre_ss_type;
10662306a36Sopenharmony_ci	u8 cur_ss_type;
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci	u32 pre_ra_mask;
10962306a36Sopenharmony_ci	u32 cur_ra_mask;
11062306a36Sopenharmony_ci	u8 cur_ra_mask_type;
11162306a36Sopenharmony_ci	u8 pre_arfr_type;
11262306a36Sopenharmony_ci	u8 cur_arfr_type;
11362306a36Sopenharmony_ci	u8 pre_retry_limit_type;
11462306a36Sopenharmony_ci	u8 cur_retry_limit_type;
11562306a36Sopenharmony_ci	u8 pre_ampdu_time_type;
11662306a36Sopenharmony_ci	u8 cur_ampdu_time_type;
11762306a36Sopenharmony_ci};
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_cistruct coex_sta_8192e_2ant {
12062306a36Sopenharmony_ci	bool bt_link_exist;
12162306a36Sopenharmony_ci	bool sco_exist;
12262306a36Sopenharmony_ci	bool a2dp_exist;
12362306a36Sopenharmony_ci	bool hid_exist;
12462306a36Sopenharmony_ci	bool pan_exist;
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci	bool under_lps;
12762306a36Sopenharmony_ci	bool under_ips;
12862306a36Sopenharmony_ci	u32 high_priority_tx;
12962306a36Sopenharmony_ci	u32 high_priority_rx;
13062306a36Sopenharmony_ci	u32 low_priority_tx;
13162306a36Sopenharmony_ci	u32 low_priority_rx;
13262306a36Sopenharmony_ci	u8 bt_rssi;
13362306a36Sopenharmony_ci	u8 pre_bt_rssi_state;
13462306a36Sopenharmony_ci	u8 pre_wifi_rssi_state[4];
13562306a36Sopenharmony_ci	bool c2h_bt_info_req_sent;
13662306a36Sopenharmony_ci	u8 bt_info_c2h[BT_INFO_SRC_8192E_2ANT_MAX][10];
13762306a36Sopenharmony_ci	u32 bt_info_c2h_cnt[BT_INFO_SRC_8192E_2ANT_MAX];
13862306a36Sopenharmony_ci	bool c2h_bt_inquiry_page;
13962306a36Sopenharmony_ci	u8 bt_retry_cnt;
14062306a36Sopenharmony_ci	u8 bt_info_ext;
14162306a36Sopenharmony_ci};
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci/****************************************************************
14462306a36Sopenharmony_ci *    The following is interface which will notify coex module.
14562306a36Sopenharmony_ci ****************************************************************/
14662306a36Sopenharmony_civoid ex_btc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist);
14762306a36Sopenharmony_civoid ex_btc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist);
14862306a36Sopenharmony_civoid ex_btc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
14962306a36Sopenharmony_civoid ex_btc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
15062306a36Sopenharmony_civoid ex_btc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
15162306a36Sopenharmony_civoid ex_btc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
15262306a36Sopenharmony_civoid ex_btc8192e2ant_media_status_notify(struct btc_coexist *btcoexist,
15362306a36Sopenharmony_ci					 u8 type);
15462306a36Sopenharmony_civoid ex_btc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist,
15562306a36Sopenharmony_ci					   u8 type);
15662306a36Sopenharmony_civoid ex_btc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
15762306a36Sopenharmony_ci				    u8 *tmpbuf, u8 length);
15862306a36Sopenharmony_civoid ex_btc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist,
15962306a36Sopenharmony_ci					    u8 type);
16062306a36Sopenharmony_civoid ex_btc8192e2ant_halt_notify(struct btc_coexist *btcoexist);
16162306a36Sopenharmony_civoid ex_btc8192e2ant_periodical(struct btc_coexist *btcoexist);
16262306a36Sopenharmony_civoid ex_btc8192e2ant_display_coex_info(struct btc_coexist *btcoexist,
16362306a36Sopenharmony_ci				       struct seq_file *m);
164