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