• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2012  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  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25 
26 /*===========================================
27  * The following is for 8821A 1ANT BT Co-exist definition
28  *===========================================
29  */
30 #define	BT_AUTO_REPORT_ONLY_8821A_1ANT				0
31 
32 #define	BT_INFO_8821A_1ANT_B_FTP	BIT7
33 #define	BT_INFO_8821A_1ANT_B_A2DP	BIT6
34 #define	BT_INFO_8821A_1ANT_B_HID	BIT5
35 #define	BT_INFO_8821A_1ANT_B_SCO_BUSY	BIT4
36 #define	BT_INFO_8821A_1ANT_B_ACL_BUSY	BIT3
37 #define	BT_INFO_8821A_1ANT_B_INQ_PAGE	BIT2
38 #define	BT_INFO_8821A_1ANT_B_SCO_ESCO	BIT1
39 #define	BT_INFO_8821A_1ANT_B_CONNECTION	BIT0
40 
41 #define	BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_)	\
42 		(((_BT_INFO_EXT_&BIT0)) ? true : false)
43 
44 #define	BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT		2
45 
46 enum _BT_INFO_SRC_8821A_1ANT {
47 	BT_INFO_SRC_8821A_1ANT_WIFI_FW			= 0x0,
48 	BT_INFO_SRC_8821A_1ANT_BT_RSP			= 0x1,
49 	BT_INFO_SRC_8821A_1ANT_BT_ACTIVE_SEND		= 0x2,
50 	BT_INFO_SRC_8821A_1ANT_MAX
51 };
52 
53 enum _BT_8821A_1ANT_BT_STATUS {
54 	BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE		= 0x0,
55 	BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE			= 0x1,
56 	BT_8821A_1ANT_BT_STATUS_INQ_PAGE			= 0x2,
57 	BT_8821A_1ANT_BT_STATUS_ACL_BUSY			= 0x3,
58 	BT_8821A_1ANT_BT_STATUS_SCO_BUSY			= 0x4,
59 	BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY			= 0x5,
60 	BT_8821A_1ANT_BT_STATUS_MAX
61 };
62 
63 enum _BT_8821A_1ANT_WIFI_STATUS {
64 	BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE		= 0x0,
65 	BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN	= 0x1,
66 	BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN		= 0x2,
67 	BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT		= 0x3,
68 	BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE		= 0x4,
69 	BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY		= 0x5,
70 	BT_8821A_1ANT_WIFI_STATUS_MAX
71 };
72 
73 enum BT_8821A_1ANT_COEX_ALGO {
74 	BT_8821A_1ANT_COEX_ALGO_UNDEFINED		= 0x0,
75 	BT_8821A_1ANT_COEX_ALGO_SCO			= 0x1,
76 	BT_8821A_1ANT_COEX_ALGO_HID			= 0x2,
77 	BT_8821A_1ANT_COEX_ALGO_A2DP			= 0x3,
78 	BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS		= 0x4,
79 	BT_8821A_1ANT_COEX_ALGO_PANEDR			= 0x5,
80 	BT_8821A_1ANT_COEX_ALGO_PANHS			= 0x6,
81 	BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP		= 0x7,
82 	BT_8821A_1ANT_COEX_ALGO_PANEDR_HID		= 0x8,
83 	BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR		= 0x9,
84 	BT_8821A_1ANT_COEX_ALGO_HID_A2DP		= 0xa,
85 	BT_8821A_1ANT_COEX_ALGO_MAX			= 0xb,
86 };
87 
88 struct coex_dm_8821a_1ant {
89 	/* fw mechanism */
90 	bool	cur_ignore_wlan_act;
91 	bool	pre_ignore_wlan_act;
92 	u8	pre_ps_tdma;
93 	u8	cur_ps_tdma;
94 	u8	ps_tdma_para[5];
95 	u8	tdma_adj_type;
96 	bool	auto_tdma_adjust;
97 	bool	pre_ps_tdma_on;
98 	bool	cur_ps_tdma_on;
99 	bool	pre_bt_auto_report;
100 	bool	cur_bt_auto_report;
101 	u8	pre_lps;
102 	u8	cur_lps;
103 	u8	pre_rpwm;
104 	u8	cur_rpwm;
105 
106 	/* sw mechanism */
107 	bool	pre_low_penalty_ra;
108 	bool	cur_low_penalty_ra;
109 	u32	pre_val_0x6c0;
110 	u32	cur_val_0x6c0;
111 	u32	pre_val_0x6c4;
112 	u32	cur_val_0x6c4;
113 	u32	pre_val_0x6c8;
114 	u32	cur_val_0x6c8;
115 	u8	pre_val_0x6cc;
116 	u8	cur_val_0x6cc;
117 	/* Auto Rate Fallback Retry cnt */
118 	u32	backup_arfr_cnt1;
119 	/* Auto Rate Fallback Retry cnt */
120 	u32	backup_arfr_cnt2;
121 	u16	backup_retry_limit;
122 	u8	backup_ampdu_max_time;
123 
124 	/* algorithm related */
125 	u8	pre_algorithm;
126 	u8	cur_algorithm;
127 	u8	bt_status;
128 	u8	wifi_chnl_info[3];
129 
130 	u32	pre_ra_mask;
131 	u32	cur_ra_mask;
132 	u8	pre_arfr_type;
133 	u8	cur_arfr_type;
134 	u8	pre_retry_limit_type;
135 	u8	cur_retry_limit_type;
136 	u8	pre_ampdu_time_type;
137 	u8	cur_ampdu_time_type;
138 
139 	u8	error_condition;
140 };
141 
142 struct coex_sta_8821a_1ant {
143 	bool	bt_link_exist;
144 	bool	sco_exist;
145 	bool	a2dp_exist;
146 	bool	hid_exist;
147 	bool	pan_exist;
148 
149 	bool	under_Lps;
150 	bool	under_ips;
151 	u32	special_pkt_period_cnt;
152 	u32	high_priority_tx;
153 	u32	high_priority_rx;
154 	u32	low_priority_tx;
155 	u32	low_priority_rx;
156 	u8	bt_rssi;
157 	u8	pre_bt_rssi_state;
158 	u8	pre_wifi_rssi_state[4];
159 	bool	c2h_bt_info_req_sent;
160 	u8	bt_info_c2h[BT_INFO_SRC_8821A_1ANT_MAX][10];
161 	u32	bt_info_c2h_cnt[BT_INFO_SRC_8821A_1ANT_MAX];
162 	bool	c2h_bt_inquiry_page;
163 	u8	bt_retry_cnt;
164 	u8	bt_info_ext;
165 };
166 
167 /*===========================================
168  * The following is interface which will notify coex module.
169  *===========================================
170  */
171 void ex_halbtc8821a1ant_init_hwconfig(struct btc_coexist *btcoexist);
172 void ex_halbtc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist);
173 void ex_halbtc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
174 void ex_halbtc8821a1ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
175 void ex_halbtc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
176 void ex_halbtc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
177 void ex_halbtc8821a1ant_media_status_notify(struct btc_coexist *btcoexist,
178 					    u8 type);
179 void ex_halbtc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
180 					      u8 type);
181 void ex_halbtc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
182 				       u8 *tmpbuf, u8 length);
183 void ex_halbtc8821a1ant_halt_notify(struct btc_coexist *btcoexist);
184 void ex_halbtc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnpstate);
185 void ex_halbtc8821a1ant_periodical(struct btc_coexist *btcoexist);
186 void ex_halbtc8821a1ant_display_coex_info(struct btc_coexist *btcoexist);
187 void ex_halbtc8821a1ant_dbg_control(struct btc_coexist *btcoexist, u8 op_code,
188 				    u8 op_len, u8 *data);
189