• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 #ifndef	__HALBTC_OUT_SRC_H__
8 #define __HALBTC_OUT_SRC_H__
9 
10 #define NORMAL_EXEC		false
11 #define FORCE_EXEC		true
12 
13 #define BTC_RF_OFF		0x0
14 #define BTC_RF_ON		0x1
15 
16 #define BTC_RF_A		0x0
17 #define BTC_RF_B		0x1
18 #define BTC_RF_C		0x2
19 #define BTC_RF_D		0x3
20 
21 #define BTC_SMSP		SINGLEMAC_SINGLEPHY
22 #define BTC_DMDP		DUALMAC_DUALPHY
23 #define BTC_DMSP		DUALMAC_SINGLEPHY
24 #define BTC_MP_UNKNOWN		0xff
25 
26 #define BT_COEX_ANT_TYPE_PG	0
27 #define BT_COEX_ANT_TYPE_ANTDIV		1
28 #define BT_COEX_ANT_TYPE_DETECTED	2
29 
30 #define BTC_MIMO_PS_STATIC	0	/*  1ss */
31 #define BTC_MIMO_PS_DYNAMIC	1	/*  2ss */
32 
33 #define BTC_RATE_DISABLE	0
34 #define BTC_RATE_ENABLE		1
35 
36 /*  single Antenna definition */
37 #define BTC_ANT_PATH_WIFI	0
38 #define BTC_ANT_PATH_BT		1
39 #define BTC_ANT_PATH_PTA	2
40 /*  dual Antenna definition */
41 #define BTC_ANT_WIFI_AT_MAIN	0
42 #define BTC_ANT_WIFI_AT_AUX	1
43 /*  coupler Antenna definition */
44 #define BTC_ANT_WIFI_AT_CPL_MAIN	0
45 #define BTC_ANT_WIFI_AT_CPL_AUX		1
46 
47 enum {
48 	BTC_PS_WIFI_NATIVE	= 0,	/*  wifi original power save behavior */
49 	BTC_PS_LPS_ON		= 1,
50 	BTC_PS_LPS_OFF		= 2,
51 	BTC_PS_MAX
52 };
53 
54 enum {
55 	BTC_BT_REG_RF		= 0,
56 	BTC_BT_REG_MODEM	= 1,
57 	BTC_BT_REG_BLUEWIZE	= 2,
58 	BTC_BT_REG_VENDOR	= 3,
59 	BTC_BT_REG_LE		= 4,
60 	BTC_BT_REG_MAX
61 };
62 
63 enum btc_chip_interface {
64 	BTC_INTF_UNKNOWN	= 0,
65 	BTC_INTF_PCI		= 1,
66 	BTC_INTF_USB		= 2,
67 	BTC_INTF_SDIO		= 3,
68 	BTC_INTF_MAX
69 };
70 
71 enum {
72 	BTC_CHIP_UNDEF		= 0,
73 	BTC_CHIP_CSR_BC4	= 1,
74 	BTC_CHIP_CSR_BC8	= 2,
75 	BTC_CHIP_RTL8723A	= 3,
76 	BTC_CHIP_RTL8821	= 4,
77 	BTC_CHIP_RTL8723B	= 5,
78 	BTC_CHIP_MAX
79 };
80 
81 /*  following is for wifi link status */
82 #define WIFI_STA_CONNECTED				BIT0
83 #define WIFI_AP_CONNECTED				BIT1
84 #define WIFI_HS_CONNECTED				BIT2
85 #define WIFI_P2P_GO_CONNECTED			BIT3
86 #define WIFI_P2P_GC_CONNECTED			BIT4
87 
88 struct btc_board_info {
89 	/*  The following is some board information */
90 	u8 btChipType;
91 	u8 pgAntNum;	/*  pg ant number */
92 	u8 btdmAntNum;	/*  ant number for btdm */
93 	u8 btdmAntPos;		/* Bryant Add to indicate Antenna Position for (pgAntNum = 2) && (btdmAntNum = 1)  (DPDT+1Ant case) */
94 	u8 singleAntPath;	/*  current used for 8723b only, 1 =>s0,  0 =>s1 */
95 	/* bool				bBtExist; */
96 };
97 
98 enum {
99 	BTC_RSSI_STATE_HIGH			    = 0x0,
100 	BTC_RSSI_STATE_MEDIUM			= 0x1,
101 	BTC_RSSI_STATE_LOW			    = 0x2,
102 	BTC_RSSI_STATE_STAY_HIGH		= 0x3,
103 	BTC_RSSI_STATE_STAY_MEDIUM		= 0x4,
104 	BTC_RSSI_STATE_STAY_LOW			= 0x5,
105 	BTC_RSSI_MAX
106 };
107 #define BTC_RSSI_HIGH(_rssi_)	((_rssi_ == BTC_RSSI_STATE_HIGH || _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false)
108 #define BTC_RSSI_MEDIUM(_rssi_)	((_rssi_ == BTC_RSSI_STATE_MEDIUM || _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false)
109 #define BTC_RSSI_LOW(_rssi_)	((_rssi_ == BTC_RSSI_STATE_LOW || _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false)
110 
111 enum {
112 	BTC_WIFI_BW_LEGACY			= 0x0,
113 	BTC_WIFI_BW_HT20			= 0x1,
114 	BTC_WIFI_BW_HT40			= 0x2,
115 	BTC_WIFI_BW_MAX
116 };
117 
118 enum {
119 	BTC_WIFI_TRAFFIC_TX			= 0x0,
120 	BTC_WIFI_TRAFFIC_RX			= 0x1,
121 	BTC_WIFI_TRAFFIC_MAX
122 };
123 
124 enum {
125 	BTC_WIFI_PNP_WAKE_UP		= 0x0,
126 	BTC_WIFI_PNP_SLEEP			= 0x1,
127 	BTC_WIFI_PNP_MAX
128 };
129 
130 /*  defined for BFP_BTC_GET */
131 enum {
132 	/*  type bool */
133 	BTC_GET_BL_HS_OPERATION,
134 	BTC_GET_BL_HS_CONNECTING,
135 	BTC_GET_BL_WIFI_CONNECTED,
136 	BTC_GET_BL_WIFI_BUSY,
137 	BTC_GET_BL_WIFI_SCAN,
138 	BTC_GET_BL_WIFI_LINK,
139 	BTC_GET_BL_WIFI_ROAM,
140 	BTC_GET_BL_WIFI_4_WAY_PROGRESS,
141 	BTC_GET_BL_WIFI_AP_MODE_ENABLE,
142 	BTC_GET_BL_WIFI_ENABLE_ENCRYPTION,
143 	BTC_GET_BL_WIFI_UNDER_B_MODE,
144 	BTC_GET_BL_EXT_SWITCH,
145 	BTC_GET_BL_WIFI_IS_IN_MP_MODE,
146 
147 	/*  type s32 */
148 	BTC_GET_S4_WIFI_RSSI,
149 	BTC_GET_S4_HS_RSSI,
150 
151 	/*  type u32 */
152 	BTC_GET_U4_WIFI_BW,
153 	BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
154 	BTC_GET_U4_WIFI_FW_VER,
155 	BTC_GET_U4_WIFI_LINK_STATUS,
156 	BTC_GET_U4_BT_PATCH_VER,
157 
158 	/*  type u8 */
159 	BTC_GET_U1_WIFI_DOT11_CHNL,
160 	BTC_GET_U1_WIFI_CENTRAL_CHNL,
161 	BTC_GET_U1_WIFI_HS_CHNL,
162 	BTC_GET_U1_MAC_PHY_MODE,
163 	BTC_GET_U1_AP_NUM,
164 
165 	/*  for 1Ant ====== */
166 	BTC_GET_U1_LPS_MODE,
167 
168 	BTC_GET_MAX
169 };
170 
171 /*  defined for BFP_BTC_SET */
172 enum {
173 	/*  type bool */
174 	BTC_SET_BL_BT_DISABLE,
175 	BTC_SET_BL_BT_TRAFFIC_BUSY,
176 	BTC_SET_BL_BT_LIMITED_DIG,
177 	BTC_SET_BL_FORCE_TO_ROAM,
178 	BTC_SET_BL_TO_REJ_AP_AGG_PKT,
179 	BTC_SET_BL_BT_CTRL_AGG_SIZE,
180 	BTC_SET_BL_INC_SCAN_DEV_NUM,
181 	BTC_SET_BL_BT_TX_RX_MASK,
182 
183 	/*  type u8 */
184 	BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
185 	BTC_SET_U1_AGG_BUF_SIZE,
186 
187 	/*  type trigger some action */
188 	BTC_SET_ACT_GET_BT_RSSI,
189 	BTC_SET_ACT_AGGREGATE_CTRL,
190 	/*  for 1Ant ====== */
191 	/*  type bool */
192 
193 	/*  type u8 */
194 	BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE,
195 	BTC_SET_U1_LPS_VAL,
196 	BTC_SET_U1_RPWM_VAL,
197 	/*  type trigger some action */
198 	BTC_SET_ACT_LEAVE_LPS,
199 	BTC_SET_ACT_ENTER_LPS,
200 	BTC_SET_ACT_NORMAL_LPS,
201 	BTC_SET_ACT_DISABLE_LOW_POWER,
202 	BTC_SET_ACT_UPDATE_RAMASK,
203 	BTC_SET_ACT_SEND_MIMO_PS,
204 	/*  BT Coex related */
205 	BTC_SET_ACT_CTRL_BT_INFO,
206 	BTC_SET_ACT_CTRL_BT_COEX,
207 	BTC_SET_ACT_CTRL_8723B_ANT,
208 	/*  */
209 	BTC_SET_MAX
210 };
211 
212 enum {
213 	BTC_DBG_DISP_COEX_STATISTICS		= 0x0,
214 	BTC_DBG_DISP_BT_LINK_INFO			= 0x1,
215 	BTC_DBG_DISP_FW_PWR_MODE_CMD		= 0x2,
216 	BTC_DBG_DISP_MAX
217 };
218 
219 enum {
220 	BTC_IPS_LEAVE						= 0x0,
221 	BTC_IPS_ENTER						= 0x1,
222 	BTC_IPS_MAX
223 };
224 
225 enum {
226 	BTC_LPS_DISABLE						= 0x0,
227 	BTC_LPS_ENABLE						= 0x1,
228 	BTC_LPS_MAX
229 };
230 
231 enum {
232 	BTC_SCAN_FINISH						= 0x0,
233 	BTC_SCAN_START						= 0x1,
234 	BTC_SCAN_MAX
235 };
236 
237 enum {
238 	BTC_ASSOCIATE_FINISH				= 0x0,
239 	BTC_ASSOCIATE_START					= 0x1,
240 	BTC_ASSOCIATE_MAX
241 };
242 
243 enum {
244 	BTC_MEDIA_DISCONNECT				= 0x0,
245 	BTC_MEDIA_CONNECT					= 0x1,
246 	BTC_MEDIA_MAX
247 };
248 
249 enum {
250 	BTC_PACKET_UNKNOWN					= 0x0,
251 	BTC_PACKET_DHCP						= 0x1,
252 	BTC_PACKET_ARP						= 0x2,
253 	BTC_PACKET_EAPOL					= 0x3,
254 	BTC_PACKET_MAX
255 };
256 
257 /* Bryant Add */
258 enum {
259 	BTC_ANTENNA_AT_MAIN_PORT = 0x1,
260 	BTC_ANTENNA_AT_AUX_PORT  = 0x2,
261 };
262 
263 typedef u8 (*BFP_BTC_R1)(void *pBtcContext, u32 RegAddr);
264 typedef u16(*BFP_BTC_R2)(void *pBtcContext, u32 RegAddr);
265 typedef u32 (*BFP_BTC_R4)(void *pBtcContext, u32 RegAddr);
266 typedef void (*BFP_BTC_W1)(void *pBtcContext, u32 RegAddr, u8 Data);
267 typedef void(*BFP_BTC_W1_BIT_MASK)(
268 	void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b
269 );
270 typedef void (*BFP_BTC_W2)(void *pBtcContext, u32 RegAddr, u16 Data);
271 typedef void (*BFP_BTC_W4)(void *pBtcContext, u32 RegAddr, u32 Data);
272 typedef void (*BFP_BTC_LOCAL_REG_W1)(void *pBtcContext, u32 RegAddr, u8 Data);
273 typedef void (*BFP_BTC_SET_BB_REG)(
274 	void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data
275 );
276 typedef u32 (*BFP_BTC_GET_BB_REG)(void *pBtcContext, u32 RegAddr, u32 BitMask);
277 typedef void (*BFP_BTC_SET_RF_REG)(
278 	void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data
279 );
280 typedef u32 (*BFP_BTC_GET_RF_REG)(
281 	void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask
282 );
283 typedef void (*BFP_BTC_FILL_H2C)(
284 	void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer
285 );
286 
287 typedef	u8 (*BFP_BTC_GET)(void *pBtCoexist, u8 getType, void *pOutBuf);
288 
289 typedef	u8 (*BFP_BTC_SET)(void *pBtCoexist, u8 setType, void *pInBuf);
290 typedef void (*BFP_BTC_SET_BT_REG)(
291 	void *pBtcContext, u8 regType, u32 offset, u32 value
292 );
293 typedef u32 (*BFP_BTC_GET_BT_REG)(void *pBtcContext, u8 regType, u32 offset);
294 typedef void (*BFP_BTC_DISP_DBG_MSG)(void *pBtCoexist, u8 dispType);
295 
296 struct btc_bt_info {
297 	bool bBtDisabled;
298 	u8 rssiAdjustForAgcTableOn;
299 	u8 rssiAdjustFor1AntCoexType;
300 	bool bPreBtCtrlAggBufSize;
301 	bool bBtCtrlAggBufSize;
302 	bool bRejectAggPkt;
303 	bool bIncreaseScanDevNum;
304 	bool bBtTxRxMask;
305 	u8 preAggBufSize;
306 	u8 aggBufSize;
307 	bool bBtBusy;
308 	bool bLimitedDig;
309 	u16 btHciVer;
310 	u16 btRealFwVer;
311 	u8 btFwVer;
312 	u32 getBtFwVerCnt;
313 
314 	bool bBtDisableLowPwr;
315 
316 	bool bBtCtrlLps;
317 	bool bBtLpsOn;
318 	bool bForceToRoam;	/*  for 1Ant solution */
319 	u8 lpsVal;
320 	u8 rpwmVal;
321 	u32 raMask;
322 };
323 
324 struct btc_stack_info {
325 	bool bProfileNotified;
326 	u16 hciVersion;	/*  stack hci version */
327 	u8 numOfLink;
328 	bool bBtLinkExist;
329 	bool bScoExist;
330 	bool bAclExist;
331 	bool bA2dpExist;
332 	bool bHidExist;
333 	u8 numOfHid;
334 	bool bPanExist;
335 	bool bUnknownAclExist;
336 	s8 minBtRssi;
337 };
338 
339 struct btc_bt_link_info {
340 	bool bBtLinkExist;
341 	bool bScoExist;
342 	bool bScoOnly;
343 	bool bA2dpExist;
344 	bool bA2dpOnly;
345 	bool bHidExist;
346 	bool bHidOnly;
347 	bool bPanExist;
348 	bool bPanOnly;
349 	bool bSlaveRole;
350 };
351 
352 struct btc_statistics {
353 	u32 cntBind;
354 	u32 cntPowerOn;
355 	u32 cntInitHwConfig;
356 	u32 cntInitCoexDm;
357 	u32 cntIpsNotify;
358 	u32 cntLpsNotify;
359 	u32 cntScanNotify;
360 	u32 cntConnectNotify;
361 	u32 cntMediaStatusNotify;
362 	u32 cntSpecialPacketNotify;
363 	u32 cntBtInfoNotify;
364 	u32 cntRfStatusNotify;
365 	u32 cntPeriodical;
366 	u32 cntCoexDmSwitch;
367 	u32 cntStackOperationNotify;
368 	u32 cntDbgCtrl;
369 };
370 
371 struct btc_coexist {
372 	bool bBinded;		/*  make sure only one adapter can bind the data context */
373 	void *Adapter;		/*  default adapter */
374 	struct btc_board_info boardInfo;
375 	struct btc_bt_info btInfo;		/*  some bt info referenced by non-bt module */
376 	struct btc_stack_info stackInfo;
377 	struct btc_bt_link_info btLinkInfo;
378 	enum btc_chip_interface chipInterface;
379 
380 	bool bInitilized;
381 	bool bStopCoexDm;
382 	bool bManualControl;
383 	struct btc_statistics statistics;
384 	u8 pwrModeVal[10];
385 
386 	/*  function pointers */
387 	/*  io related */
388 	BFP_BTC_R1 fBtcRead1Byte;
389 	BFP_BTC_W1 fBtcWrite1Byte;
390 	BFP_BTC_W1_BIT_MASK fBtcWrite1ByteBitMask;
391 	BFP_BTC_R2 fBtcRead2Byte;
392 	BFP_BTC_W2 fBtcWrite2Byte;
393 	BFP_BTC_R4 fBtcRead4Byte;
394 	BFP_BTC_W4 fBtcWrite4Byte;
395 	BFP_BTC_LOCAL_REG_W1 fBtcWriteLocalReg1Byte;
396 	/*  read/write bb related */
397 	BFP_BTC_SET_BB_REG fBtcSetBbReg;
398 	BFP_BTC_GET_BB_REG fBtcGetBbReg;
399 
400 	/*  read/write rf related */
401 	BFP_BTC_SET_RF_REG fBtcSetRfReg;
402 	BFP_BTC_GET_RF_REG fBtcGetRfReg;
403 
404 	/*  fill h2c related */
405 	BFP_BTC_FILL_H2C fBtcFillH2c;
406 	/*  normal get/set related */
407 	BFP_BTC_GET fBtcGet;
408 	BFP_BTC_SET fBtcSet;
409 
410 	BFP_BTC_GET_BT_REG fBtcGetBtReg;
411 	BFP_BTC_SET_BT_REG fBtcSetBtReg;
412 };
413 
414 extern struct btc_coexist GLBtCoexist;
415 
416 void EXhalbtcoutsrc_PowerOnSetting(struct btc_coexist *pBtCoexist);
417 void EXhalbtcoutsrc_InitHwConfig(struct btc_coexist *pBtCoexist, u8 bWifiOnly);
418 void EXhalbtcoutsrc_InitCoexDm(struct btc_coexist *pBtCoexist);
419 void EXhalbtcoutsrc_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
420 void EXhalbtcoutsrc_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
421 void EXhalbtcoutsrc_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
422 void EXhalbtcoutsrc_ConnectNotify(struct btc_coexist *pBtCoexist, u8 action);
423 void EXhalbtcoutsrc_MediaStatusNotify(
424 	struct btc_coexist *pBtCoexist, enum rt_media_status mediaStatus
425 );
426 void EXhalbtcoutsrc_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 pktType);
427 void EXhalbtcoutsrc_BtInfoNotify(
428 	struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
429 );
430 void EXhalbtcoutsrc_HaltNotify(struct btc_coexist *pBtCoexist);
431 void EXhalbtcoutsrc_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
432 void EXhalbtcoutsrc_Periodical(struct btc_coexist *pBtCoexist);
433 void EXhalbtcoutsrc_SetChipType(u8 chipType);
434 void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum);
435 void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath);
436 
437 #endif
438