fp@2585: /******************************************************************************* fp@2585: fp@2585: Intel PRO/1000 Linux driver fp@2585: Copyright(c) 1999 - 2013 Intel Corporation. fp@2585: fp@2585: This program is free software; you can redistribute it and/or modify it fp@2585: under the terms and conditions of the GNU General Public License, fp@2585: version 2, as published by the Free Software Foundation. fp@2585: fp@2585: This program is distributed in the hope it will be useful, but WITHOUT fp@2585: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or fp@2585: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for fp@2585: more details. fp@2585: fp@2585: You should have received a copy of the GNU General Public License along with fp@2585: this program; if not, write to the Free Software Foundation, Inc., fp@2585: 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. fp@2585: fp@2585: The full GNU General Public License is included in this distribution in fp@2585: the file called "COPYING". fp@2585: fp@2585: Contact Information: fp@2585: Linux NICS fp@2585: e1000-devel Mailing List fp@2585: Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 fp@2585: fp@2585: *******************************************************************************/ fp@2585: fp@2585: /* 82571EB Gigabit Ethernet Controller fp@2585: * 82571EB Gigabit Ethernet Controller (Copper) fp@2585: * 82571EB Gigabit Ethernet Controller (Fiber) fp@2585: * 82571EB Dual Port Gigabit Mezzanine Adapter fp@2585: * 82571EB Quad Port Gigabit Mezzanine Adapter fp@2585: * 82571PT Gigabit PT Quad Port Server ExpressModule fp@2585: * 82572EI Gigabit Ethernet Controller (Copper) fp@2585: * 82572EI Gigabit Ethernet Controller (Fiber) fp@2585: * 82572EI Gigabit Ethernet Controller fp@2585: * 82573V Gigabit Ethernet Controller (Copper) fp@2585: * 82573E Gigabit Ethernet Controller (Copper) fp@2585: * 82573L Gigabit Ethernet Controller fp@2585: * 82574L Gigabit Network Connection fp@2585: * 82583V Gigabit Network Connection fp@2585: */ fp@2585: fp@2585: #include "e1000-3.10-ethercat.h" fp@2585: fp@2585: static s32 e1000_get_phy_id_82571(struct e1000_hw *hw); fp@2585: static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw); fp@2585: static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw); fp@2585: static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw); fp@2585: static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, fp@2585: u16 words, u16 *data); fp@2585: static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw); fp@2585: static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw); fp@2585: static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw); fp@2585: static bool e1000_check_mng_mode_82574(struct e1000_hw *hw); fp@2585: static s32 e1000_led_on_82574(struct e1000_hw *hw); fp@2585: static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); fp@2585: static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw); fp@2585: static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw); fp@2585: static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw); fp@2585: static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw); fp@2585: static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active); fp@2585: static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active); fp@2585: fp@2585: /** fp@2585: * e1000_init_phy_params_82571 - Init PHY func ptrs. fp@2585: * @hw: pointer to the HW structure fp@2585: **/ fp@2585: static s32 e1000_init_phy_params_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_phy_info *phy = &hw->phy; fp@2585: s32 ret_val __attribute__ ((unused)); fp@2585: fp@2585: if (hw->phy.media_type != e1000_media_type_copper) { fp@2585: phy->type = e1000_phy_none; fp@2585: return 0; fp@2585: } fp@2585: fp@2585: phy->addr = 1; fp@2585: phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; fp@2585: phy->reset_delay_us = 100; fp@2585: fp@2585: phy->ops.power_up = e1000_power_up_phy_copper; fp@2585: phy->ops.power_down = e1000_power_down_phy_copper_82571; fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: phy->type = e1000_phy_igp_2; fp@2585: break; fp@2585: case e1000_82573: fp@2585: phy->type = e1000_phy_m88; fp@2585: break; fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: phy->type = e1000_phy_bm; fp@2585: phy->ops.acquire = e1000_get_hw_semaphore_82574; fp@2585: phy->ops.release = e1000_put_hw_semaphore_82574; fp@2585: phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82574; fp@2585: phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82574; fp@2585: break; fp@2585: default: fp@2585: return -E1000_ERR_PHY; fp@2585: break; fp@2585: } fp@2585: fp@2585: /* This can only be done after all function pointers are setup. */ fp@2585: ret_val = e1000_get_phy_id_82571(hw); fp@2585: if (ret_val) { fp@2585: e_dbg("Error getting PHY ID\n"); fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /* Verify phy id */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: if (phy->id != IGP01E1000_I_PHY_ID) fp@2585: ret_val = -E1000_ERR_PHY; fp@2585: break; fp@2585: case e1000_82573: fp@2585: if (phy->id != M88E1111_I_PHY_ID) fp@2585: ret_val = -E1000_ERR_PHY; fp@2585: break; fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: if (phy->id != BME1000_E_PHY_ID_R2) fp@2585: ret_val = -E1000_ERR_PHY; fp@2585: break; fp@2585: default: fp@2585: ret_val = -E1000_ERR_PHY; fp@2585: break; fp@2585: } fp@2585: fp@2585: if (ret_val) fp@2585: e_dbg("PHY ID unknown: type = 0x%08x\n", phy->id); fp@2585: fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_init_nvm_params_82571 - Init NVM func ptrs. fp@2585: * @hw: pointer to the HW structure fp@2585: **/ fp@2585: static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_nvm_info *nvm = &hw->nvm; fp@2585: u32 eecd = er32(EECD); fp@2585: u16 size; fp@2585: fp@2585: nvm->opcode_bits = 8; fp@2585: nvm->delay_usec = 1; fp@2585: switch (nvm->override) { fp@2585: case e1000_nvm_override_spi_large: fp@2585: nvm->page_size = 32; fp@2585: nvm->address_bits = 16; fp@2585: break; fp@2585: case e1000_nvm_override_spi_small: fp@2585: nvm->page_size = 8; fp@2585: nvm->address_bits = 8; fp@2585: break; fp@2585: default: fp@2585: nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; fp@2585: nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; fp@2585: break; fp@2585: } fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: if (((eecd >> 15) & 0x3) == 0x3) { fp@2585: nvm->type = e1000_nvm_flash_hw; fp@2585: nvm->word_size = 2048; fp@2585: /* Autonomous Flash update bit must be cleared due fp@2585: * to Flash update issue. fp@2585: */ fp@2585: eecd &= ~E1000_EECD_AUPDEN; fp@2585: ew32(EECD, eecd); fp@2585: break; fp@2585: } fp@2585: /* Fall Through */ fp@2585: default: fp@2585: nvm->type = e1000_nvm_eeprom_spi; fp@2585: size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> fp@2585: E1000_EECD_SIZE_EX_SHIFT); fp@2585: /* Added to a constant, "size" becomes the left-shift value fp@2585: * for setting word_size. fp@2585: */ fp@2585: size += NVM_WORD_SIZE_BASE_SHIFT; fp@2585: fp@2585: /* EEPROM access above 16k is unsupported */ fp@2585: if (size > 14) fp@2585: size = 14; fp@2585: nvm->word_size = 1 << size; fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Function Pointers */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: nvm->ops.acquire = e1000_get_hw_semaphore_82574; fp@2585: nvm->ops.release = e1000_put_hw_semaphore_82574; fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_init_mac_params_82571 - Init MAC func ptrs. fp@2585: * @hw: pointer to the HW structure fp@2585: **/ fp@2585: static s32 e1000_init_mac_params_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_mac_info *mac = &hw->mac; fp@2585: u32 swsm = 0; fp@2585: u32 swsm2 = 0; fp@2585: bool force_clear_smbi = false; fp@2585: fp@2585: /* Set media type and media-dependent function pointers */ fp@2585: switch (hw->adapter->pdev->device) { fp@2585: case E1000_DEV_ID_82571EB_FIBER: fp@2585: case E1000_DEV_ID_82572EI_FIBER: fp@2585: case E1000_DEV_ID_82571EB_QUAD_FIBER: fp@2585: hw->phy.media_type = e1000_media_type_fiber; fp@2585: mac->ops.setup_physical_interface = fp@2585: e1000_setup_fiber_serdes_link_82571; fp@2585: mac->ops.check_for_link = e1000e_check_for_fiber_link; fp@2585: mac->ops.get_link_up_info = fp@2585: e1000e_get_speed_and_duplex_fiber_serdes; fp@2585: break; fp@2585: case E1000_DEV_ID_82571EB_SERDES: fp@2585: case E1000_DEV_ID_82571EB_SERDES_DUAL: fp@2585: case E1000_DEV_ID_82571EB_SERDES_QUAD: fp@2585: case E1000_DEV_ID_82572EI_SERDES: fp@2585: hw->phy.media_type = e1000_media_type_internal_serdes; fp@2585: mac->ops.setup_physical_interface = fp@2585: e1000_setup_fiber_serdes_link_82571; fp@2585: mac->ops.check_for_link = e1000_check_for_serdes_link_82571; fp@2585: mac->ops.get_link_up_info = fp@2585: e1000e_get_speed_and_duplex_fiber_serdes; fp@2585: break; fp@2585: default: fp@2585: hw->phy.media_type = e1000_media_type_copper; fp@2585: mac->ops.setup_physical_interface = fp@2585: e1000_setup_copper_link_82571; fp@2585: mac->ops.check_for_link = e1000e_check_for_copper_link; fp@2585: mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_copper; fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Set mta register count */ fp@2585: mac->mta_reg_count = 128; fp@2585: /* Set rar entry count */ fp@2585: mac->rar_entry_count = E1000_RAR_ENTRIES; fp@2585: /* Adaptive IFS supported */ fp@2585: mac->adaptive_ifs = true; fp@2585: fp@2585: /* MAC-specific function pointers */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: mac->ops.set_lan_id = e1000_set_lan_id_single_port; fp@2585: mac->ops.check_mng_mode = e1000e_check_mng_mode_generic; fp@2585: mac->ops.led_on = e1000e_led_on_generic; fp@2585: mac->ops.blink_led = e1000e_blink_led_generic; fp@2585: fp@2585: /* FWSM register */ fp@2585: mac->has_fwsm = true; fp@2585: /* ARC supported; valid only if manageability features are fp@2585: * enabled. fp@2585: */ fp@2585: mac->arc_subsystem_valid = !!(er32(FWSM) & fp@2585: E1000_FWSM_MODE_MASK); fp@2585: break; fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: mac->ops.set_lan_id = e1000_set_lan_id_single_port; fp@2585: mac->ops.check_mng_mode = e1000_check_mng_mode_82574; fp@2585: mac->ops.led_on = e1000_led_on_82574; fp@2585: break; fp@2585: default: fp@2585: mac->ops.check_mng_mode = e1000e_check_mng_mode_generic; fp@2585: mac->ops.led_on = e1000e_led_on_generic; fp@2585: mac->ops.blink_led = e1000e_blink_led_generic; fp@2585: fp@2585: /* FWSM register */ fp@2585: mac->has_fwsm = true; fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Ensure that the inter-port SWSM.SMBI lock bit is clear before fp@2585: * first NVM or PHY access. This should be done for single-port fp@2585: * devices, and for one port only on dual-port devices so that fp@2585: * for those devices we can still use the SMBI lock to synchronize fp@2585: * inter-port accesses to the PHY & NVM. fp@2585: */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: swsm2 = er32(SWSM2); fp@2585: fp@2585: if (!(swsm2 & E1000_SWSM2_LOCK)) { fp@2585: /* Only do this for the first interface on this card */ fp@2585: ew32(SWSM2, swsm2 | E1000_SWSM2_LOCK); fp@2585: force_clear_smbi = true; fp@2585: } else { fp@2585: force_clear_smbi = false; fp@2585: } fp@2585: break; fp@2585: default: fp@2585: force_clear_smbi = true; fp@2585: break; fp@2585: } fp@2585: fp@2585: if (force_clear_smbi) { fp@2585: /* Make sure SWSM.SMBI is clear */ fp@2585: swsm = er32(SWSM); fp@2585: if (swsm & E1000_SWSM_SMBI) { fp@2585: /* This bit should not be set on a first interface, and fp@2585: * indicates that the bootagent or EFI code has fp@2585: * improperly left this bit enabled fp@2585: */ fp@2585: e_dbg("Please update your 82571 Bootagent\n"); fp@2585: } fp@2585: ew32(SWSM, swsm & ~E1000_SWSM_SMBI); fp@2585: } fp@2585: fp@2585: /* Initialize device specific counter of SMBI acquisition timeouts. */ fp@2585: hw->dev_spec.e82571.smb_counter = 0; fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) fp@2585: { fp@2585: struct e1000_hw *hw = &adapter->hw; fp@2585: static int global_quad_port_a; /* global port a indication */ fp@2585: struct pci_dev *pdev = adapter->pdev; fp@2585: int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; fp@2585: s32 rc; fp@2585: fp@2585: rc = e1000_init_mac_params_82571(hw); fp@2585: if (rc) fp@2585: return rc; fp@2585: fp@2585: rc = e1000_init_nvm_params_82571(hw); fp@2585: if (rc) fp@2585: return rc; fp@2585: fp@2585: rc = e1000_init_phy_params_82571(hw); fp@2585: if (rc) fp@2585: return rc; fp@2585: fp@2585: /* tag quad port adapters first, it's used below */ fp@2585: switch (pdev->device) { fp@2585: case E1000_DEV_ID_82571EB_QUAD_COPPER: fp@2585: case E1000_DEV_ID_82571EB_QUAD_FIBER: fp@2585: case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: fp@2585: case E1000_DEV_ID_82571PT_QUAD_COPPER: fp@2585: adapter->flags |= FLAG_IS_QUAD_PORT; fp@2585: /* mark the first port */ fp@2585: if (global_quad_port_a == 0) fp@2585: adapter->flags |= FLAG_IS_QUAD_PORT_A; fp@2585: /* Reset for multiple quad port adapters */ fp@2585: global_quad_port_a++; fp@2585: if (global_quad_port_a == 4) fp@2585: global_quad_port_a = 0; fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: switch (adapter->hw.mac.type) { fp@2585: case e1000_82571: fp@2585: /* these dual ports don't have WoL on port B at all */ fp@2585: if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) || fp@2585: (pdev->device == E1000_DEV_ID_82571EB_SERDES) || fp@2585: (pdev->device == E1000_DEV_ID_82571EB_COPPER)) && fp@2585: (is_port_b)) fp@2585: adapter->flags &= ~FLAG_HAS_WOL; fp@2585: /* quad ports only support WoL on port A */ fp@2585: if (adapter->flags & FLAG_IS_QUAD_PORT && fp@2585: (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) fp@2585: adapter->flags &= ~FLAG_HAS_WOL; fp@2585: /* Does not support WoL on any port */ fp@2585: if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) fp@2585: adapter->flags &= ~FLAG_HAS_WOL; fp@2585: break; fp@2585: case e1000_82573: fp@2585: if (pdev->device == E1000_DEV_ID_82573L) { fp@2585: adapter->flags |= FLAG_HAS_JUMBO_FRAMES; fp@2585: adapter->max_hw_frame_size = DEFAULT_JUMBO; fp@2585: } fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Reads the PHY registers and stores the PHY ID and possibly the PHY fp@2585: * revision in the hardware structure. fp@2585: **/ fp@2585: static s32 e1000_get_phy_id_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_phy_info *phy = &hw->phy; fp@2585: s32 ret_val; fp@2585: u16 phy_id = 0; fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: /* The 82571 firmware may still be configuring the PHY. fp@2585: * In this case, we cannot access the PHY until the fp@2585: * configuration is done. So we explicitly set the fp@2585: * PHY ID. fp@2585: */ fp@2585: phy->id = IGP01E1000_I_PHY_ID; fp@2585: break; fp@2585: case e1000_82573: fp@2585: return e1000e_get_phy_id(hw); fp@2585: break; fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: ret_val = e1e_rphy(hw, MII_PHYSID1, &phy_id); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: phy->id = (u32)(phy_id << 16); fp@2585: usleep_range(20, 40); fp@2585: ret_val = e1e_rphy(hw, MII_PHYSID2, &phy_id); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: phy->id |= (u32)(phy_id); fp@2585: phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); fp@2585: break; fp@2585: default: fp@2585: return -E1000_ERR_PHY; fp@2585: break; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Acquire the HW semaphore to access the PHY or NVM fp@2585: **/ fp@2585: static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 swsm; fp@2585: s32 sw_timeout = hw->nvm.word_size + 1; fp@2585: s32 fw_timeout = hw->nvm.word_size + 1; fp@2585: s32 i = 0; fp@2585: fp@2585: /* If we have timedout 3 times on trying to acquire fp@2585: * the inter-port SMBI semaphore, there is old code fp@2585: * operating on the other port, and it is not fp@2585: * releasing SMBI. Modify the number of times that fp@2585: * we try for the semaphore to interwork with this fp@2585: * older code. fp@2585: */ fp@2585: if (hw->dev_spec.e82571.smb_counter > 2) fp@2585: sw_timeout = 1; fp@2585: fp@2585: /* Get the SW semaphore */ fp@2585: while (i < sw_timeout) { fp@2585: swsm = er32(SWSM); fp@2585: if (!(swsm & E1000_SWSM_SMBI)) fp@2585: break; fp@2585: fp@2585: usleep_range(50, 100); fp@2585: i++; fp@2585: } fp@2585: fp@2585: if (i == sw_timeout) { fp@2585: e_dbg("Driver can't access device - SMBI bit is set.\n"); fp@2585: hw->dev_spec.e82571.smb_counter++; fp@2585: } fp@2585: /* Get the FW semaphore. */ fp@2585: for (i = 0; i < fw_timeout; i++) { fp@2585: swsm = er32(SWSM); fp@2585: ew32(SWSM, swsm | E1000_SWSM_SWESMBI); fp@2585: fp@2585: /* Semaphore acquired if bit latched */ fp@2585: if (er32(SWSM) & E1000_SWSM_SWESMBI) fp@2585: break; fp@2585: fp@2585: usleep_range(50, 100); fp@2585: } fp@2585: fp@2585: if (i == fw_timeout) { fp@2585: /* Release semaphores */ fp@2585: e1000_put_hw_semaphore_82571(hw); fp@2585: e_dbg("Driver can't access the NVM\n"); fp@2585: return -E1000_ERR_NVM; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_put_hw_semaphore_82571 - Release hardware semaphore fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Release hardware semaphore used to access the PHY or NVM fp@2585: **/ fp@2585: static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 swsm; fp@2585: fp@2585: swsm = er32(SWSM); fp@2585: swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI); fp@2585: ew32(SWSM, swsm); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Acquire the HW semaphore during reset. fp@2585: * fp@2585: **/ fp@2585: static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) fp@2585: { fp@2585: u32 extcnf_ctrl; fp@2585: s32 i = 0; fp@2585: fp@2585: extcnf_ctrl = er32(EXTCNF_CTRL); fp@2585: do { fp@2585: extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; fp@2585: ew32(EXTCNF_CTRL, extcnf_ctrl); fp@2585: extcnf_ctrl = er32(EXTCNF_CTRL); fp@2585: fp@2585: if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP) fp@2585: break; fp@2585: fp@2585: usleep_range(2000, 4000); fp@2585: i++; fp@2585: } while (i < MDIO_OWNERSHIP_TIMEOUT); fp@2585: fp@2585: if (i == MDIO_OWNERSHIP_TIMEOUT) { fp@2585: /* Release semaphores */ fp@2585: e1000_put_hw_semaphore_82573(hw); fp@2585: e_dbg("Driver can't access the PHY\n"); fp@2585: return -E1000_ERR_PHY; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_put_hw_semaphore_82573 - Release hardware semaphore fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Release hardware semaphore used during reset. fp@2585: * fp@2585: **/ fp@2585: static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw) fp@2585: { fp@2585: u32 extcnf_ctrl; fp@2585: fp@2585: extcnf_ctrl = er32(EXTCNF_CTRL); fp@2585: extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; fp@2585: ew32(EXTCNF_CTRL, extcnf_ctrl); fp@2585: } fp@2585: fp@2585: static DEFINE_MUTEX(swflag_mutex); fp@2585: fp@2585: /** fp@2585: * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Acquire the HW semaphore to access the PHY or NVM. fp@2585: * fp@2585: **/ fp@2585: static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw) fp@2585: { fp@2585: s32 ret_val; fp@2585: fp@2585: mutex_lock(&swflag_mutex); fp@2585: ret_val = e1000_get_hw_semaphore_82573(hw); fp@2585: if (ret_val) fp@2585: mutex_unlock(&swflag_mutex); fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_put_hw_semaphore_82574 - Release hardware semaphore fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Release hardware semaphore used to access the PHY or NVM fp@2585: * fp@2585: **/ fp@2585: static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw) fp@2585: { fp@2585: e1000_put_hw_semaphore_82573(hw); fp@2585: mutex_unlock(&swflag_mutex); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_set_d0_lplu_state_82574 - Set Low Power Linkup D0 state fp@2585: * @hw: pointer to the HW structure fp@2585: * @active: true to enable LPLU, false to disable fp@2585: * fp@2585: * Sets the LPLU D0 state according to the active flag. fp@2585: * LPLU will not be activated unless the fp@2585: * device autonegotiation advertisement meets standards of fp@2585: * either 10 or 10/100 or 10/100/1000 at all duplexes. fp@2585: * This is a function pointer entry point only called by fp@2585: * PHY setup routines. fp@2585: **/ fp@2585: static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active) fp@2585: { fp@2585: u32 data = er32(POEMB); fp@2585: fp@2585: if (active) fp@2585: data |= E1000_PHY_CTRL_D0A_LPLU; fp@2585: else fp@2585: data &= ~E1000_PHY_CTRL_D0A_LPLU; fp@2585: fp@2585: ew32(POEMB, data); fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_set_d3_lplu_state_82574 - Sets low power link up state for D3 fp@2585: * @hw: pointer to the HW structure fp@2585: * @active: boolean used to enable/disable lplu fp@2585: * fp@2585: * The low power link up (lplu) state is set to the power management level D3 fp@2585: * when active is true, else clear lplu for D3. LPLU fp@2585: * is used during Dx states where the power conservation is most important. fp@2585: * During driver activity, SmartSpeed should be enabled so performance is fp@2585: * maintained. fp@2585: **/ fp@2585: static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active) fp@2585: { fp@2585: u32 data = er32(POEMB); fp@2585: fp@2585: if (!active) { fp@2585: data &= ~E1000_PHY_CTRL_NOND0A_LPLU; fp@2585: } else if ((hw->phy.autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || fp@2585: (hw->phy.autoneg_advertised == E1000_ALL_NOT_GIG) || fp@2585: (hw->phy.autoneg_advertised == E1000_ALL_10_SPEED)) { fp@2585: data |= E1000_PHY_CTRL_NOND0A_LPLU; fp@2585: } fp@2585: fp@2585: ew32(POEMB, data); fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_acquire_nvm_82571 - Request for access to the EEPROM fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * To gain access to the EEPROM, first we must obtain a hardware semaphore. fp@2585: * Then for non-82573 hardware, set the EEPROM access request bit and wait fp@2585: * for EEPROM access grant bit. If the access grant bit is not set, release fp@2585: * hardware semaphore. fp@2585: **/ fp@2585: static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw) fp@2585: { fp@2585: s32 ret_val; fp@2585: fp@2585: ret_val = e1000_get_hw_semaphore_82571(hw); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: break; fp@2585: default: fp@2585: ret_val = e1000e_acquire_nvm(hw); fp@2585: break; fp@2585: } fp@2585: fp@2585: if (ret_val) fp@2585: e1000_put_hw_semaphore_82571(hw); fp@2585: fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_release_nvm_82571 - Release exclusive access to EEPROM fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Stop any current commands to the EEPROM and clear the EEPROM request bit. fp@2585: **/ fp@2585: static void e1000_release_nvm_82571(struct e1000_hw *hw) fp@2585: { fp@2585: e1000e_release_nvm(hw); fp@2585: e1000_put_hw_semaphore_82571(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface fp@2585: * @hw: pointer to the HW structure fp@2585: * @offset: offset within the EEPROM to be written to fp@2585: * @words: number of words to write fp@2585: * @data: 16 bit word(s) to be written to the EEPROM fp@2585: * fp@2585: * For non-82573 silicon, write data to EEPROM at offset using SPI interface. fp@2585: * fp@2585: * If e1000e_update_nvm_checksum is not called after this function, the fp@2585: * EEPROM will most likely contain an invalid checksum. fp@2585: **/ fp@2585: static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, fp@2585: u16 *data) fp@2585: { fp@2585: s32 ret_val; fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data); fp@2585: break; fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: ret_val = e1000e_write_nvm_spi(hw, offset, words, data); fp@2585: break; fp@2585: default: fp@2585: ret_val = -E1000_ERR_NVM; fp@2585: break; fp@2585: } fp@2585: fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_update_nvm_checksum_82571 - Update EEPROM checksum fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Updates the EEPROM checksum by reading/adding each word of the EEPROM fp@2585: * up to the checksum. Then calculates the EEPROM checksum and writes the fp@2585: * value to the EEPROM. fp@2585: **/ fp@2585: static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 eecd; fp@2585: s32 ret_val; fp@2585: u16 i; fp@2585: fp@2585: ret_val = e1000e_update_nvm_checksum_generic(hw); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: /* If our nvm is an EEPROM, then we're done fp@2585: * otherwise, commit the checksum to the flash NVM. fp@2585: */ fp@2585: if (hw->nvm.type != e1000_nvm_flash_hw) fp@2585: return 0; fp@2585: fp@2585: /* Check for pending operations. */ fp@2585: for (i = 0; i < E1000_FLASH_UPDATES; i++) { fp@2585: usleep_range(1000, 2000); fp@2585: if (!(er32(EECD) & E1000_EECD_FLUPD)) fp@2585: break; fp@2585: } fp@2585: fp@2585: if (i == E1000_FLASH_UPDATES) fp@2585: return -E1000_ERR_NVM; fp@2585: fp@2585: /* Reset the firmware if using STM opcode. */ fp@2585: if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) { fp@2585: /* The enabling of and the actual reset must be done fp@2585: * in two write cycles. fp@2585: */ fp@2585: ew32(HICR, E1000_HICR_FW_RESET_ENABLE); fp@2585: e1e_flush(); fp@2585: ew32(HICR, E1000_HICR_FW_RESET); fp@2585: } fp@2585: fp@2585: /* Commit the write to flash */ fp@2585: eecd = er32(EECD) | E1000_EECD_FLUPD; fp@2585: ew32(EECD, eecd); fp@2585: fp@2585: for (i = 0; i < E1000_FLASH_UPDATES; i++) { fp@2585: usleep_range(1000, 2000); fp@2585: if (!(er32(EECD) & E1000_EECD_FLUPD)) fp@2585: break; fp@2585: } fp@2585: fp@2585: if (i == E1000_FLASH_UPDATES) fp@2585: return -E1000_ERR_NVM; fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Calculates the EEPROM checksum by reading/adding each word of the EEPROM fp@2585: * and then verifies that the sum of the EEPROM is equal to 0xBABA. fp@2585: **/ fp@2585: static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw) fp@2585: { fp@2585: if (hw->nvm.type == e1000_nvm_flash_hw) fp@2585: e1000_fix_nvm_checksum_82571(hw); fp@2585: fp@2585: return e1000e_validate_nvm_checksum_generic(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon fp@2585: * @hw: pointer to the HW structure fp@2585: * @offset: offset within the EEPROM to be written to fp@2585: * @words: number of words to write fp@2585: * @data: 16 bit word(s) to be written to the EEPROM fp@2585: * fp@2585: * After checking for invalid values, poll the EEPROM to ensure the previous fp@2585: * command has completed before trying to write the next word. After write fp@2585: * poll for completion. fp@2585: * fp@2585: * If e1000e_update_nvm_checksum is not called after this function, the fp@2585: * EEPROM will most likely contain an invalid checksum. fp@2585: **/ fp@2585: static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, fp@2585: u16 words, u16 *data) fp@2585: { fp@2585: struct e1000_nvm_info *nvm = &hw->nvm; fp@2585: u32 i, eewr = 0; fp@2585: s32 ret_val = 0; fp@2585: fp@2585: /* A check for invalid values: offset too large, too many words, fp@2585: * and not enough words. fp@2585: */ fp@2585: if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || fp@2585: (words == 0)) { fp@2585: e_dbg("nvm parameter(s) out of bounds\n"); fp@2585: return -E1000_ERR_NVM; fp@2585: } fp@2585: fp@2585: for (i = 0; i < words; i++) { fp@2585: eewr = ((data[i] << E1000_NVM_RW_REG_DATA) | fp@2585: ((offset + i) << E1000_NVM_RW_ADDR_SHIFT) | fp@2585: E1000_NVM_RW_REG_START); fp@2585: fp@2585: ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); fp@2585: if (ret_val) fp@2585: break; fp@2585: fp@2585: ew32(EEWR, eewr); fp@2585: fp@2585: ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); fp@2585: if (ret_val) fp@2585: break; fp@2585: } fp@2585: fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_get_cfg_done_82571 - Poll for configuration done fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Reads the management control register for the config done bit to be set. fp@2585: **/ fp@2585: static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw) fp@2585: { fp@2585: s32 timeout = PHY_CFG_TIMEOUT; fp@2585: fp@2585: while (timeout) { fp@2585: if (er32(EEMNGCTL) & E1000_NVM_CFG_DONE_PORT_0) fp@2585: break; fp@2585: usleep_range(1000, 2000); fp@2585: timeout--; fp@2585: } fp@2585: if (!timeout) { fp@2585: e_dbg("MNG configuration cycle has not completed.\n"); fp@2585: return -E1000_ERR_RESET; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state fp@2585: * @hw: pointer to the HW structure fp@2585: * @active: true to enable LPLU, false to disable fp@2585: * fp@2585: * Sets the LPLU D0 state according to the active flag. When activating LPLU fp@2585: * this function also disables smart speed and vice versa. LPLU will not be fp@2585: * activated unless the device autonegotiation advertisement meets standards fp@2585: * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function fp@2585: * pointer entry point only called by PHY setup routines. fp@2585: **/ fp@2585: static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active) fp@2585: { fp@2585: struct e1000_phy_info *phy = &hw->phy; fp@2585: s32 ret_val; fp@2585: u16 data; fp@2585: fp@2585: ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: if (active) { fp@2585: data |= IGP02E1000_PM_D0_LPLU; fp@2585: ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: /* When LPLU is enabled, we should disable SmartSpeed */ fp@2585: ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: data &= ~IGP01E1000_PSCFR_SMART_SPEED; fp@2585: ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: } else { fp@2585: data &= ~IGP02E1000_PM_D0_LPLU; fp@2585: ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); fp@2585: /* LPLU and SmartSpeed are mutually exclusive. LPLU is used fp@2585: * during Dx states where the power conservation is most fp@2585: * important. During driver activity we should enable fp@2585: * SmartSpeed, so performance is maintained. fp@2585: */ fp@2585: if (phy->smart_speed == e1000_smart_speed_on) { fp@2585: ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, fp@2585: &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: data |= IGP01E1000_PSCFR_SMART_SPEED; fp@2585: ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, fp@2585: data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: } else if (phy->smart_speed == e1000_smart_speed_off) { fp@2585: ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, fp@2585: &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: data &= ~IGP01E1000_PSCFR_SMART_SPEED; fp@2585: ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, fp@2585: data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: } fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_reset_hw_82571 - Reset hardware fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * This resets the hardware into a known state. fp@2585: **/ fp@2585: static s32 e1000_reset_hw_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 ctrl, ctrl_ext, eecd, tctl; fp@2585: s32 ret_val; fp@2585: fp@2585: /* Prevent the PCI-E bus from sticking if there is no TLP connection fp@2585: * on the last TLP read/write transaction when MAC is reset. fp@2585: */ fp@2585: ret_val = e1000e_disable_pcie_master(hw); fp@2585: if (ret_val) fp@2585: e_dbg("PCI-E Master disable polling has failed.\n"); fp@2585: fp@2585: e_dbg("Masking off all interrupts\n"); fp@2585: ew32(IMC, 0xffffffff); fp@2585: fp@2585: ew32(RCTL, 0); fp@2585: tctl = er32(TCTL); fp@2585: tctl &= ~E1000_TCTL_EN; fp@2585: ew32(TCTL, tctl); fp@2585: e1e_flush(); fp@2585: fp@2585: usleep_range(10000, 20000); fp@2585: fp@2585: /* Must acquire the MDIO ownership before MAC reset. fp@2585: * Ownership defaults to firmware after a reset. fp@2585: */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: ret_val = e1000_get_hw_semaphore_82573(hw); fp@2585: break; fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: ret_val = e1000_get_hw_semaphore_82574(hw); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: if (ret_val) fp@2585: e_dbg("Cannot acquire MDIO ownership\n"); fp@2585: fp@2585: ctrl = er32(CTRL); fp@2585: fp@2585: e_dbg("Issuing a global reset to MAC\n"); fp@2585: ew32(CTRL, ctrl | E1000_CTRL_RST); fp@2585: fp@2585: /* Must release MDIO ownership and mutex after MAC reset. */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: e1000_put_hw_semaphore_82574(hw); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: if (hw->nvm.type == e1000_nvm_flash_hw) { fp@2585: usleep_range(10, 20); fp@2585: ctrl_ext = er32(CTRL_EXT); fp@2585: ctrl_ext |= E1000_CTRL_EXT_EE_RST; fp@2585: ew32(CTRL_EXT, ctrl_ext); fp@2585: e1e_flush(); fp@2585: } fp@2585: fp@2585: ret_val = e1000e_get_auto_rd_done(hw); fp@2585: if (ret_val) fp@2585: /* We don't want to continue accessing MAC registers. */ fp@2585: return ret_val; fp@2585: fp@2585: /* Phy configuration from NVM just starts after EECD_AUTO_RD is set. fp@2585: * Need to wait for Phy configuration completion before accessing fp@2585: * NVM and Phy. fp@2585: */ fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: /* REQ and GNT bits need to be cleared when using AUTO_RD fp@2585: * to access the EEPROM. fp@2585: */ fp@2585: eecd = er32(EECD); fp@2585: eecd &= ~(E1000_EECD_REQ | E1000_EECD_GNT); fp@2585: ew32(EECD, eecd); fp@2585: break; fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: msleep(25); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Clear any pending interrupt events. */ fp@2585: ew32(IMC, 0xffffffff); fp@2585: er32(ICR); fp@2585: fp@2585: if (hw->mac.type == e1000_82571) { fp@2585: /* Install any alternate MAC address into RAR0 */ fp@2585: ret_val = e1000_check_alt_mac_addr_generic(hw); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: e1000e_set_laa_state_82571(hw, true); fp@2585: } fp@2585: fp@2585: /* Reinitialize the 82571 serdes link state machine */ fp@2585: if (hw->phy.media_type == e1000_media_type_internal_serdes) fp@2585: hw->mac.serdes_link_state = e1000_serdes_link_down; fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_init_hw_82571 - Initialize hardware fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * This inits the hardware readying it for operation. fp@2585: **/ fp@2585: static s32 e1000_init_hw_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_mac_info *mac = &hw->mac; fp@2585: u32 reg_data; fp@2585: s32 ret_val; fp@2585: u16 i, rar_count = mac->rar_entry_count; fp@2585: fp@2585: e1000_initialize_hw_bits_82571(hw); fp@2585: fp@2585: /* Initialize identification LED */ fp@2585: ret_val = mac->ops.id_led_init(hw); fp@2585: /* An error is not fatal and we should not stop init due to this */ fp@2585: if (ret_val) fp@2585: e_dbg("Error initializing identification LED\n"); fp@2585: fp@2585: /* Disabling VLAN filtering */ fp@2585: e_dbg("Initializing the IEEE VLAN\n"); fp@2585: mac->ops.clear_vfta(hw); fp@2585: fp@2585: /* Setup the receive address. fp@2585: * If, however, a locally administered address was assigned to the fp@2585: * 82571, we must reserve a RAR for it to work around an issue where fp@2585: * resetting one port will reload the MAC on the other port. fp@2585: */ fp@2585: if (e1000e_get_laa_state_82571(hw)) fp@2585: rar_count--; fp@2585: e1000e_init_rx_addrs(hw, rar_count); fp@2585: fp@2585: /* Zero out the Multicast HASH table */ fp@2585: e_dbg("Zeroing the MTA\n"); fp@2585: for (i = 0; i < mac->mta_reg_count; i++) fp@2585: E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); fp@2585: fp@2585: /* Setup link and flow control */ fp@2585: ret_val = mac->ops.setup_link(hw); fp@2585: fp@2585: /* Set the transmit descriptor write-back policy */ fp@2585: reg_data = er32(TXDCTL(0)); fp@2585: reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) | fp@2585: E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC); fp@2585: ew32(TXDCTL(0), reg_data); fp@2585: fp@2585: /* ...for both queues. */ fp@2585: switch (mac->type) { fp@2585: case e1000_82573: fp@2585: e1000e_enable_tx_pkt_filtering(hw); fp@2585: /* fall through */ fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: reg_data = er32(GCR); fp@2585: reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX; fp@2585: ew32(GCR, reg_data); fp@2585: break; fp@2585: default: fp@2585: reg_data = er32(TXDCTL(1)); fp@2585: reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) | fp@2585: E1000_TXDCTL_FULL_TX_DESC_WB | fp@2585: E1000_TXDCTL_COUNT_DESC); fp@2585: ew32(TXDCTL(1), reg_data); fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Clear all of the statistics registers (clear on read). It is fp@2585: * important that we do this after we have tried to establish link fp@2585: * because the symbol error count will increment wildly if there fp@2585: * is no link. fp@2585: */ fp@2585: e1000_clear_hw_cntrs_82571(hw); fp@2585: fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Initializes required hardware-dependent bits needed for normal operation. fp@2585: **/ fp@2585: static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 reg; fp@2585: fp@2585: /* Transmit Descriptor Control 0 */ fp@2585: reg = er32(TXDCTL(0)); fp@2585: reg |= (1 << 22); fp@2585: ew32(TXDCTL(0), reg); fp@2585: fp@2585: /* Transmit Descriptor Control 1 */ fp@2585: reg = er32(TXDCTL(1)); fp@2585: reg |= (1 << 22); fp@2585: ew32(TXDCTL(1), reg); fp@2585: fp@2585: /* Transmit Arbitration Control 0 */ fp@2585: reg = er32(TARC(0)); fp@2585: reg &= ~(0xF << 27); /* 30:27 */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26); fp@2585: break; fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: reg |= (1 << 26); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: ew32(TARC(0), reg); fp@2585: fp@2585: /* Transmit Arbitration Control 1 */ fp@2585: reg = er32(TARC(1)); fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: reg &= ~((1 << 29) | (1 << 30)); fp@2585: reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26); fp@2585: if (er32(TCTL) & E1000_TCTL_MULR) fp@2585: reg &= ~(1 << 28); fp@2585: else fp@2585: reg |= (1 << 28); fp@2585: ew32(TARC(1), reg); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Device Control */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: reg = er32(CTRL); fp@2585: reg &= ~(1 << 29); fp@2585: ew32(CTRL, reg); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: /* Extended Device Control */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: reg = er32(CTRL_EXT); fp@2585: reg &= ~(1 << 23); fp@2585: reg |= (1 << 22); fp@2585: ew32(CTRL_EXT, reg); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: if (hw->mac.type == e1000_82571) { fp@2585: reg = er32(PBA_ECC); fp@2585: reg |= E1000_PBA_ECC_CORR_EN; fp@2585: ew32(PBA_ECC, reg); fp@2585: } fp@2585: fp@2585: /* Workaround for hardware errata. fp@2585: * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572 fp@2585: */ fp@2585: if ((hw->mac.type == e1000_82571) || (hw->mac.type == e1000_82572)) { fp@2585: reg = er32(CTRL_EXT); fp@2585: reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN; fp@2585: ew32(CTRL_EXT, reg); fp@2585: } fp@2585: fp@2585: /* Disable IPv6 extension header parsing because some malformed fp@2585: * IPv6 headers can hang the Rx. fp@2585: */ fp@2585: if (hw->mac.type <= e1000_82573) { fp@2585: reg = er32(RFCTL); fp@2585: reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS); fp@2585: ew32(RFCTL, reg); fp@2585: } fp@2585: fp@2585: /* PCI-Ex Control Registers */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: reg = er32(GCR); fp@2585: reg |= (1 << 22); fp@2585: ew32(GCR, reg); fp@2585: fp@2585: /* Workaround for hardware errata. fp@2585: * apply workaround for hardware errata documented in errata fp@2585: * docs Fixes issue where some error prone or unreliable PCIe fp@2585: * completions are occurring, particularly with ASPM enabled. fp@2585: * Without fix, issue can cause Tx timeouts. fp@2585: */ fp@2585: reg = er32(GCR2); fp@2585: reg |= 1; fp@2585: ew32(GCR2, reg); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_clear_vfta_82571 - Clear VLAN filter table fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Clears the register array which contains the VLAN filter table by fp@2585: * setting all the values to 0. fp@2585: **/ fp@2585: static void e1000_clear_vfta_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 offset; fp@2585: u32 vfta_value = 0; fp@2585: u32 vfta_offset = 0; fp@2585: u32 vfta_bit_in_reg = 0; fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: if (hw->mng_cookie.vlan_id != 0) { fp@2585: /* The VFTA is a 4096b bit-field, each identifying fp@2585: * a single VLAN ID. The following operations fp@2585: * determine which 32b entry (i.e. offset) into the fp@2585: * array we want to set the VLAN ID (i.e. bit) of fp@2585: * the manageability unit. fp@2585: */ fp@2585: vfta_offset = (hw->mng_cookie.vlan_id >> fp@2585: E1000_VFTA_ENTRY_SHIFT) & fp@2585: E1000_VFTA_ENTRY_MASK; fp@2585: vfta_bit_in_reg = fp@2585: 1 << (hw->mng_cookie.vlan_id & fp@2585: E1000_VFTA_ENTRY_BIT_SHIFT_MASK); fp@2585: } fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) { fp@2585: /* If the offset we want to clear is the same offset of the fp@2585: * manageability VLAN ID, then clear all bits except that of fp@2585: * the manageability unit. fp@2585: */ fp@2585: vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0; fp@2585: E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value); fp@2585: e1e_flush(); fp@2585: } fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_check_mng_mode_82574 - Check manageability is enabled fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Reads the NVM Initialization Control Word 2 and returns true fp@2585: * (>0) if any manageability is enabled, else false (0). fp@2585: **/ fp@2585: static bool e1000_check_mng_mode_82574(struct e1000_hw *hw) fp@2585: { fp@2585: u16 data; fp@2585: fp@2585: e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); fp@2585: return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_led_on_82574 - Turn LED on fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Turn LED on. fp@2585: **/ fp@2585: static s32 e1000_led_on_82574(struct e1000_hw *hw) fp@2585: { fp@2585: u32 ctrl; fp@2585: u32 i; fp@2585: fp@2585: ctrl = hw->mac.ledctl_mode2; fp@2585: if (!(E1000_STATUS_LU & er32(STATUS))) { fp@2585: /* If no link, then turn LED on by setting the invert bit fp@2585: * for each LED that's "on" (0x0E) in ledctl_mode2. fp@2585: */ fp@2585: for (i = 0; i < 4; i++) fp@2585: if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) == fp@2585: E1000_LEDCTL_MODE_LED_ON) fp@2585: ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8)); fp@2585: } fp@2585: ew32(LEDCTL, ctrl); fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_check_phy_82574 - check 82574 phy hung state fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Returns whether phy is hung or not fp@2585: **/ fp@2585: bool e1000_check_phy_82574(struct e1000_hw *hw) fp@2585: { fp@2585: u16 status_1kbt = 0; fp@2585: u16 receive_errors = 0; fp@2585: s32 ret_val; fp@2585: fp@2585: /* Read PHY Receive Error counter first, if its is max - all F's then fp@2585: * read the Base1000T status register If both are max then PHY is hung. fp@2585: */ fp@2585: ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors); fp@2585: if (ret_val) fp@2585: return false; fp@2585: if (receive_errors == E1000_RECEIVE_ERROR_MAX) { fp@2585: ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt); fp@2585: if (ret_val) fp@2585: return false; fp@2585: if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) == fp@2585: E1000_IDLE_ERROR_COUNT_MASK) fp@2585: return true; fp@2585: } fp@2585: fp@2585: return false; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_setup_link_82571 - Setup flow control and link settings fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Determines which flow control settings to use, then configures flow fp@2585: * control. Calls the appropriate media-specific link configuration fp@2585: * function. Assuming the adapter has a valid link partner, a valid link fp@2585: * should be established. Assumes the hardware has previously been reset fp@2585: * and the transmitter and receiver are not enabled. fp@2585: **/ fp@2585: static s32 e1000_setup_link_82571(struct e1000_hw *hw) fp@2585: { fp@2585: /* 82573 does not have a word in the NVM to determine fp@2585: * the default flow control setting, so we explicitly fp@2585: * set it to full. fp@2585: */ fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: if (hw->fc.requested_mode == e1000_fc_default) fp@2585: hw->fc.requested_mode = e1000_fc_full; fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: return e1000e_setup_link_generic(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_setup_copper_link_82571 - Configure copper link settings fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Configures the link for auto-neg or forced speed and duplex. Then we check fp@2585: * for link, once link is established calls to configure collision distance fp@2585: * and flow control are called. fp@2585: **/ fp@2585: static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) fp@2585: { fp@2585: u32 ctrl; fp@2585: s32 ret_val; fp@2585: fp@2585: ctrl = er32(CTRL); fp@2585: ctrl |= E1000_CTRL_SLU; fp@2585: ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); fp@2585: ew32(CTRL, ctrl); fp@2585: fp@2585: switch (hw->phy.type) { fp@2585: case e1000_phy_m88: fp@2585: case e1000_phy_bm: fp@2585: ret_val = e1000e_copper_link_setup_m88(hw); fp@2585: break; fp@2585: case e1000_phy_igp_2: fp@2585: ret_val = e1000e_copper_link_setup_igp(hw); fp@2585: break; fp@2585: default: fp@2585: return -E1000_ERR_PHY; fp@2585: break; fp@2585: } fp@2585: fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: return e1000e_setup_copper_link(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Configures collision distance and flow control for fiber and serdes links. fp@2585: * Upon successful setup, poll for link. fp@2585: **/ fp@2585: static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw) fp@2585: { fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82571: fp@2585: case e1000_82572: fp@2585: /* If SerDes loopback mode is entered, there is no form fp@2585: * of reset to take the adapter out of that mode. So we fp@2585: * have to explicitly take the adapter out of loopback fp@2585: * mode. This prevents drivers from twiddling their thumbs fp@2585: * if another tool failed to take it out of loopback mode. fp@2585: */ fp@2585: ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); fp@2585: break; fp@2585: default: fp@2585: break; fp@2585: } fp@2585: fp@2585: return e1000e_setup_fiber_serdes_link(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_check_for_serdes_link_82571 - Check for link (Serdes) fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Reports the link state as up or down. fp@2585: * fp@2585: * If autonegotiation is supported by the link partner, the link state is fp@2585: * determined by the result of autonegotiation. This is the most likely case. fp@2585: * If autonegotiation is not supported by the link partner, and the link fp@2585: * has a valid signal, force the link up. fp@2585: * fp@2585: * The link state is represented internally here by 4 states: fp@2585: * fp@2585: * 1) down fp@2585: * 2) autoneg_progress fp@2585: * 3) autoneg_complete (the link successfully autonegotiated) fp@2585: * 4) forced_up (the link has been forced up, it did not autonegotiate) fp@2585: * fp@2585: **/ fp@2585: static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_mac_info *mac = &hw->mac; fp@2585: u32 rxcw; fp@2585: u32 ctrl; fp@2585: u32 status; fp@2585: u32 txcw; fp@2585: u32 i; fp@2585: s32 ret_val = 0; fp@2585: fp@2585: ctrl = er32(CTRL); fp@2585: status = er32(STATUS); fp@2585: er32(RXCW); fp@2585: /* SYNCH bit and IV bit are sticky */ fp@2585: usleep_range(10, 20); fp@2585: rxcw = er32(RXCW); fp@2585: fp@2585: if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) { fp@2585: /* Receiver is synchronized with no invalid bits. */ fp@2585: switch (mac->serdes_link_state) { fp@2585: case e1000_serdes_link_autoneg_complete: fp@2585: if (!(status & E1000_STATUS_LU)) { fp@2585: /* We have lost link, retry autoneg before fp@2585: * reporting link failure fp@2585: */ fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_autoneg_progress; fp@2585: mac->serdes_has_link = false; fp@2585: e_dbg("AN_UP -> AN_PROG\n"); fp@2585: } else { fp@2585: mac->serdes_has_link = true; fp@2585: } fp@2585: break; fp@2585: fp@2585: case e1000_serdes_link_forced_up: fp@2585: /* If we are receiving /C/ ordered sets, re-enable fp@2585: * auto-negotiation in the TXCW register and disable fp@2585: * forced link in the Device Control register in an fp@2585: * attempt to auto-negotiate with our link partner. fp@2585: */ fp@2585: if (rxcw & E1000_RXCW_C) { fp@2585: /* Enable autoneg, and unforce link up */ fp@2585: ew32(TXCW, mac->txcw); fp@2585: ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_autoneg_progress; fp@2585: mac->serdes_has_link = false; fp@2585: e_dbg("FORCED_UP -> AN_PROG\n"); fp@2585: } else { fp@2585: mac->serdes_has_link = true; fp@2585: } fp@2585: break; fp@2585: fp@2585: case e1000_serdes_link_autoneg_progress: fp@2585: if (rxcw & E1000_RXCW_C) { fp@2585: /* We received /C/ ordered sets, meaning the fp@2585: * link partner has autonegotiated, and we can fp@2585: * trust the Link Up (LU) status bit. fp@2585: */ fp@2585: if (status & E1000_STATUS_LU) { fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_autoneg_complete; fp@2585: e_dbg("AN_PROG -> AN_UP\n"); fp@2585: mac->serdes_has_link = true; fp@2585: } else { fp@2585: /* Autoneg completed, but failed. */ fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_down; fp@2585: e_dbg("AN_PROG -> DOWN\n"); fp@2585: } fp@2585: } else { fp@2585: /* The link partner did not autoneg. fp@2585: * Force link up and full duplex, and change fp@2585: * state to forced. fp@2585: */ fp@2585: ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); fp@2585: ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD); fp@2585: ew32(CTRL, ctrl); fp@2585: fp@2585: /* Configure Flow Control after link up. */ fp@2585: ret_val = e1000e_config_fc_after_link_up(hw); fp@2585: if (ret_val) { fp@2585: e_dbg("Error config flow control\n"); fp@2585: break; fp@2585: } fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_forced_up; fp@2585: mac->serdes_has_link = true; fp@2585: e_dbg("AN_PROG -> FORCED_UP\n"); fp@2585: } fp@2585: break; fp@2585: fp@2585: case e1000_serdes_link_down: fp@2585: default: fp@2585: /* The link was down but the receiver has now gained fp@2585: * valid sync, so lets see if we can bring the link fp@2585: * up. fp@2585: */ fp@2585: ew32(TXCW, mac->txcw); fp@2585: ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_autoneg_progress; fp@2585: mac->serdes_has_link = false; fp@2585: e_dbg("DOWN -> AN_PROG\n"); fp@2585: break; fp@2585: } fp@2585: } else { fp@2585: if (!(rxcw & E1000_RXCW_SYNCH)) { fp@2585: mac->serdes_has_link = false; fp@2585: mac->serdes_link_state = e1000_serdes_link_down; fp@2585: e_dbg("ANYSTATE -> DOWN\n"); fp@2585: } else { fp@2585: /* Check several times, if SYNCH bit and CONFIG fp@2585: * bit both are consistently 1 then simply ignore fp@2585: * the IV bit and restart Autoneg fp@2585: */ fp@2585: for (i = 0; i < AN_RETRY_COUNT; i++) { fp@2585: usleep_range(10, 20); fp@2585: rxcw = er32(RXCW); fp@2585: if ((rxcw & E1000_RXCW_SYNCH) && fp@2585: (rxcw & E1000_RXCW_C)) fp@2585: continue; fp@2585: fp@2585: if (rxcw & E1000_RXCW_IV) { fp@2585: mac->serdes_has_link = false; fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_down; fp@2585: e_dbg("ANYSTATE -> DOWN\n"); fp@2585: break; fp@2585: } fp@2585: } fp@2585: fp@2585: if (i == AN_RETRY_COUNT) { fp@2585: txcw = er32(TXCW); fp@2585: txcw |= E1000_TXCW_ANE; fp@2585: ew32(TXCW, txcw); fp@2585: mac->serdes_link_state = fp@2585: e1000_serdes_link_autoneg_progress; fp@2585: mac->serdes_has_link = false; fp@2585: e_dbg("ANYSTATE -> AN_PROG\n"); fp@2585: } fp@2585: } fp@2585: } fp@2585: fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_valid_led_default_82571 - Verify a valid default LED config fp@2585: * @hw: pointer to the HW structure fp@2585: * @data: pointer to the NVM (EEPROM) fp@2585: * fp@2585: * Read the EEPROM for the current default LED configuration. If the fp@2585: * LED configuration is not valid, set to a valid LED configuration. fp@2585: **/ fp@2585: static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data) fp@2585: { fp@2585: s32 ret_val; fp@2585: fp@2585: ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); fp@2585: if (ret_val) { fp@2585: e_dbg("NVM Read Error\n"); fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: switch (hw->mac.type) { fp@2585: case e1000_82573: fp@2585: case e1000_82574: fp@2585: case e1000_82583: fp@2585: if (*data == ID_LED_RESERVED_F746) fp@2585: *data = ID_LED_DEFAULT_82573; fp@2585: break; fp@2585: default: fp@2585: if (*data == ID_LED_RESERVED_0000 || fp@2585: *data == ID_LED_RESERVED_FFFF) fp@2585: *data = ID_LED_DEFAULT; fp@2585: break; fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000e_get_laa_state_82571 - Get locally administered address state fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Retrieve and return the current locally administered address state. fp@2585: **/ fp@2585: bool e1000e_get_laa_state_82571(struct e1000_hw *hw) fp@2585: { fp@2585: if (hw->mac.type != e1000_82571) fp@2585: return false; fp@2585: fp@2585: return hw->dev_spec.e82571.laa_is_present; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000e_set_laa_state_82571 - Set locally administered address state fp@2585: * @hw: pointer to the HW structure fp@2585: * @state: enable/disable locally administered address fp@2585: * fp@2585: * Enable/Disable the current locally administered address state. fp@2585: **/ fp@2585: void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state) fp@2585: { fp@2585: if (hw->mac.type != e1000_82571) fp@2585: return; fp@2585: fp@2585: hw->dev_spec.e82571.laa_is_present = state; fp@2585: fp@2585: /* If workaround is activated... */ fp@2585: if (state) fp@2585: /* Hold a copy of the LAA in RAR[14] This is done so that fp@2585: * between the time RAR[0] gets clobbered and the time it fp@2585: * gets fixed, the actual LAA is in one of the RARs and no fp@2585: * incoming packets directed to this port are dropped. fp@2585: * Eventually the LAA will be in RAR[0] and RAR[14]. fp@2585: */ fp@2585: hw->mac.ops.rar_set(hw, hw->mac.addr, fp@2585: hw->mac.rar_entry_count - 1); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Verifies that the EEPROM has completed the update. After updating the fp@2585: * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If fp@2585: * the checksum fix is not implemented, we need to set the bit and update fp@2585: * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect, fp@2585: * we need to return bad checksum. fp@2585: **/ fp@2585: static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_nvm_info *nvm = &hw->nvm; fp@2585: s32 ret_val; fp@2585: u16 data; fp@2585: fp@2585: if (nvm->type != e1000_nvm_flash_hw) fp@2585: return 0; fp@2585: fp@2585: /* Check bit 4 of word 10h. If it is 0, firmware is done updating fp@2585: * 10h-12h. Checksum may need to be fixed. fp@2585: */ fp@2585: ret_val = e1000_read_nvm(hw, 0x10, 1, &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: if (!(data & 0x10)) { fp@2585: /* Read 0x23 and check bit 15. This bit is a 1 fp@2585: * when the checksum has already been fixed. If fp@2585: * the checksum is still wrong and this bit is a fp@2585: * 1, we need to return bad checksum. Otherwise, fp@2585: * we need to set this bit to a 1 and update the fp@2585: * checksum. fp@2585: */ fp@2585: ret_val = e1000_read_nvm(hw, 0x23, 1, &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: fp@2585: if (!(data & 0x8000)) { fp@2585: data |= 0x8000; fp@2585: ret_val = e1000_write_nvm(hw, 0x23, 1, &data); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: ret_val = e1000e_update_nvm_checksum(hw); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: } fp@2585: } fp@2585: fp@2585: return 0; fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_read_mac_addr_82571 - Read device MAC address fp@2585: * @hw: pointer to the HW structure fp@2585: **/ fp@2585: static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) fp@2585: { fp@2585: if (hw->mac.type == e1000_82571) { fp@2585: s32 ret_val; fp@2585: fp@2585: /* If there's an alternate MAC address place it in RAR0 fp@2585: * so that it will override the Si installed default perm fp@2585: * address. fp@2585: */ fp@2585: ret_val = e1000_check_alt_mac_addr_generic(hw); fp@2585: if (ret_val) fp@2585: return ret_val; fp@2585: } fp@2585: fp@2585: return e1000_read_mac_addr_generic(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_power_down_phy_copper_82571 - Remove link during PHY power down fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * In the case of a PHY power down to save power, or to turn off link during a fp@2585: * driver unload, or wake on lan is not enabled, remove the link. fp@2585: **/ fp@2585: static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw) fp@2585: { fp@2585: struct e1000_phy_info *phy = &hw->phy; fp@2585: struct e1000_mac_info *mac = &hw->mac; fp@2585: fp@2585: if (!phy->ops.check_reset_block) fp@2585: return; fp@2585: fp@2585: /* If the management interface is not enabled, then power down */ fp@2585: if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw))) fp@2585: e1000_power_down_phy_copper(hw); fp@2585: } fp@2585: fp@2585: /** fp@2585: * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters fp@2585: * @hw: pointer to the HW structure fp@2585: * fp@2585: * Clears the hardware counters by reading the counter registers. fp@2585: **/ fp@2585: static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) fp@2585: { fp@2585: e1000e_clear_hw_cntrs_base(hw); fp@2585: fp@2585: er32(PRC64); fp@2585: er32(PRC127); fp@2585: er32(PRC255); fp@2585: er32(PRC511); fp@2585: er32(PRC1023); fp@2585: er32(PRC1522); fp@2585: er32(PTC64); fp@2585: er32(PTC127); fp@2585: er32(PTC255); fp@2585: er32(PTC511); fp@2585: er32(PTC1023); fp@2585: er32(PTC1522); fp@2585: fp@2585: er32(ALGNERRC); fp@2585: er32(RXERRC); fp@2585: er32(TNCRS); fp@2585: er32(CEXTERR); fp@2585: er32(TSCTC); fp@2585: er32(TSCTFC); fp@2585: fp@2585: er32(MGTPRC); fp@2585: er32(MGTPDC); fp@2585: er32(MGTPTC); fp@2585: fp@2585: er32(IAC); fp@2585: er32(ICRXOC); fp@2585: fp@2585: er32(ICRXPTC); fp@2585: er32(ICRXATC); fp@2585: er32(ICTXPTC); fp@2585: er32(ICTXATC); fp@2585: er32(ICTXQEC); fp@2585: er32(ICTXQMTC); fp@2585: er32(ICRXDMTC); fp@2585: } fp@2585: fp@2585: static const struct e1000_mac_operations e82571_mac_ops = { fp@2585: /* .check_mng_mode: mac type dependent */ fp@2585: /* .check_for_link: media type dependent */ fp@2585: .id_led_init = e1000e_id_led_init_generic, fp@2585: .cleanup_led = e1000e_cleanup_led_generic, fp@2585: .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, fp@2585: .get_bus_info = e1000e_get_bus_info_pcie, fp@2585: .set_lan_id = e1000_set_lan_id_multi_port_pcie, fp@2585: /* .get_link_up_info: media type dependent */ fp@2585: /* .led_on: mac type dependent */ fp@2585: .led_off = e1000e_led_off_generic, fp@2585: .update_mc_addr_list = e1000e_update_mc_addr_list_generic, fp@2585: .write_vfta = e1000_write_vfta_generic, fp@2585: .clear_vfta = e1000_clear_vfta_82571, fp@2585: .reset_hw = e1000_reset_hw_82571, fp@2585: .init_hw = e1000_init_hw_82571, fp@2585: .setup_link = e1000_setup_link_82571, fp@2585: /* .setup_physical_interface: media type dependent */ fp@2585: .setup_led = e1000e_setup_led_generic, fp@2585: .config_collision_dist = e1000e_config_collision_dist_generic, fp@2585: .read_mac_addr = e1000_read_mac_addr_82571, fp@2585: .rar_set = e1000e_rar_set_generic, fp@2585: }; fp@2585: fp@2585: static const struct e1000_phy_operations e82_phy_ops_igp = { fp@2585: .acquire = e1000_get_hw_semaphore_82571, fp@2585: .check_polarity = e1000_check_polarity_igp, fp@2585: .check_reset_block = e1000e_check_reset_block_generic, fp@2585: .commit = NULL, fp@2585: .force_speed_duplex = e1000e_phy_force_speed_duplex_igp, fp@2585: .get_cfg_done = e1000_get_cfg_done_82571, fp@2585: .get_cable_length = e1000e_get_cable_length_igp_2, fp@2585: .get_info = e1000e_get_phy_info_igp, fp@2585: .read_reg = e1000e_read_phy_reg_igp, fp@2585: .release = e1000_put_hw_semaphore_82571, fp@2585: .reset = e1000e_phy_hw_reset_generic, fp@2585: .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, fp@2585: .set_d3_lplu_state = e1000e_set_d3_lplu_state, fp@2585: .write_reg = e1000e_write_phy_reg_igp, fp@2585: .cfg_on_link_up = NULL, fp@2585: }; fp@2585: fp@2585: static const struct e1000_phy_operations e82_phy_ops_m88 = { fp@2585: .acquire = e1000_get_hw_semaphore_82571, fp@2585: .check_polarity = e1000_check_polarity_m88, fp@2585: .check_reset_block = e1000e_check_reset_block_generic, fp@2585: .commit = e1000e_phy_sw_reset, fp@2585: .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, fp@2585: .get_cfg_done = e1000e_get_cfg_done_generic, fp@2585: .get_cable_length = e1000e_get_cable_length_m88, fp@2585: .get_info = e1000e_get_phy_info_m88, fp@2585: .read_reg = e1000e_read_phy_reg_m88, fp@2585: .release = e1000_put_hw_semaphore_82571, fp@2585: .reset = e1000e_phy_hw_reset_generic, fp@2585: .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, fp@2585: .set_d3_lplu_state = e1000e_set_d3_lplu_state, fp@2585: .write_reg = e1000e_write_phy_reg_m88, fp@2585: .cfg_on_link_up = NULL, fp@2585: }; fp@2585: fp@2585: static const struct e1000_phy_operations e82_phy_ops_bm = { fp@2585: .acquire = e1000_get_hw_semaphore_82571, fp@2585: .check_polarity = e1000_check_polarity_m88, fp@2585: .check_reset_block = e1000e_check_reset_block_generic, fp@2585: .commit = e1000e_phy_sw_reset, fp@2585: .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, fp@2585: .get_cfg_done = e1000e_get_cfg_done_generic, fp@2585: .get_cable_length = e1000e_get_cable_length_m88, fp@2585: .get_info = e1000e_get_phy_info_m88, fp@2585: .read_reg = e1000e_read_phy_reg_bm2, fp@2585: .release = e1000_put_hw_semaphore_82571, fp@2585: .reset = e1000e_phy_hw_reset_generic, fp@2585: .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, fp@2585: .set_d3_lplu_state = e1000e_set_d3_lplu_state, fp@2585: .write_reg = e1000e_write_phy_reg_bm2, fp@2585: .cfg_on_link_up = NULL, fp@2585: }; fp@2585: fp@2585: static const struct e1000_nvm_operations e82571_nvm_ops = { fp@2585: .acquire = e1000_acquire_nvm_82571, fp@2585: .read = e1000e_read_nvm_eerd, fp@2585: .release = e1000_release_nvm_82571, fp@2585: .reload = e1000e_reload_nvm_generic, fp@2585: .update = e1000_update_nvm_checksum_82571, fp@2585: .valid_led_default = e1000_valid_led_default_82571, fp@2585: .validate = e1000_validate_nvm_checksum_82571, fp@2585: .write = e1000_write_nvm_82571, fp@2585: }; fp@2585: fp@2585: const struct e1000_info e1000_82571_info = { fp@2585: .mac = e1000_82571, fp@2585: .flags = FLAG_HAS_HW_VLAN_FILTER fp@2585: | FLAG_HAS_JUMBO_FRAMES fp@2585: | FLAG_HAS_WOL fp@2585: | FLAG_APME_IN_CTRL3 fp@2585: | FLAG_HAS_CTRLEXT_ON_LOAD fp@2585: | FLAG_HAS_SMART_POWER_DOWN fp@2585: | FLAG_RESET_OVERWRITES_LAA /* errata */ fp@2585: | FLAG_TARC_SPEED_MODE_BIT /* errata */ fp@2585: | FLAG_APME_CHECK_PORT_B, fp@2585: .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ fp@2585: | FLAG2_DMA_BURST, fp@2585: .pba = 38, fp@2585: .max_hw_frame_size = DEFAULT_JUMBO, fp@2585: .get_variants = e1000_get_variants_82571, fp@2585: .mac_ops = &e82571_mac_ops, fp@2585: .phy_ops = &e82_phy_ops_igp, fp@2585: .nvm_ops = &e82571_nvm_ops, fp@2585: }; fp@2585: fp@2585: const struct e1000_info e1000_82572_info = { fp@2585: .mac = e1000_82572, fp@2585: .flags = FLAG_HAS_HW_VLAN_FILTER fp@2585: | FLAG_HAS_JUMBO_FRAMES fp@2585: | FLAG_HAS_WOL fp@2585: | FLAG_APME_IN_CTRL3 fp@2585: | FLAG_HAS_CTRLEXT_ON_LOAD fp@2585: | FLAG_TARC_SPEED_MODE_BIT, /* errata */ fp@2585: .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ fp@2585: | FLAG2_DMA_BURST, fp@2585: .pba = 38, fp@2585: .max_hw_frame_size = DEFAULT_JUMBO, fp@2585: .get_variants = e1000_get_variants_82571, fp@2585: .mac_ops = &e82571_mac_ops, fp@2585: .phy_ops = &e82_phy_ops_igp, fp@2585: .nvm_ops = &e82571_nvm_ops, fp@2585: }; fp@2585: fp@2585: const struct e1000_info e1000_82573_info = { fp@2585: .mac = e1000_82573, fp@2585: .flags = FLAG_HAS_HW_VLAN_FILTER fp@2585: | FLAG_HAS_WOL fp@2585: | FLAG_APME_IN_CTRL3 fp@2585: | FLAG_HAS_SMART_POWER_DOWN fp@2585: | FLAG_HAS_AMT fp@2585: | FLAG_HAS_SWSM_ON_LOAD, fp@2585: .flags2 = FLAG2_DISABLE_ASPM_L1 fp@2585: | FLAG2_DISABLE_ASPM_L0S, fp@2585: .pba = 20, fp@2585: .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, fp@2585: .get_variants = e1000_get_variants_82571, fp@2585: .mac_ops = &e82571_mac_ops, fp@2585: .phy_ops = &e82_phy_ops_m88, fp@2585: .nvm_ops = &e82571_nvm_ops, fp@2585: }; fp@2585: fp@2585: const struct e1000_info e1000_82574_info = { fp@2585: .mac = e1000_82574, fp@2585: .flags = FLAG_HAS_HW_VLAN_FILTER fp@2585: | FLAG_HAS_MSIX fp@2585: | FLAG_HAS_JUMBO_FRAMES fp@2585: | FLAG_HAS_WOL fp@2585: | FLAG_HAS_HW_TIMESTAMP fp@2585: | FLAG_APME_IN_CTRL3 fp@2585: | FLAG_HAS_SMART_POWER_DOWN fp@2585: | FLAG_HAS_AMT fp@2585: | FLAG_HAS_CTRLEXT_ON_LOAD, fp@2585: .flags2 = FLAG2_CHECK_PHY_HANG fp@2585: | FLAG2_DISABLE_ASPM_L0S fp@2585: | FLAG2_DISABLE_ASPM_L1 fp@2585: | FLAG2_NO_DISABLE_RX fp@2585: | FLAG2_DMA_BURST, fp@2585: .pba = 32, fp@2585: .max_hw_frame_size = DEFAULT_JUMBO, fp@2585: .get_variants = e1000_get_variants_82571, fp@2585: .mac_ops = &e82571_mac_ops, fp@2585: .phy_ops = &e82_phy_ops_bm, fp@2585: .nvm_ops = &e82571_nvm_ops, fp@2585: }; fp@2585: fp@2585: const struct e1000_info e1000_82583_info = { fp@2585: .mac = e1000_82583, fp@2585: .flags = FLAG_HAS_HW_VLAN_FILTER fp@2585: | FLAG_HAS_WOL fp@2585: | FLAG_HAS_HW_TIMESTAMP fp@2585: | FLAG_APME_IN_CTRL3 fp@2585: | FLAG_HAS_SMART_POWER_DOWN fp@2585: | FLAG_HAS_AMT fp@2585: | FLAG_HAS_JUMBO_FRAMES fp@2585: | FLAG_HAS_CTRLEXT_ON_LOAD, fp@2585: .flags2 = FLAG2_DISABLE_ASPM_L0S fp@2585: | FLAG2_NO_DISABLE_RX, fp@2585: .pba = 32, fp@2585: .max_hw_frame_size = DEFAULT_JUMBO, fp@2585: .get_variants = e1000_get_variants_82571, fp@2585: .mac_ops = &e82571_mac_ops, fp@2585: .phy_ops = &e82_phy_ops_bm, fp@2585: .nvm_ops = &e82571_nvm_ops, fp@2585: };