mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-20 03:36:29 +00:00
generic: backport accepted and pending patches for mtk_eth_soc
Backport a bunch of fixes and improvements for WED and PPE, mostly for MT7988. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
8730f9e536
commit
f3d2829b51
@ -0,0 +1,113 @@
|
|||||||
|
From 52ea72ad0daa0f29535b4cef39257616c5a211d3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||||
|
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 <frank-w@public-files.de>
|
||||||
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||||
|
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
|
||||||
|
Link: https://lore.kernel.org/r/d983cbfe8ea562fef9264de8f0c501f7d5705bd5.1698098381.git.lorenzo@kernel.org
|
||||||
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||||
|
---
|
||||||
|
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)
|
@ -0,0 +1,51 @@
|
|||||||
|
From 7aa8defd3495208289abcc629946af26a2af3391 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||||
|
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 <lorenzo@kernel.org>
|
||||||
|
Link: https://lore.kernel.org/r/530537db0872f7523deff21f0a5dfdd9b75fdc9d.1698098459.git.lorenzo@kernel.org
|
||||||
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||||
|
---
|
||||||
|
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);
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
From 65aacd457eaf5d0c958ed8030ec46f99ea808dd9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||||
|
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 <lorenzo@kernel.org>
|
||||||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||||
|
---
|
||||||
|
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;
|
||||||
|
|
@ -0,0 +1,91 @@
|
|||||||
|
From 5f5997322584b6257543d4d103f81484b8006d84 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||||
|
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 <sujuan.chen@mediatek.com>
|
||||||
|
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
|
||||||
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||||
|
Link: https://lore.kernel.org/r/1c7efdf5d384ea7af3c0209723e40b2ee0f956bf.1700239272.git.lorenzo@kernel.org
|
||||||
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||||
|
---
|
||||||
|
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;
|
||||||
|
|
@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||||||
|
|
||||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||||
+++ b/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
|
* for NAPI to work
|
||||||
*/
|
*/
|
||||||
init_dummy_netdev(ð->dummy_dev);
|
init_dummy_netdev(ð->dummy_dev);
|
||||||
|
@ -24,7 +24,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||||||
#include <net/page_pool/helpers.h>
|
#include <net/page_pool/helpers.h>
|
||||||
|
|
||||||
#include "mtk_eth_soc.h"
|
#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 <nbd@nbd.name>
|
|||||||
bool gso = false;
|
bool gso = false;
|
||||||
int tx_num;
|
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;
|
return NETDEV_TX_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||||||
/* TSO: fill MSS info in tcp checksum field */
|
/* TSO: fill MSS info in tcp checksum field */
|
||||||
if (skb_is_gso(skb)) {
|
if (skb_is_gso(skb)) {
|
||||||
if (skb_cow_head(skb, 0)) {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
.mac_finish = mtk_mac_finish,
|
.mac_finish = mtk_mac_finish,
|
||||||
.mac_link_down = mtk_mac_link_down,
|
.mac_link_down = mtk_mac_link_down,
|
||||||
.mac_link_up = mtk_mac_link_up,
|
.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;
|
struct mtk_eth *eth = mac->hw;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
|
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
netdev_err(dev, "%s: could not attach PHY: %d\n", __func__,
|
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++)
|
for (i = 0; i < ARRAY_SIZE(eth->ppe); i++)
|
||||||
mtk_ppe_stop(eth->ppe[i]);
|
mtk_ppe_stop(eth->ppe[i]);
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
return 0;
|
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)
|
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
||||||
{
|
{
|
||||||
const __be32 *_id = of_get_property(np, "reg", NULL);
|
const __be32 *_id = of_get_property(np, "reg", NULL);
|
||||||
@ -518,7 +518,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
phy_interface_t phy_mode;
|
phy_interface_t phy_mode;
|
||||||
struct phylink *phylink;
|
struct phylink *phylink;
|
||||||
struct mtk_mac *mac;
|
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->id = id;
|
||||||
mac->hw = eth;
|
mac->hw = eth;
|
||||||
mac->of_node = np;
|
mac->of_node = np;
|
||||||
@ -568,7 +568,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
|
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);
|
phy_interface_zero(mac->phylink_config.supported_interfaces);
|
||||||
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
|
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
|
||||||
mac->phylink_config.supported_interfaces);
|
mac->phylink_config.supported_interfaces);
|
||||||
@ -590,7 +590,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
phylink = phylink_create(&mac->phylink_config,
|
phylink = phylink_create(&mac->phylink_config,
|
||||||
of_fwnode_handle(mac->of_node),
|
of_fwnode_handle(mac->of_node),
|
||||||
phy_mode, &mtk_phylink_ops);
|
phy_mode, &mtk_phylink_ops);
|
||||||
@@ -4696,6 +4882,26 @@ free_netdev:
|
@@ -4699,6 +4885,26 @@ free_netdev:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
|
void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
|
||||||
{
|
{
|
||||||
struct net_device *dev, *tmp;
|
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);
|
regmap_write(cci, 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|||||||
err = mtk_sgmii_init(eth);
|
err = mtk_sgmii_init(eth);
|
||||||
|
|
||||||
if (err)
|
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 <daniel@makrotopia.org>
|
|||||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
|
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
|
||||||
err = devm_request_irq(eth->dev, eth->irq[0],
|
err = devm_request_irq(eth->dev, eth->irq[0],
|
||||||
mtk_handle_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]);
|
mtk_stop(eth->netdev[i]);
|
||||||
mac = netdev_priv(eth->netdev[i]);
|
mac = netdev_priv(eth->netdev[i]);
|
||||||
phylink_disconnect_phy(mac->phylink);
|
phylink_disconnect_phy(mac->phylink);
|
||||||
|
@ -26,7 +26,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
{
|
{
|
||||||
struct reserved_mem *rmem;
|
struct reserved_mem *rmem;
|
||||||
struct device_node *np;
|
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)
|
if (index < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -23,9 +23,12 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
|
|
||||||
--- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
|
--- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
|
||||||
+++ b/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);
|
- return readl(mem_region[MTK_WED_WO_REGION_BOOT].addr + reg);
|
||||||
+ u32 val;
|
+ u32 val;
|
||||||
@ -39,7 +42,8 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
+ return val;
|
+ 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);
|
- writel(val, mem_region[MTK_WED_WO_REGION_BOOT].addr + reg);
|
||||||
+ if (wo->boot_regmap)
|
+ if (wo->boot_regmap)
|
||||||
@ -49,7 +53,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct sk_buff *
|
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;
|
u32 val, boot_cr;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
@ -59,7 +63,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
/* load firmware region metadata */
|
/* load firmware region metadata */
|
||||||
for (i = 0; i < ARRAY_SIZE(mem_region); i++) {
|
for (i = 0; i < ARRAY_SIZE(mem_region); i++) {
|
||||||
int index = of_property_match_string(wo->hw->node,
|
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)
|
if (index < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -69,6 +73,24 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
ret = mtk_wed_get_reserved_memory_region(wo->hw, index, &mem_region[i]);
|
ret = mtk_wed_get_reserved_memory_region(wo->hw, index, &mem_region[i]);
|
||||||
if (ret)
|
if (ret)
|
||||||
return 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
|
--- a/drivers/net/ethernet/mediatek/mtk_wed_wo.h
|
||||||
+++ b/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 {
|
@@ -231,6 +231,7 @@ struct mtk_wed_wo_queue {
|
||||||
|
@ -20,7 +20,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
|
|
||||||
--- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
|
--- a/drivers/net/ethernet/mediatek/mtk_wed_mcu.c
|
||||||
+++ b/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
|
static int
|
||||||
@ -60,7 +60,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)
|
mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)
|
||||||
{
|
{
|
||||||
const struct mtk_wed_fw_trailer *trailer;
|
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;
|
u32 val, boot_cr;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
|
|
||||||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
|
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
|
||||||
+++ b/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;
|
struct device_node *np;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|||||||
index = of_property_match_string(dev->hw->node, "memory-region-names",
|
index = of_property_match_string(dev->hw->node, "memory-region-names",
|
||||||
"wo-dlm");
|
"wo-dlm");
|
||||||
if (index < 0)
|
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;
|
return -ENODEV;
|
||||||
|
|
||||||
dev->rro.miod_phys = rmem->base;
|
dev->rro.miod_phys = rmem->base;
|
||||||
|
Loading…
Reference in New Issue
Block a user