Skip to contentSkip to conversation

commit 5d6651fe8583 ("rtw88: 8821c: support RFE type2 wifi NIC")

PATCH In review Meng Tang 2 participants 5 messages Jun 28, 2022 – Jun 30, 2022

Subsystems (3)
lore
Share & tools
lore

Meng Tang

author
#0 lore raw

PATCH v2 1/3 commit 5d6651fe8583 ("rtw88: 8821c: support RFE type2 wifi NIC")

From: Guo-Feng Fan <[email protected]>

RFE type2 is a new NIC which has one RF antenna shares with BT. Update phy parameter to verstion V57 to allow initial procedure to load extra AGC table for sharing antenna NIC.

---
 drivers/net/wireless/realtek/rtw88/main.c     |   2 +
 drivers/net/wireless/realtek/rtw88/main.h     |   7 +
 drivers/net/wireless/realtek/rtw88/rtw8821c.c |  47 +++
 drivers/net/wireless/realtek/rtw88/rtw8821c.h |  14 +
 .../wireless/realtek/rtw88/rtw8821c_table.c   | 397 ++++++++++++++++++
 .../wireless/realtek/rtw88/rtw8821c_table.h   |   1 +
 6 files changed, 468 insertions(+)
drivers/net/wireless/realtek/rtw88/main.c +2 -0
index 2ef1416899f0..c09d2a8b51dd 100644
@@ -1551,6 +1551,8 @@ static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev)
 	rtw_phy_setup_phy_cond(rtwdev, 0);
 
 	rtw_phy_init_tx_power(rtwdev);
+	if (rfe_def->agc_btg_tbl)
+		rtw_load_table(rtwdev, rfe_def->agc_btg_tbl);
 	rtw_load_table(rtwdev, rfe_def->phy_pg_tbl);
 	rtw_load_table(rtwdev, rfe_def->txpwr_lmt_tbl);
 	rtw_phy_tx_power_by_rate_config(hal);
drivers/net/wireless/realtek/rtw88/main.h +7 -0
index 8ba0b0824ae9..7769cad3f731 100644
@@ -1041,6 +1041,7 @@ enum rtw_rfe_fem {
 struct rtw_rfe_def {
 	const struct rtw_table *phy_pg_tbl;
 	const struct rtw_table *txpwr_lmt_tbl;
+	const struct rtw_table *agc_btg_tbl;
 };
 
 #define RTW_DEF_RFE(chip, bb_pg, pwrlmt) {				  \
@@ -1048,6 +1049,12 @@ struct rtw_rfe_def {
 	.txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \
 	}
 
+#define RTW_DEF_RFE_EXT(chip, bb_pg, pwrlmt, btg) {			  \
+	.phy_pg_tbl = &rtw ## chip ## _bb_pg_type ## bb_pg ## _tbl,	  \
+	.txpwr_lmt_tbl = &rtw ## chip ## _txpwr_lmt_type ## pwrlmt ## _tbl, \
+	.agc_btg_tbl = &rtw ## chip ## _agc_btg_type ## btg ## _tbl, \
+	}
+
 #define RTW_PWR_TRK_5G_1		0
 #define RTW_PWR_TRK_5G_2		1
 #define RTW_PWR_TRK_5G_3		2
drivers/net/wireless/realtek/rtw88/rtw8821c.c +47 -0

74 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rtw8821c.h +14 -0
index 8d1e8ff71d7e..b8d6b1b29387 100644
@@ -173,6 +173,8 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 #define GET_PHY_STAT_P1_RXSNR_B(phy_stat)                                      \
 	le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
 
+#define REG_SYS_CTRL	0x000
+#define BIT_FEN_EN	BIT(26)
 #define REG_INIRTS_RATE_SEL 0x0480
 #define REG_HTSTFWT	0x800
 #define REG_RXPSEL	0x808
@@ -204,6 +206,11 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 #define REG_FA_CCK	0xa5c
 #define REG_RXDESC	0xa2c
 #define REG_ENTXCCK	0xa80
