From: Daniel Golle Date: Wed, 29 May 2024 01:41:30 +0000 (+0100) Subject: generic: backport accepted and pending patches for mtk_eth_soc X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=HEAD;p=openwrt%2Fstaging%2Fdangole.git generic: backport accepted and pending patches for mtk_eth_soc Backport a bunch of fixes and improvements for WED, mostly for MT7988. Signed-off-by: Daniel Golle --- diff --git a/target/linux/generic/backport-6.6/752-21-v6.7-net-ethernet-mtk_wed-fix-firmware-loading-for-MT7986.patch b/target/linux/generic/backport-6.6/752-21-v6.7-net-ethernet-mtk_wed-fix-firmware-loading-for-MT7986.patch new file mode 100644 index 0000000000..3b0795c536 --- /dev/null +++ b/target/linux/generic/backport-6.6/752-21-v6.7-net-ethernet-mtk_wed-fix-firmware-loading-for-MT7986.patch @@ -0,0 +1,113 @@ +From 52ea72ad0daa0f29535b4cef39257616c5a211d3 Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi +Date: Tue, 24 Oct 2023 00:00:19 +0200 +Subject: [PATCH 1/5] net: ethernet: mtk_wed: fix firmware loading for MT7986 + SoC + +The WED mcu firmware does not contain all the memory regions defined in +the dts reserved_memory node (e.g. MT7986 WED firmware does not contain +cpu-boot region). +Reverse the mtk_wed_mcu_run_firmware() logic to check all the fw +sections are defined in the dts reserved_memory node. + +Fixes: c6d961aeaa77 ("net: ethernet: mtk_wed: move mem_region array out of mtk_wed_mcu_load_firmware") +Tested-by: Frank Wunderlich +Signed-off-by: Lorenzo Bianconi +Reviewed-by: Jacob Keller +Link: https://lore.kernel.org/r/d983cbfe8ea562fef9264de8f0c501f7d5705bd5.1698098381.git.lorenzo@kernel.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 48 +++++++++++---------- + 1 file changed, 25 insertions(+), 23 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c +@@ -258,16 +258,12 @@ mtk_wed_get_memory_region(struct mtk_wed + } + + static int +-mtk_wed_mcu_run_firmware(struct mtk_wed_wo *wo, const struct firmware *fw, +- struct mtk_wed_wo_memory_region *region) ++mtk_wed_mcu_run_firmware(struct mtk_wed_wo *wo, const struct firmware *fw) + { + const u8 *first_region_ptr, *region_ptr, *trailer_ptr, *ptr = fw->data; + const struct mtk_wed_fw_trailer *trailer; + const struct mtk_wed_fw_region *fw_region; + +- if (!region->phy_addr || !region->size) +- return 0; +- + trailer_ptr = fw->data + fw->size - sizeof(*trailer); + trailer = (const struct mtk_wed_fw_trailer *)trailer_ptr; + region_ptr = trailer_ptr - trailer->num_region * sizeof(*fw_region); +@@ -275,33 +271,41 @@ mtk_wed_mcu_run_firmware(struct mtk_wed_ + + while (region_ptr < trailer_ptr) { + u32 length; ++ int i; + + fw_region = (const struct mtk_wed_fw_region *)region_ptr; + length = le32_to_cpu(fw_region->len); +- +- if (region->phy_addr != le32_to_cpu(fw_region->addr)) +- goto next; +- +- if (region->size < length) +- goto next; +- + if (first_region_ptr < ptr + length) + goto next; + +- if (region->shared && region->consumed) +- return 0; ++ for (i = 0; i < ARRAY_SIZE(mem_region); i++) { ++ struct mtk_wed_wo_memory_region *region; + +- if (!region->shared || !region->consumed) { +- memcpy_toio(region->addr, ptr, length); +- region->consumed = true; +- return 0; ++ region = &mem_region[i]; ++ if (region->phy_addr != le32_to_cpu(fw_region->addr)) ++ continue; ++ ++ if (region->size < length) ++ continue; ++ ++ if (region->shared && region->consumed) ++ break; ++ ++ if (!region->shared || !region->consumed) { ++ memcpy_toio(region->addr, ptr, length); ++ region->consumed = true; ++ break; ++ } + } ++ ++ if (i == ARRAY_SIZE(mem_region)) ++ return -EINVAL; + next: + region_ptr += sizeof(*fw_region); + ptr += length; + } + +- return -EINVAL; ++ return 0; + } + + static int +@@ -360,11 +364,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed + dev_info(wo->hw->dev, "MTK WED WO Chip ID %02x Region %d\n", + trailer->chip_id, trailer->num_region); + +- for (i = 0; i < ARRAY_SIZE(mem_region); i++) { +- ret = mtk_wed_mcu_run_firmware(wo, fw, &mem_region[i]); +- if (ret) +- goto out; +- } ++ ret = mtk_wed_mcu_run_firmware(wo, fw); ++ if (ret) ++ goto out; + + /* set the start address */ + if (!mtk_wed_is_v3_or_greater(wo->hw) && wo->hw->index) diff --git a/target/linux/generic/backport-6.6/752-22-v6.7-net-ethernet-mtk_wed-remove-wo-pointer-in-wo_r32-wo_.patch b/target/linux/generic/backport-6.6/752-22-v6.7-net-ethernet-mtk_wed-remove-wo-pointer-in-wo_r32-wo_.patch new file mode 100644 index 0000000000..c1bb3f5b02 --- /dev/null +++ b/target/linux/generic/backport-6.6/752-22-v6.7-net-ethernet-mtk_wed-remove-wo-pointer-in-wo_r32-wo_.patch @@ -0,0 +1,51 @@ +From 7aa8defd3495208289abcc629946af26a2af3391 Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi +Date: Tue, 24 Oct 2023 00:01:30 +0200 +Subject: [PATCH 2/5] net: ethernet: mtk_wed: remove wo pointer in + wo_r32/wo_w32 signature + +wo pointer is no longer used in wo_r32 and wo_w32 routines so get rid of +it. + +Signed-off-by: Lorenzo Bianconi +Link: https://lore.kernel.org/r/530537db0872f7523deff21f0a5dfdd9b75fdc9d.1698098459.git.lorenzo@kernel.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c +@@ -32,12 +32,12 @@ static struct mtk_wed_wo_memory_region m + }, + }; + +-static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg) ++static u32 wo_r32(u32 reg) + { + return readl(mem_region[MTK_WED_WO_REGION_BOOT].addr + reg); + } + +-static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val) ++static void wo_w32(u32 reg, u32 val) + { + writel(val, mem_region[MTK_WED_WO_REGION_BOOT].addr + reg); + } +@@ -373,13 +373,13 @@ mtk_wed_mcu_load_firmware(struct mtk_wed + boot_cr = MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR; + else + boot_cr = MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR; +- wo_w32(wo, boot_cr, mem_region[MTK_WED_WO_REGION_EMI].phy_addr >> 16); ++ wo_w32(boot_cr, mem_region[MTK_WED_WO_REGION_EMI].phy_addr >> 16); + /* wo firmware reset */ +- wo_w32(wo, MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR, 0xc00); ++ wo_w32(MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR, 0xc00); + +- val = wo_r32(wo, MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR) | ++ val = wo_r32(MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR) | + MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK; +- wo_w32(wo, MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR, val); ++ wo_w32(MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR, val); + out: + release_firmware(fw); + diff --git a/target/linux/generic/backport-6.6/752-23-v6.8-net-ethernet-mtk_wed-rely-on-__dev_alloc_page-in-mtk.patch b/target/linux/generic/backport-6.6/752-23-v6.8-net-ethernet-mtk_wed-rely-on-__dev_alloc_page-in-mtk.patch new file mode 100644 index 0000000000..7cbf6bd732 --- /dev/null +++ b/target/linux/generic/backport-6.6/752-23-v6.8-net-ethernet-mtk_wed-rely-on-__dev_alloc_page-in-mtk.patch @@ -0,0 +1,26 @@ +From 65aacd457eaf5d0c958ed8030ec46f99ea808dd9 Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi +Date: Fri, 17 Nov 2023 17:39:22 +0100 +Subject: [PATCH 3/5] net: ethernet: mtk_wed: rely on __dev_alloc_page in + mtk_wed_tx_buffer_alloc + +Simplify the code and use __dev_alloc_page() instead of __dev_alloc_pages() +with order 0 in mtk_wed_tx_buffer_alloc routine + +Signed-off-by: Lorenzo Bianconi +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/mediatek/mtk_wed.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -670,7 +670,7 @@ mtk_wed_tx_buffer_alloc(struct mtk_wed_d + void *buf; + int s; + +- page = __dev_alloc_pages(GFP_KERNEL, 0); ++ page = __dev_alloc_page(GFP_KERNEL); + if (!page) + return -ENOMEM; + diff --git a/target/linux/generic/backport-6.6/752-24-v6.8-net-ethernet-mtk_wed-add-support-for-devices-with-mo.patch b/target/linux/generic/backport-6.6/752-24-v6.8-net-ethernet-mtk_wed-add-support-for-devices-with-mo.patch new file mode 100644 index 0000000000..b08f3aaadd --- /dev/null +++ b/target/linux/generic/backport-6.6/752-24-v6.8-net-ethernet-mtk_wed-add-support-for-devices-with-mo.patch @@ -0,0 +1,91 @@ +From 5f5997322584b6257543d4d103f81484b8006d84 Mon Sep 17 00:00:00 2001 +From: Lorenzo Bianconi +Date: Fri, 17 Nov 2023 17:42:59 +0100 +Subject: [PATCH 4/5] net: ethernet: mtk_wed: add support for devices with more + than 4GB of dram + +Introduce WED offloading support for boards with more than 4GB of +memory. + +Co-developed-by: Sujuan Chen +Signed-off-by: Sujuan Chen +Signed-off-by: Lorenzo Bianconi +Link: https://lore.kernel.org/r/1c7efdf5d384ea7af3c0209723e40b2ee0f956bf.1700239272.git.lorenzo@kernel.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 ++++- + drivers/net/ethernet/mediatek/mtk_wed.c | 8 +++++--- + drivers/net/ethernet/mediatek/mtk_wed_wo.c | 3 ++- + 3 files changed, 11 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1158,15 +1158,18 @@ static int mtk_init_fq_dma(struct mtk_et + phy_ring_tail = eth->phy_scratch_ring + soc->tx.desc_size * (cnt - 1); + + for (i = 0; i < cnt; i++) { ++ dma_addr_t addr = dma_addr + i * MTK_QDMA_PAGE_SIZE; + struct mtk_tx_dma_v2 *txd; + + txd = eth->scratch_ring + i * soc->tx.desc_size; +- txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; ++ txd->txd1 = addr; + if (i < cnt - 1) + txd->txd2 = eth->phy_scratch_ring + + (i + 1) * soc->tx.desc_size; + + txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE); ++ if (MTK_HAS_CAPS(soc->caps, MTK_36BIT_DMA)) ++ txd->txd3 |= TX_DMA_PREP_ADDR64(addr); + txd->txd4 = 0; + if (mtk_is_netsys_v2_or_greater(eth)) { + txd->txd5 = 0; +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -691,10 +691,11 @@ mtk_wed_tx_buffer_alloc(struct mtk_wed_d + + for (s = 0; s < MTK_WED_BUF_PER_PAGE; s++) { + struct mtk_wdma_desc *desc = desc_ptr; ++ u32 ctrl; + + desc->buf0 = cpu_to_le32(buf_phys); + if (!mtk_wed_is_v3_or_greater(dev->hw)) { +- u32 txd_size, ctrl; ++ u32 txd_size; + + txd_size = dev->wlan.init_buf(buf, buf_phys, + token++); +@@ -708,11 +709,11 @@ mtk_wed_tx_buffer_alloc(struct mtk_wed_d + ctrl |= MTK_WDMA_DESC_CTRL_LAST_SEG0 | + FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1_V2, + MTK_WED_BUF_SIZE - txd_size); +- desc->ctrl = cpu_to_le32(ctrl); + desc->info = 0; + } else { +- desc->ctrl = cpu_to_le32(token << 16); ++ ctrl = token << 16 | TX_DMA_PREP_ADDR64(buf_phys); + } ++ desc->ctrl = cpu_to_le32(ctrl); + + desc_ptr += desc_size; + buf += MTK_WED_BUF_SIZE; +@@ -811,6 +812,7 @@ mtk_wed_hwrro_buffer_alloc(struct mtk_we + buf_phys = page_phys; + for (s = 0; s < MTK_WED_RX_BUF_PER_PAGE; s++) { + desc->buf0 = cpu_to_le32(buf_phys); ++ desc->token = cpu_to_le32(RX_DMA_PREP_ADDR64(buf_phys)); + buf_phys += MTK_WED_PAGE_BUF_SIZE; + desc++; + } +--- a/drivers/net/ethernet/mediatek/mtk_wed_wo.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.c +@@ -142,7 +142,8 @@ mtk_wed_wo_queue_refill(struct mtk_wed_w + dma_addr_t addr; + void *buf; + +- buf = page_frag_alloc(&q->cache, q->buf_size, GFP_ATOMIC); ++ buf = page_frag_alloc(&q->cache, q->buf_size, ++ GFP_ATOMIC | GFP_DMA32); + if (!buf) + break; + diff --git a/target/linux/generic/pending-6.6/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/target/linux/generic/pending-6.6/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch index e73cf9a899..ca5fe771d1 100644 --- a/target/linux/generic/pending-6.6/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch +++ b/target/linux/generic/pending-6.6/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4981,6 +4981,8 @@ static int mtk_probe(struct platform_dev +@@ -4984,6 +4984,8 @@ static int mtk_probe(struct platform_dev * for NAPI to work */ init_dummy_netdev(ð->dummy_dev); diff --git a/target/linux/generic/pending-6.6/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch b/target/linux/generic/pending-6.6/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch index a64561bf92..438f83953a 100644 --- a/target/linux/generic/pending-6.6/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch +++ b/target/linux/generic/pending-6.6/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch @@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau #include #include "mtk_eth_soc.h" -@@ -1578,12 +1579,28 @@ static void mtk_wake_queue(struct mtk_et +@@ -1581,12 +1582,28 @@ static void mtk_wake_queue(struct mtk_et } } @@ -53,7 +53,7 @@ Signed-off-by: Felix Fietkau bool gso = false; int tx_num; -@@ -1605,6 +1622,18 @@ static netdev_tx_t mtk_start_xmit(struct +@@ -1608,6 +1625,18 @@ static netdev_tx_t mtk_start_xmit(struct return NETDEV_TX_BUSY; } @@ -72,7 +72,7 @@ Signed-off-by: Felix Fietkau /* TSO: fill MSS info in tcp checksum field */ if (skb_is_gso(skb)) { if (skb_cow_head(skb, 0)) { -@@ -1620,8 +1649,14 @@ static netdev_tx_t mtk_start_xmit(struct +@@ -1623,8 +1652,14 @@ static netdev_tx_t mtk_start_xmit(struct } } diff --git a/target/linux/generic/pending-6.6/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch b/target/linux/generic/pending-6.6/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch index a52213d87a..ba7699ecad 100644 --- a/target/linux/generic/pending-6.6/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch +++ b/target/linux/generic/pending-6.6/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch @@ -490,7 +490,7 @@ Signed-off-by: Daniel Golle .mac_finish = mtk_mac_finish, .mac_link_down = mtk_mac_link_down, .mac_link_up = mtk_mac_link_up, -@@ -3390,6 +3531,9 @@ static int mtk_open(struct net_device *d +@@ -3393,6 +3534,9 @@ static int mtk_open(struct net_device *d struct mtk_eth *eth = mac->hw; int i, err; @@ -500,7 +500,7 @@ Signed-off-by: Daniel Golle err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); if (err) { netdev_err(dev, "%s: could not attach PHY: %d\n", __func__, -@@ -3519,6 +3663,9 @@ static int mtk_stop(struct net_device *d +@@ -3522,6 +3666,9 @@ static int mtk_stop(struct net_device *d for (i = 0; i < ARRAY_SIZE(eth->ppe); i++) mtk_ppe_stop(eth->ppe[i]); @@ -510,7 +510,7 @@ Signed-off-by: Daniel Golle return 0; } -@@ -4516,6 +4663,7 @@ static const struct net_device_ops mtk_n +@@ -4519,6 +4666,7 @@ static const struct net_device_ops mtk_n static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) { const __be32 *_id = of_get_property(np, "reg", NULL); @@ -518,7 +518,7 @@ Signed-off-by: Daniel Golle phy_interface_t phy_mode; struct phylink *phylink; struct mtk_mac *mac; -@@ -4552,16 +4700,41 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4555,16 +4703,41 @@ static int mtk_add_mac(struct mtk_eth *e mac->id = id; mac->hw = eth; mac->of_node = np; @@ -568,7 +568,7 @@ Signed-off-by: Daniel Golle } memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip)); -@@ -4644,8 +4817,21 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4647,8 +4820,21 @@ static int mtk_add_mac(struct mtk_eth *e phy_interface_zero(mac->phylink_config.supported_interfaces); __set_bit(PHY_INTERFACE_MODE_INTERNAL, mac->phylink_config.supported_interfaces); @@ -590,7 +590,7 @@ Signed-off-by: Daniel Golle phylink = phylink_create(&mac->phylink_config, of_fwnode_handle(mac->of_node), phy_mode, &mtk_phylink_ops); -@@ -4696,6 +4882,26 @@ free_netdev: +@@ -4699,6 +4885,26 @@ free_netdev: return err; } @@ -617,7 +617,7 @@ Signed-off-by: Daniel Golle void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev) { struct net_device *dev, *tmp; -@@ -4842,7 +5048,8 @@ static int mtk_probe(struct platform_dev +@@ -4845,7 +5051,8 @@ static int mtk_probe(struct platform_dev regmap_write(cci, 0, 3); } @@ -627,7 +627,7 @@ Signed-off-by: Daniel Golle err = mtk_sgmii_init(eth); if (err) -@@ -4953,6 +5160,24 @@ static int mtk_probe(struct platform_dev +@@ -4956,6 +5163,24 @@ static int mtk_probe(struct platform_dev } } @@ -652,7 +652,7 @@ Signed-off-by: Daniel Golle if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { err = devm_request_irq(eth->dev, eth->irq[0], mtk_handle_irq, 0, -@@ -5055,6 +5280,11 @@ static int mtk_remove(struct platform_de +@@ -5058,6 +5283,11 @@ static int mtk_remove(struct platform_de mtk_stop(eth->netdev[i]); mac = netdev_priv(eth->netdev[i]); phylink_disconnect_phy(mac->phylink); diff --git a/target/linux/mediatek/patches-6.6/940-net-ethernet-mtk_wed-rename-mtk_wed_get_memory_regio.patch b/target/linux/mediatek/patches-6.6/940-net-ethernet-mtk_wed-rename-mtk_wed_get_memory_regio.patch index 30be53518a..465f0eaf27 100644 --- a/target/linux/mediatek/patches-6.6/940-net-ethernet-mtk_wed-rename-mtk_wed_get_memory_regio.patch +++ b/target/linux/mediatek/patches-6.6/940-net-ethernet-mtk_wed-rename-mtk_wed_get_memory_regio.patch @@ -26,7 +26,7 @@ Signed-off-by: Lorenzo Bianconi { struct reserved_mem *rmem; struct device_node *np; -@@ -321,7 +321,7 @@ mtk_wed_mcu_load_firmware(struct mtk_wed +@@ -325,7 +325,7 @@ mtk_wed_mcu_load_firmware(struct mtk_wed if (index < 0) continue; diff --git a/target/linux/mediatek/patches-6.6/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch b/target/linux/mediatek/patches-6.6/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch index b4bea2087b..43014c5d12 100644 --- a/target/linux/mediatek/patches-6.6/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch +++ b/target/linux/mediatek/patches-6.6/942-net-ethernet-mtk_wed-move-cpuboot-in-a-dedicated-dts.patch @@ -23,9 +23,12 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c +++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -@@ -34,12 +34,23 @@ static struct mtk_wed_wo_memory_region m +@@ -32,14 +32,25 @@ static struct mtk_wed_wo_memory_region m + }, + }; - static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg) +-static u32 wo_r32(u32 reg) ++static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg) { - return readl(mem_region[MTK_WED_WO_REGION_BOOT].addr + reg); + u32 val; @@ -39,7 +42,8 @@ Signed-off-by: Lorenzo Bianconi + return val; } - static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val) +-static void wo_w32(u32 reg, u32 val) ++static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val) { - writel(val, mem_region[MTK_WED_WO_REGION_BOOT].addr + reg); + if (wo->boot_regmap) @@ -49,7 +53,7 @@ Signed-off-by: Lorenzo Bianconi } static struct sk_buff * -@@ -313,6 +324,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed +@@ -317,6 +328,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed u32 val, boot_cr; int ret, i; @@ -59,7 +63,7 @@ Signed-off-by: Lorenzo Bianconi /* load firmware region metadata */ for (i = 0; i < ARRAY_SIZE(mem_region); i++) { int index = of_property_match_string(wo->hw->node, -@@ -321,6 +335,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed +@@ -325,6 +339,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed if (index < 0) continue; @@ -69,6 +73,24 @@ Signed-off-by: Lorenzo Bianconi ret = mtk_wed_get_reserved_memory_region(wo->hw, index, &mem_region[i]); if (ret) return ret; +@@ -373,13 +390,13 @@ mtk_wed_mcu_load_firmware(struct mtk_wed + boot_cr = MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR; + else + boot_cr = MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR; +- wo_w32(boot_cr, mem_region[MTK_WED_WO_REGION_EMI].phy_addr >> 16); ++ wo_w32(wo, boot_cr, mem_region[MTK_WED_WO_REGION_EMI].phy_addr >> 16); + /* wo firmware reset */ +- wo_w32(MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR, 0xc00); ++ wo_w32(wo, MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR, 0xc00); + +- val = wo_r32(MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR) | ++ val = wo_r32(wo, MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR) | + MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK; +- wo_w32(MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR, val); ++ wo_w32(wo, MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR, val); + out: + release_firmware(fw); + --- a/drivers/net/ethernet/mediatek/mtk_wed_wo.h +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.h @@ -231,6 +231,7 @@ struct mtk_wed_wo_queue { diff --git a/target/linux/mediatek/patches-6.6/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch b/target/linux/mediatek/patches-6.6/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch index b4ba5b0d2d..641c2597f7 100644 --- a/target/linux/mediatek/patches-6.6/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch +++ b/target/linux/mediatek/patches-6.6/943-net-ethernet-mtk_wed-move-ilm-a-dedicated-dts-node.patch @@ -20,7 +20,7 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c +++ b/drivers/net/ethernet/mediatek/mtk_wed_mcu.c -@@ -316,6 +316,39 @@ next: +@@ -320,6 +320,39 @@ next: } static int @@ -60,7 +60,7 @@ Signed-off-by: Lorenzo Bianconi mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo) { const struct mtk_wed_fw_trailer *trailer; -@@ -324,14 +357,20 @@ mtk_wed_mcu_load_firmware(struct mtk_wed +@@ -328,14 +361,20 @@ mtk_wed_mcu_load_firmware(struct mtk_wed u32 val, boot_cr; int ret, i; diff --git a/target/linux/mediatek/patches-6.6/944-net-ethernet-mtk_wed-move-dlm-a-dedicated-dts-node.patch b/target/linux/mediatek/patches-6.6/944-net-ethernet-mtk_wed-move-dlm-a-dedicated-dts-node.patch index c92fcd43ce..abb6591b7d 100644 --- a/target/linux/mediatek/patches-6.6/944-net-ethernet-mtk_wed-move-dlm-a-dedicated-dts-node.patch +++ b/target/linux/mediatek/patches-6.6/944-net-ethernet-mtk_wed-move-dlm-a-dedicated-dts-node.patch @@ -22,7 +22,7 @@ Signed-off-by: Lorenzo Bianconi --- a/drivers/net/ethernet/mediatek/mtk_wed.c +++ b/drivers/net/ethernet/mediatek/mtk_wed.c -@@ -1320,6 +1320,24 @@ mtk_wed_rro_alloc(struct mtk_wed_device +@@ -1322,6 +1322,24 @@ mtk_wed_rro_alloc(struct mtk_wed_device struct device_node *np; int index; @@ -47,7 +47,7 @@ Signed-off-by: Lorenzo Bianconi index = of_property_match_string(dev->hw->node, "memory-region-names", "wo-dlm"); if (index < 0) -@@ -1336,6 +1354,7 @@ mtk_wed_rro_alloc(struct mtk_wed_device +@@ -1338,6 +1356,7 @@ mtk_wed_rro_alloc(struct mtk_wed_device return -ENODEV; dev->rro.miod_phys = rmem->base;