summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/amd
diff options
context:
space:
mode:
authorLendacky, Thomas <Thomas.Lendacky@amd.com>2015-05-22 16:32:14 -0500
committerDavid S. Miller <davem@davemloft.net>2015-05-25 00:13:58 -0400
commit471e14b232d13463ae24212bec63d0a455eff16b (patch)
treedd158423c755d19e36e7d4902bca3bdc27a71284 /drivers/net/ethernet/amd
parent73c259165e2648638e959844434d899f58108567 (diff)
amd-xgbe: Fix initial mode when auto-negotiation 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. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/amd')
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-mdio.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
index cea19a37806e..8b86d94ef740 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
@@ -376,6 +376,45 @@ static void xgbe_set_mode(struct xgbe_prv_data *pdata,
xgbe_switch_mode(pdata);
}
+static bool xgbe_use_xgmii_mode(struct xgbe_prv_data *pdata)
+{
+ if (pdata->phy.autoneg == AUTONEG_ENABLE) {
+ if (pdata->phy.advertising & ADVERTISED_10000baseKR_Full)
+ return true;
+ } else {
+ if (pdata->phy.speed == SPEED_10000)
+ return true;
+ }
+
+ return false;
+}
+
+static bool xgbe_use_gmii_2500_mode(struct xgbe_prv_data *pdata)
+{
+ if (pdata->phy.autoneg == AUTONEG_ENABLE) {
+ if (pdata->phy.advertising & ADVERTISED_2500baseX_Full)
+ return true;
+ } else {
+ if (pdata->phy.speed == SPEED_2500)
+ return true;
+ }
+
+ return false;
+}
+
+static bool xgbe_use_gmii_mode(struct xgbe_prv_data *pdata)
+{
+ if (pdata->phy.autoneg == AUTONEG_ENABLE) {
+ if (pdata->phy.advertising & ADVERTISED_1000baseKX_Full)
+ return true;
+ } else {
+ if (pdata->phy.speed == SPEED_1000)
+ return true;
+ }
+
+ return false;
+}
+
static void xgbe_set_an(struct xgbe_prv_data *pdata, bool enable, bool restart)
{
unsigned int reg;
@@ -1108,11 +1147,11 @@ static int xgbe_phy_start(struct xgbe_prv_data *pdata)
/* Set initial mode - call the mode setting routines
* directly to insure we are properly configured
*/
- if (pdata->phy.advertising & ADVERTISED_10000baseKR_Full) {
+ if (xgbe_use_xgmii_mode(pdata)) {
xgbe_xgmii_mode(pdata);
- } else if (pdata->phy.advertising & ADVERTISED_1000baseKX_Full) {
+ } else if (xgbe_use_gmii_mode(pdata)) {
xgbe_gmii_mode(pdata);
- } else if (pdata->phy.advertising & ADVERTISED_2500baseX_Full) {
+ } else if (xgbe_use_gmii_2500_mode(pdata)) {
xgbe_gmii_2500_mode(pdata);
} else {
ret = -EINVAL;