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 ******************************************************************************/
16 #include "odm_precomp.h"
20 static bool check_condition(struct adapter *adapt, const u32 condition)
22 struct odm_dm_struct *odm = &adapt->HalData->odmpriv;
23 u32 _board = odm->BoardType;
24 u32 _platform = odm->SupportPlatform;
25 u32 _interface = odm->SupportInterface;
28 if (condition == 0xCDCDCDCD)
31 cond = condition & 0x000000FF;
32 if ((_board == cond) && cond != 0x00)
35 cond = condition & 0x0000FF00;
37 if ((_interface & cond) == 0 && cond != 0x07)
40 cond = condition & 0x00FF0000;
42 if ((_platform & cond) == 0 && cond != 0x0F)
49 static u32 Array_RadioA_1T_8188E[] = {
151 #define READ_NEXT_PAIR(v1, v2, i) \
153 i += 2; v1 = array[i]; \
157 #define RFREG_OFFSET_MASK 0xfffff
158 #define B3WIREADDREAALENGTH 0x400
159 #define B3WIREDATALENGTH 0x800
160 #define BRFSI_RFENV 0x10
162 static void rtl_rfreg_delay(struct adapter *adapt, enum rf_radio_path rfpath, u32 addr, u32 mask, u32 data)
166 } else if (addr == 0xfd) {
168 } else if (addr == 0xfc) {
170 } else if (addr == 0xfb) {
172 } else if (addr == 0xfa) {
174 } else if (addr == 0xf9) {
177 phy_set_rf_reg(adapt, rfpath, addr, mask, data);
182 static void rtl8188e_config_rf_reg(struct adapter *adapt,
185 u32 content = 0x1000; /*RF Content: radio_a_txt*/
186 u32 maskforphyset = content & 0xE000;
188 rtl_rfreg_delay(adapt, RF90_PATH_A, addr | maskforphyset,
193 static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt)
196 u32 array_len = ARRAY_SIZE(Array_RadioA_1T_8188E);
197 u32 *array = Array_RadioA_1T_8188E;
199 for (i = 0; i < array_len; i += 2) {
203 if (v1 < 0xCDCDCDCD) {
204 rtl8188e_config_rf_reg(adapt, v1, v2);
207 if (!check_condition(adapt, array[i])) {
208 READ_NEXT_PAIR(v1, v2, i);
209 while (v2 != 0xDEAD && v2 != 0xCDEF &&
210 v2 != 0xCDCD && i < array_len - 2)
211 READ_NEXT_PAIR(v1, v2, i);
214 READ_NEXT_PAIR(v1, v2, i);
215 while (v2 != 0xDEAD && v2 != 0xCDEF &&
216 v2 != 0xCDCD && i < array_len - 2) {
217 rtl8188e_config_rf_reg(adapt, v1, v2);
218 READ_NEXT_PAIR(v1, v2, i);
221 while (v2 != 0xDEAD && i < array_len - 2)
222 READ_NEXT_PAIR(v1, v2, i);
229 static bool rf6052_conf_para(struct adapter *adapt)
231 struct hal_data_8188e *hal_data = adapt->HalData;
233 bool rtstatus = true;
234 struct bb_reg_def *pphyreg;
236 pphyreg = &hal_data->PHYRegDef[RF90_PATH_A];
237 u4val = phy_query_bb_reg(adapt, pphyreg->rfintfs, BRFSI_RFENV);
239 phy_set_bb_reg(adapt, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1);
242 phy_set_bb_reg(adapt, pphyreg->rfintfo, BRFSI_RFENV, 0x1);
245 phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, B3WIREADDREAALENGTH, 0x0);
248 phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, B3WIREDATALENGTH, 0x0);
251 rtstatus = rtl88e_phy_config_rf_with_headerfile(adapt);
253 phy_set_bb_reg(adapt, pphyreg->rfintfs, BRFSI_RFENV, u4val);
258 static bool rtl88e_phy_rf6052_config(struct adapter *adapt)
260 return rf6052_conf_para(adapt);
263 bool rtl88eu_phy_rf_config(struct adapter *adapt)
265 return rtl88e_phy_rf6052_config(adapt);