Commit 49273163 authored by Jeff Kirsher's avatar Jeff Kirsher Committed by Jeff Garzik

[PATCH] e1000: Fix loopback logic

Fixed the loopback logic to work for the PCI express adapters.
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarJohn Ronciak <john.ronciak@intel.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 7bfa4816
...@@ -1326,22 +1326,33 @@ e1000_set_phy_loopback(struct e1000_adapter *adapter) ...@@ -1326,22 +1326,33 @@ e1000_set_phy_loopback(struct e1000_adapter *adapter)
static int static int
e1000_setup_loopback_test(struct e1000_adapter *adapter) e1000_setup_loopback_test(struct e1000_adapter *adapter)
{ {
struct e1000_hw *hw = &adapter->hw;
uint32_t rctl; uint32_t rctl;
if(adapter->hw.media_type == e1000_media_type_fiber || if (hw->media_type == e1000_media_type_fiber ||
adapter->hw.media_type == e1000_media_type_internal_serdes) { hw->media_type == e1000_media_type_internal_serdes) {
if(adapter->hw.mac_type == e1000_82545 || switch (hw->mac_type) {
adapter->hw.mac_type == e1000_82546 || case e1000_82545:
adapter->hw.mac_type == e1000_82545_rev_3 || case e1000_82546:
adapter->hw.mac_type == e1000_82546_rev_3) case e1000_82545_rev_3:
case e1000_82546_rev_3:
return e1000_set_phy_loopback(adapter); return e1000_set_phy_loopback(adapter);
else { break;
rctl = E1000_READ_REG(&adapter->hw, RCTL); case e1000_82571:
case e1000_82572:
#define E1000_SERDES_LB_ON 0x410
e1000_set_phy_loopback(adapter);
E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON);
msec_delay(10);
return 0;
break;
default:
rctl = E1000_READ_REG(hw, RCTL);
rctl |= E1000_RCTL_LBM_TCVR; rctl |= E1000_RCTL_LBM_TCVR;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl); E1000_WRITE_REG(hw, RCTL, rctl);
return 0; return 0;
} }
} else if(adapter->hw.media_type == e1000_media_type_copper) } else if (hw->media_type == e1000_media_type_copper)
return e1000_set_phy_loopback(adapter); return e1000_set_phy_loopback(adapter);
return 7; return 7;
...@@ -1350,27 +1361,38 @@ e1000_setup_loopback_test(struct e1000_adapter *adapter) ...@@ -1350,27 +1361,38 @@ e1000_setup_loopback_test(struct e1000_adapter *adapter)
static void static void
e1000_loopback_cleanup(struct e1000_adapter *adapter) e1000_loopback_cleanup(struct e1000_adapter *adapter)
{ {
struct e1000_hw *hw = &adapter->hw;
uint32_t rctl; uint32_t rctl;
uint16_t phy_reg; uint16_t phy_reg;
rctl = E1000_READ_REG(&adapter->hw, RCTL); rctl = E1000_READ_REG(hw, RCTL);
rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
E1000_WRITE_REG(&adapter->hw, RCTL, rctl); E1000_WRITE_REG(hw, RCTL, rctl);
if(adapter->hw.media_type == e1000_media_type_copper || switch (hw->mac_type) {
((adapter->hw.media_type == e1000_media_type_fiber || case e1000_82571:
adapter->hw.media_type == e1000_media_type_internal_serdes) && case e1000_82572:
(adapter->hw.mac_type == e1000_82545 || if (hw->media_type == e1000_media_type_fiber ||
adapter->hw.mac_type == e1000_82546 || hw->media_type == e1000_media_type_internal_serdes) {
adapter->hw.mac_type == e1000_82545_rev_3 || #define E1000_SERDES_LB_OFF 0x400
adapter->hw.mac_type == e1000_82546_rev_3))) { E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF);
adapter->hw.autoneg = TRUE; msec_delay(10);
e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); break;
if(phy_reg & MII_CR_LOOPBACK) { }
/* Fall Through */
case e1000_82545:
case e1000_82546:
case e1000_82545_rev_3:
case e1000_82546_rev_3:
default:
hw->autoneg = TRUE;
e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
if (phy_reg & MII_CR_LOOPBACK) {
phy_reg &= ~MII_CR_LOOPBACK; phy_reg &= ~MII_CR_LOOPBACK;
e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
e1000_phy_reset(&adapter->hw); e1000_phy_reset(hw);
} }
break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment