Skip to contentSkip to conversation

wifi: rtw88: 8723b: Read the package type from efuse

PATCH In review Bitterblue Smith 3 participants 6 messages Oct 17 – Oct 20 Realtek wireless driver (rtw88)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtw88: 8723b: Read the package type from efuse

Some chip package types need different parts of the RF initialisation table, so read the package type from efuse.

Also disable support for 40 MHz channel width based on some other bits of the same efuse byte. This is not exactly the package type, but the vendor driver puts it in the same function.

---
 drivers/net/wireless/realtek/rtw88/rtw8723b.c | 35 +++++++++++++++++++
 drivers/net/wireless/realtek/rtw88/rtw8723b.h |  8 +++++
 2 files changed, 43 insertions(+)
drivers/net/wireless/realtek/rtw88/rtw8723b.c +35 -0
index 8bb9c03d769c..fa57900b22fa 100644
@@ -6,6 +6,7 @@
 
 #include "main.h"
 #include "coex.h"
+#include "efuse.h"
 #include "fw.h"
 #include "mac.h"
 #include "phy.h"
@@ -2349,6 +2350,38 @@ static void rtw8723b_fill_txdesc_checksum(struct rtw_dev *rtwdev,
 	fill_txdesc_checksum_common(txdesc, 16);
 }
 
+static void rtw8723b_read_package_type(struct rtw_dev *rtwdev)
+{
+	struct rtw_hal *hal = &rtwdev->hal;
+	u8 val_1fb;
+
+	rtw8723b_efuse_grant(rtwdev, true);
+	rtw_read8_physical_efuse(rtwdev, 0x1fb, &val_1fb);
+	rtw8723b_efuse_grant(rtwdev, false);
+
+	switch (u8_get_bits(val_1fb, GENMASK(2, 0))) {
+	case 0x4:
+		hal->pkg_type = RTW8723B_PACKAGE_TFBGA79;
+		break;
+	case 0x5:
+		hal->pkg_type = RTW8723B_PACKAGE_TFBGA90;
+		break;
+	case 0x6:
+		hal->pkg_type = RTW8723B_PACKAGE_QFN68;
+		break;
+	case 0x7:
+		hal->pkg_type = RTW8723B_PACKAGE_TFBGA80;
+		break;
+	default:
+		hal->pkg_type = RTW8723B_PACKAGE_DEFAULT;
+		break;
+	}
+
+	if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO &&
+	    u8_get_bits(val_1fb, GENMASK(5, 4)) == 0x2)
+		rtwdev->efuse.hw_cap.bw &= ~BIT(RTW_CHANNEL_WIDTH_40);
+}
+
 static int rtw8723b_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
 {
 	struct rtw_efuse *efuse = &rtwdev->efuse;
@@ -2374,6 +2407,8 @@ static int rtw8723b_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
 	efuse->hw_cap.bw = BIT(RTW_CHANNEL_WIDTH_20) |
 			   BIT(RTW_CHANNEL_WIDTH_40);
 
+	rtw8723b_read_package_type(rtwdev);
+
 	return 0;
 }
 
drivers/net/wireless/realtek/rtw88/rtw8723b.h +8 -0
index cf93b93ede81..8201109c18f2 100644
@@ -9,6 +9,14 @@
 
 #include "rtw8723x.h"
 
+enum rtw8723b_package_type {
+	RTW8723B_PACKAGE_DEFAULT,
+	RTW8723B_PACKAGE_QFN68,
+	RTW8723B_PACKAGE_TFBGA90,
+	RTW8723B_PACKAGE_TFBGA80,
+	RTW8723B_PACKAGE_TFBGA79,
+};
+
 extern const struct rtw_chip_info rtw8723b_hw_spec;
 
 #endif
Signature · 1 line
2.55.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Bitterblue Smith

Some chip package types need different parts of the RF initialisation table, so read the package type from efuse.

Also disable support for 40 MHz channel width based on some other bits of the same efuse byte. This is not exactly the package type, but the vendor driver puts it in the same function.

---

Looks good to me, also tested on RTL8723BS.

Best regards,
Luka Gejak

maintainer
#2 lore raw
In reply to Bitterblue Smith

Bitterblue Smith <[email protected]> wrote:

[...]

