Skip to content

Commit 5247187

Browse files
Ping-Ke ShihKalle Valo
authored andcommitted
wifi: rtw89: 8922a: read efuse content from physical map
The calibration values of thermal and bias are programmed in invariable physical map. Read them into driver and will set them to registers later. Signed-off-by: Ping-Ke Shih <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c7ccb24 commit 5247187

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

drivers/net/wireless/realtek/rtw89/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4345,6 +4345,7 @@ struct rtw89_power_trim_info {
43454345
bool pg_pa_bias_trim;
43464346
u8 thermal_trim[RF_PATH_MAX];
43474347
u8 pa_bias_trim[RF_PATH_MAX];
4348+
u8 pad_bias_trim[RF_PATH_MAX];
43484349
};
43494350

43504351
struct rtw89_regd {

drivers/net/wireless/realtek/rtw89/rtw8922a.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,92 @@ static int rtw8922a_read_efuse(struct rtw89_dev *rtwdev, u8 *log_map,
175175
}
176176
}
177177

178+
#define THM_TRIM_POSITIVE_MASK BIT(6)
179+
#define THM_TRIM_MAGNITUDE_MASK GENMASK(5, 0)
180+
181+
static void rtw8922a_phycap_parsing_thermal_trim(struct rtw89_dev *rtwdev,
182+
u8 *phycap_map)
183+
{
184+
static const u32 thm_trim_addr[RF_PATH_NUM_8922A] = {0x1706, 0x1733};
185+
struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
186+
u32 addr = rtwdev->chip->phycap_addr;
187+
bool pg = true;
188+
u8 pg_th;
189+
s8 val;
190+
u8 i;
191+
192+
for (i = 0; i < RF_PATH_NUM_8922A; i++) {
193+
pg_th = phycap_map[thm_trim_addr[i] - addr];
194+
if (pg_th == 0xff) {
195+
info->thermal_trim[i] = 0;
196+
pg = false;
197+
break;
198+
}
199+
200+
val = u8_get_bits(pg_th, THM_TRIM_MAGNITUDE_MASK);
201+
202+
if (!(pg_th & THM_TRIM_POSITIVE_MASK))
203+
val *= -1;
204+
205+
info->thermal_trim[i] = val;
206+
207+
rtw89_debug(rtwdev, RTW89_DBG_RFK,
208+
"[THERMAL][TRIM] path=%d thermal_trim=0x%x (%d)\n",
209+
i, pg_th, val);
210+
}
211+
212+
info->pg_thermal_trim = pg;
213+
}
214+
215+
static void rtw8922a_phycap_parsing_pa_bias_trim(struct rtw89_dev *rtwdev,
216+
u8 *phycap_map)
217+
{
218+
static const u32 pabias_trim_addr[RF_PATH_NUM_8922A] = {0x1707, 0x1734};
219+
static const u32 check_pa_pad_trim_addr = 0x1700;
220+
struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
221+
u32 addr = rtwdev->chip->phycap_addr;
222+
u8 val;
223+
u8 i;
224+
225+
val = phycap_map[check_pa_pad_trim_addr - addr];
226+
if (val != 0xff)
227+
info->pg_pa_bias_trim = true;
228+
229+
for (i = 0; i < RF_PATH_NUM_8922A; i++) {
230+
info->pa_bias_trim[i] = phycap_map[pabias_trim_addr[i] - addr];
231+
232+
rtw89_debug(rtwdev, RTW89_DBG_RFK,
233+
"[PA_BIAS][TRIM] path=%d pa_bias_trim=0x%x\n",
234+
i, info->pa_bias_trim[i]);
235+
}
236+
}
237+
238+
static void rtw8922a_phycap_parsing_pad_bias_trim(struct rtw89_dev *rtwdev,
239+
u8 *phycap_map)
240+
{
241+
static const u32 pad_bias_trim_addr[RF_PATH_NUM_8922A] = {0x1708, 0x1735};
242+
struct rtw89_power_trim_info *info = &rtwdev->pwr_trim;
243+
u32 addr = rtwdev->chip->phycap_addr;
244+
u8 i;
245+
246+
for (i = 0; i < RF_PATH_NUM_8922A; i++) {
247+
info->pad_bias_trim[i] = phycap_map[pad_bias_trim_addr[i] - addr];
248+
249+
rtw89_debug(rtwdev, RTW89_DBG_RFK,
250+
"[PAD_BIAS][TRIM] path=%d pad_bias_trim=0x%x\n",
251+
i, info->pad_bias_trim[i]);
252+
}
253+
}
254+
255+
static int rtw8922a_read_phycap(struct rtw89_dev *rtwdev, u8 *phycap_map)
256+
{
257+
rtw8922a_phycap_parsing_thermal_trim(rtwdev, phycap_map);
258+
rtw8922a_phycap_parsing_pa_bias_trim(rtwdev, phycap_map);
259+
rtw8922a_phycap_parsing_pad_bias_trim(rtwdev, phycap_map);
260+
261+
return 0;
262+
}
263+
178264
#ifdef CONFIG_PM
179265
static const struct wiphy_wowlan_support rtw_wowlan_stub_8922a = {
180266
.flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
@@ -186,6 +272,7 @@ static const struct wiphy_wowlan_support rtw_wowlan_stub_8922a = {
186272

187273
static const struct rtw89_chip_ops rtw8922a_chip_ops = {
188274
.read_efuse = rtw8922a_read_efuse,
275+
.read_phycap = rtw8922a_read_phycap,
189276
};
190277

191278
const struct rtw89_chip_info rtw8922a_chip_info = {

0 commit comments

Comments
 (0)