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