+#define BTG_LNA		0xfc84
+#define WLG_LNA		0x7532
+#define REG_ENRXCCA	0xa84
+#define BTG_CCA		0x0e
+#define WLG_CCA		0x12
 #define REG_PWRTH2	0xaa8
 #define REG_CSRATIO	0xaaa
 #define REG_TXFILTER	0xaac
@@ -217,6 +224,11 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 #define REG_RFESEL0	0xcb0
 #define REG_RFESEL8	0xcb4
 #define REG_RFECTL	0xcb8
+#define B_BTG_SWITCH	BIT(16)
+#define B_CTRL_SWITCH	BIT(18)
+#define B_WL_SWITCH	(BIT(20) | BIT(22))
+#define B_WLG_SWITCH	BIT(21)
+#define B_WLA_SWITCH	BIT(23)
 #define REG_RFEINV	0xcbc
 #define REG_AGCTR_B	0xe08
 #define REG_RXIGI_B	0xe50
@@ -227,6 +239,8 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 #define REG_CCA_OFDM	0xf08
 #define REG_FA_OFDM	0xf48
 #define REG_CCA_CCK	0xfcc
+#define REG_DMEM_CTRL	0x1080
+#define BIT_WL_RST	BIT(16)
 #define REG_ANTWT	0x1904
 #define REG_IQKFAILMSK	0x1bf0
 #define BIT_MASK_R_RFE_SEL_15	GENMASK(31, 28)
drivers/net/wireless/realtek/rtw88/rtw8821c_table.c +397 -0

410 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/rtw8821c_table.h +1 -0
index 5ea8b4fc7fba..cda98f5c4a01 100644
@@ -7,6 +7,7 @@
 
 extern const struct rtw_table rtw8821c_mac_tbl;
 extern const struct rtw_table rtw8821c_agc_tbl;
+extern const struct rtw_table rtw8821c_agc_btg_type2_tbl;
 extern const struct rtw_table rtw8821c_bb_tbl;
 extern const struct rtw_table rtw8821c_bb_pg_type0_tbl;
 extern const struct rtw_table rtw8821c_rf_a_tbl;
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH v2 2/3 commit b789e3fe7047 ("rtw88: 8821c: support RFE type4 wifi NIC")

From: Guo-Feng Fan <[email protected]>

RFE type4 is a new NIC which has one RF antenna shares with BT. RFE type4 HW is the same as RFE type2 but attaching antenna to aux antenna connector.

RFE type2 attach antenna to main antenna connector. Load the same parameter as RFE type2 when initializing NIC.

---
 drivers/net/wireless/realtek/rtw88/rtw8821c.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/rtw8821c.c +12 -1
index 4514c4e8ee58..9c8fbc96f536 100644
@@ -300,7 +300,8 @@ static void rtw8821c_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
 	if (channel <= 14) {
 		if (rtwdev->efuse.rfe_option == 0)
 			rtw8821c_switch_rf_set(rtwdev, SWITCH_TO_WLG);
-		else if (rtwdev->efuse.rfe_option == 2)
+		else if (rtwdev->efuse.rfe_option == 2 ||
+			 rtwdev->efuse.rfe_option == 4)
 			rtw8821c_switch_rf_set(rtwdev, SWITCH_TO_BTG);
 		rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(6), 0x1);
 		rtw_write_rf(rtwdev, RF_PATH_A, 0x64, 0xf, 0xf);
