1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
21 #include "odm_precomp.h"
25 static bool check_condition(struct adapter
*adapt
, const u32 condition
)
27 struct odm_dm_struct
*odm
= &GET_HAL_DATA(adapt
)->odmpriv
;
28 u32 _board
= odm
->BoardType
;
29 u32 _platform
= odm
->SupportPlatform
;
30 u32 _interface
= odm
->SupportInterface
;
33 if (condition
== 0xCDCDCDCD)
36 cond
= condition
& 0x000000FF;
37 if ((_board
== cond
) && cond
!= 0x00)
40 cond
= condition
& 0x0000FF00;
42 if ((_interface
& cond
) == 0 && cond
!= 0x07)
45 cond
= condition
& 0x00FF0000;
47 if ((_platform
& cond
) == 0 && cond
!= 0x0F)
54 static u32 Array_RadioA_1T_8188E
[] = {
156 #define READ_NEXT_PAIR(v1, v2, i) \
158 i += 2; v1 = array[i]; \
162 #define RFREG_OFFSET_MASK 0xfffff
163 #define B3WIREADDREAALENGTH 0x400
164 #define B3WIREDATALENGTH 0x800
165 #define BRFSI_RFENV 0x10
167 static void rtl_rfreg_delay(struct adapter
*adapt
, enum rf_radio_path rfpath
, u32 addr
, u32 mask
, u32 data
)
171 } else if (addr
== 0xfd) {
173 } else if (addr
== 0xfc) {
175 } else if (addr
== 0xfb) {
177 } else if (addr
== 0xfa) {
179 } else if (addr
== 0xf9) {
182 phy_set_rf_reg(adapt
, rfpath
, addr
, mask
, data
);
187 static void rtl8188e_config_rf_reg(struct adapter
*adapt
,
190 u32 content
= 0x1000; /*RF Content: radio_a_txt*/
191 u32 maskforphyset
= (u32
)(content
& 0xE000);
193 rtl_rfreg_delay(adapt
, RF90_PATH_A
, addr
| maskforphyset
,
198 static bool rtl88e_phy_config_rf_with_headerfile(struct adapter
*adapt
)
201 u32 array_len
= sizeof(Array_RadioA_1T_8188E
)/sizeof(u32
);
202 u32
*array
= Array_RadioA_1T_8188E
;
204 for (i
= 0; i
< array_len
; i
+= 2) {
208 if (v1
< 0xCDCDCDCD) {
209 rtl8188e_config_rf_reg(adapt
, v1
, v2
);
212 if (!check_condition(adapt
, array
[i
])) {
213 READ_NEXT_PAIR(v1
, v2
, i
);
214 while (v2
!= 0xDEAD && v2
!= 0xCDEF &&
215 v2
!= 0xCDCD && i
< array_len
- 2)
216 READ_NEXT_PAIR(v1
, v2
, i
);
219 READ_NEXT_PAIR(v1
, v2
, i
);
220 while (v2
!= 0xDEAD && v2
!= 0xCDEF &&
221 v2
!= 0xCDCD && i
< array_len
- 2) {
222 rtl8188e_config_rf_reg(adapt
, v1
, v2
);
223 READ_NEXT_PAIR(v1
, v2
, i
);
226 while (v2
!= 0xDEAD && i
< array_len
- 2)
227 READ_NEXT_PAIR(v1
, v2
, i
);
234 static bool rf6052_conf_para(struct adapter
*adapt
)
236 struct hal_data_8188e
*hal_data
= GET_HAL_DATA(adapt
);
239 bool rtstatus
= true;
240 struct bb_reg_def
*pphyreg
;
242 for (rfpath
= 0; rfpath
< hal_data
->NumTotalRFPath
; rfpath
++) {
243 pphyreg
= &hal_data
->PHYRegDef
[rfpath
];
248 u4val
= phy_query_bb_reg(adapt
, pphyreg
->rfintfs
,
253 u4val
= phy_query_bb_reg(adapt
, pphyreg
->rfintfs
,
258 phy_set_bb_reg(adapt
, pphyreg
->rfintfe
, BRFSI_RFENV
<< 16, 0x1);
261 phy_set_bb_reg(adapt
, pphyreg
->rfintfo
, BRFSI_RFENV
, 0x1);
264 phy_set_bb_reg(adapt
, pphyreg
->rfHSSIPara2
,
265 B3WIREADDREAALENGTH
, 0x0);
268 phy_set_bb_reg(adapt
, pphyreg
->rfHSSIPara2
,
269 B3WIREDATALENGTH
, 0x0);
274 rtstatus
= rtl88e_phy_config_rf_with_headerfile(adapt
);
277 rtstatus
= rtl88e_phy_config_rf_with_headerfile(adapt
);
288 phy_set_bb_reg(adapt
, pphyreg
->rfintfs
,
293 phy_set_bb_reg(adapt
, pphyreg
->rfintfs
,
294 BRFSI_RFENV
<< 16, u4val
);
305 static bool rtl88e_phy_rf6052_config(struct adapter
*adapt
)
307 struct hal_data_8188e
*hal_data
= GET_HAL_DATA(adapt
);
309 if (hal_data
->rf_type
== RF_1T1R
)
310 hal_data
->NumTotalRFPath
= 1;
312 hal_data
->NumTotalRFPath
= 2;
314 return rf6052_conf_para(adapt
);
317 bool rtl88eu_phy_rf_config(struct adapter
*adapt
)
319 return rtl88e_phy_rf6052_config(adapt
);