aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb/e1000_82575.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/igb/e1000_82575.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/igb/e1000_82575.c')
-rw-r--r--drivers/net/igb/e1000_82575.c603
1 files changed, 406 insertions, 197 deletions
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f8f5772557ce..4a32bed77c71 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -30,7 +30,6 @@
30 */ 30 */
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
34#include <linux/if_ether.h> 33#include <linux/if_ether.h>
35 34
36#include "e1000_mac.h" 35#include "e1000_mac.h"
@@ -46,7 +45,10 @@ static s32 igb_get_cfg_done_82575(struct e1000_hw *);
46static s32 igb_init_hw_82575(struct e1000_hw *); 45static s32 igb_init_hw_82575(struct e1000_hw *);
47static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *); 46static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *);
48static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *); 47static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *);
48static s32 igb_read_phy_reg_82580(struct e1000_hw *, u32, u16 *);
49static s32 igb_write_phy_reg_82580(struct e1000_hw *, u32, u16);
49static s32 igb_reset_hw_82575(struct e1000_hw *); 50static s32 igb_reset_hw_82575(struct e1000_hw *);
51static s32 igb_reset_hw_82580(struct e1000_hw *);
50static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool); 52static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool);
51static s32 igb_setup_copper_link_82575(struct e1000_hw *); 53static s32 igb_setup_copper_link_82575(struct e1000_hw *);
52static s32 igb_setup_serdes_link_82575(struct e1000_hw *); 54static s32 igb_setup_serdes_link_82575(struct e1000_hw *);
@@ -62,6 +64,12 @@ static s32 igb_reset_init_script_82575(struct e1000_hw *);
62static s32 igb_read_mac_addr_82575(struct e1000_hw *); 64static s32 igb_read_mac_addr_82575(struct e1000_hw *);
63static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw); 65static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw);
64 66
67static const u16 e1000_82580_rxpbs_table[] =
68 { 36, 72, 144, 1, 2, 4, 8, 16,
69 35, 70, 140 };
70#define E1000_82580_RXPBS_TABLE_SIZE \
71 (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
72
65static s32 igb_get_invariants_82575(struct e1000_hw *hw) 73static s32 igb_get_invariants_82575(struct e1000_hw *hw)
66{ 74{
67 struct e1000_phy_info *phy = &hw->phy; 75 struct e1000_phy_info *phy = &hw->phy;
@@ -81,12 +89,21 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
81 break; 89 break;
82 case E1000_DEV_ID_82576: 90 case E1000_DEV_ID_82576:
83 case E1000_DEV_ID_82576_NS: 91 case E1000_DEV_ID_82576_NS:
92 case E1000_DEV_ID_82576_NS_SERDES:
84 case E1000_DEV_ID_82576_FIBER: 93 case E1000_DEV_ID_82576_FIBER:
85 case E1000_DEV_ID_82576_SERDES: 94 case E1000_DEV_ID_82576_SERDES:
86 case E1000_DEV_ID_82576_QUAD_COPPER: 95 case E1000_DEV_ID_82576_QUAD_COPPER:
96 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
87 case E1000_DEV_ID_82576_SERDES_QUAD: 97 case E1000_DEV_ID_82576_SERDES_QUAD:
88 mac->type = e1000_82576; 98 mac->type = e1000_82576;
89 break; 99 break;
100 case E1000_DEV_ID_82580_COPPER:
101 case E1000_DEV_ID_82580_FIBER:
102 case E1000_DEV_ID_82580_SERDES:
103 case E1000_DEV_ID_82580_SGMII:
104 case E1000_DEV_ID_82580_COPPER_DUAL:
105 mac->type = e1000_82580;
106 break;
90 default: 107 default:
91 return -E1000_ERR_MAC_INIT; 108 return -E1000_ERR_MAC_INIT;
92 break; 109 break;
@@ -109,6 +126,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
109 dev_spec->sgmii_active = true; 126 dev_spec->sgmii_active = true;
110 ctrl_ext |= E1000_CTRL_I2C_ENA; 127 ctrl_ext |= E1000_CTRL_I2C_ENA;
111 break; 128 break;
129 case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
112 case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES: 130 case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
113 hw->phy.media_type = e1000_media_type_internal_serdes; 131 hw->phy.media_type = e1000_media_type_internal_serdes;
114 ctrl_ext |= E1000_CTRL_I2C_ENA; 132 ctrl_ext |= E1000_CTRL_I2C_ENA;
@@ -120,12 +138,26 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
120 138
121 wr32(E1000_CTRL_EXT, ctrl_ext); 139 wr32(E1000_CTRL_EXT, ctrl_ext);
122 140
141 /*
142 * if using i2c make certain the MDICNFG register is cleared to prevent
143 * communications from being misrouted to the mdic registers
144 */
145 if ((ctrl_ext & E1000_CTRL_I2C_ENA) && (hw->mac.type == e1000_82580))
146 wr32(E1000_MDICNFG, 0);
147
123 /* Set mta register count */ 148 /* Set mta register count */
124 mac->mta_reg_count = 128; 149 mac->mta_reg_count = 128;
125 /* Set rar entry count */ 150 /* Set rar entry count */
126 mac->rar_entry_count = E1000_RAR_ENTRIES_82575; 151 mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
127 if (mac->type == e1000_82576) 152 if (mac->type == e1000_82576)
128 mac->rar_entry_count = E1000_RAR_ENTRIES_82576; 153 mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
154 if (mac->type == e1000_82580)
155 mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
156 /* reset */
157 if (mac->type == e1000_82580)
158 mac->ops.reset_hw = igb_reset_hw_82580;
159 else
160 mac->ops.reset_hw = igb_reset_hw_82575;
129 /* Set if part includes ASF firmware */ 161 /* Set if part includes ASF firmware */
130 mac->asf_firmware_present = true; 162 mac->asf_firmware_present = true;
131 /* Set if manageability features are enabled. */ 163 /* Set if manageability features are enabled. */
@@ -193,6 +225,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
193 phy->ops.reset = igb_phy_hw_reset_sgmii_82575; 225 phy->ops.reset = igb_phy_hw_reset_sgmii_82575;
194 phy->ops.read_reg = igb_read_phy_reg_sgmii_82575; 226 phy->ops.read_reg = igb_read_phy_reg_sgmii_82575;
195 phy->ops.write_reg = igb_write_phy_reg_sgmii_82575; 227 phy->ops.write_reg = igb_write_phy_reg_sgmii_82575;
228 } else if (hw->mac.type == e1000_82580) {
229 phy->ops.reset = igb_phy_hw_reset;
230 phy->ops.read_reg = igb_read_phy_reg_82580;
231 phy->ops.write_reg = igb_write_phy_reg_82580;
196 } else { 232 } else {
197 phy->ops.reset = igb_phy_hw_reset; 233 phy->ops.reset = igb_phy_hw_reset;
198 phy->ops.read_reg = igb_read_phy_reg_igp; 234 phy->ops.read_reg = igb_read_phy_reg_igp;
@@ -224,6 +260,12 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
224 phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575; 260 phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575;
225 phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state; 261 phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state;
226 break; 262 break;
263 case I82580_I_PHY_ID:
264 phy->type = e1000_phy_82580;
265 phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580;
266 phy->ops.get_cable_length = igb_get_cable_length_82580;
267 phy->ops.get_phy_info = igb_get_phy_info_82580;
268 break;
227 default: 269 default:
228 return -E1000_ERR_PHY; 270 return -E1000_ERR_PHY;
229 } 271 }
@@ -240,9 +282,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
240 **/ 282 **/
241static s32 igb_acquire_phy_82575(struct e1000_hw *hw) 283static s32 igb_acquire_phy_82575(struct e1000_hw *hw)
242{ 284{
243 u16 mask; 285 u16 mask = E1000_SWFW_PHY0_SM;
244 286
245 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; 287 if (hw->bus.func == E1000_FUNC_1)
288 mask = E1000_SWFW_PHY1_SM;
246 289
247 return igb_acquire_swfw_sync_82575(hw, mask); 290 return igb_acquire_swfw_sync_82575(hw, mask);
248} 291}
@@ -256,9 +299,11 @@ static s32 igb_acquire_phy_82575(struct e1000_hw *hw)
256 **/ 299 **/
257static void igb_release_phy_82575(struct e1000_hw *hw) 300static void igb_release_phy_82575(struct e1000_hw *hw)
258{ 301{
259 u16 mask; 302 u16 mask = E1000_SWFW_PHY0_SM;
303
304 if (hw->bus.func == E1000_FUNC_1)
305 mask = E1000_SWFW_PHY1_SM;
260 306
261 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
262 igb_release_swfw_sync_82575(hw, mask); 307 igb_release_swfw_sync_82575(hw, mask);
263} 308}
264 309
@@ -274,45 +319,23 @@ static void igb_release_phy_82575(struct e1000_hw *hw)
274static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset, 319static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
275 u16 *data) 320 u16 *data)
276{ 321{
277 struct e1000_phy_info *phy = &hw->phy; 322 s32 ret_val = -E1000_ERR_PARAM;
278 u32 i, i2ccmd = 0;
279 323
280 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) { 324 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
281 hw_dbg("PHY Address %u is out of range\n", offset); 325 hw_dbg("PHY Address %u is out of range\n", offset);
282 return -E1000_ERR_PARAM; 326 goto out;
283 } 327 }
284 328
285 /* 329 ret_val = hw->phy.ops.acquire(hw);
286 * Set up Op-code, Phy Address, and register address in the I2CCMD 330 if (ret_val)
287 * register. The MAC will take care of interfacing with the 331 goto out;
288 * PHY to retrieve the desired data.
289 */
290 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
291 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
292 (E1000_I2CCMD_OPCODE_READ));
293
294 wr32(E1000_I2CCMD, i2ccmd);
295 332
296 /* Poll the ready bit to see if the I2C read completed */ 333 ret_val = igb_read_phy_reg_i2c(hw, offset, data);
297 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
298 udelay(50);
299 i2ccmd = rd32(E1000_I2CCMD);
300 if (i2ccmd & E1000_I2CCMD_READY)
301 break;
302 }
303 if (!(i2ccmd & E1000_I2CCMD_READY)) {
304 hw_dbg("I2CCMD Read did not complete\n");
305 return -E1000_ERR_PHY;
306 }
307 if (i2ccmd & E1000_I2CCMD_ERROR) {
308 hw_dbg("I2CCMD Error bit set\n");
309 return -E1000_ERR_PHY;
310 }
311 334
312 /* Need to byte-swap the 16-bit value. */ 335 hw->phy.ops.release(hw);
313 *data = ((i2ccmd >> 8) & 0x00FF) | ((i2ccmd << 8) & 0xFF00);
314 336
315 return 0; 337out:
338 return ret_val;
316} 339}
317 340
318/** 341/**
@@ -327,47 +350,24 @@ static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
327static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset, 350static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
328 u16 data) 351 u16 data)
329{ 352{
330 struct e1000_phy_info *phy = &hw->phy; 353 s32 ret_val = -E1000_ERR_PARAM;
331 u32 i, i2ccmd = 0; 354
332 u16 phy_data_swapped;
333 355
334 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) { 356 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
335 hw_dbg("PHY Address %d is out of range\n", offset); 357 hw_dbg("PHY Address %d is out of range\n", offset);
336 return -E1000_ERR_PARAM; 358 goto out;
337 } 359 }
338 360
339 /* Swap the data bytes for the I2C interface */ 361 ret_val = hw->phy.ops.acquire(hw);
340 phy_data_swapped = ((data >> 8) & 0x00FF) | ((data << 8) & 0xFF00); 362 if (ret_val)
363 goto out;
341 364
342 /* 365 ret_val = igb_write_phy_reg_i2c(hw, offset, data);
343 * Set up Op-code, Phy Address, and register address in the I2CCMD
344 * register. The MAC will take care of interfacing with the
345 * PHY to retrieve the desired data.
346 */
347 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
348 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
349 E1000_I2CCMD_OPCODE_WRITE |
350 phy_data_swapped);
351
352 wr32(E1000_I2CCMD, i2ccmd);
353
354 /* Poll the ready bit to see if the I2C read completed */
355 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
356 udelay(50);
357 i2ccmd = rd32(E1000_I2CCMD);
358 if (i2ccmd & E1000_I2CCMD_READY)
359 break;
360 }
361 if (!(i2ccmd & E1000_I2CCMD_READY)) {
362 hw_dbg("I2CCMD Write did not complete\n");
363 return -E1000_ERR_PHY;
364 }
365 if (i2ccmd & E1000_I2CCMD_ERROR) {
366 hw_dbg("I2CCMD Error bit set\n");
367 return -E1000_ERR_PHY;
368 }
369 366
370 return 0; 367 hw->phy.ops.release(hw);
368
369out:
370 return ret_val;
371} 371}
372 372
373/** 373/**
@@ -676,6 +676,10 @@ static s32 igb_get_cfg_done_82575(struct e1000_hw *hw)
676 676
677 if (hw->bus.func == 1) 677 if (hw->bus.func == 1)
678 mask = E1000_NVM_CFG_DONE_PORT_1; 678 mask = E1000_NVM_CFG_DONE_PORT_1;
679 else if (hw->bus.func == E1000_FUNC_2)
680 mask = E1000_NVM_CFG_DONE_PORT_2;
681 else if (hw->bus.func == E1000_FUNC_3)
682 mask = E1000_NVM_CFG_DONE_PORT_3;
679 683
680 while (timeout) { 684 while (timeout) {
681 if (rd32(E1000_EEMNGCTL) & mask) 685 if (rd32(E1000_EEMNGCTL) & mask)
@@ -706,9 +710,7 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)
706 s32 ret_val; 710 s32 ret_val;
707 u16 speed, duplex; 711 u16 speed, duplex;
708 712
709 /* SGMII link check is done through the PCS register. */ 713 if (hw->phy.media_type != e1000_media_type_copper) {
710 if ((hw->phy.media_type != e1000_media_type_copper) ||
711 (igb_sgmii_active_82575(hw))) {
712 ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed, 714 ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
713 &duplex); 715 &duplex);
714 /* 716 /*
@@ -723,6 +725,35 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)
723 725
724 return ret_val; 726 return ret_val;
725} 727}
728
729/**
730 * igb_power_up_serdes_link_82575 - Power up the serdes link after shutdown
731 * @hw: pointer to the HW structure
732 **/
733void igb_power_up_serdes_link_82575(struct e1000_hw *hw)
734{
735 u32 reg;
736
737
738 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
739 !igb_sgmii_active_82575(hw))
740 return;
741
742 /* Enable PCS to turn on link */
743 reg = rd32(E1000_PCS_CFG0);
744 reg |= E1000_PCS_CFG_PCS_EN;
745 wr32(E1000_PCS_CFG0, reg);
746
747 /* Power up the laser */
748 reg = rd32(E1000_CTRL_EXT);
749 reg &= ~E1000_CTRL_EXT_SDP3_DATA;
750 wr32(E1000_CTRL_EXT, reg);
751
752 /* flush the write to verify completion */
753 wrfl();
754 msleep(1);
755}
756
726/** 757/**
727 * igb_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex 758 * igb_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
728 * @hw: pointer to the HW structure 759 * @hw: pointer to the HW structure
@@ -789,11 +820,10 @@ void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
789{ 820{
790 u32 reg; 821 u32 reg;
791 822
792 if (hw->phy.media_type != e1000_media_type_internal_serdes || 823 if (hw->phy.media_type != e1000_media_type_internal_serdes &&
793 igb_sgmii_active_82575(hw)) 824 igb_sgmii_active_82575(hw))
794 return; 825 return;
795 826
796 /* if the management interface is not enabled, then power down */
797 if (!igb_enable_mng_pass_thru(hw)) { 827 if (!igb_enable_mng_pass_thru(hw)) {
798 /* Disable PCS to turn off link */ 828 /* Disable PCS to turn off link */
799 reg = rd32(E1000_PCS_CFG0); 829 reg = rd32(E1000_PCS_CFG0);
@@ -809,8 +839,6 @@ void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
809 wrfl(); 839 wrfl();
810 msleep(1); 840 msleep(1);
811 } 841 }
812
813 return;
814} 842}
815 843
816/** 844/**
@@ -908,6 +936,11 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)
908 for (i = 0; i < mac->mta_reg_count; i++) 936 for (i = 0; i < mac->mta_reg_count; i++)
909 array_wr32(E1000_MTA, i, 0); 937 array_wr32(E1000_MTA, i, 0);
910 938
939 /* Zero out the Unicast HASH table */
940 hw_dbg("Zeroing the UTA\n");
941 for (i = 0; i < mac->uta_reg_count; i++)
942 array_wr32(E1000_UTA, i, 0);
943
911 /* Setup link and flow control */ 944 /* Setup link and flow control */
912 ret_val = igb_setup_link(hw); 945 ret_val = igb_setup_link(hw);
913 946
@@ -934,7 +967,6 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
934{ 967{
935 u32 ctrl; 968 u32 ctrl;
936 s32 ret_val; 969 s32 ret_val;
937 bool link;
938 970
939 ctrl = rd32(E1000_CTRL); 971 ctrl = rd32(E1000_CTRL);
940 ctrl |= E1000_CTRL_SLU; 972 ctrl |= E1000_CTRL_SLU;
@@ -946,6 +978,9 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
946 goto out; 978 goto out;
947 979
948 if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) { 980 if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) {
981 /* allow time for SFP cage time to power up phy */
982 msleep(300);
983
949 ret_val = hw->phy.ops.reset(hw); 984 ret_val = hw->phy.ops.reset(hw);
950 if (ret_val) { 985 if (ret_val) {
951 hw_dbg("Error resetting the PHY.\n"); 986 hw_dbg("Error resetting the PHY.\n");
@@ -959,6 +994,9 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
959 case e1000_phy_igp_3: 994 case e1000_phy_igp_3:
960 ret_val = igb_copper_link_setup_igp(hw); 995 ret_val = igb_copper_link_setup_igp(hw);
961 break; 996 break;
997 case e1000_phy_82580:
998 ret_val = igb_copper_link_setup_82580(hw);
999 break;
962 default: 1000 default:
963 ret_val = -E1000_ERR_PHY; 1001 ret_val = -E1000_ERR_PHY;
964 break; 1002 break;
@@ -967,57 +1005,24 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
967 if (ret_val) 1005 if (ret_val)
968 goto out; 1006 goto out;
969 1007
970 if (hw->mac.autoneg) { 1008 ret_val = igb_setup_copper_link(hw);
971 /*
972 * Setup autoneg and flow control advertisement
973 * and perform autonegotiation.
974 */
975 ret_val = igb_copper_link_autoneg(hw);
976 if (ret_val)
977 goto out;
978 } else {
979 /*
980 * PHY will be set to 10H, 10F, 100H or 100F
981 * depending on user settings.
982 */
983 hw_dbg("Forcing Speed and Duplex\n");
984 ret_val = hw->phy.ops.force_speed_duplex(hw);
985 if (ret_val) {
986 hw_dbg("Error Forcing Speed and Duplex\n");
987 goto out;
988 }
989 }
990
991 /*
992 * Check link status. Wait up to 100 microseconds for link to become
993 * valid.
994 */
995 ret_val = igb_phy_has_link(hw, COPPER_LINK_UP_LIMIT, 10, &link);
996 if (ret_val)
997 goto out;
998
999 if (link) {
1000 hw_dbg("Valid link established!!!\n");
1001 /* Config the MAC and PHY after link is up */
1002 igb_config_collision_dist(hw);
1003 ret_val = igb_config_fc_after_link_up(hw);
1004 } else {
1005 hw_dbg("Unable to establish link!!!\n");
1006 }
1007
1008out: 1009out:
1009 return ret_val; 1010 return ret_val;
1010} 1011}
1011 1012
1012/** 1013/**
1013 * igb_setup_serdes_link_82575 - Setup link for fiber/serdes 1014 * igb_setup_serdes_link_82575 - Setup link for serdes
1014 * @hw: pointer to the HW structure 1015 * @hw: pointer to the HW structure
1015 * 1016 *
1016 * Configures speed and duplex for fiber and serdes links. 1017 * Configure the physical coding sub-layer (PCS) link. The PCS link is
1018 * used on copper connections where the serialized gigabit media independent
1019 * interface (sgmii), or serdes fiber is being used. Configures the link
1020 * for auto-negotiation or forces speed/duplex.
1017 **/ 1021 **/
1018static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) 1022static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
1019{ 1023{
1020 u32 ctrl_reg, reg; 1024 u32 ctrl_ext, ctrl_reg, reg;
1025 bool pcs_autoneg;
1021 1026
1022 if ((hw->phy.media_type != e1000_media_type_internal_serdes) && 1027 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
1023 !igb_sgmii_active_82575(hw)) 1028 !igb_sgmii_active_82575(hw))
@@ -1032,9 +1037,9 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
1032 wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); 1037 wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1033 1038
1034 /* power on the sfp cage if present */ 1039 /* power on the sfp cage if present */
1035 reg = rd32(E1000_CTRL_EXT); 1040 ctrl_ext = rd32(E1000_CTRL_EXT);
1036 reg &= ~E1000_CTRL_EXT_SDP3_DATA; 1041 ctrl_ext &= ~E1000_CTRL_EXT_SDP3_DATA;
1037 wr32(E1000_CTRL_EXT, reg); 1042 wr32(E1000_CTRL_EXT, ctrl_ext);
1038 1043
1039 ctrl_reg = rd32(E1000_CTRL); 1044 ctrl_reg = rd32(E1000_CTRL);
1040 ctrl_reg |= E1000_CTRL_SLU; 1045 ctrl_reg |= E1000_CTRL_SLU;
@@ -1051,15 +1056,31 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
1051 1056
1052 reg = rd32(E1000_PCS_LCTL); 1057 reg = rd32(E1000_PCS_LCTL);
1053 1058
1054 if (igb_sgmii_active_82575(hw)) { 1059 /* default pcs_autoneg to the same setting as mac autoneg */
1055 /* allow time for SFP cage to power up phy */ 1060 pcs_autoneg = hw->mac.autoneg;
1056 msleep(300);
1057 1061
1058 /* AN time out should be disabled for SGMII mode */ 1062 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
1063 case E1000_CTRL_EXT_LINK_MODE_SGMII:
1064 /* sgmii mode lets the phy handle forcing speed/duplex */
1065 pcs_autoneg = true;
1066 /* autoneg time out should be disabled for SGMII mode */
1059 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT); 1067 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
1060 } else { 1068 break;
1069 case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
1070 /* disable PCS autoneg and support parallel detect only */
1071 pcs_autoneg = false;
1072 default:
1073 /*
1074 * non-SGMII modes only supports a speed of 1000/Full for the
1075 * link so it is best to just force the MAC and let the pcs
1076 * link either autoneg or be forced to 1000/Full
1077 */
1061 ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD | 1078 ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
1062 E1000_CTRL_FD | E1000_CTRL_FRCDPX; 1079 E1000_CTRL_FD | E1000_CTRL_FRCDPX;
1080
1081 /* set speed of 1000/Full if speed/duplex is forced */
1082 reg |= E1000_PCS_LCTL_FSV_1000 | E1000_PCS_LCTL_FDV_FULL;
1083 break;
1063 } 1084 }
1064 1085
1065 wr32(E1000_CTRL, ctrl_reg); 1086 wr32(E1000_CTRL, ctrl_reg);
@@ -1070,7 +1091,6 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
1070 * mode that will be compatible with older link partners and switches. 1091 * mode that will be compatible with older link partners and switches.
1071 * However, both are supported by the hardware and some drivers/tools. 1092 * However, both are supported by the hardware and some drivers/tools.
1072 */ 1093 */
1073
1074 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | 1094 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
1075 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); 1095 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
1076 1096
@@ -1080,25 +1100,16 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
1080 */ 1100 */
1081 reg |= E1000_PCS_LCTL_FORCE_FCTRL; 1101 reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1082 1102
1083 /* 1103 if (pcs_autoneg) {
1084 * we always set sgmii to autoneg since it is the phy that will be
1085 * forcing the link and the serdes is just a go-between
1086 */
1087 if (hw->mac.autoneg || igb_sgmii_active_82575(hw)) {
1088 /* Set PCS register for autoneg */ 1104 /* Set PCS register for autoneg */
1089 reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */ 1105 reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
1090 E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */ 1106 E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
1091 E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */ 1107 hw_dbg("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
1092 E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
1093 hw_dbg("Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
1094 } else { 1108 } else {
1095 /* Set PCS register for forced speed */ 1109 /* Set PCS register for forced link */
1096 reg |= E1000_PCS_LCTL_FLV_LINK_UP | /* Force link up */ 1110 reg |= E1000_PCS_LCTL_FSD; /* Force Speed */
1097 E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */ 1111
1098 E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */ 1112 hw_dbg("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
1099 E1000_PCS_LCTL_FSD | /* Force Speed */
1100 E1000_PCS_LCTL_FORCE_LINK; /* Force Link */
1101 hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
1102 } 1113 }
1103 1114
1104 wr32(E1000_PCS_LCTL, reg); 1115 wr32(E1000_PCS_LCTL, reg);
@@ -1167,13 +1178,38 @@ static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
1167{ 1178{
1168 s32 ret_val = 0; 1179 s32 ret_val = 0;
1169 1180
1170 if (igb_check_alt_mac_addr(hw)) 1181 /*
1171 ret_val = igb_read_mac_addr(hw); 1182 * If there's an alternate MAC address place it in RAR0
1183 * so that it will override the Si installed default perm
1184 * address.
1185 */
1186 ret_val = igb_check_alt_mac_addr(hw);
1187 if (ret_val)
1188 goto out;
1189
1190 ret_val = igb_read_mac_addr(hw);
1172 1191
1192out:
1173 return ret_val; 1193 return ret_val;
1174} 1194}
1175 1195
1176/** 1196/**
1197 * igb_power_down_phy_copper_82575 - Remove link during PHY power down
1198 * @hw: pointer to the HW structure
1199 *
1200 * In the case of a PHY power down to save power, or to turn off link during a
1201 * driver unload, or wake on lan is not enabled, remove the link.
1202 **/
1203void igb_power_down_phy_copper_82575(struct e1000_hw *hw)
1204{
1205 /* If the management interface is not enabled, then power down */
1206 if (!(igb_enable_mng_pass_thru(hw) || igb_check_reset_block(hw)))
1207 igb_power_down_phy_copper(hw);
1208
1209 return;
1210}
1211
1212/**
1177 * igb_clear_hw_cntrs_82575 - Clear device specific hardware counters 1213 * igb_clear_hw_cntrs_82575 - Clear device specific hardware counters
1178 * @hw: pointer to the HW structure 1214 * @hw: pointer to the HW structure
1179 * 1215 *
@@ -1181,61 +1217,59 @@ static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
1181 **/ 1217 **/
1182static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw) 1218static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw)
1183{ 1219{
1184 u32 temp;
1185
1186 igb_clear_hw_cntrs_base(hw); 1220 igb_clear_hw_cntrs_base(hw);
1187 1221
1188 temp = rd32(E1000_PRC64); 1222 rd32(E1000_PRC64);
1189 temp = rd32(E1000_PRC127); 1223 rd32(E1000_PRC127);
1190 temp = rd32(E1000_PRC255); 1224 rd32(E1000_PRC255);
1191 temp = rd32(E1000_PRC511); 1225 rd32(E1000_PRC511);
1192 temp = rd32(E1000_PRC1023); 1226 rd32(E1000_PRC1023);
1193 temp = rd32(E1000_PRC1522); 1227 rd32(E1000_PRC1522);
1194 temp = rd32(E1000_PTC64); 1228 rd32(E1000_PTC64);
1195 temp = rd32(E1000_PTC127); 1229 rd32(E1000_PTC127);
1196 temp = rd32(E1000_PTC255); 1230 rd32(E1000_PTC255);
1197 temp = rd32(E1000_PTC511); 1231 rd32(E1000_PTC511);
1198 temp = rd32(E1000_PTC1023); 1232 rd32(E1000_PTC1023);
1199 temp = rd32(E1000_PTC1522); 1233 rd32(E1000_PTC1522);
1200 1234
1201 temp = rd32(E1000_ALGNERRC); 1235 rd32(E1000_ALGNERRC);
1202 temp = rd32(E1000_RXERRC); 1236 rd32(E1000_RXERRC);
1203 temp = rd32(E1000_TNCRS); 1237 rd32(E1000_TNCRS);
1204 temp = rd32(E1000_CEXTERR); 1238 rd32(E1000_CEXTERR);
1205 temp = rd32(E1000_TSCTC); 1239 rd32(E1000_TSCTC);
1206 temp = rd32(E1000_TSCTFC); 1240 rd32(E1000_TSCTFC);
1207 1241
1208 temp = rd32(E1000_MGTPRC); 1242 rd32(E1000_MGTPRC);
1209 temp = rd32(E1000_MGTPDC); 1243 rd32(E1000_MGTPDC);
1210 temp = rd32(E1000_MGTPTC); 1244 rd32(E1000_MGTPTC);
1211 1245
1212 temp = rd32(E1000_IAC); 1246 rd32(E1000_IAC);
1213 temp = rd32(E1000_ICRXOC); 1247 rd32(E1000_ICRXOC);
1214 1248
1215 temp = rd32(E1000_ICRXPTC); 1249 rd32(E1000_ICRXPTC);
1216 temp = rd32(E1000_ICRXATC); 1250 rd32(E1000_ICRXATC);
1217 temp = rd32(E1000_ICTXPTC); 1251 rd32(E1000_ICTXPTC);
1218 temp = rd32(E1000_ICTXATC); 1252 rd32(E1000_ICTXATC);
1219 temp = rd32(E1000_ICTXQEC); 1253 rd32(E1000_ICTXQEC);
1220 temp = rd32(E1000_ICTXQMTC); 1254 rd32(E1000_ICTXQMTC);
1221 temp = rd32(E1000_ICRXDMTC); 1255 rd32(E1000_ICRXDMTC);
1222 1256
1223 temp = rd32(E1000_CBTMPC); 1257 rd32(E1000_CBTMPC);
1224 temp = rd32(E1000_HTDPMC); 1258 rd32(E1000_HTDPMC);
1225 temp = rd32(E1000_CBRMPC); 1259 rd32(E1000_CBRMPC);
1226 temp = rd32(E1000_RPTHC); 1260 rd32(E1000_RPTHC);
1227 temp = rd32(E1000_HGPTC); 1261 rd32(E1000_HGPTC);
1228 temp = rd32(E1000_HTCBDPC); 1262 rd32(E1000_HTCBDPC);
1229 temp = rd32(E1000_HGORCL); 1263 rd32(E1000_HGORCL);
1230 temp = rd32(E1000_HGORCH); 1264 rd32(E1000_HGORCH);
1231 temp = rd32(E1000_HGOTCL); 1265 rd32(E1000_HGOTCL);
1232 temp = rd32(E1000_HGOTCH); 1266 rd32(E1000_HGOTCH);
1233 temp = rd32(E1000_LENERRS); 1267 rd32(E1000_LENERRS);
1234 1268
1235 /* This register should not be read in copper configurations */ 1269 /* This register should not be read in copper configurations */
1236 if (hw->phy.media_type == e1000_media_type_internal_serdes || 1270 if (hw->phy.media_type == e1000_media_type_internal_serdes ||
1237 igb_sgmii_active_82575(hw)) 1271 igb_sgmii_active_82575(hw))
1238 temp = rd32(E1000_SCVPC); 1272 rd32(E1000_SCVPC);
1239} 1273}
1240 1274
1241/** 1275/**
@@ -1400,8 +1434,183 @@ void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
1400 wr32(E1000_VT_CTL, vt_ctl); 1434 wr32(E1000_VT_CTL, vt_ctl);
1401} 1435}
1402 1436
1437/**
1438 * igb_read_phy_reg_82580 - Read 82580 MDI control register
1439 * @hw: pointer to the HW structure
1440 * @offset: register offset to be read
1441 * @data: pointer to the read data
1442 *
1443 * Reads the MDI control register in the PHY at offset and stores the
1444 * information read to data.
1445 **/
1446static s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data)
1447{
1448 u32 mdicnfg = 0;
1449 s32 ret_val;
1450
1451
1452 ret_val = hw->phy.ops.acquire(hw);
1453 if (ret_val)
1454 goto out;
1455
1456 /*
1457 * We config the phy address in MDICNFG register now. Same bits
1458 * as before. The values in MDIC can be written but will be
1459 * ignored. This allows us to call the old function after
1460 * configuring the PHY address in the new register
1461 */
1462 mdicnfg = (hw->phy.addr << E1000_MDIC_PHY_SHIFT);
1463 wr32(E1000_MDICNFG, mdicnfg);
1464
1465 ret_val = igb_read_phy_reg_mdic(hw, offset, data);
1466
1467 hw->phy.ops.release(hw);
1468
1469out:
1470 return ret_val;
1471}
1472
1473/**
1474 * igb_write_phy_reg_82580 - Write 82580 MDI control register
1475 * @hw: pointer to the HW structure
1476 * @offset: register offset to write to
1477 * @data: data to write to register at offset
1478 *
1479 * Writes data to MDI control register in the PHY at offset.
1480 **/
1481static s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data)
1482{
1483 u32 mdicnfg = 0;
1484 s32 ret_val;
1485
1486
1487 ret_val = hw->phy.ops.acquire(hw);
1488 if (ret_val)
1489 goto out;
1490
1491 /*
1492 * We config the phy address in MDICNFG register now. Same bits
1493 * as before. The values in MDIC can be written but will be
1494 * ignored. This allows us to call the old function after
1495 * configuring the PHY address in the new register
1496 */
1497 mdicnfg = (hw->phy.addr << E1000_MDIC_PHY_SHIFT);
1498 wr32(E1000_MDICNFG, mdicnfg);
1499
1500 ret_val = igb_write_phy_reg_mdic(hw, offset, data);
1501
1502 hw->phy.ops.release(hw);
1503
1504out:
1505 return ret_val;
1506}
1507
1508/**
1509 * igb_reset_hw_82580 - Reset hardware
1510 * @hw: pointer to the HW structure
1511 *
1512 * This resets function or entire device (all ports, etc.)
1513 * to a known state.
1514 **/
1515static s32 igb_reset_hw_82580(struct e1000_hw *hw)
1516{
1517 s32 ret_val = 0;
1518 /* BH SW mailbox bit in SW_FW_SYNC */
1519 u16 swmbsw_mask = E1000_SW_SYNCH_MB;
1520 u32 ctrl, icr;
1521 bool global_device_reset = hw->dev_spec._82575.global_device_reset;
1522
1523
1524 hw->dev_spec._82575.global_device_reset = false;
1525
1526 /* Get current control state. */
1527 ctrl = rd32(E1000_CTRL);
1528
1529 /*
1530 * Prevent the PCI-E bus from sticking if there is no TLP connection
1531 * on the last TLP read/write transaction when MAC is reset.
1532 */
1533 ret_val = igb_disable_pcie_master(hw);
1534 if (ret_val)
1535 hw_dbg("PCI-E Master disable polling has failed.\n");
1536
1537 hw_dbg("Masking off all interrupts\n");
1538 wr32(E1000_IMC, 0xffffffff);
1539 wr32(E1000_RCTL, 0);
1540 wr32(E1000_TCTL, E1000_TCTL_PSP);
1541 wrfl();
1542
1543 msleep(10);
1544
1545 /* Determine whether or not a global dev reset is requested */
1546 if (global_device_reset &&
1547 igb_acquire_swfw_sync_82575(hw, swmbsw_mask))
1548 global_device_reset = false;
1549
1550 if (global_device_reset &&
1551 !(rd32(E1000_STATUS) & E1000_STAT_DEV_RST_SET))
1552 ctrl |= E1000_CTRL_DEV_RST;
1553 else
1554 ctrl |= E1000_CTRL_RST;
1555
1556 wr32(E1000_CTRL, ctrl);
1557
1558 /* Add delay to insure DEV_RST has time to complete */
1559 if (global_device_reset)
1560 msleep(5);
1561
1562 ret_val = igb_get_auto_rd_done(hw);
1563 if (ret_val) {
1564 /*
1565 * When auto config read does not complete, do not
1566 * return with an error. This can happen in situations
1567 * where there is no eeprom and prevents getting link.
1568 */
1569 hw_dbg("Auto Read Done did not complete\n");
1570 }
1571
1572 /* If EEPROM is not present, run manual init scripts */
1573 if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
1574 igb_reset_init_script_82575(hw);
1575
1576 /* clear global device reset status bit */
1577 wr32(E1000_STATUS, E1000_STAT_DEV_RST_SET);
1578
1579 /* Clear any pending interrupt events. */
1580 wr32(E1000_IMC, 0xffffffff);
1581 icr = rd32(E1000_ICR);
1582
1583 /* Install any alternate MAC address into RAR0 */
1584 ret_val = igb_check_alt_mac_addr(hw);
1585
1586 /* Release semaphore */
1587 if (global_device_reset)
1588 igb_release_swfw_sync_82575(hw, swmbsw_mask);
1589
1590 return ret_val;
1591}
1592
1593/**
1594 * igb_rxpbs_adjust_82580 - adjust RXPBS value to reflect actual RX PBA size
1595 * @data: data received by reading RXPBS register
1596 *
1597 * The 82580 uses a table based approach for packet buffer allocation sizes.
1598 * This function converts the retrieved value into the correct table value
1599 * 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7
1600 * 0x0 36 72 144 1 2 4 8 16
1601 * 0x8 35 70 140 rsv rsv rsv rsv rsv
1602 */
1603u16 igb_rxpbs_adjust_82580(u32 data)
1604{
1605 u16 ret_val = 0;
1606
1607 if (data < E1000_82580_RXPBS_TABLE_SIZE)
1608 ret_val = e1000_82580_rxpbs_table[data];
1609
1610 return ret_val;
1611}
1612
1403static struct e1000_mac_operations e1000_mac_ops_82575 = { 1613static struct e1000_mac_operations e1000_mac_ops_82575 = {
1404 .reset_hw = igb_reset_hw_82575,
1405 .init_hw = igb_init_hw_82575, 1614 .init_hw = igb_init_hw_82575,
1406 .check_for_link = igb_check_for_link_82575, 1615 .check_for_link = igb_check_for_link_82575,
1407 .rar_set = igb_rar_set, 1616 .rar_set = igb_rar_set,