net: ethernet: mtk_eth_soc: reapply mdc divider on reset
[ Upstream commit 6bc2b6c6f16d8e60de518d26da1bc6bc436cf71d ]
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: c0a440031d ("net: ethernet: mtk_eth_soc: set MDIO bus clock frequency")
Signed-off-by: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Link: https://patch.msgid.link/8ab7381447e6cdcb317d5b5a6ddd90a1734efcb0.1744764277.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
da5035d7ae
commit
b524a14ec1
@@ -823,9 +823,25 @@ static const struct phylink_mac_ops mtk_phylink_ops = {
|
||||
.mac_link_up = mtk_mac_link_up,
|
||||
};
|
||||
|
||||
static void mtk_mdio_config(struct mtk_eth *eth)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
/* Configure MDC Divider */
|
||||
val = FIELD_PREP(PPSC_MDC_CFG, eth->mdc_divider);
|
||||
|
||||
/* Configure MDC Turbo Mode */
|
||||
if (mtk_is_netsys_v3_or_greater(eth))
|
||||
mtk_m32(eth, 0, MISC_MDC_TURBO, MTK_MAC_MISC_V3);
|
||||
else
|
||||
val |= PPSC_MDC_TURBO;
|
||||
|
||||
mtk_m32(eth, PPSC_MDC_CFG, val, MTK_PPSC);
|
||||
}
|
||||
|
||||
static int mtk_mdio_init(struct mtk_eth *eth)
|
||||
{
|
||||
unsigned int max_clk = 2500000, divider;
|
||||
unsigned int max_clk = 2500000;
|
||||
struct device_node *mii_np;
|
||||
int ret;
|
||||
u32 val;
|
||||
@@ -865,20 +881,9 @@ static int mtk_mdio_init(struct mtk_eth *eth)
|
||||
}
|
||||
max_clk = val;
|
||||
}
|
||||
divider = min_t(unsigned int, DIV_ROUND_UP(MDC_MAX_FREQ, max_clk), 63);
|
||||
|
||||
/* Configure MDC Turbo Mode */
|
||||
if (mtk_is_netsys_v3_or_greater(eth))
|
||||
mtk_m32(eth, 0, MISC_MDC_TURBO, MTK_MAC_MISC_V3);
|
||||
|
||||
/* Configure MDC Divider */
|
||||
val = FIELD_PREP(PPSC_MDC_CFG, divider);
|
||||
if (!mtk_is_netsys_v3_or_greater(eth))
|
||||
val |= PPSC_MDC_TURBO;
|
||||
mtk_m32(eth, PPSC_MDC_CFG, val, MTK_PPSC);
|
||||
|
||||
dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / divider);
|
||||
|
||||
eth->mdc_divider = min_t(unsigned int, DIV_ROUND_UP(MDC_MAX_FREQ, max_clk), 63);
|
||||
mtk_mdio_config(eth);
|
||||
dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / eth->mdc_divider);
|
||||
ret = of_mdiobus_register(eth->mii_bus, mii_np);
|
||||
|
||||
err_put_node:
|
||||
@@ -3928,6 +3933,10 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)
|
||||
else
|
||||
mtk_hw_reset(eth);
|
||||
|
||||
/* No MT7628/88 support yet */
|
||||
if (reset && !MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
|
||||
mtk_mdio_config(eth);
|
||||
|
||||
if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
/* Set FE to PDMAv2 if necessary */
|
||||
val = mtk_r32(eth, MTK_FE_GLO_MISC);
|
||||
|
||||
@@ -1260,6 +1260,7 @@ struct mtk_eth {
|
||||
struct clk *clks[MTK_CLK_MAX];
|
||||
|
||||
struct mii_bus *mii_bus;
|
||||
unsigned int mdc_divider;
|
||||
struct work_struct pending_work;
|
||||
unsigned long state;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user