wifi: rtw89: update suspend/resume for different generation
authorChin-Yen Lee <timlee@realtek.com>
Sat, 2 Mar 2024 00:58:26 +0000 (08:58 +0800)
committerKalle Valo <kvalo@kernel.org>
Tue, 5 Mar 2024 18:56:43 +0000 (20:56 +0200)
The setting during suspend or resume is different between different
generation, so update it.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240302005828.13666-6-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/pci.h
drivers/net/wireless/realtek/rtw89/pci_be.c
drivers/net/wireless/realtek/rtw89/reg.h
drivers/net/wireless/realtek/rtw89/rtw8922ae.c

index 4a817dd9822e952f6372ab7620dd6e227cb65e5b..a63b6b7c9bfaf6fcf9d871b980b687ee463098c3 100644 (file)
 #define B_BE_SER_L1SUB_IMR BIT(1)
 #define B_BE_SER_PMU_IMR BIT(0)
 
+#define R_BE_REG_PL1_ISR 0x34B4
+
 #define R_BE_RX_APPEND_MODE 0x8920
 #define B_BE_APPEND_OFFSET_MASK GENMASK(23, 16)
 #define B_BE_APPEND_LEN_MASK GENMASK(15, 0)
@@ -1558,6 +1560,7 @@ static inline bool rtw89_pci_ltr_is_err_reg_val(u32 val)
 }
 
 extern const struct dev_pm_ops rtw89_pm_ops;
+extern const struct dev_pm_ops rtw89_pm_ops_be;
 extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set;
 extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set_v1;
 extern const struct rtw89_pci_ch_dma_addr_set rtw89_pci_ch_dma_addr_set_be;
index 1a3f02c687f72a360624d7ea7054295fbd6440d8..7cc32822296528387af769b8d9cbba564502a6ce 100644 (file)
@@ -550,6 +550,46 @@ static int rtw89_pci_lv1rst_start_dma_be(struct rtw89_dev *rtwdev)
        return 0;
 }
 
+static int __maybe_unused rtw89_pci_suspend_be(struct device *dev)
+{
+       struct ieee80211_hw *hw = dev_get_drvdata(dev);
+       struct rtw89_dev *rtwdev = hw->priv;
+
+       rtw89_write32_set(rtwdev, R_BE_RSV_CTRL, B_BE_WLOCK_1C_BIT6);
+       rtw89_write32_set(rtwdev, R_BE_RSV_CTRL, B_BE_R_DIS_PRST);
+       rtw89_write32_clr(rtwdev, R_BE_RSV_CTRL, B_BE_WLOCK_1C_BIT6);
+       rtw89_write32_set(rtwdev, R_BE_PCIE_FRZ_CLK, B_BE_PCIE_FRZ_REG_RST);
+       rtw89_write32_clr(rtwdev, R_BE_REG_PL1_MASK, B_BE_SER_PM_MASTER_IMR);
+       return 0;
+}
+
+static int __maybe_unused rtw89_pci_resume_be(struct device *dev)
+{
+       struct ieee80211_hw *hw = dev_get_drvdata(dev);
+       struct rtw89_dev *rtwdev = hw->priv;
+       u32 polling;
+       int ret;
+
+       rtw89_write32_set(rtwdev, R_BE_RSV_CTRL, B_BE_WLOCK_1C_BIT6);
+       rtw89_write32_clr(rtwdev, R_BE_RSV_CTRL, B_BE_R_DIS_PRST);
+       rtw89_write32_clr(rtwdev, R_BE_RSV_CTRL, B_BE_WLOCK_1C_BIT6);
+       rtw89_write32_clr(rtwdev, R_BE_PCIE_FRZ_CLK, B_BE_PCIE_FRZ_REG_RST);
+       rtw89_write32_clr(rtwdev, R_BE_SER_PL1_CTRL, B_BE_PL1_SER_PL1_EN);
+
+       ret = read_poll_timeout_atomic(rtw89_read32, polling, !polling, 1, 1000,
+                                      false, rtwdev, R_BE_REG_PL1_ISR);
+       if (ret)
+               rtw89_warn(rtwdev, "[ERR] PCIE SER clear polling fail\n");
+
+       rtw89_write32_set(rtwdev, R_BE_SER_PL1_CTRL, B_BE_PL1_SER_PL1_EN);
+       rtw89_write32_set(rtwdev, R_BE_REG_PL1_MASK, B_BE_SER_PM_MASTER_IMR);
+
+       return 0;
+}
+
+SIMPLE_DEV_PM_OPS(rtw89_pm_ops_be, rtw89_pci_suspend_be, rtw89_pci_resume_be);
+EXPORT_SYMBOL(rtw89_pm_ops_be);
+
 const struct rtw89_pci_gen_def rtw89_pci_gen_be = {
        .isr_rdu = B_BE_RDU_CH1_INT | B_BE_RDU_CH0_INT,
        .isr_halt_c2h = B_BE_HALT_C2H_INT,
index 088d39202ca248f2be83ac3b8323cfbcfa087585..72e448e91b6fefe1feff4ced7a4f162eef2a4df5 100644 (file)
 #define B_BE_SYM_PADPDN_WL_RFC1_1P3 BIT(6)
 #define B_BE_SYM_PADPDN_WL_RFC0_1P3 BIT(5)
 
+#define R_BE_RSV_CTRL 0x001C
+#define B_BE_HR_BE_DBG GENMASK(23, 12)
+#define B_BE_R_SYM_DIS_PCIE_FLR BIT(9)
+#define B_BE_R_EN_HRST_PWRON BIT(8)
+#define B_BE_LOCK_ALL_EN BIT(7)
+#define B_BE_R_DIS_PRST BIT(6)
+#define B_BE_WLOCK_1C_BIT6 BIT(5)
+#define B_BE_WLOCK_40 BIT(4)
+#define B_BE_WLOCK_08 BIT(3)
+#define B_BE_WLOCK_04 BIT(2)
+#define B_BE_WLOCK_00 BIT(1)
+#define B_BE_WLOCK_ALL BIT(0)
+
 #define R_BE_AFE_LDO_CTRL 0x0020
 #define B_BE_FORCE_MACBBBT_PWR_ON BIT(31)
 #define B_BE_R_SYM_WLPOFF_P4_PC_EN BIT(28)
index 9f46fb16610554e1a52b22f86a28fcb9bb2f5456..4981b657bd7b0e1409a3aad682171dc6048222f9 100644 (file)
@@ -80,7 +80,7 @@ static struct pci_driver rtw89_8922ae_driver = {
        .id_table       = rtw89_8922ae_id_table,
        .probe          = rtw89_pci_probe,
        .remove         = rtw89_pci_remove,
-       .driver.pm      = &rtw89_pm_ops,
+       .driver.pm      = &rtw89_pm_ops_be,
 };
 module_pci_driver(rtw89_8922ae_driver);