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_alg_dbg(dbgflag, fmt, ...) \
121 if (unlikely(btc_dbg_type[BTC_MSG_ALGORITHM] & dbgflag)) \
122 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
124 #define btc_iface_dbg(dbgflag, fmt, ...) \
126 if (unlikely(btc_dbg_type[BTC_MSG_INTERFACE] & dbgflag)) \
127 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
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)
141 enum btc_power_save_type {
142 BTC_PS_WIFI_NATIVE = 0,
148 struct btc_board_info {
149 /* The following is some board information */
151 u8 pg_ant_num; /* pg ant number */
152 u8 btdm_ant_num; /* ant number for btdm */
157 enum btc_dbg_opcode {
158 BTC_DBG_SET_COEX_NORMAL = 0x0,
159 BTC_DBG_SET_COEX_WIFI_ONLY = 0x1,
160 BTC_DBG_SET_COEX_BT_ONLY = 0x2,
164 enum btc_rssi_state {
165 BTC_RSSI_STATE_HIGH = 0x0,
166 BTC_RSSI_STATE_MEDIUM = 0x1,
167 BTC_RSSI_STATE_LOW = 0x2,
168 BTC_RSSI_STATE_STAY_HIGH = 0x3,
169 BTC_RSSI_STATE_STAY_MEDIUM = 0x4,
170 BTC_RSSI_STATE_STAY_LOW = 0x5,
175 BTC_ROLE_STATION = 0x0,
178 BTC_ROLE_HS_MODE = 0x3,
182 enum btc_wifi_bw_mode {
183 BTC_WIFI_BW_LEGACY = 0x0,
184 BTC_WIFI_BW_HT20 = 0x1,
185 BTC_WIFI_BW_HT40 = 0x2,
189 enum btc_wifi_traffic_dir {
190 BTC_WIFI_TRAFFIC_TX = 0x0,
191 BTC_WIFI_TRAFFIC_RX = 0x1,
196 BTC_WIFI_PNP_WAKE_UP = 0x0,
197 BTC_WIFI_PNP_SLEEP = 0x1,
203 BTC_GET_BL_HS_OPERATION,
204 BTC_GET_BL_HS_CONNECTING,
205 BTC_GET_BL_WIFI_CONNECTED,
206 BTC_GET_BL_WIFI_BUSY,
207 BTC_GET_BL_WIFI_SCAN,
208 BTC_GET_BL_WIFI_LINK,
209 BTC_GET_BL_WIFI_DHCP,
210 BTC_GET_BL_WIFI_SOFTAP_IDLE,
211 BTC_GET_BL_WIFI_SOFTAP_LINKING,
212 BTC_GET_BL_WIFI_IN_EARLY_SUSPEND,
213 BTC_GET_BL_WIFI_ROAM,
214 BTC_GET_BL_WIFI_4_WAY_PROGRESS,
215 BTC_GET_BL_WIFI_UNDER_5G,
216 BTC_GET_BL_WIFI_AP_MODE_ENABLE,
217 BTC_GET_BL_WIFI_ENABLE_ENCRYPTION,
218 BTC_GET_BL_WIFI_UNDER_B_MODE,
219 BTC_GET_BL_EXT_SWITCH,
222 BTC_GET_S4_WIFI_RSSI,
227 BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
228 BTC_GET_U4_WIFI_FW_VER,
229 BTC_GET_U4_WIFI_LINK_STATUS,
230 BTC_GET_U4_BT_PATCH_VER,
233 BTC_GET_U1_WIFI_DOT11_CHNL,
234 BTC_GET_U1_WIFI_CENTRAL_CHNL,
235 BTC_GET_U1_WIFI_HS_CHNL,
236 BTC_GET_U1_MAC_PHY_MODE,
241 BTC_GET_BL_BT_SCO_BUSY,
244 BTC_GET_DRIVER_TEST_CFG,
250 BTC_SET_BL_BT_DISABLE,
251 BTC_SET_BL_BT_TRAFFIC_BUSY,
252 BTC_SET_BL_BT_LIMITED_DIG,
253 BTC_SET_BL_FORCE_TO_ROAM,
254 BTC_SET_BL_TO_REJ_AP_AGG_PKT,
255 BTC_SET_BL_BT_CTRL_AGG_SIZE,
256 BTC_SET_BL_INC_SCAN_DEV_NUM,
259 BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
260 BTC_SET_UI_SCAN_SIG_COMPENSATION,
261 BTC_SET_U1_AGG_BUF_SIZE,
263 /* type trigger some action */
264 BTC_SET_ACT_GET_BT_RSSI,
265 BTC_SET_ACT_AGGREGATE_CTRL,
267 /********* for 1Ant **********/
269 BTC_SET_BL_BT_SCO_BUSY,
271 BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE,
275 BTC_SET_U1_1ANT_RPWM,
276 /* type trigger some action */
277 BTC_SET_ACT_LEAVE_LPS,
278 BTC_SET_ACT_ENTER_LPS,
279 BTC_SET_ACT_NORMAL_LPS,
280 BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT,
281 BTC_SET_ACT_DISABLE_LOW_POWER,
282 BTC_SET_ACT_UPDATE_ra_mask,
283 BTC_SET_ACT_SEND_MIMO_PS,
284 /* BT Coex related */
285 BTC_SET_ACT_CTRL_BT_INFO,
286 BTC_SET_ACT_CTRL_BT_COEX,
287 /***************************/
291 enum btc_dbg_disp_type {
292 BTC_DBG_DISP_COEX_STATISTICS = 0x0,
293 BTC_DBG_DISP_BT_LINK_INFO = 0x1,
294 BTC_DBG_DISP_BT_FW_VER = 0x2,
295 BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x3,
299 enum btc_notify_type_ips {
305 enum btc_notify_type_lps {
306 BTC_LPS_DISABLE = 0x0,
307 BTC_LPS_ENABLE = 0x1,
311 enum btc_notify_type_scan {
312 BTC_SCAN_FINISH = 0x0,
313 BTC_SCAN_START = 0x1,
317 enum btc_notify_type_associate {
318 BTC_ASSOCIATE_FINISH = 0x0,
319 BTC_ASSOCIATE_START = 0x1,
323 enum btc_notify_type_media_status {
324 BTC_MEDIA_DISCONNECT = 0x0,
325 BTC_MEDIA_CONNECT = 0x1,
329 enum btc_notify_type_special_packet {
330 BTC_PACKET_UNKNOWN = 0x0,
331 BTC_PACKET_DHCP = 0x1,
332 BTC_PACKET_ARP = 0x2,
333 BTC_PACKET_EAPOL = 0x3,
337 enum hci_ext_bt_operation {
338 HCI_BT_OP_NONE = 0x0,
339 HCI_BT_OP_INQUIRY_START = 0x1,
340 HCI_BT_OP_INQUIRY_FINISH = 0x2,
341 HCI_BT_OP_PAGING_START = 0x3,
342 HCI_BT_OP_PAGING_SUCCESS = 0x4,
343 HCI_BT_OP_PAGING_UNSUCCESS = 0x5,
344 HCI_BT_OP_PAIRING_START = 0x6,
345 HCI_BT_OP_PAIRING_FINISH = 0x7,
346 HCI_BT_OP_BT_DEV_ENABLE = 0x8,
347 HCI_BT_OP_BT_DEV_DISABLE = 0x9,
351 enum btc_notify_type_stack_operation {
352 BTC_STACK_OP_NONE = 0x0,
353 BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1,
354 BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2,
358 typedef u8 (*bfp_btc_r1)(void *btc_context, u32 reg_addr);
360 typedef u16 (*bfp_btc_r2)(void *btc_context, u32 reg_addr);
362 typedef u32 (*bfp_btc_r4)(void *btc_context, u32 reg_addr);
364 typedef void (*bfp_btc_w1)(void *btc_context, u32 reg_addr, u32 data);
366 typedef void (*bfp_btc_w1_bit_mak)(void *btc_context, u32 reg_addr,
367 u32 bit_mask, u8 data1b);
369 typedef void (*bfp_btc_w2)(void *btc_context, u32 reg_addr, u16 data);
371 typedef void (*bfp_btc_w4)(void *btc_context, u32 reg_addr, u32 data);
373 typedef void (*bfp_btc_wr_1byte_bit_mask)(void *btc_context, u32 reg_addr,
374 u8 bit_mask, u8 data);
376 typedef void (*bfp_btc_set_bb_reg)(void *btc_context, u32 reg_addr,
377 u32 bit_mask, u32 data);
379 typedef u32 (*bfp_btc_get_bb_reg)(void *btc_context, u32 reg_addr,
382 typedef void (*bfp_btc_set_rf_reg)(void *btc_context, u8 rf_path, u32 reg_addr,
383 u32 bit_mask, u32 data);
385 typedef u32 (*bfp_btc_get_rf_reg)(void *btc_context, u8 rf_path,
386 u32 reg_addr, u32 bit_mask);
388 typedef void (*bfp_btc_fill_h2c)(void *btc_context, u8 element_id,
389 u32 cmd_len, u8 *cmd_buffer);
391 typedef bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf);
393 typedef bool (*bfp_btc_set)(void *btcoexist, u8 set_type, void *in_buf);
395 typedef void (*bfp_btc_disp_dbg_msg)(void *btcoexist, u8 disp_type);
399 u8 rssi_adjust_for_agc_table_on;
400 u8 rssi_adjust_for_1ant_coex_type;
405 bool bt_ctrl_buf_size;
406 bool increase_scan_dev_num;
411 bool bt_disable_low_pwr;
413 /* the following is for 1Ant solution */
415 bool bt_pwr_save_mode;
418 u8 force_exec_pwr_cmd_cnt;
424 struct btc_stack_info {
425 bool profile_notified;
426 u16 hci_version; /* stack hci version */
435 bool unknown_acl_exist;
439 struct btc_statistics {
441 u32 cnt_init_hw_config;
442 u32 cnt_init_coex_dm;
446 u32 cnt_connect_notify;
447 u32 cnt_media_status_notify;
448 u32 cnt_special_packet_notify;
449 u32 cnt_bt_info_notify;
451 u32 cnt_coex_dm_switch;
452 u32 cnt_stack_operation_notify;
456 struct btc_bt_link_info {
468 enum btc_antenna_pos {
469 BTC_ANTENNA_AT_MAIN_PORT = 0x1,
470 BTC_ANTENNA_AT_AUX_PORT = 0x2,
474 /* make sure only one adapter can bind the data context */
476 /* default adapter */
478 struct btc_board_info board_info;
479 /* some bt info referenced by non-bt module */
480 struct btc_bt_info bt_info;
481 struct btc_stack_info stack_info;
482 enum btc_chip_interface chip_interface;
483 struct btc_bt_link_info bt_link_info;
488 struct btc_statistics statistics;
491 /* function pointers - io related */
492 bfp_btc_r1 btc_read_1byte;
493 bfp_btc_w1 btc_write_1byte;
494 bfp_btc_w1_bit_mak btc_write_1byte_bitmask;
495 bfp_btc_r2 btc_read_2byte;
496 bfp_btc_w2 btc_write_2byte;
497 bfp_btc_r4 btc_read_4byte;
498 bfp_btc_w4 btc_write_4byte;
500 bfp_btc_set_bb_reg btc_set_bb_reg;
501 bfp_btc_get_bb_reg btc_get_bb_reg;
503 bfp_btc_set_rf_reg btc_set_rf_reg;
504 bfp_btc_get_rf_reg btc_get_rf_reg;
506 bfp_btc_fill_h2c btc_fill_h2c;
508 bfp_btc_disp_dbg_msg btc_disp_dbg_msg;
514 bool halbtc_is_wifi_uplink(struct rtl_priv *adapter);
516 extern struct btc_coexist gl_bt_coexist;
518 bool exhalbtc_initlize_variables(struct rtl_priv *adapter);
519 void exhalbtc_init_hw_config(struct btc_coexist *btcoexist);
520 void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist);
521 void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type);
522 void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type);
523 void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type);
524 void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action);
525 void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
526 enum rt_media_status media_status);
527 void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type);
528 void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist, u8 *tmp_buf,
530 void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type);
531 void exhalbtc_halt_notify(struct btc_coexist *btcoexist);
532 void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
533 void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist);
534 void exhalbtc_periodical(struct btc_coexist *btcoexist);
535 void exhalbtc_dbg_control(struct btc_coexist *btcoexist, u8 code, u8 len,
537 void exhalbtc_stack_update_profile_info(void);
538 void exhalbtc_set_hci_version(u16 hci_version);
539 void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
540 void exhalbtc_update_min_bt_rssi(s8 bt_rssi);
541 void exhalbtc_set_bt_exist(bool bt_exist);
542 void exhalbtc_set_chip_type(u8 chip_type);
543 void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num);
544 void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
545 void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
546 u8 *rssi_wifi, u8 *rssi_bt);
547 void exhalbtc_lps_leave(struct btc_coexist *btcoexist);
548 void exhalbtc_low_wifi_traffic_notify(struct btc_coexist *btcoexist);