Skip to content

Commit 8c90b79

Browse files
hkallweitdavem330
authored andcommitted
net: phy: improve genphy_soft_reset
PHY's behave differently when being reset. Some reset registers to defaults, some don't. Some trigger an autoneg restart, some don't. So let's also set the autoneg restart bit when resetting. Then PHY behavior should be more consistent. Clearing BMCR_ISOLATE serves the same purpose and is borrowed from genphy_restart_aneg. BMCR holds the speed / duplex settings in fixed mode. Therefore we may have an issue if a soft reset resets BMCR to its default. So better call genphy_setup_forced() afterwards in fixed mode. We've seen no related complaint in the last >10 yrs, so let's treat it as an improvement. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f7abc06 commit 8c90b79

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/net/phy/phy_device.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,13 +1815,25 @@ EXPORT_SYMBOL(genphy_read_status);
18151815
*/
18161816
int genphy_soft_reset(struct phy_device *phydev)
18171817
{
1818+
u16 res = BMCR_RESET;
18181819
int ret;
18191820

1820-
ret = phy_set_bits(phydev, MII_BMCR, BMCR_RESET);
1821+
if (phydev->autoneg == AUTONEG_ENABLE)
1822+
res |= BMCR_ANRESTART;
1823+
1824+
ret = phy_modify(phydev, MII_BMCR, BMCR_ISOLATE, res);
18211825
if (ret < 0)
18221826
return ret;
18231827

1824-
return phy_poll_reset(phydev);
1828+
ret = phy_poll_reset(phydev);
1829+
if (ret)
1830+
return ret;
1831+
1832+
/* BMCR may be reset to defaults */
1833+
if (phydev->autoneg == AUTONEG_DISABLE)
1834+
ret = genphy_setup_forced(phydev);
1835+
1836+
return ret;
18251837
}
18261838
EXPORT_SYMBOL(genphy_soft_reset);
18271839

0 commit comments

Comments
 (0)