Skip to content

Commit

Permalink
Merge pull request #9684 from heitbaum/rtw
Browse files Browse the repository at this point in the history
linux: wifi: rtw88: update patches as they have now been accepted int…
  • Loading branch information
chewitt authored Jan 14, 2025
2 parents bb22f8d + 63c3ce5 commit a7d1729
Show file tree
Hide file tree
Showing 6 changed files with 801 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 93b3a45645f13290745ef58bf99ad0877af29381 Mon Sep 17 00:00:00 2001
From: Bitterblue Smith <[email protected]>
Date: Mon, 23 Dec 2024 17:01:57 +0200
Subject: [PATCH 36/41] wifi: rtl8xxxu: Fix RTL8188EU firmware upload block
size

A user reports that the firmware upload consistently fails when it's
uploaded in chunks of 128 bytes, but it works when uploaded in chunks
of 196 bytes. The official driver uses 196 bytes also.

Link: https://github.com/a5a5aa555oo/rtl8xxxu/issues/2
Signed-off-by: Bitterblue Smith <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
---
drivers/net/wireless/realtek/rtl8xxxu/8188e.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/8188e.c b/drivers/net/wireless/realtek/rtl8xxxu/8188e.c
index 3d04df0f5bf4..766a7a7c7d28 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/8188e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/8188e.c
@@ -1860,7 +1860,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = {
.set_crystal_cap = rtl8188f_set_crystal_cap,
.cck_rssi = rtl8188e_cck_rssi,
.led_classdev_brightness_set = rtl8188eu_led_brightness_set,
- .writeN_block_size = 128,
+ .writeN_block_size = 196,
.rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16),
.tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
.has_tx_report = 1,
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
From fc57e8bef80bbfaba1ce0554f3b3c8df825e30b9 Mon Sep 17 00:00:00 2001
From: Bitterblue Smith <[email protected]>
Date: Wed, 1 Jan 2025 18:16:32 +0200
Subject: [PATCH 37/41] wifi: rtw88: Add USB PHY configuration

Add some extra configuration for USB devices. Currently only RTL8822BU
version (cut) D needs this. The new code makes use of the existing
usb3_param_8822b array from rtw8822b.c.

A user reported that TP-Link Archer T3U in USB 3 mode was randomly
disconnecting from USB:

[ 26.036502] usb 2-2: new SuperSpeed USB device number 3 using xhci_hcd
...
[ 27.576491] usb 2-2: USB disconnect, device number 3
[ 28.621528] usb 2-2: new SuperSpeed USB device number 4 using xhci_hcd
...
[ 45.984521] usb 2-2: USB disconnect, device number 4
...
[ 46.845585] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
...
[ 94.400380] usb 2-2: USB disconnect, device number 5
...
[ 95.590421] usb 2-2: new SuperSpeed USB device number 6 using xhci_hcd

This patch fixes that.

Link: https://github.com/lwfinger/rtw88/issues/262
Signed-off-by: Bitterblue Smith <[email protected]>
Acked-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
---
drivers/net/wireless/realtek/rtw88/reg.h | 10 ++++
drivers/net/wireless/realtek/rtw88/usb.c | 68 ++++++++++++++++++++++++
2 files changed, 78 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h
index e4d506cf9c33..95a39ae74cd3 100644
--- a/drivers/net/wireless/realtek/rtw88/reg.h
+++ b/drivers/net/wireless/realtek/rtw88/reg.h
@@ -871,7 +871,17 @@

#define REG_USB_MOD 0xf008
#define REG_USB3_RXITV 0xf050
+#define REG_USB2_PHY_ADR 0xfe40
+#define REG_USB2_PHY_DAT 0xfe41
+#define REG_USB2_PHY_CMD 0xfe42
+#define BIT_USB2_PHY_CMD_TRG 0x81
#define REG_USB_HRPWM 0xfe58
+#define REG_USB3_PHY_ADR 0xff0c
+#define REG_USB3_PHY_DAT_L 0xff0d
+#define REG_USB3_PHY_DAT_H 0xff0e
+#define BIT_USB3_PHY_ADR_WR BIT(7)
+#define BIT_USB3_PHY_ADR_RD BIT(6)
+#define BIT_USB3_PHY_ADR_MASK GENMASK(5, 0)

