1 /******************************************************************************
3 Copyright (c) 2001-2010, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ******************************************************************************/
36 * 82571EB Gigabit Ethernet Controller
37 * 82571EB Gigabit Ethernet Controller (Copper)
38 * 82571EB Gigabit Ethernet Controller (Fiber)
39 * 82571EB Dual Port Gigabit Mezzanine Adapter
40 * 82571EB Quad Port Gigabit Mezzanine Adapter
41 * 82571PT Gigabit PT Quad Port Server ExpressModule
42 * 82572EI Gigabit Ethernet Controller (Copper)
43 * 82572EI Gigabit Ethernet Controller (Fiber)
44 * 82572EI Gigabit Ethernet Controller
45 * 82573V Gigabit Ethernet Controller (Copper)
46 * 82573E Gigabit Ethernet Controller (Copper)
47 * 82573L Gigabit Ethernet Controller
48 * 82574L Gigabit Network Connection
49 * 82583V Gigabit Network Connection
52 #include "e1000_api.h"
54 static s32 e1000_init_phy_params_82571(struct e1000_hw *hw);
55 static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw);
56 static s32 e1000_init_mac_params_82571(struct e1000_hw *hw);
57 static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw);
58 static void e1000_release_nvm_82571(struct e1000_hw *hw);
59 static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset,
60 u16 words, u16 *data);
61 static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw);
62 static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw);
63 static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw);
64 static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw,
66 static s32 e1000_reset_hw_82571(struct e1000_hw *hw);
67 static s32 e1000_init_hw_82571(struct e1000_hw *hw);
68 static void e1000_clear_vfta_82571(struct e1000_hw *hw);
69 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
70 static s32 e1000_led_on_82574(struct e1000_hw *hw);
71 static s32 e1000_setup_link_82571(struct e1000_hw *hw);
72 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
73 static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw);
74 static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
75 static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data);
76 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
77 static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw);
78 static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
79 static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
80 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
81 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
82 static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
83 u16 words, u16 *data);
84 static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw);
85 static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
88 * e1000_init_phy_params_82571 - Init PHY func ptrs.
89 * @hw: pointer to the HW structure
91 static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
93 struct e1000_phy_info *phy = &hw->phy;
94 s32 ret_val = E1000_SUCCESS;
96 DEBUGFUNC("e1000_init_phy_params_82571");
98 if (hw->phy.media_type != e1000_media_type_copper) {
99 phy->type = e1000_phy_none;
104 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
105 phy->reset_delay_us = 100;
107 phy->ops.acquire = e1000_get_hw_semaphore_82571;
108 phy->ops.check_reset_block = e1000_check_reset_block_generic;
109 phy->ops.release = e1000_put_hw_semaphore_82571;
110 phy->ops.reset = e1000_phy_hw_reset_generic;
111 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82571;
112 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_generic;
113 phy->ops.power_up = e1000_power_up_phy_copper;
114 phy->ops.power_down = e1000_power_down_phy_copper_82571;
116 switch (hw->mac.type) {
119 phy->type = e1000_phy_igp_2;
120 phy->ops.get_cfg_done = e1000_get_cfg_done_82571;
121 phy->ops.get_info = e1000_get_phy_info_igp;
122 phy->ops.check_polarity = e1000_check_polarity_igp;
123 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
124 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
125 phy->ops.read_reg = e1000_read_phy_reg_igp;
126 phy->ops.write_reg = e1000_write_phy_reg_igp;
128 /* This uses above function pointers */
129 ret_val = e1000_get_phy_id_82571(hw);
132 if (phy->id != IGP01E1000_I_PHY_ID) {
133 ret_val = -E1000_ERR_PHY;
134 DEBUGOUT1("PHY ID unknown: type = 0x%08x\n", phy->id);
139 phy->type = e1000_phy_m88;
140 phy->ops.get_cfg_done = e1000_get_cfg_done_generic;
141 phy->ops.get_info = e1000_get_phy_info_m88;
142 phy->ops.check_polarity = e1000_check_polarity_m88;
143 phy->ops.commit = e1000_phy_sw_reset_generic;
144 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
145 phy->ops.get_cable_length = e1000_get_cable_length_m88;
146 phy->ops.read_reg = e1000_read_phy_reg_m88;
147 phy->ops.write_reg = e1000_write_phy_reg_m88;
149 /* This uses above function pointers */
150 ret_val = e1000_get_phy_id_82571(hw);
153 if (phy->id != M88E1111_I_PHY_ID) {
154 ret_val = -E1000_ERR_PHY;
155 DEBUGOUT1("PHY ID unknown: type = 0x%08x\n", phy->id);
161 phy->type = e1000_phy_bm;
162 phy->ops.get_cfg_done = e1000_get_cfg_done_generic;
163 phy->ops.get_info = e1000_get_phy_info_m88;
164 phy->ops.check_polarity = e1000_check_polarity_m88;
165 phy->ops.commit = e1000_phy_sw_reset_generic;
166 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
167 phy->ops.get_cable_length = e1000_get_cable_length_m88;
168 phy->ops.read_reg = e1000_read_phy_reg_bm2;
169 phy->ops.write_reg = e1000_write_phy_reg_bm2;
171 /* This uses above function pointers */
172 ret_val = e1000_get_phy_id_82571(hw);
174 if (phy->id != BME1000_E_PHY_ID_R2) {
175 ret_val = -E1000_ERR_PHY;
176 DEBUGOUT1("PHY ID unknown: type = 0x%08x\n", phy->id);
181 ret_val = -E1000_ERR_PHY;
191 * e1000_init_nvm_params_82571 - Init NVM func ptrs.
192 * @hw: pointer to the HW structure
194 static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
196 struct e1000_nvm_info *nvm = &hw->nvm;
197 u32 eecd = E1000_READ_REG(hw, E1000_EECD);
200 DEBUGFUNC("e1000_init_nvm_params_82571");
202 nvm->opcode_bits = 8;
204 switch (nvm->override) {
205 case e1000_nvm_override_spi_large:
207 nvm->address_bits = 16;
209 case e1000_nvm_override_spi_small:
211 nvm->address_bits = 8;
214 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
215 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
219 switch (hw->mac.type) {
223 if (((eecd >> 15) & 0x3) == 0x3) {
224 nvm->type = e1000_nvm_flash_hw;
225 nvm->word_size = 2048;
227 * Autonomous Flash update bit must be cleared due
228 * to Flash update issue.
230 eecd &= ~E1000_EECD_AUPDEN;
231 E1000_WRITE_REG(hw, E1000_EECD, eecd);
236 nvm->type = e1000_nvm_eeprom_spi;
237 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
238 E1000_EECD_SIZE_EX_SHIFT);
240 * Added to a constant, "size" becomes the left-shift value
241 * for setting word_size.
243 size += NVM_WORD_SIZE_BASE_SHIFT;
245 /* EEPROM access above 16k is unsupported */
248 nvm->word_size = 1 << size;
252 /* Function Pointers */
253 nvm->ops.acquire = e1000_acquire_nvm_82571;
254 nvm->ops.read = e1000_read_nvm_eerd;
255 nvm->ops.release = e1000_release_nvm_82571;
256 nvm->ops.update = e1000_update_nvm_checksum_82571;
257 nvm->ops.validate = e1000_validate_nvm_checksum_82571;
258 nvm->ops.valid_led_default = e1000_valid_led_default_82571;
259 nvm->ops.write = e1000_write_nvm_82571;
261 return E1000_SUCCESS;
265 * e1000_init_mac_params_82571 - Init MAC func ptrs.
266 * @hw: pointer to the HW structure
268 static s32 e1000_init_mac_params_82571(struct e1000_hw *hw)
270 struct e1000_mac_info *mac = &hw->mac;
273 bool force_clear_smbi = FALSE;
275 DEBUGFUNC("e1000_init_mac_params_82571");
277 /* Set media type and media-dependent function pointers */
278 switch (hw->device_id) {
279 case E1000_DEV_ID_82571EB_FIBER:
280 case E1000_DEV_ID_82572EI_FIBER:
281 case E1000_DEV_ID_82571EB_QUAD_FIBER:
282 hw->phy.media_type = e1000_media_type_fiber;
283 mac->ops.setup_physical_interface =
284 e1000_setup_fiber_serdes_link_82571;
285 mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
286 mac->ops.get_link_up_info =
287 e1000_get_speed_and_duplex_fiber_serdes_generic;
289 case E1000_DEV_ID_82571EB_SERDES:
290 case E1000_DEV_ID_82571EB_SERDES_DUAL:
291 case E1000_DEV_ID_82571EB_SERDES_QUAD:
292 case E1000_DEV_ID_82572EI_SERDES:
293 hw->phy.media_type = e1000_media_type_internal_serdes;
294 mac->ops.setup_physical_interface =
295 e1000_setup_fiber_serdes_link_82571;
296 mac->ops.check_for_link = e1000_check_for_serdes_link_82571;
297 mac->ops.get_link_up_info =
298 e1000_get_speed_and_duplex_fiber_serdes_generic;
301 hw->phy.media_type = e1000_media_type_copper;
302 mac->ops.setup_physical_interface =
303 e1000_setup_copper_link_82571;
304 mac->ops.check_for_link = e1000_check_for_copper_link_generic;
305 mac->ops.get_link_up_info =
306 e1000_get_speed_and_duplex_copper_generic;
310 /* Set mta register count */
311 mac->mta_reg_count = 128;
312 /* Set rar entry count */
313 mac->rar_entry_count = E1000_RAR_ENTRIES;
314 /* Set if part includes ASF firmware */
315 mac->asf_firmware_present = TRUE;
316 /* Adaptive IFS supported */
317 mac->adaptive_ifs = TRUE;
319 /* Function pointers */
321 /* bus type/speed/width */
322 mac->ops.get_bus_info = e1000_get_bus_info_pcie_generic;
324 mac->ops.reset_hw = e1000_reset_hw_82571;
325 /* hw initialization */
326 mac->ops.init_hw = e1000_init_hw_82571;
328 mac->ops.setup_link = e1000_setup_link_82571;
329 /* multicast address update */
330 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
332 mac->ops.write_vfta = e1000_write_vfta_generic;
334 mac->ops.clear_vfta = e1000_clear_vfta_82571;
335 /* read mac address */
336 mac->ops.read_mac_addr = e1000_read_mac_addr_82571;
338 mac->ops.id_led_init = e1000_id_led_init_generic;
340 mac->ops.blink_led = e1000_blink_led_generic;
342 mac->ops.setup_led = e1000_setup_led_generic;
344 mac->ops.cleanup_led = e1000_cleanup_led_generic;
346 mac->ops.led_off = e1000_led_off_generic;
347 /* clear hardware counters */
348 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82571;
350 /* MAC-specific function pointers */
351 switch (hw->mac.type) {
353 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
354 mac->ops.check_mng_mode = e1000_check_mng_mode_generic;
355 mac->ops.led_on = e1000_led_on_generic;
358 mac->has_fwsm = TRUE;
360 * ARC supported; valid only if manageability features are
363 mac->arc_subsystem_valid =
364 (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK)
369 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
370 mac->ops.check_mng_mode = e1000_check_mng_mode_82574;
371 mac->ops.led_on = e1000_led_on_82574;
374 mac->ops.check_mng_mode = e1000_check_mng_mode_generic;
375 mac->ops.led_on = e1000_led_on_generic;
378 mac->has_fwsm = TRUE;
383 * Ensure that the inter-port SWSM.SMBI lock bit is clear before
384 * first NVM or PHY acess. This should be done for single-port
385 * devices, and for one port only on dual-port devices so that
386 * for those devices we can still use the SMBI lock to synchronize
387 * inter-port accesses to the PHY & NVM.
389 switch (hw->mac.type) {
392 swsm2 = E1000_READ_REG(hw, E1000_SWSM2);
394 if (!(swsm2 & E1000_SWSM2_LOCK)) {
395 /* Only do this for the first interface on this card */
396 E1000_WRITE_REG(hw, E1000_SWSM2,
397 swsm2 | E1000_SWSM2_LOCK);
398 force_clear_smbi = TRUE;
400 force_clear_smbi = FALSE;
403 force_clear_smbi = TRUE;
407 if (force_clear_smbi) {
408 /* Make sure SWSM.SMBI is clear */
409 swsm = E1000_READ_REG(hw, E1000_SWSM);
410 if (swsm & E1000_SWSM_SMBI) {
411 /* This bit should not be set on a first interface, and
412 * indicates that the bootagent or EFI code has
413 * improperly left this bit enabled
415 DEBUGOUT("Please update your 82571 Bootagent\n");
417 E1000_WRITE_REG(hw, E1000_SWSM, swsm & ~E1000_SWSM_SMBI);
421 * Initialze device specific counter of SMBI acquisition
424 hw->dev_spec._82571.smb_counter = 0;
426 return E1000_SUCCESS;
430 * e1000_init_function_pointers_82571 - Init func ptrs.
431 * @hw: pointer to the HW structure
433 * Called to initialize all function pointers and parameters.
435 void e1000_init_function_pointers_82571(struct e1000_hw *hw)
437 DEBUGFUNC("e1000_init_function_pointers_82571");
439 hw->mac.ops.init_params = e1000_init_mac_params_82571;
440 hw->nvm.ops.init_params = e1000_init_nvm_params_82571;
441 hw->phy.ops.init_params = e1000_init_phy_params_82571;
445 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
446 * @hw: pointer to the HW structure
448 * Reads the PHY registers and stores the PHY ID and possibly the PHY
449 * revision in the hardware structure.
451 static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
453 struct e1000_phy_info *phy = &hw->phy;
454 s32 ret_val = E1000_SUCCESS;
457 DEBUGFUNC("e1000_get_phy_id_82571");
459 switch (hw->mac.type) {
463 * The 82571 firmware may still be configuring the PHY.
464 * In this case, we cannot access the PHY until the
465 * configuration is done. So we explicitly set the
468 phy->id = IGP01E1000_I_PHY_ID;
471 ret_val = e1000_get_phy_id(hw);
475 ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
479 phy->id = (u32)(phy_id << 16);
481 ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id);
485 phy->id |= (u32)(phy_id);
486 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
489 ret_val = -E1000_ERR_PHY;
497 * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
498 * @hw: pointer to the HW structure
500 * Acquire the HW semaphore to access the PHY or NVM
502 static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
505 s32 ret_val = E1000_SUCCESS;
506 s32 sw_timeout = hw->nvm.word_size + 1;
507 s32 fw_timeout = hw->nvm.word_size + 1;
510 DEBUGFUNC("e1000_get_hw_semaphore_82571");
513 * If we have timedout 3 times on trying to acquire
514 * the inter-port SMBI semaphore, there is old code
515 * operating on the other port, and it is not
516 * releasing SMBI. Modify the number of times that
517 * we try for the semaphore to interwork with this
520 if (hw->dev_spec._82571.smb_counter > 2)
523 /* Get the SW semaphore */
524 while (i < sw_timeout) {
525 swsm = E1000_READ_REG(hw, E1000_SWSM);
526 if (!(swsm & E1000_SWSM_SMBI))
533 if (i == sw_timeout) {
534 DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
535 hw->dev_spec._82571.smb_counter++;
537 /* Get the FW semaphore. */
538 for (i = 0; i < fw_timeout; i++) {
539 swsm = E1000_READ_REG(hw, E1000_SWSM);
540 E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
542 /* Semaphore acquired if bit latched */
543 if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI)
549 if (i == fw_timeout) {
550 /* Release semaphores */
551 e1000_put_hw_semaphore_82571(hw);
552 DEBUGOUT("Driver can't access the NVM\n");
553 ret_val = -E1000_ERR_NVM;
562 * e1000_put_hw_semaphore_82571 - Release hardware semaphore
563 * @hw: pointer to the HW structure
565 * Release hardware semaphore used to access the PHY or NVM
567 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
571 DEBUGFUNC("e1000_put_hw_semaphore_generic");
573 swsm = E1000_READ_REG(hw, E1000_SWSM);
575 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
577 E1000_WRITE_REG(hw, E1000_SWSM, swsm);
581 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
582 * @hw: pointer to the HW structure
584 * To gain access to the EEPROM, first we must obtain a hardware semaphore.
585 * Then for non-82573 hardware, set the EEPROM access request bit and wait
586 * for EEPROM access grant bit. If the access grant bit is not set, release
587 * hardware semaphore.
589 static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
593 DEBUGFUNC("e1000_acquire_nvm_82571");
595 ret_val = e1000_get_hw_semaphore_82571(hw);
599 switch (hw->mac.type) {
605 ret_val = e1000_acquire_nvm_generic(hw);
610 e1000_put_hw_semaphore_82571(hw);
617 * e1000_release_nvm_82571 - Release exclusive access to EEPROM
618 * @hw: pointer to the HW structure
620 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
622 static void e1000_release_nvm_82571(struct e1000_hw *hw)
624 DEBUGFUNC("e1000_release_nvm_82571");
626 e1000_release_nvm_generic(hw);
627 e1000_put_hw_semaphore_82571(hw);
631 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
632 * @hw: pointer to the HW structure
633 * @offset: offset within the EEPROM to be written to
634 * @words: number of words to write
635 * @data: 16 bit word(s) to be written to the EEPROM
637 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
639 * If e1000_update_nvm_checksum is not called after this function, the
640 * EEPROM will most likely contain an invalid checksum.
642 static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
645 s32 ret_val = E1000_SUCCESS;
647 DEBUGFUNC("e1000_write_nvm_82571");
649 switch (hw->mac.type) {
653 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
657 ret_val = e1000_write_nvm_spi(hw, offset, words, data);
660 ret_val = -E1000_ERR_NVM;
668 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
669 * @hw: pointer to the HW structure
671 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
672 * up to the checksum. Then calculates the EEPROM checksum and writes the
673 * value to the EEPROM.
675 static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
681 DEBUGFUNC("e1000_update_nvm_checksum_82571");
683 ret_val = e1000_update_nvm_checksum_generic(hw);
688 * If our nvm is an EEPROM, then we're done
689 * otherwise, commit the checksum to the flash NVM.
691 if (hw->nvm.type != e1000_nvm_flash_hw)
694 /* Check for pending operations. */
695 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
697 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_FLUPD) == 0)
701 if (i == E1000_FLASH_UPDATES) {
702 ret_val = -E1000_ERR_NVM;
706 /* Reset the firmware if using STM opcode. */
707 if ((E1000_READ_REG(hw, E1000_FLOP) & 0xFF00) == E1000_STM_OPCODE) {
709 * The enabling of and the actual reset must be done
710 * in two write cycles.
712 E1000_WRITE_REG(hw, E1000_HICR, E1000_HICR_FW_RESET_ENABLE);
713 E1000_WRITE_FLUSH(hw);
714 E1000_WRITE_REG(hw, E1000_HICR, E1000_HICR_FW_RESET);
717 /* Commit the write to flash */
718 eecd = E1000_READ_REG(hw, E1000_EECD) | E1000_EECD_FLUPD;
719 E1000_WRITE_REG(hw, E1000_EECD, eecd);
721 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
723 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_FLUPD) == 0)
727 if (i == E1000_FLASH_UPDATES) {
728 ret_val = -E1000_ERR_NVM;
737 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
738 * @hw: pointer to the HW structure
740 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
741 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
743 static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
745 DEBUGFUNC("e1000_validate_nvm_checksum_82571");
747 if (hw->nvm.type == e1000_nvm_flash_hw)
748 e1000_fix_nvm_checksum_82571(hw);
750 return e1000_validate_nvm_checksum_generic(hw);
754 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
755 * @hw: pointer to the HW structure
756 * @offset: offset within the EEPROM to be written to
757 * @words: number of words to write
758 * @data: 16 bit word(s) to be written to the EEPROM
760 * After checking for invalid values, poll the EEPROM to ensure the previous
761 * command has completed before trying to write the next word. After write
762 * poll for completion.
764 * If e1000_update_nvm_checksum is not called after this function, the
765 * EEPROM will most likely contain an invalid checksum.
767 static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
768 u16 words, u16 *data)
770 struct e1000_nvm_info *nvm = &hw->nvm;
774 DEBUGFUNC("e1000_write_nvm_eewr_82571");
777 * A check for invalid values: offset too large, too many words,
778 * and not enough words.
780 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
782 DEBUGOUT("nvm parameter(s) out of bounds\n");
783 ret_val = -E1000_ERR_NVM;
787 for (i = 0; i < words; i++) {
788 eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
789 ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
790 E1000_NVM_RW_REG_START;
792 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
796 E1000_WRITE_REG(hw, E1000_EEWR, eewr);
798 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
808 * e1000_get_cfg_done_82571 - Poll for configuration done
809 * @hw: pointer to the HW structure
811 * Reads the management control register for the config done bit to be set.
813 static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
815 s32 timeout = PHY_CFG_TIMEOUT;
816 s32 ret_val = E1000_SUCCESS;
818 DEBUGFUNC("e1000_get_cfg_done_82571");
821 if (E1000_READ_REG(hw, E1000_EEMNGCTL) &
822 E1000_NVM_CFG_DONE_PORT_0)
828 DEBUGOUT("MNG configuration cycle has not completed.\n");
829 ret_val = -E1000_ERR_RESET;
838 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
839 * @hw: pointer to the HW structure
840 * @active: TRUE to enable LPLU, FALSE to disable
842 * Sets the LPLU D0 state according to the active flag. When activating LPLU
843 * this function also disables smart speed and vice versa. LPLU will not be
844 * activated unless the device autonegotiation advertisement meets standards
845 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
846 * pointer entry point only called by PHY setup routines.
848 static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
850 struct e1000_phy_info *phy = &hw->phy;
851 s32 ret_val = E1000_SUCCESS;
854 DEBUGFUNC("e1000_set_d0_lplu_state_82571");
856 if (!(phy->ops.read_reg))
859 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
864 data |= IGP02E1000_PM_D0_LPLU;
865 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
870 /* When LPLU is enabled, we should disable SmartSpeed */
871 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
873 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
874 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
879 data &= ~IGP02E1000_PM_D0_LPLU;
880 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
883 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
884 * during Dx states where the power conservation is most
885 * important. During driver activity we should enable
886 * SmartSpeed, so performance is maintained.
888 if (phy->smart_speed == e1000_smart_speed_on) {
889 ret_val = phy->ops.read_reg(hw,
890 IGP01E1000_PHY_PORT_CONFIG,
895 data |= IGP01E1000_PSCFR_SMART_SPEED;
896 ret_val = phy->ops.write_reg(hw,
897 IGP01E1000_PHY_PORT_CONFIG,
901 } else if (phy->smart_speed == e1000_smart_speed_off) {
902 ret_val = phy->ops.read_reg(hw,
903 IGP01E1000_PHY_PORT_CONFIG,
908 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
909 ret_val = phy->ops.write_reg(hw,
910 IGP01E1000_PHY_PORT_CONFIG,
922 * e1000_reset_hw_82571 - Reset hardware
923 * @hw: pointer to the HW structure
925 * This resets the hardware into a known state.
927 static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
929 u32 ctrl, extcnf_ctrl, ctrl_ext, icr;
933 DEBUGFUNC("e1000_reset_hw_82571");
936 * Prevent the PCI-E bus from sticking if there is no TLP connection
937 * on the last TLP read/write transaction when MAC is reset.
939 ret_val = e1000_disable_pcie_master_generic(hw);
941 DEBUGOUT("PCI-E Master disable polling has failed.\n");
943 DEBUGOUT("Masking off all interrupts\n");
944 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
946 E1000_WRITE_REG(hw, E1000_RCTL, 0);
947 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
948 E1000_WRITE_FLUSH(hw);
953 * Must acquire the MDIO ownership before MAC reset.
954 * Ownership defaults to firmware after a reset.
956 switch (hw->mac.type) {
960 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
961 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
964 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
965 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
967 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
970 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
974 } while (i < MDIO_OWNERSHIP_TIMEOUT);
980 ctrl = E1000_READ_REG(hw, E1000_CTRL);
982 DEBUGOUT("Issuing a global reset to MAC\n");
983 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
985 if (hw->nvm.type == e1000_nvm_flash_hw) {
987 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
988 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
989 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
990 E1000_WRITE_FLUSH(hw);
993 ret_val = e1000_get_auto_rd_done_generic(hw);
995 /* We don't want to continue accessing MAC registers. */
999 * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
1000 * Need to wait for Phy configuration completion before accessing
1004 switch (hw->mac.type) {
1014 /* Clear any pending interrupt events. */
1015 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1016 icr = E1000_READ_REG(hw, E1000_ICR);
1018 /* Install any alternate MAC address into RAR0 */
1019 ret_val = e1000_check_alt_mac_addr_generic(hw);
1023 e1000_set_laa_state_82571(hw, TRUE);
1025 /* Reinitialize the 82571 serdes link state machine */
1026 if (hw->phy.media_type == e1000_media_type_internal_serdes)
1027 hw->mac.serdes_link_state = e1000_serdes_link_down;
1034 * e1000_init_hw_82571 - Initialize hardware
1035 * @hw: pointer to the HW structure
1037 * This inits the hardware readying it for operation.
1039 static s32 e1000_init_hw_82571(struct e1000_hw *hw)
1041 struct e1000_mac_info *mac = &hw->mac;
1044 u16 i, rar_count = mac->rar_entry_count;
1046 DEBUGFUNC("e1000_init_hw_82571");
1048 e1000_initialize_hw_bits_82571(hw);
1050 /* Initialize identification LED */
1051 ret_val = mac->ops.id_led_init(hw);
1053 DEBUGOUT("Error initializing identification LED\n");
1054 /* This is not fatal and we should not stop init due to this */
1056 /* Disabling VLAN filtering */
1057 DEBUGOUT("Initializing the IEEE VLAN\n");
1058 mac->ops.clear_vfta(hw);
1060 /* Setup the receive address. */
1062 * If, however, a locally administered address was assigned to the
1063 * 82571, we must reserve a RAR for it to work around an issue where
1064 * resetting one port will reload the MAC on the other port.
1066 if (e1000_get_laa_state_82571(hw))
1068 e1000_init_rx_addrs_generic(hw, rar_count);
1070 /* Zero out the Multicast HASH table */
1071 DEBUGOUT("Zeroing the MTA\n");
1072 for (i = 0; i < mac->mta_reg_count; i++)
1073 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1075 /* Setup link and flow control */
1076 ret_val = mac->ops.setup_link(hw);
1078 /* Set the transmit descriptor write-back policy */
1079 reg_data = E1000_READ_REG(hw, E1000_TXDCTL(0));
1080 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1081 E1000_TXDCTL_FULL_TX_DESC_WB |
1082 E1000_TXDCTL_COUNT_DESC;
1083 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg_data);
1085 /* ...for both queues. */
1086 switch (mac->type) {
1088 e1000_enable_tx_pkt_filtering_generic(hw);
1092 reg_data = E1000_READ_REG(hw, E1000_GCR);
1093 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
1094 E1000_WRITE_REG(hw, E1000_GCR, reg_data);
1097 reg_data = E1000_READ_REG(hw, E1000_TXDCTL(1));
1098 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1099 E1000_TXDCTL_FULL_TX_DESC_WB |
1100 E1000_TXDCTL_COUNT_DESC;
1101 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg_data);
1106 * Clear all of the statistics registers (clear on read). It is
1107 * important that we do this after we have tried to establish link
1108 * because the symbol error count will increment wildly if there
1111 e1000_clear_hw_cntrs_82571(hw);
1117 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
1118 * @hw: pointer to the HW structure
1120 * Initializes required hardware-dependent bits needed for normal operation.
1122 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1126 DEBUGFUNC("e1000_initialize_hw_bits_82571");
1128 /* Transmit Descriptor Control 0 */
1129 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
1131 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
1133 /* Transmit Descriptor Control 1 */
1134 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
1136 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
1138 /* Transmit Arbitration Control 0 */
1139 reg = E1000_READ_REG(hw, E1000_TARC(0));
1140 reg &= ~(0xF << 27); /* 30:27 */
1141 switch (hw->mac.type) {
1144 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1149 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
1151 /* Transmit Arbitration Control 1 */
1152 reg = E1000_READ_REG(hw, E1000_TARC(1));
1153 switch (hw->mac.type) {
1156 reg &= ~((1 << 29) | (1 << 30));
1157 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
1158 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
1162 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
1168 /* Device Control */
1169 switch (hw->mac.type) {
1173 reg = E1000_READ_REG(hw, E1000_CTRL);
1175 E1000_WRITE_REG(hw, E1000_CTRL, reg);
1181 /* Extended Device Control */
1182 switch (hw->mac.type) {
1186 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1189 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1195 if (hw->mac.type == e1000_82571) {
1196 reg = E1000_READ_REG(hw, E1000_PBA_ECC);
1197 reg |= E1000_PBA_ECC_CORR_EN;
1198 E1000_WRITE_REG(hw, E1000_PBA_ECC, reg);
1202 * Workaround for hardware errata.
1203 * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572
1205 if ((hw->mac.type == e1000_82571) ||
1206 (hw->mac.type == e1000_82572)) {
1207 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1208 reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN;
1209 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1212 /* PCI-Ex Control Registers */
1213 switch (hw->mac.type) {
1216 reg = E1000_READ_REG(hw, E1000_GCR);
1218 E1000_WRITE_REG(hw, E1000_GCR, reg);
1221 * Workaround for hardware errata.
1222 * apply workaround for hardware errata documented in errata
1223 * docs Fixes issue where some error prone or unreliable PCIe
1224 * completions are occurring, particularly with ASPM enabled.
1225 * Without fix, issue can cause tx timeouts.
1227 reg = E1000_READ_REG(hw, E1000_GCR2);
1229 E1000_WRITE_REG(hw, E1000_GCR2, reg);
1239 * e1000_clear_vfta_82571 - Clear VLAN filter table
1240 * @hw: pointer to the HW structure
1242 * Clears the register array which contains the VLAN filter table by
1243 * setting all the values to 0.
1245 static void e1000_clear_vfta_82571(struct e1000_hw *hw)
1249 u32 vfta_offset = 0;
1250 u32 vfta_bit_in_reg = 0;
1252 DEBUGFUNC("e1000_clear_vfta_82571");
1254 switch (hw->mac.type) {
1258 if (hw->mng_cookie.vlan_id != 0) {
1260 * The VFTA is a 4096b bit-field, each identifying
1261 * a single VLAN ID. The following operations
1262 * determine which 32b entry (i.e. offset) into the
1263 * array we want to set the VLAN ID (i.e. bit) of
1264 * the manageability unit.
1266 vfta_offset = (hw->mng_cookie.vlan_id >>
1267 E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_MASK;
1268 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
1269 E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
1275 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
1277 * If the offset we want to clear is the same offset of the
1278 * manageability VLAN ID, then clear all bits except that of
1279 * the manageability unit.
1281 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
1282 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
1283 E1000_WRITE_FLUSH(hw);
1288 * e1000_check_mng_mode_82574 - Check manageability is enabled
1289 * @hw: pointer to the HW structure
1291 * Reads the NVM Initialization Control Word 2 and returns TRUE
1292 * (>0) if any manageability is enabled, else FALSE (0).
1294 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
1298 DEBUGFUNC("e1000_check_mng_mode_82574");
1300 hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &data);
1301 return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
1305 * e1000_led_on_82574 - Turn LED on
1306 * @hw: pointer to the HW structure
1310 static s32 e1000_led_on_82574(struct e1000_hw *hw)
1315 DEBUGFUNC("e1000_led_on_82574");
1317 ctrl = hw->mac.ledctl_mode2;
1318 if (!(E1000_STATUS_LU & E1000_READ_REG(hw, E1000_STATUS))) {
1320 * If no link, then turn LED on by setting the invert bit
1321 * for each LED that's "on" (0x0E) in ledctl_mode2.
1323 for (i = 0; i < 4; i++)
1324 if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1325 E1000_LEDCTL_MODE_LED_ON)
1326 ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
1328 E1000_WRITE_REG(hw, E1000_LEDCTL, ctrl);
1330 return E1000_SUCCESS;
1335 * e1000_setup_link_82571 - Setup flow control and link settings
1336 * @hw: pointer to the HW structure
1338 * Determines which flow control settings to use, then configures flow
1339 * control. Calls the appropriate media-specific link configuration
1340 * function. Assuming the adapter has a valid link partner, a valid link
1341 * should be established. Assumes the hardware has previously been reset
1342 * and the transmitter and receiver are not enabled.
1344 static s32 e1000_setup_link_82571(struct e1000_hw *hw)
1346 DEBUGFUNC("e1000_setup_link_82571");
1349 * 82573 does not have a word in the NVM to determine
1350 * the default flow control setting, so we explicitly
1353 switch (hw->mac.type) {
1357 if (hw->fc.requested_mode == e1000_fc_default)
1358 hw->fc.requested_mode = e1000_fc_full;
1363 return e1000_setup_link_generic(hw);
1367 * e1000_setup_copper_link_82571 - Configure copper link settings
1368 * @hw: pointer to the HW structure
1370 * Configures the link for auto-neg or forced speed and duplex. Then we check
1371 * for link, once link is established calls to configure collision distance
1372 * and flow control are called.
1374 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
1379 DEBUGFUNC("e1000_setup_copper_link_82571");
1381 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1382 ctrl |= E1000_CTRL_SLU;
1383 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1384 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1386 switch (hw->phy.type) {
1389 ret_val = e1000_copper_link_setup_m88(hw);
1391 case e1000_phy_igp_2:
1392 ret_val = e1000_copper_link_setup_igp(hw);
1395 ret_val = -E1000_ERR_PHY;
1402 ret_val = e1000_setup_copper_link_generic(hw);
1409 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
1410 * @hw: pointer to the HW structure
1412 * Configures collision distance and flow control for fiber and serdes links.
1413 * Upon successful setup, poll for link.
1415 static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
1417 DEBUGFUNC("e1000_setup_fiber_serdes_link_82571");
1419 switch (hw->mac.type) {
1423 * If SerDes loopback mode is entered, there is no form
1424 * of reset to take the adapter out of that mode. So we
1425 * have to explicitly take the adapter out of loopback
1426 * mode. This prevents drivers from twiddling their thumbs
1427 * if another tool failed to take it out of loopback mode.
1429 E1000_WRITE_REG(hw, E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1435 return e1000_setup_fiber_serdes_link_generic(hw);
1439 * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
1440 * @hw: pointer to the HW structure
1442 * Reports the link state as up or down.
1444 * If autonegotiation is supported by the link partner, the link state is
1445 * determined by the result of autonegotiation. This is the most likely case.
1446 * If autonegotiation is not supported by the link partner, and the link
1447 * has a valid signal, force the link up.
1449 * The link state is represented internally here by 4 states:
1452 * 2) autoneg_progress
1453 * 3) autoneg_complete (the link sucessfully autonegotiated)
1454 * 4) forced_up (the link has been forced up, it did not autonegotiate)
1457 static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1459 struct e1000_mac_info *mac = &hw->mac;
1463 s32 ret_val = E1000_SUCCESS;
1465 DEBUGFUNC("e1000_check_for_serdes_link_82571");
1467 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1468 status = E1000_READ_REG(hw, E1000_STATUS);
1469 rxcw = E1000_READ_REG(hw, E1000_RXCW);
1471 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
1473 /* Receiver is synchronized with no invalid bits. */
1474 switch (mac->serdes_link_state) {
1475 case e1000_serdes_link_autoneg_complete:
1476 if (!(status & E1000_STATUS_LU)) {
1478 * We have lost link, retry autoneg before
1479 * reporting link failure
1481 mac->serdes_link_state =
1482 e1000_serdes_link_autoneg_progress;
1483 mac->serdes_has_link = FALSE;
1484 DEBUGOUT("AN_UP -> AN_PROG\n");
1488 case e1000_serdes_link_forced_up:
1490 * If we are receiving /C/ ordered sets, re-enable
1491 * auto-negotiation in the TXCW register and disable
1492 * forced link in the Device Control register in an
1493 * attempt to auto-negotiate with our link partner.
1495 if (rxcw & E1000_RXCW_C) {
1496 /* Enable autoneg, and unforce link up */
1497 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
1498 E1000_WRITE_REG(hw, E1000_CTRL,
1499 (ctrl & ~E1000_CTRL_SLU));
1500 mac->serdes_link_state =
1501 e1000_serdes_link_autoneg_progress;
1502 mac->serdes_has_link = FALSE;
1503 DEBUGOUT("FORCED_UP -> AN_PROG\n");
1507 case e1000_serdes_link_autoneg_progress:
1508 if (rxcw & E1000_RXCW_C) {
1510 * We received /C/ ordered sets, meaning the
1511 * link partner has autonegotiated, and we can
1512 * trust the Link Up (LU) status bit.
1514 if (status & E1000_STATUS_LU) {
1515 mac->serdes_link_state =
1516 e1000_serdes_link_autoneg_complete;
1517 DEBUGOUT("AN_PROG -> AN_UP\n");
1518 mac->serdes_has_link = TRUE;
1520 /* Autoneg completed, but failed. */
1521 mac->serdes_link_state =
1522 e1000_serdes_link_down;
1523 DEBUGOUT("AN_PROG -> DOWN\n");
1527 * The link partner did not autoneg.
1528 * Force link up and full duplex, and change
1531 E1000_WRITE_REG(hw, E1000_TXCW,
1532 (mac->txcw & ~E1000_TXCW_ANE));
1533 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
1534 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1536 /* Configure Flow Control after link up. */
1538 e1000_config_fc_after_link_up_generic(hw);
1540 DEBUGOUT("Error config flow control\n");
1543 mac->serdes_link_state =
1544 e1000_serdes_link_forced_up;
1545 mac->serdes_has_link = TRUE;
1546 DEBUGOUT("AN_PROG -> FORCED_UP\n");
1550 case e1000_serdes_link_down:
1553 * The link was down but the receiver has now gained
1554 * valid sync, so lets see if we can bring the link
1557 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
1558 E1000_WRITE_REG(hw, E1000_CTRL,
1559 (ctrl & ~E1000_CTRL_SLU));
1560 mac->serdes_link_state =
1561 e1000_serdes_link_autoneg_progress;
1562 DEBUGOUT("DOWN -> AN_PROG\n");
1566 if (!(rxcw & E1000_RXCW_SYNCH)) {
1567 mac->serdes_has_link = FALSE;
1568 mac->serdes_link_state = e1000_serdes_link_down;
1569 DEBUGOUT("ANYSTATE -> DOWN\n");
1572 * We have sync, and can tolerate one invalid (IV)
1573 * codeword before declaring link down, so reread
1577 rxcw = E1000_READ_REG(hw, E1000_RXCW);
1578 if (rxcw & E1000_RXCW_IV) {
1579 mac->serdes_link_state = e1000_serdes_link_down;
1580 mac->serdes_has_link = FALSE;
1581 DEBUGOUT("ANYSTATE -> DOWN\n");
1590 * e1000_valid_led_default_82571 - Verify a valid default LED config
1591 * @hw: pointer to the HW structure
1592 * @data: pointer to the NVM (EEPROM)
1594 * Read the EEPROM for the current default LED configuration. If the
1595 * LED configuration is not valid, set to a valid LED configuration.
1597 static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
1601 DEBUGFUNC("e1000_valid_led_default_82571");
1603 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
1605 DEBUGOUT("NVM Read Error\n");
1609 switch (hw->mac.type) {
1613 if (*data == ID_LED_RESERVED_F746)
1614 *data = ID_LED_DEFAULT_82573;
1617 if (*data == ID_LED_RESERVED_0000 ||
1618 *data == ID_LED_RESERVED_FFFF)
1619 *data = ID_LED_DEFAULT;
1628 * e1000_get_laa_state_82571 - Get locally administered address state
1629 * @hw: pointer to the HW structure
1631 * Retrieve and return the current locally administered address state.
1633 bool e1000_get_laa_state_82571(struct e1000_hw *hw)
1635 DEBUGFUNC("e1000_get_laa_state_82571");
1637 if (hw->mac.type != e1000_82571)
1640 return hw->dev_spec._82571.laa_is_present;
1644 * e1000_set_laa_state_82571 - Set locally administered address state
1645 * @hw: pointer to the HW structure
1646 * @state: enable/disable locally administered address
1648 * Enable/Disable the current locally administered address state.
1650 void e1000_set_laa_state_82571(struct e1000_hw *hw, bool state)
1652 DEBUGFUNC("e1000_set_laa_state_82571");
1654 if (hw->mac.type != e1000_82571)
1657 hw->dev_spec._82571.laa_is_present = state;
1659 /* If workaround is activated... */
1662 * Hold a copy of the LAA in RAR[14] This is done so that
1663 * between the time RAR[0] gets clobbered and the time it
1664 * gets fixed, the actual LAA is in one of the RARs and no
1665 * incoming packets directed to this port are dropped.
1666 * Eventually the LAA will be in RAR[0] and RAR[14].
1668 e1000_rar_set_generic(hw, hw->mac.addr,
1669 hw->mac.rar_entry_count - 1);
1674 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
1675 * @hw: pointer to the HW structure
1677 * Verifies that the EEPROM has completed the update. After updating the
1678 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
1679 * the checksum fix is not implemented, we need to set the bit and update
1680 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
1681 * we need to return bad checksum.
1683 static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
1685 struct e1000_nvm_info *nvm = &hw->nvm;
1686 s32 ret_val = E1000_SUCCESS;
1689 DEBUGFUNC("e1000_fix_nvm_checksum_82571");
1691 if (nvm->type != e1000_nvm_flash_hw)
1695 * Check bit 4 of word 10h. If it is 0, firmware is done updating
1696 * 10h-12h. Checksum may need to be fixed.
1698 ret_val = nvm->ops.read(hw, 0x10, 1, &data);
1702 if (!(data & 0x10)) {
1704 * Read 0x23 and check bit 15. This bit is a 1
1705 * when the checksum has already been fixed. If
1706 * the checksum is still wrong and this bit is a
1707 * 1, we need to return bad checksum. Otherwise,
1708 * we need to set this bit to a 1 and update the
1711 ret_val = nvm->ops.read(hw, 0x23, 1, &data);
1715 if (!(data & 0x8000)) {
1717 ret_val = nvm->ops.write(hw, 0x23, 1, &data);
1720 ret_val = nvm->ops.update(hw);
1730 * e1000_read_mac_addr_82571 - Read device MAC address
1731 * @hw: pointer to the HW structure
1733 static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1735 s32 ret_val = E1000_SUCCESS;
1737 DEBUGFUNC("e1000_read_mac_addr_82571");
1740 * If there's an alternate MAC address place it in RAR0
1741 * so that it will override the Si installed default perm
1744 ret_val = e1000_check_alt_mac_addr_generic(hw);
1748 ret_val = e1000_read_mac_addr_generic(hw);
1755 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
1756 * @hw: pointer to the HW structure
1758 * In the case of a PHY power down to save power, or to turn off link during a
1759 * driver unload, or wake on lan is not enabled, remove the link.
1761 static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
1763 struct e1000_phy_info *phy = &hw->phy;
1764 struct e1000_mac_info *mac = &hw->mac;
1766 if (!(phy->ops.check_reset_block))
1769 /* If the management interface is not enabled, then power down */
1770 if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
1771 e1000_power_down_phy_copper(hw);
1777 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
1778 * @hw: pointer to the HW structure
1780 * Clears the hardware counters by reading the counter registers.
1782 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
1784 DEBUGFUNC("e1000_clear_hw_cntrs_82571");
1786 e1000_clear_hw_cntrs_base_generic(hw);
1788 E1000_READ_REG(hw, E1000_PRC64);
1789 E1000_READ_REG(hw, E1000_PRC127);
1790 E1000_READ_REG(hw, E1000_PRC255);
1791 E1000_READ_REG(hw, E1000_PRC511);
1792 E1000_READ_REG(hw, E1000_PRC1023);
1793 E1000_READ_REG(hw, E1000_PRC1522);
1794 E1000_READ_REG(hw, E1000_PTC64);
1795 E1000_READ_REG(hw, E1000_PTC127);
1796 E1000_READ_REG(hw, E1000_PTC255);
1797 E1000_READ_REG(hw, E1000_PTC511);
1798 E1000_READ_REG(hw, E1000_PTC1023);
1799 E1000_READ_REG(hw, E1000_PTC1522);
1801 E1000_READ_REG(hw, E1000_ALGNERRC);
1802 E1000_READ_REG(hw, E1000_RXERRC);
1803 E1000_READ_REG(hw, E1000_TNCRS);
1804 E1000_READ_REG(hw, E1000_CEXTERR);
1805 E1000_READ_REG(hw, E1000_TSCTC);
1806 E1000_READ_REG(hw, E1000_TSCTFC);
1808 E1000_READ_REG(hw, E1000_MGTPRC);
1809 E1000_READ_REG(hw, E1000_MGTPDC);
1810 E1000_READ_REG(hw, E1000_MGTPTC);
1812 E1000_READ_REG(hw, E1000_IAC);
1813 E1000_READ_REG(hw, E1000_ICRXOC);
1815 E1000_READ_REG(hw, E1000_ICRXPTC);
1816 E1000_READ_REG(hw, E1000_ICRXATC);
1817 E1000_READ_REG(hw, E1000_ICTXPTC);
1818 E1000_READ_REG(hw, E1000_ICTXATC);
1819 E1000_READ_REG(hw, E1000_ICTXQEC);
1820 E1000_READ_REG(hw, E1000_ICTXQMTC);
1821 E1000_READ_REG(hw, E1000_ICRXDMTC);