rtw89: extend dmac_pre_init to support 8852C
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 25 Mar 2022 06:00:47 +0000 (14:00 +0800)
committerKalle Valo <kvalo@kernel.org>
Wed, 6 Apr 2022 08:55:13 +0000 (11:55 +0300)
DMAC is short for data MAC. 8852C has more settings than 8852A, so add
them.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220325060055.58482-9-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/mac.c
drivers/net/wireless/realtek/rtw89/reg.h

index d751054..66122d6 100644 (file)
@@ -2756,18 +2756,41 @@ static int rtw89_mac_enable_cpu(struct rtw89_dev *rtwdev, u8 boot_reason,
        return 0;
 }
 
-static int rtw89_mac_fw_dl_pre_init(struct rtw89_dev *rtwdev)
+static int rtw89_mac_dmac_pre_init(struct rtw89_dev *rtwdev)
 {
+       enum rtw89_core_chip_id chip_id = rtwdev->chip->chip_id;
        u32 val;
        int ret;
 
-       val = B_AX_MAC_FUNC_EN | B_AX_DMAC_FUNC_EN | B_AX_DISPATCHER_EN |
-             B_AX_PKT_BUF_EN;
+       if (chip_id == RTL8852C)
+               val = B_AX_MAC_FUNC_EN | B_AX_DMAC_FUNC_EN | B_AX_DISPATCHER_EN |
+                     B_AX_PKT_BUF_EN | B_AX_H_AXIDMA_EN;
+       else
+               val = B_AX_MAC_FUNC_EN | B_AX_DMAC_FUNC_EN | B_AX_DISPATCHER_EN |
+                     B_AX_PKT_BUF_EN;
        rtw89_write32(rtwdev, R_AX_DMAC_FUNC_EN, val);
 
        val = B_AX_DISPATCHER_CLK_EN;
        rtw89_write32(rtwdev, R_AX_DMAC_CLK_EN, val);
 
+       if (chip_id != RTL8852C)
+               goto dle;
+
+       val = rtw89_read32(rtwdev, R_AX_HAXI_INIT_CFG1);
+       val &= ~(B_AX_DMA_MODE_MASK | B_AX_STOP_AXI_MST);
+       val |= FIELD_PREP(B_AX_DMA_MODE_MASK, DMA_MOD_PCIE_1B) |
+              B_AX_TXHCI_EN_V1 | B_AX_RXHCI_EN_V1;
+       rtw89_write32(rtwdev, R_AX_HAXI_INIT_CFG1, val);
+
+       rtw89_write32_clr(rtwdev, R_AX_HAXI_DMA_STOP1,
+                         B_AX_STOP_ACH0 | B_AX_STOP_ACH1 | B_AX_STOP_ACH3 |
+                         B_AX_STOP_ACH4 | B_AX_STOP_ACH5 | B_AX_STOP_ACH6 |
+                         B_AX_STOP_ACH7 | B_AX_STOP_CH8 | B_AX_STOP_CH9 |
+                         B_AX_STOP_CH12 | B_AX_STOP_ACH2);
+       rtw89_write32_clr(rtwdev, R_AX_HAXI_DMA_STOP2, B_AX_STOP_CH10 | B_AX_STOP_CH11);
+       rtw89_write32_set(rtwdev, R_AX_PLATFORM_ENABLE, B_AX_AXIDMA_EN);
+
+dle:
        ret = dle_init(rtwdev, RTW89_QTA_DLFW, rtwdev->mac.qta_mode);
        if (ret) {
                rtw89_err(rtwdev, "[ERR]DLE pre init %d\n", ret);
@@ -2825,16 +2848,16 @@ int rtw89_mac_partial_init(struct rtw89_dev *rtwdev)
 
        rtw89_mac_hci_func_en(rtwdev);
 
+       ret = rtw89_mac_dmac_pre_init(rtwdev);
+       if (ret)
+               return ret;
+
        if (rtwdev->hci.ops->mac_pre_init) {
                ret = rtwdev->hci.ops->mac_pre_init(rtwdev);
                if (ret)
                        return ret;
        }
 
-       ret = rtw89_mac_fw_dl_pre_init(rtwdev);
-       if (ret)
-               return ret;
-
        rtw89_mac_disable_cpu(rtwdev);
        ret = rtw89_mac_enable_cpu(rtwdev, 0, true);
        if (ret)
index 21a4512..9d9554d 100644 (file)
 #define B_AX_R_AX_BG GENMASK(1, 0)
 
 #define R_AX_PLATFORM_ENABLE 0x0088
+#define B_AX_AXIDMA_EN BIT(3)
 #define B_AX_WCPU_EN BIT(1)
 #define B_AX_PLATFORM_EN BIT(0)