initial commit with v2.6.32.60
[linux-2.6.32.60-moxart.git] / drivers / net / igb / e1000_82575.c
blobd617f2d8969e0d47d108df5bbde2fd2ec0bc823f
1 /*******************************************************************************
3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2009 Intel Corporation.
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.
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.
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
22 Contact Information:
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
28 /* e1000_82575
29 * e1000_82576
32 #include <linux/types.h>
33 #include <linux/slab.h>
34 #include <linux/if_ether.h>
36 #include "e1000_mac.h"
37 #include "e1000_82575.h"
39 static s32 igb_get_invariants_82575(struct e1000_hw *);
40 static s32 igb_acquire_phy_82575(struct e1000_hw *);
41 static void igb_release_phy_82575(struct e1000_hw *);
42 static s32 igb_acquire_nvm_82575(struct e1000_hw *);
43 static void igb_release_nvm_82575(struct e1000_hw *);
44 static s32 igb_check_for_link_82575(struct e1000_hw *);
45 static s32 igb_get_cfg_done_82575(struct e1000_hw *);
46 static s32 igb_init_hw_82575(struct e1000_hw *);
47 static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *);
48 static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *);
49 static s32 igb_reset_hw_82575(struct e1000_hw *);
50 static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool);
51 static s32 igb_setup_copper_link_82575(struct e1000_hw *);
52 static s32 igb_setup_serdes_link_82575(struct e1000_hw *);
53 static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16);
54 static void igb_clear_hw_cntrs_82575(struct e1000_hw *);
55 static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16);
56 static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *,
57 u16 *);
58 static s32 igb_get_phy_id_82575(struct e1000_hw *);
59 static void igb_release_swfw_sync_82575(struct e1000_hw *, u16);
60 static bool igb_sgmii_active_82575(struct e1000_hw *);
61 static s32 igb_reset_init_script_82575(struct e1000_hw *);
62 static s32 igb_read_mac_addr_82575(struct e1000_hw *);
63 static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw);
65 static s32 igb_get_invariants_82575(struct e1000_hw *hw)
67 struct e1000_phy_info *phy = &hw->phy;
68 struct e1000_nvm_info *nvm = &hw->nvm;
69 struct e1000_mac_info *mac = &hw->mac;
70 struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575;
71 u32 eecd;
72 s32 ret_val;
73 u16 size;
74 u32 ctrl_ext = 0;
76 switch (hw->device_id) {
77 case E1000_DEV_ID_82575EB_COPPER:
78 case E1000_DEV_ID_82575EB_FIBER_SERDES:
79 case E1000_DEV_ID_82575GB_QUAD_COPPER:
80 mac->type = e1000_82575;
81 break;
82 case E1000_DEV_ID_82576:
83 case E1000_DEV_ID_82576_NS:
84 case E1000_DEV_ID_82576_NS_SERDES:
85 case E1000_DEV_ID_82576_FIBER:
86 case E1000_DEV_ID_82576_SERDES:
87 case E1000_DEV_ID_82576_QUAD_COPPER:
88 case E1000_DEV_ID_82576_SERDES_QUAD:
89 mac->type = e1000_82576;
90 break;
91 default:
92 return -E1000_ERR_MAC_INIT;
93 break;
96 /* Set media type */
98 * The 82575 uses bits 22:23 for link mode. The mode can be changed
99 * based on the EEPROM. We cannot rely upon device ID. There
100 * is no distinguishable difference between fiber and internal
101 * SerDes mode on the 82575. There can be an external PHY attached
102 * on the SGMII interface. For this, we'll set sgmii_active to true.
104 phy->media_type = e1000_media_type_copper;
105 dev_spec->sgmii_active = false;
107 ctrl_ext = rd32(E1000_CTRL_EXT);
108 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
109 case E1000_CTRL_EXT_LINK_MODE_SGMII:
110 dev_spec->sgmii_active = true;
111 ctrl_ext |= E1000_CTRL_I2C_ENA;
112 break;
113 case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
114 hw->phy.media_type = e1000_media_type_internal_serdes;
115 ctrl_ext |= E1000_CTRL_I2C_ENA;
116 break;
117 default:
118 ctrl_ext &= ~E1000_CTRL_I2C_ENA;
119 break;
122 wr32(E1000_CTRL_EXT, ctrl_ext);
124 /* Set mta register count */
125 mac->mta_reg_count = 128;
126 /* Set rar entry count */
127 mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
128 if (mac->type == e1000_82576)
129 mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
130 /* Set if part includes ASF firmware */
131 mac->asf_firmware_present = true;
132 /* Set if manageability features are enabled. */
133 mac->arc_subsystem_valid =
134 (rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK)
135 ? true : false;
137 /* physical interface link setup */
138 mac->ops.setup_physical_interface =
139 (hw->phy.media_type == e1000_media_type_copper)
140 ? igb_setup_copper_link_82575
141 : igb_setup_serdes_link_82575;
143 /* NVM initialization */
144 eecd = rd32(E1000_EECD);
146 nvm->opcode_bits = 8;
147 nvm->delay_usec = 1;
148 switch (nvm->override) {
149 case e1000_nvm_override_spi_large:
150 nvm->page_size = 32;
151 nvm->address_bits = 16;
152 break;
153 case e1000_nvm_override_spi_small:
154 nvm->page_size = 8;
155 nvm->address_bits = 8;
156 break;
157 default:
158 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
159 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
160 break;
163 nvm->type = e1000_nvm_eeprom_spi;
165 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
166 E1000_EECD_SIZE_EX_SHIFT);
169 * Added to a constant, "size" becomes the left-shift value
170 * for setting word_size.
172 size += NVM_WORD_SIZE_BASE_SHIFT;
174 /* EEPROM access above 16k is unsupported */
175 if (size > 14)
176 size = 14;
177 nvm->word_size = 1 << size;
179 /* if 82576 then initialize mailbox parameters */
180 if (mac->type == e1000_82576)
181 igb_init_mbx_params_pf(hw);
183 /* setup PHY parameters */
184 if (phy->media_type != e1000_media_type_copper) {
185 phy->type = e1000_phy_none;
186 return 0;
189 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
190 phy->reset_delay_us = 100;
192 /* PHY function pointers */
193 if (igb_sgmii_active_82575(hw)) {
194 phy->ops.reset = igb_phy_hw_reset_sgmii_82575;
195 phy->ops.read_reg = igb_read_phy_reg_sgmii_82575;
196 phy->ops.write_reg = igb_write_phy_reg_sgmii_82575;
197 } else {
198 phy->ops.reset = igb_phy_hw_reset;
199 phy->ops.read_reg = igb_read_phy_reg_igp;
200 phy->ops.write_reg = igb_write_phy_reg_igp;
203 /* set lan id */
204 hw->bus.func = (rd32(E1000_STATUS) & E1000_STATUS_FUNC_MASK) >>
205 E1000_STATUS_FUNC_SHIFT;
207 /* Set phy->phy_addr and phy->id. */
208 ret_val = igb_get_phy_id_82575(hw);
209 if (ret_val)
210 return ret_val;
212 /* Verify phy id and set remaining function pointers */
213 switch (phy->id) {
214 case M88E1111_I_PHY_ID:
215 phy->type = e1000_phy_m88;
216 phy->ops.get_phy_info = igb_get_phy_info_m88;
217 phy->ops.get_cable_length = igb_get_cable_length_m88;
218 phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;
219 break;
220 case IGP03E1000_E_PHY_ID:
221 phy->type = e1000_phy_igp_3;
222 phy->ops.get_phy_info = igb_get_phy_info_igp;
223 phy->ops.get_cable_length = igb_get_cable_length_igp_2;
224 phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_igp;
225 phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575;
226 phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state;
227 break;
228 default:
229 return -E1000_ERR_PHY;
232 return 0;
236 * igb_acquire_phy_82575 - Acquire rights to access PHY
237 * @hw: pointer to the HW structure
239 * Acquire access rights to the correct PHY. This is a
240 * function pointer entry point called by the api module.
242 static s32 igb_acquire_phy_82575(struct e1000_hw *hw)
244 u16 mask;
246 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
248 return igb_acquire_swfw_sync_82575(hw, mask);
252 * igb_release_phy_82575 - Release rights to access PHY
253 * @hw: pointer to the HW structure
255 * A wrapper to release access rights to the correct PHY. This is a
256 * function pointer entry point called by the api module.
258 static void igb_release_phy_82575(struct e1000_hw *hw)
260 u16 mask;
262 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
263 igb_release_swfw_sync_82575(hw, mask);
267 * igb_read_phy_reg_sgmii_82575 - Read PHY register using sgmii
268 * @hw: pointer to the HW structure
269 * @offset: register offset to be read
270 * @data: pointer to the read data
272 * Reads the PHY register at offset using the serial gigabit media independent
273 * interface and stores the retrieved information in data.
275 static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
276 u16 *data)
278 struct e1000_phy_info *phy = &hw->phy;
279 u32 i, i2ccmd = 0;
281 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
282 hw_dbg("PHY Address %u is out of range\n", offset);
283 return -E1000_ERR_PARAM;
287 * Set up Op-code, Phy Address, and register address in the I2CCMD
288 * register. The MAC will take care of interfacing with the
289 * PHY to retrieve the desired data.
291 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
292 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
293 (E1000_I2CCMD_OPCODE_READ));
295 wr32(E1000_I2CCMD, i2ccmd);
297 /* Poll the ready bit to see if the I2C read completed */
298 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
299 udelay(50);
300 i2ccmd = rd32(E1000_I2CCMD);
301 if (i2ccmd & E1000_I2CCMD_READY)
302 break;
304 if (!(i2ccmd & E1000_I2CCMD_READY)) {
305 hw_dbg("I2CCMD Read did not complete\n");
306 return -E1000_ERR_PHY;
308 if (i2ccmd & E1000_I2CCMD_ERROR) {
309 hw_dbg("I2CCMD Error bit set\n");
310 return -E1000_ERR_PHY;
313 /* Need to byte-swap the 16-bit value. */
314 *data = ((i2ccmd >> 8) & 0x00FF) | ((i2ccmd << 8) & 0xFF00);
316 return 0;
320 * igb_write_phy_reg_sgmii_82575 - Write PHY register using sgmii
321 * @hw: pointer to the HW structure
322 * @offset: register offset to write to
323 * @data: data to write at register offset
325 * Writes the data to PHY register at the offset using the serial gigabit
326 * media independent interface.
328 static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
329 u16 data)
331 struct e1000_phy_info *phy = &hw->phy;
332 u32 i, i2ccmd = 0;
333 u16 phy_data_swapped;
335 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
336 hw_dbg("PHY Address %d is out of range\n", offset);
337 return -E1000_ERR_PARAM;
340 /* Swap the data bytes for the I2C interface */
341 phy_data_swapped = ((data >> 8) & 0x00FF) | ((data << 8) & 0xFF00);
344 * Set up Op-code, Phy Address, and register address in the I2CCMD
345 * register. The MAC will take care of interfacing with the
346 * PHY to retrieve the desired data.
348 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
349 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
350 E1000_I2CCMD_OPCODE_WRITE |
351 phy_data_swapped);
353 wr32(E1000_I2CCMD, i2ccmd);
355 /* Poll the ready bit to see if the I2C read completed */
356 for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
357 udelay(50);
358 i2ccmd = rd32(E1000_I2CCMD);
359 if (i2ccmd & E1000_I2CCMD_READY)
360 break;
362 if (!(i2ccmd & E1000_I2CCMD_READY)) {
363 hw_dbg("I2CCMD Write did not complete\n");
364 return -E1000_ERR_PHY;
366 if (i2ccmd & E1000_I2CCMD_ERROR) {
367 hw_dbg("I2CCMD Error bit set\n");
368 return -E1000_ERR_PHY;
371 return 0;
375 * igb_get_phy_id_82575 - Retrieve PHY addr and id
376 * @hw: pointer to the HW structure
378 * Retrieves the PHY address and ID for both PHY's which do and do not use
379 * sgmi interface.
381 static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
383 struct e1000_phy_info *phy = &hw->phy;
384 s32 ret_val = 0;
385 u16 phy_id;
386 u32 ctrl_ext;
389 * For SGMII PHYs, we try the list of possible addresses until
390 * we find one that works. For non-SGMII PHYs
391 * (e.g. integrated copper PHYs), an address of 1 should
392 * work. The result of this function should mean phy->phy_addr
393 * and phy->id are set correctly.
395 if (!(igb_sgmii_active_82575(hw))) {
396 phy->addr = 1;
397 ret_val = igb_get_phy_id(hw);
398 goto out;
401 /* Power on sgmii phy if it is disabled */
402 ctrl_ext = rd32(E1000_CTRL_EXT);
403 wr32(E1000_CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
404 wrfl();
405 msleep(300);
408 * The address field in the I2CCMD register is 3 bits and 0 is invalid.
409 * Therefore, we need to test 1-7
411 for (phy->addr = 1; phy->addr < 8; phy->addr++) {
412 ret_val = igb_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
413 if (ret_val == 0) {
414 hw_dbg("Vendor ID 0x%08X read at address %u\n",
415 phy_id, phy->addr);
417 * At the time of this writing, The M88 part is
418 * the only supported SGMII PHY product.
420 if (phy_id == M88_VENDOR)
421 break;
422 } else {
423 hw_dbg("PHY address %u was unreadable\n", phy->addr);
427 /* A valid PHY type couldn't be found. */
428 if (phy->addr == 8) {
429 phy->addr = 0;
430 ret_val = -E1000_ERR_PHY;
431 goto out;
432 } else {
433 ret_val = igb_get_phy_id(hw);
436 /* restore previous sfp cage power state */
437 wr32(E1000_CTRL_EXT, ctrl_ext);
439 out:
440 return ret_val;
444 * igb_phy_hw_reset_sgmii_82575 - Performs a PHY reset
445 * @hw: pointer to the HW structure
447 * Resets the PHY using the serial gigabit media independent interface.
449 static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
451 s32 ret_val;
454 * This isn't a true "hard" reset, but is the only reset
455 * available to us at this time.
458 hw_dbg("Soft resetting SGMII attached PHY...\n");
461 * SFP documentation requires the following to configure the SPF module
462 * to work on SGMII. No further documentation is given.
464 ret_val = hw->phy.ops.write_reg(hw, 0x1B, 0x8084);
465 if (ret_val)
466 goto out;
468 ret_val = igb_phy_sw_reset(hw);
470 out:
471 return ret_val;
475 * igb_set_d0_lplu_state_82575 - Set Low Power Linkup D0 state
476 * @hw: pointer to the HW structure
477 * @active: true to enable LPLU, false to disable
479 * Sets the LPLU D0 state according to the active flag. When
480 * activating LPLU this function also disables smart speed
481 * and vice versa. LPLU will not be activated unless the
482 * device autonegotiation advertisement meets standards of
483 * either 10 or 10/100 or 10/100/1000 at all duplexes.
484 * This is a function pointer entry point only called by
485 * PHY setup routines.
487 static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
489 struct e1000_phy_info *phy = &hw->phy;
490 s32 ret_val;
491 u16 data;
493 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
494 if (ret_val)
495 goto out;
497 if (active) {
498 data |= IGP02E1000_PM_D0_LPLU;
499 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
500 data);
501 if (ret_val)
502 goto out;
504 /* When LPLU is enabled, we should disable SmartSpeed */
505 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
506 &data);
507 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
508 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
509 data);
510 if (ret_val)
511 goto out;
512 } else {
513 data &= ~IGP02E1000_PM_D0_LPLU;
514 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
515 data);
517 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
518 * during Dx states where the power conservation is most
519 * important. During driver activity we should enable
520 * SmartSpeed, so performance is maintained.
522 if (phy->smart_speed == e1000_smart_speed_on) {
523 ret_val = phy->ops.read_reg(hw,
524 IGP01E1000_PHY_PORT_CONFIG, &data);
525 if (ret_val)
526 goto out;
528 data |= IGP01E1000_PSCFR_SMART_SPEED;
529 ret_val = phy->ops.write_reg(hw,
530 IGP01E1000_PHY_PORT_CONFIG, data);
531 if (ret_val)
532 goto out;
533 } else if (phy->smart_speed == e1000_smart_speed_off) {
534 ret_val = phy->ops.read_reg(hw,
535 IGP01E1000_PHY_PORT_CONFIG, &data);
536 if (ret_val)
537 goto out;
539 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
540 ret_val = phy->ops.write_reg(hw,
541 IGP01E1000_PHY_PORT_CONFIG, data);
542 if (ret_val)
543 goto out;
547 out:
548 return ret_val;
552 * igb_acquire_nvm_82575 - Request for access to EEPROM
553 * @hw: pointer to the HW structure
555 * Acquire the necessary semaphores for exclusive access to the EEPROM.
556 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
557 * Return successful if access grant bit set, else clear the request for
558 * EEPROM access and return -E1000_ERR_NVM (-1).
560 static s32 igb_acquire_nvm_82575(struct e1000_hw *hw)
562 s32 ret_val;
564 ret_val = igb_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
565 if (ret_val)
566 goto out;
568 ret_val = igb_acquire_nvm(hw);
570 if (ret_val)
571 igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
573 out:
574 return ret_val;
578 * igb_release_nvm_82575 - Release exclusive access to EEPROM
579 * @hw: pointer to the HW structure
581 * Stop any current commands to the EEPROM and clear the EEPROM request bit,
582 * then release the semaphores acquired.
584 static void igb_release_nvm_82575(struct e1000_hw *hw)
586 igb_release_nvm(hw);
587 igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
591 * igb_acquire_swfw_sync_82575 - Acquire SW/FW semaphore
592 * @hw: pointer to the HW structure
593 * @mask: specifies which semaphore to acquire
595 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
596 * will also specify which port we're acquiring the lock for.
598 static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
600 u32 swfw_sync;
601 u32 swmask = mask;
602 u32 fwmask = mask << 16;
603 s32 ret_val = 0;
604 s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
606 while (i < timeout) {
607 if (igb_get_hw_semaphore(hw)) {
608 ret_val = -E1000_ERR_SWFW_SYNC;
609 goto out;
612 swfw_sync = rd32(E1000_SW_FW_SYNC);
613 if (!(swfw_sync & (fwmask | swmask)))
614 break;
617 * Firmware currently using resource (fwmask)
618 * or other software thread using resource (swmask)
620 igb_put_hw_semaphore(hw);
621 mdelay(5);
622 i++;
625 if (i == timeout) {
626 hw_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
627 ret_val = -E1000_ERR_SWFW_SYNC;
628 goto out;
631 swfw_sync |= swmask;
632 wr32(E1000_SW_FW_SYNC, swfw_sync);
634 igb_put_hw_semaphore(hw);
636 out:
637 return ret_val;
641 * igb_release_swfw_sync_82575 - Release SW/FW semaphore
642 * @hw: pointer to the HW structure
643 * @mask: specifies which semaphore to acquire
645 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
646 * will also specify which port we're releasing the lock for.
648 static void igb_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
650 u32 swfw_sync;
652 while (igb_get_hw_semaphore(hw) != 0);
653 /* Empty */
655 swfw_sync = rd32(E1000_SW_FW_SYNC);
656 swfw_sync &= ~mask;
657 wr32(E1000_SW_FW_SYNC, swfw_sync);
659 igb_put_hw_semaphore(hw);
663 * igb_get_cfg_done_82575 - Read config done bit
664 * @hw: pointer to the HW structure
666 * Read the management control register for the config done bit for
667 * completion status. NOTE: silicon which is EEPROM-less will fail trying
668 * to read the config done bit, so an error is *ONLY* logged and returns
669 * 0. If we were to return with error, EEPROM-less silicon
670 * would not be able to be reset or change link.
672 static s32 igb_get_cfg_done_82575(struct e1000_hw *hw)
674 s32 timeout = PHY_CFG_TIMEOUT;
675 s32 ret_val = 0;
676 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
678 if (hw->bus.func == 1)
679 mask = E1000_NVM_CFG_DONE_PORT_1;
681 while (timeout) {
682 if (rd32(E1000_EEMNGCTL) & mask)
683 break;
684 msleep(1);
685 timeout--;
687 if (!timeout)
688 hw_dbg("MNG configuration cycle has not completed.\n");
690 /* If EEPROM is not marked present, init the PHY manually */
691 if (((rd32(E1000_EECD) & E1000_EECD_PRES) == 0) &&
692 (hw->phy.type == e1000_phy_igp_3))
693 igb_phy_init_script_igp3(hw);
695 return ret_val;
699 * igb_check_for_link_82575 - Check for link
700 * @hw: pointer to the HW structure
702 * If sgmii is enabled, then use the pcs register to determine link, otherwise
703 * use the generic interface for determining link.
705 static s32 igb_check_for_link_82575(struct e1000_hw *hw)
707 s32 ret_val;
708 u16 speed, duplex;
710 /* SGMII link check is done through the PCS register. */
711 if ((hw->phy.media_type != e1000_media_type_copper) ||
712 (igb_sgmii_active_82575(hw))) {
713 ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
714 &duplex);
716 * Use this flag to determine if link needs to be checked or
717 * not. If we have link clear the flag so that we do not
718 * continue to check for link.
720 hw->mac.get_link_status = !hw->mac.serdes_has_link;
721 } else {
722 ret_val = igb_check_for_copper_link(hw);
725 return ret_val;
728 * igb_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
729 * @hw: pointer to the HW structure
730 * @speed: stores the current speed
731 * @duplex: stores the current duplex
733 * Using the physical coding sub-layer (PCS), retrieve the current speed and
734 * duplex, then store the values in the pointers provided.
736 static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
737 u16 *duplex)
739 struct e1000_mac_info *mac = &hw->mac;
740 u32 pcs;
742 /* Set up defaults for the return values of this function */
743 mac->serdes_has_link = false;
744 *speed = 0;
745 *duplex = 0;
748 * Read the PCS Status register for link state. For non-copper mode,
749 * the status register is not accurate. The PCS status register is
750 * used instead.
752 pcs = rd32(E1000_PCS_LSTAT);
755 * The link up bit determines when link is up on autoneg. The sync ok
756 * gets set once both sides sync up and agree upon link. Stable link
757 * can be determined by checking for both link up and link sync ok
759 if ((pcs & E1000_PCS_LSTS_LINK_OK) && (pcs & E1000_PCS_LSTS_SYNK_OK)) {
760 mac->serdes_has_link = true;
762 /* Detect and store PCS speed */
763 if (pcs & E1000_PCS_LSTS_SPEED_1000) {
764 *speed = SPEED_1000;
765 } else if (pcs & E1000_PCS_LSTS_SPEED_100) {
766 *speed = SPEED_100;
767 } else {
768 *speed = SPEED_10;
771 /* Detect and store PCS duplex */
772 if (pcs & E1000_PCS_LSTS_DUPLEX_FULL) {
773 *duplex = FULL_DUPLEX;
774 } else {
775 *duplex = HALF_DUPLEX;
779 return 0;
783 * igb_shutdown_serdes_link_82575 - Remove link during power down
784 * @hw: pointer to the HW structure
786 * In the case of fiber serdes, shut down optics and PCS on driver unload
787 * when management pass thru is not enabled.
789 void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
791 u32 reg;
793 if (hw->phy.media_type != e1000_media_type_internal_serdes ||
794 igb_sgmii_active_82575(hw))
795 return;
797 /* if the management interface is not enabled, then power down */
798 if (!igb_enable_mng_pass_thru(hw)) {
799 /* Disable PCS to turn off link */
800 reg = rd32(E1000_PCS_CFG0);
801 reg &= ~E1000_PCS_CFG_PCS_EN;
802 wr32(E1000_PCS_CFG0, reg);
804 /* shutdown the laser */
805 reg = rd32(E1000_CTRL_EXT);
806 reg |= E1000_CTRL_EXT_SDP3_DATA;
807 wr32(E1000_CTRL_EXT, reg);
809 /* flush the write to verify completion */
810 wrfl();
811 msleep(1);
814 return;
818 * igb_reset_hw_82575 - Reset hardware
819 * @hw: pointer to the HW structure
821 * This resets the hardware into a known state. This is a
822 * function pointer entry point called by the api module.
824 static s32 igb_reset_hw_82575(struct e1000_hw *hw)
826 u32 ctrl, icr;
827 s32 ret_val;
830 * Prevent the PCI-E bus from sticking if there is no TLP connection
831 * on the last TLP read/write transaction when MAC is reset.
833 ret_val = igb_disable_pcie_master(hw);
834 if (ret_val)
835 hw_dbg("PCI-E Master disable polling has failed.\n");
837 /* set the completion timeout for interface */
838 ret_val = igb_set_pcie_completion_timeout(hw);
839 if (ret_val) {
840 hw_dbg("PCI-E Set completion timeout has failed.\n");
843 hw_dbg("Masking off all interrupts\n");
844 wr32(E1000_IMC, 0xffffffff);
846 wr32(E1000_RCTL, 0);
847 wr32(E1000_TCTL, E1000_TCTL_PSP);
848 wrfl();
850 msleep(10);
852 ctrl = rd32(E1000_CTRL);
854 hw_dbg("Issuing a global reset to MAC\n");
855 wr32(E1000_CTRL, ctrl | E1000_CTRL_RST);
857 ret_val = igb_get_auto_rd_done(hw);
858 if (ret_val) {
860 * When auto config read does not complete, do not
861 * return with an error. This can happen in situations
862 * where there is no eeprom and prevents getting link.
864 hw_dbg("Auto Read Done did not complete\n");
867 /* If EEPROM is not present, run manual init scripts */
868 if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
869 igb_reset_init_script_82575(hw);
871 /* Clear any pending interrupt events. */
872 wr32(E1000_IMC, 0xffffffff);
873 icr = rd32(E1000_ICR);
875 /* Install any alternate MAC address into RAR0 */
876 ret_val = igb_check_alt_mac_addr(hw);
878 return ret_val;
882 * igb_init_hw_82575 - Initialize hardware
883 * @hw: pointer to the HW structure
885 * This inits the hardware readying it for operation.
887 static s32 igb_init_hw_82575(struct e1000_hw *hw)
889 struct e1000_mac_info *mac = &hw->mac;
890 s32 ret_val;
891 u16 i, rar_count = mac->rar_entry_count;
893 /* Initialize identification LED */
894 ret_val = igb_id_led_init(hw);
895 if (ret_val) {
896 hw_dbg("Error initializing identification LED\n");
897 /* This is not fatal and we should not stop init due to this */
900 /* Disabling VLAN filtering */
901 hw_dbg("Initializing the IEEE VLAN\n");
902 igb_clear_vfta(hw);
904 /* Setup the receive address */
905 igb_init_rx_addrs(hw, rar_count);
907 /* Zero out the Multicast HASH table */
908 hw_dbg("Zeroing the MTA\n");
909 for (i = 0; i < mac->mta_reg_count; i++)
910 array_wr32(E1000_MTA, i, 0);
912 /* Setup link and flow control */
913 ret_val = igb_setup_link(hw);
916 * Clear all of the statistics registers (clear on read). It is
917 * important that we do this after we have tried to establish link
918 * because the symbol error count will increment wildly if there
919 * is no link.
921 igb_clear_hw_cntrs_82575(hw);
923 return ret_val;
927 * igb_setup_copper_link_82575 - Configure copper link settings
928 * @hw: pointer to the HW structure
930 * Configures the link for auto-neg or forced speed and duplex. Then we check
931 * for link, once link is established calls to configure collision distance
932 * and flow control are called.
934 static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
936 u32 ctrl;
937 s32 ret_val;
938 bool link;
940 ctrl = rd32(E1000_CTRL);
941 ctrl |= E1000_CTRL_SLU;
942 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
943 wr32(E1000_CTRL, ctrl);
944 wrfl();
946 ret_val = igb_setup_serdes_link_82575(hw);
947 if (ret_val)
948 goto out;
950 if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) {
951 ret_val = hw->phy.ops.reset(hw);
952 if (ret_val) {
953 hw_dbg("Error resetting the PHY.\n");
954 goto out;
957 switch (hw->phy.type) {
958 case e1000_phy_m88:
959 ret_val = igb_copper_link_setup_m88(hw);
960 break;
961 case e1000_phy_igp_3:
962 ret_val = igb_copper_link_setup_igp(hw);
963 break;
964 default:
965 ret_val = -E1000_ERR_PHY;
966 break;
969 if (ret_val)
970 goto out;
972 if (hw->mac.autoneg) {
974 * Setup autoneg and flow control advertisement
975 * and perform autonegotiation.
977 ret_val = igb_copper_link_autoneg(hw);
978 if (ret_val)
979 goto out;
980 } else {
982 * PHY will be set to 10H, 10F, 100H or 100F
983 * depending on user settings.
985 hw_dbg("Forcing Speed and Duplex\n");
986 ret_val = hw->phy.ops.force_speed_duplex(hw);
987 if (ret_val) {
988 hw_dbg("Error Forcing Speed and Duplex\n");
989 goto out;
994 * Check link status. Wait up to 100 microseconds for link to become
995 * valid.
997 ret_val = igb_phy_has_link(hw, COPPER_LINK_UP_LIMIT, 10, &link);
998 if (ret_val)
999 goto out;
1001 if (link) {
1002 hw_dbg("Valid link established!!!\n");
1003 /* Config the MAC and PHY after link is up */
1004 igb_config_collision_dist(hw);
1005 ret_val = igb_config_fc_after_link_up(hw);
1006 } else {
1007 hw_dbg("Unable to establish link!!!\n");
1010 out:
1011 return ret_val;
1015 * igb_setup_serdes_link_82575 - Setup link for fiber/serdes
1016 * @hw: pointer to the HW structure
1018 * Configures speed and duplex for fiber and serdes links.
1020 static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
1022 u32 ctrl_reg, reg;
1024 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
1025 !igb_sgmii_active_82575(hw))
1026 return 0;
1029 * On the 82575, SerDes loopback mode persists until it is
1030 * explicitly turned off or a power cycle is performed. A read to
1031 * the register does not indicate its status. Therefore, we ensure
1032 * loopback mode is disabled during initialization.
1034 wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1036 /* power on the sfp cage if present */
1037 reg = rd32(E1000_CTRL_EXT);
1038 reg &= ~E1000_CTRL_EXT_SDP3_DATA;
1039 wr32(E1000_CTRL_EXT, reg);
1041 ctrl_reg = rd32(E1000_CTRL);
1042 ctrl_reg |= E1000_CTRL_SLU;
1044 if (hw->mac.type == e1000_82575 || hw->mac.type == e1000_82576) {
1045 /* set both sw defined pins */
1046 ctrl_reg |= E1000_CTRL_SWDPIN0 | E1000_CTRL_SWDPIN1;
1048 /* Set switch control to serdes energy detect */
1049 reg = rd32(E1000_CONNSW);
1050 reg |= E1000_CONNSW_ENRGSRC;
1051 wr32(E1000_CONNSW, reg);
1054 reg = rd32(E1000_PCS_LCTL);
1056 if (igb_sgmii_active_82575(hw)) {
1057 /* allow time for SFP cage to power up phy */
1058 msleep(300);
1060 /* AN time out should be disabled for SGMII mode */
1061 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
1062 } else {
1063 ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
1064 E1000_CTRL_FD | E1000_CTRL_FRCDPX;
1067 wr32(E1000_CTRL, ctrl_reg);
1070 * New SerDes mode allows for forcing speed or autonegotiating speed
1071 * at 1gb. Autoneg should be default set by most drivers. This is the
1072 * mode that will be compatible with older link partners and switches.
1073 * However, both are supported by the hardware and some drivers/tools.
1076 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
1077 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
1080 * We force flow control to prevent the CTRL register values from being
1081 * overwritten by the autonegotiated flow control values
1083 reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1086 * we always set sgmii to autoneg since it is the phy that will be
1087 * forcing the link and the serdes is just a go-between
1089 if (hw->mac.autoneg || igb_sgmii_active_82575(hw)) {
1090 /* Set PCS register for autoneg */
1091 reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */
1092 E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */
1093 E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
1094 E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
1095 hw_dbg("Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
1096 } else {
1097 /* Set PCS register for forced speed */
1098 reg |= E1000_PCS_LCTL_FLV_LINK_UP | /* Force link up */
1099 E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */
1100 E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */
1101 E1000_PCS_LCTL_FSD | /* Force Speed */
1102 E1000_PCS_LCTL_FORCE_LINK; /* Force Link */
1103 hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
1106 wr32(E1000_PCS_LCTL, reg);
1108 if (!igb_sgmii_active_82575(hw))
1109 igb_force_mac_fc(hw);
1111 return 0;
1115 * igb_sgmii_active_82575 - Return sgmii state
1116 * @hw: pointer to the HW structure
1118 * 82575 silicon has a serialized gigabit media independent interface (sgmii)
1119 * which can be enabled for use in the embedded applications. Simply
1120 * return the current state of the sgmii interface.
1122 static bool igb_sgmii_active_82575(struct e1000_hw *hw)
1124 struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
1125 return dev_spec->sgmii_active;
1129 * igb_reset_init_script_82575 - Inits HW defaults after reset
1130 * @hw: pointer to the HW structure
1132 * Inits recommended HW defaults after a reset when there is no EEPROM
1133 * detected. This is only for the 82575.
1135 static s32 igb_reset_init_script_82575(struct e1000_hw *hw)
1137 if (hw->mac.type == e1000_82575) {
1138 hw_dbg("Running reset init script for 82575\n");
1139 /* SerDes configuration via SERDESCTRL */
1140 igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x00, 0x0C);
1141 igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x01, 0x78);
1142 igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x1B, 0x23);
1143 igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x23, 0x15);
1145 /* CCM configuration via CCMCTL register */
1146 igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x14, 0x00);
1147 igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x10, 0x00);
1149 /* PCIe lanes configuration */
1150 igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x00, 0xEC);
1151 igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x61, 0xDF);
1152 igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x34, 0x05);
1153 igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x2F, 0x81);
1155 /* PCIe PLL Configuration */
1156 igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x02, 0x47);
1157 igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x14, 0x00);
1158 igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x10, 0x00);
1161 return 0;
1165 * igb_read_mac_addr_82575 - Read device MAC address
1166 * @hw: pointer to the HW structure
1168 static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
1170 s32 ret_val = 0;
1173 * If there's an alternate MAC address place it in RAR0
1174 * so that it will override the Si installed default perm
1175 * address.
1177 ret_val = igb_check_alt_mac_addr(hw);
1178 if (ret_val)
1179 goto out;
1181 ret_val = igb_read_mac_addr(hw);
1183 out:
1184 return ret_val;
1188 * igb_clear_hw_cntrs_82575 - Clear device specific hardware counters
1189 * @hw: pointer to the HW structure
1191 * Clears the hardware counters by reading the counter registers.
1193 static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw)
1195 u32 temp;
1197 igb_clear_hw_cntrs_base(hw);
1199 temp = rd32(E1000_PRC64);
1200 temp = rd32(E1000_PRC127);
1201 temp = rd32(E1000_PRC255);
1202 temp = rd32(E1000_PRC511);
1203 temp = rd32(E1000_PRC1023);
1204 temp = rd32(E1000_PRC1522);
1205 temp = rd32(E1000_PTC64);
1206 temp = rd32(E1000_PTC127);
1207 temp = rd32(E1000_PTC255);
1208 temp = rd32(E1000_PTC511);
1209 temp = rd32(E1000_PTC1023);
1210 temp = rd32(E1000_PTC1522);
1212 temp = rd32(E1000_ALGNERRC);
1213 temp = rd32(E1000_RXERRC);
1214 temp = rd32(E1000_TNCRS);
1215 temp = rd32(E1000_CEXTERR);
1216 temp = rd32(E1000_TSCTC);
1217 temp = rd32(E1000_TSCTFC);
1219 temp = rd32(E1000_MGTPRC);
1220 temp = rd32(E1000_MGTPDC);
1221 temp = rd32(E1000_MGTPTC);
1223 temp = rd32(E1000_IAC);
1224 temp = rd32(E1000_ICRXOC);
1226 temp = rd32(E1000_ICRXPTC);
1227 temp = rd32(E1000_ICRXATC);
1228 temp = rd32(E1000_ICTXPTC);
1229 temp = rd32(E1000_ICTXATC);
1230 temp = rd32(E1000_ICTXQEC);
1231 temp = rd32(E1000_ICTXQMTC);
1232 temp = rd32(E1000_ICRXDMTC);
1234 temp = rd32(E1000_CBTMPC);
1235 temp = rd32(E1000_HTDPMC);
1236 temp = rd32(E1000_CBRMPC);
1237 temp = rd32(E1000_RPTHC);
1238 temp = rd32(E1000_HGPTC);
1239 temp = rd32(E1000_HTCBDPC);
1240 temp = rd32(E1000_HGORCL);
1241 temp = rd32(E1000_HGORCH);
1242 temp = rd32(E1000_HGOTCL);
1243 temp = rd32(E1000_HGOTCH);
1244 temp = rd32(E1000_LENERRS);
1246 /* This register should not be read in copper configurations */
1247 if (hw->phy.media_type == e1000_media_type_internal_serdes ||
1248 igb_sgmii_active_82575(hw))
1249 temp = rd32(E1000_SCVPC);
1253 * igb_rx_fifo_flush_82575 - Clean rx fifo after RX enable
1254 * @hw: pointer to the HW structure
1256 * After rx enable if managability is enabled then there is likely some
1257 * bad data at the start of the fifo and possibly in the DMA fifo. This
1258 * function clears the fifos and flushes any packets that came in as rx was
1259 * being enabled.
1261 void igb_rx_fifo_flush_82575(struct e1000_hw *hw)
1263 u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled;
1264 int i, ms_wait;
1266 if (hw->mac.type != e1000_82575 ||
1267 !(rd32(E1000_MANC) & E1000_MANC_RCV_TCO_EN))
1268 return;
1270 /* Disable all RX queues */
1271 for (i = 0; i < 4; i++) {
1272 rxdctl[i] = rd32(E1000_RXDCTL(i));
1273 wr32(E1000_RXDCTL(i),
1274 rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
1276 /* Poll all queues to verify they have shut down */
1277 for (ms_wait = 0; ms_wait < 10; ms_wait++) {
1278 msleep(1);
1279 rx_enabled = 0;
1280 for (i = 0; i < 4; i++)
1281 rx_enabled |= rd32(E1000_RXDCTL(i));
1282 if (!(rx_enabled & E1000_RXDCTL_QUEUE_ENABLE))
1283 break;
1286 if (ms_wait == 10)
1287 hw_dbg("Queue disable timed out after 10ms\n");
1289 /* Clear RLPML, RCTL.SBP, RFCTL.LEF, and set RCTL.LPE so that all
1290 * incoming packets are rejected. Set enable and wait 2ms so that
1291 * any packet that was coming in as RCTL.EN was set is flushed
1293 rfctl = rd32(E1000_RFCTL);
1294 wr32(E1000_RFCTL, rfctl & ~E1000_RFCTL_LEF);
1296 rlpml = rd32(E1000_RLPML);
1297 wr32(E1000_RLPML, 0);
1299 rctl = rd32(E1000_RCTL);
1300 temp_rctl = rctl & ~(E1000_RCTL_EN | E1000_RCTL_SBP);
1301 temp_rctl |= E1000_RCTL_LPE;
1303 wr32(E1000_RCTL, temp_rctl);
1304 wr32(E1000_RCTL, temp_rctl | E1000_RCTL_EN);
1305 wrfl();
1306 msleep(2);
1308 /* Enable RX queues that were previously enabled and restore our
1309 * previous state
1311 for (i = 0; i < 4; i++)
1312 wr32(E1000_RXDCTL(i), rxdctl[i]);
1313 wr32(E1000_RCTL, rctl);
1314 wrfl();
1316 wr32(E1000_RLPML, rlpml);
1317 wr32(E1000_RFCTL, rfctl);
1319 /* Flush receive errors generated by workaround */
1320 rd32(E1000_ROC);
1321 rd32(E1000_RNBC);
1322 rd32(E1000_MPC);
1326 * igb_set_pcie_completion_timeout - set pci-e completion timeout
1327 * @hw: pointer to the HW structure
1329 * The defaults for 82575 and 82576 should be in the range of 50us to 50ms,
1330 * however the hardware default for these parts is 500us to 1ms which is less
1331 * than the 10ms recommended by the pci-e spec. To address this we need to
1332 * increase the value to either 10ms to 200ms for capability version 1 config,
1333 * or 16ms to 55ms for version 2.
1335 static s32 igb_set_pcie_completion_timeout(struct e1000_hw *hw)
1337 u32 gcr = rd32(E1000_GCR);
1338 s32 ret_val = 0;
1339 u16 pcie_devctl2;
1341 /* only take action if timeout value is defaulted to 0 */
1342 if (gcr & E1000_GCR_CMPL_TMOUT_MASK)
1343 goto out;
1346 * if capababilities version is type 1 we can write the
1347 * timeout of 10ms to 200ms through the GCR register
1349 if (!(gcr & E1000_GCR_CAP_VER2)) {
1350 gcr |= E1000_GCR_CMPL_TMOUT_10ms;
1351 goto out;
1355 * for version 2 capabilities we need to write the config space
1356 * directly in order to set the completion timeout value for
1357 * 16ms to 55ms
1359 ret_val = igb_read_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
1360 &pcie_devctl2);
1361 if (ret_val)
1362 goto out;
1364 pcie_devctl2 |= PCIE_DEVICE_CONTROL2_16ms;
1366 ret_val = igb_write_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
1367 &pcie_devctl2);
1368 out:
1369 /* disable completion timeout resend */
1370 gcr &= ~E1000_GCR_CMPL_TMOUT_RESEND;
1372 wr32(E1000_GCR, gcr);
1373 return ret_val;
1377 * igb_vmdq_set_loopback_pf - enable or disable vmdq loopback
1378 * @hw: pointer to the hardware struct
1379 * @enable: state to enter, either enabled or disabled
1381 * enables/disables L2 switch loopback functionality.
1383 void igb_vmdq_set_loopback_pf(struct e1000_hw *hw, bool enable)
1385 u32 dtxswc = rd32(E1000_DTXSWC);
1387 if (enable)
1388 dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN;
1389 else
1390 dtxswc &= ~E1000_DTXSWC_VMDQ_LOOPBACK_EN;
1392 wr32(E1000_DTXSWC, dtxswc);
1396 * igb_vmdq_set_replication_pf - enable or disable vmdq replication
1397 * @hw: pointer to the hardware struct
1398 * @enable: state to enter, either enabled or disabled
1400 * enables/disables replication of packets across multiple pools.
1402 void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
1404 u32 vt_ctl = rd32(E1000_VT_CTL);
1406 if (enable)
1407 vt_ctl |= E1000_VT_CTL_VM_REPL_EN;
1408 else
1409 vt_ctl &= ~E1000_VT_CTL_VM_REPL_EN;
1411 wr32(E1000_VT_CTL, vt_ctl);
1414 static struct e1000_mac_operations e1000_mac_ops_82575 = {
1415 .reset_hw = igb_reset_hw_82575,
1416 .init_hw = igb_init_hw_82575,
1417 .check_for_link = igb_check_for_link_82575,
1418 .rar_set = igb_rar_set,
1419 .read_mac_addr = igb_read_mac_addr_82575,
1420 .get_speed_and_duplex = igb_get_speed_and_duplex_copper,
1423 static struct e1000_phy_operations e1000_phy_ops_82575 = {
1424 .acquire = igb_acquire_phy_82575,
1425 .get_cfg_done = igb_get_cfg_done_82575,
1426 .release = igb_release_phy_82575,
1429 static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
1430 .acquire = igb_acquire_nvm_82575,
1431 .read = igb_read_nvm_eerd,
1432 .release = igb_release_nvm_82575,
1433 .write = igb_write_nvm_spi,
1436 const struct e1000_info e1000_82575_info = {
1437 .get_invariants = igb_get_invariants_82575,
1438 .mac_ops = &e1000_mac_ops_82575,
1439 .phy_ops = &e1000_phy_ops_82575,
1440 .nvm_ops = &e1000_nvm_ops_82575,