Re: [PATCH v3 2/5] net: macb: add support for sgmii MAC-PHY interface
From: Russell King - ARM Linux admin
Date: Fri Jun 21 2019 - 04:52:27 EST
On Fri, Jun 21, 2019 at 09:34:50AM +0100, Parshuram Thombare wrote:
> @@ -486,23 +503,54 @@ static void gem_mac_config(struct phylink_config *pl_config, unsigned int mode,
> {
> struct net_device *netdev = to_net_dev(pl_config->dev);
> struct macb *bp = netdev_priv(netdev);
> + bool change_interface = bp->phy_interface != state->interface;
> unsigned long flags;
>
> spin_lock_irqsave(&bp->lock, flags);
>
> + if (change_interface) {
> + if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII ||
> + bp->phy_interface == PHY_INTERFACE_MODE_1000BASEX ||
> + bp->phy_interface == PHY_INTERFACE_MODE_2500BASEX) {
> + gem_writel(bp, NCFGR, ~GEM_BIT(SGMIIEN) &
> + ~GEM_BIT(PCSSEL) &
> + gem_readl(bp, NCFGR));
> + gem_writel(bp, NCR, ~GEM_BIT(TWO_PT_FIVE_GIG) &
> + gem_readl(bp, NCR));
> + gem_writel(bp, PCS_CTRL, gem_readl(bp, PCS_CTRL) |
> + GEM_BIT(PCS_CTRL_RST));
> + }
> + bp->phy_interface = state->interface;
> + }
> +
> if (!phylink_autoneg_inband(mode) &&
> (bp->speed != state->speed ||
> - bp->duplex != state->duplex)) {
> + bp->duplex != state->duplex ||
> + change_interface)) {
> u32 reg;
>
> reg = macb_readl(bp, NCFGR);
> reg &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
> if (macb_is_gem(bp))
> reg &= ~GEM_BIT(GBE);
> + macb_or_gem_writel(bp, NCFGR, reg);
> +
> + if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII ||
> + bp->phy_interface == PHY_INTERFACE_MODE_1000BASEX ||
> + bp->phy_interface == PHY_INTERFACE_MODE_2500BASEX)
> + gem_writel(bp, NCFGR, GEM_BIT(SGMIIEN) |
> + GEM_BIT(PCSSEL) |
> + gem_readl(bp, NCFGR));
You don't appear to treat SGMII any differently from the 802.3z modes.
They are certainly not the same thing, so this doesn't seem to be
correct. Also, placing this here, I don't see how the MAC gets
configured for SGMII if in-band mode is enabled.
> +
> + reg = macb_readl(bp, NCFGR);
> if (state->duplex)
> reg |= MACB_BIT(FD);
>
> switch (state->speed) {
> + case SPEED_2500:
> + gem_writel(bp, NCR, GEM_BIT(TWO_PT_FIVE_GIG) |
> + gem_readl(bp, NCR));
> + break;
> case SPEED_1000:
> reg |= GEM_BIT(GBE);
> break;
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up