drivers/net/wireless/realtek/rtw88/rtw8723b.c static void rtw8723b_fill_txdesc_checksum(struct rtw_dev *rtwdev, · line 2360

Quoted 8 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +8 -0
+static void rtw8723b_read_package_type(struct rtw_dev *rtwdev)
+{
+       struct rtw_hal *hal = &rtwdev->hal;
+       u8 val_1fb;
+
+       rtw8723b_efuse_grant(rtwdev, true);
+       rtw_read8_physical_efuse(rtwdev, 0x1fb, &val_1fb);
+       rtw8723b_efuse_grant(rtwdev, false);

In rtw_parse_efuse_map(), we can pass 'phy_map' to read_efuse()? -chip->ops->read_efuse(rtwdev, log_map); +chip->ops->read_efuse(rtwdev, log_map, phy_map);

As .phy_efuse_size = 512 for RTL7823B, I think it will work.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+       switch (u8_get_bits(val_1fb, GENMASK(2, 0))) {

Bit 2~0 seems like PKG_TYPE. Define an enum?

Quoted 9 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +9 -0
+       case 0x4:
+               hal->pkg_type = RTW8723B_PACKAGE_TFBGA79;
+               break;
+       case 0x5:
+               hal->pkg_type = RTW8723B_PACKAGE_TFBGA90;
+               break;
+       case 0x6:
+               hal->pkg_type = RTW8723B_PACKAGE_QFN68;
+               break;

drivers/net/wireless/realtek/rtw88/rtw8723b.c static void rtw8723b_fill_txdesc_checksum(struct rtw_dev *rtwdev, · line 2381

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +10 -0
+       case 0x7:
+               hal->pkg_type = RTW8723B_PACKAGE_TFBGA80;
+               break;
+       default:
+               hal->pkg_type = RTW8723B_PACKAGE_DEFAULT;
+               break;
+       }
+
+       if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO &&
+           u8_get_bits(val_1fb, GENMASK(5, 4)) == 0x2)

Can you define enums for bit 5-4 and value 0x2?
I'm not sure if vendor driver has some comments pointing out this or not.

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +3 -0
+               rtwdev->efuse.hw_cap.bw &= ~BIT(RTW_CHANNEL_WIDTH_40);
+}
+
 static int rtw8723b_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
 {
        struct rtw_efuse *efuse = &rtwdev->efuse;
#3 lore raw
Quoted 17 lines · Ping-Ke Shih

Bitterblue Smith <[email protected]> wrote:

[...]

drivers/net/wireless/realtek/rtw88/rtw8723b.c static void rtw8723b_fill_txdesc_checksum(struct rtw_dev *rtwdev, · line 2360

Quoted 8 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +8 -0
+static void rtw8723b_read_package_type(struct rtw_dev *rtwdev)
+{
+       struct rtw_hal *hal = &rtwdev->hal;
+       u8 val_1fb;
+
+       rtw8723b_efuse_grant(rtwdev, true);
+       rtw_read8_physical_efuse(rtwdev, 0x1fb, &val_1fb);
+       rtw8723b_efuse_grant(rtwdev, false);

In rtw_parse_efuse_map(), we can pass 'phy_map' to read_efuse()?

(quoted diff) +1 -1
-chip->ops->read_efuse(rtwdev, log_map);
+chip->ops->read_efuse(rtwdev, log_map, phy_map);
Quoted 2 lines

As .phy_efuse_size = 512 for RTL7823B, I think it will work.

Yes, that should work.

Quoted 25 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+       switch (u8_get_bits(val_1fb, GENMASK(2, 0))) {

Bit 2~0 seems like PKG_TYPE. Define an enum?

Quoted 9 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +9 -0
+       case 0x4:
+               hal->pkg_type = RTW8723B_PACKAGE_TFBGA79;
+               break;
+       case 0x5:
+               hal->pkg_type = RTW8723B_PACKAGE_TFBGA90;
+               break;
+       case 0x6:
+               hal->pkg_type = RTW8723B_PACKAGE_QFN68;
+               break;

drivers/net/wireless/realtek/rtw88/rtw8723b.c static void rtw8723b_fill_txdesc_checksum(struct rtw_dev *rtwdev, · line 2381

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +10 -0
+       case 0x7:
+               hal->pkg_type = RTW8723B_PACKAGE_TFBGA80;
+               break;
+       default:
+               hal->pkg_type = RTW8723B_PACKAGE_DEFAULT;
+               break;
+       }
+
+       if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO &&
+           u8_get_bits(val_1fb, GENMASK(5, 4)) == 0x2)
Quoted 3 lines

Can you define enums for bit 5-4 and value 0x2?
I'm not sure if vendor driver has some comments pointing out this or not.

I guess bits 5-4 identify the chip variant:

	/* RTL8703AS: 0x1FB[5:4] 2b'10 */
	/* RTL8723BS: 0x1FB[5:4] 2b'11 */
	if ((efuseContent & 0x30) == 0x20) {
		pAdapter->registrypriv.bw_mode &= 0xF0;
		RTW_INFO("This is the case of 8703AS\n");
	}

RTL8703AS appears to be a (cheaper?) version of RTL8723BS. Ten years ago Hans de Goede was saying:

The rtl8703as in reality is a rtl8723bs in a different package. (it has the same sdio-id).

In android the rtl8703as uses the rtl8723bs-vq0 driver instead of the regular rtl8732bs driver. Looking at a diff between the 2 the only difference is that the vq0 driver forces the antenna-path to ODM_RF_PATH_B.

It seems that we can identify the rtl8703as by its package, as it comes in a QNF68 package, where as the rtl8723bs comes in a TFBGA79 package, so we can simply support both in the same driver.

https://github.com/hadess/rtl8723bs/pull/93/changes/ebec0ae8ccedc05a945478926d52c99277f500ee

Quoted 7 lines
Quoted 6 lines
drivers/net/wireless/realtek/rtw88/rtw8723b.c +3 -0
+               rtwdev->efuse.hw_cap.bw &= ~BIT(RTW_CHANNEL_WIDTH_40);
+}
+
 static int rtw8723b_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
 {
        struct rtw_efuse *efuse = &rtwdev->efuse;
#4 lore raw

Hi Bitterblue,

Quoted 82 lines · Bitterblue Smith
Quoted 17 lines · Ping-Ke Shih

Bitterblue Smith <[email protected]> wrote:

[...]

Quoted 10 lines

+static void rtw8723b_read_package_type(struct rtw_dev *rtwdev)
+{
+ struct rtw_hal *hal = &rtwdev->hal;
+ u8 val_1fb;
+
+ rtw8723b_efuse_grant(rtwdev, true);
+ rtw_read8_physical_efuse(rtwdev, 0x1fb, &val_1fb);
+ rtw8723b_efuse_grant(rtwdev, false);

Quoted 6 lines

In rtw_parse_efuse_map(), we can pass 'phy_map' to read_efuse()? -chip->ops->read_efuse(rtwdev, log_map); +chip->ops->read_efuse(rtwdev, log_map, phy_map);

As .phy_efuse_size = 512 for RTL7823B, I think it will work.

Yes, that should work.

Quoted 31 lines
Quoted 5 lines

+
+ switch (u8_get_bits(val_1fb, GENMASK(2, 0))) {

Bit 2~0 seems like PKG_TYPE. Define an enum?

Quoted 12 lines

+ case 0x4:
+ hal->pkg_type = RTW8723B_PACKAGE_TFBGA79;
+ break;
+ case 0x5:
+ hal->pkg_type = RTW8723B_PACKAGE_TFBGA90;
+ break;
+ case 0x6:
+ hal->pkg_type = RTW8723B_PACKAGE_QFN68;
+ break;
+ case 0x7:
+ hal->pkg_type = RTW8723B_PACKAGE_TFBGA80;

Quoted 9 lines

+ break;
+ default:
+ hal->pkg_type = RTW8723B_PACKAGE_DEFAULT;
+ break;
+ }
+
+ if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO &&
+ u8_get_bits(val_1fb, GENMASK(5, 4)) == 0x2)

Quoted 3 lines

Can you define enums for bit 5-4 and value 0x2?
I'm not sure if vendor driver has some comments pointing out this or not.

I guess bits 5-4 identify the chip variant:

/* RTL8703AS: 0x1FB[5:4] 2b'10 */
/* RTL8723BS: 0x1FB[5:4] 2b'11 */
if ((efuseContent & 0x30) == 0x20) {
pAdapter->registrypriv.bw_mode &= 0xF0;
RTW_INFO("This is the case of 8703AS\n");
}

RTL8703AS appears to be a (cheaper?) version of RTL8723BS. Ten years ago Hans de Goede was saying:

The rtl8703as in reality is a rtl8723bs in a different package. (it has the same sdio-id).

In android the rtl8703as uses the rtl8723bs-vq0 driver instead of the regular rtl8732bs driver. Looking at a diff between the 2 the only difference is that the vq0 driver forces the antenna-path to ODM_RF_PATH_B.

Quoted 5 lines

It seems that we can identify the rtl8703as by its package, as it comes in a QNF68 package, where as the rtl8723bs comes in a TFBGA79 package, so we can simply support both in the same driver.

https://github.com/hadess/rtl8723bs/pull/93/changes/ebec0ae8ccedc05a945478926d52c99277f500ee

So 8703AS should work just fine with rtw8723b. The one thing I'm not sure about is antenna path. The vq0 driver hardcodes path B, but the normal driver reads it from efuse, same as rtw88. If some 8703AS boards have it wrong in efuse we might need a quirk. Have you come across such?

Best regards,
Luka Gejak

#5 lore raw
Quoted 90 lines · Luka Gejak

Hi Bitterblue,

Quoted 86 lines · Bitterblue Smith
Quoted 17 lines · Ping-Ke Shih

Bitterblue Smith <[email protected]> wrote:

[...]

Quoted 10 lines

+static void rtw8723b_read_package_type(struct rtw_dev *rtwdev)
+{
+ struct rtw_hal *hal = &rtwdev->hal;
+ u8 val_1fb;
+
+ rtw8723b_efuse_grant(rtwdev, true);
+ rtw_read8_physical_efuse(rtwdev, 0x1fb, &val_1fb);
+ rtw8723b_efuse_grant(rtwdev, false);

Quoted 6 lines

In rtw_parse_efuse_map(), we can pass 'phy_map' to read_efuse()? -chip->ops->read_efuse(rtwdev, log_map); +chip->ops->read_efuse(rtwdev, log_map, phy_map);

As .phy_efuse_size = 512 for RTL7823B, I think it will work.

Yes, that should work.

Quoted 31 lines
Quoted 5 lines

+
+ switch (u8_get_bits(val_1fb, GENMASK(2, 0))) {

Bit 2~0 seems like PKG_TYPE. Define an enum?

Quoted 12 lines

+ case 0x4:
+ hal->pkg_type = RTW8723B_PACKAGE_TFBGA79;
+ break;
+ case 0x5:
+ hal->pkg_type = RTW8723B_PACKAGE_TFBGA90;
+ break;
+ case 0x6:
+ hal->pkg_type = RTW8723B_PACKAGE_QFN68;
+ break;
+ case 0x7:
+ hal->pkg_type = RTW8723B_PACKAGE_TFBGA80;

Quoted 9 lines

+ break;
+ default:
+ hal->pkg_type = RTW8723B_PACKAGE_DEFAULT;
+ break;
+ }
+
+ if (rtw_hci_type(rtwdev) == RTW_HCI_TYPE_SDIO &&
+ u8_get_bits(val_1fb, GENMASK(5, 4)) == 0x2)

Quoted 3 lines

Can you define enums for bit 5-4 and value 0x2?
I'm not sure if vendor driver has some comments pointing out this or not.

I guess bits 5-4 identify the chip variant:

/* RTL8703AS: 0x1FB[5:4] 2b'10 */
/* RTL8723BS: 0x1FB[5:4] 2b'11 */
if ((efuseContent & 0x30) == 0x20) {
pAdapter->registrypriv.bw_mode &= 0xF0;
RTW_INFO("This is the case of 8703AS\n");
}

RTL8703AS appears to be a (cheaper?) version of RTL8723BS. Ten years ago Hans de Goede was saying:

The rtl8703as in reality is a rtl8723bs in a different package. (it has the same sdio-id).

In android the rtl8703as uses the rtl8723bs-vq0 driver instead of the regular rtl8732bs driver. Looking at a diff between the 2 the only difference is that the vq0 driver forces the antenna-path to ODM_RF_PATH_B.

It seems that we can identify the rtl8703as by its package, as it comes in a QNF68 package, where as the rtl8723bs comes in a TFBGA79 package, so we can simply support both in the same driver.

Quoted 7 lines
Quoted 1 line

https://github.com/hadess/rtl8723bs/pull/93/changes/ebec0ae8ccedc05a945478926d52c99277f500ee

So 8703AS should work just fine with rtw8723b. The one thing I'm not sure about is antenna path. The vq0 driver hardcodes path B, but the normal driver reads it from efuse, same as rtw88. If some 8703AS boards have it wrong in efuse we might need a quirk. Have you come across such?

No, I only have RTL8723BU.

Quoted 2 lines

Best regards,
Luka Gejak