blob: 4cadcc76ad581b226e424f54bb1a7bcbefd8ae62 [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanf5e261e2012-01-01 16:00:03 +00004 Copyright(c) 1999 - 2012 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;
Dave Graham23a2d1b2009-06-08 14:28:17 +0000242 u32 swsm = 0;
243 u32 swsm2 = 0;
244 bool force_clear_smbi = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700245
Bruce Allan66092f52012-01-31 06:37:48 +0000246 /* Set media type and media-dependent function pointers */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700247 switch (adapter->pdev->device) {
248 case E1000_DEV_ID_82571EB_FIBER:
249 case E1000_DEV_ID_82572EI_FIBER:
250 case E1000_DEV_ID_82571EB_QUAD_FIBER:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700251 hw->phy.media_type = e1000_media_type_fiber;
Bruce Allan66092f52012-01-31 06:37:48 +0000252 mac->ops.setup_physical_interface =
253 e1000_setup_fiber_serdes_link_82571;
254 mac->ops.check_for_link = e1000e_check_for_fiber_link;
255 mac->ops.get_link_up_info =
256 e1000e_get_speed_and_duplex_fiber_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700257 break;
258 case E1000_DEV_ID_82571EB_SERDES:
Auke Kok040babf2007-10-31 15:22:05 -0700259 case E1000_DEV_ID_82571EB_SERDES_DUAL:
260 case E1000_DEV_ID_82571EB_SERDES_QUAD:
Bruce Allan66092f52012-01-31 06:37:48 +0000261 case E1000_DEV_ID_82572EI_SERDES:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700262 hw->phy.media_type = e1000_media_type_internal_serdes;
Bruce Allan66092f52012-01-31 06:37:48 +0000263 mac->ops.setup_physical_interface =
264 e1000_setup_fiber_serdes_link_82571;
265 mac->ops.check_for_link = e1000_check_for_serdes_link_82571;
266 mac->ops.get_link_up_info =
267 e1000e_get_speed_and_duplex_fiber_serdes;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700268 break;
269 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700270 hw->phy.media_type = e1000_media_type_copper;
Bruce Allan66092f52012-01-31 06:37:48 +0000271 mac->ops.setup_physical_interface =
272 e1000_setup_copper_link_82571;
273 mac->ops.check_for_link = e1000e_check_for_copper_link;
274 mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_copper;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700275 break;
276 }
277
278 /* Set mta register count */
279 mac->mta_reg_count = 128;
280 /* Set rar entry count */
281 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allanf464ba82010-01-07 16:31:35 +0000282 /* Adaptive IFS supported */
283 mac->adaptive_ifs = true;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700284
Bruce Allan66092f52012-01-31 06:37:48 +0000285 /* MAC-specific function pointers */
Bruce Allan4662e822008-08-26 18:37:06 -0700286 switch (hw->mac.type) {
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000287 case e1000_82573:
Bruce Allan66092f52012-01-31 06:37:48 +0000288 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
289 mac->ops.check_mng_mode = e1000e_check_mng_mode_generic;
290 mac->ops.led_on = e1000e_led_on_generic;
291 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana65a4a02010-05-10 15:01:51 +0000292
293 /* FWSM register */
294 mac->has_fwsm = true;
295 /*
296 * ARC supported; valid only if manageability features are
297 * enabled.
298 */
299 mac->arc_subsystem_valid =
300 (er32(FWSM) & E1000_FWSM_MODE_MASK)
301 ? true : false;
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000302 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700303 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000304 case e1000_82583:
Bruce Allan66092f52012-01-31 06:37:48 +0000305 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
306 mac->ops.check_mng_mode = e1000_check_mng_mode_82574;
307 mac->ops.led_on = e1000_led_on_82574;
Bruce Allan4662e822008-08-26 18:37:06 -0700308 break;
309 default:
Bruce Allan66092f52012-01-31 06:37:48 +0000310 mac->ops.check_mng_mode = e1000e_check_mng_mode_generic;
311 mac->ops.led_on = e1000e_led_on_generic;
312 mac->ops.blink_led = e1000e_blink_led_generic;
Bruce Allana65a4a02010-05-10 15:01:51 +0000313
314 /* FWSM register */
315 mac->has_fwsm = true;
Bruce Allan4662e822008-08-26 18:37:06 -0700316 break;
317 }
318
Dave Graham23a2d1b2009-06-08 14:28:17 +0000319 /*
320 * Ensure that the inter-port SWSM.SMBI lock bit is clear before
Uwe Kleine-Königb5950762010-11-01 15:38:34 -0400321 * first NVM or PHY access. This should be done for single-port
Dave Graham23a2d1b2009-06-08 14:28:17 +0000322 * devices, and for one port only on dual-port devices so that
323 * for those devices we can still use the SMBI lock to synchronize
324 * inter-port accesses to the PHY & NVM.
325 */
326 switch (hw->mac.type) {
327 case e1000_82571:
328 case e1000_82572:
329 swsm2 = er32(SWSM2);
330
331 if (!(swsm2 & E1000_SWSM2_LOCK)) {
332 /* Only do this for the first interface on this card */
Bruce Allan66092f52012-01-31 06:37:48 +0000333 ew32(SWSM2, swsm2 | E1000_SWSM2_LOCK);
Dave Graham23a2d1b2009-06-08 14:28:17 +0000334 force_clear_smbi = true;
Bruce Allan66092f52012-01-31 06:37:48 +0000335 } else {
Dave Graham23a2d1b2009-06-08 14:28:17 +0000336 force_clear_smbi = false;
Bruce Allan66092f52012-01-31 06:37:48 +0000337 }
Dave Graham23a2d1b2009-06-08 14:28:17 +0000338 break;
339 default:
340 force_clear_smbi = true;
341 break;
342 }
343
344 if (force_clear_smbi) {
345 /* Make sure SWSM.SMBI is clear */
346 swsm = er32(SWSM);
347 if (swsm & E1000_SWSM_SMBI) {
348 /* This bit should not be set on a first interface, and
349 * indicates that the bootagent or EFI code has
350 * improperly left this bit enabled
351 */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000352 e_dbg("Please update your 82571 Bootagent\n");
Dave Graham23a2d1b2009-06-08 14:28:17 +0000353 }
354 ew32(SWSM, swsm & ~E1000_SWSM_SMBI);
355 }
356
357 /*
Joe Perches2c73e1f2010-03-26 20:16:59 +0000358 * Initialize device specific counter of SMBI acquisition
Dave Graham23a2d1b2009-06-08 14:28:17 +0000359 * timeouts.
360 */
361 hw->dev_spec.e82571.smb_counter = 0;
362
Auke Kokbc7f75f2007-09-17 12:30:59 -0700363 return 0;
364}
365
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700366static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700367{
368 struct e1000_hw *hw = &adapter->hw;
369 static int global_quad_port_a; /* global port a indication */
370 struct pci_dev *pdev = adapter->pdev;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700371 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
372 s32 rc;
373
374 rc = e1000_init_mac_params_82571(adapter);
375 if (rc)
376 return rc;
377
378 rc = e1000_init_nvm_params_82571(hw);
379 if (rc)
380 return rc;
381
382 rc = e1000_init_phy_params_82571(hw);
383 if (rc)
384 return rc;
385
386 /* tag quad port adapters first, it's used below */
387 switch (pdev->device) {
388 case E1000_DEV_ID_82571EB_QUAD_COPPER:
389 case E1000_DEV_ID_82571EB_QUAD_FIBER:
390 case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
Auke Kok040babf2007-10-31 15:22:05 -0700391 case E1000_DEV_ID_82571PT_QUAD_COPPER:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700392 adapter->flags |= FLAG_IS_QUAD_PORT;
393 /* mark the first port */
394 if (global_quad_port_a == 0)
395 adapter->flags |= FLAG_IS_QUAD_PORT_A;
396 /* Reset for multiple quad port adapters */
397 global_quad_port_a++;
398 if (global_quad_port_a == 4)
399 global_quad_port_a = 0;
400 break;
401 default:
402 break;
403 }
404
405 switch (adapter->hw.mac.type) {
406 case e1000_82571:
407 /* these dual ports don't have WoL on port B at all */
408 if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) ||
409 (pdev->device == E1000_DEV_ID_82571EB_SERDES) ||
410 (pdev->device == E1000_DEV_ID_82571EB_COPPER)) &&
411 (is_port_b))
412 adapter->flags &= ~FLAG_HAS_WOL;
413 /* quad ports only support WoL on port A */
414 if (adapter->flags & FLAG_IS_QUAD_PORT &&
Roel Kluin6e4ca802007-10-29 10:50:05 -0700415 (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
Auke Kokbc7f75f2007-09-17 12:30:59 -0700416 adapter->flags &= ~FLAG_HAS_WOL;
Auke Kok040babf2007-10-31 15:22:05 -0700417 /* Does not support WoL on any port */
418 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
419 adapter->flags &= ~FLAG_HAS_WOL;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700420 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700421 case e1000_82573:
422 if (pdev->device == E1000_DEV_ID_82573L) {
Bruce Allan6f461f62010-04-27 03:33:04 +0000423 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
424 adapter->max_hw_frame_size = DEFAULT_JUMBO;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700425 }
426 break;
427 default:
428 break;
429 }
430
431 return 0;
432}
433
434/**
435 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
436 * @hw: pointer to the HW structure
437 *
438 * Reads the PHY registers and stores the PHY ID and possibly the PHY
439 * revision in the hardware structure.
440 **/
441static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
442{
443 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan4662e822008-08-26 18:37:06 -0700444 s32 ret_val;
445 u16 phy_id = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700446
447 switch (hw->mac.type) {
448 case e1000_82571:
449 case e1000_82572:
Bruce Allanad680762008-03-28 09:15:03 -0700450 /*
451 * The 82571 firmware may still be configuring the PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700452 * In this case, we cannot access the PHY until the
453 * configuration is done. So we explicitly set the
Bruce Allanad680762008-03-28 09:15:03 -0700454 * PHY ID.
455 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700456 phy->id = IGP01E1000_I_PHY_ID;
457 break;
458 case e1000_82573:
459 return e1000e_get_phy_id(hw);
460 break;
Bruce Allan4662e822008-08-26 18:37:06 -0700461 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000462 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -0700463 ret_val = e1e_rphy(hw, PHY_ID1, &phy_id);
464 if (ret_val)
465 return ret_val;
466
467 phy->id = (u32)(phy_id << 16);
468 udelay(20);
469 ret_val = e1e_rphy(hw, PHY_ID2, &phy_id);
470 if (ret_val)
471 return ret_val;
472
473 phy->id |= (u32)(phy_id);
474 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK);
475 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700476 default:
477 return -E1000_ERR_PHY;
478 break;
479 }
480
481 return 0;
482}
483
484/**
485 * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
486 * @hw: pointer to the HW structure
487 *
488 * Acquire the HW semaphore to access the PHY or NVM
489 **/
490static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw)
491{
492 u32 swsm;
Dave Graham23a2d1b2009-06-08 14:28:17 +0000493 s32 sw_timeout = hw->nvm.word_size + 1;
494 s32 fw_timeout = hw->nvm.word_size + 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700495 s32 i = 0;
496
Dave Graham23a2d1b2009-06-08 14:28:17 +0000497 /*
498 * If we have timedout 3 times on trying to acquire
499 * the inter-port SMBI semaphore, there is old code
500 * operating on the other port, and it is not
501 * releasing SMBI. Modify the number of times that
502 * we try for the semaphore to interwork with this
503 * older code.
504 */
505 if (hw->dev_spec.e82571.smb_counter > 2)
506 sw_timeout = 1;
507
508 /* Get the SW semaphore */
509 while (i < sw_timeout) {
510 swsm = er32(SWSM);
511 if (!(swsm & E1000_SWSM_SMBI))
512 break;
513
514 udelay(50);
515 i++;
516 }
517
518 if (i == sw_timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000519 e_dbg("Driver can't access device - SMBI bit is set.\n");
Dave Graham23a2d1b2009-06-08 14:28:17 +0000520 hw->dev_spec.e82571.smb_counter++;
521 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700522 /* Get the FW semaphore. */
Dave Graham23a2d1b2009-06-08 14:28:17 +0000523 for (i = 0; i < fw_timeout; i++) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700524 swsm = er32(SWSM);
525 ew32(SWSM, swsm | E1000_SWSM_SWESMBI);
526
527 /* Semaphore acquired if bit latched */
528 if (er32(SWSM) & E1000_SWSM_SWESMBI)
529 break;
530
531 udelay(50);
532 }
533
Dave Graham23a2d1b2009-06-08 14:28:17 +0000534 if (i == fw_timeout) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700535 /* Release semaphores */
Dave Graham23a2d1b2009-06-08 14:28:17 +0000536 e1000_put_hw_semaphore_82571(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000537 e_dbg("Driver can't access the NVM\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700538 return -E1000_ERR_NVM;
539 }
540
541 return 0;
542}
543
544/**
545 * e1000_put_hw_semaphore_82571 - Release hardware semaphore
546 * @hw: pointer to the HW structure
547 *
548 * Release hardware semaphore used to access the PHY or NVM
549 **/
550static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
551{
552 u32 swsm;
553
554 swsm = er32(SWSM);
Dave Graham23a2d1b2009-06-08 14:28:17 +0000555 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700556 ew32(SWSM, swsm);
557}
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800558/**
559 * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore
560 * @hw: pointer to the HW structure
561 *
562 * Acquire the HW semaphore during reset.
563 *
564 **/
565static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
566{
567 u32 extcnf_ctrl;
568 s32 ret_val = 0;
569 s32 i = 0;
570
571 extcnf_ctrl = er32(EXTCNF_CTRL);
572 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
573 do {
574 ew32(EXTCNF_CTRL, extcnf_ctrl);
575 extcnf_ctrl = er32(EXTCNF_CTRL);
576
577 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
578 break;
579
580 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
581
Bruce Allan1bba4382011-03-19 00:27:20 +0000582 usleep_range(2000, 4000);
Bruce Allan1b98c2b2010-11-16 19:50:14 -0800583 i++;
584 } while (i < MDIO_OWNERSHIP_TIMEOUT);
585
586 if (i == MDIO_OWNERSHIP_TIMEOUT) {
587 /* Release semaphores */
588 e1000_put_hw_semaphore_82573(hw);
589 e_dbg("Driver can't access the PHY\n");
590 ret_val = -E1000_ERR_PHY;
591 goto out;
592 }
593
594out:
595 return ret_val;
596}
597
598/**
599 * e1000_put_hw_semaphore_82573 - Release hardware semaphore
600 * @hw: pointer to the HW structure
601 *
602 * Release hardware semaphore used during reset.
603 *
604 **/
605static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw)
606{
607 u32 extcnf_ctrl;
608
609 extcnf_ctrl = er32(EXTCNF_CTRL);
610 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
611 ew32(EXTCNF_CTRL, extcnf_ctrl);
612}
613
614static DEFINE_MUTEX(swflag_mutex);
615
616/**
617 * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore
618 * @hw: pointer to the HW structure
619 *
620 * Acquire the HW semaphore to access the PHY or NVM.
621 *
622 **/
623static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw)
624{
625 s32 ret_val;
626
627 mutex_lock(&swflag_mutex);
628 ret_val = e1000_get_hw_semaphore_82573(hw);
629 if (ret_val)
630 mutex_unlock(&swflag_mutex);
631 return ret_val;
632}
633
634/**
635 * e1000_put_hw_semaphore_82574 - Release hardware semaphore
636 * @hw: pointer to the HW structure
637 *
638 * Release hardware semaphore used to access the PHY or NVM
639 *
640 **/
641static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw)
642{
643 e1000_put_hw_semaphore_82573(hw);
644 mutex_unlock(&swflag_mutex);
645}
Auke Kokbc7f75f2007-09-17 12:30:59 -0700646
647/**
Bruce Allan77996d12011-01-06 14:29:53 +0000648 * e1000_set_d0_lplu_state_82574 - Set Low Power Linkup D0 state
649 * @hw: pointer to the HW structure
650 * @active: true to enable LPLU, false to disable
651 *
652 * Sets the LPLU D0 state according to the active flag.
653 * LPLU will not be activated unless the
654 * device autonegotiation advertisement meets standards of
655 * either 10 or 10/100 or 10/100/1000 at all duplexes.
656 * This is a function pointer entry point only called by
657 * PHY setup routines.
658 **/
659static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active)
660{
661 u16 data = er32(POEMB);
662
663 if (active)
664 data |= E1000_PHY_CTRL_D0A_LPLU;
665 else
666 data &= ~E1000_PHY_CTRL_D0A_LPLU;
667
668 ew32(POEMB, data);
669 return 0;
670}
671
672/**
673 * e1000_set_d3_lplu_state_82574 - Sets low power link up state for D3
674 * @hw: pointer to the HW structure
675 * @active: boolean used to enable/disable lplu
676 *
677 * The low power link up (lplu) state is set to the power management level D3
678 * when active is true, else clear lplu for D3. LPLU
679 * is used during Dx states where the power conservation is most important.
680 * During driver activity, SmartSpeed should be enabled so performance is
681 * maintained.
682 **/
683static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active)
684{
685 u16 data = er32(POEMB);
686
687 if (!active) {
688 data &= ~E1000_PHY_CTRL_NOND0A_LPLU;
689 } else if ((hw->phy.autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
690 (hw->phy.autoneg_advertised == E1000_ALL_NOT_GIG) ||
691 (hw->phy.autoneg_advertised == E1000_ALL_10_SPEED)) {
692 data |= E1000_PHY_CTRL_NOND0A_LPLU;
693 }
694
695 ew32(POEMB, data);
696 return 0;
697}
698
699/**
Auke Kokbc7f75f2007-09-17 12:30:59 -0700700 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
701 * @hw: pointer to the HW structure
702 *
703 * To gain access to the EEPROM, first we must obtain a hardware semaphore.
704 * Then for non-82573 hardware, set the EEPROM access request bit and wait
705 * for EEPROM access grant bit. If the access grant bit is not set, release
706 * hardware semaphore.
707 **/
708static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
709{
710 s32 ret_val;
711
712 ret_val = e1000_get_hw_semaphore_82571(hw);
713 if (ret_val)
714 return ret_val;
715
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000716 switch (hw->mac.type) {
717 case e1000_82573:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000718 break;
719 default:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700720 ret_val = e1000e_acquire_nvm(hw);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000721 break;
722 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700723
724 if (ret_val)
725 e1000_put_hw_semaphore_82571(hw);
726
727 return ret_val;
728}
729
730/**
731 * e1000_release_nvm_82571 - Release exclusive access to EEPROM
732 * @hw: pointer to the HW structure
733 *
734 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
735 **/
736static void e1000_release_nvm_82571(struct e1000_hw *hw)
737{
738 e1000e_release_nvm(hw);
739 e1000_put_hw_semaphore_82571(hw);
740}
741
742/**
743 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
744 * @hw: pointer to the HW structure
745 * @offset: offset within the EEPROM to be written to
746 * @words: number of words to write
747 * @data: 16 bit word(s) to be written to the EEPROM
748 *
749 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
750 *
751 * If e1000e_update_nvm_checksum is not called after this function, the
Auke Kok489815c2008-02-21 15:11:07 -0800752 * EEPROM will most likely contain an invalid checksum.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700753 **/
754static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
755 u16 *data)
756{
757 s32 ret_val;
758
759 switch (hw->mac.type) {
760 case e1000_82573:
Bruce Allan4662e822008-08-26 18:37:06 -0700761 case e1000_82574:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +0000762 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700763 ret_val = e1000_write_nvm_eewr_82571(hw, offset, words, data);
764 break;
765 case e1000_82571:
766 case e1000_82572:
767 ret_val = e1000e_write_nvm_spi(hw, offset, words, data);
768 break;
769 default:
770 ret_val = -E1000_ERR_NVM;
771 break;
772 }
773
774 return ret_val;
775}
776
777/**
778 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
779 * @hw: pointer to the HW structure
780 *
781 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
782 * up to the checksum. Then calculates the EEPROM checksum and writes the
783 * value to the EEPROM.
784 **/
785static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
786{
787 u32 eecd;
788 s32 ret_val;
789 u16 i;
790
791 ret_val = e1000e_update_nvm_checksum_generic(hw);
792 if (ret_val)
793 return ret_val;
794
Bruce Allanad680762008-03-28 09:15:03 -0700795 /*
796 * If our nvm is an EEPROM, then we're done
797 * otherwise, commit the checksum to the flash NVM.
798 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700799 if (hw->nvm.type != e1000_nvm_flash_hw)
800 return ret_val;
801
802 /* Check for pending operations. */
803 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000804 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700805 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
806 break;
807 }
808
809 if (i == E1000_FLASH_UPDATES)
810 return -E1000_ERR_NVM;
811
812 /* Reset the firmware if using STM opcode. */
813 if ((er32(FLOP) & 0xFF00) == E1000_STM_OPCODE) {
Bruce Allanad680762008-03-28 09:15:03 -0700814 /*
815 * The enabling of and the actual reset must be done
Auke Kokbc7f75f2007-09-17 12:30:59 -0700816 * in two write cycles.
817 */
818 ew32(HICR, E1000_HICR_FW_RESET_ENABLE);
819 e1e_flush();
820 ew32(HICR, E1000_HICR_FW_RESET);
821 }
822
823 /* Commit the write to flash */
824 eecd = er32(EECD) | E1000_EECD_FLUPD;
825 ew32(EECD, eecd);
826
827 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
Bruce Allan1bba4382011-03-19 00:27:20 +0000828 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700829 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
830 break;
831 }
832
833 if (i == E1000_FLASH_UPDATES)
834 return -E1000_ERR_NVM;
835
836 return 0;
837}
838
839/**
840 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
841 * @hw: pointer to the HW structure
842 *
843 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
844 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
845 **/
846static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
847{
848 if (hw->nvm.type == e1000_nvm_flash_hw)
849 e1000_fix_nvm_checksum_82571(hw);
850
851 return e1000e_validate_nvm_checksum_generic(hw);
852}
853
854/**
855 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
856 * @hw: pointer to the HW structure
857 * @offset: offset within the EEPROM to be written to
858 * @words: number of words to write
859 * @data: 16 bit word(s) to be written to the EEPROM
860 *
861 * After checking for invalid values, poll the EEPROM to ensure the previous
862 * command has completed before trying to write the next word. After write
863 * poll for completion.
864 *
865 * If e1000e_update_nvm_checksum is not called after this function, the
Auke Kok489815c2008-02-21 15:11:07 -0800866 * EEPROM will most likely contain an invalid checksum.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700867 **/
868static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
869 u16 words, u16 *data)
870{
871 struct e1000_nvm_info *nvm = &hw->nvm;
Bruce Allana708dd82009-11-20 23:28:37 +0000872 u32 i, eewr = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700873 s32 ret_val = 0;
874
Bruce Allanad680762008-03-28 09:15:03 -0700875 /*
876 * A check for invalid values: offset too large, too many words,
877 * and not enough words.
878 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700879 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
880 (words == 0)) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000881 e_dbg("nvm parameter(s) out of bounds\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700882 return -E1000_ERR_NVM;
883 }
884
885 for (i = 0; i < words; i++) {
886 eewr = (data[i] << E1000_NVM_RW_REG_DATA) |
887 ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) |
888 E1000_NVM_RW_REG_START;
889
890 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
891 if (ret_val)
892 break;
893
894 ew32(EEWR, eewr);
895
896 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE);
897 if (ret_val)
898 break;
899 }
900
901 return ret_val;
902}
903
904/**
905 * e1000_get_cfg_done_82571 - Poll for configuration done
906 * @hw: pointer to the HW structure
907 *
908 * Reads the management control register for the config done bit to be set.
909 **/
910static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
911{
912 s32 timeout = PHY_CFG_TIMEOUT;
913
914 while (timeout) {
915 if (er32(EEMNGCTL) &
916 E1000_NVM_CFG_DONE_PORT_0)
917 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000918 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700919 timeout--;
920 }
921 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000922 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700923 return -E1000_ERR_RESET;
924 }
925
926 return 0;
927}
928
929/**
930 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
931 * @hw: pointer to the HW structure
Bruce Allan564ea9b2009-11-20 23:26:44 +0000932 * @active: true to enable LPLU, false to disable
Auke Kokbc7f75f2007-09-17 12:30:59 -0700933 *
934 * Sets the LPLU D0 state according to the active flag. When activating LPLU
935 * this function also disables smart speed and vice versa. LPLU will not be
936 * activated unless the device autonegotiation advertisement meets standards
937 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
938 * pointer entry point only called by PHY setup routines.
939 **/
940static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
941{
942 struct e1000_phy_info *phy = &hw->phy;
943 s32 ret_val;
944 u16 data;
945
946 ret_val = e1e_rphy(hw, IGP02E1000_PHY_POWER_MGMT, &data);
947 if (ret_val)
948 return ret_val;
949
950 if (active) {
951 data |= IGP02E1000_PM_D0_LPLU;
952 ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
953 if (ret_val)
954 return ret_val;
955
956 /* When LPLU is enabled, we should disable SmartSpeed */
957 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
958 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
959 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
960 if (ret_val)
961 return ret_val;
962 } else {
963 data &= ~IGP02E1000_PM_D0_LPLU;
964 ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data);
Bruce Allanad680762008-03-28 09:15:03 -0700965 /*
966 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
Auke Kokbc7f75f2007-09-17 12:30:59 -0700967 * during Dx states where the power conservation is most
968 * important. During driver activity we should enable
Bruce Allanad680762008-03-28 09:15:03 -0700969 * SmartSpeed, so performance is maintained.
970 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700971 if (phy->smart_speed == e1000_smart_speed_on) {
972 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700973 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700974 if (ret_val)
975 return ret_val;
976
977 data |= IGP01E1000_PSCFR_SMART_SPEED;
978 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700979 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700980 if (ret_val)
981 return ret_val;
982 } else if (phy->smart_speed == e1000_smart_speed_off) {
983 ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700984 &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700985 if (ret_val)
986 return ret_val;
987
988 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
989 ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
Bruce Allanad680762008-03-28 09:15:03 -0700990 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700991 if (ret_val)
992 return ret_val;
993 }
994 }
995
996 return 0;
997}
998
999/**
1000 * e1000_reset_hw_82571 - Reset hardware
1001 * @hw: pointer to the HW structure
1002 *
Bruce Allanfe401672009-11-20 23:26:05 +00001003 * This resets the hardware into a known state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001004 **/
1005static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
1006{
Bruce Allandd93f952011-01-06 14:29:48 +00001007 u32 ctrl, ctrl_ext;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001008 s32 ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001009
Bruce Allanad680762008-03-28 09:15:03 -07001010 /*
1011 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -07001012 * on the last TLP read/write transaction when MAC is reset.
1013 */
1014 ret_val = e1000e_disable_pcie_master(hw);
1015 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001016 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001017
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001018 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001019 ew32(IMC, 0xffffffff);
1020
1021 ew32(RCTL, 0);
1022 ew32(TCTL, E1000_TCTL_PSP);
1023 e1e_flush();
1024
Bruce Allan1bba4382011-03-19 00:27:20 +00001025 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001026
Bruce Allanad680762008-03-28 09:15:03 -07001027 /*
1028 * Must acquire the MDIO ownership before MAC reset.
1029 * Ownership defaults to firmware after a reset.
1030 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001031 switch (hw->mac.type) {
1032 case e1000_82573:
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001033 ret_val = e1000_get_hw_semaphore_82573(hw);
1034 break;
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001035 case e1000_82574:
1036 case e1000_82583:
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001037 ret_val = e1000_get_hw_semaphore_82574(hw);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001038 break;
1039 default:
1040 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001041 }
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001042 if (ret_val)
1043 e_dbg("Cannot acquire MDIO ownership\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001044
1045 ctrl = er32(CTRL);
1046
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001047 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001048 ew32(CTRL, ctrl | E1000_CTRL_RST);
1049
Bruce Allan1b98c2b2010-11-16 19:50:14 -08001050 /* Must release MDIO ownership and mutex after MAC reset. */
1051 switch (hw->mac.type) {
1052 case e1000_82574:
1053 case e1000_82583:
1054 e1000_put_hw_semaphore_82574(hw);
1055 break;
1056 default:
1057 break;
1058 }
1059
Auke Kokbc7f75f2007-09-17 12:30:59 -07001060 if (hw->nvm.type == e1000_nvm_flash_hw) {
1061 udelay(10);
1062 ctrl_ext = er32(CTRL_EXT);
1063 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
1064 ew32(CTRL_EXT, ctrl_ext);
1065 e1e_flush();
1066 }
1067
1068 ret_val = e1000e_get_auto_rd_done(hw);
1069 if (ret_val)
1070 /* We don't want to continue accessing MAC registers. */
1071 return ret_val;
1072
Bruce Allanad680762008-03-28 09:15:03 -07001073 /*
1074 * Phy configuration from NVM just starts after EECD_AUTO_RD is set.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001075 * Need to wait for Phy configuration completion before accessing
1076 * NVM and Phy.
1077 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001078
1079 switch (hw->mac.type) {
1080 case e1000_82573:
1081 case e1000_82574:
1082 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001083 msleep(25);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001084 break;
1085 default:
1086 break;
1087 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001088
1089 /* Clear any pending interrupt events. */
1090 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +00001091 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001092
Bruce Allan1aef70e2010-08-19 15:48:52 -07001093 if (hw->mac.type == e1000_82571) {
1094 /* Install any alternate MAC address into RAR0 */
1095 ret_val = e1000_check_alt_mac_addr_generic(hw);
1096 if (ret_val)
1097 return ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001098
Bruce Allan1aef70e2010-08-19 15:48:52 -07001099 e1000e_set_laa_state_82571(hw, true);
1100 }
Bill Hayes93ca1612007-10-31 15:21:52 -07001101
dave grahamc9523372009-02-10 12:52:28 +00001102 /* Reinitialize the 82571 serdes link state machine */
1103 if (hw->phy.media_type == e1000_media_type_internal_serdes)
1104 hw->mac.serdes_link_state = e1000_serdes_link_down;
1105
Auke Kokbc7f75f2007-09-17 12:30:59 -07001106 return 0;
1107}
1108
1109/**
1110 * e1000_init_hw_82571 - Initialize hardware
1111 * @hw: pointer to the HW structure
1112 *
1113 * This inits the hardware readying it for operation.
1114 **/
1115static s32 e1000_init_hw_82571(struct e1000_hw *hw)
1116{
1117 struct e1000_mac_info *mac = &hw->mac;
1118 u32 reg_data;
1119 s32 ret_val;
Bruce Allana708dd82009-11-20 23:28:37 +00001120 u16 i, rar_count = mac->rar_entry_count;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001121
1122 e1000_initialize_hw_bits_82571(hw);
1123
1124 /* Initialize identification LED */
1125 ret_val = e1000e_id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +00001126 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001127 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +00001128 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001129
1130 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001131 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +00001132 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001133
1134 /* Setup the receive address. */
Bruce Allanad680762008-03-28 09:15:03 -07001135 /*
1136 * If, however, a locally administered address was assigned to the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001137 * 82571, we must reserve a RAR for it to work around an issue where
1138 * resetting one port will reload the MAC on the other port.
1139 */
1140 if (e1000e_get_laa_state_82571(hw))
1141 rar_count--;
1142 e1000e_init_rx_addrs(hw, rar_count);
1143
1144 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001145 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001146 for (i = 0; i < mac->mta_reg_count; i++)
1147 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1148
1149 /* Setup link and flow control */
1150 ret_val = e1000_setup_link_82571(hw);
1151
1152 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001153 reg_data = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001154 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1155 E1000_TXDCTL_FULL_TX_DESC_WB |
1156 E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001157 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001158
1159 /* ...for both queues. */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001160 switch (mac->type) {
1161 case e1000_82573:
Bruce Allana65a4a02010-05-10 15:01:51 +00001162 e1000e_enable_tx_pkt_filtering(hw);
1163 /* fall through */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001164 case e1000_82574:
1165 case e1000_82583:
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001166 reg_data = er32(GCR);
1167 reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
1168 ew32(GCR, reg_data);
1169 break;
1170 default:
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001171 reg_data = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001172 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
1173 E1000_TXDCTL_FULL_TX_DESC_WB |
1174 E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001175 ew32(TXDCTL(1), reg_data);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001176 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001177 }
1178
Bruce Allanad680762008-03-28 09:15:03 -07001179 /*
1180 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -07001181 * important that we do this after we have tried to establish link
1182 * because the symbol error count will increment wildly if there
1183 * is no link.
1184 */
1185 e1000_clear_hw_cntrs_82571(hw);
1186
1187 return ret_val;
1188}
1189
1190/**
1191 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
1192 * @hw: pointer to the HW structure
1193 *
1194 * Initializes required hardware-dependent bits needed for normal operation.
1195 **/
1196static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1197{
1198 u32 reg;
1199
1200 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001201 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001202 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001203 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001204
1205 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001206 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001207 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001208 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001209
1210 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001211 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001212 reg &= ~(0xF << 27); /* 30:27 */
1213 switch (hw->mac.type) {
1214 case e1000_82571:
1215 case e1000_82572:
1216 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1217 break;
Bruce Alland6cb17d2011-12-16 00:46:22 +00001218 case e1000_82574:
1219 case e1000_82583:
1220 reg |= (1 << 26);
1221 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001222 default:
1223 break;
1224 }
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001225 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001226
1227 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001228 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001229 switch (hw->mac.type) {
1230 case e1000_82571:
1231 case e1000_82572:
1232 reg &= ~((1 << 29) | (1 << 30));
1233 reg |= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
1234 if (er32(TCTL) & E1000_TCTL_MULR)
1235 reg &= ~(1 << 28);
1236 else
1237 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -07001238 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001239 break;
1240 default:
1241 break;
1242 }
1243
1244 /* Device Control */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001245 switch (hw->mac.type) {
1246 case e1000_82573:
1247 case e1000_82574:
1248 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001249 reg = er32(CTRL);
1250 reg &= ~(1 << 29);
1251 ew32(CTRL, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001252 break;
1253 default:
1254 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001255 }
1256
1257 /* Extended Device Control */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001258 switch (hw->mac.type) {
1259 case e1000_82573:
1260 case e1000_82574:
1261 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001262 reg = er32(CTRL_EXT);
1263 reg &= ~(1 << 23);
1264 reg |= (1 << 22);
1265 ew32(CTRL_EXT, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001266 break;
1267 default:
1268 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001269 }
Bruce Allan4662e822008-08-26 18:37:06 -07001270
Alexander Duyck6ea7ae12008-11-14 06:54:36 +00001271 if (hw->mac.type == e1000_82571) {
1272 reg = er32(PBA_ECC);
1273 reg |= E1000_PBA_ECC_CORR_EN;
1274 ew32(PBA_ECC, reg);
1275 }
dave graham5df3f0e2009-02-10 12:51:41 +00001276 /*
1277 * Workaround for hardware errata.
1278 * Ensure that DMA Dynamic Clock gating is disabled on 82571 and 82572
1279 */
1280
1281 if ((hw->mac.type == e1000_82571) ||
1282 (hw->mac.type == e1000_82572)) {
1283 reg = er32(CTRL_EXT);
1284 reg &= ~E1000_CTRL_EXT_DMA_DYN_CLK_EN;
1285 ew32(CTRL_EXT, reg);
1286 }
1287
Alexander Duyck6ea7ae12008-11-14 06:54:36 +00001288
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001289 /* PCI-Ex Control Registers */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001290 switch (hw->mac.type) {
1291 case e1000_82574:
1292 case e1000_82583:
Bruce Allan4662e822008-08-26 18:37:06 -07001293 reg = er32(GCR);
1294 reg |= (1 << 22);
1295 ew32(GCR, reg);
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001296
Bruce Allan84efb7b2009-11-20 23:26:24 +00001297 /*
1298 * Workaround for hardware errata.
1299 * apply workaround for hardware errata documented in errata
1300 * docs Fixes issue where some error prone or unreliable PCIe
1301 * completions are occurring, particularly with ASPM enabled.
Bruce Allanaf667a22010-12-31 06:10:01 +00001302 * Without fix, issue can cause Tx timeouts.
Bruce Allan84efb7b2009-11-20 23:26:24 +00001303 */
Jesse Brandeburg78272bb2009-01-26 12:16:26 -08001304 reg = er32(GCR2);
1305 reg |= 1;
1306 ew32(GCR2, reg);
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001307 break;
1308 default:
1309 break;
Bruce Allan4662e822008-08-26 18:37:06 -07001310 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001311}
1312
1313/**
Bruce Allancaaddaf2009-12-01 15:46:43 +00001314 * e1000_clear_vfta_82571 - Clear VLAN filter table
Auke Kokbc7f75f2007-09-17 12:30:59 -07001315 * @hw: pointer to the HW structure
1316 *
1317 * Clears the register array which contains the VLAN filter table by
1318 * setting all the values to 0.
1319 **/
Bruce Allancaaddaf2009-12-01 15:46:43 +00001320static void e1000_clear_vfta_82571(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001321{
1322 u32 offset;
1323 u32 vfta_value = 0;
1324 u32 vfta_offset = 0;
1325 u32 vfta_bit_in_reg = 0;
1326
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001327 switch (hw->mac.type) {
1328 case e1000_82573:
1329 case e1000_82574:
1330 case e1000_82583:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001331 if (hw->mng_cookie.vlan_id != 0) {
Bruce Allanad680762008-03-28 09:15:03 -07001332 /*
1333 * The VFTA is a 4096b bit-field, each identifying
Auke Kokbc7f75f2007-09-17 12:30:59 -07001334 * a single VLAN ID. The following operations
1335 * determine which 32b entry (i.e. offset) into the
1336 * array we want to set the VLAN ID (i.e. bit) of
1337 * the manageability unit.
1338 */
1339 vfta_offset = (hw->mng_cookie.vlan_id >>
1340 E1000_VFTA_ENTRY_SHIFT) &
1341 E1000_VFTA_ENTRY_MASK;
1342 vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
1343 E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
1344 }
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001345 break;
1346 default:
1347 break;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001348 }
1349 for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
Bruce Allanad680762008-03-28 09:15:03 -07001350 /*
1351 * If the offset we want to clear is the same offset of the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001352 * manageability VLAN ID, then clear all bits except that of
1353 * the manageability unit.
1354 */
1355 vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
1356 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, vfta_value);
1357 e1e_flush();
1358 }
1359}
1360
1361/**
Bruce Allan4662e822008-08-26 18:37:06 -07001362 * e1000_check_mng_mode_82574 - Check manageability is enabled
1363 * @hw: pointer to the HW structure
1364 *
1365 * Reads the NVM Initialization Control Word 2 and returns true
1366 * (>0) if any manageability is enabled, else false (0).
1367 **/
1368static bool e1000_check_mng_mode_82574(struct e1000_hw *hw)
1369{
1370 u16 data;
1371
1372 e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
1373 return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0;
1374}
1375
1376/**
1377 * e1000_led_on_82574 - Turn LED on
1378 * @hw: pointer to the HW structure
1379 *
1380 * Turn LED on.
1381 **/
1382static s32 e1000_led_on_82574(struct e1000_hw *hw)
1383{
1384 u32 ctrl;
1385 u32 i;
1386
1387 ctrl = hw->mac.ledctl_mode2;
1388 if (!(E1000_STATUS_LU & er32(STATUS))) {
1389 /*
1390 * If no link, then turn LED on by setting the invert bit
1391 * for each LED that's "on" (0x0E) in ledctl_mode2.
1392 */
1393 for (i = 0; i < 4; i++)
1394 if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1395 E1000_LEDCTL_MODE_LED_ON)
1396 ctrl |= (E1000_LEDCTL_LED0_IVRT << (i * 8));
1397 }
1398 ew32(LEDCTL, ctrl);
1399
1400 return 0;
1401}
1402
1403/**
Carolyn Wybornyff10e132010-10-28 00:59:53 +00001404 * e1000_check_phy_82574 - check 82574 phy hung state
1405 * @hw: pointer to the HW structure
1406 *
1407 * Returns whether phy is hung or not
1408 **/
1409bool e1000_check_phy_82574(struct e1000_hw *hw)
1410{
1411 u16 status_1kbt = 0;
1412 u16 receive_errors = 0;
1413 bool phy_hung = false;
1414 s32 ret_val = 0;
1415
1416 /*
1417 * Read PHY Receive Error counter first, if its is max - all F's then
1418 * read the Base1000T status register If both are max then PHY is hung.
1419 */
1420 ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors);
1421
1422 if (ret_val)
1423 goto out;
1424 if (receive_errors == E1000_RECEIVE_ERROR_MAX) {
1425 ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt);
1426 if (ret_val)
1427 goto out;
1428 if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) ==
1429 E1000_IDLE_ERROR_COUNT_MASK)
1430 phy_hung = true;
1431 }
1432out:
1433 return phy_hung;
1434}
1435
1436/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001437 * e1000_setup_link_82571 - Setup flow control and link settings
1438 * @hw: pointer to the HW structure
1439 *
1440 * Determines which flow control settings to use, then configures flow
1441 * control. Calls the appropriate media-specific link configuration
1442 * function. Assuming the adapter has a valid link partner, a valid link
1443 * should be established. Assumes the hardware has previously been reset
1444 * and the transmitter and receiver are not enabled.
1445 **/
1446static s32 e1000_setup_link_82571(struct e1000_hw *hw)
1447{
Bruce Allanad680762008-03-28 09:15:03 -07001448 /*
1449 * 82573 does not have a word in the NVM to determine
Auke Kokbc7f75f2007-09-17 12:30:59 -07001450 * the default flow control setting, so we explicitly
1451 * set it to full.
1452 */
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001453 switch (hw->mac.type) {
1454 case e1000_82573:
1455 case e1000_82574:
1456 case e1000_82583:
1457 if (hw->fc.requested_mode == e1000_fc_default)
1458 hw->fc.requested_mode = e1000_fc_full;
1459 break;
1460 default:
1461 break;
1462 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001463
1464 return e1000e_setup_link(hw);
1465}
1466
1467/**
1468 * e1000_setup_copper_link_82571 - Configure copper link settings
1469 * @hw: pointer to the HW structure
1470 *
1471 * Configures the link for auto-neg or forced speed and duplex. Then we check
1472 * for link, once link is established calls to configure collision distance
1473 * and flow control are called.
1474 **/
1475static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
1476{
1477 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001478 s32 ret_val;
1479
1480 ctrl = er32(CTRL);
1481 ctrl |= E1000_CTRL_SLU;
1482 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1483 ew32(CTRL, ctrl);
1484
1485 switch (hw->phy.type) {
1486 case e1000_phy_m88:
Bruce Allan4662e822008-08-26 18:37:06 -07001487 case e1000_phy_bm:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001488 ret_val = e1000e_copper_link_setup_m88(hw);
1489 break;
1490 case e1000_phy_igp_2:
1491 ret_val = e1000e_copper_link_setup_igp(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001492 break;
1493 default:
1494 return -E1000_ERR_PHY;
1495 break;
1496 }
1497
1498 if (ret_val)
1499 return ret_val;
1500
1501 ret_val = e1000e_setup_copper_link(hw);
1502
1503 return ret_val;
1504}
1505
1506/**
1507 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
1508 * @hw: pointer to the HW structure
1509 *
1510 * Configures collision distance and flow control for fiber and serdes links.
1511 * Upon successful setup, poll for link.
1512 **/
1513static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
1514{
1515 switch (hw->mac.type) {
1516 case e1000_82571:
1517 case e1000_82572:
Bruce Allanad680762008-03-28 09:15:03 -07001518 /*
1519 * If SerDes loopback mode is entered, there is no form
Auke Kokbc7f75f2007-09-17 12:30:59 -07001520 * of reset to take the adapter out of that mode. So we
1521 * have to explicitly take the adapter out of loopback
Auke Kok489815c2008-02-21 15:11:07 -08001522 * mode. This prevents drivers from twiddling their thumbs
Auke Kokbc7f75f2007-09-17 12:30:59 -07001523 * if another tool failed to take it out of loopback mode.
1524 */
Bruce Allanad680762008-03-28 09:15:03 -07001525 ew32(SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001526 break;
1527 default:
1528 break;
1529 }
1530
1531 return e1000e_setup_fiber_serdes_link(hw);
1532}
1533
1534/**
dave grahamc9523372009-02-10 12:52:28 +00001535 * e1000_check_for_serdes_link_82571 - Check for link (Serdes)
1536 * @hw: pointer to the HW structure
1537 *
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001538 * Reports the link state as up or down.
1539 *
1540 * If autonegotiation is supported by the link partner, the link state is
1541 * determined by the result of autonegotiation. This is the most likely case.
1542 * If autonegotiation is not supported by the link partner, and the link
1543 * has a valid signal, force the link up.
1544 *
1545 * The link state is represented internally here by 4 states:
1546 *
1547 * 1) down
1548 * 2) autoneg_progress
Daniel Mack3ad2f3f2010-02-03 08:01:28 +08001549 * 3) autoneg_complete (the link successfully autonegotiated)
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001550 * 4) forced_up (the link has been forced up, it did not autonegotiate)
1551 *
dave grahamc9523372009-02-10 12:52:28 +00001552 **/
Hannes Ederf6370112009-02-14 11:32:25 +00001553static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
dave grahamc9523372009-02-10 12:52:28 +00001554{
1555 struct e1000_mac_info *mac = &hw->mac;
1556 u32 rxcw;
1557 u32 ctrl;
1558 u32 status;
Bruce Alland9c76f92010-11-24 06:01:35 +00001559 u32 txcw;
1560 u32 i;
dave grahamc9523372009-02-10 12:52:28 +00001561 s32 ret_val = 0;
1562
1563 ctrl = er32(CTRL);
1564 status = er32(STATUS);
1565 rxcw = er32(RXCW);
1566
1567 if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) {
1568
1569 /* Receiver is synchronized with no invalid bits. */
1570 switch (mac->serdes_link_state) {
1571 case e1000_serdes_link_autoneg_complete:
1572 if (!(status & E1000_STATUS_LU)) {
1573 /*
1574 * We have lost link, retry autoneg before
1575 * reporting link failure
1576 */
1577 mac->serdes_link_state =
1578 e1000_serdes_link_autoneg_progress;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001579 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001580 e_dbg("AN_UP -> AN_PROG\n");
Bruce Allana82a14f2010-11-24 06:01:20 +00001581 } else {
1582 mac->serdes_has_link = true;
dave grahamc9523372009-02-10 12:52:28 +00001583 }
Bruce Allana82a14f2010-11-24 06:01:20 +00001584 break;
dave grahamc9523372009-02-10 12:52:28 +00001585
1586 case e1000_serdes_link_forced_up:
1587 /*
1588 * If we are receiving /C/ ordered sets, re-enable
1589 * auto-negotiation in the TXCW register and disable
1590 * forced link in the Device Control register in an
1591 * attempt to auto-negotiate with our link partner.
Bruce Alland478eb42010-11-16 19:50:13 -08001592 * If the partner code word is null, stop forcing
1593 * and restart auto negotiation.
dave grahamc9523372009-02-10 12:52:28 +00001594 */
Bruce Alland478eb42010-11-16 19:50:13 -08001595 if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
dave grahamc9523372009-02-10 12:52:28 +00001596 /* Enable autoneg, and unforce link up */
1597 ew32(TXCW, mac->txcw);
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001598 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
dave grahamc9523372009-02-10 12:52:28 +00001599 mac->serdes_link_state =
1600 e1000_serdes_link_autoneg_progress;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001601 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001602 e_dbg("FORCED_UP -> AN_PROG\n");
Bruce Allana82a14f2010-11-24 06:01:20 +00001603 } else {
1604 mac->serdes_has_link = true;
dave grahamc9523372009-02-10 12:52:28 +00001605 }
1606 break;
1607
1608 case e1000_serdes_link_autoneg_progress:
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001609 if (rxcw & E1000_RXCW_C) {
1610 /*
1611 * We received /C/ ordered sets, meaning the
1612 * link partner has autonegotiated, and we can
1613 * trust the Link Up (LU) status bit.
1614 */
1615 if (status & E1000_STATUS_LU) {
1616 mac->serdes_link_state =
1617 e1000_serdes_link_autoneg_complete;
1618 e_dbg("AN_PROG -> AN_UP\n");
1619 mac->serdes_has_link = true;
1620 } else {
1621 /* Autoneg completed, but failed. */
1622 mac->serdes_link_state =
1623 e1000_serdes_link_down;
1624 e_dbg("AN_PROG -> DOWN\n");
1625 }
dave grahamc9523372009-02-10 12:52:28 +00001626 } else {
1627 /*
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001628 * The link partner did not autoneg.
1629 * Force link up and full duplex, and change
1630 * state to forced.
dave grahamc9523372009-02-10 12:52:28 +00001631 */
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001632 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
dave grahamc9523372009-02-10 12:52:28 +00001633 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
1634 ew32(CTRL, ctrl);
1635
1636 /* Configure Flow Control after link up. */
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001637 ret_val = e1000e_config_fc_after_link_up(hw);
dave grahamc9523372009-02-10 12:52:28 +00001638 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001639 e_dbg("Error config flow control\n");
dave grahamc9523372009-02-10 12:52:28 +00001640 break;
1641 }
1642 mac->serdes_link_state =
1643 e1000_serdes_link_forced_up;
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001644 mac->serdes_has_link = true;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001645 e_dbg("AN_PROG -> FORCED_UP\n");
dave grahamc9523372009-02-10 12:52:28 +00001646 }
dave grahamc9523372009-02-10 12:52:28 +00001647 break;
1648
1649 case e1000_serdes_link_down:
1650 default:
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001651 /*
1652 * The link was down but the receiver has now gained
dave grahamc9523372009-02-10 12:52:28 +00001653 * valid sync, so lets see if we can bring the link
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001654 * up.
1655 */
dave grahamc9523372009-02-10 12:52:28 +00001656 ew32(TXCW, mac->txcw);
Bruce Allan1a40d5c2009-12-01 15:49:51 +00001657 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
dave grahamc9523372009-02-10 12:52:28 +00001658 mac->serdes_link_state =
1659 e1000_serdes_link_autoneg_progress;
Bruce Allana82a14f2010-11-24 06:01:20 +00001660 mac->serdes_has_link = false;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001661 e_dbg("DOWN -> AN_PROG\n");
dave grahamc9523372009-02-10 12:52:28 +00001662 break;
1663 }
1664 } else {
1665 if (!(rxcw & E1000_RXCW_SYNCH)) {
1666 mac->serdes_has_link = false;
1667 mac->serdes_link_state = e1000_serdes_link_down;
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001668 e_dbg("ANYSTATE -> DOWN\n");
dave grahamc9523372009-02-10 12:52:28 +00001669 } else {
1670 /*
Bruce Alland9c76f92010-11-24 06:01:35 +00001671 * Check several times, if Sync and Config
1672 * both are consistently 1 then simply ignore
1673 * the Invalid bit and restart Autoneg
dave grahamc9523372009-02-10 12:52:28 +00001674 */
Bruce Alland9c76f92010-11-24 06:01:35 +00001675 for (i = 0; i < AN_RETRY_COUNT; i++) {
1676 udelay(10);
1677 rxcw = er32(RXCW);
1678 if ((rxcw & E1000_RXCW_IV) &&
1679 !((rxcw & E1000_RXCW_SYNCH) &&
1680 (rxcw & E1000_RXCW_C))) {
1681 mac->serdes_has_link = false;
1682 mac->serdes_link_state =
1683 e1000_serdes_link_down;
1684 e_dbg("ANYSTATE -> DOWN\n");
1685 break;
1686 }
1687 }
1688
1689 if (i == AN_RETRY_COUNT) {
1690 txcw = er32(TXCW);
1691 txcw |= E1000_TXCW_ANE;
1692 ew32(TXCW, txcw);
1693 mac->serdes_link_state =
1694 e1000_serdes_link_autoneg_progress;
dave grahamc9523372009-02-10 12:52:28 +00001695 mac->serdes_has_link = false;
Bruce Alland9c76f92010-11-24 06:01:35 +00001696 e_dbg("ANYSTATE -> AN_PROG\n");
dave grahamc9523372009-02-10 12:52:28 +00001697 }
1698 }
1699 }
1700
1701 return ret_val;
1702}
1703
1704/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001705 * e1000_valid_led_default_82571 - Verify a valid default LED config
1706 * @hw: pointer to the HW structure
1707 * @data: pointer to the NVM (EEPROM)
1708 *
1709 * Read the EEPROM for the current default LED configuration. If the
1710 * LED configuration is not valid, set to a valid LED configuration.
1711 **/
1712static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
1713{
1714 s32 ret_val;
1715
1716 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
1717 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001718 e_dbg("NVM Read Error\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001719 return ret_val;
1720 }
1721
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00001722 switch (hw->mac.type) {
1723 case e1000_82573:
1724 case e1000_82574:
1725 case e1000_82583:
1726 if (*data == ID_LED_RESERVED_F746)
1727 *data = ID_LED_DEFAULT_82573;
1728 break;
1729 default:
1730 if (*data == ID_LED_RESERVED_0000 ||
1731 *data == ID_LED_RESERVED_FFFF)
1732 *data = ID_LED_DEFAULT;
1733 break;
1734 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001735
1736 return 0;
1737}
1738
1739/**
1740 * e1000e_get_laa_state_82571 - Get locally administered address state
1741 * @hw: pointer to the HW structure
1742 *
Auke Kok489815c2008-02-21 15:11:07 -08001743 * Retrieve and return the current locally administered address state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001744 **/
1745bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
1746{
1747 if (hw->mac.type != e1000_82571)
Bruce Allan564ea9b2009-11-20 23:26:44 +00001748 return false;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001749
1750 return hw->dev_spec.e82571.laa_is_present;
1751}
1752
1753/**
1754 * e1000e_set_laa_state_82571 - Set locally administered address state
1755 * @hw: pointer to the HW structure
1756 * @state: enable/disable locally administered address
1757 *
Bruce Allan5ff5b662009-12-01 15:51:11 +00001758 * Enable/Disable the current locally administered address state.
Auke Kokbc7f75f2007-09-17 12:30:59 -07001759 **/
1760void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
1761{
1762 if (hw->mac.type != e1000_82571)
1763 return;
1764
1765 hw->dev_spec.e82571.laa_is_present = state;
1766
1767 /* If workaround is activated... */
1768 if (state)
Bruce Allanad680762008-03-28 09:15:03 -07001769 /*
1770 * Hold a copy of the LAA in RAR[14] This is done so that
Auke Kokbc7f75f2007-09-17 12:30:59 -07001771 * between the time RAR[0] gets clobbered and the time it
1772 * gets fixed, the actual LAA is in one of the RARs and no
1773 * incoming packets directed to this port are dropped.
1774 * Eventually the LAA will be in RAR[0] and RAR[14].
1775 */
1776 e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1);
1777}
1778
1779/**
1780 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
1781 * @hw: pointer to the HW structure
1782 *
1783 * Verifies that the EEPROM has completed the update. After updating the
1784 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
1785 * the checksum fix is not implemented, we need to set the bit and update
1786 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
1787 * we need to return bad checksum.
1788 **/
1789static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
1790{
1791 struct e1000_nvm_info *nvm = &hw->nvm;
1792 s32 ret_val;
1793 u16 data;
1794
1795 if (nvm->type != e1000_nvm_flash_hw)
1796 return 0;
1797
Bruce Allanad680762008-03-28 09:15:03 -07001798 /*
1799 * Check bit 4 of word 10h. If it is 0, firmware is done updating
Auke Kokbc7f75f2007-09-17 12:30:59 -07001800 * 10h-12h. Checksum may need to be fixed.
1801 */
1802 ret_val = e1000_read_nvm(hw, 0x10, 1, &data);
1803 if (ret_val)
1804 return ret_val;
1805
1806 if (!(data & 0x10)) {
Bruce Allanad680762008-03-28 09:15:03 -07001807 /*
1808 * Read 0x23 and check bit 15. This bit is a 1
Auke Kokbc7f75f2007-09-17 12:30:59 -07001809 * when the checksum has already been fixed. If
1810 * the checksum is still wrong and this bit is a
1811 * 1, we need to return bad checksum. Otherwise,
1812 * we need to set this bit to a 1 and update the
1813 * checksum.
1814 */
1815 ret_val = e1000_read_nvm(hw, 0x23, 1, &data);
1816 if (ret_val)
1817 return ret_val;
1818
1819 if (!(data & 0x8000)) {
1820 data |= 0x8000;
1821 ret_val = e1000_write_nvm(hw, 0x23, 1, &data);
1822 if (ret_val)
1823 return ret_val;
1824 ret_val = e1000e_update_nvm_checksum(hw);
1825 }
1826 }
1827
1828 return 0;
1829}
1830
1831/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001832 * e1000_read_mac_addr_82571 - Read device MAC address
1833 * @hw: pointer to the HW structure
1834 **/
1835static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1836{
1837 s32 ret_val = 0;
1838
Bruce Allan1aef70e2010-08-19 15:48:52 -07001839 if (hw->mac.type == e1000_82571) {
1840 /*
1841 * If there's an alternate MAC address place it in RAR0
1842 * so that it will override the Si installed default perm
1843 * address.
1844 */
1845 ret_val = e1000_check_alt_mac_addr_generic(hw);
1846 if (ret_val)
1847 goto out;
1848 }
Bruce Allan608f8a02010-01-13 02:04:58 +00001849
1850 ret_val = e1000_read_mac_addr_generic(hw);
1851
1852out:
1853 return ret_val;
1854}
1855
1856/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001857 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
1858 * @hw: pointer to the HW structure
1859 *
1860 * In the case of a PHY power down to save power, or to turn off link during a
1861 * driver unload, or wake on lan is not enabled, remove the link.
1862 **/
1863static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
1864{
1865 struct e1000_phy_info *phy = &hw->phy;
1866 struct e1000_mac_info *mac = &hw->mac;
1867
1868 if (!(phy->ops.check_reset_block))
1869 return;
1870
1871 /* If the management interface is not enabled, then power down */
1872 if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
1873 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001874}
1875
1876/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001877 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
1878 * @hw: pointer to the HW structure
1879 *
1880 * Clears the hardware counters by reading the counter registers.
1881 **/
1882static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw)
1883{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001884 e1000e_clear_hw_cntrs_base(hw);
1885
Bruce Allan99673d92009-11-20 23:27:21 +00001886 er32(PRC64);
1887 er32(PRC127);
1888 er32(PRC255);
1889 er32(PRC511);
1890 er32(PRC1023);
1891 er32(PRC1522);
1892 er32(PTC64);
1893 er32(PTC127);
1894 er32(PTC255);
1895 er32(PTC511);
1896 er32(PTC1023);
1897 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001898
Bruce Allan99673d92009-11-20 23:27:21 +00001899 er32(ALGNERRC);
1900 er32(RXERRC);
1901 er32(TNCRS);
1902 er32(CEXTERR);
1903 er32(TSCTC);
1904 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001905
Bruce Allan99673d92009-11-20 23:27:21 +00001906 er32(MGTPRC);
1907 er32(MGTPDC);
1908 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001909
Bruce Allan99673d92009-11-20 23:27:21 +00001910 er32(IAC);
1911 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001912
Bruce Allan99673d92009-11-20 23:27:21 +00001913 er32(ICRXPTC);
1914 er32(ICRXATC);
1915 er32(ICTXPTC);
1916 er32(ICTXATC);
1917 er32(ICTXQEC);
1918 er32(ICTXQMTC);
1919 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001920}
1921
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001922static const struct e1000_mac_operations e82571_mac_ops = {
Bruce Allan4662e822008-08-26 18:37:06 -07001923 /* .check_mng_mode: mac type dependent */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001924 /* .check_for_link: media type dependent */
Bruce Allana4f58f52009-06-02 11:29:18 +00001925 .id_led_init = e1000e_id_led_init,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001926 .cleanup_led = e1000e_cleanup_led_generic,
1927 .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
1928 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001929 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001930 /* .get_link_up_info: media type dependent */
Bruce Allan4662e822008-08-26 18:37:06 -07001931 /* .led_on: mac type dependent */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001932 .led_off = e1000e_led_off_generic,
Bruce Allanab8932f2010-01-13 02:05:38 +00001933 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001934 .write_vfta = e1000_write_vfta_generic,
1935 .clear_vfta = e1000_clear_vfta_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001936 .reset_hw = e1000_reset_hw_82571,
1937 .init_hw = e1000_init_hw_82571,
1938 .setup_link = e1000_setup_link_82571,
1939 /* .setup_physical_interface: media type dependent */
Bruce Allana4f58f52009-06-02 11:29:18 +00001940 .setup_led = e1000e_setup_led_generic,
Bruce Allan608f8a02010-01-13 02:04:58 +00001941 .read_mac_addr = e1000_read_mac_addr_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001942};
1943
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001944static const struct e1000_phy_operations e82_phy_ops_igp = {
Bruce Allan94d81862009-11-20 23:25:26 +00001945 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001946 .check_polarity = e1000_check_polarity_igp,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001947 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001948 .commit = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001949 .force_speed_duplex = e1000e_phy_force_speed_duplex_igp,
1950 .get_cfg_done = e1000_get_cfg_done_82571,
1951 .get_cable_length = e1000e_get_cable_length_igp_2,
Bruce Allan94d81862009-11-20 23:25:26 +00001952 .get_info = e1000e_get_phy_info_igp,
1953 .read_reg = e1000e_read_phy_reg_igp,
1954 .release = e1000_put_hw_semaphore_82571,
1955 .reset = e1000e_phy_hw_reset_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001956 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1957 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001958 .write_reg = e1000e_write_phy_reg_igp,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001959 .cfg_on_link_up = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001960};
1961
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001962static const struct e1000_phy_operations e82_phy_ops_m88 = {
Bruce Allan94d81862009-11-20 23:25:26 +00001963 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001964 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001965 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001966 .commit = e1000e_phy_sw_reset,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001967 .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
1968 .get_cfg_done = e1000e_get_cfg_done,
1969 .get_cable_length = e1000e_get_cable_length_m88,
Bruce Allan94d81862009-11-20 23:25:26 +00001970 .get_info = e1000e_get_phy_info_m88,
1971 .read_reg = e1000e_read_phy_reg_m88,
1972 .release = e1000_put_hw_semaphore_82571,
1973 .reset = e1000e_phy_hw_reset_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001974 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1975 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001976 .write_reg = e1000e_write_phy_reg_m88,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001977 .cfg_on_link_up = NULL,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001978};
1979
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001980static const struct e1000_phy_operations e82_phy_ops_bm = {
Bruce Allan94d81862009-11-20 23:25:26 +00001981 .acquire = e1000_get_hw_semaphore_82571,
Bruce Allan94e5b652009-12-02 17:02:14 +00001982 .check_polarity = e1000_check_polarity_m88,
Bruce Allan4662e822008-08-26 18:37:06 -07001983 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001984 .commit = e1000e_phy_sw_reset,
Bruce Allan4662e822008-08-26 18:37:06 -07001985 .force_speed_duplex = e1000e_phy_force_speed_duplex_m88,
1986 .get_cfg_done = e1000e_get_cfg_done,
1987 .get_cable_length = e1000e_get_cable_length_m88,
Bruce Allan94d81862009-11-20 23:25:26 +00001988 .get_info = e1000e_get_phy_info_m88,
1989 .read_reg = e1000e_read_phy_reg_bm2,
1990 .release = e1000_put_hw_semaphore_82571,
1991 .reset = e1000e_phy_hw_reset_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07001992 .set_d0_lplu_state = e1000_set_d0_lplu_state_82571,
1993 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001994 .write_reg = e1000e_write_phy_reg_bm2,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001995 .cfg_on_link_up = NULL,
Bruce Allan4662e822008-08-26 18:37:06 -07001996};
1997
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001998static const struct e1000_nvm_operations e82571_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001999 .acquire = e1000_acquire_nvm_82571,
2000 .read = e1000e_read_nvm_eerd,
2001 .release = e1000_release_nvm_82571,
2002 .update = e1000_update_nvm_checksum_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002003 .valid_led_default = e1000_valid_led_default_82571,
Bruce Allan94d81862009-11-20 23:25:26 +00002004 .validate = e1000_validate_nvm_checksum_82571,
2005 .write = e1000_write_nvm_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002006};
2007
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002008const struct e1000_info e1000_82571_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002009 .mac = e1000_82571,
2010 .flags = FLAG_HAS_HW_VLAN_FILTER
2011 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07002012 | FLAG_HAS_WOL
2013 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07002014 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07002015 | FLAG_HAS_SMART_POWER_DOWN
2016 | FLAG_RESET_OVERWRITES_LAA /* errata */
2017 | FLAG_TARC_SPEED_MODE_BIT /* errata */
2018 | FLAG_APME_CHECK_PORT_B,
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00002019 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
2020 | FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002021 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00002022 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07002023 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002024 .mac_ops = &e82571_mac_ops,
2025 .phy_ops = &e82_phy_ops_igp,
2026 .nvm_ops = &e82571_nvm_ops,
2027};
2028
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002029const struct e1000_info e1000_82572_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002030 .mac = e1000_82572,
2031 .flags = FLAG_HAS_HW_VLAN_FILTER
2032 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07002033 | FLAG_HAS_WOL
2034 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07002035 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07002036 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00002037 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
2038 | FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002039 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00002040 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07002041 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002042 .mac_ops = &e82571_mac_ops,
2043 .phy_ops = &e82_phy_ops_igp,
2044 .nvm_ops = &e82571_nvm_ops,
2045};
2046
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002047const struct e1000_info e1000_82573_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07002048 .mac = e1000_82573,
2049 .flags = FLAG_HAS_HW_VLAN_FILTER
Auke Kokbc7f75f2007-09-17 12:30:59 -07002050 | FLAG_HAS_WOL
2051 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07002052 | FLAG_HAS_SMART_POWER_DOWN
2053 | FLAG_HAS_AMT
Auke Kokbc7f75f2007-09-17 12:30:59 -07002054 | FLAG_HAS_SWSM_ON_LOAD,
Bruce Allan78cd29d2011-03-24 03:09:03 +00002055 .flags2 = FLAG2_DISABLE_ASPM_L1
2056 | FLAG2_DISABLE_ASPM_L0S,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002057 .pba = 20,
Bruce Allan2adc55c2009-06-02 11:28:58 +00002058 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07002059 .get_variants = e1000_get_variants_82571,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002060 .mac_ops = &e82571_mac_ops,
2061 .phy_ops = &e82_phy_ops_m88,
Auke Kok31f8c4f2008-02-21 15:10:47 -08002062 .nvm_ops = &e82571_nvm_ops,
Auke Kokbc7f75f2007-09-17 12:30:59 -07002063};
2064
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002065const struct e1000_info e1000_82574_info = {
Bruce Allan4662e822008-08-26 18:37:06 -07002066 .mac = e1000_82574,
2067 .flags = FLAG_HAS_HW_VLAN_FILTER
2068 | FLAG_HAS_MSIX
2069 | FLAG_HAS_JUMBO_FRAMES
2070 | FLAG_HAS_WOL
2071 | FLAG_APME_IN_CTRL3
Bruce Allan4662e822008-08-26 18:37:06 -07002072 | FLAG_HAS_SMART_POWER_DOWN
2073 | FLAG_HAS_AMT
2074 | FLAG_HAS_CTRLEXT_ON_LOAD,
Bruce Allan78cd29d2011-03-24 03:09:03 +00002075 .flags2 = FLAG2_CHECK_PHY_HANG
Bruce Allan7f99ae62011-07-22 06:21:35 +00002076 | FLAG2_DISABLE_ASPM_L0S
2077 | FLAG2_NO_DISABLE_RX,
Bruce Allaned5c2b02010-11-24 06:01:25 +00002078 .pba = 32,
Alexander Duycka825e002009-10-02 12:30:42 +00002079 .max_hw_frame_size = DEFAULT_JUMBO,
Bruce Allan4662e822008-08-26 18:37:06 -07002080 .get_variants = e1000_get_variants_82571,
2081 .mac_ops = &e82571_mac_ops,
2082 .phy_ops = &e82_phy_ops_bm,
2083 .nvm_ops = &e82571_nvm_ops,
2084};
2085
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00002086const struct e1000_info e1000_82583_info = {
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002087 .mac = e1000_82583,
2088 .flags = FLAG_HAS_HW_VLAN_FILTER
2089 | FLAG_HAS_WOL
2090 | FLAG_APME_IN_CTRL3
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002091 | FLAG_HAS_SMART_POWER_DOWN
2092 | FLAG_HAS_AMT
Carolyn Wybornya3d72d52011-07-12 16:10:11 +00002093 | FLAG_HAS_JUMBO_FRAMES
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002094 | FLAG_HAS_CTRLEXT_ON_LOAD,
Bruce Allan7f99ae62011-07-22 06:21:35 +00002095 .flags2 = FLAG2_DISABLE_ASPM_L0S
2096 | FLAG2_NO_DISABLE_RX,
Bruce Allaned5c2b02010-11-24 06:01:25 +00002097 .pba = 32,
Carolyn Wybornya3d72d52011-07-12 16:10:11 +00002098 .max_hw_frame_size = DEFAULT_JUMBO,
Alexander Duyck8c81c9c2009-03-19 01:12:27 +00002099 .get_variants = e1000_get_variants_82571,
2100 .mac_ops = &e82571_mac_ops,
2101 .phy_ops = &e82_phy_ops_bm,
2102 .nvm_ops = &e82571_nvm_ops,
2103};
2104