xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8822be/include/hal_phy.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __HAL_PHY_H__
21 #define __HAL_PHY_H__
22 
23 
24 #if DISABLE_BB_RF
25 	#define	HAL_FW_ENABLE				0
26 	#define	HAL_MAC_ENABLE			0
27 	#define	HAL_BB_ENABLE				0
28 	#define	HAL_RF_ENABLE				0
29 #else /* FPGA_PHY and ASIC */
30 	#define	HAL_FW_ENABLE				1
31 	#define	HAL_MAC_ENABLE			1
32 	#define	HAL_BB_ENABLE				1
33 	#define	HAL_RF_ENABLE				1
34 #endif
35 
36 #define	RF6052_MAX_TX_PWR			0x3F
37 #define	RF6052_MAX_REG_88E			0xFF
38 #define	RF6052_MAX_REG_92C			0x7F
39 
40 #define	RF6052_MAX_REG	\
41 	((RF6052_MAX_REG_88E > RF6052_MAX_REG_92C) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C)
42 
43 #define GET_RF6052_REAL_MAX_REG(_Adapter)	\
44 	(IS_HARDWARE_TYPE_8188E(_Adapter) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C)
45 
46 #define	RF6052_MAX_PATH				2
47 
48 /*
49  * Antenna detection method, i.e., using single tone detection or RSSI reported from each antenna detected.
50  * Added by Roger, 2013.05.22.
51  *   */
52 #define ANT_DETECT_BY_SINGLE_TONE	BIT0
53 #define ANT_DETECT_BY_RSSI				BIT1
54 #define IS_ANT_DETECT_SUPPORT_SINGLE_TONE(__Adapter)		((GET_HAL_DATA(__Adapter)->AntDetection) & ANT_DETECT_BY_SINGLE_TONE)
55 #define IS_ANT_DETECT_SUPPORT_RSSI(__Adapter)		((GET_HAL_DATA(__Adapter)->AntDetection) & ANT_DETECT_BY_RSSI)
56 
57 
58 /*--------------------------Define Parameters-------------------------------*/
59 typedef	enum _RF_TYPE {
60 	RF_TYPE_MIN = 0,	/* 0 */
61 	RF_8225 = 1,			/* 1 11b/g RF for verification only */
62 	RF_8256 = 2,			/* 2 11b/g/n */
63 	RF_8258 = 3,			/* 3 11a/b/g/n RF */
64 	RF_6052 = 4,			/* 4 11b/g/n RF */
65 	RF_PSEUDO_11N = 5,	/* 5, It is a temporality RF. */
66 	RF_TYPE_MAX
67 } RF_TYPE_E, *PRF_TYPE_E;
68 
69 #define	TX_1S			0
70 #define	TX_2S			1
71 #define	TX_3S			2
72 #define	TX_4S			3
73 
74 #define	RF_PATH_MAX_92C_88E		2
75 #define	RF_PATH_MAX_90_8812		4	/* Max RF number 90 support */
76 
77 typedef enum _ANTENNA_PATH {
78 	ANTENNA_NONE	= 0,
79 	ANTENNA_D		= 1,
80 	ANTENNA_C		= 2,
81 	ANTENNA_CD	= 3,
82 	ANTENNA_B		= 4,
83 	ANTENNA_BD	= 5,
84 	ANTENNA_BC	= 6,
85 	ANTENNA_BCD	= 7,
86 	ANTENNA_A		= 8,
87 	ANTENNA_AD	= 9,
88 	ANTENNA_AC	= 10,
89 	ANTENNA_ACD	= 11,
90 	ANTENNA_AB	= 12,
91 	ANTENNA_ABD	= 13,
92 	ANTENNA_ABC	= 14,
93 	ANTENNA_ABCD	= 15
94 } ANTENNA_PATH;
95 
96 typedef enum _RF_CONTENT {
97 	radioa_txt = 0x1000,
98 	radiob_txt = 0x1001,
99 	radioc_txt = 0x1002,
100 	radiod_txt = 0x1003
101 } RF_CONTENT;
102 
103 typedef enum _BaseBand_Config_Type {
104 	BaseBand_Config_PHY_REG = 0,			/* Radio Path A */
105 	BaseBand_Config_AGC_TAB = 1,			/* Radio Path B */
106 	BaseBand_Config_AGC_TAB_2G = 2,
107 	BaseBand_Config_AGC_TAB_5G = 3,
108 	BaseBand_Config_PHY_REG_PG
109 } BaseBand_Config_Type, *PBaseBand_Config_Type;
110 
111 typedef enum _HW_BLOCK {
112 	HW_BLOCK_MAC = 0,
113 	HW_BLOCK_PHY0 = 1,
114 	HW_BLOCK_PHY1 = 2,
115 	HW_BLOCK_RF = 3,
116 	HW_BLOCK_MAXIMUM = 4, /* Never use this */
117 } HW_BLOCK_E, *PHW_BLOCK_E;
118 
119 typedef enum _WIRELESS_MODE {
120 	WIRELESS_MODE_UNKNOWN = 0x00,
121 	WIRELESS_MODE_A = 0x01,
122 	WIRELESS_MODE_B = 0x02,
123 	WIRELESS_MODE_G = 0x04,
124 	WIRELESS_MODE_AUTO = 0x08,
125 	WIRELESS_MODE_N_24G = 0x10,
126 	WIRELESS_MODE_N_5G = 0x20,
127 	WIRELESS_MODE_AC_5G = 0x40,
128 	WIRELESS_MODE_AC_24G  = 0x80,
129 	WIRELESS_MODE_AC_ONLY  = 0x100,
130 } WIRELESS_MODE;
131 
132 typedef enum _SwChnlCmdID {
133 	CmdID_End,
134 	CmdID_SetTxPowerLevel,
135 	CmdID_BBRegWrite10,
136 	CmdID_WritePortUlong,
137 	CmdID_WritePortUshort,
138 	CmdID_WritePortUchar,
139 	CmdID_RF_WriteReg,
140 } SwChnlCmdID;
141 
142 typedef struct _SwChnlCmd {
143 	SwChnlCmdID	CmdID;
144 	u32				Para1;
145 	u32				Para2;
146 	u32				msDelay;
147 } SwChnlCmd;
148 
149 typedef struct _R_ANTENNA_SELECT_OFDM {
150 	u32			r_tx_antenna:4;
151 	u32			r_ant_l:4;
152 	u32			r_ant_non_ht:4;
153 	u32			r_ant_ht1:4;
154 	u32			r_ant_ht2:4;
155 	u32			r_ant_ht_s1:4;
156 	u32			r_ant_non_ht_s1:4;
157 	u32			OFDM_TXSC:2;
158 	u32			Reserved:2;
159 } R_ANTENNA_SELECT_OFDM;
160 
161 typedef struct _R_ANTENNA_SELECT_CCK {
162 	u8			r_cckrx_enable_2:2;
163 	u8			r_cckrx_enable:2;
164 	u8			r_ccktx_enable:4;
165 } R_ANTENNA_SELECT_CCK;
166 
167 typedef struct RF_Shadow_Compare_Map {
168 	/* Shadow register value */
169 	u32		Value;
170 	/* Compare or not flag */
171 	u8		Compare;
172 	/* Record If it had ever modified unpredicted */
173 	u8		ErrorOrNot;
174 	/* Recorver Flag */
175 	u8		Recorver;
176 	/*  */
177 	u8		Driver_Write;
178 } RF_SHADOW_T;
179 
180 /*--------------------------Exported Function prototype---------------------*/
181 
182 u32
183 PHY_CalculateBitShift(
184 	u32 BitMask
185 );
186 
187 u32
188 PHY_RFShadowRead(
189 	IN	PADAPTER		Adapter,
190 	IN	u8				eRFPath,
191 	IN	u32				Offset);
192 
193 VOID
194 PHY_RFShadowWrite(
195 	IN	PADAPTER		Adapter,
196 	IN	u8				eRFPath,
197 	IN	u32				Offset,
198 	IN	u32				Data);
199 
200 BOOLEAN
201 PHY_RFShadowCompare(
202 	IN	PADAPTER		Adapter,
203 	IN	u8				eRFPath,
204 	IN	u32				Offset);
205 
206 VOID
207 PHY_RFShadowRecorver(
208 	IN	PADAPTER		Adapter,
209 	IN	u8				eRFPath,
210 	IN	u32				Offset);
211 
212 VOID
213 PHY_RFShadowCompareAll(
214 	IN	PADAPTER		Adapter);
215 
216 VOID
217 PHY_RFShadowRecorverAll(
218 	IN	PADAPTER		Adapter);
219 
220 VOID
221 PHY_RFShadowCompareFlagSet(
222 	IN	PADAPTER		Adapter,
223 	IN	u8				eRFPath,
224 	IN	u32				Offset,
225 	IN	u8				Type);
226 
227 VOID
228 PHY_RFShadowRecorverFlagSet(
229 	IN	PADAPTER		Adapter,
230 	IN	u8				eRFPath,
231 	IN	u32				Offset,
232 	IN	u8				Type);
233 
234 VOID
235 PHY_RFShadowCompareFlagSetAll(
236 	IN	PADAPTER		Adapter);
237 
238 VOID
239 PHY_RFShadowRecorverFlagSetAll(
240 	IN	PADAPTER		Adapter);
241 
242 VOID
243 PHY_RFShadowRefresh(
244 	IN	PADAPTER		Adapter);
245 
246 #endif /* __HAL_COMMON_H__ */
247