aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLendacky, Thomas <Thomas.Lendacky@amd.com>2015-05-26 10:51:49 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-26 19:47:30 -0400
commit983942a5eacae8821882a3d348618b020098e8dc (patch)
tree78dfbdb46aff14453df7075f887385bed2e55d56 /drivers/net
parentfe9066ade6a42a6f0bd22333e5831194104713ce (diff)
amd-xgbe-phy: Fix initial mode when autoneg is disabled
When the ethtool command is used to set the speed of the device while the device is down, the check to set the initial mode may fail when the device is brought up, causing failure to bring the device up. Update the code to set the initial mode based on the desired speed if auto-negotiation is disabled. This patch fixes a bug introduced by: d9663c8c2149 ("amd-xgbe-phy: Use phydev advertising field vs supported") Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/phy/amd-xgbe-phy.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/net/phy/amd-xgbe-phy.c b/drivers/net/phy/amd-xgbe-phy.c
index fb276f64cd64..34a75cba3b73 100644
--- a/drivers/net/phy/amd-xgbe-phy.c
+++ b/drivers/net/phy/amd-xgbe-phy.c
@@ -755,6 +755,45 @@ static int amd_xgbe_phy_set_mode(struct phy_device *phydev,
755 return ret; 755 return ret;
756} 756}
757 757
758static bool amd_xgbe_phy_use_xgmii_mode(struct phy_device *phydev)
759{
760 if (phydev->autoneg == AUTONEG_ENABLE) {
761 if (phydev->advertising & ADVERTISED_10000baseKR_Full)
762 return true;
763 } else {
764 if (phydev->speed == SPEED_10000)
765 return true;
766 }
767
768 return false;
769}
770
771static bool amd_xgbe_phy_use_gmii_2500_mode(struct phy_device *phydev)
772{
773 if (phydev->autoneg == AUTONEG_ENABLE) {
774 if (phydev->advertising & ADVERTISED_2500baseX_Full)
775 return true;
776 } else {
777 if (phydev->speed == SPEED_2500)
778 return true;
779 }
780
781 return false;
782}
783
784static bool amd_xgbe_phy_use_gmii_mode(struct phy_device *phydev)
785{
786 if (phydev->autoneg == AUTONEG_ENABLE) {
787 if (phydev->advertising & ADVERTISED_1000baseKX_Full)
788 return true;
789 } else {
790 if (phydev->speed == SPEED_1000)
791 return true;
792 }
793
794 return false;
795}
796
758static int amd_xgbe_phy_set_an(struct phy_device *phydev, bool enable, 797static int amd_xgbe_phy_set_an(struct phy_device *phydev, bool enable,
759 bool restart) 798 bool restart)
760{ 799{
@@ -1235,11 +1274,11 @@ static int amd_xgbe_phy_config_init(struct phy_device *phydev)
1235 /* Set initial mode - call the mode setting routines 1274 /* Set initial mode - call the mode setting routines
1236 * directly to insure we are properly configured 1275 * directly to insure we are properly configured
1237 */ 1276 */
1238 if (phydev->advertising & SUPPORTED_10000baseKR_Full) 1277 if (amd_xgbe_phy_use_xgmii_mode(phydev))
1239 ret = amd_xgbe_phy_xgmii_mode(phydev); 1278 ret = amd_xgbe_phy_xgmii_mode(phydev);
1240 else if (phydev->advertising & SUPPORTED_1000baseKX_Full) 1279 else if (amd_xgbe_phy_use_gmii_mode(phydev))
1241 ret = amd_xgbe_phy_gmii_mode(phydev); 1280 ret = amd_xgbe_phy_gmii_mode(phydev);
1242 else if (phydev->advertising & SUPPORTED_2500baseX_Full) 1281 else if (amd_xgbe_phy_use_gmii_2500_mode(phydev))
1243 ret = amd_xgbe_phy_gmii_2500_mode(phydev); 1282 ret = amd_xgbe_phy_gmii_2500_mode(phydev);
1244 else 1283 else
1245 ret = -EINVAL; 1284 ret = -EINVAL;