Skip to content

Commit 14705f9

Browse files
saschahauerKalle Valo
authored andcommitted
wifi: rtw88: rtw8821c: Fix rfe_option field width
On my RTW8821CU chipset rfe_option reads as 0x22. Looking at the vendor driver suggests that the field width of rfe_option is 5 bit, so rfe_option should be masked with 0x1f. Without this the rfe_option comparisons with 2 further down the driver evaluate as false when they should really evaluate as true. The effect is that 2G channels do not work. rfe_option is also used as an array index into rtw8821c_rfe_defs[]. rtw8821c_rfe_defs[34] (0x22) was added as part of adding USB support, likely because rfe_option reads as 0x22. As this now becomes 0x2, rtw8821c_rfe_defs[34] is no longer used and can be removed. Note that this might not be the whole truth. In the vendor driver there are indeed places where the unmasked rfe_option value is used. However, the driver has several places where rfe_option is tested with the pattern if (rfe_option == 2 || rfe_option == 0x22) or if (rfe_option == 4 || rfe_option == 0x24), so that rfe_option BIT(5) has no influence on the code path taken. We therefore mask BIT(5) out from rfe_option entirely until this assumption is proved wrong by some chip variant we do not know yet. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Alexandru gagniuc <mr.nuke.me@gmail.com> Tested-by: Larry Finger <Larry.Finger@lwfinger.net> Tested-by: ValdikSS <iam@valdikss.org.ru> Cc: stable@vger.kernel.org Reviewed-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230417140358.2240429-3-s.hauer@pengutronix.de
1 parent a6f187f commit 14705f9

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/net/wireless/realtek/rtw88/rtw8821c.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int rtw8821c_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
5353

5454
map = (struct rtw8821c_efuse *)log_map;
5555

56-
efuse->rfe_option = map->rfe_option;
56+
efuse->rfe_option = map->rfe_option & 0x1f;
5757
efuse->rf_board_option = map->rf_board_option;
5858
efuse->crystal_cap = map->xtal_k;
5959
efuse->pa_type_2g = map->pa_type;
@@ -1546,7 +1546,6 @@ static const struct rtw_rfe_def rtw8821c_rfe_defs[] = {
15461546
[2] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
15471547
[4] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
15481548
[6] = RTW_DEF_RFE(8821c, 0, 0),
1549-
[34] = RTW_DEF_RFE(8821c, 0, 0),
15501549
};
15511550

15521551
static struct rtw_hw_reg rtw8821c_dig[] = {

0 commit comments

Comments
 (0)