Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethoc: Account for duplex changes

ethoc_mdio_poll() which is our PHYLIB adjust_link callback does nothing,
we should at least react to duplex changes and change MODER accordingly.
Speed changes is not a problem, since the OpenCores Ethernet core seems
to be reacting okay without us telling it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Fainelli and committed by
David S. Miller
abf7e53e 1c0d32fd

+35
+35
drivers/net/ethernet/ethoc.c
··· 221 221 struct mii_bus *mdio; 222 222 struct clk *clk; 223 223 s8 phy_id; 224 + 225 + int old_link; 226 + int old_duplex; 224 227 }; 225 228 226 229 /** ··· 670 667 671 668 static void ethoc_mdio_poll(struct net_device *dev) 672 669 { 670 + struct ethoc *priv = netdev_priv(dev); 671 + struct phy_device *phydev = dev->phydev; 672 + bool changed = false; 673 + u32 mode; 674 + 675 + if (priv->old_link != phydev->link) { 676 + changed = true; 677 + priv->old_link = phydev->link; 678 + } 679 + 680 + if (priv->old_duplex != phydev->duplex) { 681 + changed = true; 682 + priv->old_duplex = phydev->duplex; 683 + } 684 + 685 + if (!changed) 686 + return; 687 + 688 + mode = ethoc_read(priv, MODER); 689 + if (phydev->duplex == DUPLEX_FULL) 690 + mode |= MODER_FULLD; 691 + else 692 + mode &= ~MODER_FULLD; 693 + ethoc_write(priv, MODER, mode); 694 + 695 + phy_print_status(phydev); 673 696 } 674 697 675 698 static int ethoc_mdio_probe(struct net_device *dev) ··· 713 684 dev_err(&dev->dev, "no PHY found\n"); 714 685 return -ENXIO; 715 686 } 687 + 688 + priv->old_duplex = -1; 689 + priv->old_link = -1; 716 690 717 691 err = phy_connect_direct(dev, phy, ethoc_mdio_poll, 718 692 PHY_INTERFACE_MODE_GMII); ··· 752 720 dev_dbg(&dev->dev, " starting queue\n"); 753 721 netif_start_queue(dev); 754 722 } 723 + 724 + priv->old_link = -1; 725 + priv->old_duplex = -1; 755 726 756 727 phy_start(dev->phydev); 757 728 napi_enable(&priv->napi);