Skip to content

Commit 6bc2b6c

Browse files
Bo-Cun Chenkuba-moo
authored andcommitted
net: ethernet: mtk_eth_soc: reapply mdc divider on reset
In the current method, the MDC divider was reset to the default setting of 2.5MHz after the NETSYS SER. Therefore, we need to reapply the MDC divider configuration function in mtk_hw_init() after reset. Fixes: c0a4400 ("net: ethernet: mtk_eth_soc: set MDIO bus clock frequency") Signed-off-by: Bo-Cun Chen <[email protected]> Signed-off-by: Daniel Golle <[email protected]> Link: https://patch.msgid.link/8ab7381447e6cdcb317d5b5a6ddd90a1734efcb0.1744764277.git.daniel@makrotopia.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8e57ce3 commit 6bc2b6c

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,25 @@ static const struct phylink_mac_ops mtk_phylink_ops = {
871871
.mac_enable_tx_lpi = mtk_mac_enable_tx_lpi,
872872
};
873873

874+
static void mtk_mdio_config(struct mtk_eth *eth)
875+
{
876+
u32 val;
877+
878+
/* Configure MDC Divider */
879+
val = FIELD_PREP(PPSC_MDC_CFG, eth->mdc_divider);
880+
881+
/* Configure MDC Turbo Mode */
882+
if (mtk_is_netsys_v3_or_greater(eth))
883+
mtk_m32(eth, 0, MISC_MDC_TURBO, MTK_MAC_MISC_V3);
884+
else
885+
val |= PPSC_MDC_TURBO;
886+
887+
mtk_m32(eth, PPSC_MDC_CFG, val, MTK_PPSC);
888+
}
889+
874890
static int mtk_mdio_init(struct mtk_eth *eth)
875891
{
876-
unsigned int max_clk = 2500000, divider;
892+
unsigned int max_clk = 2500000;
877893
struct device_node *mii_np;
878894
int ret;
879895
u32 val;
@@ -908,20 +924,9 @@ static int mtk_mdio_init(struct mtk_eth *eth)
908924
}
909925
max_clk = val;
910926
}
911-
divider = min_t(unsigned int, DIV_ROUND_UP(MDC_MAX_FREQ, max_clk), 63);
912-
913-
/* Configure MDC Turbo Mode */
914-
if (mtk_is_netsys_v3_or_greater(eth))
915-
mtk_m32(eth, 0, MISC_MDC_TURBO, MTK_MAC_MISC_V3);
916-
917-
/* Configure MDC Divider */
918-
val = FIELD_PREP(PPSC_MDC_CFG, divider);
919-
if (!mtk_is_netsys_v3_or_greater(eth))
920-
val |= PPSC_MDC_TURBO;
921-
mtk_m32(eth, PPSC_MDC_CFG, val, MTK_PPSC);
922-
923-
dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / divider);
924-
927+
eth->mdc_divider = min_t(unsigned int, DIV_ROUND_UP(MDC_MAX_FREQ, max_clk), 63);
928+
mtk_mdio_config(eth);
929+
dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / eth->mdc_divider);
925930
ret = of_mdiobus_register(eth->mii_bus, mii_np);
926931

927932
err_put_node:
@@ -3974,6 +3979,10 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)
39743979
else
39753980
mtk_hw_reset(eth);
39763981

3982+
/* No MT7628/88 support yet */
3983+
if (reset && !MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
3984+
mtk_mdio_config(eth);
3985+
39773986
if (mtk_is_netsys_v3_or_greater(eth)) {
39783987
/* Set FE to PDMAv2 if necessary */
39793988
val = mtk_r32(eth, MTK_FE_GLO_MISC);

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,7 @@ struct mtk_eth {
12711271
struct clk *clks[MTK_CLK_MAX];
12721272

12731273
struct mii_bus *mii_bus;
1274+
unsigned int mdc_divider;
12741275
struct work_struct pending_work;
12751276
unsigned long state;
12761277

0 commit comments

Comments
 (0)