blob: 0609ac69bb385c891ebab85f59640f156149db0e [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allan0d6057e2011-01-04 01:16:44 +00004 Copyright(c) 1999 - 2011 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
Bruce Alland9c76f92010-11-24 06:01:35 +000055#define AN_RETRY_COUNT 5 /* Autoneg Retry Count value */
Carolyn Wybornyff10e132010-10-28 00:59:53 +000056#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
Auke Kokbc7f75f2007-09-17 12:30:59 -070060
Bruce Allan4662e822008-08-26 18:37:06 -070061#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */
62
Auke Kokbc7f75f2007-09-17 12:30:59 -070063static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);
64static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);
65static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw);
dave grahamc9523372009-02-10 12:52:28 +000066static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -070067static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
68 u16 words, u16 *data);
69static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
70static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
71static s32 e1000_setup_link_82571(struct e1000_hw *hw);
72static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
Bruce Allancaaddaf2009-12-01 15:46:43 +000073static void e1000_clear_vfta_82571(struct e1000_hw *hw);
Bruce Allan4662e822008-08-26 18:37:06 -070074static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
75static s32 e1000_led_on_82574(struct e1000_hw *hw);
Dave Graham23a2d1b2009-06-08 14:28:17 +000076static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
Bruce Allan17f208d2009-12-01 15:47:22 +000077static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
Bruce Allan1b98c2b2010-11-16 19:50:14 -080078static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw);
79static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw);
80static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw);
Bruce Allan77996d12011-01-06 14:29:53 +000081static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active);
82static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active);
Auke Kokbc7f75f2007-09-17 12:30:59 -070083
84/**
85 * e1000_init_phy_params_82571 - Init PHY func ptrs.
86 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070087 **/
88static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
89{
90 struct e1000_phy_info *phy = &hw->phy;
91 s32 ret_val;
92
Jeff Kirsher318a94d2008-03-28 09:15:16 -070093 if (hw->phy.media_type != e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -070094 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
Bruce Allan17f208d2009-12-01 15:47:22 +0000102 phy->ops.power_up = e1000_power_up_phy_copper;
103 phy->ops.power_down = e1000_power_down_phy_copper_82571;
104
Auke Kokbc7f75f2007-09-17 12:30:59 -0700105 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;
Bruce Allan4662e822008-08-26 18:37:06 -0700113 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000114 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700115 phy->type = e1000_phy_bm;
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800116 phy->ops.acquire = e1000_get_hw_semaphore_82574;
117 phy->ops.release = e1000_put_hw_semaphore_82574;
Bruce Allan77996d12011-01-06 14:29:53 +0000118 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;
Bruce Allan4662e822008-08-26 18:37:06 -0700120 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700121 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);
Bruce Allandd93f952011-01-06 14:29:48 +0000128 if (ret_val) {
129 e_dbg("Error getting PHY ID\n");
130 return ret_val;
131 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700132
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)
Bruce Allandd93f952011-01-06 14:29:48 +0000138 ret_val = -E1000_ERR_PHY;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700139 break;
140 case e1000_82573:
141 if (phy->id != M88E1111_I_PHY_ID)
Bruce Allandd93f952011-01-06 14:29:48 +0000142 ret_val = -E1000_ERR_PHY;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700143 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700144 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000145 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700146 if (phy->id != BME1000_E_PHY_ID_R2)
Bruce Allandd93f952011-01-06 14:29:48 +0000147 ret_val = -E1000_ERR_PHY;
Bruce Allan4662e822008-08-26 18:37:06 -0700148 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700149 default:
Bruce Allandd93f952011-01-06 14:29:48 +0000150 ret_val = -E1000_ERR_PHY;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700151 break;
152 }
153
Bruce Allandd93f952011-01-06 14:29:48 +0000154 if (ret_val)
155 e_dbg("PHY ID unknown: type = 0x%08x\n", phy->id);
156
157 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700158}
159
160/**
161 * e1000_init_nvm_params_82571 - Init NVM func ptrs.
162 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700163 **/
164static 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:
Bruce Allan4662e822008-08-26 18:37:06 -0700189 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000190 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700191 if (((eecd >> 15) & 0x3) == 0x3) {
192 nvm->type = e1000_nvm_flash_hw;
193 nvm->word_size = 2048;
Bruce Allanad680762008-03-28 09:15:03 -0700194 /*
195 * Autonomous Flash update bit must be cleared due
Auke Kokbc7f75f2007-09-17 12:30:59 -0700196 * to Flash update issue.
197 */
198 eecd &= ~E1000_EECD_AUPDEN;
199 ew32(EECD, eecd);
200 break;
201 }
202 /* Fall Through */
203 default:
Bruce Allanad680762008-03-28 09:15:03 -0700204 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700205 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
206 E1000_EECD_SIZE_EX_SHIFT);
Bruce Allanad680762008-03-28 09:15:03 -0700207 /*
208 * Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700209 * for setting word_size.
210 */
211 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700212
213 /* EEPROM access above 16k is unsupported */
214 if (size > 14)
215 size = 14;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700216 nvm->word_size = 1 << size;
217 break;
218 }
219
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800220 /* 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
Auke Kokbc7f75f2007-09-17 12:30:59 -0700231 return 0;
232}
233
234/**
235 * e1000_init_mac_params_82571 - Init MAC func ptrs.
236 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700237 **/
238static 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;
242 struct e1000_mac_operations *func = &mac->ops;
Dave Graham23a2d1b2009-06-08 14:28:17 +0000243 u32 swsm = 0;
244 u32 swsm2 = 0;
245 bool force_clear_smbi = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700246
247 /* Set media type */
248 switch (adapter->pdev->device) {
249 case E1000_DEV_ID_82571EB_FIBER:
250 case E1000_DEV_ID_82572EI_FIBER:
251 case E1000_DEV_ID_82571EB_QUAD_FIBER:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700252 hw->phy.media_type = e1000_media_type_fiber;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700253 break;
254 case E1000_DEV_ID_82571EB_SERDES:
255 case E1000_DEV_ID_82572EI_SERDES:
Auke Kok040babf2007-10-31 15:22:05 -0700256 case E1000_DEV_ID_82571EB_SERDES_DUAL:
257 case E1000_DEV_ID_82571EB_SERDES_QUAD:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700258 hw->phy.media_type = e1000_media_type_internal_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700259 break;
260 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700261 hw->phy.media_type = e1000_media_type_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700262 break;
263 }
264
265 /* Set mta register count */
266 mac->mta_reg_count = 128;
267 /* Set rar entry count */
268 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allanf464ba82010-01-07 16:31:35 +0000269 /* Adaptive IFS supported */
270 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700271
272 /* check for link */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700273 switch (hw->phy.media_type) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700274 case e1000_media_type_copper:
275 func->setup_physical_interface = e1000_setup_copper_link_82571;
276 func->check_for_link = e1000e_check_for_copper_link;
277 func->get_link_up_info = e1000e_get_speed_and_duplex_copper;
278 break;
279 case e1000_media_type_fiber:
Bruce Allanad680762008-03-28 09:15:03 -0700280 func->setup_physical_interface =
281 e1000_setup_fiber_serdes_link_82571;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700282 func->check_for_link = e1000e_check_for_fiber_link;
Bruce Allanad680762008-03-28 09:15:03 -0700283 func->get_link_up_info =
284 e1000e_get_speed_and_duplex_fiber_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700285 break;
286 case e1000_media_type_internal_serdes:
Bruce Allanad680762008-03-28 09:15:03 -0700287 func->setup_physical_interface =
288 e1000_setup_fiber_serdes_link_82571;
dave grahamc9523372009-02-10 12:52:28 +0000289 func->check_for_link = e1000_check_for_serdes_link_82571;
Bruce Allanad680762008-03-28 09:15:03 -0700290 func->get_link_up_info =
291 e1000e_get_speed_and_duplex_fiber_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700292 break;
293 default:
294 return -E1000_ERR_CONFIG;
295 break;
296 }
297
Bruce Allan4662e822008-08-26 18:37:06 -0700298 switch (hw->mac.type) {
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000299 case e1000_82573:
300 func->set_lan_id = e1000_set_lan_id_single_port;
301 func->check_mng_mode = e1000e_check_mng_mode_generic;
302 func->led_on = e1000e_led_on_generic;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000303 func->blink_led = e1000e_blink_led_generic;
Bruce Allana65a4a02010-05-10 15:01:51 +0000304
305 /* FWSM register */
306 mac->has_fwsm = true;
307 /*
308 * ARC supported; valid only if manageability features are
309 * enabled.
310 */
311 mac->arc_subsystem_valid =
312 (er32(FWSM) & E1000_FWSM_MODE_MASK)
313 ? true : false;
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000314 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700315 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000316 case e1000_82583:
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000317 func->set_lan_id = e1000_set_lan_id_single_port;
Bruce Allan4662e822008-08-26 18:37:06 -0700318 func->check_mng_mode = e1000_check_mng_mode_82574;
319 func->led_on = e1000_led_on_82574;
320 break;
321 default:
322 func->check_mng_mode = e1000e_check_mng_mode_generic;
323 func->led_on = e1000e_led_on_generic;
Bruce Allandbf80dc2011-04-16 00:34:40 +0000324 func->blink_led = e1000e_blink_led_generic;
Bruce Allana65a4a02010-05-10 15:01:51 +0000325
326 /* FWSM register */
327 mac->has_fwsm = true;
Bruce Allan4662e822008-08-26 18:37:06 -0700328 break;
329 }
330
Dave Graham23a2d1b2009-06-08 14:28:17 +0000331 /*
332 * Ensure that the inter-port SWSM.SMBI lock bit is clear before
Uwe Kleine-Königb5950762010-11-01 15:38:34 -0400333 * first NVM or PHY access. This should be done for single-port
Dave Graham23a2d1b2009-06-08 14:28:17 +0000334 * devices, and for one port only on dual-port devices so that
335 * for those devices we can still use the SMBI lock to synchronize
336 * inter-port accesses to the PHY & NVM.
337 */
338 switch (hw->mac.type) {
339 case e1000_82571:
340 case e1000_82572:
341 swsm2 = er32(SWSM2);
342
343 if (!(swsm2 & E1000_SWSM2_LOCK)) {
344 /* Only do this for the first interface on this card */
345 ew32(SWSM2,
346 swsm2 | E1000_SWSM2_LOCK);
347 force_clear_smbi = true;
348 } else
349 force_clear_smbi = false;
350 break;
351 default:
352 force_clear_smbi = true;
353 break;
354 }
355
356 if (force_clear_smbi) {
357 /* Make sure SWSM.SMBI is clear */
358 swsm = er32(SWSM);
359 if (swsm & E1000_SWSM_SMBI) {
360 /* This bit should not be set on a first interface, and
361 * indicates that the bootagent or EFI code has
362 * improperly left this bit enabled
363 */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000364 e_dbg("Please update your 82571 Bootagent\n");
Dave Graham23a2d1b2009-06-08 14:28:17 +0000365 }
366 ew32(SWSM, swsm & ~E1000_SWSM_SMBI);
367 }
368
369 /*
Joe Perches2c73e1f2010-03-26 20:16:59 +0000370 * Initialize device specific counter of SMBI acquisition
Dave Graham23a2d1b2009-06-08 14:28:17 +0000371 * timeouts.
372 */
373 hw->dev_spec.e82571.smb_counter = 0;
374
Auke Kokbc7f75f2007-09-17 12:30:59 -0700375 return 0;
376}
377
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700378static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700379{
380 struct e1000_hw *hw = &adapter->hw;
381 static int global_quad_port_a; /* global port a indication */
382 struct pci_dev *pdev = adapter->pdev;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700383 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
384 s32 rc;
385
386 rc = e1000_init_mac_params_82571(adapter);
387 if (rc)
388 return rc;
389
390 rc = e1000_init_nvm_params_82571(hw);
391 if (rc)
392 return rc;
393
394 rc = e1000_init_phy_params_82571(hw);
395 if (rc)
396 return rc;
397
398 /* tag quad port adapters first, it's used below */
399 switch (pdev->device) {
400 case E1000_DEV_ID_82571EB_QUAD_COPPER:
401 case E1000_DEV_ID_82571EB_QUAD_FIBER:
402 case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
Auke Kok040babf2007-10-31 15:22:05 -0700403 case E1000_DEV_ID_82571PT_QUAD_COPPER:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700404 adapter->flags |= FLAG_IS_QUAD_PORT;
405 /* mark the first port */
406 if (global_quad_port_a == 0)
407 adapter->flags |= FLAG_IS_QUAD_PORT_A;
408 /* Reset for multiple quad port adapters */
409 global_quad_port_a++;
410 if (global_quad_port_a == 4)
411 global_quad_port_a = 0;
412 break;
413 default:
414 break;
415 }
416
417 switch (adapter->hw.mac.type) {
418 case e1000_82571:
419 /* these dual ports don't have WoL on port B at all */
420 if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) ||
421 (pdev->device == E1000_DEV_ID_82571EB_SERDES) ||
422 (pdev->device == E1000_DEV_ID_82571EB_COPPER)) &&
423 (is_port_b))
424 adapter->flags &= ~FLAG_HAS_WOL;
425 /* quad ports only support WoL on port A */
426 if (adapter->flags & FLAG_IS_QUAD_PORT &&
Roel Kluin6e4ca802007-10-29 10:50:05 -0700427 (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700428 adapter->flags &= ~FLAG_HAS_WOL;
Auke Kok040babf2007-10-31 15:22:05 -0700429 /* Does not support WoL on any port */
430 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
431 adapter->flags &= ~FLAG_HAS_WOL;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700432 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700433 case e1000_82573:
434 if (pdev->device == E1000_DEV_ID_82573L) {
Bruce Allan6f461f62010-04-27 03:33:04 +0000435 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
436 adapter->max_hw_frame_size = DEFAULT_JUMBO;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700437 }
438 break;
439 default:
440 break;
441 }
442
443 return 0;
444}
445
446/**
447 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
448 * @hw: pointer to the HW structure
449 *
450 * Reads the PHY registers and stores the PHY ID and possibly the PHY
451 * revision in the hardware structure.
452 **/
453static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
454{
455 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan4662e822008-08-26 18:37:06 -0700456 s32 ret_val;
457 u16 phy_id = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700458
459 switch (hw->mac.type) {
460 case e1000_82571:
461 case e1000_82572:
Bruce Allanad680762008-03-28 09:15:03 -0700462 /*
463 * The 82571 firmware may still be configuring the PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700464 * In this case, we cannot access the PHY until the
465 * configuration is done. So we explicitly set the
Bruce Allanad680762008-03-28 09:15:03 -0700466 * PHY ID.
467 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700468 phy->id = IGP01E1000_I_PHY_ID;
469 break;
470 case e1000_82573:
471 return e1000e_get_phy_id(hw);
472 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700473 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000474 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700475 ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
476 if (ret_val)
477 return ret_val;
478
479 phy->id = (u32)(phy_id << 16);
480 udelay(20);
481 ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
482 if (ret_val)
483 return ret_val;
484
485 phy->id |= (u32)(phy_id);
486 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
487 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700488 default:
489 return -E1000_ERR_PHY;
490 break;
491 }
492
493 return 0;
494}
495
496/**
497 * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
498 * @hw: pointer to the HW structure
499 *
500 * Acquire the HW semaphore to access the PHY or NVM
501 **/
502static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
503{
504 u32 swsm;
Dave Graham23a2d1b2009-06-08 14:28:17 +0000505 s32 sw_timeout = hw->nvm.word_size + 1;
506 s32 fw_timeout = hw->nvm.word_size + 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700507 s32 i = 0;
508
Dave Graham23a2d1b2009-06-08 14:28:17 +0000509 /*
510 * If we have timedout 3 times on trying to acquire
511 * the inter-port SMBI semaphore, there is old code
512 * operating on the other port, and it is not
513 * releasing SMBI. Modify the number of times that
514 * we try for the semaphore to interwork with this
515 * older code.
516 */
517 if (hw->dev_spec.e82571.smb_counter > 2)
518 sw_timeout = 1;
519
520 /* Get the SW semaphore */
521 while (i < sw_timeout) {
522 swsm = er32(SWSM);
523 if (!(swsm & E1000_SWSM_SMBI))
524 break;
525
526 udelay(50);
527 i++;
528 }
529
530 if (i == sw_timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000531 e_dbg("Driver can't access device - SMBI bit is set.\n");
Dave Graham23a2d1b2009-06-08 14:28:17 +0000532 hw->dev_spec.e82571.smb_counter++;
533 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700534 /* Get the FW semaphore. */
Dave Graham23a2d1b2009-06-08 14:28:17 +0000535 for (i = 0; i < fw_timeout; i++) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700536 swsm = er32(SWSM);
537 ew32(SWSM, swsm | E1000_SWSM_SWESMBI);
538
539 /* Semaphore acquired if bit latched */
540 if (er32(SWSM) & E1000_SWSM_SWESMBI)
541 break;
542
543 udelay(50);
544 }
545
Dave Graham23a2d1b2009-06-08 14:28:17 +0000546 if (i == fw_timeout) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700547 /* Release semaphores */
Dave Graham23a2d1b2009-06-08 14:28:17 +0000548 e1000_put_hw_semaphore_82571(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000549 e_dbg("Driver can't access the NVM\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700550 return -E1000_ERR_NVM;
551 }
552
553 return 0;
554}
555
556/**
557 * e1000_put_hw_semaphore_82571 - Release hardware semaphore
558 * @hw: pointer to the HW structure
559 *
560 * Release hardware semaphore used to access the PHY or NVM
561 **/
562static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
563{
564 u32 swsm;
565
566 swsm = er32(SWSM);
Dave Graham23a2d1b2009-06-08 14:28:17 +0000567 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700568 ew32(SWSM, swsm);
569}
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800570/**
571 * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore
572 * @hw: pointer to the HW structure
573 *
574 * Acquire the HW semaphore during reset.
575 *
576 **/
577static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
578{
579 u32 extcnf_ctrl;
580 s32 ret_val = 0;
581 s32 i = 0;
582
583 extcnf_ctrl = er32(EXTCNF_CTRL);
584 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
585 do {
586 ew32(EXTCNF_CTRL, extcnf_ctrl);
587 extcnf_ctrl = er32(EXTCNF_CTRL);
588
589 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
590 break;
591
592 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
593
Bruce Allan1bba4382011-03-19 00:27:20 +0000594 usleep_range(2000, 4000);
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800595 i++;
596 } while (i < MDIO_OWNERSHIP_TIMEOUT);
597
598 if (i == MDIO_OWNERSHIP_TIMEOUT) {
599 /* Release semaphores */
600 e1000_put_hw_semaphore_82573(hw);
601 e_dbg("Driver can't access the PHY\n");
602 ret_val = -E1000_ERR_PHY;
603 goto out;
604 }
605
606out:
607 return ret_val;
608}
609
610/**
611 * e1000_put_hw_semaphore_82573 - Release hardware semaphore
612 * @hw: pointer to the HW structure
613 *
614 * Release hardware semaphore used during reset.
615 *
616 **/
617static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw)
618{
619 u32 extcnf_ctrl;
620
621 extcnf_ctrl = er32(EXTCNF_CTRL);
622 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
623 ew32(EXTCNF_CTRL, extcnf_ctrl);
624}
625
626static DEFINE_MUTEX(swflag_mutex);
627
628/**
629 * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore
630 * @hw: pointer to the HW structure
631 *
632 * Acquire the HW semaphore to access the PHY or NVM.
633 *
634 **/
635static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw)
636{
637 s32 ret_val;
638
639 mutex_lock(&swflag_mutex);
640 ret_val = e1000_get_hw_semaphore_82573(hw);
641 if (ret_val)
642 mutex_unlock(&swflag_mutex);
643 return ret_val;
644}
645
646/**
647 * e1000_put_hw_semaphore_82574 - Release hardware semaphore
648 * @hw: pointer to the HW structure
649 *
650 * Release hardware semaphore used to access the PHY or NVM
651 *
652 **/
653static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw)
654{
655 e1000_put_hw_semaphore_82573(hw);
656 mutex_unlock(&swflag_mutex);
657}
Auke Kokbc7f75f2007-09-17 12:30:59 -0700658
659/**
Bruce Allan77996d12011-01-06 14:29:53 +0000660 * e1000_set_d0_lplu_state_82574 - Set Low Power Linkup D0 state
661 * @hw: pointer to the HW structure
662 * @active: true to enable LPLU, false to disable
663 *
664 * Sets the LPLU D0 state according to the active flag.
665 * LPLU will not be activated unless the
666 * device autonegotiation advertisement meets standards of
667 * either 10 or 10/100 or 10/100/1000 at all duplexes.
668 * This is a function pointer entry point only called by
669 * PHY setup routines.
670 **/
671static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active)
672{
673 u16 data = er32(POEMB);
674
675 if (active)
676 data |= E1000_PHY_CTRL_D0A_LPLU;
677 else
678 data &= ~E1000_PHY_CTRL_D0A_LPLU;
679
680 ew32(POEMB, data);
681 return 0;
682}
683
684/**
685 * e1000_set_d3_lplu_state_82574 - Sets low power link up state for D3
686 * @hw: pointer to the HW structure
687 * @active: boolean used to enable/disable lplu
688 *
689 * The low power link up (lplu) state is set to the power management level D3
690 * when active is true, else clear lplu for D3. LPLU
691 * is used during Dx states where the power conservation is most important.
692 * During driver activity, SmartSpeed should be enabled so performance is
693 * maintained.
694 **/
695static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active)
696{
697 u16 data = er32(POEMB);
698
699 if (!active) {
700 data &= ~E1000_PHY_CTRL_NOND0A_LPLU;
701 } else if ((hw->phy.autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
702 (hw->phy.autoneg_advertised == E1000_ALL_NOT_GIG) ||
703 (hw->phy.autoneg_advertised == E1000_ALL_10_SPEED)) {
704 data |= E1000_PHY_CTRL_NOND0A_LPLU;
705 }
706
707 ew32(POEMB, data);
708 return 0;
709}
710
711/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700712 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
713 * @hw: pointer to the HW structure
714 *
715 * To gain access to the EEPROM, first we must obtain a hardware semaphore.
716 * Then for non-82573 hardware, set the EEPROM access request bit and wait
717 * for EEPROM access grant bit. If the access grant bit is not set, release
718 * hardware semaphore.
719 **/
720static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
721{
722 s32 ret_val;
723
724 ret_val = e1000_get_hw_semaphore_82571(hw);
725 if (ret_val)
726 return ret_val;
727
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000728 switch (hw->mac.type) {
729 case e1000_82573:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000730 break;
731 default:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700732 ret_val = e1000e_acquire_nvm(hw);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000733 break;
734 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700735
736 if (ret_val)
737 e1000_put_hw_semaphore_82571(hw);
738
739 return ret_val;
740}
741
742/**
743 * e1000_release_nvm_82571 - Release exclusive access to EEPROM
744 * @hw: pointer to the HW structure
745 *
746 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
747 **/
748static void e1000_release_nvm_82571(struct e1000_hw *hw)
749{
750 e1000e_release_nvm(hw);
751 e1000_put_hw_semaphore_82571(hw);
752}
753
754/**
755 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
756 * @hw: pointer to the HW structure
757 * @offset: offset within the EEPROM to be written to
758 * @words: number of words to write
759 * @data: 16 bit word(s) to be written to the EEPROM
760 *
761 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
762 *
763 * If e1000e_update_nvm_checksum is not called after this function, the
Auke Kok489815c2008-02-21 15:11:07 -0800764 * EEPROM will most likely contain an invalid checksum.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700765 **/
766static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
767 u16 *data)
768{
769 s32 ret_val;
770
771 switch (hw->mac.type) {
772 case e1000_82573:
Bruce Allan4662e822008-08-26 18:37:06 -0700773 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000774 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700775 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
776 break;
777 case e1000_82571:
778 case e1000_82572:
779 ret_val = e1000e_write_nvm_spi(hw, offset, words, data);
780 break;
781 default:
782 ret_val = -E1000_ERR_NVM;
783 break;
784 }
785
786 return ret_val;
787}
788
789/**
790 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
791 * @hw: pointer to the HW structure
792 *
793 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
794 * up to the checksum. Then calculates the EEPROM checksum and writes the
795 * value to the EEPROM.
796 **/
797static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
798{
799 u32 eecd;
800 s32 ret_val;
801 u16 i;
802
803 ret_val = e1000e_update_nvm_checksum_generic(hw);
804 if (ret_val)
805 return ret_val;
806
Bruce Allanad680762008-03-28 09:15:03 -0700807 /*
808 * If our nvm is an EEPROM, then we're done
809 * otherwise, commit the checksum to the flash NVM.
810 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700811 if (hw->nvm.type != e1000_nvm_flash_hw)
812 return ret_val;
813
814 /* Check for pending operations. */
815 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000816 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700817 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
818 break;
819 }
820
821 if (i == E1000_FLASH_UPDATES)
822 return -E1000_ERR_NVM;
823
824 /* Reset the firmware if using STM opcode. */
825 if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) {
Bruce Allanad680762008-03-28 09:15:03 -0700826 /*
827 * The enabling of and the actual reset must be done
Auke Kokbc7f75f2007-09-17 12:30:59 -0700828 * in two write cycles.
829 */
830 ew32(HICR, E1000_HICR_FW_RESET_ENABLE);
831 e1e_flush();
832 ew32(HICR, E1000_HICR_FW_RESET);
833 }
834
835 /* Commit the write to flash */
836 eecd = er32(EECD) | E1000_EECD_FLUPD;
837 ew32(EECD, eecd);
838
839 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000840 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700841 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
842 break;
843 }
844
845 if (i == E1000_FLASH_UPDATES)
846 return -E1000_ERR_NVM;
847
848 return 0;
849}
850
851/**
852 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
853 * @hw: pointer to the HW structure
854 *
855 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
856 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
857 **/
858static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
859{
860 if (hw->nvm.type == e1000_nvm_flash_hw)
861 e1000_fix_nvm_checksum_82571(hw);
862
863 return e1000e_validate_nvm_checksum_generic(hw);
864}
865
866/**
867 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
868 * @hw: pointer to the HW structure
869 * @offset: offset within the EEPROM to be written to
870 * @words: number of words to write
871 * @data: 16 bit word(s) to be written to the EEPROM
872 *
873 * After checking for invalid values, poll the EEPROM to ensure the previous
874 * command has completed before trying to write the next word. After write
875 * poll for completion.
876 *
877 * If e1000e_update_nvm_checksum is not called after this function, the
Auke Kok489815c2008-02-21 15:11:07 -0800878 * EEPROM will most likely contain an invalid checksum.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700879 **/
880static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
881 u16 words, u16 *data)
882{
883 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allana708dd82009-11-20 23:28:37 +0000884 u32 i, eewr = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700885 s32 ret_val = 0;
886
Bruce Allanad680762008-03-28 09:15:03 -0700887 /*
888 * A check for invalid values: offset too large, too many words,
889 * and not enough words.
890 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700891 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
892 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000893 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700894 return -E1000_ERR_NVM;
895 }
896
897 for (i = 0; i < words; i++) {
898 eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
899 ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
900 E1000_NVM_RW_REG_START;
901
902 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
903 if (ret_val)
904 break;
905
906 ew32(EEWR, eewr);
907
908 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
909 if (ret_val)
910 break;
911 }
912
913 return ret_val;
914}
915
916/**
917 * e1000_get_cfg_done_82571 - Poll for configuration done
918 * @hw: pointer to the HW structure
919 *
920 * Reads the management control register for the config done bit to be set.
921 **/
922static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
923{
924 s32 timeout = PHY_CFG_TIMEOUT;
925
926 while (timeout) {
927 if (er32(EEMNGCTL) &
928 E1000_NVM_CFG_DONE_PORT_0)
929 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000930 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700931 timeout--;
932 }
933 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000934 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700935 return -E1000_ERR_RESET;
936 }
937
938 return 0;
939}
940
941/**
942 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
943 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +0000944 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -0700945 *
946 * Sets the LPLU D0 state according to the active flag. When activating LPLU
947 * this function also disables smart speed and vice versa. LPLU will not be
948 * activated unless the device autonegotiation advertisement meets standards
949 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
950 * pointer entry point only called by PHY setup routines.
951 **/
952static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
953{
954 struct e1000_phy_info *phy = &hw->phy;
955 s32 ret_val;
956 u16 data;
957
958 ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
959 if (ret_val)
960 return ret_val;
961
962 if (active) {
963 data |= IGP02E1000_PM_D0_LPLU;
964 ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
965 if (ret_val)
966 return ret_val;
967
968 /* When LPLU is enabled, we should disable SmartSpeed */
969 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
970 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
971 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
972 if (ret_val)
973 return ret_val;
974 } else {
975 data &= ~IGP02E1000_PM_D0_LPLU;
976 ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
Bruce Allanad680762008-03-28 09:15:03 -0700977 /*
978 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -0700979 * during Dx states where the power conservation is most
980 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -0700981 * SmartSpeed, so performance is maintained.
982 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700983 if (phy->smart_speed == e1000_smart_speed_on) {
984 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700985 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700986 if (ret_val)
987 return ret_val;
988
989 data |= IGP01E1000_PSCFR_SMART_SPEED;
990 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700991 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700992 if (ret_val)
993 return ret_val;
994 } else if (phy->smart_speed == e1000_smart_speed_off) {
995 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700996 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700997 if (ret_val)
998 return ret_val;
999
1000 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1001 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -07001002 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001003 if (ret_val)
1004 return ret_val;
1005 }
1006 }
1007
1008 return 0;
1009}
1010
1011/**
1012 * e1000_reset_hw_82571 - Reset hardware
1013 * @hw: pointer to the HW structure
1014 *
Bruce Allanfe401672009-11-20 23:26:05 +00001015 * This resets the hardware into a known state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001016 **/
1017static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
1018{
Bruce Allandd93f952011-01-06 14:29:48 +00001019 u32 ctrl, ctrl_ext;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001020 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001021
Bruce Allanad680762008-03-28 09:15:03 -07001022 /*
1023 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07001024 * on the last TLP read/write transaction when MAC is reset.
1025 */
1026 ret_val = e1000e_disable_pcie_master(hw);
1027 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001028 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001029
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001030 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001031 ew32(IMC, 0xffffffff);
1032
1033 ew32(RCTL, 0);
1034 ew32(TCTL, E1000_TCTL_PSP);
1035 e1e_flush();
1036
Bruce Allan1bba4382011-03-19 00:27:20 +00001037 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001038
Bruce Allanad680762008-03-28 09:15:03 -07001039 /*
1040 * Must acquire the MDIO ownership before MAC reset.
1041 * Ownership defaults to firmware after a reset.
1042 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001043 switch (hw->mac.type) {
1044 case e1000_82573:
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001045 ret_val = e1000_get_hw_semaphore_82573(hw);
1046 break;
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001047 case e1000_82574:
1048 case e1000_82583:
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001049 ret_val = e1000_get_hw_semaphore_82574(hw);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001050 break;
1051 default:
1052 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001053 }
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001054 if (ret_val)
1055 e_dbg("Cannot acquire MDIO ownership\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001056
1057 ctrl = er32(CTRL);
1058
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001059 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001060 ew32(CTRL, ctrl | E1000_CTRL_RST);
1061
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001062 /* Must release MDIO ownership and mutex after MAC reset. */
1063 switch (hw->mac.type) {
1064 case e1000_82574:
1065 case e1000_82583:
1066 e1000_put_hw_semaphore_82574(hw);
1067 break;
1068 default:
1069 break;
1070 }
1071
Auke Kokbc7f75f2007-09-17 12:30:59 -07001072 if (hw->nvm.type == e1000_nvm_flash_hw) {
1073 udelay(10);
1074 ctrl_ext = er32(CTRL_EXT);
1075 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
1076 ew32(CTRL_EXT, ctrl_ext);
1077 e1e_flush();
1078 }
1079
1080 ret_val = e1000e_get_auto_rd_done(hw);
1081 if (ret_val)
1082 /* We don't want to continue accessing MAC registers. */
1083 return ret_val;
1084
Bruce Allanad680762008-03-28 09:15:03 -07001085 /*
1086 * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001087 * Need to wait for Phy configuration completion before accessing
1088 * NVM and Phy.
1089 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001090
1091 switch (hw->mac.type) {
1092 case e1000_82573:
1093 case e1000_82574:
1094 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001095 msleep(25);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001096 break;
1097 default:
1098 break;
1099 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001100
1101 /* Clear any pending interrupt events. */
1102 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00001103 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001104
Bruce Allan1aef70e2010-08-19 15:48:52 -07001105 if (hw->mac.type == e1000_82571) {
1106 /* Install any alternate MAC address into RAR0 */
1107 ret_val = e1000_check_alt_mac_addr_generic(hw);
1108 if (ret_val)
1109 return ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001110
Bruce Allan1aef70e2010-08-19 15:48:52 -07001111 e1000e_set_laa_state_82571(hw, true);
1112 }
Bill Hayes93ca1612007-10-31 15:21:52 -07001113
dave grahamc9523372009-02-10 12:52:28 +00001114 /* Reinitialize the 82571 serdes link state machine */
1115 if (hw->phy.media_type == e1000_media_type_internal_serdes)
1116 hw->mac.serdes_link_state = e1000_serdes_link_down;
1117
Auke Kokbc7f75f2007-09-17 12:30:59 -07001118 return 0;
1119}
1120
1121/**
1122 * e1000_init_hw_82571 - Initialize hardware
1123 * @hw: pointer to the HW structure
1124 *
1125 * This inits the hardware readying it for operation.
1126 **/
1127static s32 e1000_init_hw_82571(struct e1000_hw *hw)
1128{
1129 struct e1000_mac_info *mac = &hw->mac;
1130 u32 reg_data;
1131 s32 ret_val;
Bruce Allana708dd82009-11-20 23:28:37 +00001132 u16 i, rar_count = mac->rar_entry_count;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001133
1134 e1000_initialize_hw_bits_82571(hw);
1135
1136 /* Initialize identification LED */
1137 ret_val = e1000e_id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00001138 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001139 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00001140 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001141
1142 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001143 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +00001144 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001145
1146 /* Setup the receive address. */
Bruce Allanad680762008-03-28 09:15:03 -07001147 /*
1148 * If, however, a locally administered address was assigned to the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001149 * 82571, we must reserve a RAR for it to work around an issue where
1150 * resetting one port will reload the MAC on the other port.
1151 */
1152 if (e1000e_get_laa_state_82571(hw))
1153 rar_count--;
1154 e1000e_init_rx_addrs(hw, rar_count);
1155
1156 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001157 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001158 for (i = 0; i < mac->mta_reg_count; i++)
1159 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1160
1161 /* Setup link and flow control */
1162 ret_val = e1000_setup_link_82571(hw);
1163
1164 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001165 reg_data = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001166 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1167 E1000_TXDCTL_FULL_TX_DESC_WB |
1168 E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001169 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001170
1171 /* ...for both queues. */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001172 switch (mac->type) {
1173 case e1000_82573:
Bruce Allana65a4a02010-05-10 15:01:51 +00001174 e1000e_enable_tx_pkt_filtering(hw);
1175 /* fall through */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001176 case e1000_82574:
1177 case e1000_82583:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001178 reg_data = er32(GCR);
1179 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
1180 ew32(GCR, reg_data);
1181 break;
1182 default:
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001183 reg_data = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001184 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1185 E1000_TXDCTL_FULL_TX_DESC_WB |
1186 E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001187 ew32(TXDCTL(1), reg_data);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001188 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001189 }
1190
Bruce Allanad680762008-03-28 09:15:03 -07001191 /*
1192 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07001193 * important that we do this after we have tried to establish link
1194 * because the symbol error count will increment wildly if there
1195 * is no link.
1196 */
1197 e1000_clear_hw_cntrs_82571(hw);
1198
1199 return ret_val;
1200}
1201
1202/**
1203 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
1204 * @hw: pointer to the HW structure
1205 *
1206 * Initializes required hardware-dependent bits needed for normal operation.
1207 **/
1208static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1209{
1210 u32 reg;
1211
1212 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001213 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001214 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001215 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001216
1217 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001218 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001219 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001220 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001221
1222 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001223 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001224 reg &= ~(0xF << 27); /* 30:27 */
1225 switch (hw->mac.type) {
1226 case e1000_82571:
1227 case e1000_82572:
1228 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1229 break;
Bruce Alland6cb17d2011-12-16 00:46:22 +00001230 case e1000_82574:
1231 case e1000_82583:
1232 reg |= (1 << 26);
1233 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001234 default:
1235 break;
1236 }
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001237 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001238
1239 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001240 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001241 switch (hw->mac.type) {
1242 case e1000_82571:
1243 case e1000_82572:
1244 reg &= ~((1 << 29) | (1 << 30));
1245 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
1246 if (er32(TCTL) & E1000_TCTL_MULR)
1247 reg &= ~(1 << 28);
1248 else
1249 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001250 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001251 break;
1252 default:
1253 break;
1254 }
1255
1256 /* Device Control */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001257 switch (hw->mac.type) {
1258 case e1000_82573:
1259 case e1000_82574:
1260 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001261 reg = er32(CTRL);
1262 reg &= ~(1 << 29);
1263 ew32(CTRL, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001264 break;
1265 default:
1266 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001267 }
1268
1269 /* Extended Device Control */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001270 switch (hw->mac.type) {
1271 case e1000_82573:
1272 case e1000_82574:
1273 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001274 reg = er32(CTRL_EXT);
1275 reg &= ~(1 << 23);
1276 reg |= (1 << 22);
1277 ew32(CTRL_EXT, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001278 break;
1279 default:
1280 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001281 }
Bruce Allan4662e822008-08-26 18:37:06 -07001282
Alexander Duyck6ea7ae12008-11-14 06:54:36 +00001283 if (hw->mac.type == e1000_82571) {
1284 reg = er32(PBA_ECC);
1285 reg |= E1000_PBA_ECC_CORR_EN;
1286 ew32(PBA_ECC, reg);
1287 }
dave graham5df3f0e2009-02-10 12:51:41 +00001288 /*
1289 * Workaround for hardware errata.
1290 * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572
1291 */
1292
1293 if ((hw->mac.type == e1000_82571) ||
1294 (hw->mac.type == e1000_82572)) {
1295 reg = er32(CTRL_EXT);
1296 reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN;
1297 ew32(CTRL_EXT, reg);
1298 }
1299
Alexander Duyck6ea7ae12008-11-14 06:54:36 +00001300
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001301 /* PCI-Ex Control Registers */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001302 switch (hw->mac.type) {
1303 case e1000_82574:
1304 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -07001305 reg = er32(GCR);
1306 reg |= (1 << 22);
1307 ew32(GCR, reg);
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001308
Bruce Allan84efb7b2009-11-20 23:26:24 +00001309 /*
1310 * Workaround for hardware errata.
1311 * apply workaround for hardware errata documented in errata
1312 * docs Fixes issue where some error prone or unreliable PCIe
1313 * completions are occurring, particularly with ASPM enabled.
Bruce Allanaf667a22010-12-31 06:10:01 +00001314 * Without fix, issue can cause Tx timeouts.
Bruce Allan84efb7b2009-11-20 23:26:24 +00001315 */
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001316 reg = er32(GCR2);
1317 reg |= 1;
1318 ew32(GCR2, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001319 break;
1320 default:
1321 break;
Bruce Allan4662e822008-08-26 18:37:06 -07001322 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001323}
1324
1325/**
Bruce Allancaaddaf2009-12-01 15:46:43 +00001326 * e1000_clear_vfta_82571 - Clear VLAN filter table
Auke Kokbc7f75f2007-09-17 12:30:59 -07001327 * @hw: pointer to the HW structure
1328 *
1329 * Clears the register array which contains the VLAN filter table by
1330 * setting all the values to 0.
1331 **/
Bruce Allancaaddaf2009-12-01 15:46:43 +00001332static void e1000_clear_vfta_82571(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001333{
1334 u32 offset;
1335 u32 vfta_value = 0;
1336 u32 vfta_offset = 0;
1337 u32 vfta_bit_in_reg = 0;
1338
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001339 switch (hw->mac.type) {
1340 case e1000_82573:
1341 case e1000_82574:
1342 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001343 if (hw->mng_cookie.vlan_id != 0) {
Bruce Allanad680762008-03-28 09:15:03 -07001344 /*
1345 * The VFTA is a 4096b bit-field, each identifying
Auke Kokbc7f75f2007-09-17 12:30:59 -07001346 * a single VLAN ID. The following operations
1347 * determine which 32b entry (i.e. offset) into the
1348 * array we want to set the VLAN ID (i.e. bit) of
1349 * the manageability unit.
1350 */
1351 vfta_offset = (hw->mng_cookie.vlan_id >>
1352 E1000_VFTA_ENTRY_SHIFT) &
1353 E1000_VFTA_ENTRY_MASK;
1354 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
1355 E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
1356 }
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001357 break;
1358 default:
1359 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001360 }
1361 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
Bruce Allanad680762008-03-28 09:15:03 -07001362 /*
1363 * If the offset we want to clear is the same offset of the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001364 * manageability VLAN ID, then clear all bits except that of
1365 * the manageability unit.
1366 */
1367 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
1368 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
1369 e1e_flush();
1370 }
1371}
1372
1373/**
Bruce Allan4662e822008-08-26 18:37:06 -07001374 * e1000_check_mng_mode_82574 - Check manageability is enabled
1375 * @hw: pointer to the HW structure
1376 *
1377 * Reads the NVM Initialization Control Word 2 and returns true
1378 * (>0) if any manageability is enabled, else false (0).
1379 **/
1380static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
1381{
1382 u16 data;
1383
1384 e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
1385 return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
1386}
1387
1388/**
1389 * e1000_led_on_82574 - Turn LED on
1390 * @hw: pointer to the HW structure
1391 *
1392 * Turn LED on.
1393 **/
1394static s32 e1000_led_on_82574(struct e1000_hw *hw)
1395{
1396 u32 ctrl;
1397 u32 i;
1398
1399 ctrl = hw->mac.ledctl_mode2;
1400 if (!(E1000_STATUS_LU & er32(STATUS))) {
1401 /*
1402 * If no link, then turn LED on by setting the invert bit
1403 * for each LED that's "on" (0x0E) in ledctl_mode2.
1404 */
1405 for (i = 0; i < 4; i++)
1406 if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1407 E1000_LEDCTL_MODE_LED_ON)
1408 ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
1409 }
1410 ew32(LEDCTL, ctrl);
1411
1412 return 0;
1413}
1414
1415/**
Carolyn Wybornyff10e132010-10-28 00:59:53 +00001416 * e1000_check_phy_82574 - check 82574 phy hung state
1417 * @hw: pointer to the HW structure
1418 *
1419 * Returns whether phy is hung or not
1420 **/
1421bool e1000_check_phy_82574(struct e1000_hw *hw)
1422{
1423 u16 status_1kbt = 0;
1424 u16 receive_errors = 0;
1425 bool phy_hung = false;
1426 s32 ret_val = 0;
1427
1428 /*
1429 * Read PHY Receive Error counter first, if its is max - all F's then
1430 * read the Base1000T status register If both are max then PHY is hung.
1431 */
1432 ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors);
1433
1434 if (ret_val)
1435 goto out;
1436 if (receive_errors == E1000_RECEIVE_ERROR_MAX) {
1437 ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt);
1438 if (ret_val)
1439 goto out;
1440 if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) ==
1441 E1000_IDLE_ERROR_COUNT_MASK)
1442 phy_hung = true;
1443 }
1444out:
1445 return phy_hung;
1446}
1447
1448/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001449 * e1000_setup_link_82571 - Setup flow control and link settings
1450 * @hw: pointer to the HW structure
1451 *
1452 * Determines which flow control settings to use, then configures flow
1453 * control. Calls the appropriate media-specific link configuration
1454 * function. Assuming the adapter has a valid link partner, a valid link
1455 * should be established. Assumes the hardware has previously been reset
1456 * and the transmitter and receiver are not enabled.
1457 **/
1458static s32 e1000_setup_link_82571(struct e1000_hw *hw)
1459{
Bruce Allanad680762008-03-28 09:15:03 -07001460 /*
1461 * 82573 does not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07001462 * the default flow control setting, so we explicitly
1463 * set it to full.
1464 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001465 switch (hw->mac.type) {
1466 case e1000_82573:
1467 case e1000_82574:
1468 case e1000_82583:
1469 if (hw->fc.requested_mode == e1000_fc_default)
1470 hw->fc.requested_mode = e1000_fc_full;
1471 break;
1472 default:
1473 break;
1474 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001475
1476 return e1000e_setup_link(hw);
1477}
1478
1479/**
1480 * e1000_setup_copper_link_82571 - Configure copper link settings
1481 * @hw: pointer to the HW structure
1482 *
1483 * Configures the link for auto-neg or forced speed and duplex. Then we check
1484 * for link, once link is established calls to configure collision distance
1485 * and flow control are called.
1486 **/
1487static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
1488{
1489 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001490 s32 ret_val;
1491
1492 ctrl = er32(CTRL);
1493 ctrl |= E1000_CTRL_SLU;
1494 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1495 ew32(CTRL, ctrl);
1496
1497 switch (hw->phy.type) {
1498 case e1000_phy_m88:
Bruce Allan4662e822008-08-26 18:37:06 -07001499 case e1000_phy_bm:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001500 ret_val = e1000e_copper_link_setup_m88(hw);
1501 break;
1502 case e1000_phy_igp_2:
1503 ret_val = e1000e_copper_link_setup_igp(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001504 break;
1505 default:
1506 return -E1000_ERR_PHY;
1507 break;
1508 }
1509
1510 if (ret_val)
1511 return ret_val;
1512
1513 ret_val = e1000e_setup_copper_link(hw);
1514
1515 return ret_val;
1516}
1517
1518/**
1519 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
1520 * @hw: pointer to the HW structure
1521 *
1522 * Configures collision distance and flow control for fiber and serdes links.
1523 * Upon successful setup, poll for link.
1524 **/
1525static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
1526{
1527 switch (hw->mac.type) {
1528 case e1000_82571:
1529 case e1000_82572:
Bruce Allanad680762008-03-28 09:15:03 -07001530 /*
1531 * If SerDes loopback mode is entered, there is no form
Auke Kokbc7f75f2007-09-17 12:30:59 -07001532 * of reset to take the adapter out of that mode. So we
1533 * have to explicitly take the adapter out of loopback
Auke Kok489815c2008-02-21 15:11:07 -08001534 * mode. This prevents drivers from twiddling their thumbs
Auke Kokbc7f75f2007-09-17 12:30:59 -07001535 * if another tool failed to take it out of loopback mode.
1536 */
Bruce Allanad680762008-03-28 09:15:03 -07001537 ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001538 break;
1539 default:
1540 break;
1541 }
1542
1543 return e1000e_setup_fiber_serdes_link(hw);
1544}
1545
1546/**
dave grahamc9523372009-02-10 12:52:28 +00001547 * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
1548 * @hw: pointer to the HW structure
1549 *
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001550 * Reports the link state as up or down.
1551 *
1552 * If autonegotiation is supported by the link partner, the link state is
1553 * determined by the result of autonegotiation. This is the most likely case.
1554 * If autonegotiation is not supported by the link partner, and the link
1555 * has a valid signal, force the link up.
1556 *
1557 * The link state is represented internally here by 4 states:
1558 *
1559 * 1) down
1560 * 2) autoneg_progress
Daniel Mack3ad2f3f2010-02-03 08:01:28 +08001561 * 3) autoneg_complete (the link successfully autonegotiated)
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001562 * 4) forced_up (the link has been forced up, it did not autonegotiate)
1563 *
dave grahamc9523372009-02-10 12:52:28 +00001564 **/
Hannes Ederf6370112009-02-14 11:32:25 +00001565static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
dave grahamc9523372009-02-10 12:52:28 +00001566{
1567 struct e1000_mac_info *mac = &hw->mac;
1568 u32 rxcw;
1569 u32 ctrl;
1570 u32 status;
Bruce Alland9c76f92010-11-24 06:01:35 +00001571 u32 txcw;
1572 u32 i;
dave grahamc9523372009-02-10 12:52:28 +00001573 s32 ret_val = 0;
1574
1575 ctrl = er32(CTRL);
1576 status = er32(STATUS);
1577 rxcw = er32(RXCW);
1578
1579 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
1580
1581 /* Receiver is synchronized with no invalid bits. */
1582 switch (mac->serdes_link_state) {
1583 case e1000_serdes_link_autoneg_complete:
1584 if (!(status & E1000_STATUS_LU)) {
1585 /*
1586 * We have lost link, retry autoneg before
1587 * reporting link failure
1588 */
1589 mac->serdes_link_state =
1590 e1000_serdes_link_autoneg_progress;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001591 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001592 e_dbg("AN_UP -> AN_PROG\n");
Bruce Allana82a14f2010-11-24 06:01:20 +00001593 } else {
1594 mac->serdes_has_link = true;
dave grahamc9523372009-02-10 12:52:28 +00001595 }
Bruce Allana82a14f2010-11-24 06:01:20 +00001596 break;
dave grahamc9523372009-02-10 12:52:28 +00001597
1598 case e1000_serdes_link_forced_up:
1599 /*
1600 * If we are receiving /C/ ordered sets, re-enable
1601 * auto-negotiation in the TXCW register and disable
1602 * forced link in the Device Control register in an
1603 * attempt to auto-negotiate with our link partner.
Bruce Alland478eb42010-11-16 19:50:13 -08001604 * If the partner code word is null, stop forcing
1605 * and restart auto negotiation.
dave grahamc9523372009-02-10 12:52:28 +00001606 */
Bruce Alland478eb42010-11-16 19:50:13 -08001607 if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
dave grahamc9523372009-02-10 12:52:28 +00001608 /* Enable autoneg, and unforce link up */
1609 ew32(TXCW, mac->txcw);
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001610 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
dave grahamc9523372009-02-10 12:52:28 +00001611 mac->serdes_link_state =
1612 e1000_serdes_link_autoneg_progress;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001613 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001614 e_dbg("FORCED_UP -> AN_PROG\n");
Bruce Allana82a14f2010-11-24 06:01:20 +00001615 } else {
1616 mac->serdes_has_link = true;
dave grahamc9523372009-02-10 12:52:28 +00001617 }
1618 break;
1619
1620 case e1000_serdes_link_autoneg_progress:
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001621 if (rxcw & E1000_RXCW_C) {
1622 /*
1623 * We received /C/ ordered sets, meaning the
1624 * link partner has autonegotiated, and we can
1625 * trust the Link Up (LU) status bit.
1626 */
1627 if (status & E1000_STATUS_LU) {
1628 mac->serdes_link_state =
1629 e1000_serdes_link_autoneg_complete;
1630 e_dbg("AN_PROG -> AN_UP\n");
1631 mac->serdes_has_link = true;
1632 } else {
1633 /* Autoneg completed, but failed. */
1634 mac->serdes_link_state =
1635 e1000_serdes_link_down;
1636 e_dbg("AN_PROG -> DOWN\n");
1637 }
dave grahamc9523372009-02-10 12:52:28 +00001638 } else {
1639 /*
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001640 * The link partner did not autoneg.
1641 * Force link up and full duplex, and change
1642 * state to forced.
dave grahamc9523372009-02-10 12:52:28 +00001643 */
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001644 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
dave grahamc9523372009-02-10 12:52:28 +00001645 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
1646 ew32(CTRL, ctrl);
1647
1648 /* Configure Flow Control after link up. */
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001649 ret_val = e1000e_config_fc_after_link_up(hw);
dave grahamc9523372009-02-10 12:52:28 +00001650 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001651 e_dbg("Error config flow control\n");
dave grahamc9523372009-02-10 12:52:28 +00001652 break;
1653 }
1654 mac->serdes_link_state =
1655 e1000_serdes_link_forced_up;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001656 mac->serdes_has_link = true;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001657 e_dbg("AN_PROG -> FORCED_UP\n");
dave grahamc9523372009-02-10 12:52:28 +00001658 }
dave grahamc9523372009-02-10 12:52:28 +00001659 break;
1660
1661 case e1000_serdes_link_down:
1662 default:
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001663 /*
1664 * The link was down but the receiver has now gained
dave grahamc9523372009-02-10 12:52:28 +00001665 * valid sync, so lets see if we can bring the link
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001666 * up.
1667 */
dave grahamc9523372009-02-10 12:52:28 +00001668 ew32(TXCW, mac->txcw);
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001669 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
dave grahamc9523372009-02-10 12:52:28 +00001670 mac->serdes_link_state =
1671 e1000_serdes_link_autoneg_progress;
Bruce Allana82a14f2010-11-24 06:01:20 +00001672 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001673 e_dbg("DOWN -> AN_PROG\n");
dave grahamc9523372009-02-10 12:52:28 +00001674 break;
1675 }
1676 } else {
1677 if (!(rxcw & E1000_RXCW_SYNCH)) {
1678 mac->serdes_has_link = false;
1679 mac->serdes_link_state = e1000_serdes_link_down;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001680 e_dbg("ANYSTATE -> DOWN\n");
dave grahamc9523372009-02-10 12:52:28 +00001681 } else {
1682 /*
Bruce Alland9c76f92010-11-24 06:01:35 +00001683 * Check several times, if Sync and Config
1684 * both are consistently 1 then simply ignore
1685 * the Invalid bit and restart Autoneg
dave grahamc9523372009-02-10 12:52:28 +00001686 */
Bruce Alland9c76f92010-11-24 06:01:35 +00001687 for (i = 0; i < AN_RETRY_COUNT; i++) {
1688 udelay(10);
1689 rxcw = er32(RXCW);
1690 if ((rxcw & E1000_RXCW_IV) &&
1691 !((rxcw & E1000_RXCW_SYNCH) &&
1692 (rxcw & E1000_RXCW_C))) {
1693 mac->serdes_has_link = false;
1694 mac->serdes_link_state =
1695 e1000_serdes_link_down;
1696 e_dbg("ANYSTATE -> DOWN\n");
1697 break;
1698 }
1699 }
1700
1701 if (i == AN_RETRY_COUNT) {
1702 txcw = er32(TXCW);
1703 txcw |= E1000_TXCW_ANE;
1704 ew32(TXCW, txcw);
1705 mac->serdes_link_state =
1706 e1000_serdes_link_autoneg_progress;
dave grahamc9523372009-02-10 12:52:28 +00001707 mac->serdes_has_link = false;
Bruce Alland9c76f92010-11-24 06:01:35 +00001708 e_dbg("ANYSTATE -> AN_PROG\n");
dave grahamc9523372009-02-10 12:52:28 +00001709 }
1710 }
1711 }
1712
1713 return ret_val;
1714}
1715
1716/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001717 * e1000_valid_led_default_82571 - Verify a valid default LED config
1718 * @hw: pointer to the HW structure
1719 * @data: pointer to the NVM (EEPROM)
1720 *
1721 * Read the EEPROM for the current default LED configuration. If the
1722 * LED configuration is not valid, set to a valid LED configuration.
1723 **/
1724static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
1725{
1726 s32 ret_val;
1727
1728 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
1729 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001730 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001731 return ret_val;
1732 }
1733
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001734 switch (hw->mac.type) {
1735 case e1000_82573:
1736 case e1000_82574:
1737 case e1000_82583:
1738 if (*data == ID_LED_RESERVED_F746)
1739 *data = ID_LED_DEFAULT_82573;
1740 break;
1741 default:
1742 if (*data == ID_LED_RESERVED_0000 ||
1743 *data == ID_LED_RESERVED_FFFF)
1744 *data = ID_LED_DEFAULT;
1745 break;
1746 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001747
1748 return 0;
1749}
1750
1751/**
1752 * e1000e_get_laa_state_82571 - Get locally administered address state
1753 * @hw: pointer to the HW structure
1754 *
Auke Kok489815c2008-02-21 15:11:07 -08001755 * Retrieve and return the current locally administered address state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001756 **/
1757bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
1758{
1759 if (hw->mac.type != e1000_82571)
Bruce Allan564ea9b2009-11-20 23:26:44 +00001760 return false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001761
1762 return hw->dev_spec.e82571.laa_is_present;
1763}
1764
1765/**
1766 * e1000e_set_laa_state_82571 - Set locally administered address state
1767 * @hw: pointer to the HW structure
1768 * @state: enable/disable locally administered address
1769 *
Bruce Allan5ff5b662009-12-01 15:51:11 +00001770 * Enable/Disable the current locally administered address state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001771 **/
1772void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
1773{
1774 if (hw->mac.type != e1000_82571)
1775 return;
1776
1777 hw->dev_spec.e82571.laa_is_present = state;
1778
1779 /* If workaround is activated... */
1780 if (state)
Bruce Allanad680762008-03-28 09:15:03 -07001781 /*
1782 * Hold a copy of the LAA in RAR[14] This is done so that
Auke Kokbc7f75f2007-09-17 12:30:59 -07001783 * between the time RAR[0] gets clobbered and the time it
1784 * gets fixed, the actual LAA is in one of the RARs and no
1785 * incoming packets directed to this port are dropped.
1786 * Eventually the LAA will be in RAR[0] and RAR[14].
1787 */
1788 e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1);
1789}
1790
1791/**
1792 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
1793 * @hw: pointer to the HW structure
1794 *
1795 * Verifies that the EEPROM has completed the update. After updating the
1796 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
1797 * the checksum fix is not implemented, we need to set the bit and update
1798 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
1799 * we need to return bad checksum.
1800 **/
1801static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
1802{
1803 struct e1000_nvm_info *nvm = &hw->nvm;
1804 s32 ret_val;
1805 u16 data;
1806
1807 if (nvm->type != e1000_nvm_flash_hw)
1808 return 0;
1809
Bruce Allanad680762008-03-28 09:15:03 -07001810 /*
1811 * Check bit 4 of word 10h. If it is 0, firmware is done updating
Auke Kokbc7f75f2007-09-17 12:30:59 -07001812 * 10h-12h. Checksum may need to be fixed.
1813 */
1814 ret_val = e1000_read_nvm(hw, 0x10, 1, &data);
1815 if (ret_val)
1816 return ret_val;
1817
1818 if (!(data & 0x10)) {
Bruce Allanad680762008-03-28 09:15:03 -07001819 /*
1820 * Read 0x23 and check bit 15. This bit is a 1
Auke Kokbc7f75f2007-09-17 12:30:59 -07001821 * when the checksum has already been fixed. If
1822 * the checksum is still wrong and this bit is a
1823 * 1, we need to return bad checksum. Otherwise,
1824 * we need to set this bit to a 1 and update the
1825 * checksum.
1826 */
1827 ret_val = e1000_read_nvm(hw, 0x23, 1, &data);
1828 if (ret_val)
1829 return ret_val;
1830
1831 if (!(data & 0x8000)) {
1832 data |= 0x8000;
1833 ret_val = e1000_write_nvm(hw, 0x23, 1, &data);
1834 if (ret_val)
1835 return ret_val;
1836 ret_val = e1000e_update_nvm_checksum(hw);
1837 }
1838 }
1839
1840 return 0;
1841}
1842
1843/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001844 * e1000_read_mac_addr_82571 - Read device MAC address
1845 * @hw: pointer to the HW structure
1846 **/
1847static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1848{
1849 s32 ret_val = 0;
1850
Bruce Allan1aef70e2010-08-19 15:48:52 -07001851 if (hw->mac.type == e1000_82571) {
1852 /*
1853 * If there's an alternate MAC address place it in RAR0
1854 * so that it will override the Si installed default perm
1855 * address.
1856 */
1857 ret_val = e1000_check_alt_mac_addr_generic(hw);
1858 if (ret_val)
1859 goto out;
1860 }
Bruce Allan608f8a02010-01-13 02:04:58 +00001861
1862 ret_val = e1000_read_mac_addr_generic(hw);
1863
1864out:
1865 return ret_val;
1866}
1867
1868/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001869 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
1870 * @hw: pointer to the HW structure
1871 *
1872 * In the case of a PHY power down to save power, or to turn off link during a
1873 * driver unload, or wake on lan is not enabled, remove the link.
1874 **/
1875static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
1876{
1877 struct e1000_phy_info *phy = &hw->phy;
1878 struct e1000_mac_info *mac = &hw->mac;
1879
1880 if (!(phy->ops.check_reset_block))
1881 return;
1882
1883 /* If the management interface is not enabled, then power down */
1884 if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
1885 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001886}
1887
1888/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001889 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
1890 * @hw: pointer to the HW structure
1891 *
1892 * Clears the hardware counters by reading the counter registers.
1893 **/
1894static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
1895{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001896 e1000e_clear_hw_cntrs_base(hw);
1897
Bruce Allan99673d92009-11-20 23:27:21 +00001898 er32(PRC64);
1899 er32(PRC127);
1900 er32(PRC255);
1901 er32(PRC511);
1902 er32(PRC1023);
1903 er32(PRC1522);
1904 er32(PTC64);
1905 er32(PTC127);
1906 er32(PTC255);
1907 er32(PTC511);
1908 er32(PTC1023);
1909 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001910
Bruce Allan99673d92009-11-20 23:27:21 +00001911 er32(ALGNERRC);
1912 er32(RXERRC);
1913 er32(TNCRS);
1914 er32(CEXTERR);
1915 er32(TSCTC);
1916 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001917
Bruce Allan99673d92009-11-20 23:27:21 +00001918 er32(MGTPRC);
1919 er32(MGTPDC);
1920 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001921
Bruce Allan99673d92009-11-20 23:27:21 +00001922 er32(IAC);
1923 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001924
Bruce Allan99673d92009-11-20 23:27:21 +00001925 er32(ICRXPTC);
1926 er32(ICRXATC);
1927 er32(ICTXPTC);
1928 er32(ICTXATC);
1929 er32(ICTXQEC);
1930 er32(ICTXQMTC);
1931 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001932}
1933
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001934static const struct e1000_mac_operations e82571_mac_ops = {
Bruce Allan4662e822008-08-26 18:37:06 -07001935 /* .check_mng_mode: mac type dependent */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001936 /* .check_for_link: media type dependent */
Bruce Allana4f58f52009-06-02 11:29:18 +00001937 .id_led_init = e1000e_id_led_init,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001938 .cleanup_led = e1000e_cleanup_led_generic,
1939 .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
1940 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001941 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001942 /* .get_link_up_info: media type dependent */
Bruce Allan4662e822008-08-26 18:37:06 -07001943 /* .led_on: mac type dependent */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001944 .led_off = e1000e_led_off_generic,
Bruce Allanab8932f2010-01-13 02:05:38 +00001945 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001946 .write_vfta = e1000_write_vfta_generic,
1947 .clear_vfta = e1000_clear_vfta_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001948 .reset_hw = e1000_reset_hw_82571,
1949 .init_hw = e1000_init_hw_82571,
1950 .setup_link = e1000_setup_link_82571,
1951 /* .setup_physical_interface: media type dependent */
Bruce Allana4f58f52009-06-02 11:29:18 +00001952 .setup_led = e1000e_setup_led_generic,
Bruce Allan608f8a02010-01-13 02:04:58 +00001953 .read_mac_addr = e1000_read_mac_addr_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001954};
1955
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001956static const struct e1000_phy_operations e82_phy_ops_igp = {
Bruce Allan94d81862009-11-20 23:25:26 +00001957 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001958 .check_polarity = e1000_check_polarity_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001959 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001960 .commit = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001961 .force_speed_duplex = e1000e_phy_force_speed_duplex_igp,
1962 .get_cfg_done = e1000_get_cfg_done_82571,
1963 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00001964 .get_info = e1000e_get_phy_info_igp,
1965 .read_reg = e1000e_read_phy_reg_igp,
1966 .release = e1000_put_hw_semaphore_82571,
1967 .reset = e1000e_phy_hw_reset_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001968 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1969 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001970 .write_reg = e1000e_write_phy_reg_igp,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001971 .cfg_on_link_up = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001972};
1973
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001974static const struct e1000_phy_operations e82_phy_ops_m88 = {
Bruce Allan94d81862009-11-20 23:25:26 +00001975 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001976 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001977 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001978 .commit = e1000e_phy_sw_reset,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001979 .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
1980 .get_cfg_done = e1000e_get_cfg_done,
1981 .get_cable_length = e1000e_get_cable_length_m88,
Bruce Allan94d81862009-11-20 23:25:26 +00001982 .get_info = e1000e_get_phy_info_m88,
1983 .read_reg = e1000e_read_phy_reg_m88,
1984 .release = e1000_put_hw_semaphore_82571,
1985 .reset = e1000e_phy_hw_reset_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001986 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1987 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001988 .write_reg = e1000e_write_phy_reg_m88,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001989 .cfg_on_link_up = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001990};
1991
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001992static const struct e1000_phy_operations e82_phy_ops_bm = {
Bruce Allan94d81862009-11-20 23:25:26 +00001993 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001994 .check_polarity = e1000_check_polarity_m88,
Bruce Allan4662e822008-08-26 18:37:06 -07001995 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001996 .commit = e1000e_phy_sw_reset,
Bruce Allan4662e822008-08-26 18:37:06 -07001997 .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
1998 .get_cfg_done = e1000e_get_cfg_done,
1999 .get_cable_length = e1000e_get_cable_length_m88,
Bruce Allan94d81862009-11-20 23:25:26 +00002000 .get_info = e1000e_get_phy_info_m88,
2001 .read_reg = e1000e_read_phy_reg_bm2,
2002 .release = e1000_put_hw_semaphore_82571,
2003 .reset = e1000e_phy_hw_reset_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07002004 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
2005 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00002006 .write_reg = e1000e_write_phy_reg_bm2,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08002007 .cfg_on_link_up = NULL,
Bruce Allan4662e822008-08-26 18:37:06 -07002008};
2009
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002010static const struct e1000_nvm_operations e82571_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00002011 .acquire = e1000_acquire_nvm_82571,
2012 .read = e1000e_read_nvm_eerd,
2013 .release = e1000_release_nvm_82571,
2014 .update = e1000_update_nvm_checksum_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002015 .valid_led_default = e1000_valid_led_default_82571,
Bruce Allan94d81862009-11-20 23:25:26 +00002016 .validate = e1000_validate_nvm_checksum_82571,
2017 .write = e1000_write_nvm_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002018};
2019
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002020const struct e1000_info e1000_82571_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002021 .mac = e1000_82571,
2022 .flags = FLAG_HAS_HW_VLAN_FILTER
2023 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07002024 | FLAG_HAS_WOL
2025 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07002026 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07002027 | FLAG_HAS_SMART_POWER_DOWN
2028 | FLAG_RESET_OVERWRITES_LAA /* errata */
2029 | FLAG_TARC_SPEED_MODE_BIT /* errata */
2030 | FLAG_APME_CHECK_PORT_B,
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00002031 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
2032 | FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002033 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00002034 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07002035 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002036 .mac_ops = &e82571_mac_ops,
2037 .phy_ops = &e82_phy_ops_igp,
2038 .nvm_ops = &e82571_nvm_ops,
2039};
2040
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002041const struct e1000_info e1000_82572_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002042 .mac = e1000_82572,
2043 .flags = FLAG_HAS_HW_VLAN_FILTER
2044 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07002045 | FLAG_HAS_WOL
2046 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07002047 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07002048 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00002049 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
2050 | FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002051 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00002052 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07002053 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002054 .mac_ops = &e82571_mac_ops,
2055 .phy_ops = &e82_phy_ops_igp,
2056 .nvm_ops = &e82571_nvm_ops,
2057};
2058
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002059const struct e1000_info e1000_82573_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002060 .mac = e1000_82573,
2061 .flags = FLAG_HAS_HW_VLAN_FILTER
Auke Kokbc7f75f2007-09-17 12:30:59 -07002062 | FLAG_HAS_WOL
2063 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07002064 | FLAG_HAS_SMART_POWER_DOWN
2065 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07002066 | FLAG_HAS_SWSM_ON_LOAD,
Bruce Allan78cd29d2011-03-24 03:09:03 +00002067 .flags2 = FLAG2_DISABLE_ASPM_L1
2068 | FLAG2_DISABLE_ASPM_L0S,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002069 .pba = 20,
Bruce Allan2adc55c2009-06-02 11:28:58 +00002070 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07002071 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002072 .mac_ops = &e82571_mac_ops,
2073 .phy_ops = &e82_phy_ops_m88,
Auke Kok31f8c4f2008-02-21 15:10:47 -08002074 .nvm_ops = &e82571_nvm_ops,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002075};
2076
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002077const struct e1000_info e1000_82574_info = {
Bruce Allan4662e822008-08-26 18:37:06 -07002078 .mac = e1000_82574,
2079 .flags = FLAG_HAS_HW_VLAN_FILTER
2080 | FLAG_HAS_MSIX
2081 | FLAG_HAS_JUMBO_FRAMES
2082 | FLAG_HAS_WOL
2083 | FLAG_APME_IN_CTRL3
Bruce Allan4662e822008-08-26 18:37:06 -07002084 | FLAG_HAS_SMART_POWER_DOWN
2085 | FLAG_HAS_AMT
2086 | FLAG_HAS_CTRLEXT_ON_LOAD,
Bruce Allan78cd29d2011-03-24 03:09:03 +00002087 .flags2 = FLAG2_CHECK_PHY_HANG
Bruce Allan7f99ae62011-07-22 06:21:35 +00002088 | FLAG2_DISABLE_ASPM_L0S
2089 | FLAG2_NO_DISABLE_RX,
Bruce Allaned5c2b02010-11-24 06:01:25 +00002090 .pba = 32,
Alexander Duycka825e002009-10-02 12:30:42 +00002091 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allan4662e822008-08-26 18:37:06 -07002092 .get_variants = e1000_get_variants_82571,
2093 .mac_ops = &e82571_mac_ops,
2094 .phy_ops = &e82_phy_ops_bm,
2095 .nvm_ops = &e82571_nvm_ops,
2096};
2097
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002098const struct e1000_info e1000_82583_info = {
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002099 .mac = e1000_82583,
2100 .flags = FLAG_HAS_HW_VLAN_FILTER
2101 | FLAG_HAS_WOL
2102 | FLAG_APME_IN_CTRL3
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002103 | FLAG_HAS_SMART_POWER_DOWN
2104 | FLAG_HAS_AMT
Carolyn Wybornya3d72d52011-07-12 16:10:11 +00002105 | FLAG_HAS_JUMBO_FRAMES
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002106 | FLAG_HAS_CTRLEXT_ON_LOAD,
Bruce Allan7f99ae62011-07-22 06:21:35 +00002107 .flags2 = FLAG2_DISABLE_ASPM_L0S
2108 | FLAG2_NO_DISABLE_RX,
Bruce Allaned5c2b02010-11-24 06:01:25 +00002109 .pba = 32,
Carolyn Wybornya3d72d52011-07-12 16:10:11 +00002110 .max_hw_frame_size = DEFAULT_JUMBO,
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002111 .get_variants = e1000_get_variants_82571,
2112 .mac_ops = &e82571_mac_ops,
2113 .phy_ops = &e82_phy_ops_bm,
2114 .nvm_ops = &e82571_nvm_ops,
2115};
2116