cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

HalBtcOutSrc.h (10796B)


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