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) --- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 9dd7e78cfbc4..0426f608ebdf 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; @@ -162,8 +163,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) { @@ -180,12 +182,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