xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8723bs/hal/phydm/halrf/halrf.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 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  *****************************************************************************/
15 
16 
17 #ifndef	_HALRF_H__
18 #define _HALRF_H__
19 
20 /*============================================================*/
21 /*include files*/
22 /*============================================================*/
23 
24 
25 
26 /*============================================================*/
27 /*Definition */
28 /*============================================================*/
29 /*IQK version*/
30 #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
31 #define IQK_VERSION_8188E	"0x14"
32 #define IQK_VERSION_8192E	"0x01"
33 #define IQK_VERSION_8723B	"0x1d"
34 #define IQK_VERSION_8812A	"0x01"
35 #define IQK_VERSION_8821A	"0x01"
36 #elif (DM_ODM_SUPPORT_TYPE & (ODM_CE))
37 #define IQK_VERSION_8188E	"0x01"
38 #define IQK_VERSION_8192E	"0x01"
39 #define IQK_VERSION_8723B	"0x19"
40 #define IQK_VERSION_8812A	"0x01"
41 #define IQK_VERSION_8821A	"0x01"
42 #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP))
43 #define IQK_VERSION_8188E	"0x01"
44 #define IQK_VERSION_8192E	"0x01"
45 #define IQK_VERSION_8723B	"0x01"
46 #define IQK_VERSION_8812A	"0x01"
47 #define IQK_VERSION_8821A	"0x01"
48 #endif
49 #define IQK_VERSION_8814A	"0x0f"
50 #define IQK_VERSION_8188F	"0x01"
51 #define IQK_VERSION_8197F	"0x01"
52 #define IQK_VERSION_8703B	"0x04"
53 #define IQK_VERSION_8710B	"0x01"
54 #define IQK_VERSION_8723D	"0x01"
55 #define IQK_VERSION_8822B	"0x2e"
56 #define IQK_VERSION_8821C	"0x23"
57 
58 /*LCK version*/
59 #define LCK_VERSION_8188E	"0x01"
60 #define LCK_VERSION_8192E	"0x01"
61 #define LCK_VERSION_8723B	"0x01"
62 #define LCK_VERSION_8812A	"0x01"
63 #define LCK_VERSION_8821A	"0x01"
64 #define LCK_VERSION_8814A	"0x01"
65 #define LCK_VERSION_8188F	"0x01"
66 #define LCK_VERSION_8197F	"0x01"
67 #define LCK_VERSION_8703B	"0x01"
68 #define LCK_VERSION_8710B	"0x01"
69 #define LCK_VERSION_8723D	"0x01"
70 #define LCK_VERSION_8822B	"0x01"
71 #define LCK_VERSION_8821C	"0x01"
72 
73 
74 #define HALRF_IQK_VER	(p_dm->support_ic_type == ODM_RTL8188E)? IQK_VERSION_8188E :\
75 						(p_dm->support_ic_type == ODM_RTL8192E)? IQK_VERSION_8192E :\
76 						(p_dm->support_ic_type == ODM_RTL8723B)? IQK_VERSION_8723B :\
77 						(p_dm->support_ic_type == ODM_RTL8812)? IQK_VERSION_8812A :\
78 						(p_dm->support_ic_type == ODM_RTL8821)? IQK_VERSION_8821A :\
79 						(p_dm->support_ic_type == ODM_RTL8814A)? IQK_VERSION_8814A :\
80 						(p_dm->support_ic_type == ODM_RTL8188F)? IQK_VERSION_8188F :\
81 						(p_dm->support_ic_type == ODM_RTL8197F)? IQK_VERSION_8197F :\
82 						(p_dm->support_ic_type == ODM_RTL8703B)? IQK_VERSION_8703B :\
83 						(p_dm->support_ic_type == ODM_RTL8710B)? IQK_VERSION_8710B :\
84 						(p_dm->support_ic_type == ODM_RTL8723D)? IQK_VERSION_8723D :\
85 						(p_dm->support_ic_type == ODM_RTL8822B)? IQK_VERSION_8822B :\
86 						(p_dm->support_ic_type == ODM_RTL8821C)? IQK_VERSION_8821C :"unknown"
87 
88 
89 #define HALRF_LCK_VER	(p_dm->support_ic_type == ODM_RTL8188E)? LCK_VERSION_8188E :\
90 						(p_dm->support_ic_type == ODM_RTL8192E)? LCK_VERSION_8192E :\
91 						(p_dm->support_ic_type == ODM_RTL8723B)? LCK_VERSION_8723B :\
92 						(p_dm->support_ic_type == ODM_RTL8812)? LCK_VERSION_8812A :\
93 						(p_dm->support_ic_type == ODM_RTL8821)? LCK_VERSION_8821A :\
94 						(p_dm->support_ic_type == ODM_RTL8814A)? LCK_VERSION_8814A :\
95 						(p_dm->support_ic_type == ODM_RTL8188F)? LCK_VERSION_8188F :\
96 						(p_dm->support_ic_type == ODM_RTL8197F)? LCK_VERSION_8197F :\
97 						(p_dm->support_ic_type == ODM_RTL8703B)? LCK_VERSION_8703B :\
98 						(p_dm->support_ic_type == ODM_RTL8710B)? LCK_VERSION_8710B :\
99 						(p_dm->support_ic_type == ODM_RTL8723D)? LCK_VERSION_8723D :\
100 						(p_dm->support_ic_type == ODM_RTL8822B)? LCK_VERSION_8822B :\
101 						(p_dm->support_ic_type == ODM_RTL8821C)? LCK_VERSION_8821C :"unknown"
102 #define HALRF_DPK_VER	"0x02"
103 
104 #define IQK_THRESHOLD			8
105 #define DPK_THRESHOLD			4
106 
107 /*============================================================*/
108 /* enumeration */
109 /*============================================================*/
110 enum halrf_ability_e {
111 
112 	HAL_RF_TX_PWR_TRACK	= BIT(0),
113 	HAL_RF_IQK				= BIT(1),
114 	HAL_RF_LCK				= BIT(2),
115 	HAL_RF_DPK				= BIT(3),
116 	HAL_RF_TXGAPK			= BIT(4)
117 };
118 
119 enum halrf_cmninfo_init_e {
120 	HALRF_CMNINFO_ABILITY = 0,
121 	HALRF_CMNINFO_DPK_EN = 1,
122 	HALRF_CMNINFO_EEPROM_THERMAL_VALUE,
123 	HALRF_CMNINFO_FW_VER,
124 	HALRF_CMNINFO_RFK_FORBIDDEN,
125 	HALRF_CMNINFO_IQK_SEGMENT
126 };
127 
128 enum halrf_cmninfo_hook_e {
129 	HALRF_CMNINFO_CON_TX,
130 	HALRF_CMNINFO_SINGLE_TONE,
131 	HALRF_CMNINFO_CARRIER_SUPPRESSION,
132 	HALRF_CMNINFO_MP_RATE_INDEX
133 };
134 
135 enum phydm_lna_set {
136 	phydm_lna_disable		= 0,
137 	phydm_lna_enable		= 1,
138 };
139 
140 
141 /*============================================================*/
142 /* structure */
143 /*============================================================*/
144 
145 struct _hal_rf_ {
146 	/*hook*/
147 	u8		*test1;
148 
149 	/*update*/
150 	u32		rf_supportability;
151 
152 	u8		eeprom_thermal;
153 	u8		dpk_en;			/*Enable Function DPK OFF/ON = 0/1*/
154 	boolean	dpk_done;
155 	u32		fw_ver;
156 
157 	boolean	*p_is_con_tx;
158 	boolean	*p_is_single_tone;
159 	boolean	*p_is_carrier_suppresion;
160 
161 	u8		*p_mp_rate_index;
162 	u8		*p_rate_index;
163 };
164 
165 /*============================================================*/
166 /* function prototype */
167 /*============================================================*/
168 
169 void halrf_basic_profile(
170 	void			*p_dm_void,
171 	u32			*_used,
172 	char			*output,
173 	u32			*_out_len
174 );
175 #if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1)
176 void halrf_iqk_info_dump(
177 	void *p_dm_void,
178 	u32 *_used,
179 	char *output,
180 	u32 *_out_len
181 );
182 
183 void
184 halrf_iqk_hwtx_check(
185 	void *p_dm_void,
186 	boolean		is_check
187 );
188 #endif
189 
190 void
191 halrf_support_ability_debug(
192 	void		*p_dm_void,
193 	char		input[][16],
194 	u32		*_used,
195 	char		*output,
196 	u32		*_out_len
197 );
198 
199 void
200 halrf_cmn_info_init(
201 	void		*p_dm_void,
202 	enum halrf_cmninfo_init_e	cmn_info,
203 	u32		value
204 );
205 
206 void
207 halrf_cmn_info_hook(
208 	void		*p_dm_void,
209 	u32		cmn_info,
210 	void		*p_value
211 );
212 
213 void
214 halrf_cmn_info_set(
215 	void		*p_dm_void,
216 	u32			cmn_info,
217 	u64			value
218 );
219 
220 u64
221 halrf_cmn_info_get(
222 	void		*p_dm_void,
223 	u32			cmn_info
224 );
225 
226 void
227 halrf_watchdog(
228 	void			*p_dm_void
229 );
230 
231 void
232 halrf_supportability_init(
233 	void		*p_dm_void
234 );
235 
236 void
237 halrf_init(
238 	void			*p_dm_void
239 );
240 
241 void
242 halrf_iqk_trigger(
243 	void			*p_dm_void,
244 	boolean		is_recovery
245 );
246 
247 void
248 halrf_segment_iqk_trigger(
249 	void			*p_dm_void,
250 	boolean		clear,
251 	boolean		segment_iqk
252 );
253 
254 void
255 halrf_lck_trigger(
256 	void			*p_dm_void
257 );
258 
259 void
260 halrf_iqk_debug(
261 	void		*p_dm_void,
262 	u32		*const dm_value,
263 	u32		*_used,
264 	char		*output,
265 	u32		*_out_len
266 );
267 
268 void
269 phydm_get_iqk_cfir(
270 	void		*p_dm_void,
271 	u8 idx,
272 	u8 path,
273 	boolean debug
274 );
275 
276 void
277 halrf_iqk_xym_read(
278 	void *p_dm_void,
279 	u8 path,
280 	u8 xym_type
281  );
282 
283 void
284 halrf_rf_lna_setting(
285 	void	*p_dm_void,
286 	enum phydm_lna_set type
287 );
288 
289 
290 void
291 halrf_do_imr_test(
292 	void	*p_dm_void,
293 	u8 data
294 );
295 
296 u32
297 halrf_psd_log2base(
298 	IN u32 val
299 );
300 
301 
302 #if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1)
303 void halrf_iqk_dbg(void	*p_dm_void);
304 #endif
305 #endif
306 
307 
308