1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
30 * 82571EB Gigabit Ethernet Controller
31 * 82571EB Gigabit Ethernet Controller (Copper)
32 * 82571EB Gigabit Ethernet Controller (Fiber)
33 * 82571EB Dual Port Gigabit Mezzanine Adapter
34 * 82571EB Quad Port Gigabit Mezzanine Adapter
35 * 82571PT Gigabit PT Quad Port Server ExpressModule
36 * 82572EI Gigabit Ethernet Controller (Copper)
37 * 82572EI Gigabit Ethernet Controller (Fiber)
38 * 82572EI Gigabit Ethernet Controller
39 * 82573V Gigabit Ethernet Controller (Copper)
40 * 82573E Gigabit Ethernet Controller (Copper)
41 * 82573L Gigabit Ethernet Controller
42 * 82574L Gigabit Network Connection
43 * 82583V Gigabit Network Connection
48 #define ID_LED_RESERVED_F746 0xF746
49 #define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \
50 (ID_LED_OFF1_ON2 << 8) | \
51 (ID_LED_DEF1_DEF2 << 4) | \
54 #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
55 #define E1000_BASE1000T_STATUS 10
56 #define E1000_IDLE_ERROR_COUNT_MASK 0xFF
57 #define E1000_RECEIVE_ERROR_COUNTER 21
58 #define E1000_RECEIVE_ERROR_MAX 0xFFFF
60 #define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */
62 static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
63 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
64 static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
65 static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw);
66 static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
67 u16 words, u16 *data);
68 static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
69 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
70 static s32 e1000_setup_link_82571(struct e1000_hw *hw);
71 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
72 static void e1000_clear_vfta_82571(struct e1000_hw *hw);
73 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
74 static s32 e1000_led_on_82574(struct e1000_hw *hw);
75 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
76 static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
77 static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw);
78 static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw);
79 static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw);
82 * e1000_init_phy_params_82571 - Init PHY func ptrs.
83 * @hw: pointer to the HW structure
85 static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
87 struct e1000_phy_info *phy = &hw->phy;
90 if (hw->phy.media_type != e1000_media_type_copper) {
91 phy->type = e1000_phy_none;
96 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
97 phy->reset_delay_us = 100;
99 phy->ops.power_up = e1000_power_up_phy_copper;
100 phy->ops.power_down = e1000_power_down_phy_copper_82571;
102 switch (hw->mac.type) {
105 phy->type = e1000_phy_igp_2;
108 phy->type = e1000_phy_m88;
112 phy->type = e1000_phy_bm;
113 phy->ops.acquire = e1000_get_hw_semaphore_82574;
114 phy->ops.release = e1000_put_hw_semaphore_82574;
117 return -E1000_ERR_PHY;
121 /* This can only be done after all function pointers are setup. */
122 ret_val = e1000_get_phy_id_82571(hw);
125 switch (hw->mac.type) {
128 if (phy->id != IGP01E1000_I_PHY_ID)
129 return -E1000_ERR_PHY;
132 if (phy->id != M88E1111_I_PHY_ID)
133 return -E1000_ERR_PHY;
137 if (phy->id != BME1000_E_PHY_ID_R2)
138 return -E1000_ERR_PHY;
141 return -E1000_ERR_PHY;
149 * e1000_init_nvm_params_82571 - Init NVM func ptrs.
150 * @hw: pointer to the HW structure
152 static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
154 struct e1000_nvm_info *nvm = &hw->nvm;
155 u32 eecd = er32(EECD);
158 nvm->opcode_bits = 8;
160 switch (nvm->override) {
161 case e1000_nvm_override_spi_large:
163 nvm->address_bits = 16;
165 case e1000_nvm_override_spi_small:
167 nvm->address_bits = 8;
170 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
171 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
175 switch (hw->mac.type) {
179 if (((eecd >> 15) & 0x3) == 0x3) {
180 nvm->type = e1000_nvm_flash_hw;
181 nvm->word_size = 2048;
183 * Autonomous Flash update bit must be cleared due
184 * to Flash update issue.
186 eecd &= ~E1000_EECD_AUPDEN;
192 nvm->type = e1000_nvm_eeprom_spi;
193 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
194 E1000_EECD_SIZE_EX_SHIFT);
196 * Added to a constant, "size" becomes the left-shift value
197 * for setting word_size.
199 size += NVM_WORD_SIZE_BASE_SHIFT;
201 /* EEPROM access above 16k is unsupported */
204 nvm->word_size = 1 << size;
208 /* Function Pointers */
209 switch (hw->mac.type) {
212 nvm->ops.acquire = e1000_get_hw_semaphore_82574;
213 nvm->ops.release = e1000_put_hw_semaphore_82574;
223 * e1000_init_mac_params_82571 - Init MAC func ptrs.
224 * @hw: pointer to the HW structure
226 static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
228 struct e1000_hw *hw = &adapter->hw;
229 struct e1000_mac_info *mac = &hw->mac;
230 struct e1000_mac_operations *func = &mac->ops;
233 bool force_clear_smbi = false;
236 switch (adapter->pdev->device) {
237 case E1000_DEV_ID_82571EB_FIBER:
238 case E1000_DEV_ID_82572EI_FIBER:
239 case E1000_DEV_ID_82571EB_QUAD_FIBER:
240 hw->phy.media_type = e1000_media_type_fiber;
242 case E1000_DEV_ID_82571EB_SERDES:
243 case E1000_DEV_ID_82572EI_SERDES:
244 case E1000_DEV_ID_82571EB_SERDES_DUAL:
245 case E1000_DEV_ID_82571EB_SERDES_QUAD:
246 hw->phy.media_type = e1000_media_type_internal_serdes;
249 hw->phy.media_type = e1000_media_type_copper;
253 /* Set mta register count */
254 mac->mta_reg_count = 128;
255 /* Set rar entry count */
256 mac->rar_entry_count = E1000_RAR_ENTRIES;
257 /* Adaptive IFS supported */
258 mac->adaptive_ifs = true;
261 switch (hw->phy.media_type) {
262 case e1000_media_type_copper:
263 func->setup_physical_interface = e1000_setup_copper_link_82571;
264 func->check_for_link = e1000e_check_for_copper_link;
265 func->get_link_up_info = e1000e_get_speed_and_duplex_copper;
267 case e1000_media_type_fiber:
268 func->setup_physical_interface =
269 e1000_setup_fiber_serdes_link_82571;
270 func->check_for_link = e1000e_check_for_fiber_link;
271 func->get_link_up_info =
272 e1000e_get_speed_and_duplex_fiber_serdes;
274 case e1000_media_type_internal_serdes:
275 func->setup_physical_interface =
276 e1000_setup_fiber_serdes_link_82571;
277 func->check_for_link = e1000_check_for_serdes_link_82571;
278 func->get_link_up_info =
279 e1000e_get_speed_and_duplex_fiber_serdes;
282 return -E1000_ERR_CONFIG;
286 switch (hw->mac.type) {
288 func->set_lan_id = e1000_set_lan_id_single_port;
289 func->check_mng_mode = e1000e_check_mng_mode_generic;
290 func->led_on = e1000e_led_on_generic;
293 mac->has_fwsm = true;
295 * ARC supported; valid only if manageability features are
298 mac->arc_subsystem_valid =
299 (er32(FWSM) & E1000_FWSM_MODE_MASK)
304 func->set_lan_id = e1000_set_lan_id_single_port;
305 func->check_mng_mode = e1000_check_mng_mode_82574;
306 func->led_on = e1000_led_on_82574;
309 func->check_mng_mode = e1000e_check_mng_mode_generic;
310 func->led_on = e1000e_led_on_generic;
313 mac->has_fwsm = true;
318 * Ensure that the inter-port SWSM.SMBI lock bit is clear before
319 * first NVM or PHY acess. This should be done for single-port
320 * devices, and for one port only on dual-port devices so that
321 * for those devices we can still use the SMBI lock to synchronize
322 * inter-port accesses to the PHY & NVM.
324 switch (hw->mac.type) {
329 if (!(swsm2 & E1000_SWSM2_LOCK)) {
330 /* Only do this for the first interface on this card */
332 swsm2 | E1000_SWSM2_LOCK);
333 force_clear_smbi = true;
335 force_clear_smbi = false;
338 force_clear_smbi = true;
342 if (force_clear_smbi) {
343 /* Make sure SWSM.SMBI is clear */
345 if (swsm & E1000_SWSM_SMBI) {
346 /* This bit should not be set on a first interface, and
347 * indicates that the bootagent or EFI code has
348 * improperly left this bit enabled
350 e_dbg("Please update your 82571 Bootagent\n");
352 ew32(SWSM, swsm & ~E1000_SWSM_SMBI);
356 * Initialize device specific counter of SMBI acquisition
359 hw->dev_spec.e82571.smb_counter = 0;
364 static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
366 struct e1000_hw *hw = &adapter->hw;
367 static int global_quad_port_a; /* global port a indication */
368 struct pci_dev *pdev = adapter->pdev;
369 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
372 rc = e1000_init_mac_params_82571(adapter);
376 rc = e1000_init_nvm_params_82571(hw);
380 rc = e1000_init_phy_params_82571(hw);
384 /* tag quad port adapters first, it's used below */
385 switch (pdev->device) {
386 case E1000_DEV_ID_82571EB_QUAD_COPPER:
387 case E1000_DEV_ID_82571EB_QUAD_FIBER:
388 case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
389 case E1000_DEV_ID_82571PT_QUAD_COPPER:
390 adapter->flags |= FLAG_IS_QUAD_PORT;
391 /* mark the first port */
392 if (global_quad_port_a == 0)
393 adapter->flags |= FLAG_IS_QUAD_PORT_A;
394 /* Reset for multiple quad port adapters */
395 global_quad_port_a++;
396 if (global_quad_port_a == 4)
397 global_quad_port_a = 0;
403 switch (adapter->hw.mac.type) {
405 /* these dual ports don't have WoL on port B at all */
406 if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) ||
407 (pdev->device == E1000_DEV_ID_82571EB_SERDES) ||
408 (pdev->device == E1000_DEV_ID_82571EB_COPPER)) &&
410 adapter->flags &= ~FLAG_HAS_WOL;
411 /* quad ports only support WoL on port A */
412 if (adapter->flags & FLAG_IS_QUAD_PORT &&
413 (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
414 adapter->flags &= ~FLAG_HAS_WOL;
415 /* Does not support WoL on any port */
416 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
417 adapter->flags &= ~FLAG_HAS_WOL;
422 /* Disable ASPM L0s due to hardware errata */
423 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
425 if (pdev->device == E1000_DEV_ID_82573L) {
426 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
427 adapter->max_hw_frame_size = DEFAULT_JUMBO;
438 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
439 * @hw: pointer to the HW structure
441 * Reads the PHY registers and stores the PHY ID and possibly the PHY
442 * revision in the hardware structure.
444 static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
446 struct e1000_phy_info *phy = &hw->phy;
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 return e1000e_get_phy_id(hw);
466 ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
470 phy->id = (u32)(phy_id << 16);
472 ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
476 phy->id |= (u32)(phy_id);
477 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
480 return -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 sw_timeout = hw->nvm.word_size + 1;
497 s32 fw_timeout = hw->nvm.word_size + 1;
501 * If we have timedout 3 times on trying to acquire
502 * the inter-port SMBI semaphore, there is old code
503 * operating on the other port, and it is not
504 * releasing SMBI. Modify the number of times that
505 * we try for the semaphore to interwork with this
508 if (hw->dev_spec.e82571.smb_counter > 2)
511 /* Get the SW semaphore */
512 while (i < sw_timeout) {
514 if (!(swsm & E1000_SWSM_SMBI))
521 if (i == sw_timeout) {
522 e_dbg("Driver can't access device - SMBI bit is set.\n");
523 hw->dev_spec.e82571.smb_counter++;
525 /* Get the FW semaphore. */
526 for (i = 0; i < fw_timeout; i++) {
528 ew32(SWSM, swsm | E1000_SWSM_SWESMBI);
530 /* Semaphore acquired if bit latched */
531 if (er32(SWSM) & E1000_SWSM_SWESMBI)
537 if (i == fw_timeout) {
538 /* Release semaphores */
539 e1000_put_hw_semaphore_82571(hw);
540 e_dbg("Driver can't access the NVM\n");
541 return -E1000_ERR_NVM;
548 * e1000_put_hw_semaphore_82571 - Release hardware semaphore
549 * @hw: pointer to the HW structure
551 * Release hardware semaphore used to access the PHY or NVM
553 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
558 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
562 * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore
563 * @hw: pointer to the HW structure
565 * Acquire the HW semaphore during reset.
568 static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
574 extcnf_ctrl = er32(EXTCNF_CTRL);
575 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
577 ew32(EXTCNF_CTRL, extcnf_ctrl);
578 extcnf_ctrl = er32(EXTCNF_CTRL);
580 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
583 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
587 } while (i < MDIO_OWNERSHIP_TIMEOUT);
589 if (i == MDIO_OWNERSHIP_TIMEOUT) {
590 /* Release semaphores */
591 e1000_put_hw_semaphore_82573(hw);
592 e_dbg("Driver can't access the PHY\n");
593 ret_val = -E1000_ERR_PHY;
602 * e1000_put_hw_semaphore_82573 - Release hardware semaphore
603 * @hw: pointer to the HW structure
605 * Release hardware semaphore used during reset.
608 static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw)
612 extcnf_ctrl = er32(EXTCNF_CTRL);
613 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
614 ew32(EXTCNF_CTRL, extcnf_ctrl);
617 static DEFINE_MUTEX(swflag_mutex);
620 * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore
621 * @hw: pointer to the HW structure
623 * Acquire the HW semaphore to access the PHY or NVM.
626 static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw)
630 mutex_lock(&swflag_mutex);
631 ret_val = e1000_get_hw_semaphore_82573(hw);
633 mutex_unlock(&swflag_mutex);
638 * e1000_put_hw_semaphore_82574 - Release hardware semaphore
639 * @hw: pointer to the HW structure
641 * Release hardware semaphore used to access the PHY or NVM
644 static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw)
646 e1000_put_hw_semaphore_82573(hw);
647 mutex_unlock(&swflag_mutex);
651 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
652 * @hw: pointer to the HW structure
654 * To gain access to the EEPROM, first we must obtain a hardware semaphore.
655 * Then for non-82573 hardware, set the EEPROM access request bit and wait
656 * for EEPROM access grant bit. If the access grant bit is not set, release
657 * hardware semaphore.
659 static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
663 ret_val = e1000_get_hw_semaphore_82571(hw);
667 switch (hw->mac.type) {
671 ret_val = e1000e_acquire_nvm(hw);
676 e1000_put_hw_semaphore_82571(hw);
682 * e1000_release_nvm_82571 - Release exclusive access to EEPROM
683 * @hw: pointer to the HW structure
685 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
687 static void e1000_release_nvm_82571(struct e1000_hw *hw)
689 e1000e_release_nvm(hw);
690 e1000_put_hw_semaphore_82571(hw);
694 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
695 * @hw: pointer to the HW structure
696 * @offset: offset within the EEPROM to be written to
697 * @words: number of words to write
698 * @data: 16 bit word(s) to be written to the EEPROM
700 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
702 * If e1000e_update_nvm_checksum is not called after this function, the
703 * EEPROM will most likely contain an invalid checksum.
705 static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
710 switch (hw->mac.type) {
714 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
718 ret_val = e1000e_write_nvm_spi(hw, offset, words, data);
721 ret_val = -E1000_ERR_NVM;
729 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
730 * @hw: pointer to the HW structure
732 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
733 * up to the checksum. Then calculates the EEPROM checksum and writes the
734 * value to the EEPROM.
736 static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
742 ret_val = e1000e_update_nvm_checksum_generic(hw);
747 * If our nvm is an EEPROM, then we're done
748 * otherwise, commit the checksum to the flash NVM.
750 if (hw->nvm.type != e1000_nvm_flash_hw)
753 /* Check for pending operations. */
754 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
756 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
760 if (i == E1000_FLASH_UPDATES)
761 return -E1000_ERR_NVM;
763 /* Reset the firmware if using STM opcode. */
764 if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) {
766 * The enabling of and the actual reset must be done
767 * in two write cycles.
769 ew32(HICR, E1000_HICR_FW_RESET_ENABLE);
771 ew32(HICR, E1000_HICR_FW_RESET);
774 /* Commit the write to flash */
775 eecd = er32(EECD) | E1000_EECD_FLUPD;
778 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
780 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
784 if (i == E1000_FLASH_UPDATES)
785 return -E1000_ERR_NVM;
791 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
792 * @hw: pointer to the HW structure
794 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
795 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
797 static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
799 if (hw->nvm.type == e1000_nvm_flash_hw)
800 e1000_fix_nvm_checksum_82571(hw);
802 return e1000e_validate_nvm_checksum_generic(hw);
806 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
807 * @hw: pointer to the HW structure
808 * @offset: offset within the EEPROM to be written to
809 * @words: number of words to write
810 * @data: 16 bit word(s) to be written to the EEPROM
812 * After checking for invalid values, poll the EEPROM to ensure the previous
813 * command has completed before trying to write the next word. After write
814 * poll for completion.
816 * If e1000e_update_nvm_checksum is not called after this function, the
817 * EEPROM will most likely contain an invalid checksum.
819 static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
820 u16 words, u16 *data)
822 struct e1000_nvm_info *nvm = &hw->nvm;
827 * A check for invalid values: offset too large, too many words,
828 * and not enough words.
830 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
832 e_dbg("nvm parameter(s) out of bounds\n");
833 return -E1000_ERR_NVM;
836 for (i = 0; i < words; i++) {
837 eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
838 ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
839 E1000_NVM_RW_REG_START;
841 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
847 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
856 * e1000_get_cfg_done_82571 - Poll for configuration done
857 * @hw: pointer to the HW structure
859 * Reads the management control register for the config done bit to be set.
861 static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
863 s32 timeout = PHY_CFG_TIMEOUT;
867 E1000_NVM_CFG_DONE_PORT_0)
873 e_dbg("MNG configuration cycle has not completed.\n");
874 return -E1000_ERR_RESET;
881 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
882 * @hw: pointer to the HW structure
883 * @active: true to enable LPLU, false to disable
885 * Sets the LPLU D0 state according to the active flag. When activating LPLU
886 * this function also disables smart speed and vice versa. LPLU will not be
887 * activated unless the device autonegotiation advertisement meets standards
888 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
889 * pointer entry point only called by PHY setup routines.
891 static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
893 struct e1000_phy_info *phy = &hw->phy;
897 ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
902 data |= IGP02E1000_PM_D0_LPLU;
903 ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
907 /* When LPLU is enabled, we should disable SmartSpeed */
908 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
909 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
910 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
914 data &= ~IGP02E1000_PM_D0_LPLU;
915 ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
917 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
918 * during Dx states where the power conservation is most
919 * important. During driver activity we should enable
920 * SmartSpeed, so performance is maintained.
922 if (phy->smart_speed == e1000_smart_speed_on) {
923 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
928 data |= IGP01E1000_PSCFR_SMART_SPEED;
929 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
933 } else if (phy->smart_speed == e1000_smart_speed_off) {
934 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
939 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
940 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
951 * e1000_reset_hw_82571 - Reset hardware
952 * @hw: pointer to the HW structure
954 * This resets the hardware into a known state.
956 static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
958 u32 ctrl, ctrl_ext, icr;
962 * Prevent the PCI-E bus from sticking if there is no TLP connection
963 * on the last TLP read/write transaction when MAC is reset.
965 ret_val = e1000e_disable_pcie_master(hw);
967 e_dbg("PCI-E Master disable polling has failed.\n");
969 e_dbg("Masking off all interrupts\n");
970 ew32(IMC, 0xffffffff);
973 ew32(TCTL, E1000_TCTL_PSP);
979 * Must acquire the MDIO ownership before MAC reset.
980 * Ownership defaults to firmware after a reset.
982 switch (hw->mac.type) {
984 ret_val = e1000_get_hw_semaphore_82573(hw);
988 ret_val = e1000_get_hw_semaphore_82574(hw);
994 e_dbg("Cannot acquire MDIO ownership\n");
998 e_dbg("Issuing a global reset to MAC\n");
999 ew32(CTRL, ctrl | E1000_CTRL_RST);
1001 /* Must release MDIO ownership and mutex after MAC reset. */
1002 switch (hw->mac.type) {
1005 e1000_put_hw_semaphore_82574(hw);
1011 if (hw->nvm.type == e1000_nvm_flash_hw) {
1013 ctrl_ext = er32(CTRL_EXT);
1014 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
1015 ew32(CTRL_EXT, ctrl_ext);
1019 ret_val = e1000e_get_auto_rd_done(hw);
1021 /* We don't want to continue accessing MAC registers. */
1025 * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
1026 * Need to wait for Phy configuration completion before accessing
1030 switch (hw->mac.type) {
1040 /* Clear any pending interrupt events. */
1041 ew32(IMC, 0xffffffff);
1044 if (hw->mac.type == e1000_82571) {
1045 /* Install any alternate MAC address into RAR0 */
1046 ret_val = e1000_check_alt_mac_addr_generic(hw);
1050 e1000e_set_laa_state_82571(hw, true);
1053 /* Reinitialize the 82571 serdes link state machine */
1054 if (hw->phy.media_type == e1000_media_type_internal_serdes)
1055 hw->mac.serdes_link_state = e1000_serdes_link_down;
1061 * e1000_init_hw_82571 - Initialize hardware
1062 * @hw: pointer to the HW structure
1064 * This inits the hardware readying it for operation.
1066 static s32 e1000_init_hw_82571(struct e1000_hw *hw)
1068 struct e1000_mac_info *mac = &hw->mac;
1071 u16 i, rar_count = mac->rar_entry_count;
1073 e1000_initialize_hw_bits_82571(hw);
1075 /* Initialize identification LED */
1076 ret_val = e1000e_id_led_init(hw);
1078 e_dbg("Error initializing identification LED\n");
1079 /* This is not fatal and we should not stop init due to this */
1081 /* Disabling VLAN filtering */
1082 e_dbg("Initializing the IEEE VLAN\n");
1083 mac->ops.clear_vfta(hw);
1085 /* Setup the receive address. */
1087 * If, however, a locally administered address was assigned to the
1088 * 82571, we must reserve a RAR for it to work around an issue where
1089 * resetting one port will reload the MAC on the other port.
1091 if (e1000e_get_laa_state_82571(hw))
1093 e1000e_init_rx_addrs(hw, rar_count);
1095 /* Zero out the Multicast HASH table */
1096 e_dbg("Zeroing the MTA\n");
1097 for (i = 0; i < mac->mta_reg_count; i++)
1098 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1100 /* Setup link and flow control */
1101 ret_val = e1000_setup_link_82571(hw);
1103 /* Set the transmit descriptor write-back policy */
1104 reg_data = er32(TXDCTL(0));
1105 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1106 E1000_TXDCTL_FULL_TX_DESC_WB |
1107 E1000_TXDCTL_COUNT_DESC;
1108 ew32(TXDCTL(0), reg_data);
1110 /* ...for both queues. */
1111 switch (mac->type) {
1113 e1000e_enable_tx_pkt_filtering(hw);
1117 reg_data = er32(GCR);
1118 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
1119 ew32(GCR, reg_data);
1122 reg_data = er32(TXDCTL(1));
1123 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1124 E1000_TXDCTL_FULL_TX_DESC_WB |
1125 E1000_TXDCTL_COUNT_DESC;
1126 ew32(TXDCTL(1), reg_data);
1131 * Clear all of the statistics registers (clear on read). It is
1132 * important that we do this after we have tried to establish link
1133 * because the symbol error count will increment wildly if there
1136 e1000_clear_hw_cntrs_82571(hw);
1142 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
1143 * @hw: pointer to the HW structure
1145 * Initializes required hardware-dependent bits needed for normal operation.
1147 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1151 /* Transmit Descriptor Control 0 */
1152 reg = er32(TXDCTL(0));
1154 ew32(TXDCTL(0), reg);
1156 /* Transmit Descriptor Control 1 */
1157 reg = er32(TXDCTL(1));
1159 ew32(TXDCTL(1), reg);
1161 /* Transmit Arbitration Control 0 */
1162 reg = er32(TARC(0));
1163 reg &= ~(0xF << 27); /* 30:27 */
1164 switch (hw->mac.type) {
1167 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1174 /* Transmit Arbitration Control 1 */
1175 reg = er32(TARC(1));
1176 switch (hw->mac.type) {
1179 reg &= ~((1 << 29) | (1 << 30));
1180 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
1181 if (er32(TCTL) & E1000_TCTL_MULR)
1191 /* Device Control */
1192 switch (hw->mac.type) {
1204 /* Extended Device Control */
1205 switch (hw->mac.type) {
1209 reg = er32(CTRL_EXT);
1212 ew32(CTRL_EXT, reg);
1218 if (hw->mac.type == e1000_82571) {
1219 reg = er32(PBA_ECC);
1220 reg |= E1000_PBA_ECC_CORR_EN;
1224 * Workaround for hardware errata.
1225 * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572
1228 if ((hw->mac.type == e1000_82571) ||
1229 (hw->mac.type == e1000_82572)) {
1230 reg = er32(CTRL_EXT);
1231 reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN;
1232 ew32(CTRL_EXT, reg);
1236 /* PCI-Ex Control Registers */
1237 switch (hw->mac.type) {
1245 * Workaround for hardware errata.
1246 * apply workaround for hardware errata documented in errata
1247 * docs Fixes issue where some error prone or unreliable PCIe
1248 * completions are occurring, particularly with ASPM enabled.
1249 * Without fix, issue can cause tx timeouts.
1261 * e1000_clear_vfta_82571 - Clear VLAN filter table
1262 * @hw: pointer to the HW structure
1264 * Clears the register array which contains the VLAN filter table by
1265 * setting all the values to 0.
1267 static void e1000_clear_vfta_82571(struct e1000_hw *hw)
1271 u32 vfta_offset = 0;
1272 u32 vfta_bit_in_reg = 0;
1274 switch (hw->mac.type) {
1278 if (hw->mng_cookie.vlan_id != 0) {
1280 * The VFTA is a 4096b bit-field, each identifying
1281 * a single VLAN ID. The following operations
1282 * determine which 32b entry (i.e. offset) into the
1283 * array we want to set the VLAN ID (i.e. bit) of
1284 * the manageability unit.
1286 vfta_offset = (hw->mng_cookie.vlan_id >>
1287 E1000_VFTA_ENTRY_SHIFT) &
1288 E1000_VFTA_ENTRY_MASK;
1289 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
1290 E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
1296 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
1298 * If the offset we want to clear is the same offset of the
1299 * manageability VLAN ID, then clear all bits except that of
1300 * the manageability unit.
1302 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
1303 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
1309 * e1000_check_mng_mode_82574 - Check manageability is enabled
1310 * @hw: pointer to the HW structure
1312 * Reads the NVM Initialization Control Word 2 and returns true
1313 * (>0) if any manageability is enabled, else false (0).
1315 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
1319 e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
1320 return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
1324 * e1000_led_on_82574 - Turn LED on
1325 * @hw: pointer to the HW structure
1329 static s32 e1000_led_on_82574(struct e1000_hw *hw)
1334 ctrl = hw->mac.ledctl_mode2;
1335 if (!(E1000_STATUS_LU & er32(STATUS))) {
1337 * If no link, then turn LED on by setting the invert bit
1338 * for each LED that's "on" (0x0E) in ledctl_mode2.
1340 for (i = 0; i < 4; i++)
1341 if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1342 E1000_LEDCTL_MODE_LED_ON)
1343 ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
1351 * e1000_check_phy_82574 - check 82574 phy hung state
1352 * @hw: pointer to the HW structure
1354 * Returns whether phy is hung or not
1356 bool e1000_check_phy_82574(struct e1000_hw *hw)
1358 u16 status_1kbt = 0;
1359 u16 receive_errors = 0;
1360 bool phy_hung = false;
1364 * Read PHY Receive Error counter first, if its is max - all F's then
1365 * read the Base1000T status register If both are max then PHY is hung.
1367 ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors);
1371 if (receive_errors == E1000_RECEIVE_ERROR_MAX) {
1372 ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt);
1375 if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) ==
1376 E1000_IDLE_ERROR_COUNT_MASK)
1384 * e1000_setup_link_82571 - Setup flow control and link settings
1385 * @hw: pointer to the HW structure
1387 * Determines which flow control settings to use, then configures flow
1388 * control. Calls the appropriate media-specific link configuration
1389 * function. Assuming the adapter has a valid link partner, a valid link
1390 * should be established. Assumes the hardware has previously been reset
1391 * and the transmitter and receiver are not enabled.
1393 static s32 e1000_setup_link_82571(struct e1000_hw *hw)
1396 * 82573 does not have a word in the NVM to determine
1397 * the default flow control setting, so we explicitly
1400 switch (hw->mac.type) {
1404 if (hw->fc.requested_mode == e1000_fc_default)
1405 hw->fc.requested_mode = e1000_fc_full;
1411 return e1000e_setup_link(hw);
1415 * e1000_setup_copper_link_82571 - Configure copper link settings
1416 * @hw: pointer to the HW structure
1418 * Configures the link for auto-neg or forced speed and duplex. Then we check
1419 * for link, once link is established calls to configure collision distance
1420 * and flow control are called.
1422 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
1428 ctrl |= E1000_CTRL_SLU;
1429 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1432 switch (hw->phy.type) {
1435 ret_val = e1000e_copper_link_setup_m88(hw);
1437 case e1000_phy_igp_2:
1438 ret_val = e1000e_copper_link_setup_igp(hw);
1441 return -E1000_ERR_PHY;
1448 ret_val = e1000e_setup_copper_link(hw);
1454 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
1455 * @hw: pointer to the HW structure
1457 * Configures collision distance and flow control for fiber and serdes links.
1458 * Upon successful setup, poll for link.
1460 static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
1462 switch (hw->mac.type) {
1466 * If SerDes loopback mode is entered, there is no form
1467 * of reset to take the adapter out of that mode. So we
1468 * have to explicitly take the adapter out of loopback
1469 * mode. This prevents drivers from twiddling their thumbs
1470 * if another tool failed to take it out of loopback mode.
1472 ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1478 return e1000e_setup_fiber_serdes_link(hw);
1482 * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
1483 * @hw: pointer to the HW structure
1485 * Reports the link state as up or down.
1487 * If autonegotiation is supported by the link partner, the link state is
1488 * determined by the result of autonegotiation. This is the most likely case.
1489 * If autonegotiation is not supported by the link partner, and the link
1490 * has a valid signal, force the link up.
1492 * The link state is represented internally here by 4 states:
1495 * 2) autoneg_progress
1496 * 3) autoneg_complete (the link successfully autonegotiated)
1497 * 4) forced_up (the link has been forced up, it did not autonegotiate)
1500 static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1502 struct e1000_mac_info *mac = &hw->mac;
1509 status = er32(STATUS);
1512 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
1514 /* Receiver is synchronized with no invalid bits. */
1515 switch (mac->serdes_link_state) {
1516 case e1000_serdes_link_autoneg_complete:
1517 if (!(status & E1000_STATUS_LU)) {
1519 * We have lost link, retry autoneg before
1520 * reporting link failure
1522 mac->serdes_link_state =
1523 e1000_serdes_link_autoneg_progress;
1524 mac->serdes_has_link = false;
1525 e_dbg("AN_UP -> AN_PROG\n");
1529 case e1000_serdes_link_forced_up:
1531 * If we are receiving /C/ ordered sets, re-enable
1532 * auto-negotiation in the TXCW register and disable
1533 * forced link in the Device Control register in an
1534 * attempt to auto-negotiate with our link partner.
1535 * If the partner code word is null, stop forcing
1536 * and restart auto negotiation.
1538 if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
1539 /* Enable autoneg, and unforce link up */
1540 ew32(TXCW, mac->txcw);
1541 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
1542 mac->serdes_link_state =
1543 e1000_serdes_link_autoneg_progress;
1544 mac->serdes_has_link = false;
1545 e_dbg("FORCED_UP -> AN_PROG\n");
1549 case e1000_serdes_link_autoneg_progress:
1550 if (rxcw & E1000_RXCW_C) {
1552 * We received /C/ ordered sets, meaning the
1553 * link partner has autonegotiated, and we can
1554 * trust the Link Up (LU) status bit.
1556 if (status & E1000_STATUS_LU) {
1557 mac->serdes_link_state =
1558 e1000_serdes_link_autoneg_complete;
1559 e_dbg("AN_PROG -> AN_UP\n");
1560 mac->serdes_has_link = true;
1562 /* Autoneg completed, but failed. */
1563 mac->serdes_link_state =
1564 e1000_serdes_link_down;
1565 e_dbg("AN_PROG -> DOWN\n");
1569 * The link partner did not autoneg.
1570 * Force link up and full duplex, and change
1573 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
1574 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
1577 /* Configure Flow Control after link up. */
1578 ret_val = e1000e_config_fc_after_link_up(hw);
1580 e_dbg("Error config flow control\n");
1583 mac->serdes_link_state =
1584 e1000_serdes_link_forced_up;
1585 mac->serdes_has_link = true;
1586 e_dbg("AN_PROG -> FORCED_UP\n");
1590 case e1000_serdes_link_down:
1593 * The link was down but the receiver has now gained
1594 * valid sync, so lets see if we can bring the link
1597 ew32(TXCW, mac->txcw);
1598 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
1599 mac->serdes_link_state =
1600 e1000_serdes_link_autoneg_progress;
1601 e_dbg("DOWN -> AN_PROG\n");
1605 if (!(rxcw & E1000_RXCW_SYNCH)) {
1606 mac->serdes_has_link = false;
1607 mac->serdes_link_state = e1000_serdes_link_down;
1608 e_dbg("ANYSTATE -> DOWN\n");
1611 * We have sync, and can tolerate one invalid (IV)
1612 * codeword before declaring link down, so reread
1617 if (rxcw & E1000_RXCW_IV) {
1618 mac->serdes_link_state = e1000_serdes_link_down;
1619 mac->serdes_has_link = false;
1620 e_dbg("ANYSTATE -> DOWN\n");
1629 * e1000_valid_led_default_82571 - Verify a valid default LED config
1630 * @hw: pointer to the HW structure
1631 * @data: pointer to the NVM (EEPROM)
1633 * Read the EEPROM for the current default LED configuration. If the
1634 * LED configuration is not valid, set to a valid LED configuration.
1636 static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
1640 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
1642 e_dbg("NVM Read Error\n");
1646 switch (hw->mac.type) {
1650 if (*data == ID_LED_RESERVED_F746)
1651 *data = ID_LED_DEFAULT_82573;
1654 if (*data == ID_LED_RESERVED_0000 ||
1655 *data == ID_LED_RESERVED_FFFF)
1656 *data = ID_LED_DEFAULT;
1664 * e1000e_get_laa_state_82571 - Get locally administered address state
1665 * @hw: pointer to the HW structure
1667 * Retrieve and return the current locally administered address state.
1669 bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
1671 if (hw->mac.type != e1000_82571)
1674 return hw->dev_spec.e82571.laa_is_present;
1678 * e1000e_set_laa_state_82571 - Set locally administered address state
1679 * @hw: pointer to the HW structure
1680 * @state: enable/disable locally administered address
1682 * Enable/Disable the current locally administered address state.
1684 void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
1686 if (hw->mac.type != e1000_82571)
1689 hw->dev_spec.e82571.laa_is_present = state;
1691 /* If workaround is activated... */
1694 * Hold a copy of the LAA in RAR[14] This is done so that
1695 * between the time RAR[0] gets clobbered and the time it
1696 * gets fixed, the actual LAA is in one of the RARs and no
1697 * incoming packets directed to this port are dropped.
1698 * Eventually the LAA will be in RAR[0] and RAR[14].
1700 e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1);
1704 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
1705 * @hw: pointer to the HW structure
1707 * Verifies that the EEPROM has completed the update. After updating the
1708 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
1709 * the checksum fix is not implemented, we need to set the bit and update
1710 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
1711 * we need to return bad checksum.
1713 static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
1715 struct e1000_nvm_info *nvm = &hw->nvm;
1719 if (nvm->type != e1000_nvm_flash_hw)
1723 * Check bit 4 of word 10h. If it is 0, firmware is done updating
1724 * 10h-12h. Checksum may need to be fixed.
1726 ret_val = e1000_read_nvm(hw, 0x10, 1, &data);
1730 if (!(data & 0x10)) {
1732 * Read 0x23 and check bit 15. This bit is a 1
1733 * when the checksum has already been fixed. If
1734 * the checksum is still wrong and this bit is a
1735 * 1, we need to return bad checksum. Otherwise,
1736 * we need to set this bit to a 1 and update the
1739 ret_val = e1000_read_nvm(hw, 0x23, 1, &data);
1743 if (!(data & 0x8000)) {
1745 ret_val = e1000_write_nvm(hw, 0x23, 1, &data);
1748 ret_val = e1000e_update_nvm_checksum(hw);
1756 * e1000_read_mac_addr_82571 - Read device MAC address
1757 * @hw: pointer to the HW structure
1759 static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1763 if (hw->mac.type == e1000_82571) {
1765 * If there's an alternate MAC address place it in RAR0
1766 * so that it will override the Si installed default perm
1769 ret_val = e1000_check_alt_mac_addr_generic(hw);
1774 ret_val = e1000_read_mac_addr_generic(hw);
1781 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
1782 * @hw: pointer to the HW structure
1784 * In the case of a PHY power down to save power, or to turn off link during a
1785 * driver unload, or wake on lan is not enabled, remove the link.
1787 static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
1789 struct e1000_phy_info *phy = &hw->phy;
1790 struct e1000_mac_info *mac = &hw->mac;
1792 if (!(phy->ops.check_reset_block))
1795 /* If the management interface is not enabled, then power down */
1796 if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
1797 e1000_power_down_phy_copper(hw);
1801 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
1802 * @hw: pointer to the HW structure
1804 * Clears the hardware counters by reading the counter registers.
1806 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
1808 e1000e_clear_hw_cntrs_base(hw);
1846 static struct e1000_mac_operations e82571_mac_ops = {
1847 /* .check_mng_mode: mac type dependent */
1848 /* .check_for_link: media type dependent */
1849 .id_led_init = e1000e_id_led_init,
1850 .cleanup_led = e1000e_cleanup_led_generic,
1851 .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
1852 .get_bus_info = e1000e_get_bus_info_pcie,
1853 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
1854 /* .get_link_up_info: media type dependent */
1855 /* .led_on: mac type dependent */
1856 .led_off = e1000e_led_off_generic,
1857 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
1858 .write_vfta = e1000_write_vfta_generic,
1859 .clear_vfta = e1000_clear_vfta_82571,
1860 .reset_hw = e1000_reset_hw_82571,
1861 .init_hw = e1000_init_hw_82571,
1862 .setup_link = e1000_setup_link_82571,
1863 /* .setup_physical_interface: media type dependent */
1864 .setup_led = e1000e_setup_led_generic,
1865 .read_mac_addr = e1000_read_mac_addr_82571,
1868 static struct e1000_phy_operations e82_phy_ops_igp = {
1869 .acquire = e1000_get_hw_semaphore_82571,
1870 .check_polarity = e1000_check_polarity_igp,
1871 .check_reset_block = e1000e_check_reset_block_generic,
1873 .force_speed_duplex = e1000e_phy_force_speed_duplex_igp,
1874 .get_cfg_done = e1000_get_cfg_done_82571,
1875 .get_cable_length = e1000e_get_cable_length_igp_2,
1876 .get_info = e1000e_get_phy_info_igp,
1877 .read_reg = e1000e_read_phy_reg_igp,
1878 .release = e1000_put_hw_semaphore_82571,
1879 .reset = e1000e_phy_hw_reset_generic,
1880 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1881 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1882 .write_reg = e1000e_write_phy_reg_igp,
1883 .cfg_on_link_up = NULL,
1886 static struct e1000_phy_operations e82_phy_ops_m88 = {
1887 .acquire = e1000_get_hw_semaphore_82571,
1888 .check_polarity = e1000_check_polarity_m88,
1889 .check_reset_block = e1000e_check_reset_block_generic,
1890 .commit = e1000e_phy_sw_reset,
1891 .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
1892 .get_cfg_done = e1000e_get_cfg_done,
1893 .get_cable_length = e1000e_get_cable_length_m88,
1894 .get_info = e1000e_get_phy_info_m88,
1895 .read_reg = e1000e_read_phy_reg_m88,
1896 .release = e1000_put_hw_semaphore_82571,
1897 .reset = e1000e_phy_hw_reset_generic,
1898 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1899 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1900 .write_reg = e1000e_write_phy_reg_m88,
1901 .cfg_on_link_up = NULL,
1904 static struct e1000_phy_operations e82_phy_ops_bm = {
1905 .acquire = e1000_get_hw_semaphore_82571,
1906 .check_polarity = e1000_check_polarity_m88,
1907 .check_reset_block = e1000e_check_reset_block_generic,
1908 .commit = e1000e_phy_sw_reset,
1909 .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
1910 .get_cfg_done = e1000e_get_cfg_done,
1911 .get_cable_length = e1000e_get_cable_length_m88,
1912 .get_info = e1000e_get_phy_info_m88,
1913 .read_reg = e1000e_read_phy_reg_bm2,
1914 .release = e1000_put_hw_semaphore_82571,
1915 .reset = e1000e_phy_hw_reset_generic,
1916 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1917 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1918 .write_reg = e1000e_write_phy_reg_bm2,
1919 .cfg_on_link_up = NULL,
1922 static struct e1000_nvm_operations e82571_nvm_ops = {
1923 .acquire = e1000_acquire_nvm_82571,
1924 .read = e1000e_read_nvm_eerd,
1925 .release = e1000_release_nvm_82571,
1926 .update = e1000_update_nvm_checksum_82571,
1927 .valid_led_default = e1000_valid_led_default_82571,
1928 .validate = e1000_validate_nvm_checksum_82571,
1929 .write = e1000_write_nvm_82571,
1932 struct e1000_info e1000_82571_info = {
1934 .flags = FLAG_HAS_HW_VLAN_FILTER
1935 | FLAG_HAS_JUMBO_FRAMES
1937 | FLAG_APME_IN_CTRL3
1938 | FLAG_RX_CSUM_ENABLED
1939 | FLAG_HAS_CTRLEXT_ON_LOAD
1940 | FLAG_HAS_SMART_POWER_DOWN
1941 | FLAG_RESET_OVERWRITES_LAA /* errata */
1942 | FLAG_TARC_SPEED_MODE_BIT /* errata */
1943 | FLAG_APME_CHECK_PORT_B,
1944 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
1947 .max_hw_frame_size = DEFAULT_JUMBO,
1948 .get_variants = e1000_get_variants_82571,
1949 .mac_ops = &e82571_mac_ops,
1950 .phy_ops = &e82_phy_ops_igp,
1951 .nvm_ops = &e82571_nvm_ops,
1954 struct e1000_info e1000_82572_info = {
1956 .flags = FLAG_HAS_HW_VLAN_FILTER
1957 | FLAG_HAS_JUMBO_FRAMES
1959 | FLAG_APME_IN_CTRL3
1960 | FLAG_RX_CSUM_ENABLED
1961 | FLAG_HAS_CTRLEXT_ON_LOAD
1962 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
1963 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
1966 .max_hw_frame_size = DEFAULT_JUMBO,
1967 .get_variants = e1000_get_variants_82571,
1968 .mac_ops = &e82571_mac_ops,
1969 .phy_ops = &e82_phy_ops_igp,
1970 .nvm_ops = &e82571_nvm_ops,
1973 struct e1000_info e1000_82573_info = {
1975 .flags = FLAG_HAS_HW_VLAN_FILTER
1977 | FLAG_APME_IN_CTRL3
1978 | FLAG_RX_CSUM_ENABLED
1979 | FLAG_HAS_SMART_POWER_DOWN
1981 | FLAG_HAS_SWSM_ON_LOAD,
1982 .flags2 = FLAG2_DISABLE_ASPM_L1,
1984 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
1985 .get_variants = e1000_get_variants_82571,
1986 .mac_ops = &e82571_mac_ops,
1987 .phy_ops = &e82_phy_ops_m88,
1988 .nvm_ops = &e82571_nvm_ops,
1991 struct e1000_info e1000_82574_info = {
1993 .flags = FLAG_HAS_HW_VLAN_FILTER
1995 | FLAG_HAS_JUMBO_FRAMES
1997 | FLAG_APME_IN_CTRL3
1998 | FLAG_RX_CSUM_ENABLED
1999 | FLAG_HAS_SMART_POWER_DOWN
2001 | FLAG_HAS_CTRLEXT_ON_LOAD,
2002 .flags2 = FLAG2_CHECK_PHY_HANG,
2004 .max_hw_frame_size = DEFAULT_JUMBO,
2005 .get_variants = e1000_get_variants_82571,
2006 .mac_ops = &e82571_mac_ops,
2007 .phy_ops = &e82_phy_ops_bm,
2008 .nvm_ops = &e82571_nvm_ops,
2011 struct e1000_info e1000_82583_info = {
2013 .flags = FLAG_HAS_HW_VLAN_FILTER
2015 | FLAG_APME_IN_CTRL3
2016 | FLAG_RX_CSUM_ENABLED
2017 | FLAG_HAS_SMART_POWER_DOWN
2019 | FLAG_HAS_CTRLEXT_ON_LOAD,
2021 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
2022 .get_variants = e1000_get_variants_82571,
2023 .mac_ops = &e82571_mac_ops,
2024 .phy_ops = &e82_phy_ops_bm,
2025 .nvm_ops = &e82571_nvm_ops,