xref: /linux/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h (revision bfd5bb6f90af092aa345b15cd78143956a13c2a8)
1 /******************************************************************************
2  *
3  * Copyright(c) 2009-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 #ifndef	__HALBTC_OUT_SRC_H__
26 #define __HALBTC_OUT_SRC_H__
27 
28 #include	"../wifi.h"
29 
30 #define		NORMAL_EXEC				false
31 #define		FORCE_EXEC				true
32 
33 #define		BTC_RF_OFF				0x0
34 #define		BTC_RF_ON				0x1
35 
36 #define		BTC_RF_A				RF90_PATH_A
37 #define		BTC_RF_B				RF90_PATH_B
38 #define		BTC_RF_C				RF90_PATH_C
39 #define		BTC_RF_D				RF90_PATH_D
40 
41 #define		BTC_SMSP				SINGLEMAC_SINGLEPHY
42 #define		BTC_DMDP				DUALMAC_DUALPHY
43 #define		BTC_DMSP				DUALMAC_SINGLEPHY
44 #define		BTC_MP_UNKNOWN				0xff
45 
46 #define		IN
47 #define		OUT
48 
49 #define		BT_TMP_BUF_SIZE				100
50 
51 #define		BT_COEX_ANT_TYPE_PG			0
52 #define		BT_COEX_ANT_TYPE_ANTDIV			1
53 #define		BT_COEX_ANT_TYPE_DETECTED		2
54 
55 #define		BTC_MIMO_PS_STATIC			0
56 #define		BTC_MIMO_PS_DYNAMIC			1
57 
58 #define		BTC_RATE_DISABLE			0
59 #define		BTC_RATE_ENABLE				1
60 
61 /* single Antenna definition */
62 #define		BTC_ANT_PATH_WIFI			0
63 #define		BTC_ANT_PATH_BT				1
64 #define		BTC_ANT_PATH_PTA			2
65 #define		BTC_ANT_PATH_WIFI5G			3
66 #define		BTC_ANT_PATH_AUTO			4
67 /* dual Antenna definition */
68 #define		BTC_ANT_WIFI_AT_MAIN			0
69 #define		BTC_ANT_WIFI_AT_AUX			1
70 /* coupler Antenna definition */
71 #define		BTC_ANT_WIFI_AT_CPL_MAIN		0
72 #define		BTC_ANT_WIFI_AT_CPL_AUX			1
73 
74 enum btc_bt_reg_type {
75 	BTC_BT_REG_RF		= 0,
76 	BTC_BT_REG_MODEM	= 1,
77 	BTC_BT_REG_BLUEWIZE	= 2,
78 	BTC_BT_REG_VENDOR	= 3,
79 	BTC_BT_REG_LE		= 4,
80 	BTC_BT_REG_MAX
81 };
82 
83 enum btc_chip_interface {
84 	BTC_INTF_UNKNOWN	= 0,
85 	BTC_INTF_PCI		= 1,
86 	BTC_INTF_USB		= 2,
87 	BTC_INTF_SDIO		= 3,
88 	BTC_INTF_GSPI		= 4,
89 	BTC_INTF_MAX
90 };
91 
92 enum btc_chip_type {
93 	BTC_CHIP_UNDEF		= 0,
94 	BTC_CHIP_CSR_BC4	= 1,
95 	BTC_CHIP_CSR_BC8	= 2,
96 	BTC_CHIP_RTL8723A	= 3,
97 	BTC_CHIP_RTL8821	= 4,
98 	BTC_CHIP_RTL8723B	= 5,
99 	BTC_CHIP_MAX
100 };
101 
102 enum btc_msg_type {
103 	BTC_MSG_INTERFACE	= 0x0,
104 	BTC_MSG_ALGORITHM	= 0x1,
105 	BTC_MSG_MAX
106 };
107 
108 /* following is for BTC_MSG_INTERFACE */
109 #define		INTF_INIT				BIT0
110 #define		INTF_NOTIFY				BIT2
111 
112 /* following is for BTC_ALGORITHM */
113 #define		ALGO_BT_RSSI_STATE			BIT0
114 #define		ALGO_WIFI_RSSI_STATE			BIT1
115 #define		ALGO_BT_MONITOR				BIT2
116 #define		ALGO_TRACE				BIT3
117 #define		ALGO_TRACE_FW				BIT4
118 #define		ALGO_TRACE_FW_DETAIL			BIT5
119 #define		ALGO_TRACE_FW_EXEC			BIT6
120 #define		ALGO_TRACE_SW				BIT7
121 #define		ALGO_TRACE_SW_DETAIL			BIT8
122 #define		ALGO_TRACE_SW_EXEC			BIT9
123 
124 /* following is for wifi link status */
125 #define		WIFI_STA_CONNECTED			BIT0
126 #define		WIFI_AP_CONNECTED			BIT1
127 #define		WIFI_HS_CONNECTED			BIT2
128 #define		WIFI_P2P_GO_CONNECTED			BIT3
129 #define		WIFI_P2P_GC_CONNECTED			BIT4
130 
131 #define	BTC_RSSI_HIGH(_rssi_)	\
132 	((_rssi_ == BTC_RSSI_STATE_HIGH ||	\
133 	  _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false)
134 #define	BTC_RSSI_MEDIUM(_rssi_)	\
135 	((_rssi_ == BTC_RSSI_STATE_MEDIUM ||	\
136 	  _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false)
137 #define	BTC_RSSI_LOW(_rssi_)	\
138 	((_rssi_ == BTC_RSSI_STATE_LOW ||	\
139 	  _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false)
140 
141 enum btc_power_save_type {
142 	BTC_PS_WIFI_NATIVE = 0,
143 	BTC_PS_LPS_ON = 1,
144 	BTC_PS_LPS_OFF = 2,
145 	BTC_PS_LPS_MAX
146 };
147 
148 struct btc_board_info {
149 	/* The following is some board information */
150 	u8 bt_chip_type;
151 	u8 pg_ant_num;	/* pg ant number */
152 	u8 btdm_ant_num;	/* ant number for btdm */
153 	u8 btdm_ant_pos;
154 	u8 single_ant_path; /* current used for 8723b only, 1=>s0,  0=>s1 */
155 	bool tfbga_package;
156 
157 	u8 rfe_type;
158 	u8 ant_div_cfg;
159 	u8 customer_id;
160 };
161 
162 enum btc_dbg_opcode {
163 	BTC_DBG_SET_COEX_NORMAL = 0x0,
164 	BTC_DBG_SET_COEX_WIFI_ONLY = 0x1,
165 	BTC_DBG_SET_COEX_BT_ONLY = 0x2,
166 	BTC_DBG_MAX
167 };
168 
169 enum btc_rssi_state {
170 	BTC_RSSI_STATE_HIGH = 0x0,
171 	BTC_RSSI_STATE_MEDIUM = 0x1,
172 	BTC_RSSI_STATE_LOW = 0x2,
173 	BTC_RSSI_STATE_STAY_HIGH = 0x3,
174 	BTC_RSSI_STATE_STAY_MEDIUM = 0x4,
175 	BTC_RSSI_STATE_STAY_LOW = 0x5,
176 	BTC_RSSI_MAX
177 };
178 
179 enum btc_wifi_role {
180 	BTC_ROLE_STATION = 0x0,
181 	BTC_ROLE_AP = 0x1,
182 	BTC_ROLE_IBSS = 0x2,
183 	BTC_ROLE_HS_MODE = 0x3,
184 	BTC_ROLE_MAX
185 };
186 
187 enum btc_wireless_freq {
188 	BTC_FREQ_2_4G = 0x0,
189 	BTC_FREQ_5G = 0x1,
190 	BTC_FREQ_MAX
191 };
192 
193 enum btc_wifi_bw_mode {
194 	BTC_WIFI_BW_LEGACY = 0x0,
195 	BTC_WIFI_BW_HT20 = 0x1,
196 	BTC_WIFI_BW_HT40 = 0x2,
197 	BTC_WIFI_BW_HT80 = 0x3,
198 	BTC_WIFI_BW_MAX
199 };
200 
201 enum btc_wifi_traffic_dir {
202 	BTC_WIFI_TRAFFIC_TX = 0x0,
203 	BTC_WIFI_TRAFFIC_RX = 0x1,
204 	BTC_WIFI_TRAFFIC_MAX
205 };
206 
207 enum btc_wifi_pnp {
208 	BTC_WIFI_PNP_WAKE_UP = 0x0,
209 	BTC_WIFI_PNP_SLEEP = 0x1,
210 	BTC_WIFI_PNP_SLEEP_KEEP_ANT = 0x2,
211 	BTC_WIFI_PNP_MAX
212 };
213 
214 enum btc_iot_peer {
215 	BTC_IOT_PEER_UNKNOWN = 0,
216 	BTC_IOT_PEER_REALTEK = 1,
217 	BTC_IOT_PEER_REALTEK_92SE = 2,
218 	BTC_IOT_PEER_BROADCOM = 3,
219 	BTC_IOT_PEER_RALINK = 4,
220 	BTC_IOT_PEER_ATHEROS = 5,
221 	BTC_IOT_PEER_CISCO = 6,
222 	BTC_IOT_PEER_MERU = 7,
223 	BTC_IOT_PEER_MARVELL = 8,
224 	BTC_IOT_PEER_REALTEK_SOFTAP = 9,
225 	BTC_IOT_PEER_SELF_SOFTAP = 10, /* Self is SoftAP */
226 	BTC_IOT_PEER_AIRGO = 11,
227 	BTC_IOT_PEER_REALTEK_JAGUAR_BCUTAP = 12,
228 	BTC_IOT_PEER_REALTEK_JAGUAR_CCUTAP = 13,
229 	BTC_IOT_PEER_MAX,
230 };
231 
232 /* for 8723b-d cut large current issue */
233 enum bt_wifi_coex_state {
234 	BTC_WIFI_STAT_INIT,
235 	BTC_WIFI_STAT_IQK,
236 	BTC_WIFI_STAT_NORMAL_OFF,
237 	BTC_WIFI_STAT_MP_OFF,
238 	BTC_WIFI_STAT_NORMAL,
239 	BTC_WIFI_STAT_ANT_DIV,
240 	BTC_WIFI_STAT_MAX
241 };
242 
243 enum bt_ant_type {
244 	BTC_ANT_TYPE_0,
245 	BTC_ANT_TYPE_1,
246 	BTC_ANT_TYPE_2,
247 	BTC_ANT_TYPE_3,
248 	BTC_ANT_TYPE_4,
249 	BTC_ANT_TYPE_MAX
250 };
251 
252 enum btc_get_type {
253 	/* type bool */
254 	BTC_GET_BL_HS_OPERATION,
255 	BTC_GET_BL_HS_CONNECTING,
256 	BTC_GET_BL_WIFI_CONNECTED,
257 	BTC_GET_BL_WIFI_DUAL_BAND_CONNECTED,
258 	BTC_GET_BL_WIFI_BUSY,
259 	BTC_GET_BL_WIFI_SCAN,
260 	BTC_GET_BL_WIFI_LINK,
261 	BTC_GET_BL_WIFI_DHCP,
262 	BTC_GET_BL_WIFI_SOFTAP_IDLE,
263 	BTC_GET_BL_WIFI_SOFTAP_LINKING,
264 	BTC_GET_BL_WIFI_IN_EARLY_SUSPEND,
265 	BTC_GET_BL_WIFI_ROAM,
266 	BTC_GET_BL_WIFI_4_WAY_PROGRESS,
267 	BTC_GET_BL_WIFI_UNDER_5G,
268 	BTC_GET_BL_WIFI_AP_MODE_ENABLE,
269 	BTC_GET_BL_WIFI_ENABLE_ENCRYPTION,
270 	BTC_GET_BL_WIFI_UNDER_B_MODE,
271 	BTC_GET_BL_EXT_SWITCH,
272 	BTC_GET_BL_WIFI_IS_IN_MP_MODE,
273 	BTC_GET_BL_IS_ASUS_8723B,
274 	BTC_GET_BL_FW_READY,
275 	BTC_GET_BL_RF4CE_CONNECTED,
276 
277 	/* type s4Byte */
278 	BTC_GET_S4_WIFI_RSSI,
279 	BTC_GET_S4_HS_RSSI,
280 
281 	/* type u32 */
282 	BTC_GET_U4_WIFI_BW,
283 	BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
284 	BTC_GET_U4_WIFI_FW_VER,
285 	BTC_GET_U4_WIFI_LINK_STATUS,
286 	BTC_GET_U4_BT_PATCH_VER,
287 	BTC_GET_U4_VENDOR,
288 	BTC_GET_U4_SUPPORTED_VERSION,
289 	BTC_GET_U4_SUPPORTED_FEATURE,
290 	BTC_GET_U4_BT_DEVICE_INFO,
291 	BTC_GET_U4_BT_FORBIDDEN_SLOT_VAL,
292 	BTC_GET_U4_WIFI_IQK_TOTAL,
293 	BTC_GET_U4_WIFI_IQK_OK,
294 	BTC_GET_U4_WIFI_IQK_FAIL,
295 
296 	/* type u1Byte */
297 	BTC_GET_U1_WIFI_DOT11_CHNL,
298 	BTC_GET_U1_WIFI_CENTRAL_CHNL,
299 	BTC_GET_U1_WIFI_HS_CHNL,
300 	BTC_GET_U1_MAC_PHY_MODE,
301 	BTC_GET_U1_AP_NUM,
302 	BTC_GET_U1_ANT_TYPE,
303 	BTC_GET_U1_IOT_PEER,
304 
305 	/* for 1Ant */
306 	BTC_GET_U1_LPS_MODE,
307 	BTC_GET_BL_BT_SCO_BUSY,
308 
309 	/* for test mode */
310 	BTC_GET_DRIVER_TEST_CFG,
311 	BTC_GET_MAX
312 };
313 
314 enum btc_vendor {
315 	BTC_VENDOR_LENOVO,
316 	BTC_VENDOR_ASUS,
317 	BTC_VENDOR_OTHER
318 };
319 
320 enum btc_set_type {
321 	/* type bool */
322 	BTC_SET_BL_BT_DISABLE,
323 	BTC_SET_BL_BT_TRAFFIC_BUSY,
324 	BTC_SET_BL_BT_LIMITED_DIG,
325 	BTC_SET_BL_FORCE_TO_ROAM,
326 	BTC_SET_BL_TO_REJ_AP_AGG_PKT,
327 	BTC_SET_BL_BT_CTRL_AGG_SIZE,
328 	BTC_SET_BL_INC_SCAN_DEV_NUM,
329 	BTC_SET_BL_BT_TX_RX_MASK,
330 	BTC_SET_BL_MIRACAST_PLUS_BT,
331 
332 	/* type u1Byte */
333 	BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
334 	BTC_SET_UI_SCAN_SIG_COMPENSATION,
335 	BTC_SET_U1_AGG_BUF_SIZE,
336 
337 	/* type trigger some action */
338 	BTC_SET_ACT_GET_BT_RSSI,
339 	BTC_SET_ACT_AGGREGATE_CTRL,
340 	BTC_SET_ACT_ANTPOSREGRISTRY_CTRL,
341 	BTC_SET_MIMO_PS_MODE,
342 
343 	/********* for 1Ant **********/
344 	/* type bool */
345 	BTC_SET_BL_BT_SCO_BUSY,
346 	/* type u1Byte */
347 	BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE,
348 	BTC_SET_U1_LPS_VAL,
349 	BTC_SET_U1_RPWM_VAL,
350 	BTC_SET_U1_1ANT_LPS,
351 	BTC_SET_U1_1ANT_RPWM,
352 	/* type trigger some action */
353 	BTC_SET_ACT_LEAVE_LPS,
354 	BTC_SET_ACT_ENTER_LPS,
355 	BTC_SET_ACT_NORMAL_LPS,
356 	BTC_SET_ACT_PRE_NORMAL_LPS,
357 	BTC_SET_ACT_POST_NORMAL_LPS,
358 	BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT,
359 	BTC_SET_ACT_DISABLE_LOW_POWER,
360 	BTC_SET_BL_BT_LNA_CONSTRAIN_LEVEL,
361 	BTC_SET_ACT_UPDATE_RAMASK,
362 	BTC_SET_ACT_SEND_MIMO_PS,
363 	/* BT Coex related */
364 	BTC_SET_ACT_CTRL_BT_INFO,
365 	BTC_SET_ACT_CTRL_BT_COEX,
366 	BTC_SET_ACT_CTRL_8723B_ANT,
367 	/***************************/
368 	BTC_SET_MAX
369 };
370 
371 enum btc_dbg_disp_type {
372 	BTC_DBG_DISP_COEX_STATISTICS = 0x0,
373 	BTC_DBG_DISP_BT_LINK_INFO = 0x1,
374 	BTC_DBG_DISP_BT_FW_VER = 0x2,
375 	BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x3,
376 	BTC_DBG_DISP_WIFI_STATUS = 0x04,
377 	BTC_DBG_DISP_MAX
378 };
379 
380 enum btc_notify_type_ips {
381 	BTC_IPS_LEAVE = 0x0,
382 	BTC_IPS_ENTER = 0x1,
383 	BTC_IPS_MAX
384 };
385 
386 enum btc_notify_type_lps {
387 	BTC_LPS_DISABLE = 0x0,
388 	BTC_LPS_ENABLE = 0x1,
389 	BTC_LPS_MAX
390 };
391 
392 enum btc_notify_type_scan {
393 	BTC_SCAN_FINISH = 0x0,
394 	BTC_SCAN_START = 0x1,
395 	BTC_SCAN_START_2G = 0x2,
396 	BTC_SCAN_MAX
397 };
398 
399 enum btc_notify_type_switchband {
400 	BTC_NOT_SWITCH = 0x0,
401 	BTC_SWITCH_TO_24G = 0x1,
402 	BTC_SWITCH_TO_5G = 0x2,
403 	BTC_SWITCH_TO_24G_NOFORSCAN = 0x3,
404 	BTC_SWITCH_MAX
405 };
406 
407 enum btc_notify_type_associate {
408 	BTC_ASSOCIATE_FINISH = 0x0,
409 	BTC_ASSOCIATE_START = 0x1,
410 	BTC_ASSOCIATE_5G_FINISH = 0x2,
411 	BTC_ASSOCIATE_5G_START = 0x3,
412 	BTC_ASSOCIATE_MAX
413 };
414 
415 enum btc_notify_type_media_status {
416 	BTC_MEDIA_DISCONNECT = 0x0,
417 	BTC_MEDIA_CONNECT = 0x1,
418 	BTC_MEDIA_MAX
419 };
420 
421 enum btc_notify_type_special_packet {
422 	BTC_PACKET_UNKNOWN = 0x0,
423 	BTC_PACKET_DHCP = 0x1,
424 	BTC_PACKET_ARP = 0x2,
425 	BTC_PACKET_EAPOL = 0x3,
426 	BTC_PACKET_MAX
427 };
428 
429 enum hci_ext_bt_operation {
430 	HCI_BT_OP_NONE = 0x0,
431 	HCI_BT_OP_INQUIRY_START = 0x1,
432 	HCI_BT_OP_INQUIRY_FINISH = 0x2,
433 	HCI_BT_OP_PAGING_START = 0x3,
434 	HCI_BT_OP_PAGING_SUCCESS = 0x4,
435 	HCI_BT_OP_PAGING_UNSUCCESS = 0x5,
436 	HCI_BT_OP_PAIRING_START = 0x6,
437 	HCI_BT_OP_PAIRING_FINISH = 0x7,
438 	HCI_BT_OP_BT_DEV_ENABLE = 0x8,
439 	HCI_BT_OP_BT_DEV_DISABLE = 0x9,
440 	HCI_BT_OP_MAX
441 };
442 
443 enum btc_notify_type_stack_operation {
444 	BTC_STACK_OP_NONE = 0x0,
445 	BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1,
446 	BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2,
447 	BTC_STACK_OP_MAX
448 };
449 
450 enum {
451 	BTC_CCK_1,
452 	BTC_CCK_2,
453 	BTC_CCK_5_5,
454 	BTC_CCK_11,
455 	BTC_OFDM_6,
456 	BTC_OFDM_9,
457 	BTC_OFDM_12,
458 	BTC_OFDM_18,
459 	BTC_OFDM_24,
460 	BTC_OFDM_36,
461 	BTC_OFDM_48,
462 	BTC_OFDM_54,
463 	BTC_MCS_0,
464 	BTC_MCS_1,
465 	BTC_MCS_2,
466 	BTC_MCS_3,
467 	BTC_MCS_4,
468 	BTC_MCS_5,
469 	BTC_MCS_6,
470 	BTC_MCS_7,
471 	BTC_MCS_8,
472 	BTC_MCS_9,
473 	BTC_MCS_10,
474 	BTC_MCS_11,
475 	BTC_MCS_12,
476 	BTC_MCS_13,
477 	BTC_MCS_14,
478 	BTC_MCS_15,
479 	BTC_MCS_16,
480 	BTC_MCS_17,
481 	BTC_MCS_18,
482 	BTC_MCS_19,
483 	BTC_MCS_20,
484 	BTC_MCS_21,
485 	BTC_MCS_22,
486 	BTC_MCS_23,
487 	BTC_MCS_24,
488 	BTC_MCS_25,
489 	BTC_MCS_26,
490 	BTC_MCS_27,
491 	BTC_MCS_28,
492 	BTC_MCS_29,
493 	BTC_MCS_30,
494 	BTC_MCS_31,
495 	BTC_VHT_1SS_MCS_0,
496 	BTC_VHT_1SS_MCS_1,
497 	BTC_VHT_1SS_MCS_2,
498 	BTC_VHT_1SS_MCS_3,
499 	BTC_VHT_1SS_MCS_4,
500 	BTC_VHT_1SS_MCS_5,
501 	BTC_VHT_1SS_MCS_6,
502 	BTC_VHT_1SS_MCS_7,
503 	BTC_VHT_1SS_MCS_8,
504 	BTC_VHT_1SS_MCS_9,
505 	BTC_VHT_2SS_MCS_0,
506 	BTC_VHT_2SS_MCS_1,
507 	BTC_VHT_2SS_MCS_2,
508 	BTC_VHT_2SS_MCS_3,
509 	BTC_VHT_2SS_MCS_4,
510 	BTC_VHT_2SS_MCS_5,
511 	BTC_VHT_2SS_MCS_6,
512 	BTC_VHT_2SS_MCS_7,
513 	BTC_VHT_2SS_MCS_8,
514 	BTC_VHT_2SS_MCS_9,
515 	BTC_VHT_3SS_MCS_0,
516 	BTC_VHT_3SS_MCS_1,
517 	BTC_VHT_3SS_MCS_2,
518 	BTC_VHT_3SS_MCS_3,
519 	BTC_VHT_3SS_MCS_4,
520 	BTC_VHT_3SS_MCS_5,
521 	BTC_VHT_3SS_MCS_6,
522 	BTC_VHT_3SS_MCS_7,
523 	BTC_VHT_3SS_MCS_8,
524 	BTC_VHT_3SS_MCS_9,
525 	BTC_VHT_4SS_MCS_0,
526 	BTC_VHT_4SS_MCS_1,
527 	BTC_VHT_4SS_MCS_2,
528 	BTC_VHT_4SS_MCS_3,
529 	BTC_VHT_4SS_MCS_4,
530 	BTC_VHT_4SS_MCS_5,
531 	BTC_VHT_4SS_MCS_6,
532 	BTC_VHT_4SS_MCS_7,
533 	BTC_VHT_4SS_MCS_8,
534 	BTC_VHT_4SS_MCS_9,
535 	BTC_MCS_32,
536 	BTC_UNKNOWN,
537 	BTC_PKT_MGNT,
538 	BTC_PKT_CTRL,
539 	BTC_PKT_UNKNOWN,
540 	BTC_PKT_NOT_FOR_ME,
541 	BTC_RATE_MAX
542 };
543 
544 enum {
545 	BTC_MULTIPORT_SCC,
546 	BTC_MULTIPORT_MCC_2CHANNEL,
547 	BTC_MULTIPORT_MCC_2BAND,
548 	BTC_MULTIPORT_MAX
549 };
550 
551 struct btc_bt_info {
552 	bool bt_disabled;
553 	u8 rssi_adjust_for_agc_table_on;
554 	u8 rssi_adjust_for_1ant_coex_type;
555 	bool pre_bt_ctrl_agg_buf_size;
556 	bool bt_busy;
557 	u8 pre_agg_buf_size;
558 	u8 agg_buf_size;
559 	bool limited_dig;
560 	bool pre_reject_agg_pkt;
561 	bool reject_agg_pkt;
562 	bool bt_ctrl_buf_size;
563 	bool increase_scan_dev_num;
564 	bool miracast_plus_bt;
565 	bool bt_ctrl_agg_buf_size;
566 	bool bt_tx_rx_mask;
567 	u16 bt_hci_ver;
568 	u16 bt_real_fw_ver;
569 	u8 bt_fw_ver;
570 	u32 bt_get_fw_ver;
571 
572 	bool bt_disable_low_pwr;
573 
574 	/* the following is for 1Ant solution */
575 	bool bt_ctrl_lps;
576 	bool bt_pwr_save_mode;
577 	bool bt_lps_on;
578 	bool force_to_roam;
579 	u8 force_exec_pwr_cmd_cnt;
580 	u8 lps_val;
581 	u8 rpwm_val;
582 	u32 ra_mask;
583 
584 	u32 afh_map_l;
585 	u32 afh_map_m;
586 	u16 afh_map_h;
587 	u32 bt_supported_feature;
588 	u32 bt_supported_version;
589 	u32 bt_device_info;
590 	u32 bt_forb_slot_val;
591 	u8 bt_ant_det_val;
592 	u8 bt_ble_scan_type;
593 	u32 bt_ble_scan_para;
594 };
595 
596 struct btc_stack_info {
597 	bool profile_notified;
598 	u16 hci_version;	/* stack hci version */
599 	u8 num_of_link;
600 	bool bt_link_exist;
601 	bool sco_exist;
602 	bool acl_exist;
603 	bool a2dp_exist;
604 	bool hid_exist;
605 	u8 num_of_hid;
606 	bool pan_exist;
607 	bool unknown_acl_exist;
608 	s8 min_bt_rssi;
609 };
610 
611 struct btc_statistics {
612 	u32 cnt_bind;
613 	u32 cnt_init_hw_config;
614 	u32 cnt_init_coex_dm;
615 	u32 cnt_ips_notify;
616 	u32 cnt_lps_notify;
617 	u32 cnt_scan_notify;
618 	u32 cnt_connect_notify;
619 	u32 cnt_media_status_notify;
620 	u32 cnt_special_packet_notify;
621 	u32 cnt_bt_info_notify;
622 	u32 cnt_periodical;
623 	u32 cnt_coex_dm_switch;
624 	u32 cnt_stack_operation_notify;
625 	u32 cnt_dbg_ctrl;
626 	u32 cnt_pre_load_firmware;
627 	u32 cnt_power_on;
628 };
629 
630 struct btc_bt_link_info {
631 	bool bt_link_exist;
632 	bool bt_hi_pri_link_exist;
633 	bool sco_exist;
634 	bool sco_only;
635 	bool a2dp_exist;
636 	bool a2dp_only;
637 	bool hid_exist;
638 	bool hid_only;
639 	bool pan_exist;
640 	bool pan_only;
641 	bool slave_role;
642 	bool acl_busy;
643 };
644 
645 enum btc_antenna_pos {
646 	BTC_ANTENNA_AT_MAIN_PORT = 0x1,
647 	BTC_ANTENNA_AT_AUX_PORT = 0x2,
648 };
649 
650 enum btc_mp_h2c_op_code {
651 	BT_OP_GET_BT_VERSION			= 0,
652 	BT_OP_WRITE_REG_ADDR			= 12,
653 	BT_OP_WRITE_REG_VALUE			= 13,
654 	BT_OP_READ_REG				= 17,
655 	BT_OP_GET_AFH_MAP_L			= 30,
656 	BT_OP_GET_AFH_MAP_M			= 31,
657 	BT_OP_GET_AFH_MAP_H			= 32,
658 	BT_OP_GET_BT_COEX_SUPPORTED_FEATURE	= 42,
659 	BT_OP_GET_BT_COEX_SUPPORTED_VERSION	= 43,
660 	BT_OP_GET_BT_ANT_DET_VAL		= 44,
661 	BT_OP_GET_BT_BLE_SCAN_PARA		= 45,
662 	BT_OP_GET_BT_BLE_SCAN_TYPE		= 46,
663 	BT_OP_GET_BT_DEVICE_INFO		= 48,
664 	BT_OP_GET_BT_FORBIDDEN_SLOT_VAL		= 49,
665 	BT_OP_MAX
666 };
667 
668 enum btc_mp_h2c_req_num {
669 	/* 4 bits only */
670 	BT_SEQ_DONT_CARE			= 0,
671 	BT_SEQ_GET_BT_VERSION			= 0xE,
672 	BT_SEQ_GET_AFH_MAP_L			= 0x5,
673 	BT_SEQ_GET_AFH_MAP_M			= 0x6,
674 	BT_SEQ_GET_AFH_MAP_H			= 0x9,
675 	BT_SEQ_GET_BT_COEX_SUPPORTED_FEATURE	= 0x7,
676 	BT_SEQ_GET_BT_COEX_SUPPORTED_VERSION	= 0x8,
677 	BT_SEQ_GET_BT_ANT_DET_VAL		= 0x2,
678 	BT_SEQ_GET_BT_BLE_SCAN_PARA		= 0x3,
679 	BT_SEQ_GET_BT_BLE_SCAN_TYPE		= 0x4,
680 	BT_SEQ_GET_BT_DEVICE_INFO		= 0xA,
681 	BT_SEQ_GET_BT_FORB_SLOT_VAL		= 0xB,
682 };
683 
684 struct btc_coexist {
685 	/* make sure only one adapter can bind the data context  */
686 	bool binded;
687 	/* default adapter */
688 	void *adapter;
689 	struct btc_board_info board_info;
690 	/* some bt info referenced by non-bt module */
691 	struct btc_bt_info bt_info;
692 	struct btc_stack_info stack_info;
693 	enum btc_chip_interface	chip_interface;
694 	struct btc_bt_link_info bt_link_info;
695 
696 	/* boolean variables to replace BT_AUTO_REPORT_ONLY_XXXXY_ZANT
697 	 * configuration parameters
698 	 */
699 	bool auto_report_1ant;
700 	bool auto_report_2ant;
701 	bool dbg_mode_1ant;
702 	bool dbg_mode_2ant;
703 	bool initilized;
704 	bool stop_coex_dm;
705 	bool manual_control;
706 	struct btc_statistics statistics;
707 	u8 pwr_mode_val[10];
708 
709 	struct completion bt_mp_comp;
710 
711 	/* function pointers - io related */
712 	u8 (*btc_read_1byte)(void *btc_context, u32 reg_addr);
713 	void (*btc_write_1byte)(void *btc_context, u32 reg_addr, u32 data);
714 	void (*btc_write_1byte_bitmask)(void *btc_context, u32 reg_addr,
715 					u32 bit_mask, u8 data1b);
716 	u16 (*btc_read_2byte)(void *btc_context, u32 reg_addr);
717 	void (*btc_write_2byte)(void *btc_context, u32 reg_addr, u16 data);
718 	u32 (*btc_read_4byte)(void *btc_context, u32 reg_addr);
719 	void (*btc_write_4byte)(void *btc_context, u32 reg_addr, u32 data);
720 
721 	void (*btc_write_local_reg_1byte)(void *btc_context, u32 reg_addr,
722 					  u8 data);
723 	void (*btc_set_bb_reg)(void *btc_context, u32 reg_addr,
724 			       u32 bit_mask, u32 data);
725 	u32 (*btc_get_bb_reg)(void *btc_context, u32 reg_addr,
726 			      u32 bit_mask);
727 	void (*btc_set_rf_reg)(void *btc_context, u8 rf_path, u32 reg_addr,
728 			       u32 bit_mask, u32 data);
729 	u32 (*btc_get_rf_reg)(void *btc_context, u8 rf_path,
730 			      u32 reg_addr, u32 bit_mask);
731 
732 	void (*btc_fill_h2c)(void *btc_context, u8 element_id,
733 			     u32 cmd_len, u8 *cmd_buffer);
734 
735 	void (*btc_disp_dbg_msg)(void *btcoexist, u8 disp_type,
736 				 struct seq_file *m);
737 
738 	bool (*btc_get)(void *btcoexist, u8 get_type, void *out_buf);
739 	bool (*btc_set)(void *btcoexist, u8 set_type, void *in_buf);
740 
741 	void (*btc_set_bt_reg)(void *btc_context, u8 reg_type, u32 offset,
742 			       u32 value);
743 	u32 (*btc_get_bt_reg)(void *btc_context, u8 reg_type, u32 offset);
744 	u32 (*btc_get_bt_coex_supported_feature)(void *btcoexist);
745 	u32 (*btc_get_bt_coex_supported_version)(void *btcoexist);
746 	u32 (*btc_get_bt_phydm_version)(void *btcoexist);
747 	void (*btc_phydm_modify_ra_pcr_threshold)(void *btcoexist,
748 						  u8 ra_offset_direction,
749 						  u8 ra_threshold_offset);
750 	u32 (*btc_phydm_query_phy_counter)(void *btcoexist,
751 					   enum dm_info_query dm_id);
752 	u8 (*btc_get_ant_det_val_from_bt)(void *btcoexist);
753 	u8 (*btc_get_ble_scan_type_from_bt)(void *btcoexist);
754 	u32 (*btc_get_ble_scan_para_from_bt)(void *btcoexist, u8 scan_type);
755 	bool (*btc_get_bt_afh_map_from_bt)(void *btcoexist, u8 map_type,
756 					   u8 *afh_map);
757 };
758 
759 bool halbtc_is_wifi_uplink(struct rtl_priv *adapter);
760 
761 #define rtl_btc_coexist(rtlpriv)				\
762 	((struct btc_coexist *)((rtlpriv)->btcoexist.btc_context))
763 #define rtl_btc_wifi_only(rtlpriv)				\
764 	((struct wifi_only_cfg *)((rtlpriv)->btcoexist.wifi_only_context))
765 
766 struct wifi_only_cfg;
767 
768 bool exhalbtc_initlize_variables(struct rtl_priv *rtlpriv);
769 bool exhalbtc_initlize_variables_wifi_only(struct rtl_priv *rtlpriv);
770 bool exhalbtc_bind_bt_coex_withadapter(void *adapter);
771 void exhalbtc_power_on_setting(struct btc_coexist *btcoexist);
772 void exhalbtc_pre_load_firmware(struct btc_coexist *btcoexist);
773 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist, bool wifi_only);
774 void exhalbtc_init_hw_config_wifi_only(struct wifi_only_cfg *wifionly_cfg);
775 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist);
776 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type);
777 void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type);
778 void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type);
779 void exhalbtc_scan_notify_wifi_only(struct wifi_only_cfg *wifionly_cfg,
780 				    u8 is_5g);
781 void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action);
782 void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
783 				 enum rt_media_status media_status);
784 void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type);
785 void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist, u8 *tmp_buf,
786 			     u8 length);
787 void exhalbtc_rf_status_notify(struct btc_coexist *btcoexist, u8 type);
788 void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type);
789 void exhalbtc_halt_notify(struct btc_coexist *btcoexist);
790 void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
791 void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist);
792 void exhalbtc_periodical(struct btc_coexist *btcoexist);
793 void exhalbtc_dbg_control(struct btc_coexist *btcoexist, u8 code, u8 len,
794 			  u8 *data);
795 void exhalbtc_antenna_detection(struct btc_coexist *btcoexist, u32 cent_freq,
796 				u32 offset, u32 span, u32 seconds);
797 void exhalbtc_stack_update_profile_info(void);
798 void exhalbtc_set_hci_version(struct btc_coexist *btcoexist, u16 hci_version);
799 void exhalbtc_set_bt_patch_version(struct btc_coexist *btcoexist,
800 				   u16 bt_hci_version, u16 bt_patch_version);
801 void exhalbtc_update_min_bt_rssi(struct btc_coexist *btcoexist, s8 bt_rssi);
802 void exhalbtc_set_bt_exist(struct btc_coexist *btcoexist, bool bt_exist);
803 void exhalbtc_set_chip_type(struct btc_coexist *btcoexist, u8 chip_type);
804 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
805 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist,
806 				   struct seq_file *m);
807 void exhalbtc_switch_band_notify(struct btc_coexist *btcoexist, u8 type);
808 void exhalbtc_switch_band_notify_wifi_only(struct wifi_only_cfg *wifionly_cfg,
809 					   u8 is_5g);
810 void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
811 				  u8 *rssi_wifi, u8 *rssi_bt);
812 void exhalbtc_lps_leave(struct btc_coexist *btcoexist);
813 void exhalbtc_low_wifi_traffic_notify(struct btc_coexist *btcoexist);
814 void exhalbtc_set_single_ant_path(struct btc_coexist *btcoexist,
815 				  u8 single_ant_path);
816 void halbtc_send_wifi_port_id_cmd(void *bt_context);
817 void halbtc_set_default_port_id_cmd(void *bt_context);
818 
819 /* The following are used by wifi_only case */
820 enum wifionly_chip_interface {
821 	WIFIONLY_INTF_UNKNOWN	= 0,
822 	WIFIONLY_INTF_PCI		= 1,
823 	WIFIONLY_INTF_USB		= 2,
824 	WIFIONLY_INTF_SDIO		= 3,
825 	WIFIONLY_INTF_MAX
826 };
827 
828 enum wifionly_customer_id {
829 	CUSTOMER_NORMAL			= 0,
830 	CUSTOMER_HP_1			= 1,
831 };
832 
833 struct wifi_only_haldata {
834 	u16		customer_id;
835 	u8		efuse_pg_antnum;
836 	u8		efuse_pg_antpath;
837 	u8		rfe_type;
838 	u8		ant_div_cfg;
839 };
840 
841 struct wifi_only_cfg {
842 	void				*adapter;
843 	struct wifi_only_haldata	haldata_info;
844 	enum wifionly_chip_interface	chip_interface;
845 };
846 
847 static inline
848 void halwifionly_phy_set_bb_reg(struct wifi_only_cfg *wifi_conly_cfg,
849 				u32 regaddr, u32 bitmask, u32 data)
850 {
851 	struct rtl_priv *rtlpriv = (struct rtl_priv *)wifi_conly_cfg->adapter;
852 
853 	rtl_set_bbreg(rtlpriv->hw, regaddr, bitmask, data);
854 }
855 
856 #endif
857