[net-next v1 5/6] net: dwmac4: Add NCSI mac speed and duplex setting in NCSI case

From: Minda Chen

Date: Wed Jun 10 2026 - 05:05:48 EST


Add dwmac4 mac speed config and duplex setting in NCSI case
because NCSI lack of PHY, will not call stmmac_mac_link_up().

Signed-off-by: Minda Chen <minda.chen@xxxxxxxxxxxxxxxx>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index c6fcfae27c3d..7db4c5dc1f80 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -46,7 +46,20 @@ static void dwmac4_core_init(struct mac_device_info *hw,
u32 value;

value = readl(ioaddr + GMAC_CONFIG);
- writel(value | GMAC_CORE_INIT, ioaddr + GMAC_CONFIG);
+ if (priv->plat->use_ncsi) {
+ /*
+ * In NCSI case, because lack of PHY, will NOT
+ * set the mac speed config and mac duplex
+ * in stmmac_mac_link_up(). Now set these in
+ * core init function.
+ */
+ value |= GMAC_CORE_INIT;
+ value &= ~priv->hw->link.speed_mask;
+ value |= priv->hw->link.duplex | priv->hw->link.speed100;
+ writel(value, ioaddr + GMAC_CONFIG);
+ } else {
+ writel(value | GMAC_CORE_INIT, ioaddr + GMAC_CONFIG);
+ }

/* Configure LPI 1us counter to number of CSR clock ticks in 1us - 1 */
clk_rate = clk_get_rate(priv->plat->stmmac_clk);
--
2.17.1