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 /* Set if manageability features are enabled. */
317 mac->arc_subsystem_valid =
318 (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK)
320 /* Adaptive IFS supported */
321 mac->adaptive_ifs = TRUE;
323 /* Function pointers */
325 /* bus type/speed/width */
326 mac->ops.get_bus_info = e1000_get_bus_info_pcie_generic;
328 mac->ops.reset_hw = e1000_reset_hw_82571;
329 /* hw initialization */
330 mac->ops.init_hw = e1000_init_hw_82571;
332 mac->ops.setup_link = e1000_setup_link_82571;
333 /* multicast address update */
334 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
336 mac->ops.write_vfta = e1000_write_vfta_generic;
338 mac->ops.clear_vfta = e1000_clear_vfta_82571;
339 /* read mac address */
340 mac->ops.read_mac_addr = e1000_read_mac_addr_82571;
342 mac->ops.id_led_init = e1000_id_led_init_generic;
344 mac->ops.blink_led = e1000_blink_led_generic;
346 mac->ops.setup_led = e1000_setup_led_generic;
348 mac->ops.cleanup_led = e1000_cleanup_led_generic;
350 mac->ops.led_off = e1000_led_off_generic;
351 /* clear hardware counters */
352 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82571;
354 /* MAC-specific function pointers */
355 switch (hw->mac.type) {
357 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
358 mac->ops.check_mng_mode = e1000_check_mng_mode_generic;
359 mac->ops.led_on = e1000_led_on_generic;
363 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
364 mac->ops.check_mng_mode = e1000_check_mng_mode_82574;
365 mac->ops.led_on = e1000_led_on_82574;
368 mac->ops.check_mng_mode = e1000_check_mng_mode_generic;
369 mac->ops.led_on = e1000_led_on_generic;
374 * Ensure that the inter-port SWSM.SMBI lock bit is clear before
375 * first NVM or PHY acess. This should be done for single-port
376 * devices, and for one port only on dual-port devices so that
377 * for those devices we can still use the SMBI lock to synchronize
378 * inter-port accesses to the PHY & NVM.
380 switch (hw->mac.type) {
383 swsm2 = E1000_READ_REG(hw, E1000_SWSM2);
385 if (!(swsm2 & E1000_SWSM2_LOCK)) {
386 /* Only do this for the first interface on this card */
387 E1000_WRITE_REG(hw, E1000_SWSM2,
388 swsm2 | E1000_SWSM2_LOCK);
389 force_clear_smbi = TRUE;
391 force_clear_smbi = FALSE;
394 force_clear_smbi = TRUE;
398 if (force_clear_smbi) {
399 /* Make sure SWSM.SMBI is clear */
400 swsm = E1000_READ_REG(hw, E1000_SWSM);
401 if (swsm & E1000_SWSM_SMBI) {
402 /* This bit should not be set on a first interface, and
403 * indicates that the bootagent or EFI code has
404 * improperly left this bit enabled
406 DEBUGOUT("Please update your 82571 Bootagent\n");
408 E1000_WRITE_REG(hw, E1000_SWSM, swsm & ~E1000_SWSM_SMBI);
412 * Initialze device specific counter of SMBI acquisition
415 hw->dev_spec._82571.smb_counter = 0;
417 return E1000_SUCCESS;
421 * e1000_init_function_pointers_82571 - Init func ptrs.
422 * @hw: pointer to the HW structure
424 * Called to initialize all function pointers and parameters.
426 void e1000_init_function_pointers_82571(struct e1000_hw *hw)
428 DEBUGFUNC("e1000_init_function_pointers_82571");
430 hw->mac.ops.init_params = e1000_init_mac_params_82571;
431 hw->nvm.ops.init_params = e1000_init_nvm_params_82571;
432 hw->phy.ops.init_params = e1000_init_phy_params_82571;
436 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
437 * @hw: pointer to the HW structure
439 * Reads the PHY registers and stores the PHY ID and possibly the PHY
440 * revision in the hardware structure.
442 static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
444 struct e1000_phy_info *phy = &hw->phy;
445 s32 ret_val = E1000_SUCCESS;
448 DEBUGFUNC("e1000_get_phy_id_82571");
450 switch (hw->mac.type) {
454 * The 82571 firmware may still be configuring the PHY.
455 * In this case, we cannot access the PHY until the
456 * configuration is done. So we explicitly set the
459 phy->id = IGP01E1000_I_PHY_ID;
462 ret_val = e1000_get_phy_id(hw);
466 ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
470 phy->id = (u32)(phy_id << 16);
472 ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id);
476 phy->id |= (u32)(phy_id);
477 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
480 ret_val = -E1000_ERR_PHY;
488 * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
489 * @hw: pointer to the HW structure
491 * Acquire the HW semaphore to access the PHY or NVM
493 static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
496 s32 ret_val = E1000_SUCCESS;
497 s32 sw_timeout = hw->nvm.word_size + 1;
498 s32 fw_timeout = hw->nvm.word_size + 1;
501 DEBUGFUNC("e1000_get_hw_semaphore_82571");
504 * If we have timedout 3 times on trying to acquire
505 * the inter-port SMBI semaphore, there is old code
506 * operating on the other port, and it is not
507 * releasing SMBI. Modify the number of times that
508 * we try for the semaphore to interwork with this
511 if (hw->dev_spec._82571.smb_counter > 2)
514 /* Get the SW semaphore */
515 while (i < sw_timeout) {
516 swsm = E1000_READ_REG(hw, E1000_SWSM);
517 if (!(swsm & E1000_SWSM_SMBI))
524 if (i == sw_timeout) {
525 DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
526 hw->dev_spec._82571.smb_counter++;
528 /* Get the FW semaphore. */
529 for (i = 0; i < fw_timeout; i++) {
530 swsm = E1000_READ_REG(hw, E1000_SWSM);
531 E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
533 /* Semaphore acquired if bit latched */
534 if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI)
540 if (i == fw_timeout) {
541 /* Release semaphores */
542 e1000_put_hw_semaphore_82571(hw);
543 DEBUGOUT("Driver can't access the NVM\n");
544 ret_val = -E1000_ERR_NVM;
553 * e1000_put_hw_semaphore_82571 - Release hardware semaphore
554 * @hw: pointer to the HW structure
556 * Release hardware semaphore used to access the PHY or NVM
558 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
562 DEBUGFUNC("e1000_put_hw_semaphore_generic");
564 swsm = E1000_READ_REG(hw, E1000_SWSM);
566 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
568 E1000_WRITE_REG(hw, E1000_SWSM, swsm);
572 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
573 * @hw: pointer to the HW structure
575 * To gain access to the EEPROM, first we must obtain a hardware semaphore.
576 * Then for non-82573 hardware, set the EEPROM access request bit and wait
577 * for EEPROM access grant bit. If the access grant bit is not set, release
578 * hardware semaphore.
580 static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
584 DEBUGFUNC("e1000_acquire_nvm_82571");
586 ret_val = e1000_get_hw_semaphore_82571(hw);
590 switch (hw->mac.type) {
596 ret_val = e1000_acquire_nvm_generic(hw);
601 e1000_put_hw_semaphore_82571(hw);
608 * e1000_release_nvm_82571 - Release exclusive access to EEPROM
609 * @hw: pointer to the HW structure
611 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
613 static void e1000_release_nvm_82571(struct e1000_hw *hw)
615 DEBUGFUNC("e1000_release_nvm_82571");
617 e1000_release_nvm_generic(hw);
618 e1000_put_hw_semaphore_82571(hw);
622 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
623 * @hw: pointer to the HW structure
624 * @offset: offset within the EEPROM to be written to
625 * @words: number of words to write
626 * @data: 16 bit word(s) to be written to the EEPROM
628 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
630 * If e1000_update_nvm_checksum is not called after this function, the
631 * EEPROM will most likely contain an invalid checksum.
633 static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
636 s32 ret_val = E1000_SUCCESS;
638 DEBUGFUNC("e1000_write_nvm_82571");
640 switch (hw->mac.type) {
644 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
648 ret_val = e1000_write_nvm_spi(hw, offset, words, data);
651 ret_val = -E1000_ERR_NVM;
659 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
660 * @hw: pointer to the HW structure
662 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
663 * up to the checksum. Then calculates the EEPROM checksum and writes the
664 * value to the EEPROM.
666 static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
672 DEBUGFUNC("e1000_update_nvm_checksum_82571");
674 ret_val = e1000_update_nvm_checksum_generic(hw);
679 * If our nvm is an EEPROM, then we're done
680 * otherwise, commit the checksum to the flash NVM.
682 if (hw->nvm.type != e1000_nvm_flash_hw)
685 /* Check for pending operations. */
686 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
688 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_FLUPD) == 0)
692 if (i == E1000_FLASH_UPDATES) {
693 ret_val = -E1000_ERR_NVM;
697 /* Reset the firmware if using STM opcode. */
698 if ((E1000_READ_REG(hw, E1000_FLOP) & 0xFF00) == E1000_STM_OPCODE) {
700 * The enabling of and the actual reset must be done
701 * in two write cycles.
703 E1000_WRITE_REG(hw, E1000_HICR, E1000_HICR_FW_RESET_ENABLE);
704 E1000_WRITE_FLUSH(hw);
705 E1000_WRITE_REG(hw, E1000_HICR, E1000_HICR_FW_RESET);
708 /* Commit the write to flash */
709 eecd = E1000_READ_REG(hw, E1000_EECD) | E1000_EECD_FLUPD;
710 E1000_WRITE_REG(hw, E1000_EECD, eecd);
712 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
714 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_FLUPD) == 0)
718 if (i == E1000_FLASH_UPDATES) {
719 ret_val = -E1000_ERR_NVM;
728 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
729 * @hw: pointer to the HW structure
731 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
732 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
734 static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
736 DEBUGFUNC("e1000_validate_nvm_checksum_82571");
738 if (hw->nvm.type == e1000_nvm_flash_hw)
739 e1000_fix_nvm_checksum_82571(hw);
741 return e1000_validate_nvm_checksum_generic(hw);
745 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
746 * @hw: pointer to the HW structure
747 * @offset: offset within the EEPROM to be written to
748 * @words: number of words to write
749 * @data: 16 bit word(s) to be written to the EEPROM
751 * After checking for invalid values, poll the EEPROM to ensure the previous
752 * command has completed before trying to write the next word. After write
753 * poll for completion.
755 * If e1000_update_nvm_checksum is not called after this function, the
756 * EEPROM will most likely contain an invalid checksum.
758 static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
759 u16 words, u16 *data)
761 struct e1000_nvm_info *nvm = &hw->nvm;
765 DEBUGFUNC("e1000_write_nvm_eewr_82571");
768 * A check for invalid values: offset too large, too many words,
769 * and not enough words.
771 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
773 DEBUGOUT("nvm parameter(s) out of bounds\n");
774 ret_val = -E1000_ERR_NVM;
778 for (i = 0; i < words; i++) {
779 eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
780 ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
781 E1000_NVM_RW_REG_START;
783 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
787 E1000_WRITE_REG(hw, E1000_EEWR, eewr);
789 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
799 * e1000_get_cfg_done_82571 - Poll for configuration done
800 * @hw: pointer to the HW structure
802 * Reads the management control register for the config done bit to be set.
804 static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
806 s32 timeout = PHY_CFG_TIMEOUT;
807 s32 ret_val = E1000_SUCCESS;
809 DEBUGFUNC("e1000_get_cfg_done_82571");
812 if (E1000_READ_REG(hw, E1000_EEMNGCTL) &
813 E1000_NVM_CFG_DONE_PORT_0)
819 DEBUGOUT("MNG configuration cycle has not completed.\n");
820 ret_val = -E1000_ERR_RESET;
829 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
830 * @hw: pointer to the HW structure
831 * @active: TRUE to enable LPLU, FALSE to disable
833 * Sets the LPLU D0 state according to the active flag. When activating LPLU
834 * this function also disables smart speed and vice versa. LPLU will not be
835 * activated unless the device autonegotiation advertisement meets standards
836 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
837 * pointer entry point only called by PHY setup routines.
839 static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
841 struct e1000_phy_info *phy = &hw->phy;
842 s32 ret_val = E1000_SUCCESS;
845 DEBUGFUNC("e1000_set_d0_lplu_state_82571");
847 if (!(phy->ops.read_reg))
850 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
855 data |= IGP02E1000_PM_D0_LPLU;
856 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
861 /* When LPLU is enabled, we should disable SmartSpeed */
862 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
864 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
865 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
870 data &= ~IGP02E1000_PM_D0_LPLU;
871 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
874 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
875 * during Dx states where the power conservation is most
876 * important. During driver activity we should enable
877 * SmartSpeed, so performance is maintained.
879 if (phy->smart_speed == e1000_smart_speed_on) {
880 ret_val = phy->ops.read_reg(hw,
881 IGP01E1000_PHY_PORT_CONFIG,
886 data |= IGP01E1000_PSCFR_SMART_SPEED;
887 ret_val = phy->ops.write_reg(hw,
888 IGP01E1000_PHY_PORT_CONFIG,
892 } else if (phy->smart_speed == e1000_smart_speed_off) {
893 ret_val = phy->ops.read_reg(hw,
894 IGP01E1000_PHY_PORT_CONFIG,
899 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
900 ret_val = phy->ops.write_reg(hw,
901 IGP01E1000_PHY_PORT_CONFIG,
913 * e1000_reset_hw_82571 - Reset hardware
914 * @hw: pointer to the HW structure
916 * This resets the hardware into a known state.
918 static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
920 u32 ctrl, extcnf_ctrl, ctrl_ext, icr;
924 DEBUGFUNC("e1000_reset_hw_82571");
927 * Prevent the PCI-E bus from sticking if there is no TLP connection
928 * on the last TLP read/write transaction when MAC is reset.
930 ret_val = e1000_disable_pcie_master_generic(hw);
932 DEBUGOUT("PCI-E Master disable polling has failed.\n");
934 DEBUGOUT("Masking off all interrupts\n");
935 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
937 E1000_WRITE_REG(hw, E1000_RCTL, 0);
938 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
939 E1000_WRITE_FLUSH(hw);
944 * Must acquire the MDIO ownership before MAC reset.
945 * Ownership defaults to firmware after a reset.
947 switch (hw->mac.type) {
951 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
952 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
955 E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl);
956 extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL);
958 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
961 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
965 } while (i < MDIO_OWNERSHIP_TIMEOUT);
971 ctrl = E1000_READ_REG(hw, E1000_CTRL);
973 DEBUGOUT("Issuing a global reset to MAC\n");
974 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
976 if (hw->nvm.type == e1000_nvm_flash_hw) {
978 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
979 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
980 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
981 E1000_WRITE_FLUSH(hw);
984 ret_val = e1000_get_auto_rd_done_generic(hw);
986 /* We don't want to continue accessing MAC registers. */
990 * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
991 * Need to wait for Phy configuration completion before accessing
995 switch (hw->mac.type) {
1005 /* Clear any pending interrupt events. */
1006 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1007 icr = E1000_READ_REG(hw, E1000_ICR);
1009 /* Install any alternate MAC address into RAR0 */
1010 ret_val = e1000_check_alt_mac_addr_generic(hw);
1014 e1000_set_laa_state_82571(hw, TRUE);
1016 /* Reinitialize the 82571 serdes link state machine */
1017 if (hw->phy.media_type == e1000_media_type_internal_serdes)
1018 hw->mac.serdes_link_state = e1000_serdes_link_down;
1025 * e1000_init_hw_82571 - Initialize hardware
1026 * @hw: pointer to the HW structure
1028 * This inits the hardware readying it for operation.
1030 static s32 e1000_init_hw_82571(struct e1000_hw *hw)
1032 struct e1000_mac_info *mac = &hw->mac;
1035 u16 i, rar_count = mac->rar_entry_count;
1037 DEBUGFUNC("e1000_init_hw_82571");
1039 e1000_initialize_hw_bits_82571(hw);
1041 /* Initialize identification LED */
1042 ret_val = mac->ops.id_led_init(hw);
1044 DEBUGOUT("Error initializing identification LED\n");
1045 /* This is not fatal and we should not stop init due to this */
1047 /* Disabling VLAN filtering */
1048 DEBUGOUT("Initializing the IEEE VLAN\n");
1049 mac->ops.clear_vfta(hw);
1051 /* Setup the receive address. */
1053 * If, however, a locally administered address was assigned to the
1054 * 82571, we must reserve a RAR for it to work around an issue where
1055 * resetting one port will reload the MAC on the other port.
1057 if (e1000_get_laa_state_82571(hw))
1059 e1000_init_rx_addrs_generic(hw, rar_count);
1061 /* Zero out the Multicast HASH table */
1062 DEBUGOUT("Zeroing the MTA\n");
1063 for (i = 0; i < mac->mta_reg_count; i++)
1064 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1066 /* Setup link and flow control */
1067 ret_val = mac->ops.setup_link(hw);
1069 /* Set the transmit descriptor write-back policy */
1070 reg_data = E1000_READ_REG(hw, E1000_TXDCTL(0));
1071 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1072 E1000_TXDCTL_FULL_TX_DESC_WB |
1073 E1000_TXDCTL_COUNT_DESC;
1074 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg_data);
1076 /* ...for both queues. */
1077 switch (mac->type) {
1081 e1000_enable_tx_pkt_filtering_generic(hw);
1082 reg_data = E1000_READ_REG(hw, E1000_GCR);
1083 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
1084 E1000_WRITE_REG(hw, E1000_GCR, reg_data);
1087 reg_data = E1000_READ_REG(hw, E1000_TXDCTL(1));
1088 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1089 E1000_TXDCTL_FULL_TX_DESC_WB |
1090 E1000_TXDCTL_COUNT_DESC;
1091 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg_data);
1096 * Clear all of the statistics registers (clear on read). It is
1097 * important that we do this after we have tried to establish link
1098 * because the symbol error count will increment wildly if there
1101 e1000_clear_hw_cntrs_82571(hw);
1107 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
1108 * @hw: pointer to the HW structure
1110 * Initializes required hardware-dependent bits needed for normal operation.
1112 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1116 DEBUGFUNC("e1000_initialize_hw_bits_82571");
1118 /* Transmit Descriptor Control 0 */
1119 reg = E1000_READ_REG(hw, E1000_TXDCTL(0));
1121 E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg);
1123 /* Transmit Descriptor Control 1 */
1124 reg = E1000_READ_REG(hw, E1000_TXDCTL(1));
1126 E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg);
1128 /* Transmit Arbitration Control 0 */
1129 reg = E1000_READ_REG(hw, E1000_TARC(0));
1130 reg &= ~(0xF << 27); /* 30:27 */
1131 switch (hw->mac.type) {
1134 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1139 E1000_WRITE_REG(hw, E1000_TARC(0), reg);
1141 /* Transmit Arbitration Control 1 */
1142 reg = E1000_READ_REG(hw, E1000_TARC(1));
1143 switch (hw->mac.type) {
1146 reg &= ~((1 << 29) | (1 << 30));
1147 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
1148 if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR)
1152 E1000_WRITE_REG(hw, E1000_TARC(1), reg);
1158 /* Device Control */
1159 switch (hw->mac.type) {
1163 reg = E1000_READ_REG(hw, E1000_CTRL);
1165 E1000_WRITE_REG(hw, E1000_CTRL, reg);
1171 /* Extended Device Control */
1172 switch (hw->mac.type) {
1176 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1179 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1185 if (hw->mac.type == e1000_82571) {
1186 reg = E1000_READ_REG(hw, E1000_PBA_ECC);
1187 reg |= E1000_PBA_ECC_CORR_EN;
1188 E1000_WRITE_REG(hw, E1000_PBA_ECC, reg);
1192 * Workaround for hardware errata.
1193 * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572
1195 if ((hw->mac.type == e1000_82571) ||
1196 (hw->mac.type == e1000_82572)) {
1197 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1198 reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN;
1199 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1202 /* PCI-Ex Control Registers */
1203 switch (hw->mac.type) {
1206 reg = E1000_READ_REG(hw, E1000_GCR);
1208 E1000_WRITE_REG(hw, E1000_GCR, reg);
1211 * Workaround for hardware errata.
1212 * apply workaround for hardware errata documented in errata
1213 * docs Fixes issue where some error prone or unreliable PCIe
1214 * completions are occurring, particularly with ASPM enabled.
1215 * Without fix, issue can cause tx timeouts.
1217 reg = E1000_READ_REG(hw, E1000_GCR2);
1219 E1000_WRITE_REG(hw, E1000_GCR2, reg);
1229 * e1000_clear_vfta_82571 - Clear VLAN filter table
1230 * @hw: pointer to the HW structure
1232 * Clears the register array which contains the VLAN filter table by
1233 * setting all the values to 0.
1235 static void e1000_clear_vfta_82571(struct e1000_hw *hw)
1239 u32 vfta_offset = 0;
1240 u32 vfta_bit_in_reg = 0;
1242 DEBUGFUNC("e1000_clear_vfta_82571");
1244 switch (hw->mac.type) {
1248 if (hw->mng_cookie.vlan_id != 0) {
1250 * The VFTA is a 4096b bit-field, each identifying
1251 * a single VLAN ID. The following operations
1252 * determine which 32b entry (i.e. offset) into the
1253 * array we want to set the VLAN ID (i.e. bit) of
1254 * the manageability unit.
1256 vfta_offset = (hw->mng_cookie.vlan_id >>
1257 E1000_VFTA_ENTRY_SHIFT) & E1000_VFTA_ENTRY_MASK;
1258 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
1259 E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
1265 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
1267 * If the offset we want to clear is the same offset of the
1268 * manageability VLAN ID, then clear all bits except that of
1269 * the manageability unit.
1271 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
1272 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
1273 E1000_WRITE_FLUSH(hw);
1278 * e1000_check_mng_mode_82574 - Check manageability is enabled
1279 * @hw: pointer to the HW structure
1281 * Reads the NVM Initialization Control Word 2 and returns TRUE
1282 * (>0) if any manageability is enabled, else FALSE (0).
1284 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
1288 DEBUGFUNC("e1000_check_mng_mode_82574");
1290 hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &data);
1291 return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
1295 * e1000_led_on_82574 - Turn LED on
1296 * @hw: pointer to the HW structure
1300 static s32 e1000_led_on_82574(struct e1000_hw *hw)
1305 DEBUGFUNC("e1000_led_on_82574");
1307 ctrl = hw->mac.ledctl_mode2;
1308 if (!(E1000_STATUS_LU & E1000_READ_REG(hw, E1000_STATUS))) {
1310 * If no link, then turn LED on by setting the invert bit
1311 * for each LED that's "on" (0x0E) in ledctl_mode2.
1313 for (i = 0; i < 4; i++)
1314 if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1315 E1000_LEDCTL_MODE_LED_ON)
1316 ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
1318 E1000_WRITE_REG(hw, E1000_LEDCTL, ctrl);
1320 return E1000_SUCCESS;
1325 * e1000_setup_link_82571 - Setup flow control and link settings
1326 * @hw: pointer to the HW structure
1328 * Determines which flow control settings to use, then configures flow
1329 * control. Calls the appropriate media-specific link configuration
1330 * function. Assuming the adapter has a valid link partner, a valid link
1331 * should be established. Assumes the hardware has previously been reset
1332 * and the transmitter and receiver are not enabled.
1334 static s32 e1000_setup_link_82571(struct e1000_hw *hw)
1336 DEBUGFUNC("e1000_setup_link_82571");
1339 * 82573 does not have a word in the NVM to determine
1340 * the default flow control setting, so we explicitly
1343 switch (hw->mac.type) {
1347 if (hw->fc.requested_mode == e1000_fc_default)
1348 hw->fc.requested_mode = e1000_fc_full;
1353 return e1000_setup_link_generic(hw);
1357 * e1000_setup_copper_link_82571 - Configure copper link settings
1358 * @hw: pointer to the HW structure
1360 * Configures the link for auto-neg or forced speed and duplex. Then we check
1361 * for link, once link is established calls to configure collision distance
1362 * and flow control are called.
1364 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
1369 DEBUGFUNC("e1000_setup_copper_link_82571");
1371 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1372 ctrl |= E1000_CTRL_SLU;
1373 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1374 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1376 switch (hw->phy.type) {
1379 ret_val = e1000_copper_link_setup_m88(hw);
1381 case e1000_phy_igp_2:
1382 ret_val = e1000_copper_link_setup_igp(hw);
1385 ret_val = -E1000_ERR_PHY;
1392 ret_val = e1000_setup_copper_link_generic(hw);
1399 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
1400 * @hw: pointer to the HW structure
1402 * Configures collision distance and flow control for fiber and serdes links.
1403 * Upon successful setup, poll for link.
1405 static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
1407 DEBUGFUNC("e1000_setup_fiber_serdes_link_82571");
1409 switch (hw->mac.type) {
1413 * If SerDes loopback mode is entered, there is no form
1414 * of reset to take the adapter out of that mode. So we
1415 * have to explicitly take the adapter out of loopback
1416 * mode. This prevents drivers from twiddling their thumbs
1417 * if another tool failed to take it out of loopback mode.
1419 E1000_WRITE_REG(hw, E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1425 return e1000_setup_fiber_serdes_link_generic(hw);
1429 * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
1430 * @hw: pointer to the HW structure
1432 * Reports the link state as up or down.
1434 * If autonegotiation is supported by the link partner, the link state is
1435 * determined by the result of autonegotiation. This is the most likely case.
1436 * If autonegotiation is not supported by the link partner, and the link
1437 * has a valid signal, force the link up.
1439 * The link state is represented internally here by 4 states:
1442 * 2) autoneg_progress
1443 * 3) autoneg_complete (the link sucessfully autonegotiated)
1444 * 4) forced_up (the link has been forced up, it did not autonegotiate)
1447 static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1449 struct e1000_mac_info *mac = &hw->mac;
1453 s32 ret_val = E1000_SUCCESS;
1455 DEBUGFUNC("e1000_check_for_serdes_link_82571");
1457 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1458 status = E1000_READ_REG(hw, E1000_STATUS);
1459 rxcw = E1000_READ_REG(hw, E1000_RXCW);
1461 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
1463 /* Receiver is synchronized with no invalid bits. */
1464 switch (mac->serdes_link_state) {
1465 case e1000_serdes_link_autoneg_complete:
1466 if (!(status & E1000_STATUS_LU)) {
1468 * We have lost link, retry autoneg before
1469 * reporting link failure
1471 mac->serdes_link_state =
1472 e1000_serdes_link_autoneg_progress;
1473 mac->serdes_has_link = FALSE;
1474 DEBUGOUT("AN_UP -> AN_PROG\n");
1478 case e1000_serdes_link_forced_up:
1480 * If we are receiving /C/ ordered sets, re-enable
1481 * auto-negotiation in the TXCW register and disable
1482 * forced link in the Device Control register in an
1483 * attempt to auto-negotiate with our link partner.
1485 if (rxcw & E1000_RXCW_C) {
1486 /* Enable autoneg, and unforce link up */
1487 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
1488 E1000_WRITE_REG(hw, E1000_CTRL,
1489 (ctrl & ~E1000_CTRL_SLU));
1490 mac->serdes_link_state =
1491 e1000_serdes_link_autoneg_progress;
1492 mac->serdes_has_link = FALSE;
1493 DEBUGOUT("FORCED_UP -> AN_PROG\n");
1497 case e1000_serdes_link_autoneg_progress:
1498 if (rxcw & E1000_RXCW_C) {
1500 * We received /C/ ordered sets, meaning the
1501 * link partner has autonegotiated, and we can
1502 * trust the Link Up (LU) status bit.
1504 if (status & E1000_STATUS_LU) {
1505 mac->serdes_link_state =
1506 e1000_serdes_link_autoneg_complete;
1507 DEBUGOUT("AN_PROG -> AN_UP\n");
1508 mac->serdes_has_link = TRUE;
1510 /* Autoneg completed, but failed. */
1511 mac->serdes_link_state =
1512 e1000_serdes_link_down;
1513 DEBUGOUT("AN_PROG -> DOWN\n");
1517 * The link partner did not autoneg.
1518 * Force link up and full duplex, and change
1521 E1000_WRITE_REG(hw, E1000_TXCW,
1522 (mac->txcw & ~E1000_TXCW_ANE));
1523 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
1524 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1526 /* Configure Flow Control after link up. */
1528 e1000_config_fc_after_link_up_generic(hw);
1530 DEBUGOUT("Error config flow control\n");
1533 mac->serdes_link_state =
1534 e1000_serdes_link_forced_up;
1535 mac->serdes_has_link = TRUE;
1536 DEBUGOUT("AN_PROG -> FORCED_UP\n");
1540 case e1000_serdes_link_down:
1543 * The link was down but the receiver has now gained
1544 * valid sync, so lets see if we can bring the link
1547 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
1548 E1000_WRITE_REG(hw, E1000_CTRL,
1549 (ctrl & ~E1000_CTRL_SLU));
1550 mac->serdes_link_state =
1551 e1000_serdes_link_autoneg_progress;
1552 DEBUGOUT("DOWN -> AN_PROG\n");
1556 if (!(rxcw & E1000_RXCW_SYNCH)) {
1557 mac->serdes_has_link = FALSE;
1558 mac->serdes_link_state = e1000_serdes_link_down;
1559 DEBUGOUT("ANYSTATE -> DOWN\n");
1562 * We have sync, and can tolerate one invalid (IV)
1563 * codeword before declaring link down, so reread
1567 rxcw = E1000_READ_REG(hw, E1000_RXCW);
1568 if (rxcw & E1000_RXCW_IV) {
1569 mac->serdes_link_state = e1000_serdes_link_down;
1570 mac->serdes_has_link = FALSE;
1571 DEBUGOUT("ANYSTATE -> DOWN\n");
1580 * e1000_valid_led_default_82571 - Verify a valid default LED config
1581 * @hw: pointer to the HW structure
1582 * @data: pointer to the NVM (EEPROM)
1584 * Read the EEPROM for the current default LED configuration. If the
1585 * LED configuration is not valid, set to a valid LED configuration.
1587 static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
1591 DEBUGFUNC("e1000_valid_led_default_82571");
1593 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
1595 DEBUGOUT("NVM Read Error\n");
1599 switch (hw->mac.type) {
1603 if (*data == ID_LED_RESERVED_F746)
1604 *data = ID_LED_DEFAULT_82573;
1607 if (*data == ID_LED_RESERVED_0000 ||
1608 *data == ID_LED_RESERVED_FFFF)
1609 *data = ID_LED_DEFAULT;
1618 * e1000_get_laa_state_82571 - Get locally administered address state
1619 * @hw: pointer to the HW structure
1621 * Retrieve and return the current locally administered address state.
1623 bool e1000_get_laa_state_82571(struct e1000_hw *hw)
1625 DEBUGFUNC("e1000_get_laa_state_82571");
1627 if (hw->mac.type != e1000_82571)
1630 return hw->dev_spec._82571.laa_is_present;
1634 * e1000_set_laa_state_82571 - Set locally administered address state
1635 * @hw: pointer to the HW structure
1636 * @state: enable/disable locally administered address
1638 * Enable/Disable the current locally administered address state.
1640 void e1000_set_laa_state_82571(struct e1000_hw *hw, bool state)
1642 DEBUGFUNC("e1000_set_laa_state_82571");
1644 if (hw->mac.type != e1000_82571)
1647 hw->dev_spec._82571.laa_is_present = state;
1649 /* If workaround is activated... */
1652 * Hold a copy of the LAA in RAR[14] This is done so that
1653 * between the time RAR[0] gets clobbered and the time it
1654 * gets fixed, the actual LAA is in one of the RARs and no
1655 * incoming packets directed to this port are dropped.
1656 * Eventually the LAA will be in RAR[0] and RAR[14].
1658 e1000_rar_set_generic(hw, hw->mac.addr,
1659 hw->mac.rar_entry_count - 1);
1664 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
1665 * @hw: pointer to the HW structure
1667 * Verifies that the EEPROM has completed the update. After updating the
1668 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
1669 * the checksum fix is not implemented, we need to set the bit and update
1670 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
1671 * we need to return bad checksum.
1673 static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
1675 struct e1000_nvm_info *nvm = &hw->nvm;
1676 s32 ret_val = E1000_SUCCESS;
1679 DEBUGFUNC("e1000_fix_nvm_checksum_82571");
1681 if (nvm->type != e1000_nvm_flash_hw)
1685 * Check bit 4 of word 10h. If it is 0, firmware is done updating
1686 * 10h-12h. Checksum may need to be fixed.
1688 ret_val = nvm->ops.read(hw, 0x10, 1, &data);
1692 if (!(data & 0x10)) {
1694 * Read 0x23 and check bit 15. This bit is a 1
1695 * when the checksum has already been fixed. If
1696 * the checksum is still wrong and this bit is a
1697 * 1, we need to return bad checksum. Otherwise,
1698 * we need to set this bit to a 1 and update the
1701 ret_val = nvm->ops.read(hw, 0x23, 1, &data);
1705 if (!(data & 0x8000)) {
1707 ret_val = nvm->ops.write(hw, 0x23, 1, &data);
1710 ret_val = nvm->ops.update(hw);
1720 * e1000_read_mac_addr_82571 - Read device MAC address
1721 * @hw: pointer to the HW structure
1723 static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1725 s32 ret_val = E1000_SUCCESS;
1727 DEBUGFUNC("e1000_read_mac_addr_82571");
1730 * If there's an alternate MAC address place it in RAR0
1731 * so that it will override the Si installed default perm
1734 ret_val = e1000_check_alt_mac_addr_generic(hw);
1738 ret_val = e1000_read_mac_addr_generic(hw);
1745 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
1746 * @hw: pointer to the HW structure
1748 * In the case of a PHY power down to save power, or to turn off link during a
1749 * driver unload, or wake on lan is not enabled, remove the link.
1751 static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
1753 struct e1000_phy_info *phy = &hw->phy;
1754 struct e1000_mac_info *mac = &hw->mac;
1756 if (!(phy->ops.check_reset_block))
1759 /* If the management interface is not enabled, then power down */
1760 if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
1761 e1000_power_down_phy_copper(hw);
1767 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
1768 * @hw: pointer to the HW structure
1770 * Clears the hardware counters by reading the counter registers.
1772 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
1774 DEBUGFUNC("e1000_clear_hw_cntrs_82571");
1776 e1000_clear_hw_cntrs_base_generic(hw);
1778 E1000_READ_REG(hw, E1000_PRC64);
1779 E1000_READ_REG(hw, E1000_PRC127);
1780 E1000_READ_REG(hw, E1000_PRC255);
1781 E1000_READ_REG(hw, E1000_PRC511);
1782 E1000_READ_REG(hw, E1000_PRC1023);
1783 E1000_READ_REG(hw, E1000_PRC1522);
1784 E1000_READ_REG(hw, E1000_PTC64);
1785 E1000_READ_REG(hw, E1000_PTC127);
1786 E1000_READ_REG(hw, E1000_PTC255);
1787 E1000_READ_REG(hw, E1000_PTC511);
1788 E1000_READ_REG(hw, E1000_PTC1023);
1789 E1000_READ_REG(hw, E1000_PTC1522);
1791 E1000_READ_REG(hw, E1000_ALGNERRC);
1792 E1000_READ_REG(hw, E1000_RXERRC);
1793 E1000_READ_REG(hw, E1000_TNCRS);
1794 E1000_READ_REG(hw, E1000_CEXTERR);
1795 E1000_READ_REG(hw, E1000_TSCTC);
1796 E1000_READ_REG(hw, E1000_TSCTFC);
1798 E1000_READ_REG(hw, E1000_MGTPRC);
1799 E1000_READ_REG(hw, E1000_MGTPDC);
1800 E1000_READ_REG(hw, E1000_MGTPTC);
1802 E1000_READ_REG(hw, E1000_IAC);
1803 E1000_READ_REG(hw, E1000_ICRXOC);
1805 E1000_READ_REG(hw, E1000_ICRXPTC);
1806 E1000_READ_REG(hw, E1000_ICRXATC);
1807 E1000_READ_REG(hw, E1000_ICTXPTC);
1808 E1000_READ_REG(hw, E1000_ICTXATC);
1809 E1000_READ_REG(hw, E1000_ICTXQEC);
1810 E1000_READ_REG(hw, E1000_ICTXQMTC);
1811 E1000_READ_REG(hw, E1000_ICRXDMTC);