#define RF_MODE 0x00
#define RF_MODOPT 0x01
diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
index 1572b61cf877..c4908db4ff0e 100644
--- a/drivers/net/wireless/realtek/rtw88/usb.c
+++ b/drivers/net/wireless/realtek/rtw88/usb.c
@@ -1128,6 +1128,71 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
return rtw_usb_switch_mode_new(rtwdev);
}

+#define USB_REG_PAGE 0xf4
+#define USB_PHY_PAGE0 0x9b
+#define USB_PHY_PAGE1 0xbb
+
+static void rtw_usb_phy_write(struct rtw_dev *rtwdev, u8 addr, u16 data,
+ enum usb_device_speed speed)
+{
+ if (speed == USB_SPEED_SUPER) {
+ rtw_write8(rtwdev, REG_USB3_PHY_DAT_L, data & 0xff);
+ rtw_write8(rtwdev, REG_USB3_PHY_DAT_H, data >> 8);
+ rtw_write8(rtwdev, REG_USB3_PHY_ADR, addr | BIT_USB3_PHY_ADR_WR);
+ } else if (speed == USB_SPEED_HIGH) {
+ rtw_write8(rtwdev, REG_USB2_PHY_DAT, data);
+ rtw_write8(rtwdev, REG_USB2_PHY_ADR, addr);
+ rtw_write8(rtwdev, REG_USB2_PHY_CMD, BIT_USB2_PHY_CMD_TRG);
+ }
+}
+
+static void rtw_usb_page_switch(struct rtw_dev *rtwdev,
+ enum usb_device_speed speed, u8 page)
+{
+ if (speed == USB_SPEED_SUPER)
+ return;
+
+ rtw_usb_phy_write(rtwdev, USB_REG_PAGE, page, speed);
+}
+
+static void rtw_usb_phy_cfg(struct rtw_dev *rtwdev,
+ enum usb_device_speed speed)
+{
+ const struct rtw_intf_phy_para *para = NULL;
+ u16 offset;
+
+ if (!rtwdev->chip->intf_table)
+ return;
+
+ if (speed == USB_SPEED_SUPER)
+ para = rtwdev->chip->intf_table->usb3_para;
+ else if (speed == USB_SPEED_HIGH)
+ para = rtwdev->chip->intf_table->usb2_para;
+
+ if (!para)
+ return;
+
+ for ( ; para->offset != 0xffff; para++) {
+ if (!(para->cut_mask & BIT(rtwdev->hal.cut_version)))
+ continue;
+
+ offset = para->offset;
+
+ if (para->ip_sel == RTW_IP_SEL_MAC) {
+ rtw_write8(rtwdev, offset, para->value);
+ } else {
+ if (offset > 0x100)
+ rtw_usb_page_switch(rtwdev, speed, USB_PHY_PAGE1);
+ else
+ rtw_usb_page_switch(rtwdev, speed, USB_PHY_PAGE0);
+
+ offset &= 0xff;
+
+ rtw_usb_phy_write(rtwdev, offset, para->value, speed);
+ }
+ }
+}
+
int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct rtw_dev *rtwdev;
@@ -1183,6 +1248,9 @@ int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
goto err_destroy_rxwq;
}

