wifi: rtw89: 8922a: add chip_ops::bb_preinit to enable BB before downloading firmware
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 1 Sep 2023 07:39:54 +0000 (15:39 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 7 Sep 2023 05:57:16 +0000 (08:57 +0300)
Before downloading firmware for BB MCU, call this ops to enable baseband
hardware.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230901073956.54203-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/mac.c
drivers/net/wireless/realtek/rtw89/rtw8851b.c
drivers/net/wireless/realtek/rtw89/rtw8852a.c
drivers/net/wireless/realtek/rtw89/rtw8852b.c
drivers/net/wireless/realtek/rtw89/rtw8852c.c

index b232bb3a3cf8a1f5f50ca61daeb4d7d4aedc36b0..2eaf1df205ecf2ad88976e3cb63215d4e0217d4b 100644 (file)
@@ -3032,6 +3032,7 @@ struct rtw89_hci_info {
 struct rtw89_chip_ops {
        int (*enable_bb_rf)(struct rtw89_dev *rtwdev);
        int (*disable_bb_rf)(struct rtw89_dev *rtwdev);
+       void (*bb_preinit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
        void (*bb_reset)(struct rtw89_dev *rtwdev,
                         enum rtw89_phy_idx phy_idx);
        void (*bb_sethw)(struct rtw89_dev *rtwdev);
@@ -5113,6 +5114,15 @@ static inline void rtw89_chip_rfe_gpio(struct rtw89_dev *rtwdev)
                chip->ops->rfe_gpio(rtwdev);
 }
 
+static inline
+void rtw89_chip_bb_preinit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
+{
+       const struct rtw89_chip_info *chip = rtwdev->chip;
+
+       if (chip->ops->bb_preinit)
+               chip->ops->bb_preinit(rtwdev, phy_idx);
+}
+
 static inline void rtw89_chip_bb_sethw(struct rtw89_dev *rtwdev)
 {
        const struct rtw89_chip_info *chip = rtwdev->chip;
index 9a03f7fa9188338a5f49f9f7061d9126d615da21..1b57c356a7a5cba44591ad4030689172474f09f3 100644 (file)
@@ -3607,6 +3607,12 @@ int rtw89_mac_partial_init(struct rtw89_dev *rtwdev, bool include_bb)
 
        rtw89_mac_ctrl_hci_dma_trx(rtwdev, true);
 
+       if (include_bb) {
+               rtw89_chip_bb_preinit(rtwdev, RTW89_PHY_0);
+               if (rtwdev->dbcc_en)
+                       rtw89_chip_bb_preinit(rtwdev, RTW89_PHY_1);
+       }
+
        ret = rtw89_mac_dmac_pre_init(rtwdev);
        if (ret)
                return ret;
index 401c2b68dd5fb0c0c446caa3b394e9e3e0199992..7c14638b6474ccf9ff6913c312a0535c26057139 100644 (file)
@@ -2280,6 +2280,7 @@ static int rtw8851b_mac_disable_bb_rf(struct rtw89_dev *rtwdev)
 static const struct rtw89_chip_ops rtw8851b_chip_ops = {
        .enable_bb_rf           = rtw8851b_mac_enable_bb_rf,
        .disable_bb_rf          = rtw8851b_mac_disable_bb_rf,
+       .bb_preinit             = NULL,
        .bb_reset               = rtw8851b_bb_reset,
        .bb_sethw               = rtw8851b_bb_sethw,
        .read_rf                = rtw89_phy_read_rf_v1,
index 7810f72e8457d06d81f437c8a4b4ff4dfe2585e4..fa5ed7b42af64a4d52a6417a6de662add6c46192 100644 (file)
@@ -2025,6 +2025,7 @@ static const struct wiphy_wowlan_support rtw_wowlan_stub_8852a = {
 static const struct rtw89_chip_ops rtw8852a_chip_ops = {
        .enable_bb_rf           = rtw89_mac_enable_bb_rf,
        .disable_bb_rf          = rtw89_mac_disable_bb_rf,
+       .bb_preinit             = NULL,
        .bb_reset               = rtw8852a_bb_reset,
        .bb_sethw               = rtw8852a_bb_sethw,
        .read_rf                = rtw89_phy_read_rf,
index 38a00c26e2ad66431fef2ec658cce80841c51b3b..b2bd843451a29e3bdf6e60c4b1b968c1b626b9bf 100644 (file)
@@ -2449,6 +2449,7 @@ static int rtw8852b_mac_disable_bb_rf(struct rtw89_dev *rtwdev)
 static const struct rtw89_chip_ops rtw8852b_chip_ops = {
        .enable_bb_rf           = rtw8852b_mac_enable_bb_rf,
        .disable_bb_rf          = rtw8852b_mac_disable_bb_rf,
+       .bb_preinit             = NULL,
        .bb_reset               = rtw8852b_bb_reset,
        .bb_sethw               = rtw8852b_bb_sethw,
        .read_rf                = rtw89_phy_read_rf_v1,
index 297ce4fe6d21793c5bfdc022dba37464ff47f21b..7f80e0bf40a4f5f486dd4784446755610483867c 100644 (file)
@@ -2760,6 +2760,7 @@ static const struct wiphy_wowlan_support rtw_wowlan_stub_8852c = {
 static const struct rtw89_chip_ops rtw8852c_chip_ops = {
        .enable_bb_rf           = rtw8852c_mac_enable_bb_rf,
        .disable_bb_rf          = rtw8852c_mac_disable_bb_rf,
+       .bb_preinit             = NULL,
        .bb_reset               = rtw8852c_bb_reset,
        .bb_sethw               = rtw8852c_bb_sethw,
        .read_rf                = rtw89_phy_read_rf_v1,