1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Sat, 14 Jan 2023 18:01:28 +0100
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce mtk_hw_reset utility
6 This is a preliminary patch to add Wireless Ethernet Dispatcher reset
9 Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
10 Tested-by: Daniel Golle <daniel@makrotopia.org>
11 Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
12 Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
13 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
14 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
17 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 @@ -3256,6 +3256,27 @@ static void mtk_set_mcr_max_rx(struct mt
20 mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
23 +static void mtk_hw_reset(struct mtk_eth *eth)
27 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
28 + regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0);
29 + val = RSTCTRL_PPE0_V2;
34 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
35 + val |= RSTCTRL_PPE1;
37 + ethsys_reset(eth, RSTCTRL_ETH | RSTCTRL_FE | val);
39 + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
40 + regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN,
44 static int mtk_hw_init(struct mtk_eth *eth)
46 u32 dma_mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA |
47 @@ -3295,22 +3316,9 @@ static int mtk_hw_init(struct mtk_eth *e
51 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
52 - regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0);
53 - val = RSTCTRL_PPE0_V2;
58 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
59 - val |= RSTCTRL_PPE1;
61 - ethsys_reset(eth, RSTCTRL_ETH | RSTCTRL_FE | val);
64 if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
65 - regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN,
68 /* Set FE to PDMAv2 if necessary */
69 val = mtk_r32(eth, MTK_FE_GLO_MISC);
70 mtk_w32(eth, val | BIT(4), MTK_FE_GLO_MISC);