@@ -737,6 +738,15 @@ static void rtw8821c_coex_cfg_ant_switch(struct rtw_dev *rtwdev, u8 ctrl_type,
 	if (switch_status == coex_dm->cur_switch_status)
 		return;
 
+	if (coex_rfe->wlg_at_btg) {
+		ctrl_type = COEX_SWITCH_CTRL_BY_BBSW;
+
+		if (coex_rfe->ant_switch_polarity)
+			pos_type = COEX_SWITCH_TO_WLA;
+		else
+			pos_type = COEX_SWITCH_TO_WLG_BT;
+	}
+
 	coex_dm->cur_switch_status = switch_status;
 
 	if (coex_rfe->ant_switch_diversity &&
@@ -1457,6 +1467,7 @@ static const struct rtw_intf_phy_para_table phy_para_table_8821c = {
 static const struct rtw_rfe_def rtw8821c_rfe_defs[] = {
 	[0] = RTW_DEF_RFE(8821c, 0, 0),
 	[2] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
+	[4] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
 };
 
 static struct rtw_hw_reg rtw8821c_dig[] = {
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH v2 3/3 commit e109e3617e5d ("rtw88: rtw8821c: enable rfe 6 devices")

In reply to Meng Tang

These commits can fix the problem of wifi not loading properly. At least in my 5.10 kernel environment, the following error message is reported:

rtw_8821ce 0000:01:00.0: rfe 6 isn't supported rtw_8821ce 0000:01:00.0: failed to setup chip efuse info rtw_8821ce 0000:01:00.0: failed to setup chip information

so I think that 5.10 need to merge these commits.

The patch 1/3 and patch 2/3 need to be merged synchronously, otherwise it will cause OE and then kernel exception.

Ping-Ke Shih answered[1] a question for a user about an rtl8821ce device that reported RFE 6, which the driver did not support. Ping-Ke suggested a possible fix, but the user never reported back.

A second user discovered the above thread and tested the proposed fix. Accordingly, I am pushing this change, even though I am not the author.

[1] https://lore.kernel.org/linux-wireless/[email protected]/

---
 drivers/net/wireless/realtek/rtw88/rtw8821c.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -0
index 9c8fbc96f536..cbb4c761c5cb 100644
@@ -1468,6 +1468,7 @@ static const struct rtw_rfe_def rtw8821c_rfe_defs[] = {
 	[0] = RTW_DEF_RFE(8821c, 0, 0),
 	[2] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
 	[4] = RTW_DEF_RFE_EXT(8821c, 0, 0, 2),
+	[6] = RTW_DEF_RFE(8821c, 0, 0),
 };
 
 static struct rtw_hw_reg rtw8821c_dig[] = {
Signature · 1 line
2.20.1
maintainer
#3 lore raw

Re: [PATCH 5.10 v2 3/3] commit e109e3617e5d ("rtw88: rtw8821c: enable rfe 6 devices")

Quoted 4 lines · Meng Tang

These commits can fix the problem of wifi not loading properly. At least in my 5.10 kernel environment, the following error message is reported:

Quoted 8 lines

rtw_8821ce 0000:01:00.0: rfe 6 isn't supported rtw_8821ce 0000:01:00.0: failed to setup chip efuse info rtw_8821ce 0000:01:00.0: failed to setup chip information

so I think that 5.10 need to merge these commits.

The patch 1/3 and patch 2/3 need to be merged synchronously, otherwise it will cause OE and then kernel exception.

This is not in the original commit log at all. Shouldn't this be in the 0/3 email instead?

And yes, this hardware is not supported in the 5.10 kernel tree, please move to 5.15 or newer and it will be fine.

thanks,

greg k-h

maintainer
#4 lore raw
In reply to Meng Tang
Quoted 12 lines · Meng Tang

From: Guo-Feng Fan <[email protected]>

RFE type2 is a new NIC which has one RF antenna shares with BT. Update phy parameter to verstion V57 to allow initial procedure to load extra AGC table for sharing antenna NIC.

Quoted 8 lines
---
 drivers/net/wireless/realtek/rtw88/main.c     |   2 +
 drivers/net/wireless/realtek/rtw88/main.h     |   7 +
 drivers/net/wireless/realtek/rtw88/rtw8821c.c |  47 +++
 drivers/net/wireless/realtek/rtw88/rtw8821c.h |  14 +
 .../wireless/realtek/rtw88/rtw8821c_table.c   | 397 ++++++++++++++++++
 .../wireless/realtek/rtw88/rtw8821c_table.h   |   1 +
 6 files changed, 468 insertions(+)

How does this meet the stable kernel rules?

This looks like new hardware support to me, right? What bugfix does this resolve for 5.10 kernels?

And for newer support, why can you not just move to 5.15?

confused,

greg k-h