1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
8 #include "odm_precomp.h"
12 static bool check_condition(struct adapter *adapt, const u32 condition)
14 struct odm_dm_struct *odm = &adapt->HalData->odmpriv;
15 u32 _board = odm->BoardType;
16 u32 _platform = odm->SupportPlatform;
17 u32 _interface = odm->SupportInterface;
20 if (condition == 0xCDCDCDCD)
23 cond = condition & 0x000000FF;
24 if ((_board == cond) && cond != 0x00)
27 cond = condition & 0x0000FF00;
29 if ((_interface & cond) == 0 && cond != 0x07)
32 cond = condition & 0x00FF0000;
34 if ((_platform & cond) == 0 && cond != 0x0F)
41 static u32 Array_RadioA_1T_8188E[] = {
143 #define READ_NEXT_PAIR(v1, v2, i) \
145 i += 2; v1 = array[i]; \
149 #define RFREG_OFFSET_MASK 0xfffff
150 #define B3WIREADDREAALENGTH 0x400
151 #define B3WIREDATALENGTH 0x800
152 #define BRFSI_RFENV 0x10
154 static void rtl_rfreg_delay(struct adapter *adapt, enum rf_radio_path rfpath, u32 addr, u32 mask, u32 data)
158 } else if (addr == 0xfd) {
160 } else if (addr == 0xfc) {
162 } else if (addr == 0xfb) {
164 } else if (addr == 0xfa) {
166 } else if (addr == 0xf9) {
169 phy_set_rf_reg(adapt, rfpath, addr, mask, data);
174 static void rtl8188e_config_rf_reg(struct adapter *adapt,
177 u32 content = 0x1000; /*RF Content: radio_a_txt*/
178 u32 maskforphyset = content & 0xE000;
180 rtl_rfreg_delay(adapt, RF90_PATH_A, addr | maskforphyset,
185 static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt)
188 u32 array_len = ARRAY_SIZE(Array_RadioA_1T_8188E);
189 u32 *array = Array_RadioA_1T_8188E;
191 for (i = 0; i < array_len; i += 2) {
195 if (v1 < 0xCDCDCDCD) {
196 rtl8188e_config_rf_reg(adapt, v1, v2);
199 if (!check_condition(adapt, array[i])) {
200 READ_NEXT_PAIR(v1, v2, i);
201 while (v2 != 0xDEAD && v2 != 0xCDEF &&
202 v2 != 0xCDCD && i < array_len - 2)
203 READ_NEXT_PAIR(v1, v2, i);
206 READ_NEXT_PAIR(v1, v2, i);
207 while (v2 != 0xDEAD && v2 != 0xCDEF &&
208 v2 != 0xCDCD && i < array_len - 2) {
209 rtl8188e_config_rf_reg(adapt, v1, v2);
210 READ_NEXT_PAIR(v1, v2, i);
213 while (v2 != 0xDEAD && i < array_len - 2)
214 READ_NEXT_PAIR(v1, v2, i);
221 static bool rf6052_conf_para(struct adapter *adapt)
223 struct hal_data_8188e *hal_data = adapt->HalData;
225 bool rtstatus = true;
226 struct bb_reg_def *pphyreg;
228 pphyreg = &hal_data->PHYRegDef[RF90_PATH_A];
229 u4val = phy_query_bb_reg(adapt, pphyreg->rfintfs, BRFSI_RFENV);
231 phy_set_bb_reg(adapt, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1);
234 phy_set_bb_reg(adapt, pphyreg->rfintfo, BRFSI_RFENV, 0x1);
237 phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, B3WIREADDREAALENGTH, 0x0);
240 phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, B3WIREDATALENGTH, 0x0);
243 rtstatus = rtl88e_phy_config_rf_with_headerfile(adapt);
245 phy_set_bb_reg(adapt, pphyreg->rfintfs, BRFSI_RFENV, u4val);
250 static bool rtl88e_phy_rf6052_config(struct adapter *adapt)
252 return rf6052_conf_para(adapt);
255 bool rtl88eu_phy_rf_config(struct adapter *adapt)
257 return rtl88e_phy_rf6052_config(adapt);