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