Skip to content

Commit 14437e3

Browse files
WoojungHuhdavem330
authored andcommitted
lan78xx: workaround of forced 100 Full/Half duplex mode error
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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 74d79a2 commit 14437e3

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,34 @@ static void lan78xx_remove_mdio(struct lan78xx_net *dev)
18041804

18051805
static void lan78xx_link_status_change(struct net_device *net)
18061806
{
1807-
/* nothing to do */
1807+
struct phy_device *phydev = net->phydev;
1808+
int ret, temp;
1809+
1810+
/* At forced 100 F/H mode, chip may fail to set mode correctly
1811+
* when cable is switched between long(~50+m) and short one.
1812+
* As workaround, set to 10 before setting to 100
1813+
* at forced 100 F/H mode.
1814+
*/
1815+
if (!phydev->autoneg && (phydev->speed == 100)) {
1816+
/* disable phy interrupt */
1817+
temp = phy_read(phydev, LAN88XX_INT_MASK);
1818+
temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
1819+
ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
1820+
1821+
temp = phy_read(phydev, MII_BMCR);
1822+
temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000);
1823+
phy_write(phydev, MII_BMCR, temp); /* set to 10 first */
1824+
temp |= BMCR_SPEED100;
1825+
phy_write(phydev, MII_BMCR, temp); /* set to 100 later */
1826+
1827+
/* clear pending interrupt generated while workaround */
1828+
temp = phy_read(phydev, LAN88XX_INT_STS);
1829+
1830+
/* enable phy interrupt back */
1831+
temp = phy_read(phydev, LAN88XX_INT_MASK);
1832+
temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
1833+
ret = phy_write(phydev, LAN88XX_INT_MASK, temp);
1834+
}
18081835
}
18091836

18101837
static int lan78xx_phy_init(struct lan78xx_net *dev)

0 commit comments

Comments
 (0)