aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2014-02-03 15:35:46 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-04 23:15:51 -0500
commit5273e3a5ca94fbeb8e07d31203069220d5e682aa (patch)
treefe7b2b94abe1a8851cae5b6c3ffbd16bd1209b4a /drivers/net/phy
parent62ad968402466c4777a6634c86010e86521bc745 (diff)
net: phy: ensure Gigabit features are masked off if requested
When a Gigabit PHY device is connected to a 10/100Mbits capable Ethernet MAC, the driver will restrict the phydev->supported modes to mask off Gigabit. If the Gigabit PHY comes out of reset with the Gigabit features set by default in MII_CTRL1000, it will keep advertising these feature, so by the time we call genphy_config_advert(), the condition on phydev->supported having the Gigabit features on is false, and we do not update MII_CTRL1000 with updated values, and we keep advertising Gigabit features, eventually configuring the PHY for Gigabit whilst the Ethernet MAC does not support that. This patches fixes the problem by ensuring that the Gigabit feature bits are always cleared in MII_CTRL1000, if the PHY happens to be a Gigabit PHY, and then, if Gigabit features are supported, setting those and updating MII_CTRL1000 accordingly. Reported-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Tested-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/phy_device.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4b03e63639b7..82514e72b3d8 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -719,7 +719,7 @@ int phy_resume(struct phy_device *phydev)
719static int genphy_config_advert(struct phy_device *phydev) 719static int genphy_config_advert(struct phy_device *phydev)
720{ 720{
721 u32 advertise; 721 u32 advertise;
722 int oldadv, adv; 722 int oldadv, adv, bmsr;
723 int err, changed = 0; 723 int err, changed = 0;
724 724
725 /* Only allow advertising what this PHY supports */ 725 /* Only allow advertising what this PHY supports */
@@ -744,26 +744,36 @@ static int genphy_config_advert(struct phy_device *phydev)
744 changed = 1; 744 changed = 1;
745 } 745 }
746 746
747 bmsr = phy_read(phydev, MII_BMSR);
748 if (bmsr < 0)
749 return bmsr;
750
751 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all
752 * 1000Mbits/sec capable PHYs shall have the BMSR_ESTATEN bit set to a
753 * logical 1.
754 */
755 if (!(bmsr & BMSR_ESTATEN))
756 return changed;
757
747 /* Configure gigabit if it's supported */ 758 /* Configure gigabit if it's supported */
759 adv = phy_read(phydev, MII_CTRL1000);
760 if (adv < 0)
761 return adv;
762
763 oldadv = adv;
764 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
765
748 if (phydev->supported & (SUPPORTED_1000baseT_Half | 766 if (phydev->supported & (SUPPORTED_1000baseT_Half |
749 SUPPORTED_1000baseT_Full)) { 767 SUPPORTED_1000baseT_Full)) {
750 adv = phy_read(phydev, MII_CTRL1000);
751 if (adv < 0)
752 return adv;
753
754 oldadv = adv;
755 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
756 adv |= ethtool_adv_to_mii_ctrl1000_t(advertise); 768 adv |= ethtool_adv_to_mii_ctrl1000_t(advertise);
757 769 if (adv != oldadv)
758 if (adv != oldadv) {
759 err = phy_write(phydev, MII_CTRL1000, adv);
760
761 if (err < 0)
762 return err;
763 changed = 1; 770 changed = 1;
764 }
765 } 771 }
766 772
773 err = phy_write(phydev, MII_CTRL1000, adv);
774 if (err < 0)
775 return err;
776
767 return changed; 777 return changed;
768} 778}
769 779