aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/amd-xgbe-phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/amd-xgbe-phy.c')
-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;