netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2 net] lan78xx: workaround of forced 100 Full/Half duplex mode error
@ 2016-04-25 22:22 Woojung.Huh
  2016-04-28 20:36 ` David Miller
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Woojung.Huh @ 2016-04-25 22:22 UTC (permalink / raw)
  To: davem; +Cc: netdev, UNGLinuxDriver

From: Woojung Huh <woojung.huh@microchip.com>

At forced 100 Full & Half duplex mode, chip may fail to set mode correctly
when cable is switched between long(~50+m) and short one.
As workaround, set to 10 before setting to 100 at forced 100 F/H mode.

Signed-off-by: Woojung Huh <woojung.huh@microchip.com>
---
 drivers/net/usb/lan78xx.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 0460b81..f64778a 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1804,7 +1804,34 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev)
 
 static void lan78xx_link_status_change(struct net_device *net)
 {
-	/* nothing to do */
+	struct phy_device *phydev = net->phydev;
+	int ret, temp;
+
+	/* At forced 100 F/H mode, chip may fail to set mode correctly
+	 * when cable is switched between long(~50+m) and short one.
+	 * As workaround, set to 10 before setting to 100
+	 * at forced 100 F/H mode.
+	 */
+	if (!phydev->autoneg && (phydev->speed == 100)) {
+		/* disable phy interrupt */
+		temp = phy_read(phydev, LAN88XX_INT_MASK);
+		temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
+		ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
+
+		temp = phy_read(phydev, MII_BMCR);
+		temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000);
+		phy_write(phydev, MII_BMCR, temp); /* set to 10 first */
+		temp |= BMCR_SPEED100;
+		phy_write(phydev, MII_BMCR, temp); /* set to 100 later */
+
+		/* clear pending interrupt generated while workaround */
+		temp = phy_read(phydev, LAN88XX_INT_STS);
+
+		/* enable phy interrupt back */
+		temp = phy_read(phydev, LAN88XX_INT_MASK);
+		temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
+		ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
+	}
 }
 
 static int lan78xx_phy_init(struct lan78xx_net *dev)
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2022-12-21 18:03 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-25 22:22 [PATCH 2/2 net] lan78xx: workaround of forced 100 Full/Half duplex mode error Woojung.Huh
2016-04-28 20:36 ` David Miller
2021-01-22 14:19 ` Marc Kleine-Budde
2022-12-16 14:49 ` [PATCH] net: lan78xx: isolate LAN88XX specific operations Enguerrand de Ribaucourt
2022-12-20  9:40   ` Paolo Abeni
2022-12-20 11:37 ` [PATCH v2] net: lan78xx: prevent " Enguerrand de Ribaucourt
2022-12-20 12:41   ` Paolo Abeni
2022-12-20 12:47     ` Enguerrand de Ribaucourt
2022-12-20 12:45   ` Paolo Abeni
2022-12-20 13:10     ` Enguerrand de Ribaucourt
2022-12-21 16:40   ` kernel test robot
2022-12-20 13:19 ` [PATCH v3 0/3] " Enguerrand de Ribaucourt
2022-12-20 13:19 ` [PATCH v3 1/3] net: phy: add EXPORT_SYMBOL to phy_disable_interrupts() Enguerrand de Ribaucourt
2022-12-20 14:40   ` Heiner Kallweit
2022-12-20 15:02     ` Enguerrand de Ribaucourt
2022-12-20 15:17       ` Andrew Lunn
2022-12-20 15:19       ` Heiner Kallweit
2022-12-20 15:48         ` Enguerrand de Ribaucourt
2022-12-20 16:55           ` Andrew Lunn
2022-12-20 19:43             ` Woojung.Huh
2022-12-21 18:03               ` Yuiko.Oshino
2022-12-20 16:13       ` Russell King (Oracle)
2022-12-20 16:22         ` Enguerrand de Ribaucourt
2022-12-20 16:47           ` AW: " Sven Schuchmann
2022-12-20 13:19 ` [PATCH v3 2/3] net: phy: make phy_enable_interrupts() non-static Enguerrand de Ribaucourt
2022-12-20 13:19 ` [PATCH v3 3/3] net: lan78xx: prevent LAN88XX specific operations Enguerrand de Ribaucourt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).