[PATCH net-next v2 13/14] net: stmmac: configure SGMII AN control according to phylink
From: Russell King (Oracle) <hidden>
Date: 2026-01-23 10:03:45
Also in:
linux-arm-kernel, linux-arm-msm, linux-phy
Subsystem:
networking drivers, stmmac ethernet driver, the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
Provide phylink with the integrated PCS autonegotiation capabilities, and configure the PCS's AN settings according to phylink's requested requirements. This may cause regressions. Signed-off-by: Russell King (Oracle) <redacted> --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 4 ++-- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 ++-- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 20 ++++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index 18a0b678295d..31f6ac5432f2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c@@ -24,8 +24,8 @@ static const struct stmmac_pcs_info dwmac1000_pcs_info = { .pcs_offset = GMAC_PCS_BASE, - .rsgmii_offset = GMAC_RGSMIIIS, - .rsgmii_status_mask = GMAC_RSGMIIIS_MASK, + .rgsmii_offset = GMAC_RGSMIIIS, + .rgsmii_status_mask = GMAC_RSGMIIIS_MASK, .int_mask = GMAC_INT_DISABLE_PCSLINK | GMAC_INT_DISABLE_PCSAN, };
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index e7836bb27a9b..ced2cd98cc54 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c@@ -24,8 +24,8 @@ static const struct stmmac_pcs_info dwmac4_pcs_info = { .pcs_offset = GMAC_PCS_BASE, - .rsgmii_offset = GMAC_PHYIF_CONTROL_STATUS, - .rsgmii_status_mask = GMAC_PHYIF_CTRLSTATUS_RSGMII_MASK, + .rgsmii_offset = GMAC_PHYIF_CONTROL_STATUS, + .rgsmii_status_mask = GMAC_PHYIF_CTRLSTATUS_RSGMII_MASK, .int_mask = GMAC_INT_PCS_LINK | GMAC_INT_PCS_ANE, };
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
index 3b450e7f794c..978f66ea51f3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c@@ -65,7 +65,8 @@ static int dwmac_integrated_pcs_validate(struct phylink_pcs *pcs, static unsigned int dwmac_integrated_pcs_inband_caps(struct phylink_pcs *pcs, phy_interface_t interface) { - if (phy_interface_mode_is_8023z(interface)) + if (phy_interface_mode_is_8023z(interface) || + interface == PHY_INTERFACE_MODE_SGMII) return LINK_INBAND_ENABLE | LINK_INBAND_DISABLE; return 0;
@@ -164,8 +165,9 @@ static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs, bool permit_pause_to_mac) { struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs); - bool changed = false, ane = true; - u32 adv; + void __iomem *an_control = spcs->base + GMAC_AN_CTRL(0); + bool changed = false; + u32 adv, ctrl; int ret; if (spcs->interface != interface) {
@@ -182,12 +184,16 @@ static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs, if (readl(spcs->base + GMAC_ANE_ADV) != adv) changed = true; writel(adv, spcs->base + GMAC_ANE_ADV); - - ane = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED; } - dwmac_ctrl_ane(spcs->base, 0, ane, - spcs->priv->hw->reverse_sgmii_enable); + ctrl = readl(an_control) & ~(GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_SGMRAL); + if (spcs->priv->hw->reverse_sgmii_enable) + ctrl |= GMAC_AN_CTRL_SGMRAL | GMAC_AN_CTRL_ANE; + else if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) + ctrl |= GMAC_AN_CTRL_ANE; + else + ctrl |= GMAC_AN_CTRL_SGMRAL; + writel(ctrl, an_control); return changed; }
--
2.47.3