wifi: rtw89: pci: add pre_deinit to be called after probe complete
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 10 Nov 2023 01:23:15 +0000 (09:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:57 +0000 (10:45 +0200)
commit 9e1aff437a560cd72cb6a60ee33fe162b0afdaf1 upstream.

At probe stage, we only do partial initialization to enable ability to
download firmware and read capabilities. After that, we use this pre_deinit
to disable HCI to save power.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231110012319.12727-4-pkshih@realtek.com
[ Zenm: The rtw89 driver in recent kernel versions supports both Wi-Fi 6/6E
        and Wi-Fi 7, however the rtw89 driver in kernel 6.6 supports
        Wi-Fi 6/6E only, so remove the unnecessary code for Wi-Fi 7 from
        the upstream patch to make it apply on 6.6.y. ]
Signed-off-by: Zenm Chen <zenmchen@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/pci.c

index 535393eca5641cc7f82b8bb84de08f2c71cf32da..d1d8fd812cbf6d5baa5b14d67788183d53d71e22 100644 (file)
@@ -3807,6 +3807,8 @@ static int rtw89_chip_efuse_info_setup(struct rtw89_dev *rtwdev)
        rtw89_core_setup_phycap(rtwdev);
        rtw89_core_setup_rfe_parms(rtwdev);
 
+       rtw89_hci_mac_pre_deinit(rtwdev);
+
        rtw89_mac_pwr_off(rtwdev);
 
        return 0;
index ee6ae2a0c798151ea66ad41252d1a3d9b18eb7a5..16aad0f8393ab707129c2a606f9827582151a1d3 100644 (file)
@@ -2989,6 +2989,7 @@ struct rtw89_hci_ops {
        void (*write32)(struct rtw89_dev *rtwdev, u32 addr, u32 data);
 
        int (*mac_pre_init)(struct rtw89_dev *rtwdev);
+       int (*mac_pre_deinit)(struct rtw89_dev *rtwdev);
        int (*mac_post_init)(struct rtw89_dev *rtwdev);
        int (*deinit)(struct rtw89_dev *rtwdev);
 
@@ -4515,6 +4516,11 @@ static inline void rtw89_hci_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
        return rtwdev->hci.ops->tx_kick_off(rtwdev, txch);
 }
 
+static inline int rtw89_hci_mac_pre_deinit(struct rtw89_dev *rtwdev)
+{
+       return rtwdev->hci.ops->mac_pre_deinit(rtwdev);
+}
+
 static inline void rtw89_hci_flush_queues(struct rtw89_dev *rtwdev, u32 queues,
                                          bool drop)
 {
index 98af64444d3ebc5564aa272dcbc32ffea6841f8f..7787159dd26fba681f0aba4ccbd245966546731b 100644 (file)
@@ -2568,6 +2568,13 @@ static int rtw89_pci_ops_mac_pre_init(struct rtw89_dev *rtwdev)
        return 0;
 }
 
+static int rtw89_pci_ops_mac_pre_deinit(struct rtw89_dev *rtwdev)
+{
+       rtw89_pci_power_wake(rtwdev, false);
+
+       return 0;
+}
+
 int rtw89_pci_ltr_set(struct rtw89_dev *rtwdev, bool en)
 {
        u32 val;
@@ -3812,6 +3819,7 @@ static const struct rtw89_hci_ops rtw89_pci_ops = {
        .write32        = rtw89_pci_ops_write32,
 
        .mac_pre_init   = rtw89_pci_ops_mac_pre_init,
+       .mac_pre_deinit = rtw89_pci_ops_mac_pre_deinit,
        .mac_post_init  = rtw89_pci_ops_mac_post_init,
        .deinit         = rtw89_pci_ops_deinit,