diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c index 391cc1daeb..f87610cfc7 100644 --- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c +++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c @@ -345,7 +345,8 @@ void mtk_prepare_reset_fe(struct mtk_eth *eth) mtk_w32(eth, val & ~(MAC_MCR_RX_EN), MTK_MAC_MCR(1)); /* Enable GDM drop */ - mtk_gdm_config(eth, MTK_GDMA_DROP_ALL); + for (i = 0; i < MTK_MAC_COUNT; i++) + mtk_gdm_config(eth, i, MTK_GDMA_DROP_ALL); /* Disable ADMA Rx */ val = mtk_r32(eth, MTK_PDMA_GLO_CFG); diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 3cd1e3be2b..1d3b09a67d 100644 --- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2611,29 +2611,27 @@ static int mtk_start_dma(struct mtk_eth *eth) return 0; } -void mtk_gdm_config(struct mtk_eth *eth, u32 config) +void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config) { - int i; + u32 val; if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) return; - for (i = 0; i < MTK_MAC_COUNT; i++) { - u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i)); + val = mtk_r32(eth, MTK_GDMA_FWD_CFG(id)); - /* default setup the forward port to send frame to PDMA */ - val &= ~0xffff; + /* default setup the forward port to send frame to PDMA */ + val &= ~0xffff; - /* Enable RX checksum */ - val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN; + /* Enable RX checksum */ + val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN; - val |= config; + val |= config; - if (eth->netdev[i] && netdev_uses_dsa(eth->netdev[i])) - val |= MTK_GDMA_SPECIAL_TAG; + if (eth->netdev[id] && netdev_uses_dsa(eth->netdev[id])) + val |= MTK_GDMA_SPECIAL_TAG; - mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i)); - } + mtk_w32(eth, val, MTK_GDMA_FWD_CFG(id)); } static int mtk_open(struct net_device *dev) @@ -2657,7 +2655,6 @@ static int mtk_open(struct net_device *dev) if (err) return err; - mtk_gdm_config(eth, MTK_GDMA_TO_PDMA); /* Indicates CDM to parse the MTK special tag from CPU */ if (netdev_uses_dsa(dev)) { @@ -2691,6 +2688,9 @@ static int mtk_open(struct net_device *dev) if (!phy_node && eth->sgmii->regmap[mac->id]) { regmap_write(eth->sgmii->regmap[mac->id], SGMSYS_QPHY_PWR_STATE_CTRL, 0); } + + mtk_gdm_config(eth, mac->id, MTK_GDMA_TO_PDMA); + return 0; } @@ -2725,6 +2725,7 @@ static int mtk_stop(struct net_device *dev) u32 val = 0; struct device_node *phy_node; + mtk_gdm_config(eth, mac->id, MTK_GDMA_DROP_ALL); netif_tx_disable(dev); phy_node = of_parse_phandle(mac->of_node, "phy-handle", 0); @@ -2750,7 +2751,6 @@ static int mtk_stop(struct net_device *dev) if (!refcount_dec_and_test(ð->dma_refcnt)) return 0; - mtk_gdm_config(eth, MTK_GDMA_DROP_ALL); mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); mtk_rx_irq_disable(eth, MTK_RX_DONE_INT(0)); diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h index b6380ffeb9..b5e04a67b2 100644 --- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1316,7 +1316,7 @@ void mtk_sgmii_restart_an(struct mtk_eth *eth, int mac_id); int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id); int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id); int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id); -void mtk_gdm_config(struct mtk_eth *eth, u32 config); +void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config); void ethsys_reset(struct mtk_eth *eth, u32 reset_bits); #endif /* MTK_ETH_H */