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 #define BTC_ANT_PATH_WIFI 0
59 #define BTC_ANT_PATH_BT 1
60 #define BTC_ANT_PATH_PTA 2
62 enum btc_chip_interface
{
75 BTC_CHIP_RTL8723A
= 3,
77 BTC_CHIP_RTL8723B
= 5,
82 BTC_MSG_INTERFACE
= 0x0,
83 BTC_MSG_ALGORITHM
= 0x1,
86 extern u32 btc_dbg_type
[];
88 /* following is for BTC_MSG_INTERFACE */
89 #define INTF_INIT BIT0
90 #define INTF_NOTIFY BIT2
92 /* following is for BTC_ALGORITHM */
93 #define ALGO_BT_RSSI_STATE BIT0
94 #define ALGO_WIFI_RSSI_STATE BIT1
95 #define ALGO_BT_MONITOR BIT2
96 #define ALGO_TRACE BIT3
97 #define ALGO_TRACE_FW BIT4
98 #define ALGO_TRACE_FW_DETAIL BIT5
99 #define ALGO_TRACE_FW_EXEC BIT6
100 #define ALGO_TRACE_SW BIT7
101 #define ALGO_TRACE_SW_DETAIL BIT8
102 #define ALGO_TRACE_SW_EXEC BIT9
104 #define BT_COEX_ANT_TYPE_PG 0
105 #define BT_COEX_ANT_TYPE_ANTDIV 1
106 #define BT_COEX_ANT_TYPE_DETECTED 2
107 #define BTC_MIMO_PS_STATIC 0
108 #define BTC_MIMO_PS_DYNAMIC 1
109 #define BTC_RATE_DISABLE 0
110 #define BTC_RATE_ENABLE 1
111 #define BTC_ANT_PATH_WIFI 0
112 #define BTC_ANT_PATH_BT 1
113 #define BTC_ANT_PATH_PTA 2
116 #define CL_SPRINTF snprintf
117 #define CL_PRINTF printk
119 #define BTC_PRINT(dbgtype, dbgflag, printstr, ...) \
121 if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) {\
122 printk(printstr, ##__VA_ARGS__); \
126 #define BTC_PRINT_F(dbgtype, dbgflag, printstr, ...) \
128 if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) {\
129 pr_info("%s: ", __func__); \
130 printk(printstr, ##__VA_ARGS__); \
134 #define BTC_PRINT_ADDR(dbgtype, dbgflag, printstr, _ptr) \
136 if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) { \
138 u8 *__ptr = (u8 *)_ptr; \
140 for (__i = 0; __i < 6; __i++) \
141 printk("%02X%s", __ptr[__i], (__i == 5) ? \
147 #define BTC_PRINT_DATA(dbgtype, dbgflag, _titlestring, _hexdata, _hexdatalen) \
149 if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) { \
151 u8 *__ptr = (u8 *)_hexdata; \
152 printk(_titlestring); \
153 for (__i = 0; __i < (int)_hexdatalen; __i++) { \
154 printk("%02X%s", __ptr[__i], (((__i + 1) % 4) \
156 if (((__i + 1) % 16) == 0) \
163 #define BTC_ANT_PATH_WIFI 0
164 #define BTC_ANT_PATH_BT 1
165 #define BTC_ANT_PATH_PTA 2
167 enum btc_power_save_type
{
168 BTC_PS_WIFI_NATIVE
= 0,
174 struct btc_board_info
{
175 /* The following is some board information */
177 u8 pg_ant_num
; /* pg ant number */
178 u8 btdm_ant_num
; /* ant number for btdm */
183 enum btc_dbg_opcode
{
184 BTC_DBG_SET_COEX_NORMAL
= 0x0,
185 BTC_DBG_SET_COEX_WIFI_ONLY
= 0x1,
186 BTC_DBG_SET_COEX_BT_ONLY
= 0x2,
190 enum btc_rssi_state
{
191 BTC_RSSI_STATE_HIGH
= 0x0,
192 BTC_RSSI_STATE_MEDIUM
= 0x1,
193 BTC_RSSI_STATE_LOW
= 0x2,
194 BTC_RSSI_STATE_STAY_HIGH
= 0x3,
195 BTC_RSSI_STATE_STAY_MEDIUM
= 0x4,
196 BTC_RSSI_STATE_STAY_LOW
= 0x5,
201 BTC_ROLE_STATION
= 0x0,
204 BTC_ROLE_HS_MODE
= 0x3,
208 enum btc_wifi_bw_mode
{
209 BTC_WIFI_BW_LEGACY
= 0x0,
210 BTC_WIFI_BW_HT20
= 0x1,
211 BTC_WIFI_BW_HT40
= 0x2,
215 enum btc_wifi_traffic_dir
{
216 BTC_WIFI_TRAFFIC_TX
= 0x0,
217 BTC_WIFI_TRAFFIC_RX
= 0x1,
222 BTC_WIFI_PNP_WAKE_UP
= 0x0,
223 BTC_WIFI_PNP_SLEEP
= 0x1,
230 BTC_GET_BL_HS_OPERATION
,
231 BTC_GET_BL_HS_CONNECTING
,
232 BTC_GET_BL_WIFI_CONNECTED
,
233 BTC_GET_BL_WIFI_BUSY
,
234 BTC_GET_BL_WIFI_SCAN
,
235 BTC_GET_BL_WIFI_LINK
,
236 BTC_GET_BL_WIFI_DHCP
,
237 BTC_GET_BL_WIFI_SOFTAP_IDLE
,
238 BTC_GET_BL_WIFI_SOFTAP_LINKING
,
239 BTC_GET_BL_WIFI_IN_EARLY_SUSPEND
,
240 BTC_GET_BL_WIFI_ROAM
,
241 BTC_GET_BL_WIFI_4_WAY_PROGRESS
,
242 BTC_GET_BL_WIFI_UNDER_5G
,
243 BTC_GET_BL_WIFI_AP_MODE_ENABLE
,
244 BTC_GET_BL_WIFI_ENABLE_ENCRYPTION
,
245 BTC_GET_BL_WIFI_UNDER_B_MODE
,
246 BTC_GET_BL_EXT_SWITCH
,
249 BTC_GET_S4_WIFI_RSSI
,
254 BTC_GET_U4_WIFI_TRAFFIC_DIRECTION
,
255 BTC_GET_U4_WIFI_FW_VER
,
256 BTC_GET_U4_BT_PATCH_VER
,
259 BTC_GET_U1_WIFI_DOT11_CHNL
,
260 BTC_GET_U1_WIFI_CENTRAL_CHNL
,
261 BTC_GET_U1_WIFI_HS_CHNL
,
262 BTC_GET_U1_MAC_PHY_MODE
,
266 BTC_GET_BL_BT_SCO_BUSY
,
269 BTC_GET_DRIVER_TEST_CFG
,
276 BTC_SET_BL_BT_DISABLE
,
277 BTC_SET_BL_BT_TRAFFIC_BUSY
,
278 BTC_SET_BL_BT_LIMITED_DIG
,
279 BTC_SET_BL_FORCE_TO_ROAM
,
280 BTC_SET_BL_TO_REJ_AP_AGG_PKT
,
281 BTC_SET_BL_BT_CTRL_AGG_SIZE
,
282 BTC_SET_BL_INC_SCAN_DEV_NUM
,
285 BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON
,
286 BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE
,
287 BTC_SET_UI_SCAN_SIG_COMPENSATION
,
288 BTC_SET_U1_AGG_BUF_SIZE
,
290 /* type trigger some action */
291 BTC_SET_ACT_GET_BT_RSSI
,
292 BTC_SET_ACT_AGGREGATE_CTRL
,
294 /********* for 1Ant **********/
296 BTC_SET_BL_BT_SCO_BUSY
,
299 BTC_SET_U1_1ANT_RPWM
,
300 /* type trigger some action */
301 BTC_SET_ACT_LEAVE_LPS
,
302 BTC_SET_ACT_ENTER_LPS
,
303 BTC_SET_ACT_NORMAL_LPS
,
304 BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT
,
305 BTC_SET_ACT_DISABLE_LOW_POWER
,
306 BTC_SET_ACT_UPDATE_ra_mask
,
307 BTC_SET_ACT_SEND_MIMO_PS
,
308 /* BT Coex related */
309 BTC_SET_ACT_CTRL_BT_INFO
,
310 BTC_SET_ACT_CTRL_BT_COEX
,
311 /***************************/
315 enum btc_dbg_disp_type
{
316 BTC_DBG_DISP_COEX_STATISTICS
= 0x0,
317 BTC_DBG_DISP_BT_LINK_INFO
= 0x1,
318 BTC_DBG_DISP_BT_FW_VER
= 0x2,
319 BTC_DBG_DISP_FW_PWR_MODE_CMD
= 0x3,
323 enum btc_notify_type_ips
{
329 enum btc_notify_type_lps
{
330 BTC_LPS_DISABLE
= 0x0,
331 BTC_LPS_ENABLE
= 0x1,
335 enum btc_notify_type_scan
{
336 BTC_SCAN_FINISH
= 0x0,
337 BTC_SCAN_START
= 0x1,
341 enum btc_notify_type_associate
{
342 BTC_ASSOCIATE_FINISH
= 0x0,
343 BTC_ASSOCIATE_START
= 0x1,
347 enum btc_notify_type_media_status
{
348 BTC_MEDIA_DISCONNECT
= 0x0,
349 BTC_MEDIA_CONNECT
= 0x1,
353 enum btc_notify_type_special_packet
{
354 BTC_PACKET_UNKNOWN
= 0x0,
355 BTC_PACKET_DHCP
= 0x1,
356 BTC_PACKET_ARP
= 0x2,
357 BTC_PACKET_EAPOL
= 0x3,
361 enum btc_notify_type_stack_operation
{
362 BTC_STACK_OP_NONE
= 0x0,
363 BTC_STACK_OP_INQ_PAGE_PAIR_START
= 0x1,
364 BTC_STACK_OP_INQ_PAGE_PAIR_FINISH
= 0x2,
369 typedef u8 (*bfp_btc_r1
)(void *btc_context
, u32 reg_addr
);
371 typedef u16 (*bfp_btc_r2
)(void *btc_context
, u32 reg_addr
);
373 typedef u32 (*bfp_btc_r4
)(void *btc_context
, u32 reg_addr
);
375 typedef void (*bfp_btc_w1
)(void *btc_context
, u32 reg_addr
, u8 data
);
377 typedef void (*bfp_btc_w1_bit_mak
)(void *btc_context
, u32 reg_addr
,
378 u32 bit_mask
, u8 data1b
);
380 typedef void (*bfp_btc_w2
)(void *btc_context
, u32 reg_addr
, u16 data
);
382 typedef void (*bfp_btc_w4
)(void *btc_context
, u32 reg_addr
, u32 data
);
384 typedef void (*bfp_btc_wr_1byte_bit_mask
)(void *btc_context
, u32 reg_addr
,
385 u8 bit_mask
, u8 data
);
387 typedef void (*bfp_btc_set_bb_reg
)(void *btc_context
, u32 reg_addr
,
388 u32 bit_mask
, u32 data
);
390 typedef u32 (*bfp_btc_get_bb_reg
)(void *btc_context
, u32 reg_addr
,
393 typedef void (*bfp_btc_set_rf_reg
)(void *btc_context
, u8 rf_path
, u32 reg_addr
,
394 u32 bit_mask
, u32 data
);
396 typedef u32 (*bfp_btc_get_rf_reg
)(void *btc_context
, u8 rf_path
,
397 u32 reg_addr
, u32 bit_mask
);
399 typedef void (*bfp_btc_fill_h2c
)(void *btc_context
, u8 element_id
,
400 u32 cmd_len
, u8
*cmd_buffer
);
402 typedef bool (*bfp_btc_get
)(void *btcoexist
, u8 get_type
, void *out_buf
);
404 typedef bool (*bfp_btc_set
)(void *btcoexist
, u8 set_type
, void *in_buf
);
406 typedef void (*bfp_btc_disp_dbg_msg
)(void *btcoexist
, u8 disp_type
);
410 u8 rssi_adjust_for_agc_table_on
;
411 u8 rssi_adjust_for_1ant_coex_type
;
416 bool b_bt_ctrl_buf_size
;
417 bool increase_scan_dev_num
;
422 /* the following is for 1Ant solution */
424 bool bt_pwr_save_mode
;
427 u8 force_exec_pwr_cmd_cnt
;
433 struct btc_stack_info
{
434 bool profile_notified
;
435 u16 hci_version
; /* stack hci version */
444 bool unknown_acl_exist
;
448 struct btc_statistics
{
450 u32 cnt_init_hw_config
;
451 u32 cnt_init_coex_dm
;
455 u32 cnt_connect_notify
;
456 u32 cnt_media_status_notify
;
457 u32 cnt_special_packet_notify
;
458 u32 cnt_bt_info_notify
;
460 u32 cnt_stack_operation_notify
;
464 struct btc_bt_link_info
{
476 enum btc_antenna_pos
{
477 BTC_ANTENNA_AT_MAIN_PORT
= 0x1,
478 BTC_ANTENNA_AT_AUX_PORT
= 0x2,
482 /* make sure only one adapter can bind the data context */
484 /* default adapter */
486 struct btc_board_info board_info
;
487 /* some bt info referenced by non-bt module */
488 struct btc_bt_info bt_info
;
489 struct btc_stack_info stack_info
;
490 enum btc_chip_interface chip_interface
;
491 struct btc_bt_link_info bt_link_info
;
497 struct btc_statistics statistics
;
500 /* function pointers - io related */
501 bfp_btc_r1 btc_read_1byte
;
502 bfp_btc_w1 btc_write_1byte
;
503 bfp_btc_w1_bit_mak btc_write_1byte_bitmask
;
504 bfp_btc_r2 btc_read_2byte
;
505 bfp_btc_w2 btc_write_2byte
;
506 bfp_btc_r4 btc_read_4byte
;
507 bfp_btc_w4 btc_write_4byte
;
509 bfp_btc_set_bb_reg btc_set_bb_reg
;
510 bfp_btc_get_bb_reg btc_get_bb_reg
;
513 bfp_btc_set_rf_reg btc_set_rf_reg
;
514 bfp_btc_get_rf_reg btc_get_rf_reg
;
516 bfp_btc_fill_h2c btc_fill_h2c
;
518 bfp_btc_disp_dbg_msg btc_disp_dbg_msg
;
524 bool halbtc_is_wifi_uplink(struct rtl_priv
*adapter
);
526 extern struct btc_coexist gl_bt_coexist
;
528 bool exhalbtc_initlize_variables(struct rtl_priv
*adapter
);
529 void exhalbtc_init_hw_config(struct btc_coexist
*btcoexist
);
530 void exhalbtc_init_coex_dm(struct btc_coexist
*btcoexist
);
531 void exhalbtc_ips_notify(struct btc_coexist
*btcoexist
, u8 type
);
532 void exhalbtc_lps_notify(struct btc_coexist
*btcoexist
, u8 type
);
533 void exhalbtc_scan_notify(struct btc_coexist
*btcoexist
, u8 type
);
534 void exhalbtc_connect_notify(struct btc_coexist
*btcoexist
, u8 action
);
535 void exhalbtc_mediastatus_notify(struct btc_coexist
*btcoexist
,
536 enum _RT_MEDIA_STATUS media_status
);
537 void exhalbtc_special_packet_notify(struct btc_coexist
*btcoexist
, u8 pkt_type
);
538 void exhalbtc_bt_info_notify(struct btc_coexist
*btcoexist
, u8
*tmp_buf
,
540 void exhalbtc_stack_operation_notify(struct btc_coexist
*btcoexist
, u8 type
);
541 void exhalbtc_halt_notify(struct btc_coexist
*btcoexist
);
542 void exhalbtc_pnp_notify(struct btc_coexist
*btcoexist
, u8 pnp_state
);
543 void exhalbtc_periodical(struct btc_coexist
*btcoexist
);
544 void exhalbtc_dbg_control(struct btc_coexist
*btcoexist
, u8 code
, u8 len
,
546 void exhalbtc_stack_update_profile_info(void);
547 void exhalbtc_set_hci_version(u16 hci_version
);
548 void exhalbtc_set_bt_patch_version(u16 bt_hci_version
, u16 bt_patch_version
);
549 void exhalbtc_update_min_bt_rssi(char bt_rssi
);
550 void exhalbtc_set_bt_exist(bool bt_exist
);
551 void exhalbtc_set_chip_type(u8 chip_type
);
552 void exhalbtc_set_ant_num(u8 type
, u8 ant_num
);
553 void exhalbtc_display_bt_coex_info(struct btc_coexist
*btcoexist
);
554 void exhalbtc_signal_compensation(struct btc_coexist
*btcoexist
,
555 u8
*rssi_wifi
, u8
*rssi_bt
);
556 void exhalbtc_lps_leave(struct btc_coexist
*btcoexist
);
557 void exhalbtc_low_wifi_traffic_notify(struct btc_coexist
*btcoexist
);