aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/ethtool.c
diff options
context:
space:
mode:
authorBruce Allan <bruce.w.allan@intel.com>2010-06-16 09:25:55 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-19 01:12:14 -0400
commit3af50481eee6bb278da9050266ff31804e7a57d6 (patch)
tree34350fe19d0b53382060e126cdda662376d1b38a /drivers/net/e1000e/ethtool.c
parent20c0da65d72598ced2bfd4d4ca9a5aca1c93f5b9 (diff)
e1000e: cleanup ethtool loopback setup code
Refactor the loopback setup code to first handle the only 10/100 PHY supported by the driver if applicable and then handle the 1Gig PHYs in a switch statement for PHY-specific setups. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Emil Tantilov <emil.s.tantilov@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/e1000e/ethtool.c')
-rw-r--r--drivers/net/e1000e/ethtool.c74
1 files changed, 42 insertions, 32 deletions
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 2c521218102b..86c6a26c0a39 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1263,33 +1263,36 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1263 1263
1264 hw->mac.autoneg = 0; 1264 hw->mac.autoneg = 0;
1265 1265
1266 /* Workaround: K1 must be disabled for stable 1Gbps operation */ 1266 if (hw->phy.type == e1000_phy_ife) {
1267 if (hw->mac.type == e1000_pchlan)
1268 e1000_configure_k1_ich8lan(hw, false);
1269
1270 if (hw->phy.type == e1000_phy_m88) {
1271 /* Auto-MDI/MDIX Off */
1272 e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
1273 /* reset to update Auto-MDI/MDIX */
1274 e1e_wphy(hw, PHY_CONTROL, 0x9140);
1275 /* autoneg off */
1276 e1e_wphy(hw, PHY_CONTROL, 0x8140);
1277 } else if (hw->phy.type == e1000_phy_gg82563)
1278 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC);
1279
1280 ctrl_reg = er32(CTRL);
1281
1282 switch (hw->phy.type) {
1283 case e1000_phy_ife:
1284 /* force 100, set loopback */ 1267 /* force 100, set loopback */
1285 e1e_wphy(hw, PHY_CONTROL, 0x6100); 1268 e1e_wphy(hw, PHY_CONTROL, 0x6100);
1286 1269
1287 /* Now set up the MAC to the same speed/duplex as the PHY. */ 1270 /* Now set up the MAC to the same speed/duplex as the PHY. */
1271 ctrl_reg = er32(CTRL);
1288 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1272 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1289 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ 1273 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1290 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ 1274 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1291 E1000_CTRL_SPD_100 |/* Force Speed to 100 */ 1275 E1000_CTRL_SPD_100 |/* Force Speed to 100 */
1292 E1000_CTRL_FD); /* Force Duplex to FULL */ 1276 E1000_CTRL_FD); /* Force Duplex to FULL */
1277
1278 ew32(CTRL, ctrl_reg);
1279 udelay(500);
1280
1281 return 0;
1282 }
1283
1284 /* Specific PHY configuration for loopback */
1285 switch (hw->phy.type) {
1286 case e1000_phy_m88:
1287 /* Auto-MDI/MDIX Off */
1288 e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
1289 /* reset to update Auto-MDI/MDIX */
1290 e1e_wphy(hw, PHY_CONTROL, 0x9140);
1291 /* autoneg off */
1292 e1e_wphy(hw, PHY_CONTROL, 0x8140);
1293 break;
1294 case e1000_phy_gg82563:
1295 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC);
1293 break; 1296 break;
1294 case e1000_phy_bm: 1297 case e1000_phy_bm:
1295 /* Set Default MAC Interface speed to 1GB */ 1298 /* Set Default MAC Interface speed to 1GB */
@@ -1312,23 +1315,30 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1312 /* Set Early Link Enable */ 1315 /* Set Early Link Enable */
1313 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg); 1316 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1314 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400); 1317 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400);
1315 /* fall through */ 1318 break;
1319 case e1000_phy_82577:
1320 case e1000_phy_82578:
1321 /* Workaround: K1 must be disabled for stable 1Gbps operation */
1322 e1000_configure_k1_ich8lan(hw, false);
1323 break;
1316 default: 1324 default:
1317 /* force 1000, set loopback */ 1325 break;
1318 e1e_wphy(hw, PHY_CONTROL, 0x4140); 1326 }
1319 mdelay(250);
1320 1327
1321 /* Now set up the MAC to the same speed/duplex as the PHY. */ 1328 /* force 1000, set loopback */
1322 ctrl_reg = er32(CTRL); 1329 e1e_wphy(hw, PHY_CONTROL, 0x4140);
1323 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ 1330 mdelay(250);
1324 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1325 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1326 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1327 E1000_CTRL_FD); /* Force Duplex to FULL */
1328 1331
1329 if (adapter->flags & FLAG_IS_ICH) 1332 /* Now set up the MAC to the same speed/duplex as the PHY. */
1330 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */ 1333 ctrl_reg = er32(CTRL);
1331 } 1334 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1335 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1336 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1337 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1338 E1000_CTRL_FD); /* Force Duplex to FULL */
1339
1340 if (adapter->flags & FLAG_IS_ICH)
1341 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */
1332 1342
1333 if (hw->phy.media_type == e1000_media_type_copper && 1343 if (hw->phy.media_type == e1000_media_type_copper &&
1334 hw->phy.type == e1000_phy_m88) { 1344 hw->phy.type == e1000_phy_m88) {