blob: 6942e2f86eac101c80193cfa79597c8c5bf2adde [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allan451152d2010-06-16 13:28:11 +00004 Copyright(c) 1999 - 2010 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
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 Allan16059272008-11-21 16:51:06 -080031 * 82571EB Gigabit Ethernet Controller (Copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -070032 * 82571EB Gigabit Ethernet Controller (Fiber)
Bruce Allanad680762008-03-28 09:15:03 -070033 * 82571EB Dual Port Gigabit Mezzanine Adapter
34 * 82571EB Quad Port Gigabit Mezzanine Adapter
35 * 82571PT Gigabit PT Quad Port Server ExpressModule
Auke Kokbc7f75f2007-09-17 12:30:59 -070036 * 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 Allan4662e822008-08-26 18:37:06 -070042 * 82574L Gigabit Network Connection
Alexander Duyck8c81c9c2009-03-19 01:12:27 +000043 * 82583V Gigabit Network Connection
Auke Kokbc7f75f2007-09-17 12:30:59 -070044 */
45
Auke Kokbc7f75f2007-09-17 12:30:59 -070046#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 Wybornyff10e132010-10-28 00:59:53 +000055#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 Kokbc7f75f2007-09-17 12:30:59 -070059
Bruce Allan4662e822008-08-26 18:37:06 -070060#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */
61
Auke Kokbc7f75f2007-09-17 12:30:59 -070062static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
63static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
64static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
dave grahamc9523372009-02-10 12:52:28 +000065static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -070066static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
67 u16 words, u16 *data);
68static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
69static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
70static s32 e1000_setup_link_82571(struct e1000_hw *hw);
71static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
Bruce Allancaaddaf2009-12-01 15:46:43 +000072static void e1000_clear_vfta_82571(struct e1000_hw *hw);
Bruce Allan4662e822008-08-26 18:37:06 -070073static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
74static s32 e1000_led_on_82574(struct e1000_hw *hw);
Dave Graham23a2d1b2009-06-08 14:28:17 +000075static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
Bruce Allan17f208d2009-12-01 15:47:22 +000076static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
Bruce Allan1b98c2b2010-11-16 19:50:14 -080077static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw);
78static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw);
79static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -070080
81/**
82 * e1000_init_phy_params_82571 - Init PHY func ptrs.
83 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070084 **/
85static 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 Kirsher318a94d2008-03-28 09:15:16 -070090 if (hw->phy.media_type != e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -070091 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 Allan17f208d2009-12-01 15:47:22 +000099 phy->ops.power_up = e1000_power_up_phy_copper;
100 phy->ops.power_down = e1000_power_down_phy_copper_82571;
101
Auke Kokbc7f75f2007-09-17 12:30:59 -0700102 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 Allan4662e822008-08-26 18:37:06 -0700110 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000111 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700112 phy->type = e1000_phy_bm;
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800113 phy->ops.acquire = e1000_get_hw_semaphore_82574;
114 phy->ops.release = e1000_put_hw_semaphore_82574;
Bruce Allan4662e822008-08-26 18:37:06 -0700115 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700116 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 Allan4662e822008-08-26 18:37:06 -0700135 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000136 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700137 if (phy->id != BME1000_E_PHY_ID_R2)
138 return -E1000_ERR_PHY;
139 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700140 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 Kokbc7f75f2007-09-17 12:30:59 -0700151 **/
152static 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 Allan4662e822008-08-26 18:37:06 -0700177 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000178 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700179 if (((eecd >> 15) & 0x3) == 0x3) {
180 nvm->type = e1000_nvm_flash_hw;
181 nvm->word_size = 2048;
Bruce Allanad680762008-03-28 09:15:03 -0700182 /*
183 * Autonomous Flash update bit must be cleared due
Auke Kokbc7f75f2007-09-17 12:30:59 -0700184 * to Flash update issue.
185 */
186 eecd &= ~E1000_EECD_AUPDEN;
187 ew32(EECD, eecd);
188 break;
189 }
190 /* Fall Through */
191 default:
Bruce Allanad680762008-03-28 09:15:03 -0700192 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700193 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
194 E1000_EECD_SIZE_EX_SHIFT);
Bruce Allanad680762008-03-28 09:15:03 -0700195 /*
196 * Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700197 * for setting word_size.
198 */
199 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700200
201 /* EEPROM access above 16k is unsupported */
202 if (size > 14)
203 size = 14;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700204 nvm->word_size = 1 << size;
205 break;
206 }
207
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800208 /* 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 Kokbc7f75f2007-09-17 12:30:59 -0700219 return 0;
220}
221
222/**
223 * e1000_init_mac_params_82571 - Init MAC func ptrs.
224 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700225 **/
226static 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 Graham23a2d1b2009-06-08 14:28:17 +0000231 u32 swsm = 0;
232 u32 swsm2 = 0;
233 bool force_clear_smbi = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700234
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 Kirsher318a94d2008-03-28 09:15:16 -0700240 hw->phy.media_type = e1000_media_type_fiber;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700241 break;
242 case E1000_DEV_ID_82571EB_SERDES:
243 case E1000_DEV_ID_82572EI_SERDES:
Auke Kok040babf2007-10-31 15:22:05 -0700244 case E1000_DEV_ID_82571EB_SERDES_DUAL:
245 case E1000_DEV_ID_82571EB_SERDES_QUAD:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700246 hw->phy.media_type = e1000_media_type_internal_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700247 break;
248 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700249 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700250 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 Allanf464ba82010-01-07 16:31:35 +0000257 /* Adaptive IFS supported */
258 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700259
260 /* check for link */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700261 switch (hw->phy.media_type) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700262 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 Allanad680762008-03-28 09:15:03 -0700268 func->setup_physical_interface =
269 e1000_setup_fiber_serdes_link_82571;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700270 func->check_for_link = e1000e_check_for_fiber_link;
Bruce Allanad680762008-03-28 09:15:03 -0700271 func->get_link_up_info =
272 e1000e_get_speed_and_duplex_fiber_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700273 break;
274 case e1000_media_type_internal_serdes:
Bruce Allanad680762008-03-28 09:15:03 -0700275 func->setup_physical_interface =
276 e1000_setup_fiber_serdes_link_82571;
dave grahamc9523372009-02-10 12:52:28 +0000277 func->check_for_link = e1000_check_for_serdes_link_82571;
Bruce Allanad680762008-03-28 09:15:03 -0700278 func->get_link_up_info =
279 e1000e_get_speed_and_duplex_fiber_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700280 break;
281 default:
282 return -E1000_ERR_CONFIG;
283 break;
284 }
285
Bruce Allan4662e822008-08-26 18:37:06 -0700286 switch (hw->mac.type) {
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000287 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 Allana65a4a02010-05-10 15:01:51 +0000291
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 Allanf4d2dd42010-01-13 02:05:18 +0000301 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700302 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000303 case e1000_82583:
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000304 func->set_lan_id = e1000_set_lan_id_single_port;
Bruce Allan4662e822008-08-26 18:37:06 -0700305 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 Allana65a4a02010-05-10 15:01:51 +0000311
312 /* FWSM register */
313 mac->has_fwsm = true;
Bruce Allan4662e822008-08-26 18:37:06 -0700314 break;
315 }
316
Dave Graham23a2d1b2009-06-08 14:28:17 +0000317 /*
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 Allan3bb99fe2009-11-20 23:25:07 +0000350 e_dbg("Please update your 82571 Bootagent\n");
Dave Graham23a2d1b2009-06-08 14:28:17 +0000351 }
352 ew32(SWSM, swsm & ~E1000_SWSM_SMBI);
353 }
354
355 /*
Joe Perches2c73e1f2010-03-26 20:16:59 +0000356 * Initialize device specific counter of SMBI acquisition
Dave Graham23a2d1b2009-06-08 14:28:17 +0000357 * timeouts.
358 */
359 hw->dev_spec.e82571.smb_counter = 0;
360
Auke Kokbc7f75f2007-09-17 12:30:59 -0700361 return 0;
362}
363
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700364static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700365{
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 Kokbc7f75f2007-09-17 12:30:59 -0700369 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 Kok040babf2007-10-31 15:22:05 -0700389 case E1000_DEV_ID_82571PT_QUAD_COPPER:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700390 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 Kluin6e4ca802007-10-29 10:50:05 -0700413 (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700414 adapter->flags &= ~FLAG_HAS_WOL;
Auke Kok040babf2007-10-31 15:22:05 -0700415 /* Does not support WoL on any port */
416 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
417 adapter->flags &= ~FLAG_HAS_WOL;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700418 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700419 case e1000_82573:
Bruce Allan6f461f62010-04-27 03:33:04 +0000420 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 Kokbc7f75f2007-09-17 12:30:59 -0700425 if (pdev->device == E1000_DEV_ID_82573L) {
Bruce Allan6f461f62010-04-27 03:33:04 +0000426 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
427 adapter->max_hw_frame_size = DEFAULT_JUMBO;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700428 }
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 **/
444static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
445{
446 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan4662e822008-08-26 18:37:06 -0700447 s32 ret_val;
448 u16 phy_id = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700449
450 switch (hw->mac.type) {
451 case e1000_82571:
452 case e1000_82572:
Bruce Allanad680762008-03-28 09:15:03 -0700453 /*
454 * The 82571 firmware may still be configuring the PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700455 * In this case, we cannot access the PHY until the
456 * configuration is done. So we explicitly set the
Bruce Allanad680762008-03-28 09:15:03 -0700457 * PHY ID.
458 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700459 phy->id = IGP01E1000_I_PHY_ID;
460 break;
461 case e1000_82573:
462 return e1000e_get_phy_id(hw);
463 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700464 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000465 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700466 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 Kokbc7f75f2007-09-17 12:30:59 -0700479 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 **/
493static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
494{
495 u32 swsm;
Dave Graham23a2d1b2009-06-08 14:28:17 +0000496 s32 sw_timeout = hw->nvm.word_size + 1;
497 s32 fw_timeout = hw->nvm.word_size + 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700498 s32 i = 0;
499
Dave Graham23a2d1b2009-06-08 14:28:17 +0000500 /*
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 Allan3bb99fe2009-11-20 23:25:07 +0000522 e_dbg("Driver can't access device - SMBI bit is set.\n");
Dave Graham23a2d1b2009-06-08 14:28:17 +0000523 hw->dev_spec.e82571.smb_counter++;
524 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700525 /* Get the FW semaphore. */
Dave Graham23a2d1b2009-06-08 14:28:17 +0000526 for (i = 0; i < fw_timeout; i++) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700527 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 Graham23a2d1b2009-06-08 14:28:17 +0000537 if (i == fw_timeout) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700538 /* Release semaphores */
Dave Graham23a2d1b2009-06-08 14:28:17 +0000539 e1000_put_hw_semaphore_82571(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000540 e_dbg("Driver can't access the NVM\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700541 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 **/
553static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
554{
555 u32 swsm;
556
557 swsm = er32(SWSM);
Dave Graham23a2d1b2009-06-08 14:28:17 +0000558 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700559 ew32(SWSM, swsm);
560}
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800561/**
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 **/
568static 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
597out:
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 **/
608static 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
617static 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 **/
626static 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 **/
644static 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 Kokbc7f75f2007-09-17 12:30:59 -0700649
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 **/
659static 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 Duyck8c81c9c2009-03-19 01:12:27 +0000667 switch (hw->mac.type) {
668 case e1000_82573:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000669 break;
670 default:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700671 ret_val = e1000e_acquire_nvm(hw);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000672 break;
673 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700674
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 **/
687static 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 Kok489815c2008-02-21 15:11:07 -0800703 * EEPROM will most likely contain an invalid checksum.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700704 **/
705static 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 Allan4662e822008-08-26 18:37:06 -0700712 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000713 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700714 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 **/
736static 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 Allanad680762008-03-28 09:15:03 -0700746 /*
747 * If our nvm is an EEPROM, then we're done
748 * otherwise, commit the checksum to the flash NVM.
749 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700750 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 Allanad680762008-03-28 09:15:03 -0700765 /*
766 * The enabling of and the actual reset must be done
Auke Kokbc7f75f2007-09-17 12:30:59 -0700767 * 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 **/
797static 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 Kok489815c2008-02-21 15:11:07 -0800817 * EEPROM will most likely contain an invalid checksum.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700818 **/
819static 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 Allana708dd82009-11-20 23:28:37 +0000823 u32 i, eewr = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700824 s32 ret_val = 0;
825
Bruce Allanad680762008-03-28 09:15:03 -0700826 /*
827 * A check for invalid values: offset too large, too many words,
828 * and not enough words.
829 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700830 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
831 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000832 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700833 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 **/
861static 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 Allan3bb99fe2009-11-20 23:25:07 +0000873 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700874 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 Allan564ea9b2009-11-20 23:26:44 +0000883 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -0700884 *
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 **/
891static 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 Allanad680762008-03-28 09:15:03 -0700916 /*
917 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -0700918 * during Dx states where the power conservation is most
919 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -0700920 * SmartSpeed, so performance is maintained.
921 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700922 if (phy->smart_speed == e1000_smart_speed_on) {
923 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700924 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700925 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 Allanad680762008-03-28 09:15:03 -0700930 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700931 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 Allanad680762008-03-28 09:15:03 -0700935 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700936 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 Allanad680762008-03-28 09:15:03 -0700941 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700942 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 Allanfe401672009-11-20 23:26:05 +0000954 * This resets the hardware into a known state.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700955 **/
956static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
957{
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800958 u32 ctrl, ctrl_ext, icr;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700959 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700960
Bruce Allanad680762008-03-28 09:15:03 -0700961 /*
962 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -0700963 * 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 Allan3bb99fe2009-11-20 23:25:07 +0000967 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700968
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000969 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700970 ew32(IMC, 0xffffffff);
971
972 ew32(RCTL, 0);
973 ew32(TCTL, E1000_TCTL_PSP);
974 e1e_flush();
975
976 msleep(10);
977
Bruce Allanad680762008-03-28 09:15:03 -0700978 /*
979 * Must acquire the MDIO ownership before MAC reset.
980 * Ownership defaults to firmware after a reset.
981 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000982 switch (hw->mac.type) {
983 case e1000_82573:
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800984 ret_val = e1000_get_hw_semaphore_82573(hw);
985 break;
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000986 case e1000_82574:
987 case e1000_82583:
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800988 ret_val = e1000_get_hw_semaphore_82574(hw);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000989 break;
990 default:
991 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700992 }
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800993 if (ret_val)
994 e_dbg("Cannot acquire MDIO ownership\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700995
996 ctrl = er32(CTRL);
997
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000998 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700999 ew32(CTRL, ctrl | E1000_CTRL_RST);
1000
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001001 /* 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 Kokbc7f75f2007-09-17 12:30:59 -07001011 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 Allanad680762008-03-28 09:15:03 -07001024 /*
1025 * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001026 * Need to wait for Phy configuration completion before accessing
1027 * NVM and Phy.
1028 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001029
1030 switch (hw->mac.type) {
1031 case e1000_82573:
1032 case e1000_82574:
1033 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001034 msleep(25);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001035 break;
1036 default:
1037 break;
1038 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001039
1040 /* Clear any pending interrupt events. */
1041 ew32(IMC, 0xffffffff);
1042 icr = er32(ICR);
1043
Bruce Allan1aef70e2010-08-19 15:48:52 -07001044 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 Allan608f8a02010-01-13 02:04:58 +00001049
Bruce Allan1aef70e2010-08-19 15:48:52 -07001050 e1000e_set_laa_state_82571(hw, true);
1051 }
Bill Hayes93ca1612007-10-31 15:21:52 -07001052
dave grahamc9523372009-02-10 12:52:28 +00001053 /* 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 Kokbc7f75f2007-09-17 12:30:59 -07001057 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 **/
1066static 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 Allana708dd82009-11-20 23:28:37 +00001071 u16 i, rar_count = mac->rar_entry_count;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001072
1073 e1000_initialize_hw_bits_82571(hw);
1074
1075 /* Initialize identification LED */
1076 ret_val = e1000e_id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00001077 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001078 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00001079 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001080
1081 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001082 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +00001083 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001084
1085 /* Setup the receive address. */
Bruce Allanad680762008-03-28 09:15:03 -07001086 /*
1087 * If, however, a locally administered address was assigned to the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001088 * 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 Allan3bb99fe2009-11-20 23:25:07 +00001096 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001097 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 Kirshere9ec2c02008-04-02 13:48:13 -07001104 reg_data = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001105 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1106 E1000_TXDCTL_FULL_TX_DESC_WB |
1107 E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001108 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001109
1110 /* ...for both queues. */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001111 switch (mac->type) {
1112 case e1000_82573:
Bruce Allana65a4a02010-05-10 15:01:51 +00001113 e1000e_enable_tx_pkt_filtering(hw);
1114 /* fall through */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001115 case e1000_82574:
1116 case e1000_82583:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001117 reg_data = er32(GCR);
1118 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
1119 ew32(GCR, reg_data);
1120 break;
1121 default:
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001122 reg_data = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001123 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1124 E1000_TXDCTL_FULL_TX_DESC_WB |
1125 E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001126 ew32(TXDCTL(1), reg_data);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001127 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001128 }
1129
Bruce Allanad680762008-03-28 09:15:03 -07001130 /*
1131 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07001132 * 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 **/
1147static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1148{
1149 u32 reg;
1150
1151 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001152 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001153 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001154 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001155
1156 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001157 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001158 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001159 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001160
1161 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001162 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001163 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 Kirshere9ec2c02008-04-02 13:48:13 -07001172 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001173
1174 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001175 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001176 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 Kirshere9ec2c02008-04-02 13:48:13 -07001185 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001186 break;
1187 default:
1188 break;
1189 }
1190
1191 /* Device Control */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001192 switch (hw->mac.type) {
1193 case e1000_82573:
1194 case e1000_82574:
1195 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001196 reg = er32(CTRL);
1197 reg &= ~(1 << 29);
1198 ew32(CTRL, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001199 break;
1200 default:
1201 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001202 }
1203
1204 /* Extended Device Control */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001205 switch (hw->mac.type) {
1206 case e1000_82573:
1207 case e1000_82574:
1208 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001209 reg = er32(CTRL_EXT);
1210 reg &= ~(1 << 23);
1211 reg |= (1 << 22);
1212 ew32(CTRL_EXT, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001213 break;
1214 default:
1215 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001216 }
Bruce Allan4662e822008-08-26 18:37:06 -07001217
Alexander Duyck6ea7ae12008-11-14 06:54:36 +00001218 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 graham5df3f0e2009-02-10 12:51:41 +00001223 /*
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 Duyck6ea7ae12008-11-14 06:54:36 +00001235
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001236 /* PCI-Ex Control Registers */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001237 switch (hw->mac.type) {
1238 case e1000_82574:
1239 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -07001240 reg = er32(GCR);
1241 reg |= (1 << 22);
1242 ew32(GCR, reg);
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001243
Bruce Allan84efb7b2009-11-20 23:26:24 +00001244 /*
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 Brandeburg78272bb2009-01-26 12:16:26 -08001251 reg = er32(GCR2);
1252 reg |= 1;
1253 ew32(GCR2, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001254 break;
1255 default:
1256 break;
Bruce Allan4662e822008-08-26 18:37:06 -07001257 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001258}
1259
1260/**
Bruce Allancaaddaf2009-12-01 15:46:43 +00001261 * e1000_clear_vfta_82571 - Clear VLAN filter table
Auke Kokbc7f75f2007-09-17 12:30:59 -07001262 * @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 Allancaaddaf2009-12-01 15:46:43 +00001267static void e1000_clear_vfta_82571(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001268{
1269 u32 offset;
1270 u32 vfta_value = 0;
1271 u32 vfta_offset = 0;
1272 u32 vfta_bit_in_reg = 0;
1273
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001274 switch (hw->mac.type) {
1275 case e1000_82573:
1276 case e1000_82574:
1277 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001278 if (hw->mng_cookie.vlan_id != 0) {
Bruce Allanad680762008-03-28 09:15:03 -07001279 /*
1280 * The VFTA is a 4096b bit-field, each identifying
Auke Kokbc7f75f2007-09-17 12:30:59 -07001281 * 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 Duyck8c81c9c2009-03-19 01:12:27 +00001292 break;
1293 default:
1294 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001295 }
1296 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
Bruce Allanad680762008-03-28 09:15:03 -07001297 /*
1298 * If the offset we want to clear is the same offset of the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001299 * 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 Allan4662e822008-08-26 18:37:06 -07001309 * 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 **/
1315static 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 **/
1329static 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 Wybornyff10e132010-10-28 00:59:53 +00001351 * 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 **/
1356bool 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 }
1379out:
1380 return phy_hung;
1381}
1382
1383/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001384 * 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 **/
1393static s32 e1000_setup_link_82571(struct e1000_hw *hw)
1394{
Bruce Allanad680762008-03-28 09:15:03 -07001395 /*
1396 * 82573 does not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07001397 * the default flow control setting, so we explicitly
1398 * set it to full.
1399 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001400 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 Kokbc7f75f2007-09-17 12:30:59 -07001410
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 **/
1422static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
1423{
1424 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001425 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 Allan4662e822008-08-26 18:37:06 -07001434 case e1000_phy_bm:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001435 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 Kokbc7f75f2007-09-17 12:30:59 -07001439 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 **/
1460static 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 Allanad680762008-03-28 09:15:03 -07001465 /*
1466 * If SerDes loopback mode is entered, there is no form
Auke Kokbc7f75f2007-09-17 12:30:59 -07001467 * of reset to take the adapter out of that mode. So we
1468 * have to explicitly take the adapter out of loopback
Auke Kok489815c2008-02-21 15:11:07 -08001469 * mode. This prevents drivers from twiddling their thumbs
Auke Kokbc7f75f2007-09-17 12:30:59 -07001470 * if another tool failed to take it out of loopback mode.
1471 */
Bruce Allanad680762008-03-28 09:15:03 -07001472 ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001473 break;
1474 default:
1475 break;
1476 }
1477
1478 return e1000e_setup_fiber_serdes_link(hw);
1479}
1480
1481/**
dave grahamc9523372009-02-10 12:52:28 +00001482 * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
1483 * @hw: pointer to the HW structure
1484 *
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001485 * 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 Mack3ad2f3f2010-02-03 08:01:28 +08001496 * 3) autoneg_complete (the link successfully autonegotiated)
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001497 * 4) forced_up (the link has been forced up, it did not autonegotiate)
1498 *
dave grahamc9523372009-02-10 12:52:28 +00001499 **/
Hannes Ederf6370112009-02-14 11:32:25 +00001500static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
dave grahamc9523372009-02-10 12:52:28 +00001501{
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 Allan1a40d5c2009-12-01 15:49:51 +00001524 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001525 e_dbg("AN_UP -> AN_PROG\n");
Bruce Allana82a14f2010-11-24 06:01:20 +00001526 } else {
1527 mac->serdes_has_link = true;
dave grahamc9523372009-02-10 12:52:28 +00001528 }
Bruce Allana82a14f2010-11-24 06:01:20 +00001529 break;
dave grahamc9523372009-02-10 12:52:28 +00001530
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 Alland478eb42010-11-16 19:50:13 -08001537 * If the partner code word is null, stop forcing
1538 * and restart auto negotiation.
dave grahamc9523372009-02-10 12:52:28 +00001539 */
Bruce Alland478eb42010-11-16 19:50:13 -08001540 if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
dave grahamc9523372009-02-10 12:52:28 +00001541 /* Enable autoneg, and unforce link up */
1542 ew32(TXCW, mac->txcw);
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001543 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
dave grahamc9523372009-02-10 12:52:28 +00001544 mac->serdes_link_state =
1545 e1000_serdes_link_autoneg_progress;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001546 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001547 e_dbg("FORCED_UP -> AN_PROG\n");
Bruce Allana82a14f2010-11-24 06:01:20 +00001548 } else {
1549 mac->serdes_has_link = true;
dave grahamc9523372009-02-10 12:52:28 +00001550 }
1551 break;
1552
1553 case e1000_serdes_link_autoneg_progress:
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001554 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 grahamc9523372009-02-10 12:52:28 +00001571 } else {
1572 /*
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001573 * The link partner did not autoneg.
1574 * Force link up and full duplex, and change
1575 * state to forced.
dave grahamc9523372009-02-10 12:52:28 +00001576 */
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001577 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
dave grahamc9523372009-02-10 12:52:28 +00001578 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
1579 ew32(CTRL, ctrl);
1580
1581 /* Configure Flow Control after link up. */
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001582 ret_val = e1000e_config_fc_after_link_up(hw);
dave grahamc9523372009-02-10 12:52:28 +00001583 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001584 e_dbg("Error config flow control\n");
dave grahamc9523372009-02-10 12:52:28 +00001585 break;
1586 }
1587 mac->serdes_link_state =
1588 e1000_serdes_link_forced_up;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001589 mac->serdes_has_link = true;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001590 e_dbg("AN_PROG -> FORCED_UP\n");
dave grahamc9523372009-02-10 12:52:28 +00001591 }
dave grahamc9523372009-02-10 12:52:28 +00001592 break;
1593
1594 case e1000_serdes_link_down:
1595 default:
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001596 /*
1597 * The link was down but the receiver has now gained
dave grahamc9523372009-02-10 12:52:28 +00001598 * valid sync, so lets see if we can bring the link
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001599 * up.
1600 */
dave grahamc9523372009-02-10 12:52:28 +00001601 ew32(TXCW, mac->txcw);
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001602 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
dave grahamc9523372009-02-10 12:52:28 +00001603 mac->serdes_link_state =
1604 e1000_serdes_link_autoneg_progress;
Bruce Allana82a14f2010-11-24 06:01:20 +00001605 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001606 e_dbg("DOWN -> AN_PROG\n");
dave grahamc9523372009-02-10 12:52:28 +00001607 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 Allan3bb99fe2009-11-20 23:25:07 +00001613 e_dbg("ANYSTATE -> DOWN\n");
dave grahamc9523372009-02-10 12:52:28 +00001614 } else {
1615 /*
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001616 * We have sync, and can tolerate one invalid (IV)
1617 * codeword before declaring link down, so reread
1618 * to look again.
dave grahamc9523372009-02-10 12:52:28 +00001619 */
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 Allan3bb99fe2009-11-20 23:25:07 +00001625 e_dbg("ANYSTATE -> DOWN\n");
dave grahamc9523372009-02-10 12:52:28 +00001626 }
1627 }
1628 }
1629
1630 return ret_val;
1631}
1632
1633/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001634 * 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 **/
1641static 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 Allan3bb99fe2009-11-20 23:25:07 +00001647 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001648 return ret_val;
1649 }
1650
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001651 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 Kokbc7f75f2007-09-17 12:30:59 -07001664
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 Kok489815c2008-02-21 15:11:07 -08001672 * Retrieve and return the current locally administered address state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001673 **/
1674bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
1675{
1676 if (hw->mac.type != e1000_82571)
Bruce Allan564ea9b2009-11-20 23:26:44 +00001677 return false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001678
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 Allan5ff5b662009-12-01 15:51:11 +00001687 * Enable/Disable the current locally administered address state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001688 **/
1689void 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 Allanad680762008-03-28 09:15:03 -07001698 /*
1699 * Hold a copy of the LAA in RAR[14] This is done so that
Auke Kokbc7f75f2007-09-17 12:30:59 -07001700 * 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 **/
1718static 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 Allanad680762008-03-28 09:15:03 -07001727 /*
1728 * Check bit 4 of word 10h. If it is 0, firmware is done updating
Auke Kokbc7f75f2007-09-17 12:30:59 -07001729 * 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 Allanad680762008-03-28 09:15:03 -07001736 /*
1737 * Read 0x23 and check bit 15. This bit is a 1
Auke Kokbc7f75f2007-09-17 12:30:59 -07001738 * 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 Allan608f8a02010-01-13 02:04:58 +00001761 * e1000_read_mac_addr_82571 - Read device MAC address
1762 * @hw: pointer to the HW structure
1763 **/
1764static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1765{
1766 s32 ret_val = 0;
1767
Bruce Allan1aef70e2010-08-19 15:48:52 -07001768 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 Allan608f8a02010-01-13 02:04:58 +00001778
1779 ret_val = e1000_read_mac_addr_generic(hw);
1780
1781out:
1782 return ret_val;
1783}
1784
1785/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001786 * 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 **/
1792static 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 Allan17f208d2009-12-01 15:47:22 +00001803}
1804
1805/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001806 * 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 **/
1811static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
1812{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001813 e1000e_clear_hw_cntrs_base(hw);
1814
Bruce Allan99673d92009-11-20 23:27:21 +00001815 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 Kokbc7f75f2007-09-17 12:30:59 -07001827
Bruce Allan99673d92009-11-20 23:27:21 +00001828 er32(ALGNERRC);
1829 er32(RXERRC);
1830 er32(TNCRS);
1831 er32(CEXTERR);
1832 er32(TSCTC);
1833 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001834
Bruce Allan99673d92009-11-20 23:27:21 +00001835 er32(MGTPRC);
1836 er32(MGTPDC);
1837 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001838
Bruce Allan99673d92009-11-20 23:27:21 +00001839 er32(IAC);
1840 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001841
Bruce Allan99673d92009-11-20 23:27:21 +00001842 er32(ICRXPTC);
1843 er32(ICRXATC);
1844 er32(ICTXPTC);
1845 er32(ICTXATC);
1846 er32(ICTXQEC);
1847 er32(ICTXQMTC);
1848 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001849}
1850
1851static struct e1000_mac_operations e82571_mac_ops = {
Bruce Allan4662e822008-08-26 18:37:06 -07001852 /* .check_mng_mode: mac type dependent */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001853 /* .check_for_link: media type dependent */
Bruce Allana4f58f52009-06-02 11:29:18 +00001854 .id_led_init = e1000e_id_led_init,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001855 .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 Allanf4d2dd42010-01-13 02:05:18 +00001858 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001859 /* .get_link_up_info: media type dependent */
Bruce Allan4662e822008-08-26 18:37:06 -07001860 /* .led_on: mac type dependent */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001861 .led_off = e1000e_led_off_generic,
Bruce Allanab8932f2010-01-13 02:05:38 +00001862 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001863 .write_vfta = e1000_write_vfta_generic,
1864 .clear_vfta = e1000_clear_vfta_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001865 .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 Allana4f58f52009-06-02 11:29:18 +00001869 .setup_led = e1000e_setup_led_generic,
Bruce Allan608f8a02010-01-13 02:04:58 +00001870 .read_mac_addr = e1000_read_mac_addr_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001871};
1872
1873static struct e1000_phy_operations e82_phy_ops_igp = {
Bruce Allan94d81862009-11-20 23:25:26 +00001874 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001875 .check_polarity = e1000_check_polarity_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001876 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001877 .commit = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001878 .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 Allan94d81862009-11-20 23:25:26 +00001881 .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 Kokbc7f75f2007-09-17 12:30:59 -07001885 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1886 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001887 .write_reg = e1000e_write_phy_reg_igp,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001888 .cfg_on_link_up = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001889};
1890
1891static struct e1000_phy_operations e82_phy_ops_m88 = {
Bruce Allan94d81862009-11-20 23:25:26 +00001892 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001893 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001894 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001895 .commit = e1000e_phy_sw_reset,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001896 .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 Allan94d81862009-11-20 23:25:26 +00001899 .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 Kokbc7f75f2007-09-17 12:30:59 -07001903 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1904 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001905 .write_reg = e1000e_write_phy_reg_m88,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001906 .cfg_on_link_up = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001907};
1908
Bruce Allan4662e822008-08-26 18:37:06 -07001909static struct e1000_phy_operations e82_phy_ops_bm = {
Bruce Allan94d81862009-11-20 23:25:26 +00001910 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001911 .check_polarity = e1000_check_polarity_m88,
Bruce Allan4662e822008-08-26 18:37:06 -07001912 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001913 .commit = e1000e_phy_sw_reset,
Bruce Allan4662e822008-08-26 18:37:06 -07001914 .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 Allan94d81862009-11-20 23:25:26 +00001917 .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 Allan4662e822008-08-26 18:37:06 -07001921 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1922 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001923 .write_reg = e1000e_write_phy_reg_bm2,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001924 .cfg_on_link_up = NULL,
Bruce Allan4662e822008-08-26 18:37:06 -07001925};
1926
Auke Kokbc7f75f2007-09-17 12:30:59 -07001927static struct e1000_nvm_operations e82571_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001928 .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 Kokbc7f75f2007-09-17 12:30:59 -07001932 .valid_led_default = e1000_valid_led_default_82571,
Bruce Allan94d81862009-11-20 23:25:26 +00001933 .validate = e1000_validate_nvm_checksum_82571,
1934 .write = e1000_write_nvm_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001935};
1936
1937struct e1000_info e1000_82571_info = {
1938 .mac = e1000_82571,
1939 .flags = FLAG_HAS_HW_VLAN_FILTER
1940 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001941 | FLAG_HAS_WOL
1942 | FLAG_APME_IN_CTRL3
1943 | FLAG_RX_CSUM_ENABLED
1944 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001945 | 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 Brandeburg3a3b7582010-09-29 21:38:49 +00001949 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
1950 | FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001951 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001952 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001953 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001954 .mac_ops = &e82571_mac_ops,
1955 .phy_ops = &e82_phy_ops_igp,
1956 .nvm_ops = &e82571_nvm_ops,
1957};
1958
1959struct e1000_info e1000_82572_info = {
1960 .mac = e1000_82572,
1961 .flags = FLAG_HAS_HW_VLAN_FILTER
1962 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001963 | FLAG_HAS_WOL
1964 | FLAG_APME_IN_CTRL3
1965 | FLAG_RX_CSUM_ENABLED
1966 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001967 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00001968 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
1969 | FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001970 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001971 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001972 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001973 .mac_ops = &e82571_mac_ops,
1974 .phy_ops = &e82_phy_ops_igp,
1975 .nvm_ops = &e82571_nvm_ops,
1976};
1977
1978struct e1000_info e1000_82573_info = {
1979 .mac = e1000_82573,
1980 .flags = FLAG_HAS_HW_VLAN_FILTER
Auke Kokbc7f75f2007-09-17 12:30:59 -07001981 | FLAG_HAS_WOL
1982 | FLAG_APME_IN_CTRL3
1983 | FLAG_RX_CSUM_ENABLED
Auke Kokbc7f75f2007-09-17 12:30:59 -07001984 | FLAG_HAS_SMART_POWER_DOWN
1985 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07001986 | FLAG_HAS_SWSM_ON_LOAD,
Bruce Allan19833b52010-08-19 15:48:30 -07001987 .flags2 = FLAG2_DISABLE_ASPM_L1,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001988 .pba = 20,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001989 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001990 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001991 .mac_ops = &e82571_mac_ops,
1992 .phy_ops = &e82_phy_ops_m88,
Auke Kok31f8c4f2008-02-21 15:10:47 -08001993 .nvm_ops = &e82571_nvm_ops,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001994};
1995
Bruce Allan4662e822008-08-26 18:37:06 -07001996struct 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 Wybornyff10e132010-10-28 00:59:53 +00002007 .flags2 = FLAG2_CHECK_PHY_HANG,
Alexander Duyckedf15c12010-05-04 22:25:42 +00002008 .pba = 36,
Alexander Duycka825e002009-10-02 12:30:42 +00002009 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allan4662e822008-08-26 18:37:06 -07002010 .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 Duyck8c81c9c2009-03-19 01:12:27 +00002016struct 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 Duyckedf15c12010-05-04 22:25:42 +00002025 .pba = 36,
Alexander Duycka825e002009-10-02 12:30:42 +00002026 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002027 .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