Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | 451152d | 2010-06-16 13:28:11 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2010 Intel Corporation. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 5 | |
| 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. |
| 9 | |
| 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 |
| 13 | more details. |
| 14 | |
| 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. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
| 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 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
| 29 | /* |
| 30 | * 82571EB Gigabit Ethernet Controller |
Bruce Allan | 1605927 | 2008-11-21 16:51:06 -0800 | [diff] [blame] | 31 | * 82571EB Gigabit Ethernet Controller (Copper) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 32 | * 82571EB Gigabit Ethernet Controller (Fiber) |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 33 | * 82571EB Dual Port Gigabit Mezzanine Adapter |
| 34 | * 82571EB Quad Port Gigabit Mezzanine Adapter |
| 35 | * 82571PT Gigabit PT Quad Port Server ExpressModule |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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 |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 42 | * 82574L Gigabit Network Connection |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 43 | * 82583V Gigabit Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 44 | */ |
| 45 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 46 | #include "e1000.h" |
| 47 | |
| 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) | \ |
| 52 | (ID_LED_DEF1_DEF2)) |
| 53 | |
| 54 | #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 |
Carolyn Wyborny | ff10e13 | 2010-10-28 00:59:53 +0000 | [diff] [blame] | 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 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 59 | |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 60 | #define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */ |
| 61 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 65 | static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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); |
Bruce Allan | caaddaf | 2009-12-01 15:46:43 +0000 | [diff] [blame] | 72 | static void e1000_clear_vfta_82571(struct e1000_hw *hw); |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 73 | static bool e1000_check_mng_mode_82574(struct e1000_hw *hw); |
| 74 | static s32 e1000_led_on_82574(struct e1000_hw *hw); |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 75 | static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 76 | static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw); |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 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); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * e1000_init_phy_params_82571 - Init PHY func ptrs. |
| 83 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 84 | **/ |
| 85 | static s32 e1000_init_phy_params_82571(struct e1000_hw *hw) |
| 86 | { |
| 87 | struct e1000_phy_info *phy = &hw->phy; |
| 88 | s32 ret_val; |
| 89 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 90 | if (hw->phy.media_type != e1000_media_type_copper) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 91 | phy->type = e1000_phy_none; |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | phy->addr = 1; |
| 96 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
| 97 | phy->reset_delay_us = 100; |
| 98 | |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 99 | phy->ops.power_up = e1000_power_up_phy_copper; |
| 100 | phy->ops.power_down = e1000_power_down_phy_copper_82571; |
| 101 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 102 | switch (hw->mac.type) { |
| 103 | case e1000_82571: |
| 104 | case e1000_82572: |
| 105 | phy->type = e1000_phy_igp_2; |
| 106 | break; |
| 107 | case e1000_82573: |
| 108 | phy->type = e1000_phy_m88; |
| 109 | break; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 110 | case e1000_82574: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 111 | case e1000_82583: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 112 | phy->type = e1000_phy_bm; |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 113 | phy->ops.acquire = e1000_get_hw_semaphore_82574; |
| 114 | phy->ops.release = e1000_put_hw_semaphore_82574; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 115 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 116 | default: |
| 117 | return -E1000_ERR_PHY; |
| 118 | break; |
| 119 | } |
| 120 | |
| 121 | /* This can only be done after all function pointers are setup. */ |
| 122 | ret_val = e1000_get_phy_id_82571(hw); |
| 123 | |
| 124 | /* Verify phy id */ |
| 125 | switch (hw->mac.type) { |
| 126 | case e1000_82571: |
| 127 | case e1000_82572: |
| 128 | if (phy->id != IGP01E1000_I_PHY_ID) |
| 129 | return -E1000_ERR_PHY; |
| 130 | break; |
| 131 | case e1000_82573: |
| 132 | if (phy->id != M88E1111_I_PHY_ID) |
| 133 | return -E1000_ERR_PHY; |
| 134 | break; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 135 | case e1000_82574: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 136 | case e1000_82583: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 137 | if (phy->id != BME1000_E_PHY_ID_R2) |
| 138 | return -E1000_ERR_PHY; |
| 139 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 140 | default: |
| 141 | return -E1000_ERR_PHY; |
| 142 | break; |
| 143 | } |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * e1000_init_nvm_params_82571 - Init NVM func ptrs. |
| 150 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 151 | **/ |
| 152 | static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw) |
| 153 | { |
| 154 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 155 | u32 eecd = er32(EECD); |
| 156 | u16 size; |
| 157 | |
| 158 | nvm->opcode_bits = 8; |
| 159 | nvm->delay_usec = 1; |
| 160 | switch (nvm->override) { |
| 161 | case e1000_nvm_override_spi_large: |
| 162 | nvm->page_size = 32; |
| 163 | nvm->address_bits = 16; |
| 164 | break; |
| 165 | case e1000_nvm_override_spi_small: |
| 166 | nvm->page_size = 8; |
| 167 | nvm->address_bits = 8; |
| 168 | break; |
| 169 | default: |
| 170 | nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; |
| 171 | nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; |
| 172 | break; |
| 173 | } |
| 174 | |
| 175 | switch (hw->mac.type) { |
| 176 | case e1000_82573: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 177 | case e1000_82574: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 178 | case e1000_82583: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 179 | if (((eecd >> 15) & 0x3) == 0x3) { |
| 180 | nvm->type = e1000_nvm_flash_hw; |
| 181 | nvm->word_size = 2048; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 182 | /* |
| 183 | * Autonomous Flash update bit must be cleared due |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 184 | * to Flash update issue. |
| 185 | */ |
| 186 | eecd &= ~E1000_EECD_AUPDEN; |
| 187 | ew32(EECD, eecd); |
| 188 | break; |
| 189 | } |
| 190 | /* Fall Through */ |
| 191 | default: |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 192 | nvm->type = e1000_nvm_eeprom_spi; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 193 | size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> |
| 194 | E1000_EECD_SIZE_EX_SHIFT); |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 195 | /* |
| 196 | * Added to a constant, "size" becomes the left-shift value |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 197 | * for setting word_size. |
| 198 | */ |
| 199 | size += NVM_WORD_SIZE_BASE_SHIFT; |
Jeff Kirsher | 8d7c294 | 2008-04-02 13:48:07 -0700 | [diff] [blame] | 200 | |
| 201 | /* EEPROM access above 16k is unsupported */ |
| 202 | if (size > 14) |
| 203 | size = 14; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 204 | nvm->word_size = 1 << size; |
| 205 | break; |
| 206 | } |
| 207 | |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 208 | /* Function Pointers */ |
| 209 | switch (hw->mac.type) { |
| 210 | case e1000_82574: |
| 211 | case e1000_82583: |
| 212 | nvm->ops.acquire = e1000_get_hw_semaphore_82574; |
| 213 | nvm->ops.release = e1000_put_hw_semaphore_82574; |
| 214 | break; |
| 215 | default: |
| 216 | break; |
| 217 | } |
| 218 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * e1000_init_mac_params_82571 - Init MAC func ptrs. |
| 224 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 225 | **/ |
| 226 | static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) |
| 227 | { |
| 228 | struct e1000_hw *hw = &adapter->hw; |
| 229 | struct e1000_mac_info *mac = &hw->mac; |
| 230 | struct e1000_mac_operations *func = &mac->ops; |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 231 | u32 swsm = 0; |
| 232 | u32 swsm2 = 0; |
| 233 | bool force_clear_smbi = false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 234 | |
| 235 | /* Set media type */ |
| 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: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 240 | hw->phy.media_type = e1000_media_type_fiber; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 241 | break; |
| 242 | case E1000_DEV_ID_82571EB_SERDES: |
| 243 | case E1000_DEV_ID_82572EI_SERDES: |
Auke Kok | 040babf | 2007-10-31 15:22:05 -0700 | [diff] [blame] | 244 | case E1000_DEV_ID_82571EB_SERDES_DUAL: |
| 245 | case E1000_DEV_ID_82571EB_SERDES_QUAD: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 246 | hw->phy.media_type = e1000_media_type_internal_serdes; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 247 | break; |
| 248 | default: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 249 | hw->phy.media_type = e1000_media_type_copper; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 250 | break; |
| 251 | } |
| 252 | |
| 253 | /* Set mta register count */ |
| 254 | mac->mta_reg_count = 128; |
| 255 | /* Set rar entry count */ |
| 256 | mac->rar_entry_count = E1000_RAR_ENTRIES; |
Bruce Allan | f464ba8 | 2010-01-07 16:31:35 +0000 | [diff] [blame] | 257 | /* Adaptive IFS supported */ |
| 258 | mac->adaptive_ifs = true; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 259 | |
| 260 | /* check for link */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 261 | switch (hw->phy.media_type) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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; |
| 266 | break; |
| 267 | case e1000_media_type_fiber: |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 268 | func->setup_physical_interface = |
| 269 | e1000_setup_fiber_serdes_link_82571; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 270 | func->check_for_link = e1000e_check_for_fiber_link; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 271 | func->get_link_up_info = |
| 272 | e1000e_get_speed_and_duplex_fiber_serdes; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 273 | break; |
| 274 | case e1000_media_type_internal_serdes: |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 275 | func->setup_physical_interface = |
| 276 | e1000_setup_fiber_serdes_link_82571; |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 277 | func->check_for_link = e1000_check_for_serdes_link_82571; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 278 | func->get_link_up_info = |
| 279 | e1000e_get_speed_and_duplex_fiber_serdes; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 280 | break; |
| 281 | default: |
| 282 | return -E1000_ERR_CONFIG; |
| 283 | break; |
| 284 | } |
| 285 | |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 286 | switch (hw->mac.type) { |
Bruce Allan | f4d2dd4 | 2010-01-13 02:05:18 +0000 | [diff] [blame] | 287 | case e1000_82573: |
| 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; |
Bruce Allan | a65a4a0 | 2010-05-10 15:01:51 +0000 | [diff] [blame] | 291 | |
| 292 | /* FWSM register */ |
| 293 | mac->has_fwsm = true; |
| 294 | /* |
| 295 | * ARC supported; valid only if manageability features are |
| 296 | * enabled. |
| 297 | */ |
| 298 | mac->arc_subsystem_valid = |
| 299 | (er32(FWSM) & E1000_FWSM_MODE_MASK) |
| 300 | ? true : false; |
Bruce Allan | f4d2dd4 | 2010-01-13 02:05:18 +0000 | [diff] [blame] | 301 | break; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 302 | case e1000_82574: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 303 | case e1000_82583: |
Bruce Allan | f4d2dd4 | 2010-01-13 02:05:18 +0000 | [diff] [blame] | 304 | func->set_lan_id = e1000_set_lan_id_single_port; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 305 | func->check_mng_mode = e1000_check_mng_mode_82574; |
| 306 | func->led_on = e1000_led_on_82574; |
| 307 | break; |
| 308 | default: |
| 309 | func->check_mng_mode = e1000e_check_mng_mode_generic; |
| 310 | func->led_on = e1000e_led_on_generic; |
Bruce Allan | a65a4a0 | 2010-05-10 15:01:51 +0000 | [diff] [blame] | 311 | |
| 312 | /* FWSM register */ |
| 313 | mac->has_fwsm = true; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 314 | break; |
| 315 | } |
| 316 | |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 317 | /* |
| 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. |
| 323 | */ |
| 324 | switch (hw->mac.type) { |
| 325 | case e1000_82571: |
| 326 | case e1000_82572: |
| 327 | swsm2 = er32(SWSM2); |
| 328 | |
| 329 | if (!(swsm2 & E1000_SWSM2_LOCK)) { |
| 330 | /* Only do this for the first interface on this card */ |
| 331 | ew32(SWSM2, |
| 332 | swsm2 | E1000_SWSM2_LOCK); |
| 333 | force_clear_smbi = true; |
| 334 | } else |
| 335 | force_clear_smbi = false; |
| 336 | break; |
| 337 | default: |
| 338 | force_clear_smbi = true; |
| 339 | break; |
| 340 | } |
| 341 | |
| 342 | if (force_clear_smbi) { |
| 343 | /* Make sure SWSM.SMBI is clear */ |
| 344 | swsm = er32(SWSM); |
| 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 |
| 349 | */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 350 | e_dbg("Please update your 82571 Bootagent\n"); |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 351 | } |
| 352 | ew32(SWSM, swsm & ~E1000_SWSM_SMBI); |
| 353 | } |
| 354 | |
| 355 | /* |
Joe Perches | 2c73e1f | 2010-03-26 20:16:59 +0000 | [diff] [blame] | 356 | * Initialize device specific counter of SMBI acquisition |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 357 | * timeouts. |
| 358 | */ |
| 359 | hw->dev_spec.e82571.smb_counter = 0; |
| 360 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 361 | return 0; |
| 362 | } |
| 363 | |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 364 | static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 365 | { |
| 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; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 369 | int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; |
| 370 | s32 rc; |
| 371 | |
| 372 | rc = e1000_init_mac_params_82571(adapter); |
| 373 | if (rc) |
| 374 | return rc; |
| 375 | |
| 376 | rc = e1000_init_nvm_params_82571(hw); |
| 377 | if (rc) |
| 378 | return rc; |
| 379 | |
| 380 | rc = e1000_init_phy_params_82571(hw); |
| 381 | if (rc) |
| 382 | return rc; |
| 383 | |
| 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: |
Auke Kok | 040babf | 2007-10-31 15:22:05 -0700 | [diff] [blame] | 389 | case E1000_DEV_ID_82571PT_QUAD_COPPER: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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; |
| 398 | break; |
| 399 | default: |
| 400 | break; |
| 401 | } |
| 402 | |
| 403 | switch (adapter->hw.mac.type) { |
| 404 | case e1000_82571: |
| 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)) && |
| 409 | (is_port_b)) |
| 410 | adapter->flags &= ~FLAG_HAS_WOL; |
| 411 | /* quad ports only support WoL on port A */ |
| 412 | if (adapter->flags & FLAG_IS_QUAD_PORT && |
Roel Kluin | 6e4ca80 | 2007-10-29 10:50:05 -0700 | [diff] [blame] | 413 | (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 414 | adapter->flags &= ~FLAG_HAS_WOL; |
Auke Kok | 040babf | 2007-10-31 15:22:05 -0700 | [diff] [blame] | 415 | /* Does not support WoL on any port */ |
| 416 | if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) |
| 417 | adapter->flags &= ~FLAG_HAS_WOL; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 418 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 419 | case e1000_82573: |
Bruce Allan | 6f461f6 | 2010-04-27 03:33:04 +0000 | [diff] [blame] | 420 | case e1000_82574: |
| 421 | case e1000_82583: |
| 422 | /* Disable ASPM L0s due to hardware errata */ |
| 423 | e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S); |
| 424 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 425 | if (pdev->device == E1000_DEV_ID_82573L) { |
Bruce Allan | 6f461f6 | 2010-04-27 03:33:04 +0000 | [diff] [blame] | 426 | adapter->flags |= FLAG_HAS_JUMBO_FRAMES; |
| 427 | adapter->max_hw_frame_size = DEFAULT_JUMBO; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 428 | } |
| 429 | break; |
| 430 | default: |
| 431 | break; |
| 432 | } |
| 433 | |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision |
| 439 | * @hw: pointer to the HW structure |
| 440 | * |
| 441 | * Reads the PHY registers and stores the PHY ID and possibly the PHY |
| 442 | * revision in the hardware structure. |
| 443 | **/ |
| 444 | static s32 e1000_get_phy_id_82571(struct e1000_hw *hw) |
| 445 | { |
| 446 | struct e1000_phy_info *phy = &hw->phy; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 447 | s32 ret_val; |
| 448 | u16 phy_id = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 449 | |
| 450 | switch (hw->mac.type) { |
| 451 | case e1000_82571: |
| 452 | case e1000_82572: |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 453 | /* |
| 454 | * The 82571 firmware may still be configuring the PHY. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 455 | * In this case, we cannot access the PHY until the |
| 456 | * configuration is done. So we explicitly set the |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 457 | * PHY ID. |
| 458 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 459 | phy->id = IGP01E1000_I_PHY_ID; |
| 460 | break; |
| 461 | case e1000_82573: |
| 462 | return e1000e_get_phy_id(hw); |
| 463 | break; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 464 | case e1000_82574: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 465 | case e1000_82583: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 466 | ret_val = e1e_rphy(hw, PHY_ID1, &phy_id); |
| 467 | if (ret_val) |
| 468 | return ret_val; |
| 469 | |
| 470 | phy->id = (u32)(phy_id << 16); |
| 471 | udelay(20); |
| 472 | ret_val = e1e_rphy(hw, PHY_ID2, &phy_id); |
| 473 | if (ret_val) |
| 474 | return ret_val; |
| 475 | |
| 476 | phy->id |= (u32)(phy_id); |
| 477 | phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); |
| 478 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 479 | default: |
| 480 | return -E1000_ERR_PHY; |
| 481 | break; |
| 482 | } |
| 483 | |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore |
| 489 | * @hw: pointer to the HW structure |
| 490 | * |
| 491 | * Acquire the HW semaphore to access the PHY or NVM |
| 492 | **/ |
| 493 | static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw) |
| 494 | { |
| 495 | u32 swsm; |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 496 | s32 sw_timeout = hw->nvm.word_size + 1; |
| 497 | s32 fw_timeout = hw->nvm.word_size + 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 498 | s32 i = 0; |
| 499 | |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 500 | /* |
| 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 |
| 506 | * older code. |
| 507 | */ |
| 508 | if (hw->dev_spec.e82571.smb_counter > 2) |
| 509 | sw_timeout = 1; |
| 510 | |
| 511 | /* Get the SW semaphore */ |
| 512 | while (i < sw_timeout) { |
| 513 | swsm = er32(SWSM); |
| 514 | if (!(swsm & E1000_SWSM_SMBI)) |
| 515 | break; |
| 516 | |
| 517 | udelay(50); |
| 518 | i++; |
| 519 | } |
| 520 | |
| 521 | if (i == sw_timeout) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 522 | e_dbg("Driver can't access device - SMBI bit is set.\n"); |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 523 | hw->dev_spec.e82571.smb_counter++; |
| 524 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 525 | /* Get the FW semaphore. */ |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 526 | for (i = 0; i < fw_timeout; i++) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 527 | swsm = er32(SWSM); |
| 528 | ew32(SWSM, swsm | E1000_SWSM_SWESMBI); |
| 529 | |
| 530 | /* Semaphore acquired if bit latched */ |
| 531 | if (er32(SWSM) & E1000_SWSM_SWESMBI) |
| 532 | break; |
| 533 | |
| 534 | udelay(50); |
| 535 | } |
| 536 | |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 537 | if (i == fw_timeout) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 538 | /* Release semaphores */ |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 539 | e1000_put_hw_semaphore_82571(hw); |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 540 | e_dbg("Driver can't access the NVM\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 541 | return -E1000_ERR_NVM; |
| 542 | } |
| 543 | |
| 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * e1000_put_hw_semaphore_82571 - Release hardware semaphore |
| 549 | * @hw: pointer to the HW structure |
| 550 | * |
| 551 | * Release hardware semaphore used to access the PHY or NVM |
| 552 | **/ |
| 553 | static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw) |
| 554 | { |
| 555 | u32 swsm; |
| 556 | |
| 557 | swsm = er32(SWSM); |
Dave Graham | 23a2d1b | 2009-06-08 14:28:17 +0000 | [diff] [blame] | 558 | swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 559 | ew32(SWSM, swsm); |
| 560 | } |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 561 | /** |
| 562 | * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore |
| 563 | * @hw: pointer to the HW structure |
| 564 | * |
| 565 | * Acquire the HW semaphore during reset. |
| 566 | * |
| 567 | **/ |
| 568 | static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw) |
| 569 | { |
| 570 | u32 extcnf_ctrl; |
| 571 | s32 ret_val = 0; |
| 572 | s32 i = 0; |
| 573 | |
| 574 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 575 | extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; |
| 576 | do { |
| 577 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 578 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 579 | |
| 580 | if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP) |
| 581 | break; |
| 582 | |
| 583 | extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; |
| 584 | |
| 585 | msleep(2); |
| 586 | i++; |
| 587 | } while (i < MDIO_OWNERSHIP_TIMEOUT); |
| 588 | |
| 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; |
| 594 | goto out; |
| 595 | } |
| 596 | |
| 597 | out: |
| 598 | return ret_val; |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * e1000_put_hw_semaphore_82573 - Release hardware semaphore |
| 603 | * @hw: pointer to the HW structure |
| 604 | * |
| 605 | * Release hardware semaphore used during reset. |
| 606 | * |
| 607 | **/ |
| 608 | static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw) |
| 609 | { |
| 610 | u32 extcnf_ctrl; |
| 611 | |
| 612 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 613 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; |
| 614 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 615 | } |
| 616 | |
| 617 | static DEFINE_MUTEX(swflag_mutex); |
| 618 | |
| 619 | /** |
| 620 | * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore |
| 621 | * @hw: pointer to the HW structure |
| 622 | * |
| 623 | * Acquire the HW semaphore to access the PHY or NVM. |
| 624 | * |
| 625 | **/ |
| 626 | static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw) |
| 627 | { |
| 628 | s32 ret_val; |
| 629 | |
| 630 | mutex_lock(&swflag_mutex); |
| 631 | ret_val = e1000_get_hw_semaphore_82573(hw); |
| 632 | if (ret_val) |
| 633 | mutex_unlock(&swflag_mutex); |
| 634 | return ret_val; |
| 635 | } |
| 636 | |
| 637 | /** |
| 638 | * e1000_put_hw_semaphore_82574 - Release hardware semaphore |
| 639 | * @hw: pointer to the HW structure |
| 640 | * |
| 641 | * Release hardware semaphore used to access the PHY or NVM |
| 642 | * |
| 643 | **/ |
| 644 | static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw) |
| 645 | { |
| 646 | e1000_put_hw_semaphore_82573(hw); |
| 647 | mutex_unlock(&swflag_mutex); |
| 648 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 649 | |
| 650 | /** |
| 651 | * e1000_acquire_nvm_82571 - Request for access to the EEPROM |
| 652 | * @hw: pointer to the HW structure |
| 653 | * |
| 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. |
| 658 | **/ |
| 659 | static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw) |
| 660 | { |
| 661 | s32 ret_val; |
| 662 | |
| 663 | ret_val = e1000_get_hw_semaphore_82571(hw); |
| 664 | if (ret_val) |
| 665 | return ret_val; |
| 666 | |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 667 | switch (hw->mac.type) { |
| 668 | case e1000_82573: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 669 | break; |
| 670 | default: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 671 | ret_val = e1000e_acquire_nvm(hw); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 672 | break; |
| 673 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 674 | |
| 675 | if (ret_val) |
| 676 | e1000_put_hw_semaphore_82571(hw); |
| 677 | |
| 678 | return ret_val; |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * e1000_release_nvm_82571 - Release exclusive access to EEPROM |
| 683 | * @hw: pointer to the HW structure |
| 684 | * |
| 685 | * Stop any current commands to the EEPROM and clear the EEPROM request bit. |
| 686 | **/ |
| 687 | static void e1000_release_nvm_82571(struct e1000_hw *hw) |
| 688 | { |
| 689 | e1000e_release_nvm(hw); |
| 690 | e1000_put_hw_semaphore_82571(hw); |
| 691 | } |
| 692 | |
| 693 | /** |
| 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 |
| 699 | * |
| 700 | * For non-82573 silicon, write data to EEPROM at offset using SPI interface. |
| 701 | * |
| 702 | * If e1000e_update_nvm_checksum is not called after this function, the |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 703 | * EEPROM will most likely contain an invalid checksum. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 704 | **/ |
| 705 | static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, |
| 706 | u16 *data) |
| 707 | { |
| 708 | s32 ret_val; |
| 709 | |
| 710 | switch (hw->mac.type) { |
| 711 | case e1000_82573: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 712 | case e1000_82574: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 713 | case e1000_82583: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 714 | ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data); |
| 715 | break; |
| 716 | case e1000_82571: |
| 717 | case e1000_82572: |
| 718 | ret_val = e1000e_write_nvm_spi(hw, offset, words, data); |
| 719 | break; |
| 720 | default: |
| 721 | ret_val = -E1000_ERR_NVM; |
| 722 | break; |
| 723 | } |
| 724 | |
| 725 | return ret_val; |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * e1000_update_nvm_checksum_82571 - Update EEPROM checksum |
| 730 | * @hw: pointer to the HW structure |
| 731 | * |
| 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. |
| 735 | **/ |
| 736 | static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw) |
| 737 | { |
| 738 | u32 eecd; |
| 739 | s32 ret_val; |
| 740 | u16 i; |
| 741 | |
| 742 | ret_val = e1000e_update_nvm_checksum_generic(hw); |
| 743 | if (ret_val) |
| 744 | return ret_val; |
| 745 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 746 | /* |
| 747 | * If our nvm is an EEPROM, then we're done |
| 748 | * otherwise, commit the checksum to the flash NVM. |
| 749 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 750 | if (hw->nvm.type != e1000_nvm_flash_hw) |
| 751 | return ret_val; |
| 752 | |
| 753 | /* Check for pending operations. */ |
| 754 | for (i = 0; i < E1000_FLASH_UPDATES; i++) { |
| 755 | msleep(1); |
| 756 | if ((er32(EECD) & E1000_EECD_FLUPD) == 0) |
| 757 | break; |
| 758 | } |
| 759 | |
| 760 | if (i == E1000_FLASH_UPDATES) |
| 761 | return -E1000_ERR_NVM; |
| 762 | |
| 763 | /* Reset the firmware if using STM opcode. */ |
| 764 | if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 765 | /* |
| 766 | * The enabling of and the actual reset must be done |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 767 | * in two write cycles. |
| 768 | */ |
| 769 | ew32(HICR, E1000_HICR_FW_RESET_ENABLE); |
| 770 | e1e_flush(); |
| 771 | ew32(HICR, E1000_HICR_FW_RESET); |
| 772 | } |
| 773 | |
| 774 | /* Commit the write to flash */ |
| 775 | eecd = er32(EECD) | E1000_EECD_FLUPD; |
| 776 | ew32(EECD, eecd); |
| 777 | |
| 778 | for (i = 0; i < E1000_FLASH_UPDATES; i++) { |
| 779 | msleep(1); |
| 780 | if ((er32(EECD) & E1000_EECD_FLUPD) == 0) |
| 781 | break; |
| 782 | } |
| 783 | |
| 784 | if (i == E1000_FLASH_UPDATES) |
| 785 | return -E1000_ERR_NVM; |
| 786 | |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | /** |
| 791 | * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum |
| 792 | * @hw: pointer to the HW structure |
| 793 | * |
| 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. |
| 796 | **/ |
| 797 | static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw) |
| 798 | { |
| 799 | if (hw->nvm.type == e1000_nvm_flash_hw) |
| 800 | e1000_fix_nvm_checksum_82571(hw); |
| 801 | |
| 802 | return e1000e_validate_nvm_checksum_generic(hw); |
| 803 | } |
| 804 | |
| 805 | /** |
| 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 |
| 811 | * |
| 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. |
| 815 | * |
| 816 | * If e1000e_update_nvm_checksum is not called after this function, the |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 817 | * EEPROM will most likely contain an invalid checksum. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 818 | **/ |
| 819 | static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, |
| 820 | u16 words, u16 *data) |
| 821 | { |
| 822 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | a708dd8 | 2009-11-20 23:28:37 +0000 | [diff] [blame] | 823 | u32 i, eewr = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 824 | s32 ret_val = 0; |
| 825 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 826 | /* |
| 827 | * A check for invalid values: offset too large, too many words, |
| 828 | * and not enough words. |
| 829 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 830 | if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || |
| 831 | (words == 0)) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 832 | e_dbg("nvm parameter(s) out of bounds\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 833 | return -E1000_ERR_NVM; |
| 834 | } |
| 835 | |
| 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; |
| 840 | |
| 841 | ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); |
| 842 | if (ret_val) |
| 843 | break; |
| 844 | |
| 845 | ew32(EEWR, eewr); |
| 846 | |
| 847 | ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); |
| 848 | if (ret_val) |
| 849 | break; |
| 850 | } |
| 851 | |
| 852 | return ret_val; |
| 853 | } |
| 854 | |
| 855 | /** |
| 856 | * e1000_get_cfg_done_82571 - Poll for configuration done |
| 857 | * @hw: pointer to the HW structure |
| 858 | * |
| 859 | * Reads the management control register for the config done bit to be set. |
| 860 | **/ |
| 861 | static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw) |
| 862 | { |
| 863 | s32 timeout = PHY_CFG_TIMEOUT; |
| 864 | |
| 865 | while (timeout) { |
| 866 | if (er32(EEMNGCTL) & |
| 867 | E1000_NVM_CFG_DONE_PORT_0) |
| 868 | break; |
| 869 | msleep(1); |
| 870 | timeout--; |
| 871 | } |
| 872 | if (!timeout) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 873 | e_dbg("MNG configuration cycle has not completed.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 874 | return -E1000_ERR_RESET; |
| 875 | } |
| 876 | |
| 877 | return 0; |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state |
| 882 | * @hw: pointer to the HW structure |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 883 | * @active: true to enable LPLU, false to disable |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 884 | * |
| 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. |
| 890 | **/ |
| 891 | static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active) |
| 892 | { |
| 893 | struct e1000_phy_info *phy = &hw->phy; |
| 894 | s32 ret_val; |
| 895 | u16 data; |
| 896 | |
| 897 | ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data); |
| 898 | if (ret_val) |
| 899 | return ret_val; |
| 900 | |
| 901 | if (active) { |
| 902 | data |= IGP02E1000_PM_D0_LPLU; |
| 903 | ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); |
| 904 | if (ret_val) |
| 905 | return ret_val; |
| 906 | |
| 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); |
| 911 | if (ret_val) |
| 912 | return ret_val; |
| 913 | } else { |
| 914 | data &= ~IGP02E1000_PM_D0_LPLU; |
| 915 | ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 916 | /* |
| 917 | * LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 918 | * during Dx states where the power conservation is most |
| 919 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 920 | * SmartSpeed, so performance is maintained. |
| 921 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 922 | if (phy->smart_speed == e1000_smart_speed_on) { |
| 923 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 924 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 925 | if (ret_val) |
| 926 | return ret_val; |
| 927 | |
| 928 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
| 929 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 930 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 931 | if (ret_val) |
| 932 | return ret_val; |
| 933 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
| 934 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 935 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 936 | if (ret_val) |
| 937 | return ret_val; |
| 938 | |
| 939 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 940 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 941 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 942 | if (ret_val) |
| 943 | return ret_val; |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | return 0; |
| 948 | } |
| 949 | |
| 950 | /** |
| 951 | * e1000_reset_hw_82571 - Reset hardware |
| 952 | * @hw: pointer to the HW structure |
| 953 | * |
Bruce Allan | fe40167 | 2009-11-20 23:26:05 +0000 | [diff] [blame] | 954 | * This resets the hardware into a known state. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 955 | **/ |
| 956 | static s32 e1000_reset_hw_82571(struct e1000_hw *hw) |
| 957 | { |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 958 | u32 ctrl, ctrl_ext, icr; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 959 | s32 ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 960 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 961 | /* |
| 962 | * Prevent the PCI-E bus from sticking if there is no TLP connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 963 | * on the last TLP read/write transaction when MAC is reset. |
| 964 | */ |
| 965 | ret_val = e1000e_disable_pcie_master(hw); |
| 966 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 967 | e_dbg("PCI-E Master disable polling has failed.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 968 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 969 | e_dbg("Masking off all interrupts\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 970 | ew32(IMC, 0xffffffff); |
| 971 | |
| 972 | ew32(RCTL, 0); |
| 973 | ew32(TCTL, E1000_TCTL_PSP); |
| 974 | e1e_flush(); |
| 975 | |
| 976 | msleep(10); |
| 977 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 978 | /* |
| 979 | * Must acquire the MDIO ownership before MAC reset. |
| 980 | * Ownership defaults to firmware after a reset. |
| 981 | */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 982 | switch (hw->mac.type) { |
| 983 | case e1000_82573: |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 984 | ret_val = e1000_get_hw_semaphore_82573(hw); |
| 985 | break; |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 986 | case e1000_82574: |
| 987 | case e1000_82583: |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 988 | ret_val = e1000_get_hw_semaphore_82574(hw); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 989 | break; |
| 990 | default: |
| 991 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 992 | } |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 993 | if (ret_val) |
| 994 | e_dbg("Cannot acquire MDIO ownership\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 995 | |
| 996 | ctrl = er32(CTRL); |
| 997 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 998 | e_dbg("Issuing a global reset to MAC\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 999 | ew32(CTRL, ctrl | E1000_CTRL_RST); |
| 1000 | |
Bruce Allan | 1b98c2b | 2010-11-16 19:50:14 -0800 | [diff] [blame] | 1001 | /* Must release MDIO ownership and mutex after MAC reset. */ |
| 1002 | switch (hw->mac.type) { |
| 1003 | case e1000_82574: |
| 1004 | case e1000_82583: |
| 1005 | e1000_put_hw_semaphore_82574(hw); |
| 1006 | break; |
| 1007 | default: |
| 1008 | break; |
| 1009 | } |
| 1010 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1011 | if (hw->nvm.type == e1000_nvm_flash_hw) { |
| 1012 | udelay(10); |
| 1013 | ctrl_ext = er32(CTRL_EXT); |
| 1014 | ctrl_ext |= E1000_CTRL_EXT_EE_RST; |
| 1015 | ew32(CTRL_EXT, ctrl_ext); |
| 1016 | e1e_flush(); |
| 1017 | } |
| 1018 | |
| 1019 | ret_val = e1000e_get_auto_rd_done(hw); |
| 1020 | if (ret_val) |
| 1021 | /* We don't want to continue accessing MAC registers. */ |
| 1022 | return ret_val; |
| 1023 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1024 | /* |
| 1025 | * Phy configuration from NVM just starts after EECD_AUTO_RD is set. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1026 | * Need to wait for Phy configuration completion before accessing |
| 1027 | * NVM and Phy. |
| 1028 | */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1029 | |
| 1030 | switch (hw->mac.type) { |
| 1031 | case e1000_82573: |
| 1032 | case e1000_82574: |
| 1033 | case e1000_82583: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1034 | msleep(25); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1035 | break; |
| 1036 | default: |
| 1037 | break; |
| 1038 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1039 | |
| 1040 | /* Clear any pending interrupt events. */ |
| 1041 | ew32(IMC, 0xffffffff); |
| 1042 | icr = er32(ICR); |
| 1043 | |
Bruce Allan | 1aef70e | 2010-08-19 15:48:52 -0700 | [diff] [blame] | 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); |
| 1047 | if (ret_val) |
| 1048 | return ret_val; |
Bruce Allan | 608f8a0 | 2010-01-13 02:04:58 +0000 | [diff] [blame] | 1049 | |
Bruce Allan | 1aef70e | 2010-08-19 15:48:52 -0700 | [diff] [blame] | 1050 | e1000e_set_laa_state_82571(hw, true); |
| 1051 | } |
Bill Hayes | 93ca161 | 2007-10-31 15:21:52 -0700 | [diff] [blame] | 1052 | |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 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; |
| 1056 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1057 | return 0; |
| 1058 | } |
| 1059 | |
| 1060 | /** |
| 1061 | * e1000_init_hw_82571 - Initialize hardware |
| 1062 | * @hw: pointer to the HW structure |
| 1063 | * |
| 1064 | * This inits the hardware readying it for operation. |
| 1065 | **/ |
| 1066 | static s32 e1000_init_hw_82571(struct e1000_hw *hw) |
| 1067 | { |
| 1068 | struct e1000_mac_info *mac = &hw->mac; |
| 1069 | u32 reg_data; |
| 1070 | s32 ret_val; |
Bruce Allan | a708dd8 | 2009-11-20 23:28:37 +0000 | [diff] [blame] | 1071 | u16 i, rar_count = mac->rar_entry_count; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1072 | |
| 1073 | e1000_initialize_hw_bits_82571(hw); |
| 1074 | |
| 1075 | /* Initialize identification LED */ |
| 1076 | ret_val = e1000e_id_led_init(hw); |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame] | 1077 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1078 | e_dbg("Error initializing identification LED\n"); |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame] | 1079 | /* This is not fatal and we should not stop init due to this */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1080 | |
| 1081 | /* Disabling VLAN filtering */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1082 | e_dbg("Initializing the IEEE VLAN\n"); |
Bruce Allan | caaddaf | 2009-12-01 15:46:43 +0000 | [diff] [blame] | 1083 | mac->ops.clear_vfta(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1084 | |
| 1085 | /* Setup the receive address. */ |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1086 | /* |
| 1087 | * If, however, a locally administered address was assigned to the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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. |
| 1090 | */ |
| 1091 | if (e1000e_get_laa_state_82571(hw)) |
| 1092 | rar_count--; |
| 1093 | e1000e_init_rx_addrs(hw, rar_count); |
| 1094 | |
| 1095 | /* Zero out the Multicast HASH table */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1096 | e_dbg("Zeroing the MTA\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1097 | for (i = 0; i < mac->mta_reg_count; i++) |
| 1098 | E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); |
| 1099 | |
| 1100 | /* Setup link and flow control */ |
| 1101 | ret_val = e1000_setup_link_82571(hw); |
| 1102 | |
| 1103 | /* Set the transmit descriptor write-back policy */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1104 | reg_data = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1105 | reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | |
| 1106 | E1000_TXDCTL_FULL_TX_DESC_WB | |
| 1107 | E1000_TXDCTL_COUNT_DESC; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1108 | ew32(TXDCTL(0), reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1109 | |
| 1110 | /* ...for both queues. */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1111 | switch (mac->type) { |
| 1112 | case e1000_82573: |
Bruce Allan | a65a4a0 | 2010-05-10 15:01:51 +0000 | [diff] [blame] | 1113 | e1000e_enable_tx_pkt_filtering(hw); |
| 1114 | /* fall through */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1115 | case e1000_82574: |
| 1116 | case e1000_82583: |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1117 | reg_data = er32(GCR); |
| 1118 | reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX; |
| 1119 | ew32(GCR, reg_data); |
| 1120 | break; |
| 1121 | default: |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1122 | reg_data = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1123 | reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) | |
| 1124 | E1000_TXDCTL_FULL_TX_DESC_WB | |
| 1125 | E1000_TXDCTL_COUNT_DESC; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1126 | ew32(TXDCTL(1), reg_data); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1127 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1128 | } |
| 1129 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1130 | /* |
| 1131 | * Clear all of the statistics registers (clear on read). It is |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1132 | * important that we do this after we have tried to establish link |
| 1133 | * because the symbol error count will increment wildly if there |
| 1134 | * is no link. |
| 1135 | */ |
| 1136 | e1000_clear_hw_cntrs_82571(hw); |
| 1137 | |
| 1138 | return ret_val; |
| 1139 | } |
| 1140 | |
| 1141 | /** |
| 1142 | * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits |
| 1143 | * @hw: pointer to the HW structure |
| 1144 | * |
| 1145 | * Initializes required hardware-dependent bits needed for normal operation. |
| 1146 | **/ |
| 1147 | static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) |
| 1148 | { |
| 1149 | u32 reg; |
| 1150 | |
| 1151 | /* Transmit Descriptor Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1152 | reg = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1153 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1154 | ew32(TXDCTL(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1155 | |
| 1156 | /* Transmit Descriptor Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1157 | reg = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1158 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1159 | ew32(TXDCTL(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1160 | |
| 1161 | /* Transmit Arbitration Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1162 | reg = er32(TARC(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1163 | reg &= ~(0xF << 27); /* 30:27 */ |
| 1164 | switch (hw->mac.type) { |
| 1165 | case e1000_82571: |
| 1166 | case e1000_82572: |
| 1167 | reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26); |
| 1168 | break; |
| 1169 | default: |
| 1170 | break; |
| 1171 | } |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1172 | ew32(TARC(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1173 | |
| 1174 | /* Transmit Arbitration Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1175 | reg = er32(TARC(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1176 | switch (hw->mac.type) { |
| 1177 | case e1000_82571: |
| 1178 | case e1000_82572: |
| 1179 | reg &= ~((1 << 29) | (1 << 30)); |
| 1180 | reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26); |
| 1181 | if (er32(TCTL) & E1000_TCTL_MULR) |
| 1182 | reg &= ~(1 << 28); |
| 1183 | else |
| 1184 | reg |= (1 << 28); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 1185 | ew32(TARC(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1186 | break; |
| 1187 | default: |
| 1188 | break; |
| 1189 | } |
| 1190 | |
| 1191 | /* Device Control */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1192 | switch (hw->mac.type) { |
| 1193 | case e1000_82573: |
| 1194 | case e1000_82574: |
| 1195 | case e1000_82583: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1196 | reg = er32(CTRL); |
| 1197 | reg &= ~(1 << 29); |
| 1198 | ew32(CTRL, reg); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1199 | break; |
| 1200 | default: |
| 1201 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | /* Extended Device Control */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1205 | switch (hw->mac.type) { |
| 1206 | case e1000_82573: |
| 1207 | case e1000_82574: |
| 1208 | case e1000_82583: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1209 | reg = er32(CTRL_EXT); |
| 1210 | reg &= ~(1 << 23); |
| 1211 | reg |= (1 << 22); |
| 1212 | ew32(CTRL_EXT, reg); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1213 | break; |
| 1214 | default: |
| 1215 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1216 | } |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1217 | |
Alexander Duyck | 6ea7ae1 | 2008-11-14 06:54:36 +0000 | [diff] [blame] | 1218 | if (hw->mac.type == e1000_82571) { |
| 1219 | reg = er32(PBA_ECC); |
| 1220 | reg |= E1000_PBA_ECC_CORR_EN; |
| 1221 | ew32(PBA_ECC, reg); |
| 1222 | } |
dave graham | 5df3f0e | 2009-02-10 12:51:41 +0000 | [diff] [blame] | 1223 | /* |
| 1224 | * Workaround for hardware errata. |
| 1225 | * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572 |
| 1226 | */ |
| 1227 | |
| 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); |
| 1233 | } |
| 1234 | |
Alexander Duyck | 6ea7ae1 | 2008-11-14 06:54:36 +0000 | [diff] [blame] | 1235 | |
Jesse Brandeburg | 78272bb | 2009-01-26 12:16:26 -0800 | [diff] [blame] | 1236 | /* PCI-Ex Control Registers */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1237 | switch (hw->mac.type) { |
| 1238 | case e1000_82574: |
| 1239 | case e1000_82583: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1240 | reg = er32(GCR); |
| 1241 | reg |= (1 << 22); |
| 1242 | ew32(GCR, reg); |
Jesse Brandeburg | 78272bb | 2009-01-26 12:16:26 -0800 | [diff] [blame] | 1243 | |
Bruce Allan | 84efb7b | 2009-11-20 23:26:24 +0000 | [diff] [blame] | 1244 | /* |
| 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. |
| 1250 | */ |
Jesse Brandeburg | 78272bb | 2009-01-26 12:16:26 -0800 | [diff] [blame] | 1251 | reg = er32(GCR2); |
| 1252 | reg |= 1; |
| 1253 | ew32(GCR2, reg); |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1254 | break; |
| 1255 | default: |
| 1256 | break; |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1257 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | /** |
Bruce Allan | caaddaf | 2009-12-01 15:46:43 +0000 | [diff] [blame] | 1261 | * e1000_clear_vfta_82571 - Clear VLAN filter table |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1262 | * @hw: pointer to the HW structure |
| 1263 | * |
| 1264 | * Clears the register array which contains the VLAN filter table by |
| 1265 | * setting all the values to 0. |
| 1266 | **/ |
Bruce Allan | caaddaf | 2009-12-01 15:46:43 +0000 | [diff] [blame] | 1267 | static void e1000_clear_vfta_82571(struct e1000_hw *hw) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1268 | { |
| 1269 | u32 offset; |
| 1270 | u32 vfta_value = 0; |
| 1271 | u32 vfta_offset = 0; |
| 1272 | u32 vfta_bit_in_reg = 0; |
| 1273 | |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1274 | switch (hw->mac.type) { |
| 1275 | case e1000_82573: |
| 1276 | case e1000_82574: |
| 1277 | case e1000_82583: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1278 | if (hw->mng_cookie.vlan_id != 0) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1279 | /* |
| 1280 | * The VFTA is a 4096b bit-field, each identifying |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 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. |
| 1285 | */ |
| 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); |
| 1291 | } |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1292 | break; |
| 1293 | default: |
| 1294 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1295 | } |
| 1296 | for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1297 | /* |
| 1298 | * If the offset we want to clear is the same offset of the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1299 | * manageability VLAN ID, then clear all bits except that of |
| 1300 | * the manageability unit. |
| 1301 | */ |
| 1302 | vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0; |
| 1303 | E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value); |
| 1304 | e1e_flush(); |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | /** |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1309 | * e1000_check_mng_mode_82574 - Check manageability is enabled |
| 1310 | * @hw: pointer to the HW structure |
| 1311 | * |
| 1312 | * Reads the NVM Initialization Control Word 2 and returns true |
| 1313 | * (>0) if any manageability is enabled, else false (0). |
| 1314 | **/ |
| 1315 | static bool e1000_check_mng_mode_82574(struct e1000_hw *hw) |
| 1316 | { |
| 1317 | u16 data; |
| 1318 | |
| 1319 | e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); |
| 1320 | return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0; |
| 1321 | } |
| 1322 | |
| 1323 | /** |
| 1324 | * e1000_led_on_82574 - Turn LED on |
| 1325 | * @hw: pointer to the HW structure |
| 1326 | * |
| 1327 | * Turn LED on. |
| 1328 | **/ |
| 1329 | static s32 e1000_led_on_82574(struct e1000_hw *hw) |
| 1330 | { |
| 1331 | u32 ctrl; |
| 1332 | u32 i; |
| 1333 | |
| 1334 | ctrl = hw->mac.ledctl_mode2; |
| 1335 | if (!(E1000_STATUS_LU & er32(STATUS))) { |
| 1336 | /* |
| 1337 | * If no link, then turn LED on by setting the invert bit |
| 1338 | * for each LED that's "on" (0x0E) in ledctl_mode2. |
| 1339 | */ |
| 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)); |
| 1344 | } |
| 1345 | ew32(LEDCTL, ctrl); |
| 1346 | |
| 1347 | return 0; |
| 1348 | } |
| 1349 | |
| 1350 | /** |
Carolyn Wyborny | ff10e13 | 2010-10-28 00:59:53 +0000 | [diff] [blame] | 1351 | * e1000_check_phy_82574 - check 82574 phy hung state |
| 1352 | * @hw: pointer to the HW structure |
| 1353 | * |
| 1354 | * Returns whether phy is hung or not |
| 1355 | **/ |
| 1356 | bool e1000_check_phy_82574(struct e1000_hw *hw) |
| 1357 | { |
| 1358 | u16 status_1kbt = 0; |
| 1359 | u16 receive_errors = 0; |
| 1360 | bool phy_hung = false; |
| 1361 | s32 ret_val = 0; |
| 1362 | |
| 1363 | /* |
| 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. |
| 1366 | */ |
| 1367 | ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors); |
| 1368 | |
| 1369 | if (ret_val) |
| 1370 | goto out; |
| 1371 | if (receive_errors == E1000_RECEIVE_ERROR_MAX) { |
| 1372 | ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt); |
| 1373 | if (ret_val) |
| 1374 | goto out; |
| 1375 | if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) == |
| 1376 | E1000_IDLE_ERROR_COUNT_MASK) |
| 1377 | phy_hung = true; |
| 1378 | } |
| 1379 | out: |
| 1380 | return phy_hung; |
| 1381 | } |
| 1382 | |
| 1383 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1384 | * e1000_setup_link_82571 - Setup flow control and link settings |
| 1385 | * @hw: pointer to the HW structure |
| 1386 | * |
| 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. |
| 1392 | **/ |
| 1393 | static s32 e1000_setup_link_82571(struct e1000_hw *hw) |
| 1394 | { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1395 | /* |
| 1396 | * 82573 does not have a word in the NVM to determine |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1397 | * the default flow control setting, so we explicitly |
| 1398 | * set it to full. |
| 1399 | */ |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1400 | switch (hw->mac.type) { |
| 1401 | case e1000_82573: |
| 1402 | case e1000_82574: |
| 1403 | case e1000_82583: |
| 1404 | if (hw->fc.requested_mode == e1000_fc_default) |
| 1405 | hw->fc.requested_mode = e1000_fc_full; |
| 1406 | break; |
| 1407 | default: |
| 1408 | break; |
| 1409 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1410 | |
| 1411 | return e1000e_setup_link(hw); |
| 1412 | } |
| 1413 | |
| 1414 | /** |
| 1415 | * e1000_setup_copper_link_82571 - Configure copper link settings |
| 1416 | * @hw: pointer to the HW structure |
| 1417 | * |
| 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. |
| 1421 | **/ |
| 1422 | static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) |
| 1423 | { |
| 1424 | u32 ctrl; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1425 | s32 ret_val; |
| 1426 | |
| 1427 | ctrl = er32(CTRL); |
| 1428 | ctrl |= E1000_CTRL_SLU; |
| 1429 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
| 1430 | ew32(CTRL, ctrl); |
| 1431 | |
| 1432 | switch (hw->phy.type) { |
| 1433 | case e1000_phy_m88: |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1434 | case e1000_phy_bm: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1435 | ret_val = e1000e_copper_link_setup_m88(hw); |
| 1436 | break; |
| 1437 | case e1000_phy_igp_2: |
| 1438 | ret_val = e1000e_copper_link_setup_igp(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1439 | break; |
| 1440 | default: |
| 1441 | return -E1000_ERR_PHY; |
| 1442 | break; |
| 1443 | } |
| 1444 | |
| 1445 | if (ret_val) |
| 1446 | return ret_val; |
| 1447 | |
| 1448 | ret_val = e1000e_setup_copper_link(hw); |
| 1449 | |
| 1450 | return ret_val; |
| 1451 | } |
| 1452 | |
| 1453 | /** |
| 1454 | * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes |
| 1455 | * @hw: pointer to the HW structure |
| 1456 | * |
| 1457 | * Configures collision distance and flow control for fiber and serdes links. |
| 1458 | * Upon successful setup, poll for link. |
| 1459 | **/ |
| 1460 | static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw) |
| 1461 | { |
| 1462 | switch (hw->mac.type) { |
| 1463 | case e1000_82571: |
| 1464 | case e1000_82572: |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1465 | /* |
| 1466 | * If SerDes loopback mode is entered, there is no form |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1467 | * of reset to take the adapter out of that mode. So we |
| 1468 | * have to explicitly take the adapter out of loopback |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 1469 | * mode. This prevents drivers from twiddling their thumbs |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1470 | * if another tool failed to take it out of loopback mode. |
| 1471 | */ |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1472 | ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1473 | break; |
| 1474 | default: |
| 1475 | break; |
| 1476 | } |
| 1477 | |
| 1478 | return e1000e_setup_fiber_serdes_link(hw); |
| 1479 | } |
| 1480 | |
| 1481 | /** |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1482 | * e1000_check_for_serdes_link_82571 - Check for link (Serdes) |
| 1483 | * @hw: pointer to the HW structure |
| 1484 | * |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1485 | * Reports the link state as up or down. |
| 1486 | * |
| 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. |
| 1491 | * |
| 1492 | * The link state is represented internally here by 4 states: |
| 1493 | * |
| 1494 | * 1) down |
| 1495 | * 2) autoneg_progress |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 1496 | * 3) autoneg_complete (the link successfully autonegotiated) |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1497 | * 4) forced_up (the link has been forced up, it did not autonegotiate) |
| 1498 | * |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1499 | **/ |
Hannes Eder | f637011 | 2009-02-14 11:32:25 +0000 | [diff] [blame] | 1500 | static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw) |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1501 | { |
| 1502 | struct e1000_mac_info *mac = &hw->mac; |
| 1503 | u32 rxcw; |
| 1504 | u32 ctrl; |
| 1505 | u32 status; |
| 1506 | s32 ret_val = 0; |
| 1507 | |
| 1508 | ctrl = er32(CTRL); |
| 1509 | status = er32(STATUS); |
| 1510 | rxcw = er32(RXCW); |
| 1511 | |
| 1512 | if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) { |
| 1513 | |
| 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)) { |
| 1518 | /* |
| 1519 | * We have lost link, retry autoneg before |
| 1520 | * reporting link failure |
| 1521 | */ |
| 1522 | mac->serdes_link_state = |
| 1523 | e1000_serdes_link_autoneg_progress; |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1524 | mac->serdes_has_link = false; |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1525 | e_dbg("AN_UP -> AN_PROG\n"); |
Bruce Allan | a82a14f | 2010-11-24 06:01:20 +0000 | [diff] [blame^] | 1526 | } else { |
| 1527 | mac->serdes_has_link = true; |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1528 | } |
Bruce Allan | a82a14f | 2010-11-24 06:01:20 +0000 | [diff] [blame^] | 1529 | break; |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1530 | |
| 1531 | case e1000_serdes_link_forced_up: |
| 1532 | /* |
| 1533 | * If we are receiving /C/ ordered sets, re-enable |
| 1534 | * auto-negotiation in the TXCW register and disable |
| 1535 | * forced link in the Device Control register in an |
| 1536 | * attempt to auto-negotiate with our link partner. |
Bruce Allan | d478eb4 | 2010-11-16 19:50:13 -0800 | [diff] [blame] | 1537 | * If the partner code word is null, stop forcing |
| 1538 | * and restart auto negotiation. |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1539 | */ |
Bruce Allan | d478eb4 | 2010-11-16 19:50:13 -0800 | [diff] [blame] | 1540 | if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) { |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1541 | /* Enable autoneg, and unforce link up */ |
| 1542 | ew32(TXCW, mac->txcw); |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1543 | ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1544 | mac->serdes_link_state = |
| 1545 | e1000_serdes_link_autoneg_progress; |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1546 | mac->serdes_has_link = false; |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1547 | e_dbg("FORCED_UP -> AN_PROG\n"); |
Bruce Allan | a82a14f | 2010-11-24 06:01:20 +0000 | [diff] [blame^] | 1548 | } else { |
| 1549 | mac->serdes_has_link = true; |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1550 | } |
| 1551 | break; |
| 1552 | |
| 1553 | case e1000_serdes_link_autoneg_progress: |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1554 | if (rxcw & E1000_RXCW_C) { |
| 1555 | /* |
| 1556 | * We received /C/ ordered sets, meaning the |
| 1557 | * link partner has autonegotiated, and we can |
| 1558 | * trust the Link Up (LU) status bit. |
| 1559 | */ |
| 1560 | if (status & E1000_STATUS_LU) { |
| 1561 | mac->serdes_link_state = |
| 1562 | e1000_serdes_link_autoneg_complete; |
| 1563 | e_dbg("AN_PROG -> AN_UP\n"); |
| 1564 | mac->serdes_has_link = true; |
| 1565 | } else { |
| 1566 | /* Autoneg completed, but failed. */ |
| 1567 | mac->serdes_link_state = |
| 1568 | e1000_serdes_link_down; |
| 1569 | e_dbg("AN_PROG -> DOWN\n"); |
| 1570 | } |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1571 | } else { |
| 1572 | /* |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1573 | * The link partner did not autoneg. |
| 1574 | * Force link up and full duplex, and change |
| 1575 | * state to forced. |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1576 | */ |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1577 | ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1578 | ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD); |
| 1579 | ew32(CTRL, ctrl); |
| 1580 | |
| 1581 | /* Configure Flow Control after link up. */ |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1582 | ret_val = e1000e_config_fc_after_link_up(hw); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1583 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1584 | e_dbg("Error config flow control\n"); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1585 | break; |
| 1586 | } |
| 1587 | mac->serdes_link_state = |
| 1588 | e1000_serdes_link_forced_up; |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1589 | mac->serdes_has_link = true; |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1590 | e_dbg("AN_PROG -> FORCED_UP\n"); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1591 | } |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1592 | break; |
| 1593 | |
| 1594 | case e1000_serdes_link_down: |
| 1595 | default: |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1596 | /* |
| 1597 | * The link was down but the receiver has now gained |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1598 | * valid sync, so lets see if we can bring the link |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1599 | * up. |
| 1600 | */ |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1601 | ew32(TXCW, mac->txcw); |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1602 | ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1603 | mac->serdes_link_state = |
| 1604 | e1000_serdes_link_autoneg_progress; |
Bruce Allan | a82a14f | 2010-11-24 06:01:20 +0000 | [diff] [blame^] | 1605 | mac->serdes_has_link = false; |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1606 | e_dbg("DOWN -> AN_PROG\n"); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1607 | break; |
| 1608 | } |
| 1609 | } else { |
| 1610 | if (!(rxcw & E1000_RXCW_SYNCH)) { |
| 1611 | mac->serdes_has_link = false; |
| 1612 | mac->serdes_link_state = e1000_serdes_link_down; |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1613 | e_dbg("ANYSTATE -> DOWN\n"); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1614 | } else { |
| 1615 | /* |
Bruce Allan | 1a40d5c | 2009-12-01 15:49:51 +0000 | [diff] [blame] | 1616 | * We have sync, and can tolerate one invalid (IV) |
| 1617 | * codeword before declaring link down, so reread |
| 1618 | * to look again. |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1619 | */ |
| 1620 | udelay(10); |
| 1621 | rxcw = er32(RXCW); |
| 1622 | if (rxcw & E1000_RXCW_IV) { |
| 1623 | mac->serdes_link_state = e1000_serdes_link_down; |
| 1624 | mac->serdes_has_link = false; |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1625 | e_dbg("ANYSTATE -> DOWN\n"); |
dave graham | c952337 | 2009-02-10 12:52:28 +0000 | [diff] [blame] | 1626 | } |
| 1627 | } |
| 1628 | } |
| 1629 | |
| 1630 | return ret_val; |
| 1631 | } |
| 1632 | |
| 1633 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1634 | * e1000_valid_led_default_82571 - Verify a valid default LED config |
| 1635 | * @hw: pointer to the HW structure |
| 1636 | * @data: pointer to the NVM (EEPROM) |
| 1637 | * |
| 1638 | * Read the EEPROM for the current default LED configuration. If the |
| 1639 | * LED configuration is not valid, set to a valid LED configuration. |
| 1640 | **/ |
| 1641 | static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data) |
| 1642 | { |
| 1643 | s32 ret_val; |
| 1644 | |
| 1645 | ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); |
| 1646 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 1647 | e_dbg("NVM Read Error\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1648 | return ret_val; |
| 1649 | } |
| 1650 | |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 1651 | switch (hw->mac.type) { |
| 1652 | case e1000_82573: |
| 1653 | case e1000_82574: |
| 1654 | case e1000_82583: |
| 1655 | if (*data == ID_LED_RESERVED_F746) |
| 1656 | *data = ID_LED_DEFAULT_82573; |
| 1657 | break; |
| 1658 | default: |
| 1659 | if (*data == ID_LED_RESERVED_0000 || |
| 1660 | *data == ID_LED_RESERVED_FFFF) |
| 1661 | *data = ID_LED_DEFAULT; |
| 1662 | break; |
| 1663 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1664 | |
| 1665 | return 0; |
| 1666 | } |
| 1667 | |
| 1668 | /** |
| 1669 | * e1000e_get_laa_state_82571 - Get locally administered address state |
| 1670 | * @hw: pointer to the HW structure |
| 1671 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 1672 | * Retrieve and return the current locally administered address state. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1673 | **/ |
| 1674 | bool e1000e_get_laa_state_82571(struct e1000_hw *hw) |
| 1675 | { |
| 1676 | if (hw->mac.type != e1000_82571) |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 1677 | return false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1678 | |
| 1679 | return hw->dev_spec.e82571.laa_is_present; |
| 1680 | } |
| 1681 | |
| 1682 | /** |
| 1683 | * e1000e_set_laa_state_82571 - Set locally administered address state |
| 1684 | * @hw: pointer to the HW structure |
| 1685 | * @state: enable/disable locally administered address |
| 1686 | * |
Bruce Allan | 5ff5b66 | 2009-12-01 15:51:11 +0000 | [diff] [blame] | 1687 | * Enable/Disable the current locally administered address state. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1688 | **/ |
| 1689 | void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state) |
| 1690 | { |
| 1691 | if (hw->mac.type != e1000_82571) |
| 1692 | return; |
| 1693 | |
| 1694 | hw->dev_spec.e82571.laa_is_present = state; |
| 1695 | |
| 1696 | /* If workaround is activated... */ |
| 1697 | if (state) |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1698 | /* |
| 1699 | * Hold a copy of the LAA in RAR[14] This is done so that |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1700 | * between the time RAR[0] gets clobbered and the time it |
| 1701 | * gets fixed, the actual LAA is in one of the RARs and no |
| 1702 | * incoming packets directed to this port are dropped. |
| 1703 | * Eventually the LAA will be in RAR[0] and RAR[14]. |
| 1704 | */ |
| 1705 | e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1); |
| 1706 | } |
| 1707 | |
| 1708 | /** |
| 1709 | * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum |
| 1710 | * @hw: pointer to the HW structure |
| 1711 | * |
| 1712 | * Verifies that the EEPROM has completed the update. After updating the |
| 1713 | * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If |
| 1714 | * the checksum fix is not implemented, we need to set the bit and update |
| 1715 | * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect, |
| 1716 | * we need to return bad checksum. |
| 1717 | **/ |
| 1718 | static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) |
| 1719 | { |
| 1720 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 1721 | s32 ret_val; |
| 1722 | u16 data; |
| 1723 | |
| 1724 | if (nvm->type != e1000_nvm_flash_hw) |
| 1725 | return 0; |
| 1726 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1727 | /* |
| 1728 | * Check bit 4 of word 10h. If it is 0, firmware is done updating |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1729 | * 10h-12h. Checksum may need to be fixed. |
| 1730 | */ |
| 1731 | ret_val = e1000_read_nvm(hw, 0x10, 1, &data); |
| 1732 | if (ret_val) |
| 1733 | return ret_val; |
| 1734 | |
| 1735 | if (!(data & 0x10)) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1736 | /* |
| 1737 | * Read 0x23 and check bit 15. This bit is a 1 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1738 | * when the checksum has already been fixed. If |
| 1739 | * the checksum is still wrong and this bit is a |
| 1740 | * 1, we need to return bad checksum. Otherwise, |
| 1741 | * we need to set this bit to a 1 and update the |
| 1742 | * checksum. |
| 1743 | */ |
| 1744 | ret_val = e1000_read_nvm(hw, 0x23, 1, &data); |
| 1745 | if (ret_val) |
| 1746 | return ret_val; |
| 1747 | |
| 1748 | if (!(data & 0x8000)) { |
| 1749 | data |= 0x8000; |
| 1750 | ret_val = e1000_write_nvm(hw, 0x23, 1, &data); |
| 1751 | if (ret_val) |
| 1752 | return ret_val; |
| 1753 | ret_val = e1000e_update_nvm_checksum(hw); |
| 1754 | } |
| 1755 | } |
| 1756 | |
| 1757 | return 0; |
| 1758 | } |
| 1759 | |
| 1760 | /** |
Bruce Allan | 608f8a0 | 2010-01-13 02:04:58 +0000 | [diff] [blame] | 1761 | * e1000_read_mac_addr_82571 - Read device MAC address |
| 1762 | * @hw: pointer to the HW structure |
| 1763 | **/ |
| 1764 | static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw) |
| 1765 | { |
| 1766 | s32 ret_val = 0; |
| 1767 | |
Bruce Allan | 1aef70e | 2010-08-19 15:48:52 -0700 | [diff] [blame] | 1768 | if (hw->mac.type == e1000_82571) { |
| 1769 | /* |
| 1770 | * If there's an alternate MAC address place it in RAR0 |
| 1771 | * so that it will override the Si installed default perm |
| 1772 | * address. |
| 1773 | */ |
| 1774 | ret_val = e1000_check_alt_mac_addr_generic(hw); |
| 1775 | if (ret_val) |
| 1776 | goto out; |
| 1777 | } |
Bruce Allan | 608f8a0 | 2010-01-13 02:04:58 +0000 | [diff] [blame] | 1778 | |
| 1779 | ret_val = e1000_read_mac_addr_generic(hw); |
| 1780 | |
| 1781 | out: |
| 1782 | return ret_val; |
| 1783 | } |
| 1784 | |
| 1785 | /** |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 1786 | * e1000_power_down_phy_copper_82571 - Remove link during PHY power down |
| 1787 | * @hw: pointer to the HW structure |
| 1788 | * |
| 1789 | * In the case of a PHY power down to save power, or to turn off link during a |
| 1790 | * driver unload, or wake on lan is not enabled, remove the link. |
| 1791 | **/ |
| 1792 | static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw) |
| 1793 | { |
| 1794 | struct e1000_phy_info *phy = &hw->phy; |
| 1795 | struct e1000_mac_info *mac = &hw->mac; |
| 1796 | |
| 1797 | if (!(phy->ops.check_reset_block)) |
| 1798 | return; |
| 1799 | |
| 1800 | /* If the management interface is not enabled, then power down */ |
| 1801 | if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw))) |
| 1802 | e1000_power_down_phy_copper(hw); |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 1803 | } |
| 1804 | |
| 1805 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1806 | * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters |
| 1807 | * @hw: pointer to the HW structure |
| 1808 | * |
| 1809 | * Clears the hardware counters by reading the counter registers. |
| 1810 | **/ |
| 1811 | static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) |
| 1812 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1813 | e1000e_clear_hw_cntrs_base(hw); |
| 1814 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1815 | er32(PRC64); |
| 1816 | er32(PRC127); |
| 1817 | er32(PRC255); |
| 1818 | er32(PRC511); |
| 1819 | er32(PRC1023); |
| 1820 | er32(PRC1522); |
| 1821 | er32(PTC64); |
| 1822 | er32(PTC127); |
| 1823 | er32(PTC255); |
| 1824 | er32(PTC511); |
| 1825 | er32(PTC1023); |
| 1826 | er32(PTC1522); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1827 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1828 | er32(ALGNERRC); |
| 1829 | er32(RXERRC); |
| 1830 | er32(TNCRS); |
| 1831 | er32(CEXTERR); |
| 1832 | er32(TSCTC); |
| 1833 | er32(TSCTFC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1834 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1835 | er32(MGTPRC); |
| 1836 | er32(MGTPDC); |
| 1837 | er32(MGTPTC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1838 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1839 | er32(IAC); |
| 1840 | er32(ICRXOC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1841 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 1842 | er32(ICRXPTC); |
| 1843 | er32(ICRXATC); |
| 1844 | er32(ICTXPTC); |
| 1845 | er32(ICTXATC); |
| 1846 | er32(ICTXQEC); |
| 1847 | er32(ICTXQMTC); |
| 1848 | er32(ICRXDMTC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | static struct e1000_mac_operations e82571_mac_ops = { |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1852 | /* .check_mng_mode: mac type dependent */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1853 | /* .check_for_link: media type dependent */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1854 | .id_led_init = e1000e_id_led_init, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1855 | .cleanup_led = e1000e_cleanup_led_generic, |
| 1856 | .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, |
| 1857 | .get_bus_info = e1000e_get_bus_info_pcie, |
Bruce Allan | f4d2dd4 | 2010-01-13 02:05:18 +0000 | [diff] [blame] | 1858 | .set_lan_id = e1000_set_lan_id_multi_port_pcie, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1859 | /* .get_link_up_info: media type dependent */ |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1860 | /* .led_on: mac type dependent */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1861 | .led_off = e1000e_led_off_generic, |
Bruce Allan | ab8932f | 2010-01-13 02:05:38 +0000 | [diff] [blame] | 1862 | .update_mc_addr_list = e1000e_update_mc_addr_list_generic, |
Bruce Allan | caaddaf | 2009-12-01 15:46:43 +0000 | [diff] [blame] | 1863 | .write_vfta = e1000_write_vfta_generic, |
| 1864 | .clear_vfta = e1000_clear_vfta_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1865 | .reset_hw = e1000_reset_hw_82571, |
| 1866 | .init_hw = e1000_init_hw_82571, |
| 1867 | .setup_link = e1000_setup_link_82571, |
| 1868 | /* .setup_physical_interface: media type dependent */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1869 | .setup_led = e1000e_setup_led_generic, |
Bruce Allan | 608f8a0 | 2010-01-13 02:04:58 +0000 | [diff] [blame] | 1870 | .read_mac_addr = e1000_read_mac_addr_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1871 | }; |
| 1872 | |
| 1873 | static struct e1000_phy_operations e82_phy_ops_igp = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1874 | .acquire = e1000_get_hw_semaphore_82571, |
Bruce Allan | 94e5b65 | 2009-12-02 17:02:14 +0000 | [diff] [blame] | 1875 | .check_polarity = e1000_check_polarity_igp, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1876 | .check_reset_block = e1000e_check_reset_block_generic, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1877 | .commit = NULL, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1878 | .force_speed_duplex = e1000e_phy_force_speed_duplex_igp, |
| 1879 | .get_cfg_done = e1000_get_cfg_done_82571, |
| 1880 | .get_cable_length = e1000e_get_cable_length_igp_2, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1881 | .get_info = e1000e_get_phy_info_igp, |
| 1882 | .read_reg = e1000e_read_phy_reg_igp, |
| 1883 | .release = e1000_put_hw_semaphore_82571, |
| 1884 | .reset = e1000e_phy_hw_reset_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1885 | .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, |
| 1886 | .set_d3_lplu_state = e1000e_set_d3_lplu_state, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1887 | .write_reg = e1000e_write_phy_reg_igp, |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1888 | .cfg_on_link_up = NULL, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1889 | }; |
| 1890 | |
| 1891 | static struct e1000_phy_operations e82_phy_ops_m88 = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1892 | .acquire = e1000_get_hw_semaphore_82571, |
Bruce Allan | 94e5b65 | 2009-12-02 17:02:14 +0000 | [diff] [blame] | 1893 | .check_polarity = e1000_check_polarity_m88, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1894 | .check_reset_block = e1000e_check_reset_block_generic, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1895 | .commit = e1000e_phy_sw_reset, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1896 | .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, |
| 1897 | .get_cfg_done = e1000e_get_cfg_done, |
| 1898 | .get_cable_length = e1000e_get_cable_length_m88, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1899 | .get_info = e1000e_get_phy_info_m88, |
| 1900 | .read_reg = e1000e_read_phy_reg_m88, |
| 1901 | .release = e1000_put_hw_semaphore_82571, |
| 1902 | .reset = e1000e_phy_hw_reset_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1903 | .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, |
| 1904 | .set_d3_lplu_state = e1000e_set_d3_lplu_state, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1905 | .write_reg = e1000e_write_phy_reg_m88, |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1906 | .cfg_on_link_up = NULL, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1907 | }; |
| 1908 | |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1909 | static struct e1000_phy_operations e82_phy_ops_bm = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1910 | .acquire = e1000_get_hw_semaphore_82571, |
Bruce Allan | 94e5b65 | 2009-12-02 17:02:14 +0000 | [diff] [blame] | 1911 | .check_polarity = e1000_check_polarity_m88, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1912 | .check_reset_block = e1000e_check_reset_block_generic, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1913 | .commit = e1000e_phy_sw_reset, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1914 | .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, |
| 1915 | .get_cfg_done = e1000e_get_cfg_done, |
| 1916 | .get_cable_length = e1000e_get_cable_length_m88, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1917 | .get_info = e1000e_get_phy_info_m88, |
| 1918 | .read_reg = e1000e_read_phy_reg_bm2, |
| 1919 | .release = e1000_put_hw_semaphore_82571, |
| 1920 | .reset = e1000e_phy_hw_reset_generic, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1921 | .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, |
| 1922 | .set_d3_lplu_state = e1000e_set_d3_lplu_state, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1923 | .write_reg = e1000e_write_phy_reg_bm2, |
Bruce Allan | 75eb0fa | 2008-11-21 16:53:51 -0800 | [diff] [blame] | 1924 | .cfg_on_link_up = NULL, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1925 | }; |
| 1926 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1927 | static struct e1000_nvm_operations e82571_nvm_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1928 | .acquire = e1000_acquire_nvm_82571, |
| 1929 | .read = e1000e_read_nvm_eerd, |
| 1930 | .release = e1000_release_nvm_82571, |
| 1931 | .update = e1000_update_nvm_checksum_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1932 | .valid_led_default = e1000_valid_led_default_82571, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1933 | .validate = e1000_validate_nvm_checksum_82571, |
| 1934 | .write = e1000_write_nvm_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1935 | }; |
| 1936 | |
| 1937 | struct e1000_info e1000_82571_info = { |
| 1938 | .mac = e1000_82571, |
| 1939 | .flags = FLAG_HAS_HW_VLAN_FILTER |
| 1940 | | FLAG_HAS_JUMBO_FRAMES |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1941 | | FLAG_HAS_WOL |
| 1942 | | FLAG_APME_IN_CTRL3 |
| 1943 | | FLAG_RX_CSUM_ENABLED |
| 1944 | | FLAG_HAS_CTRLEXT_ON_LOAD |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1945 | | FLAG_HAS_SMART_POWER_DOWN |
| 1946 | | FLAG_RESET_OVERWRITES_LAA /* errata */ |
| 1947 | | FLAG_TARC_SPEED_MODE_BIT /* errata */ |
| 1948 | | FLAG_APME_CHECK_PORT_B, |
Jesse Brandeburg | 3a3b758 | 2010-09-29 21:38:49 +0000 | [diff] [blame] | 1949 | .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ |
| 1950 | | FLAG2_DMA_BURST, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1951 | .pba = 38, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 1952 | .max_hw_frame_size = DEFAULT_JUMBO, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 1953 | .get_variants = e1000_get_variants_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1954 | .mac_ops = &e82571_mac_ops, |
| 1955 | .phy_ops = &e82_phy_ops_igp, |
| 1956 | .nvm_ops = &e82571_nvm_ops, |
| 1957 | }; |
| 1958 | |
| 1959 | struct e1000_info e1000_82572_info = { |
| 1960 | .mac = e1000_82572, |
| 1961 | .flags = FLAG_HAS_HW_VLAN_FILTER |
| 1962 | | FLAG_HAS_JUMBO_FRAMES |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1963 | | FLAG_HAS_WOL |
| 1964 | | FLAG_APME_IN_CTRL3 |
| 1965 | | FLAG_RX_CSUM_ENABLED |
| 1966 | | FLAG_HAS_CTRLEXT_ON_LOAD |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1967 | | FLAG_TARC_SPEED_MODE_BIT, /* errata */ |
Jesse Brandeburg | 3a3b758 | 2010-09-29 21:38:49 +0000 | [diff] [blame] | 1968 | .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ |
| 1969 | | FLAG2_DMA_BURST, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1970 | .pba = 38, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 1971 | .max_hw_frame_size = DEFAULT_JUMBO, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 1972 | .get_variants = e1000_get_variants_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1973 | .mac_ops = &e82571_mac_ops, |
| 1974 | .phy_ops = &e82_phy_ops_igp, |
| 1975 | .nvm_ops = &e82571_nvm_ops, |
| 1976 | }; |
| 1977 | |
| 1978 | struct e1000_info e1000_82573_info = { |
| 1979 | .mac = e1000_82573, |
| 1980 | .flags = FLAG_HAS_HW_VLAN_FILTER |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1981 | | FLAG_HAS_WOL |
| 1982 | | FLAG_APME_IN_CTRL3 |
| 1983 | | FLAG_RX_CSUM_ENABLED |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1984 | | FLAG_HAS_SMART_POWER_DOWN |
| 1985 | | FLAG_HAS_AMT |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1986 | | FLAG_HAS_SWSM_ON_LOAD, |
Bruce Allan | 19833b5 | 2010-08-19 15:48:30 -0700 | [diff] [blame] | 1987 | .flags2 = FLAG2_DISABLE_ASPM_L1, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1988 | .pba = 20, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 1989 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 1990 | .get_variants = e1000_get_variants_82571, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1991 | .mac_ops = &e82571_mac_ops, |
| 1992 | .phy_ops = &e82_phy_ops_m88, |
Auke Kok | 31f8c4f | 2008-02-21 15:10:47 -0800 | [diff] [blame] | 1993 | .nvm_ops = &e82571_nvm_ops, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1994 | }; |
| 1995 | |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1996 | struct e1000_info e1000_82574_info = { |
| 1997 | .mac = e1000_82574, |
| 1998 | .flags = FLAG_HAS_HW_VLAN_FILTER |
| 1999 | | FLAG_HAS_MSIX |
| 2000 | | FLAG_HAS_JUMBO_FRAMES |
| 2001 | | FLAG_HAS_WOL |
| 2002 | | FLAG_APME_IN_CTRL3 |
| 2003 | | FLAG_RX_CSUM_ENABLED |
| 2004 | | FLAG_HAS_SMART_POWER_DOWN |
| 2005 | | FLAG_HAS_AMT |
| 2006 | | FLAG_HAS_CTRLEXT_ON_LOAD, |
Carolyn Wyborny | ff10e13 | 2010-10-28 00:59:53 +0000 | [diff] [blame] | 2007 | .flags2 = FLAG2_CHECK_PHY_HANG, |
Alexander Duyck | edf15c1 | 2010-05-04 22:25:42 +0000 | [diff] [blame] | 2008 | .pba = 36, |
Alexander Duyck | a825e00 | 2009-10-02 12:30:42 +0000 | [diff] [blame] | 2009 | .max_hw_frame_size = DEFAULT_JUMBO, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 2010 | .get_variants = e1000_get_variants_82571, |
| 2011 | .mac_ops = &e82571_mac_ops, |
| 2012 | .phy_ops = &e82_phy_ops_bm, |
| 2013 | .nvm_ops = &e82571_nvm_ops, |
| 2014 | }; |
| 2015 | |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 2016 | struct e1000_info e1000_82583_info = { |
| 2017 | .mac = e1000_82583, |
| 2018 | .flags = FLAG_HAS_HW_VLAN_FILTER |
| 2019 | | FLAG_HAS_WOL |
| 2020 | | FLAG_APME_IN_CTRL3 |
| 2021 | | FLAG_RX_CSUM_ENABLED |
| 2022 | | FLAG_HAS_SMART_POWER_DOWN |
| 2023 | | FLAG_HAS_AMT |
| 2024 | | FLAG_HAS_CTRLEXT_ON_LOAD, |
Alexander Duyck | edf15c1 | 2010-05-04 22:25:42 +0000 | [diff] [blame] | 2025 | .pba = 36, |
Alexander Duyck | a825e00 | 2009-10-02 12:30:42 +0000 | [diff] [blame] | 2026 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
Alexander Duyck | 8c81c9c | 2009-03-19 01:12:27 +0000 | [diff] [blame] | 2027 | .get_variants = e1000_get_variants_82571, |
| 2028 | .mac_ops = &e82571_mac_ops, |
| 2029 | .phy_ops = &e82_phy_ops_bm, |
| 2030 | .nvm_ops = &e82571_nvm_ops, |
| 2031 | }; |
| 2032 | |