public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: Ping-Ke Shih <pkshih@realtek.com>
Subject: [PATCH rtw-next v3 10/14] wifi: rtw89: Fix rtw89_mac_power_switch() for USB
Date: Fri, 20 Jun 2025 22:02:14 +0300	[thread overview]
Message-ID: <3799b797-7d9a-4e8d-b9d5-73db3d3eccf8@gmail.com> (raw)
In-Reply-To: <d055bd81-6c79-46f5-8d6d-62185cc65630@gmail.com>

Clear some bits in some registers in order to allow RTL8851BU to power
on. This is done both when powering on and when powering off because
that's what the vendor driver does.

Also tested with RTL8832BU and RTL8832CU.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
v2:
 - Put the new code in a function.

v3:
 - Delete empty line.
 - Add more information to the commit message.
---
 drivers/net/wireless/realtek/rtw89/mac.c | 19 +++++++++++++++++++
 drivers/net/wireless/realtek/rtw89/reg.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
index c018071c94ee..96c54d1c658e 100644
--- a/drivers/net/wireless/realtek/rtw89/mac.c
+++ b/drivers/net/wireless/realtek/rtw89/mac.c
@@ -1440,6 +1440,23 @@ void rtw89_mac_notify_wake(struct rtw89_dev *rtwdev)
 	rtw89_mac_send_rpwm(rtwdev, state, true);
 }
 
+static void rtw89_mac_power_switch_boot_mode(struct rtw89_dev *rtwdev)
+{
+	u32 boot_mode;
+
+	if (rtwdev->hci.type != RTW89_HCI_TYPE_USB)
+		return;
+
+	boot_mode = rtw89_read32_mask(rtwdev, R_AX_GPIO_MUXCFG, B_AX_BOOT_MODE);
+	if (!boot_mode)
+		return;
+
+	rtw89_write32_clr(rtwdev, R_AX_SYS_PW_CTRL, B_AX_APFN_ONMAC);
+	rtw89_write32_clr(rtwdev, R_AX_SYS_STATUS1, B_AX_AUTO_WLPON);
+	rtw89_write32_clr(rtwdev, R_AX_GPIO_MUXCFG, B_AX_BOOT_MODE);
+	rtw89_write32_clr(rtwdev, R_AX_RSV_CTRL, B_AX_R_DIS_PRST);
+}
+
 static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
 {
 #define PWR_ACT 1
@@ -1450,6 +1467,8 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
 	int ret;
 	u8 val;
 
+	rtw89_mac_power_switch_boot_mode(rtwdev);
+
 	if (on) {
 		cfg_seq = chip->pwr_on_seq;
 		cfg_func = chip->ops->pwr_on_func;
diff --git a/drivers/net/wireless/realtek/rtw89/reg.h b/drivers/net/wireless/realtek/rtw89/reg.h
index c680441232fb..be4a8486c9f8 100644
--- a/drivers/net/wireless/realtek/rtw89/reg.h
+++ b/drivers/net/wireless/realtek/rtw89/reg.h
@@ -183,6 +183,7 @@
 
 #define R_AX_SYS_STATUS1 0x00F4
 #define B_AX_SEL_0XC0_MASK GENMASK(17, 16)
+#define B_AX_AUTO_WLPON BIT(10)
 #define B_AX_PAD_HCI_SEL_V2_MASK GENMASK(5, 3)
 #define MAC_AX_HCI_SEL_SDIO_UART 0
 #define MAC_AX_HCI_SEL_MULTI_USB 1
-- 
2.49.0


  parent reply	other threads:[~2025-06-20 19:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 18:51 [PATCH rtw-next v3 00/14] wifi: rtw89: Add support for USB devices Bitterblue Smith
2025-06-20 18:53 ` [PATCH rtw-next v3 01/14] wifi: rtw89: 8851b: Accept USB devices and load their MAC address Bitterblue Smith
2025-06-20 18:54 ` [PATCH rtw-next v3 02/14] wifi: rtw89: Make dle_mem in rtw89_chip_info an array Bitterblue Smith
2025-06-24  5:42   ` Ping-Ke Shih
2025-06-20 18:56 ` [PATCH rtw-next v3 03/14] wifi: rtw89: Make hfc_param_ini " Bitterblue Smith
2025-06-24  5:45   ` Ping-Ke Shih
2025-06-20 18:56 ` [PATCH rtw-next v3 04/14] wifi: rtw89: Add rtw8851b_dle_mem_usb{2,3} Bitterblue Smith
2025-06-20 18:57 ` [PATCH rtw-next v3 05/14] wifi: rtw89: Add rtw8851b_hfc_param_ini_usb Bitterblue Smith
2025-06-20 18:58 ` [PATCH rtw-next v3 06/14] wifi: rtw89: Disable deep power saving for USB/SDIO Bitterblue Smith
2025-06-24  5:50   ` Ping-Ke Shih
2025-06-20 18:59 ` [PATCH rtw-next v3 07/14] wifi: rtw89: Add extra TX headroom for USB Bitterblue Smith
2025-06-20 19:00 ` [PATCH rtw-next v3 08/14] wifi: rtw89: Hide some errors when the device is unplugged Bitterblue Smith
2025-06-20 19:01 ` [PATCH rtw-next v3 09/14] wifi: rtw89: 8851b: Modify rtw8851b_pwr_{on,off}_func() for USB Bitterblue Smith
2025-06-24  5:51   ` Ping-Ke Shih
2025-06-20 19:02 ` Bitterblue Smith [this message]
2025-06-24  5:52   ` [PATCH rtw-next v3 10/14] wifi: rtw89: Fix rtw89_mac_power_switch() " Ping-Ke Shih
2025-06-20 19:03 ` [PATCH rtw-next v3 11/14] wifi: rtw89: Add some definitions " Bitterblue Smith
2025-06-20 19:04 ` [PATCH rtw-next v3 12/14] wifi: rtw89: Add usb.{c,h} Bitterblue Smith
2025-06-23 20:08   ` Bitterblue Smith
2025-06-24  6:18   ` Ping-Ke Shih
2025-06-20 19:05 ` [PATCH rtw-next v3 13/14] wifi: rtw89: Add rtw8851bu.c Bitterblue Smith
2025-06-20 19:05 ` [PATCH rtw-next v3 14/14] wifi: rtw89: Enable the new USB modules Bitterblue Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3799b797-7d9a-4e8d-b9d5-73db3d3eccf8@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox