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 8723B 1ANT BT Co-exist definition
662306a36Sopenharmony_ci **********************************************************************/
762306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_FTP			BIT7
862306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_A2DP			BIT6
962306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_HID			BIT5
1062306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_SCO_BUSY			BIT4
1162306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_ACL_BUSY			BIT3
1262306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_INQ_PAGE			BIT2
1362306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_SCO_ESCO			BIT1
1462306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_B_CONNECTION			BIT0
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define	BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_)	\
1762306a36Sopenharmony_ci		(((_BT_INFO_EXT_&BIT0)) ? true : false)
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define	BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT		2
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define BT_8723B_1ANT_WIFI_NOISY_THRESH			50
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cienum _BT_INFO_SRC_8723B_1ANT {
2462306a36Sopenharmony_ci	BT_INFO_SRC_8723B_1ANT_WIFI_FW			= 0x0,
2562306a36Sopenharmony_ci	BT_INFO_SRC_8723B_1ANT_BT_RSP			= 0x1,
2662306a36Sopenharmony_ci	BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND		= 0x2,
2762306a36Sopenharmony_ci	BT_INFO_SRC_8723B_1ANT_MAX
2862306a36Sopenharmony_ci};
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_cienum _BT_8723B_1ANT_BT_STATUS {
3162306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE	= 0x0,
3262306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE		= 0x1,
3362306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_INQ_PAGE		= 0x2,
3462306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_ACL_BUSY		= 0x3,
3562306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_SCO_BUSY		= 0x4,
3662306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY		= 0x5,
3762306a36Sopenharmony_ci	BT_8723B_1ANT_BT_STATUS_MAX
3862306a36Sopenharmony_ci};
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cienum _BT_8723B_1ANT_WIFI_STATUS {
4162306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE			= 0x0,
4262306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN		= 0x1,
4362306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN			= 0x2,
4462306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT			= 0x3,
4562306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE			= 0x4,
4662306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY			= 0x5,
4762306a36Sopenharmony_ci	BT_8723B_1ANT_WIFI_STATUS_MAX
4862306a36Sopenharmony_ci};
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cienum _BT_8723B_1ANT_COEX_ALGO {
5162306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_UNDEFINED		= 0x0,
5262306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_SCO			= 0x1,
5362306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_HID			= 0x2,
5462306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_A2DP			= 0x3,
5562306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS		= 0x4,
5662306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_PANEDR			= 0x5,
5762306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_PANHS			= 0x6,
5862306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP		= 0x7,
5962306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_PANEDR_HID		= 0x8,
6062306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR		= 0x9,
6162306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_HID_A2DP		= 0xa,
6262306a36Sopenharmony_ci	BT_8723B_1ANT_COEX_ALGO_MAX			= 0xb,
6362306a36Sopenharmony_ci};
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_cistruct coex_dm_8723b_1ant {
6662306a36Sopenharmony_ci	/* hw setting */
6762306a36Sopenharmony_ci	u8 pre_ant_pos_type;
6862306a36Sopenharmony_ci	u8 cur_ant_pos_type;
6962306a36Sopenharmony_ci	/* fw mechanism */
7062306a36Sopenharmony_ci	bool cur_ignore_wlan_act;
7162306a36Sopenharmony_ci	bool pre_ignore_wlan_act;
7262306a36Sopenharmony_ci	u8 pre_ps_tdma;
7362306a36Sopenharmony_ci	u8 cur_ps_tdma;
7462306a36Sopenharmony_ci	u8 ps_tdma_para[5];
7562306a36Sopenharmony_ci	u8 ps_tdma_du_adj_type;
7662306a36Sopenharmony_ci	bool auto_tdma_adjust;
7762306a36Sopenharmony_ci	bool pre_ps_tdma_on;
7862306a36Sopenharmony_ci	bool cur_ps_tdma_on;
7962306a36Sopenharmony_ci	bool pre_bt_auto_report;
8062306a36Sopenharmony_ci	bool cur_bt_auto_report;
8162306a36Sopenharmony_ci	u8 pre_lps;
8262306a36Sopenharmony_ci	u8 cur_lps;
8362306a36Sopenharmony_ci	u8 pre_rpwm;
8462306a36Sopenharmony_ci	u8 cur_rpwm;
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci	/* sw mechanism */
8762306a36Sopenharmony_ci	bool pre_low_penalty_ra;
8862306a36Sopenharmony_ci	bool cur_low_penalty_ra;
8962306a36Sopenharmony_ci	u32 pre_val0x6c0;
9062306a36Sopenharmony_ci	u32 cur_val0x6c0;
9162306a36Sopenharmony_ci	u32 pre_val0x6c4;
9262306a36Sopenharmony_ci	u32 cur_val0x6c4;
9362306a36Sopenharmony_ci	u32 pre_val0x6c8;
9462306a36Sopenharmony_ci	u32 cur_val0x6c8;
9562306a36Sopenharmony_ci	u8 pre_val0x6cc;
9662306a36Sopenharmony_ci	u8 cur_val0x6cc;
9762306a36Sopenharmony_ci	bool limited_dig;
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	u32 backup_arfr_cnt1;	/* Auto Rate Fallback Retry cnt */
10062306a36Sopenharmony_ci	u32 backup_arfr_cnt2;	/* Auto Rate Fallback Retry cnt */
10162306a36Sopenharmony_ci	u16 backup_retry_limit;
10262306a36Sopenharmony_ci	u8 backup_ampdu_max_time;
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	/* algorithm related */
10562306a36Sopenharmony_ci	u8 pre_algorithm;
10662306a36Sopenharmony_ci	u8 cur_algorithm;
10762306a36Sopenharmony_ci	u8 bt_status;
10862306a36Sopenharmony_ci	u8 wifi_chnl_info[3];
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci	u32 prera_mask;
11162306a36Sopenharmony_ci	u32 curra_mask;
11262306a36Sopenharmony_ci	u8 pre_arfr_type;
11362306a36Sopenharmony_ci	u8 cur_arfr_type;
11462306a36Sopenharmony_ci	u8 pre_retry_limit_type;
11562306a36Sopenharmony_ci	u8 cur_retry_limit_type;
11662306a36Sopenharmony_ci	u8 pre_ampdu_time_type;
11762306a36Sopenharmony_ci	u8 cur_ampdu_time_type;
11862306a36Sopenharmony_ci	u32	arp_cnt;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci	u8 error_condition;
12162306a36Sopenharmony_ci};
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_cistruct coex_sta_8723b_1ant {
12462306a36Sopenharmony_ci	bool bt_disabled;
12562306a36Sopenharmony_ci	bool bt_link_exist;
12662306a36Sopenharmony_ci	bool sco_exist;
12762306a36Sopenharmony_ci	bool a2dp_exist;
12862306a36Sopenharmony_ci	bool hid_exist;
12962306a36Sopenharmony_ci	bool pan_exist;
13062306a36Sopenharmony_ci	bool bt_hi_pri_link_exist;
13162306a36Sopenharmony_ci	u8 num_of_profile;
13262306a36Sopenharmony_ci	bool bt_abnormal_scan;
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci	bool under_lps;
13562306a36Sopenharmony_ci	bool under_ips;
13662306a36Sopenharmony_ci	u32 special_pkt_period_cnt;
13762306a36Sopenharmony_ci	u32 high_priority_tx;
13862306a36Sopenharmony_ci	u32 high_priority_rx;
13962306a36Sopenharmony_ci	u32 low_priority_tx;
14062306a36Sopenharmony_ci	u32 low_priority_rx;
14162306a36Sopenharmony_ci	u8 bt_rssi;
14262306a36Sopenharmony_ci	u8 pre_bt_rssi_state;
14362306a36Sopenharmony_ci	u8 pre_wifi_rssi_state[4];
14462306a36Sopenharmony_ci	bool bt_tx_rx_mask;
14562306a36Sopenharmony_ci	bool c2h_bt_info_req_sent;
14662306a36Sopenharmony_ci	u8 bt_info_c2h[BT_INFO_SRC_8723B_1ANT_MAX][10];
14762306a36Sopenharmony_ci	u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_1ANT_MAX];
14862306a36Sopenharmony_ci	bool bt_whck_test;
14962306a36Sopenharmony_ci	bool c2h_bt_inquiry_page;
15062306a36Sopenharmony_ci	bool c2h_bt_remote_name_req;
15162306a36Sopenharmony_ci	bool wifi_is_high_pri_task;
15262306a36Sopenharmony_ci	u8 bt_retry_cnt;
15362306a36Sopenharmony_ci	u8 bt_info_ext;
15462306a36Sopenharmony_ci	u8 scan_ap_num;
15562306a36Sopenharmony_ci	bool cck_ever_lock;
15662306a36Sopenharmony_ci	u8 coex_table_type;
15762306a36Sopenharmony_ci	bool force_lps_on;
15862306a36Sopenharmony_ci	u32 pop_event_cnt;
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci	u32 crc_ok_cck;
16162306a36Sopenharmony_ci	u32 crc_ok_11g;
16262306a36Sopenharmony_ci	u32 crc_ok_11n;
16362306a36Sopenharmony_ci	u32 crc_ok_11n_agg;
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci	u32 crc_err_cck;
16662306a36Sopenharmony_ci	u32 crc_err_11g;
16762306a36Sopenharmony_ci	u32 crc_err_11n;
16862306a36Sopenharmony_ci	u32 crc_err_11n_agg;
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci	bool cck_lock;
17162306a36Sopenharmony_ci	bool pre_ccklock;
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci	u32 wrong_profile_notification;
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci	u8 a2dp_bit_pool;
17662306a36Sopenharmony_ci	u8 cut_version;
17762306a36Sopenharmony_ci};
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci/*************************************************************************
18062306a36Sopenharmony_ci * The following is interface which will notify coex module.
18162306a36Sopenharmony_ci *************************************************************************/
18262306a36Sopenharmony_civoid ex_btc8723b1ant_power_on_setting(struct btc_coexist *btcoexist);
18362306a36Sopenharmony_civoid ex_btc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist,
18462306a36Sopenharmony_ci				   bool wifi_only);
18562306a36Sopenharmony_civoid ex_btc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist);
18662306a36Sopenharmony_civoid ex_btc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
18762306a36Sopenharmony_civoid ex_btc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
18862306a36Sopenharmony_civoid ex_btc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
18962306a36Sopenharmony_civoid ex_btc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
19062306a36Sopenharmony_civoid ex_btc8723b1ant_media_status_notify(struct btc_coexist *btcoexist,
19162306a36Sopenharmony_ci					 u8 type);
19262306a36Sopenharmony_civoid ex_btc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist,
19362306a36Sopenharmony_ci					   u8 type);
19462306a36Sopenharmony_civoid ex_btc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist,
19562306a36Sopenharmony_ci				    u8 *tmpbuf, u8 length);
19662306a36Sopenharmony_civoid ex_btc8723b1ant_rf_status_notify(struct btc_coexist *btcoexist,
19762306a36Sopenharmony_ci				      u8 type);
19862306a36Sopenharmony_civoid ex_btc8723b1ant_halt_notify(struct btc_coexist *btcoexist);
19962306a36Sopenharmony_civoid ex_btc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnpstate);
20062306a36Sopenharmony_civoid ex_btc8723b1ant_coex_dm_reset(struct btc_coexist *btcoexist);
20162306a36Sopenharmony_civoid ex_btc8723b1ant_periodical(struct btc_coexist *btcoexist);
20262306a36Sopenharmony_civoid ex_btc8723b1ant_display_coex_info(struct btc_coexist *btcoexist,
20362306a36Sopenharmony_ci				       struct seq_file *m);
20462306a36Sopenharmony_civoid ex_btc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
205