+ rtw_usb_phy_cfg(rtwdev, USB_SPEED_HIGH);
+ rtw_usb_phy_cfg(rtwdev, USB_SPEED_SUPER);
+
ret = rtw_usb_switch_mode(rtwdev);
if (ret) {
/* Not a fail, but we do need to skip rtw_register_hw. */
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
From 254af62d5fc0f34512854eabc46591f48d387cbb Mon Sep 17 00:00:00 2001
From: Bitterblue Smith <[email protected]>
Date: Wed, 1 Jan 2025 18:27:35 +0200
Subject: [PATCH 38/41] wifi: rtw88: Delete rf_type member of struct
rtw_sta_info

It's not used for anything.

Signed-off-by: Bitterblue Smith <[email protected]>
Acked-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
---
drivers/net/wireless/realtek/rtw88/main.c | 9 ++-------
drivers/net/wireless/realtek/rtw88/main.h | 1 -
2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index e91530ed05a0..6993f93c8f06 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -1217,7 +1217,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
u8 wireless_set;
u8 bw_mode;
u8 rate_id;
- u8 rf_type = RF_1T1R;
u8 stbc_en = 0;
u8 ldpc_en = 0;
u8 tx_num = 1;
@@ -1302,13 +1301,10 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
break;
}

- if (sta->deflink.vht_cap.vht_supported && ra_mask & 0xffc00000) {
+ if (sta->deflink.vht_cap.vht_supported && ra_mask & 0xffc00000)
tx_num = 2;
- rf_type = RF_2T2R;
- } else if (sta->deflink.ht_cap.ht_supported && ra_mask & 0xfff00000) {
+ else if (sta->deflink.ht_cap.ht_supported && ra_mask & 0xfff00000)
tx_num = 2;
- rf_type = RF_2T2R;
- }

rate_id = get_rate_id(wireless_set, bw_mode, tx_num);

