wifi: rtw89: mac: define DMA channel mask to avoid unsupported channels
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 27 Sep 2022 06:26:04 +0000 (14:26 +0800)
committerKalle Valo <kvalo@kernel.org>
Wed, 28 Sep 2022 06:45:57 +0000 (09:45 +0300)
Six channels are unsupported by 8852b, so mask them out to prevent to
access undefined registers in this chip.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220927062611.30484-3-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/mac.c
drivers/net/wireless/realtek/rtw89/rtw8852a.c
drivers/net/wireless/realtek/rtw89/rtw8852b.c [new file with mode: 0644]
drivers/net/wireless/realtek/rtw89/rtw8852c.c

index c0f798ad60c2a6f128ab5612ab80c7b6d685758a..b8b143c528358537d6499b0e4aa5f148bb275d3a 100644 (file)
@@ -2716,6 +2716,7 @@ struct rtw89_chip_info {
        u8 dcfo_comp_sft;
        const struct rtw89_imr_info *imr_info;
        const struct rtw89_rrsr_cfgs *rrsr_cfgs;
+       u32 dma_ch_mask;
 };
 
 union rtw89_bus_info {
index 6f2fba6c32bfe4f327cbd3f7540ec160112ba11e..9b75d9645580fe51dfb15b6abd20eaeee8273eba 100644 (file)
@@ -827,6 +827,8 @@ static void hfc_func_en(struct rtw89_dev *rtwdev, bool en, bool h2c_en)
 
 static int hfc_init(struct rtw89_dev *rtwdev, bool reset, bool en, bool h2c_en)
 {
+       const struct rtw89_chip_info *chip = rtwdev->chip;
+       u32 dma_ch_mask = chip->dma_ch_mask;
        u8 ch;
        u32 ret = 0;
 
@@ -848,6 +850,8 @@ static int hfc_init(struct rtw89_dev *rtwdev, bool reset, bool en, bool h2c_en)
        }
 
        for (ch = RTW89_DMA_ACH0; ch < RTW89_DMA_H2C; ch++) {
+               if (dma_ch_mask & BIT(ch))
+                       continue;
                ret = hfc_ch_ctrl(rtwdev, ch);
                if (ret)
                        return ret;
@@ -863,6 +867,8 @@ static int hfc_init(struct rtw89_dev *rtwdev, bool reset, bool en, bool h2c_en)
                udelay(10);
        }
        for (ch = RTW89_DMA_ACH0; ch < RTW89_DMA_H2C; ch++) {
+               if (dma_ch_mask & BIT(ch))
+                       continue;
                ret = hfc_upd_ch_info(rtwdev, ch);
                if (ret)
                        return ret;
index be3ec41dc55c0ee2ed234405298c9607e4e882aa..124e63fe6968141fa0201bd389b0ca7085c4c74a 100644 (file)
@@ -2281,6 +2281,7 @@ const struct rtw89_chip_info rtw8852a_chip_info = {
        .dcfo_comp_sft          = 3,
        .imr_info               = &rtw8852a_imr_info,
        .rrsr_cfgs              = &rtw8852a_rrsr_cfgs,
+       .dma_ch_mask            = 0,
 };
 EXPORT_SYMBOL(rtw8852a_chip_info);
 
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b.c b/drivers/net/wireless/realtek/rtw89/rtw8852b.c
new file mode 100644 (file)
index 0000000..f951b8f
--- /dev/null
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/* Copyright(c) 2019-2022  Realtek Corporation
+ */
+
+#include "core.h"
+
+const struct rtw89_chip_info rtw8852b_chip_info = {
+       .chip_id                = RTL8852B,
+       .dma_ch_mask            = BIT(RTW89_DMA_ACH4) | BIT(RTW89_DMA_ACH5) |
+                                 BIT(RTW89_DMA_ACH6) | BIT(RTW89_DMA_ACH7) |
+                                 BIT(RTW89_DMA_B1MG) | BIT(RTW89_DMA_B1HI),
+};
+EXPORT_SYMBOL(rtw8852b_chip_info);
+
+MODULE_FIRMWARE("rtw89/rtw8852b_fw.bin");
+MODULE_AUTHOR("Realtek Corporation");
+MODULE_DESCRIPTION("Realtek 802.11ax wireless 8852B driver");
+MODULE_LICENSE("Dual BSD/GPL");
index 5dff65dbc142bb7062ab3f2629c44ac989f4b640..8c242d21e5fa4dd4795bc2a63094f700643530be 100644 (file)
@@ -3132,6 +3132,7 @@ const struct rtw89_chip_info rtw8852c_chip_info = {
        .dcfo_comp_sft          = 5,
        .imr_info               = &rtw8852c_imr_info,
        .rrsr_cfgs              = &rtw8852c_rrsr_cfgs,
+       .dma_ch_mask            = 0,
 };
 EXPORT_SYMBOL(rtw8852c_chip_info);