aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorTrent Piepho <tpiepho@freescale.com>2008-11-19 18:52:41 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-19 18:52:41 -0500
commitde339c2aa7fea18410b1abeab5674bfbd4073a63 (patch)
tree07b2d6c08d5fa9b3400fc00a286654dd06b5461a /drivers/net
parent31c221c49f92d17632e0d662eb62a27e8b425805 (diff)
phylib: Fix auto-negotiation restart avoidance
A previous patch, 51e2a3846eab18711f4eb59cd0a4c33054e2980a, made genphy_config_aneg() not restart aneg by calling genphy_restart_aneg() if the advertisement hadn't changed. But, genphy_restart_aneg() doesn't just restart aneg, it may also *enable* aneg or un-isolate the PHY from the MII (those functions are controlled by the same register). The code to avoid calling genphy_restart_aneg() didn't consider this. So, modify genphy_config_aneg() to also check if the PHY needs to have aneg enabled or be un-isolated before deciding not to restart aneg. This caused a problem with certain Davicom PHYs, as that driver isolates the PHY (why?) before calling genphy_config_aneg() and expects the PHY to be un-isolated by that function. Signed-off-by: Trent Piepho <tpiepho@freescale.com> Reported-by: Scott Wood <scottwood@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/phy/phy_device.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8fb1faca883a..55bc24b234e3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -564,20 +564,32 @@ EXPORT_SYMBOL(genphy_restart_aneg);
564 */ 564 */
565int genphy_config_aneg(struct phy_device *phydev) 565int genphy_config_aneg(struct phy_device *phydev)
566{ 566{
567 int result = 0; 567 int result;
568 568
569 if (AUTONEG_ENABLE == phydev->autoneg) { 569 if (AUTONEG_ENABLE != phydev->autoneg)
570 int result = genphy_config_advert(phydev); 570 return genphy_setup_forced(phydev);
571
572 result = genphy_config_advert(phydev);
573
574 if (result < 0) /* error */
575 return result;
571 576
572 if (result < 0) /* error */ 577 if (result == 0) {
573 return result; 578 /* Advertisment hasn't changed, but maybe aneg was never on to
579 * begin with? Or maybe phy was isolated? */
580 int ctl = phy_read(phydev, MII_BMCR);
581
582 if (ctl < 0)
583 return ctl;
584
585 if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
586 result = 1; /* do restart aneg */
587 }
574 588
575 /* Only restart aneg if we are advertising something different 589 /* Only restart aneg if we are advertising something different
576 * than we were before. */ 590 * than we were before. */
577 if (result > 0) 591 if (result > 0)
578 result = genphy_restart_aneg(phydev); 592 result = genphy_restart_aneg(phydev);
579 } else
580 result = genphy_setup_forced(phydev);
581 593
582 return result; 594 return result;
583} 595}