@@ -1319,7 +1315,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
si->bw_mode = bw_mode;
si->stbc_en = stbc_en;
si->ldpc_en = ldpc_en;
- si->rf_type = rf_type;
si->sgi_enable = is_support_sgi;
si->vht_enable = is_vht_enable;
si->ra_mask = ra_mask;
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 65c7acea41af..6ba9e0dcf9fd 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -757,7 +757,6 @@ struct rtw_sta_info {
u8 mac_id;
u8 rate_id;
enum rtw_bandwidth bw_mode;
- enum rtw_rf_type rf_type;
u8 stbc_en:2;
u8 ldpc_en:2;
bool sgi_enable;
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
From 62acd2ac82a8d5d13be9da982aad01bfd8260214 Mon Sep 17 00:00:00 2001
From: Vasily Khoruzhick <[email protected]>
Date: Thu, 2 Jan 2025 23:50:53 -0800
Subject: [PATCH 39/41] wifi: rtw88: 8703b: Fix RX/TX issues

Fix 3 typos in 8703b driver. 2 typos in calibration routines are not
fatal and do not seem to have any impact, just fix them to match vendor
driver.

However the last one in rtw8703b_set_channel_bb() clears too many bits
in REG_OFDM0_TX_PSD_NOISE, causing TX and RX issues (neither rate goes
above MCS0-MCS1). Vendor driver clears only 2 most significant bits.

With the last typo fixed, the driver is able to reach MCS7 on Pinebook

Cc: [email protected]
Fixes: 9bb762b3a957 ("wifi: rtw88: Add definitions for 8703b chip")
Signed-off-by: Vasily Khoruzhick <[email protected]>
Acked-by: Ping-Ke Shih <[email protected]>
Tested-by: Fiona Klute <[email protected]>
Tested-by: Andrey Skvortsov <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
---
drivers/net/wireless/realtek/rtw88/rtw8703b.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8703b.c b/drivers/net/wireless/realtek/rtw88/rtw8703b.c
index a19b94d022ee..1d232adbdd7e 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8703b.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8703b.c
@@ -903,7 +903,7 @@ static void rtw8703b_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
rtw_write32_mask(rtwdev, REG_FPGA0_RFMOD, BIT_MASK_RFMOD, 0x0);
rtw_write32_mask(rtwdev, REG_FPGA1_RFMOD, BIT_MASK_RFMOD, 0x0);
rtw_write32_mask(rtwdev, REG_OFDM0_TX_PSD_NOISE,
- GENMASK(31, 20), 0x0);
+ GENMASK(31, 30), 0x0);
rtw_write32(rtwdev, REG_BBRX_DFIR, 0x4A880000);
rtw_write32(rtwdev, REG_OFDM0_A_TX_AFE, 0x19F60000);
break;
@@ -1198,9 +1198,9 @@ static u8 rtw8703b_iqk_rx_path(struct rtw_dev *rtwdev,
rtw_write32(rtwdev, REG_RXIQK_TONE_A_11N, 0x38008c1c);
rtw_write32(rtwdev, REG_TX_IQK_TONE_B, 0x38008c1c);
rtw_write32(rtwdev, REG_RX_IQK_TONE_B, 0x38008c1c);
- rtw_write32(rtwdev, REG_TXIQK_PI_A_11N, 0x8216000f);
+ rtw_write32(rtwdev, REG_TXIQK_PI_A_11N, 0x8214030f);
rtw_write32(rtwdev, REG_RXIQK_PI_A_11N, 0x28110000);
- rtw_write32(rtwdev, REG_TXIQK_PI_B, 0x28110000);
+ rtw_write32(rtwdev, REG_TXIQK_PI_B, 0x82110000);
rtw_write32(rtwdev, REG_RXIQK_PI_B, 0x28110000);

/* LOK setting */
@@ -1372,7 +1372,7 @@ void rtw8703b_iqk_fill_a_matrix(struct rtw_dev *rtwdev, const s32 result[])
return;

tmp_rx_iqi |= FIELD_PREP(BIT_MASK_RXIQ_S1_X, result[IQK_S1_RX_X]);
- tmp_rx_iqi |= FIELD_PREP(BIT_MASK_RXIQ_S1_Y1, result[IQK_S1_RX_X]);
+ tmp_rx_iqi |= FIELD_PREP(BIT_MASK_RXIQ_S1_Y1, result[IQK_S1_RX_Y]);
rtw_write32(rtwdev, REG_A_RXIQI, tmp_rx_iqi);
rtw_write32_mask(rtwdev, REG_RXIQK_MATRIX_LSB_11N, BIT_MASK_RXIQ_S1_Y2,
BIT_SET_RXIQ_S1_Y2(result[IQK_S1_RX_Y]));
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From f8d47d06677264fbb7d603f1524b9fe4937be0f8 Mon Sep 17 00:00:00 2001
From: Fiona Klute <[email protected]>
Date: Mon, 6 Jan 2025 15:54:34 +0200
Subject: [PATCH 40/41] wifi: rtw88: sdio: Fix disconnection after beacon loss

This is the equivalent of commit 28818b4d871b ("wifi: rtw88: usb: Fix
disconnection after beacon loss") for SDIO chips.
Tested on Pinephone (RTL8723CS), random disconnections became rare,
instead of a frequent nuisance.

Cc: [email protected]
Signed-off-by: Fiona Klute <[email protected]>
Tested-by: Vasily Khoruzhick <[email protected]> # Tested on Pinebook
Acked-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
---
drivers/net/wireless/realtek/rtw88/sdio.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c
index 799230eb5f16..e024061bdbf7 100644
--- a/drivers/net/wireless/realtek/rtw88/sdio.c
+++ b/drivers/net/wireless/realtek/rtw88/sdio.c
@@ -1192,6 +1192,8 @@ static void rtw_sdio_indicate_tx_status(struct rtw_dev *rtwdev,
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_hw *hw = rtwdev->hw;

+ skb_pull(skb, rtwdev->chip->tx_pkt_desc_sz);
+
/* enqueue to wait for tx report */
if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
rtw_tx_report_enqueue(rtwdev, skb, tx_data->sn);
--
2.43.0

Loading

0 comments on commit a7d1729

Please sign in to comment.