1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation.
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.
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
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
25 #ifndef __HALBTC_OUT_SRC_H__
26 #define __HALBTC_OUT_SRC_H__
30 #define NORMAL_EXEC false
31 #define FORCE_EXEC true
33 #define BTC_RF_A RF90_PATH_A
34 #define BTC_RF_B RF90_PATH_B
35 #define BTC_RF_C RF90_PATH_C
36 #define BTC_RF_D RF90_PATH_D
38 #define BTC_SMSP SINGLEMAC_SINGLEPHY
39 #define BTC_DMDP DUALMAC_DUALPHY
40 #define BTC_DMSP DUALMAC_SINGLEPHY
41 #define BTC_MP_UNKNOWN 0xff
46 #define BT_TMP_BUF_SIZE 100
48 #define BT_COEX_ANT_TYPE_PG 0
49 #define BT_COEX_ANT_TYPE_ANTDIV 1
50 #define BT_COEX_ANT_TYPE_DETECTED 2
52 #define BTC_MIMO_PS_STATIC 0
53 #define BTC_MIMO_PS_DYNAMIC 1
55 #define BTC_RATE_DISABLE 0
56 #define BTC_RATE_ENABLE 1
58 /* single Antenna definition */
59 #define BTC_ANT_PATH_WIFI 0
60 #define BTC_ANT_PATH_BT 1
61 #define BTC_ANT_PATH_PTA 2
62 /* dual Antenna definition */
63 #define BTC_ANT_WIFI_AT_MAIN 0
64 #define BTC_ANT_WIFI_AT_AUX 1
65 /* coupler Antenna definition */
66 #define BTC_ANT_WIFI_AT_CPL_MAIN 0
67 #define BTC_ANT_WIFI_AT_CPL_AUX 1
69 enum btc_chip_interface
{
82 BTC_CHIP_RTL8723A
= 3,
84 BTC_CHIP_RTL8723B
= 5,
89 BTC_MSG_INTERFACE
= 0x0,
90 BTC_MSG_ALGORITHM
= 0x1,
94 extern u32 btc_dbg_type
[];
96 /* following is for BTC_MSG_INTERFACE */
97 #define INTF_INIT BIT0
98 #define INTF_NOTIFY BIT2
100 /* following is for BTC_ALGORITHM */
101 #define ALGO_BT_RSSI_STATE BIT0
102 #define ALGO_WIFI_RSSI_STATE BIT1
103 #define ALGO_BT_MONITOR BIT2
104 #define ALGO_TRACE BIT3
105 #define ALGO_TRACE_FW BIT4
106 #define ALGO_TRACE_FW_DETAIL BIT5
107 #define ALGO_TRACE_FW_EXEC BIT6
108 #define ALGO_TRACE_SW BIT7
109 #define ALGO_TRACE_SW_DETAIL BIT8
110 #define ALGO_TRACE_SW_EXEC BIT9
112 /* following is for wifi link status */
113 #define WIFI_STA_CONNECTED BIT0
114 #define WIFI_AP_CONNECTED BIT1
115 #define WIFI_HS_CONNECTED BIT2
116 #define WIFI_P2P_GO_CONNECTED BIT3
117 #define WIFI_P2P_GC_CONNECTED BIT4
119 #define BTC_PRINT(dbgtype, dbgflag, printstr, ...) \
121 if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) {\
122 printk(printstr, ##__VA_ARGS__); \
126 #define BTC_RSSI_HIGH(_rssi_) \
127 ((_rssi_ == BTC_RSSI_STATE_HIGH || \
128 _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false)
129 #define BTC_RSSI_MEDIUM(_rssi_) \
130 ((_rssi_ == BTC_RSSI_STATE_MEDIUM || \
131 _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false)
132 #define BTC_RSSI_LOW(_rssi_) \
133 ((_rssi_ == BTC_RSSI_STATE_LOW || \
134 _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false)
136 enum btc_power_save_type
{
137 BTC_PS_WIFI_NATIVE
= 0,
143 struct btc_board_info
{
144 /* The following is some board information */
146 u8 pg_ant_num
; /* pg ant number */
147 u8 btdm_ant_num
; /* ant number for btdm */
152 enum btc_dbg_opcode
{
153 BTC_DBG_SET_COEX_NORMAL
= 0x0,
154 BTC_DBG_SET_COEX_WIFI_ONLY
= 0x1,
155 BTC_DBG_SET_COEX_BT_ONLY
= 0x2,
159 enum btc_rssi_state
{
160 BTC_RSSI_STATE_HIGH
= 0x0,
161 BTC_RSSI_STATE_MEDIUM
= 0x1,
162 BTC_RSSI_STATE_LOW
= 0x2,
163 BTC_RSSI_STATE_STAY_HIGH
= 0x3,
164 BTC_RSSI_STATE_STAY_MEDIUM
= 0x4,
165 BTC_RSSI_STATE_STAY_LOW
= 0x5,
170 BTC_ROLE_STATION
= 0x0,
173 BTC_ROLE_HS_MODE
= 0x3,
177 enum btc_wifi_bw_mode
{
178 BTC_WIFI_BW_LEGACY
= 0x0,
179 BTC_WIFI_BW_HT20
= 0x1,
180 BTC_WIFI_BW_HT40
= 0x2,
184 enum btc_wifi_traffic_dir
{
185 BTC_WIFI_TRAFFIC_TX
= 0x0,
186 BTC_WIFI_TRAFFIC_RX
= 0x1,
191 BTC_WIFI_PNP_WAKE_UP
= 0x0,
192 BTC_WIFI_PNP_SLEEP
= 0x1,
198 BTC_GET_BL_HS_OPERATION
,
199 BTC_GET_BL_HS_CONNECTING
,
200 BTC_GET_BL_WIFI_CONNECTED
,
201 BTC_GET_BL_WIFI_BUSY
,
202 BTC_GET_BL_WIFI_SCAN
,
203 BTC_GET_BL_WIFI_LINK
,
204 BTC_GET_BL_WIFI_DHCP
,
205 BTC_GET_BL_WIFI_SOFTAP_IDLE
,
206 BTC_GET_BL_WIFI_SOFTAP_LINKING
,
207 BTC_GET_BL_WIFI_IN_EARLY_SUSPEND
,
208 BTC_GET_BL_WIFI_ROAM
,
209 BTC_GET_BL_WIFI_4_WAY_PROGRESS
,
210 BTC_GET_BL_WIFI_UNDER_5G
,
211 BTC_GET_BL_WIFI_AP_MODE_ENABLE
,
212 BTC_GET_BL_WIFI_ENABLE_ENCRYPTION
,
213 BTC_GET_BL_WIFI_UNDER_B_MODE
,
214 BTC_GET_BL_EXT_SWITCH
,
217 BTC_GET_S4_WIFI_RSSI
,
222 BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
,
223 BTC_GET_U4_WIFI_FW_VER
,
224 BTC_GET_U4_WIFI_LINK_STATUS
,
225 BTC_GET_U4_BT_PATCH_VER
,
228 BTC_GET_U1_WIFI_DOT11_CHNL
,
229 BTC_GET_U1_WIFI_CENTRAL_CHNL
,
230 BTC_GET_U1_WIFI_HS_CHNL
,
231 BTC_GET_U1_MAC_PHY_MODE
,
236 BTC_GET_BL_BT_SCO_BUSY
,
239 BTC_GET_DRIVER_TEST_CFG
,
245 BTC_SET_BL_BT_DISABLE
,
246 BTC_SET_BL_BT_TRAFFIC_BUSY
,
247 BTC_SET_BL_BT_LIMITED_DIG
,
248 BTC_SET_BL_FORCE_TO_ROAM
,
249 BTC_SET_BL_TO_REJ_AP_AGG_PKT
,
250 BTC_SET_BL_BT_CTRL_AGG_SIZE
,
251 BTC_SET_BL_INC_SCAN_DEV_NUM
,
254 BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON
,
255 BTC_SET_UI_SCAN_SIG_COMPENSATION
,
256 BTC_SET_U1_AGG_BUF_SIZE
,
258 /* type trigger some action */
259 BTC_SET_ACT_GET_BT_RSSI
,
260 BTC_SET_ACT_AGGREGATE_CTRL
,
262 /********* for 1Ant **********/
264 BTC_SET_BL_BT_SCO_BUSY
,
266 BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE
,
270 BTC_SET_U1_1ANT_RPWM
,
271 /* type trigger some action */
272 BTC_SET_ACT_LEAVE_LPS
,
273 BTC_SET_ACT_ENTER_LPS
,
274 BTC_SET_ACT_NORMAL_LPS
,
275 BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT
,
276 BTC_SET_ACT_DISABLE_LOW_POWER
,
277 BTC_SET_ACT_UPDATE_ra_mask
,
278 BTC_SET_ACT_SEND_MIMO_PS
,
279 /* BT Coex related */
280 BTC_SET_ACT_CTRL_BT_INFO
,
281 BTC_SET_ACT_CTRL_BT_COEX
,
282 /***************************/
286 enum btc_dbg_disp_type
{
287 BTC_DBG_DISP_COEX_STATISTICS
= 0x0,
288 BTC_DBG_DISP_BT_LINK_INFO
= 0x1,
289 BTC_DBG_DISP_BT_FW_VER
= 0x2,
290 BTC_DBG_DISP_FW_PWR_MODE_CMD
= 0x3,
294 enum btc_notify_type_ips
{
300 enum btc_notify_type_lps
{
301 BTC_LPS_DISABLE
= 0x0,
302 BTC_LPS_ENABLE
= 0x1,
306 enum btc_notify_type_scan
{
307 BTC_SCAN_FINISH
= 0x0,
308 BTC_SCAN_START
= 0x1,
312 enum btc_notify_type_associate
{
313 BTC_ASSOCIATE_FINISH
= 0x0,
314 BTC_ASSOCIATE_START
= 0x1,
318 enum btc_notify_type_media_status
{
319 BTC_MEDIA_DISCONNECT
= 0x0,
320 BTC_MEDIA_CONNECT
= 0x1,
324 enum btc_notify_type_special_packet
{
325 BTC_PACKET_UNKNOWN
= 0x0,
326 BTC_PACKET_DHCP
= 0x1,
327 BTC_PACKET_ARP
= 0x2,
328 BTC_PACKET_EAPOL
= 0x3,
332 enum hci_ext_bt_operation
{
333 HCI_BT_OP_NONE
= 0x0,
334 HCI_BT_OP_INQUIRY_START
= 0x1,
335 HCI_BT_OP_INQUIRY_FINISH
= 0x2,
336 HCI_BT_OP_PAGING_START
= 0x3,
337 HCI_BT_OP_PAGING_SUCCESS
= 0x4,
338 HCI_BT_OP_PAGING_UNSUCCESS
= 0x5,
339 HCI_BT_OP_PAIRING_START
= 0x6,
340 HCI_BT_OP_PAIRING_FINISH
= 0x7,
341 HCI_BT_OP_BT_DEV_ENABLE
= 0x8,
342 HCI_BT_OP_BT_DEV_DISABLE
= 0x9,
346 enum btc_notify_type_stack_operation
{
347 BTC_STACK_OP_NONE
= 0x0,
348 BTC_STACK_OP_INQ_PAGE_PAIR_START
= 0x1,
349 BTC_STACK_OP_INQ_PAGE_PAIR_FINISH
= 0x2,
353 typedef u8 (*bfp_btc_r1
)(void *btc_context
, u32 reg_addr
);
355 typedef u16 (*bfp_btc_r2
)(void *btc_context
, u32 reg_addr
);
357 typedef u32 (*bfp_btc_r4
)(void *btc_context
, u32 reg_addr
);
359 typedef void (*bfp_btc_w1
)(void *btc_context
, u32 reg_addr
, u32 data
);
361 typedef void (*bfp_btc_w1_bit_mak
)(void *btc_context
, u32 reg_addr
,
362 u32 bit_mask
, u8 data1b
);
364 typedef void (*bfp_btc_w2
)(void *btc_context
, u32 reg_addr
, u16 data
);
366 typedef void (*bfp_btc_w4
)(void *btc_context
, u32 reg_addr
, u32 data
);
368 typedef void (*bfp_btc_wr_1byte_bit_mask
)(void *btc_context
, u32 reg_addr
,
369 u8 bit_mask
, u8 data
);
371 typedef void (*bfp_btc_set_bb_reg
)(void *btc_context
, u32 reg_addr
,
372 u32 bit_mask
, u32 data
);
374 typedef u32 (*bfp_btc_get_bb_reg
)(void *btc_context
, u32 reg_addr
,
377 typedef void (*bfp_btc_set_rf_reg
)(void *btc_context
, u8 rf_path
, u32 reg_addr
,
378 u32 bit_mask
, u32 data
);
380 typedef u32 (*bfp_btc_get_rf_reg
)(void *btc_context
, u8 rf_path
,
381 u32 reg_addr
, u32 bit_mask
);
383 typedef void (*bfp_btc_fill_h2c
)(void *btc_context
, u8 element_id
,
384 u32 cmd_len
, u8
*cmd_buffer
);
386 typedef bool (*bfp_btc_get
)(void *btcoexist
, u8 get_type
, void *out_buf
);
388 typedef bool (*bfp_btc_set
)(void *btcoexist
, u8 set_type
, void *in_buf
);
390 typedef void (*bfp_btc_disp_dbg_msg
)(void *btcoexist
, u8 disp_type
);
394 u8 rssi_adjust_for_agc_table_on
;
395 u8 rssi_adjust_for_1ant_coex_type
;
400 bool bt_ctrl_buf_size
;
401 bool increase_scan_dev_num
;
406 bool bt_disable_low_pwr
;
408 /* the following is for 1Ant solution */
410 bool bt_pwr_save_mode
;
413 u8 force_exec_pwr_cmd_cnt
;
419 struct btc_stack_info
{
420 bool profile_notified
;
421 u16 hci_version
; /* stack hci version */
430 bool unknown_acl_exist
;
434 struct btc_statistics
{
436 u32 cnt_init_hw_config
;
437 u32 cnt_init_coex_dm
;
441 u32 cnt_connect_notify
;
442 u32 cnt_media_status_notify
;
443 u32 cnt_special_packet_notify
;
444 u32 cnt_bt_info_notify
;
446 u32 cnt_coex_dm_switch
;
447 u32 cnt_stack_operation_notify
;
451 struct btc_bt_link_info
{
463 enum btc_antenna_pos
{
464 BTC_ANTENNA_AT_MAIN_PORT
= 0x1,
465 BTC_ANTENNA_AT_AUX_PORT
= 0x2,
469 /* make sure only one adapter can bind the data context */
471 /* default adapter */
473 struct btc_board_info board_info
;
474 /* some bt info referenced by non-bt module */
475 struct btc_bt_info bt_info
;
476 struct btc_stack_info stack_info
;
477 enum btc_chip_interface chip_interface
;
478 struct btc_bt_link_info bt_link_info
;
483 struct btc_statistics statistics
;
486 /* function pointers - io related */
487 bfp_btc_r1 btc_read_1byte
;
488 bfp_btc_w1 btc_write_1byte
;
489 bfp_btc_w1_bit_mak btc_write_1byte_bitmask
;
490 bfp_btc_r2 btc_read_2byte
;
491 bfp_btc_w2 btc_write_2byte
;
492 bfp_btc_r4 btc_read_4byte
;
493 bfp_btc_w4 btc_write_4byte
;
495 bfp_btc_set_bb_reg btc_set_bb_reg
;
496 bfp_btc_get_bb_reg btc_get_bb_reg
;
498 bfp_btc_set_rf_reg btc_set_rf_reg
;
499 bfp_btc_get_rf_reg btc_get_rf_reg
;
501 bfp_btc_fill_h2c btc_fill_h2c
;
503 bfp_btc_disp_dbg_msg btc_disp_dbg_msg
;
509 bool halbtc_is_wifi_uplink(struct rtl_priv
*adapter
);
511 extern struct btc_coexist gl_bt_coexist
;
513 bool exhalbtc_initlize_variables(struct rtl_priv
*adapter
);
514 void exhalbtc_init_hw_config(struct btc_coexist
*btcoexist
);
515 void exhalbtc_init_coex_dm(struct btc_coexist
*btcoexist
);
516 void exhalbtc_ips_notify(struct btc_coexist
*btcoexist
, u8 type
);
517 void exhalbtc_lps_notify(struct btc_coexist
*btcoexist
, u8 type
);
518 void exhalbtc_scan_notify(struct btc_coexist
*btcoexist
, u8 type
);
519 void exhalbtc_connect_notify(struct btc_coexist
*btcoexist
, u8 action
);
520 void exhalbtc_mediastatus_notify(struct btc_coexist
*btcoexist
,
521 enum rt_media_status media_status
);
522 void exhalbtc_special_packet_notify(struct btc_coexist
*btcoexist
, u8 pkt_type
);
523 void exhalbtc_bt_info_notify(struct btc_coexist
*btcoexist
, u8
*tmp_buf
,
525 void exhalbtc_stack_operation_notify(struct btc_coexist
*btcoexist
, u8 type
);
526 void exhalbtc_halt_notify(struct btc_coexist
*btcoexist
);
527 void exhalbtc_pnp_notify(struct btc_coexist
*btcoexist
, u8 pnp_state
);
528 void exhalbtc_coex_dm_switch(struct btc_coexist
*btcoexist
);
529 void exhalbtc_periodical(struct btc_coexist
*btcoexist
);
530 void exhalbtc_dbg_control(struct btc_coexist
*btcoexist
, u8 code
, u8 len
,
532 void exhalbtc_stack_update_profile_info(void);
533 void exhalbtc_set_hci_version(u16 hci_version
);
534 void exhalbtc_set_bt_patch_version(u16 bt_hci_version
, u16 bt_patch_version
);
535 void exhalbtc_update_min_bt_rssi(char bt_rssi
);
536 void exhalbtc_set_bt_exist(bool bt_exist
);
537 void exhalbtc_set_chip_type(u8 chip_type
);
538 void exhalbtc_set_ant_num(u8 type
, u8 ant_num
);
539 void exhalbtc_display_bt_coex_info(struct btc_coexist
*btcoexist
);
540 void exhalbtc_signal_compensation(struct btc_coexist
*btcoexist
,
541 u8
*rssi_wifi
, u8
*rssi_bt
);
542 void exhalbtc_lps_leave(struct btc_coexist
*btcoexist
);
543 void exhalbtc_low_wifi_traffic_notify(struct btc_coexist
*btcoexist
);