1/******************************************************************************
2 *
3 * Copyright(c) 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 _HAL8723B_2_ANT
26#define _HAL8723B_2_ANT
27
28/************************************************************************
29 * The following is for 8723B 2Ant BT Co-exist definition
30 ************************************************************************/
31#define	BT_AUTO_REPORT_ONLY_8723B_2ANT			1
32
33#define	BT_INFO_8723B_2ANT_B_FTP			BIT7
34#define	BT_INFO_8723B_2ANT_B_A2DP			BIT6
35#define	BT_INFO_8723B_2ANT_B_HID			BIT5
36#define	BT_INFO_8723B_2ANT_B_SCO_BUSY			BIT4
37#define	BT_INFO_8723B_2ANT_B_ACL_BUSY			BIT3
38#define	BT_INFO_8723B_2ANT_B_INQ_PAGE			BIT2
39#define	BT_INFO_8723B_2ANT_B_SCO_ESCO			BIT1
40#define	BT_INFO_8723B_2ANT_B_CONNECTION			BIT0
41
42#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT		2
43
44enum BT_INFO_SRC_8723B_2ANT {
45	BT_INFO_SRC_8723B_2ANT_WIFI_FW			= 0x0,
46	BT_INFO_SRC_8723B_2ANT_BT_RSP			= 0x1,
47	BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND		= 0x2,
48	BT_INFO_SRC_8723B_2ANT_MAX
49};
50
51enum BT_8723B_2ANT_BT_STATUS {
52	BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE	= 0x0,
53	BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE		= 0x1,
54	BT_8723B_2ANT_BT_STATUS_INQ_PAGE		= 0x2,
55	BT_8723B_2ANT_BT_STATUS_ACL_BUSY		= 0x3,
56	BT_8723B_2ANT_BT_STATUS_SCO_BUSY		= 0x4,
57	BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY		= 0x5,
58	BT_8723B_2ANT_BT_STATUS_MAX
59};
60
61enum BT_8723B_2ANT_COEX_ALGO {
62	BT_8723B_2ANT_COEX_ALGO_UNDEFINED		= 0x0,
63	BT_8723B_2ANT_COEX_ALGO_SCO			= 0x1,
64	BT_8723B_2ANT_COEX_ALGO_HID			= 0x2,
65	BT_8723B_2ANT_COEX_ALGO_A2DP			= 0x3,
66	BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS		= 0x4,
67	BT_8723B_2ANT_COEX_ALGO_PANEDR			= 0x5,
68	BT_8723B_2ANT_COEX_ALGO_PANHS			= 0x6,
69	BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP		= 0x7,
70	BT_8723B_2ANT_COEX_ALGO_PANEDR_HID		= 0x8,
71	BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR		= 0x9,
72	BT_8723B_2ANT_COEX_ALGO_HID_A2DP		= 0xa,
73	BT_8723B_2ANT_COEX_ALGO_MAX			= 0xb,
74};
75
76struct coex_dm_8723b_2ant {
77	/* fw mechanism */
78	bool pre_dec_bt_pwr;
79	bool cur_dec_bt_pwr;
80	u8 pre_fw_dac_swing_lvl;
81	u8 cur_fw_dac_swing_lvl;
82	bool cur_ignore_wlan_act;
83	bool pre_ignore_wlan_act;
84	u8 pre_ps_tdma;
85	u8 cur_ps_tdma;
86	u8 ps_tdma_para[5];
87	u8 tdma_adj_type;
88	bool reset_tdma_adjust;
89	bool auto_tdma_adjust;
90	bool pre_ps_tdma_on;
91	bool cur_ps_tdma_on;
92	bool pre_bt_auto_report;
93	bool cur_bt_auto_report;
94
95	/* sw mechanism */
96	bool pre_rf_rx_lpf_shrink;
97	bool cur_rf_rx_lpf_shrink;
98	u32 bt_rf0x1e_backup;
99	bool pre_low_penalty_ra;
100	bool cur_low_penalty_ra;
101	bool pre_dac_swing_on;
102	u32 pre_dac_swing_lvl;
103	bool cur_dac_swing_on;
104	u32 cur_dac_swing_lvl;
105	bool pre_adc_back_off;
106	bool cur_adc_back_off;
107	bool pre_agc_table_en;
108	bool cur_agc_table_en;
109	u32 pre_val0x6c0;
110	u32 cur_val0x6c0;
111	u32 pre_val0x6c4;
112	u32 cur_val0x6c4;
113	u32 pre_val0x6c8;
114	u32 cur_val0x6c8;
115	u8 pre_val0x6cc;
116	u8 cur_val0x6cc;
117	bool limited_dig;
118
119	/* algorithm related */
120	u8 pre_algorithm;
121	u8 cur_algorithm;
122	u8 bt_status;
123	u8 wifi_chnl_info[3];
124
125	bool need_recover_0x948;
126	u16 backup_0x948;
127};
128
129struct coex_sta_8723b_2ant {
130	bool bt_link_exist;
131	bool sco_exist;
132	bool a2dp_exist;
133	bool hid_exist;
134	bool pan_exist;
135
136	bool under_lps;
137	bool under_ips;
138	u32 high_priority_tx;
139	u32 high_priority_rx;
140	u32 low_priority_tx;
141	u32 low_priority_rx;
142	u8 bt_rssi;
143	u8 pre_bt_rssi_state;
144	u8 pre_wifi_rssi_state[4];
145	bool c2h_bt_info_req_sent;
146	u8 bt_info_c2h[BT_INFO_SRC_8723B_2ANT_MAX][10];
147	u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_2ANT_MAX];
148	bool c2h_bt_inquiry_page;
149	u8 bt_retry_cnt;
150	u8 bt_info_ext;
151};
152
153/*********************************************************************
154 * The following is interface which will notify coex module.
155 *********************************************************************/
156void ex_btc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist);
157void ex_btc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist);
158void ex_btc8723b2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
159void ex_btc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
160void ex_btc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
161void ex_btc8723b2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
162void ex_btc8723b2ant_media_status_notify(struct btc_coexist *btcoexist,
163					 u8 type);
164void ex_btc8723b2ant_special_packet_notify(struct btc_coexist *btcoexist,
165					   u8 type);
166void ex_btc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist,
167				    u8 *tmpbuf, u8 length);
168void ex_btc8723b2ant_halt_notify(struct btc_coexist *btcoexist);
169void ex_btc8723b2ant_periodical(struct btc_coexist *btcoexist);
170void ex_btc8723b2ant_display_coex_info(struct btc_coexist *btcoexist);
171
172#endif
173