1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2007 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
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".
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
27 *******************************************************************************/
30 * 82571EB Gigabit Ethernet Controller
31 * 82571EB Gigabit Ethernet Controller (Fiber)
32 * 82572EI Gigabit Ethernet Controller (Copper)
33 * 82572EI Gigabit Ethernet Controller (Fiber)
34 * 82572EI Gigabit Ethernet Controller
35 * 82573V Gigabit Ethernet Controller (Copper)
36 * 82573E Gigabit Ethernet Controller (Copper)
37 * 82573L Gigabit Ethernet Controller
40 #include <linux/netdevice.h>
41 #include <linux/delay.h>
42 #include <linux/pci.h>
46 #define ID_LED_RESERVED_F746 0xF746
47 #define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \
48 (ID_LED_OFF1_ON2 << 8) | \
49 (ID_LED_DEF1_DEF2 << 4) | \
52 #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
54 static s32
e1000_get_phy_id_82571(struct e1000_hw
*hw
);
55 static s32
e1000_setup_copper_link_82571(struct e1000_hw
*hw
);
56 static s32
e1000_setup_fiber_serdes_link_82571(struct e1000_hw
*hw
);
57 static s32
e1000_write_nvm_eewr_82571(struct e1000_hw
*hw
, u16 offset
,
58 u16 words
, u16
*data
);
59 static s32
e1000_fix_nvm_checksum_82571(struct e1000_hw
*hw
);
60 static void e1000_initialize_hw_bits_82571(struct e1000_hw
*hw
);
61 static s32
e1000_setup_link_82571(struct e1000_hw
*hw
);
62 static void e1000_clear_hw_cntrs_82571(struct e1000_hw
*hw
);
65 * e1000_init_phy_params_82571 - Init PHY func ptrs.
66 * @hw: pointer to the HW structure
68 * This is a function pointer entry point called by the api module.
70 static s32
e1000_init_phy_params_82571(struct e1000_hw
*hw
)
72 struct e1000_phy_info
*phy
= &hw
->phy
;
75 if (hw
->media_type
!= e1000_media_type_copper
) {
76 phy
->type
= e1000_phy_none
;
81 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
82 phy
->reset_delay_us
= 100;
84 switch (hw
->mac
.type
) {
87 phy
->type
= e1000_phy_igp_2
;
90 phy
->type
= e1000_phy_m88
;
93 return -E1000_ERR_PHY
;
97 /* This can only be done after all function pointers are setup. */
98 ret_val
= e1000_get_phy_id_82571(hw
);
101 switch (hw
->mac
.type
) {
104 if (phy
->id
!= IGP01E1000_I_PHY_ID
)
105 return -E1000_ERR_PHY
;
108 if (phy
->id
!= M88E1111_I_PHY_ID
)
109 return -E1000_ERR_PHY
;
112 return -E1000_ERR_PHY
;
120 * e1000_init_nvm_params_82571 - Init NVM func ptrs.
121 * @hw: pointer to the HW structure
123 * This is a function pointer entry point called by the api module.
125 static s32
e1000_init_nvm_params_82571(struct e1000_hw
*hw
)
127 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
128 u32 eecd
= er32(EECD
);
131 nvm
->opcode_bits
= 8;
133 switch (nvm
->override
) {
134 case e1000_nvm_override_spi_large
:
136 nvm
->address_bits
= 16;
138 case e1000_nvm_override_spi_small
:
140 nvm
->address_bits
= 8;
143 nvm
->page_size
= eecd
& E1000_EECD_ADDR_BITS
? 32 : 8;
144 nvm
->address_bits
= eecd
& E1000_EECD_ADDR_BITS
? 16 : 8;
148 switch (hw
->mac
.type
) {
150 if (((eecd
>> 15) & 0x3) == 0x3) {
151 nvm
->type
= e1000_nvm_flash_hw
;
152 nvm
->word_size
= 2048;
153 /* Autonomous Flash update bit must be cleared due
154 * to Flash update issue.
156 eecd
&= ~E1000_EECD_AUPDEN
;
162 nvm
->type
= e1000_nvm_eeprom_spi
;
163 size
= (u16
)((eecd
& E1000_EECD_SIZE_EX_MASK
) >>
164 E1000_EECD_SIZE_EX_SHIFT
);
165 /* Added to a constant, "size" becomes the left-shift value
166 * for setting word_size.
168 size
+= NVM_WORD_SIZE_BASE_SHIFT
;
169 nvm
->word_size
= 1 << size
;
177 * e1000_init_mac_params_82571 - Init MAC func ptrs.
178 * @hw: pointer to the HW structure
180 * This is a function pointer entry point called by the api module.
182 static s32
e1000_init_mac_params_82571(struct e1000_adapter
*adapter
)
184 struct e1000_hw
*hw
= &adapter
->hw
;
185 struct e1000_mac_info
*mac
= &hw
->mac
;
186 struct e1000_mac_operations
*func
= &mac
->ops
;
189 switch (adapter
->pdev
->device
) {
190 case E1000_DEV_ID_82571EB_FIBER
:
191 case E1000_DEV_ID_82572EI_FIBER
:
192 case E1000_DEV_ID_82571EB_QUAD_FIBER
:
193 hw
->media_type
= e1000_media_type_fiber
;
195 case E1000_DEV_ID_82571EB_SERDES
:
196 case E1000_DEV_ID_82572EI_SERDES
:
197 case E1000_DEV_ID_82571EB_SERDES_DUAL
:
198 case E1000_DEV_ID_82571EB_SERDES_QUAD
:
199 hw
->media_type
= e1000_media_type_internal_serdes
;
202 hw
->media_type
= e1000_media_type_copper
;
206 /* Set mta register count */
207 mac
->mta_reg_count
= 128;
208 /* Set rar entry count */
209 mac
->rar_entry_count
= E1000_RAR_ENTRIES
;
210 /* Set if manageability features are enabled. */
211 mac
->arc_subsystem_valid
=
212 (er32(FWSM
) & E1000_FWSM_MODE_MASK
) ? 1 : 0;
215 switch (hw
->media_type
) {
216 case e1000_media_type_copper
:
217 func
->setup_physical_interface
= e1000_setup_copper_link_82571
;
218 func
->check_for_link
= e1000e_check_for_copper_link
;
219 func
->get_link_up_info
= e1000e_get_speed_and_duplex_copper
;
221 case e1000_media_type_fiber
:
222 func
->setup_physical_interface
= e1000_setup_fiber_serdes_link_82571
;
223 func
->check_for_link
= e1000e_check_for_fiber_link
;
224 func
->get_link_up_info
= e1000e_get_speed_and_duplex_fiber_serdes
;
226 case e1000_media_type_internal_serdes
:
227 func
->setup_physical_interface
= e1000_setup_fiber_serdes_link_82571
;
228 func
->check_for_link
= e1000e_check_for_serdes_link
;
229 func
->get_link_up_info
= e1000e_get_speed_and_duplex_fiber_serdes
;
232 return -E1000_ERR_CONFIG
;
239 static s32
e1000_get_invariants_82571(struct e1000_adapter
*adapter
)
241 struct e1000_hw
*hw
= &adapter
->hw
;
242 static int global_quad_port_a
; /* global port a indication */
243 struct pci_dev
*pdev
= adapter
->pdev
;
245 int is_port_b
= er32(STATUS
) & E1000_STATUS_FUNC_1
;
248 rc
= e1000_init_mac_params_82571(adapter
);
252 rc
= e1000_init_nvm_params_82571(hw
);
256 rc
= e1000_init_phy_params_82571(hw
);
260 /* tag quad port adapters first, it's used below */
261 switch (pdev
->device
) {
262 case E1000_DEV_ID_82571EB_QUAD_COPPER
:
263 case E1000_DEV_ID_82571EB_QUAD_FIBER
:
264 case E1000_DEV_ID_82571EB_QUAD_COPPER_LP
:
265 case E1000_DEV_ID_82571PT_QUAD_COPPER
:
266 adapter
->flags
|= FLAG_IS_QUAD_PORT
;
267 /* mark the first port */
268 if (global_quad_port_a
== 0)
269 adapter
->flags
|= FLAG_IS_QUAD_PORT_A
;
270 /* Reset for multiple quad port adapters */
271 global_quad_port_a
++;
272 if (global_quad_port_a
== 4)
273 global_quad_port_a
= 0;
279 switch (adapter
->hw
.mac
.type
) {
281 /* these dual ports don't have WoL on port B at all */
282 if (((pdev
->device
== E1000_DEV_ID_82571EB_FIBER
) ||
283 (pdev
->device
== E1000_DEV_ID_82571EB_SERDES
) ||
284 (pdev
->device
== E1000_DEV_ID_82571EB_COPPER
)) &&
286 adapter
->flags
&= ~FLAG_HAS_WOL
;
287 /* quad ports only support WoL on port A */
288 if (adapter
->flags
& FLAG_IS_QUAD_PORT
&&
289 (!(adapter
->flags
& FLAG_IS_QUAD_PORT_A
)))
290 adapter
->flags
&= ~FLAG_HAS_WOL
;
291 /* Does not support WoL on any port */
292 if (pdev
->device
== E1000_DEV_ID_82571EB_SERDES_QUAD
)
293 adapter
->flags
&= ~FLAG_HAS_WOL
;
297 if (pdev
->device
== E1000_DEV_ID_82573L
) {
298 e1000_read_nvm(&adapter
->hw
, NVM_INIT_3GIO_3
, 1,
300 if (eeprom_data
& NVM_WORD1A_ASPM_MASK
)
301 adapter
->flags
&= ~FLAG_HAS_JUMBO_FRAMES
;
312 * e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
313 * @hw: pointer to the HW structure
315 * Reads the PHY registers and stores the PHY ID and possibly the PHY
316 * revision in the hardware structure.
318 static s32
e1000_get_phy_id_82571(struct e1000_hw
*hw
)
320 struct e1000_phy_info
*phy
= &hw
->phy
;
322 switch (hw
->mac
.type
) {
325 /* The 82571 firmware may still be configuring the PHY.
326 * In this case, we cannot access the PHY until the
327 * configuration is done. So we explicitly set the
329 phy
->id
= IGP01E1000_I_PHY_ID
;
332 return e1000e_get_phy_id(hw
);
335 return -E1000_ERR_PHY
;
343 * e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
344 * @hw: pointer to the HW structure
346 * Acquire the HW semaphore to access the PHY or NVM
348 static s32
e1000_get_hw_semaphore_82571(struct e1000_hw
*hw
)
351 s32 timeout
= hw
->nvm
.word_size
+ 1;
354 /* Get the FW semaphore. */
355 for (i
= 0; i
< timeout
; i
++) {
357 ew32(SWSM
, swsm
| E1000_SWSM_SWESMBI
);
359 /* Semaphore acquired if bit latched */
360 if (er32(SWSM
) & E1000_SWSM_SWESMBI
)
367 /* Release semaphores */
368 e1000e_put_hw_semaphore(hw
);
369 hw_dbg(hw
, "Driver can't access the NVM\n");
370 return -E1000_ERR_NVM
;
377 * e1000_put_hw_semaphore_82571 - Release hardware semaphore
378 * @hw: pointer to the HW structure
380 * Release hardware semaphore used to access the PHY or NVM
382 static void e1000_put_hw_semaphore_82571(struct e1000_hw
*hw
)
388 swsm
&= ~E1000_SWSM_SWESMBI
;
394 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
395 * @hw: pointer to the HW structure
397 * To gain access to the EEPROM, first we must obtain a hardware semaphore.
398 * Then for non-82573 hardware, set the EEPROM access request bit and wait
399 * for EEPROM access grant bit. If the access grant bit is not set, release
400 * hardware semaphore.
402 static s32
e1000_acquire_nvm_82571(struct e1000_hw
*hw
)
406 ret_val
= e1000_get_hw_semaphore_82571(hw
);
410 if (hw
->mac
.type
!= e1000_82573
)
411 ret_val
= e1000e_acquire_nvm(hw
);
414 e1000_put_hw_semaphore_82571(hw
);
420 * e1000_release_nvm_82571 - Release exclusive access to EEPROM
421 * @hw: pointer to the HW structure
423 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
425 static void e1000_release_nvm_82571(struct e1000_hw
*hw
)
427 e1000e_release_nvm(hw
);
428 e1000_put_hw_semaphore_82571(hw
);
432 * e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
433 * @hw: pointer to the HW structure
434 * @offset: offset within the EEPROM to be written to
435 * @words: number of words to write
436 * @data: 16 bit word(s) to be written to the EEPROM
438 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
440 * If e1000e_update_nvm_checksum is not called after this function, the
441 <<<<<<< HEAD:drivers/net/e1000e/82571.c
442 * EEPROM will most likley contain an invalid checksum.
444 * EEPROM will most likely contain an invalid checksum.
445 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/e1000e/82571.c
447 static s32
e1000_write_nvm_82571(struct e1000_hw
*hw
, u16 offset
, u16 words
,
452 switch (hw
->mac
.type
) {
454 ret_val
= e1000_write_nvm_eewr_82571(hw
, offset
, words
, data
);
458 ret_val
= e1000e_write_nvm_spi(hw
, offset
, words
, data
);
461 ret_val
= -E1000_ERR_NVM
;
469 * e1000_update_nvm_checksum_82571 - Update EEPROM checksum
470 * @hw: pointer to the HW structure
472 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
473 * up to the checksum. Then calculates the EEPROM checksum and writes the
474 * value to the EEPROM.
476 static s32
e1000_update_nvm_checksum_82571(struct e1000_hw
*hw
)
482 ret_val
= e1000e_update_nvm_checksum_generic(hw
);
486 /* If our nvm is an EEPROM, then we're done
487 * otherwise, commit the checksum to the flash NVM. */
488 if (hw
->nvm
.type
!= e1000_nvm_flash_hw
)
491 /* Check for pending operations. */
492 for (i
= 0; i
< E1000_FLASH_UPDATES
; i
++) {
494 if ((er32(EECD
) & E1000_EECD_FLUPD
) == 0)
498 if (i
== E1000_FLASH_UPDATES
)
499 return -E1000_ERR_NVM
;
501 /* Reset the firmware if using STM opcode. */
502 if ((er32(FLOP
) & 0xFF00) == E1000_STM_OPCODE
) {
503 /* The enabling of and the actual reset must be done
504 * in two write cycles.
506 ew32(HICR
, E1000_HICR_FW_RESET_ENABLE
);
508 ew32(HICR
, E1000_HICR_FW_RESET
);
511 /* Commit the write to flash */
512 eecd
= er32(EECD
) | E1000_EECD_FLUPD
;
515 for (i
= 0; i
< E1000_FLASH_UPDATES
; i
++) {
517 if ((er32(EECD
) & E1000_EECD_FLUPD
) == 0)
521 if (i
== E1000_FLASH_UPDATES
)
522 return -E1000_ERR_NVM
;
528 * e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
529 * @hw: pointer to the HW structure
531 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
532 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
534 static s32
e1000_validate_nvm_checksum_82571(struct e1000_hw
*hw
)
536 if (hw
->nvm
.type
== e1000_nvm_flash_hw
)
537 e1000_fix_nvm_checksum_82571(hw
);
539 return e1000e_validate_nvm_checksum_generic(hw
);
543 * e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
544 * @hw: pointer to the HW structure
545 * @offset: offset within the EEPROM to be written to
546 * @words: number of words to write
547 * @data: 16 bit word(s) to be written to the EEPROM
549 * After checking for invalid values, poll the EEPROM to ensure the previous
550 * command has completed before trying to write the next word. After write
551 * poll for completion.
553 * If e1000e_update_nvm_checksum is not called after this function, the
554 <<<<<<< HEAD:drivers/net/e1000e/82571.c
555 * EEPROM will most likley contain an invalid checksum.
557 * EEPROM will most likely contain an invalid checksum.
558 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/e1000e/82571.c
560 static s32
e1000_write_nvm_eewr_82571(struct e1000_hw
*hw
, u16 offset
,
561 u16 words
, u16
*data
)
563 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
568 /* A check for invalid values: offset too large, too many words,
569 * and not enough words. */
570 if ((offset
>= nvm
->word_size
) || (words
> (nvm
->word_size
- offset
)) ||
572 hw_dbg(hw
, "nvm parameter(s) out of bounds\n");
573 return -E1000_ERR_NVM
;
576 for (i
= 0; i
< words
; i
++) {
577 eewr
= (data
[i
] << E1000_NVM_RW_REG_DATA
) |
578 ((offset
+i
) << E1000_NVM_RW_ADDR_SHIFT
) |
579 E1000_NVM_RW_REG_START
;
581 ret_val
= e1000e_poll_eerd_eewr_done(hw
, E1000_NVM_POLL_WRITE
);
587 ret_val
= e1000e_poll_eerd_eewr_done(hw
, E1000_NVM_POLL_WRITE
);
596 * e1000_get_cfg_done_82571 - Poll for configuration done
597 * @hw: pointer to the HW structure
599 * Reads the management control register for the config done bit to be set.
601 static s32
e1000_get_cfg_done_82571(struct e1000_hw
*hw
)
603 s32 timeout
= PHY_CFG_TIMEOUT
;
607 E1000_NVM_CFG_DONE_PORT_0
)
613 hw_dbg(hw
, "MNG configuration cycle has not completed.\n");
614 return -E1000_ERR_RESET
;
621 * e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
622 * @hw: pointer to the HW structure
623 * @active: TRUE to enable LPLU, FALSE to disable
625 * Sets the LPLU D0 state according to the active flag. When activating LPLU
626 * this function also disables smart speed and vice versa. LPLU will not be
627 * activated unless the device autonegotiation advertisement meets standards
628 * of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
629 * pointer entry point only called by PHY setup routines.
631 static s32
e1000_set_d0_lplu_state_82571(struct e1000_hw
*hw
, bool active
)
633 struct e1000_phy_info
*phy
= &hw
->phy
;
637 ret_val
= e1e_rphy(hw
, IGP02E1000_PHY_POWER_MGMT
, &data
);
642 data
|= IGP02E1000_PM_D0_LPLU
;
643 ret_val
= e1e_wphy(hw
, IGP02E1000_PHY_POWER_MGMT
, data
);
647 /* When LPLU is enabled, we should disable SmartSpeed */
648 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
649 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
650 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
654 data
&= ~IGP02E1000_PM_D0_LPLU
;
655 ret_val
= e1e_wphy(hw
, IGP02E1000_PHY_POWER_MGMT
, data
);
656 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
657 * during Dx states where the power conservation is most
658 * important. During driver activity we should enable
659 * SmartSpeed, so performance is maintained. */
660 if (phy
->smart_speed
== e1000_smart_speed_on
) {
661 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
666 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
667 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
671 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
672 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
677 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
678 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
689 * e1000_reset_hw_82571 - Reset hardware
690 * @hw: pointer to the HW structure
692 * This resets the hardware into a known state. This is a
693 * function pointer entry point called by the api module.
695 static s32
e1000_reset_hw_82571(struct e1000_hw
*hw
)
704 /* Prevent the PCI-E bus from sticking if there is no TLP connection
705 * on the last TLP read/write transaction when MAC is reset.
707 ret_val
= e1000e_disable_pcie_master(hw
);
709 hw_dbg(hw
, "PCI-E Master disable polling has failed.\n");
711 hw_dbg(hw
, "Masking off all interrupts\n");
712 ew32(IMC
, 0xffffffff);
715 ew32(TCTL
, E1000_TCTL_PSP
);
720 /* Must acquire the MDIO ownership before MAC reset.
721 * Ownership defaults to firmware after a reset. */
722 if (hw
->mac
.type
== e1000_82573
) {
723 extcnf_ctrl
= er32(EXTCNF_CTRL
);
724 extcnf_ctrl
|= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP
;
727 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
728 extcnf_ctrl
= er32(EXTCNF_CTRL
);
730 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP
)
733 extcnf_ctrl
|= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP
;
737 } while (i
< MDIO_OWNERSHIP_TIMEOUT
);
742 hw_dbg(hw
, "Issuing a global reset to MAC\n");
743 ew32(CTRL
, ctrl
| E1000_CTRL_RST
);
745 if (hw
->nvm
.type
== e1000_nvm_flash_hw
) {
747 ctrl_ext
= er32(CTRL_EXT
);
748 ctrl_ext
|= E1000_CTRL_EXT_EE_RST
;
749 ew32(CTRL_EXT
, ctrl_ext
);
753 ret_val
= e1000e_get_auto_rd_done(hw
);
755 /* We don't want to continue accessing MAC registers. */
758 /* Phy configuration from NVM just starts after EECD_AUTO_RD is set.
759 * Need to wait for Phy configuration completion before accessing
762 if (hw
->mac
.type
== e1000_82573
)
765 /* Clear any pending interrupt events. */
766 ew32(IMC
, 0xffffffff);
769 if (hw
->mac
.type
== e1000_82571
&&
770 hw
->dev_spec
.e82571
.alt_mac_addr_is_present
)
771 e1000e_set_laa_state_82571(hw
, true);
777 * e1000_init_hw_82571 - Initialize hardware
778 * @hw: pointer to the HW structure
780 * This inits the hardware readying it for operation.
782 static s32
e1000_init_hw_82571(struct e1000_hw
*hw
)
784 struct e1000_mac_info
*mac
= &hw
->mac
;
788 u16 rar_count
= mac
->rar_entry_count
;
790 e1000_initialize_hw_bits_82571(hw
);
792 /* Initialize identification LED */
793 ret_val
= e1000e_id_led_init(hw
);
795 hw_dbg(hw
, "Error initializing identification LED\n");
799 /* Disabling VLAN filtering */
800 hw_dbg(hw
, "Initializing the IEEE VLAN\n");
801 e1000e_clear_vfta(hw
);
803 /* Setup the receive address. */
804 /* If, however, a locally administered address was assigned to the
805 * 82571, we must reserve a RAR for it to work around an issue where
806 * resetting one port will reload the MAC on the other port.
808 if (e1000e_get_laa_state_82571(hw
))
810 e1000e_init_rx_addrs(hw
, rar_count
);
812 /* Zero out the Multicast HASH table */
813 hw_dbg(hw
, "Zeroing the MTA\n");
814 for (i
= 0; i
< mac
->mta_reg_count
; i
++)
815 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
817 /* Setup link and flow control */
818 ret_val
= e1000_setup_link_82571(hw
);
820 /* Set the transmit descriptor write-back policy */
821 reg_data
= er32(TXDCTL
);
822 reg_data
= (reg_data
& ~E1000_TXDCTL_WTHRESH
) |
823 E1000_TXDCTL_FULL_TX_DESC_WB
|
824 E1000_TXDCTL_COUNT_DESC
;
825 ew32(TXDCTL
, reg_data
);
827 /* ...for both queues. */
828 if (mac
->type
!= e1000_82573
) {
829 reg_data
= er32(TXDCTL1
);
830 reg_data
= (reg_data
& ~E1000_TXDCTL_WTHRESH
) |
831 E1000_TXDCTL_FULL_TX_DESC_WB
|
832 E1000_TXDCTL_COUNT_DESC
;
833 ew32(TXDCTL1
, reg_data
);
835 e1000e_enable_tx_pkt_filtering(hw
);
836 reg_data
= er32(GCR
);
837 reg_data
|= E1000_GCR_L1_ACT_WITHOUT_L0S_RX
;
841 /* Clear all of the statistics registers (clear on read). It is
842 * important that we do this after we have tried to establish link
843 * because the symbol error count will increment wildly if there
846 e1000_clear_hw_cntrs_82571(hw
);
852 * e1000_initialize_hw_bits_82571 - Initialize hardware-dependent bits
853 * @hw: pointer to the HW structure
855 * Initializes required hardware-dependent bits needed for normal operation.
857 static void e1000_initialize_hw_bits_82571(struct e1000_hw
*hw
)
861 /* Transmit Descriptor Control 0 */
866 /* Transmit Descriptor Control 1 */
871 /* Transmit Arbitration Control 0 */
873 reg
&= ~(0xF << 27); /* 30:27 */
874 switch (hw
->mac
.type
) {
877 reg
|= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
884 /* Transmit Arbitration Control 1 */
886 switch (hw
->mac
.type
) {
889 reg
&= ~((1 << 29) | (1 << 30));
890 reg
|= (1 << 22) | (1 << 24) | (1 << 25) | (1 << 26);
891 if (er32(TCTL
) & E1000_TCTL_MULR
)
902 if (hw
->mac
.type
== e1000_82573
) {
908 /* Extended Device Control */
909 if (hw
->mac
.type
== e1000_82573
) {
910 reg
= er32(CTRL_EXT
);
918 * e1000e_clear_vfta - Clear VLAN filter table
919 * @hw: pointer to the HW structure
921 * Clears the register array which contains the VLAN filter table by
922 * setting all the values to 0.
924 void e1000e_clear_vfta(struct e1000_hw
*hw
)
929 u32 vfta_bit_in_reg
= 0;
931 if (hw
->mac
.type
== e1000_82573
) {
932 if (hw
->mng_cookie
.vlan_id
!= 0) {
933 /* The VFTA is a 4096b bit-field, each identifying
934 * a single VLAN ID. The following operations
935 * determine which 32b entry (i.e. offset) into the
936 * array we want to set the VLAN ID (i.e. bit) of
937 * the manageability unit.
939 vfta_offset
= (hw
->mng_cookie
.vlan_id
>>
940 E1000_VFTA_ENTRY_SHIFT
) &
941 E1000_VFTA_ENTRY_MASK
;
942 vfta_bit_in_reg
= 1 << (hw
->mng_cookie
.vlan_id
&
943 E1000_VFTA_ENTRY_BIT_SHIFT_MASK
);
946 for (offset
= 0; offset
< E1000_VLAN_FILTER_TBL_SIZE
; offset
++) {
947 /* If the offset we want to clear is the same offset of the
948 * manageability VLAN ID, then clear all bits except that of
949 * the manageability unit.
951 vfta_value
= (offset
== vfta_offset
) ? vfta_bit_in_reg
: 0;
952 E1000_WRITE_REG_ARRAY(hw
, E1000_VFTA
, offset
, vfta_value
);
958 * e1000_mc_addr_list_update_82571 - Update Multicast addresses
959 * @hw: pointer to the HW structure
960 * @mc_addr_list: array of multicast addresses to program
961 * @mc_addr_count: number of multicast addresses to program
962 * @rar_used_count: the first RAR register free to program
963 * @rar_count: total number of supported Receive Address Registers
965 * Updates the Receive Address Registers and Multicast Table Array.
966 * The caller must have a packed mc_addr_list of multicast addresses.
967 * The parameter rar_count will usually be hw->mac.rar_entry_count
968 * unless there are workarounds that change this.
970 static void e1000_mc_addr_list_update_82571(struct e1000_hw
*hw
,
976 if (e1000e_get_laa_state_82571(hw
))
979 e1000e_mc_addr_list_update_generic(hw
, mc_addr_list
, mc_addr_count
,
980 rar_used_count
, rar_count
);
984 * e1000_setup_link_82571 - Setup flow control and link settings
985 * @hw: pointer to the HW structure
987 * Determines which flow control settings to use, then configures flow
988 * control. Calls the appropriate media-specific link configuration
989 * function. Assuming the adapter has a valid link partner, a valid link
990 * should be established. Assumes the hardware has previously been reset
991 * and the transmitter and receiver are not enabled.
993 static s32
e1000_setup_link_82571(struct e1000_hw
*hw
)
995 /* 82573 does not have a word in the NVM to determine
996 * the default flow control setting, so we explicitly
999 if (hw
->mac
.type
== e1000_82573
)
1000 hw
->mac
.fc
= e1000_fc_full
;
1002 return e1000e_setup_link(hw
);
1006 * e1000_setup_copper_link_82571 - Configure copper link settings
1007 * @hw: pointer to the HW structure
1009 * Configures the link for auto-neg or forced speed and duplex. Then we check
1010 * for link, once link is established calls to configure collision distance
1011 * and flow control are called.
1013 static s32
e1000_setup_copper_link_82571(struct e1000_hw
*hw
)
1020 ctrl
|= E1000_CTRL_SLU
;
1021 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1024 switch (hw
->phy
.type
) {
1026 ret_val
= e1000e_copper_link_setup_m88(hw
);
1028 case e1000_phy_igp_2
:
1029 ret_val
= e1000e_copper_link_setup_igp(hw
);
1030 /* Setup activity LED */
1031 led_ctrl
= er32(LEDCTL
);
1032 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
1033 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
1034 ew32(LEDCTL
, led_ctrl
);
1037 return -E1000_ERR_PHY
;
1044 ret_val
= e1000e_setup_copper_link(hw
);
1050 * e1000_setup_fiber_serdes_link_82571 - Setup link for fiber/serdes
1051 * @hw: pointer to the HW structure
1053 * Configures collision distance and flow control for fiber and serdes links.
1054 * Upon successful setup, poll for link.
1056 static s32
e1000_setup_fiber_serdes_link_82571(struct e1000_hw
*hw
)
1058 switch (hw
->mac
.type
) {
1061 /* If SerDes loopback mode is entered, there is no form
1062 * of reset to take the adapter out of that mode. So we
1063 * have to explicitly take the adapter out of loopback
1064 <<<<<<< HEAD:drivers/net/e1000e/82571.c
1065 * mode. This prevents drivers from twidling their thumbs
1067 * mode. This prevents drivers from twiddling their thumbs
1068 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/e1000e/82571.c
1069 * if another tool failed to take it out of loopback mode.
1072 E1000_SCTL_DISABLE_SERDES_LOOPBACK
);
1078 return e1000e_setup_fiber_serdes_link(hw
);
1082 * e1000_valid_led_default_82571 - Verify a valid default LED config
1083 * @hw: pointer to the HW structure
1084 * @data: pointer to the NVM (EEPROM)
1086 * Read the EEPROM for the current default LED configuration. If the
1087 * LED configuration is not valid, set to a valid LED configuration.
1089 static s32
e1000_valid_led_default_82571(struct e1000_hw
*hw
, u16
*data
)
1093 ret_val
= e1000_read_nvm(hw
, NVM_ID_LED_SETTINGS
, 1, data
);
1095 hw_dbg(hw
, "NVM Read Error\n");
1099 if (hw
->mac
.type
== e1000_82573
&&
1100 *data
== ID_LED_RESERVED_F746
)
1101 *data
= ID_LED_DEFAULT_82573
;
1102 else if (*data
== ID_LED_RESERVED_0000
||
1103 *data
== ID_LED_RESERVED_FFFF
)
1104 *data
= ID_LED_DEFAULT
;
1110 * e1000e_get_laa_state_82571 - Get locally administered address state
1111 * @hw: pointer to the HW structure
1113 <<<<<<< HEAD:drivers/net/e1000e/82571.c
1114 * Retrieve and return the current locally administed address state.
1116 * Retrieve and return the current locally administered address state.
1117 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/e1000e/82571.c
1119 bool e1000e_get_laa_state_82571(struct e1000_hw
*hw
)
1121 if (hw
->mac
.type
!= e1000_82571
)
1124 return hw
->dev_spec
.e82571
.laa_is_present
;
1128 * e1000e_set_laa_state_82571 - Set locally administered address state
1129 * @hw: pointer to the HW structure
1130 * @state: enable/disable locally administered address
1132 <<<<<<< HEAD:drivers/net/e1000e/82571.c
1133 * Enable/Disable the current locally administed address state.
1135 * Enable/Disable the current locally administers address state.
1136 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/net/e1000e/82571.c
1138 void e1000e_set_laa_state_82571(struct e1000_hw
*hw
, bool state
)
1140 if (hw
->mac
.type
!= e1000_82571
)
1143 hw
->dev_spec
.e82571
.laa_is_present
= state
;
1145 /* If workaround is activated... */
1147 /* Hold a copy of the LAA in RAR[14] This is done so that
1148 * between the time RAR[0] gets clobbered and the time it
1149 * gets fixed, the actual LAA is in one of the RARs and no
1150 * incoming packets directed to this port are dropped.
1151 * Eventually the LAA will be in RAR[0] and RAR[14].
1153 e1000e_rar_set(hw
, hw
->mac
.addr
, hw
->mac
.rar_entry_count
- 1);
1157 * e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
1158 * @hw: pointer to the HW structure
1160 * Verifies that the EEPROM has completed the update. After updating the
1161 * EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
1162 * the checksum fix is not implemented, we need to set the bit and update
1163 * the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
1164 * we need to return bad checksum.
1166 static s32
e1000_fix_nvm_checksum_82571(struct e1000_hw
*hw
)
1168 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
1172 if (nvm
->type
!= e1000_nvm_flash_hw
)
1175 /* Check bit 4 of word 10h. If it is 0, firmware is done updating
1176 * 10h-12h. Checksum may need to be fixed.
1178 ret_val
= e1000_read_nvm(hw
, 0x10, 1, &data
);
1182 if (!(data
& 0x10)) {
1183 /* Read 0x23 and check bit 15. This bit is a 1
1184 * when the checksum has already been fixed. If
1185 * the checksum is still wrong and this bit is a
1186 * 1, we need to return bad checksum. Otherwise,
1187 * we need to set this bit to a 1 and update the
1190 ret_val
= e1000_read_nvm(hw
, 0x23, 1, &data
);
1194 if (!(data
& 0x8000)) {
1196 ret_val
= e1000_write_nvm(hw
, 0x23, 1, &data
);
1199 ret_val
= e1000e_update_nvm_checksum(hw
);
1207 * e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
1208 * @hw: pointer to the HW structure
1210 * Clears the hardware counters by reading the counter registers.
1212 static void e1000_clear_hw_cntrs_82571(struct e1000_hw
*hw
)
1216 e1000e_clear_hw_cntrs_base(hw
);
1219 temp
= er32(PRC127
);
1220 temp
= er32(PRC255
);
1221 temp
= er32(PRC511
);
1222 temp
= er32(PRC1023
);
1223 temp
= er32(PRC1522
);
1225 temp
= er32(PTC127
);
1226 temp
= er32(PTC255
);
1227 temp
= er32(PTC511
);
1228 temp
= er32(PTC1023
);
1229 temp
= er32(PTC1522
);
1231 temp
= er32(ALGNERRC
);
1232 temp
= er32(RXERRC
);
1234 temp
= er32(CEXTERR
);
1236 temp
= er32(TSCTFC
);
1238 temp
= er32(MGTPRC
);
1239 temp
= er32(MGTPDC
);
1240 temp
= er32(MGTPTC
);
1243 temp
= er32(ICRXOC
);
1245 temp
= er32(ICRXPTC
);
1246 temp
= er32(ICRXATC
);
1247 temp
= er32(ICTXPTC
);
1248 temp
= er32(ICTXATC
);
1249 temp
= er32(ICTXQEC
);
1250 temp
= er32(ICTXQMTC
);
1251 temp
= er32(ICRXDMTC
);
1254 static struct e1000_mac_operations e82571_mac_ops
= {
1255 .mng_mode_enab
= E1000_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
,
1256 /* .check_for_link: media type dependent */
1257 .cleanup_led
= e1000e_cleanup_led_generic
,
1258 .clear_hw_cntrs
= e1000_clear_hw_cntrs_82571
,
1259 .get_bus_info
= e1000e_get_bus_info_pcie
,
1260 /* .get_link_up_info: media type dependent */
1261 .led_on
= e1000e_led_on_generic
,
1262 .led_off
= e1000e_led_off_generic
,
1263 .mc_addr_list_update
= e1000_mc_addr_list_update_82571
,
1264 .reset_hw
= e1000_reset_hw_82571
,
1265 .init_hw
= e1000_init_hw_82571
,
1266 .setup_link
= e1000_setup_link_82571
,
1267 /* .setup_physical_interface: media type dependent */
1270 static struct e1000_phy_operations e82_phy_ops_igp
= {
1271 .acquire_phy
= e1000_get_hw_semaphore_82571
,
1272 .check_reset_block
= e1000e_check_reset_block_generic
,
1274 .force_speed_duplex
= e1000e_phy_force_speed_duplex_igp
,
1275 .get_cfg_done
= e1000_get_cfg_done_82571
,
1276 .get_cable_length
= e1000e_get_cable_length_igp_2
,
1277 .get_phy_info
= e1000e_get_phy_info_igp
,
1278 .read_phy_reg
= e1000e_read_phy_reg_igp
,
1279 .release_phy
= e1000_put_hw_semaphore_82571
,
1280 .reset_phy
= e1000e_phy_hw_reset_generic
,
1281 .set_d0_lplu_state
= e1000_set_d0_lplu_state_82571
,
1282 .set_d3_lplu_state
= e1000e_set_d3_lplu_state
,
1283 .write_phy_reg
= e1000e_write_phy_reg_igp
,
1286 static struct e1000_phy_operations e82_phy_ops_m88
= {
1287 .acquire_phy
= e1000_get_hw_semaphore_82571
,
1288 .check_reset_block
= e1000e_check_reset_block_generic
,
1289 .commit_phy
= e1000e_phy_sw_reset
,
1290 .force_speed_duplex
= e1000e_phy_force_speed_duplex_m88
,
1291 .get_cfg_done
= e1000e_get_cfg_done
,
1292 .get_cable_length
= e1000e_get_cable_length_m88
,
1293 .get_phy_info
= e1000e_get_phy_info_m88
,
1294 .read_phy_reg
= e1000e_read_phy_reg_m88
,
1295 .release_phy
= e1000_put_hw_semaphore_82571
,
1296 .reset_phy
= e1000e_phy_hw_reset_generic
,
1297 .set_d0_lplu_state
= e1000_set_d0_lplu_state_82571
,
1298 .set_d3_lplu_state
= e1000e_set_d3_lplu_state
,
1299 .write_phy_reg
= e1000e_write_phy_reg_m88
,
1302 static struct e1000_nvm_operations e82571_nvm_ops
= {
1303 .acquire_nvm
= e1000_acquire_nvm_82571
,
1304 <<<<<<< HEAD
:drivers
/net
/e1000e
/82571.c
1305 .read_nvm
= e1000e_read_nvm_spi
,
1306 .release_nvm
= e1000_release_nvm_82571
,
1307 .update_nvm
= e1000_update_nvm_checksum_82571
,
1308 .valid_led_default
= e1000_valid_led_default_82571
,
1309 .validate_nvm
= e1000_validate_nvm_checksum_82571
,
1310 .write_nvm
= e1000_write_nvm_82571
,
1313 static struct e1000_nvm_operations e82573_nvm_ops
= {
1314 .acquire_nvm
= e1000_acquire_nvm_82571
,
1316 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/net
/e1000e
/82571.c
1317 .read_nvm
= e1000e_read_nvm_eerd
,
1318 .release_nvm
= e1000_release_nvm_82571
,
1319 .update_nvm
= e1000_update_nvm_checksum_82571
,
1320 .valid_led_default
= e1000_valid_led_default_82571
,
1321 .validate_nvm
= e1000_validate_nvm_checksum_82571
,
1322 .write_nvm
= e1000_write_nvm_82571
,
1325 struct e1000_info e1000_82571_info
= {
1327 .flags
= FLAG_HAS_HW_VLAN_FILTER
1328 | FLAG_HAS_JUMBO_FRAMES
1329 | FLAG_HAS_STATS_PTC_PRC
1331 | FLAG_APME_IN_CTRL3
1332 | FLAG_RX_CSUM_ENABLED
1333 | FLAG_HAS_CTRLEXT_ON_LOAD
1334 | FLAG_HAS_STATS_ICR_ICT
1335 | FLAG_HAS_SMART_POWER_DOWN
1336 | FLAG_RESET_OVERWRITES_LAA
/* errata */
1337 | FLAG_TARC_SPEED_MODE_BIT
/* errata */
1338 | FLAG_APME_CHECK_PORT_B
,
1340 .get_invariants
= e1000_get_invariants_82571
,
1341 .mac_ops
= &e82571_mac_ops
,
1342 .phy_ops
= &e82_phy_ops_igp
,
1343 .nvm_ops
= &e82571_nvm_ops
,
1346 struct e1000_info e1000_82572_info
= {
1348 .flags
= FLAG_HAS_HW_VLAN_FILTER
1349 | FLAG_HAS_JUMBO_FRAMES
1350 | FLAG_HAS_STATS_PTC_PRC
1352 | FLAG_APME_IN_CTRL3
1353 | FLAG_RX_CSUM_ENABLED
1354 | FLAG_HAS_CTRLEXT_ON_LOAD
1355 | FLAG_HAS_STATS_ICR_ICT
1356 | FLAG_TARC_SPEED_MODE_BIT
, /* errata */
1358 .get_invariants
= e1000_get_invariants_82571
,
1359 .mac_ops
= &e82571_mac_ops
,
1360 .phy_ops
= &e82_phy_ops_igp
,
1361 .nvm_ops
= &e82571_nvm_ops
,
1364 struct e1000_info e1000_82573_info
= {
1366 .flags
= FLAG_HAS_HW_VLAN_FILTER
1367 | FLAG_HAS_JUMBO_FRAMES
1368 | FLAG_HAS_STATS_PTC_PRC
1370 | FLAG_APME_IN_CTRL3
1371 | FLAG_RX_CSUM_ENABLED
1372 | FLAG_HAS_STATS_ICR_ICT
1373 | FLAG_HAS_SMART_POWER_DOWN
1376 | FLAG_HAS_SWSM_ON_LOAD
,
1378 .get_invariants
= e1000_get_invariants_82571
,
1379 .mac_ops
= &e82571_mac_ops
,
1380 .phy_ops
= &e82_phy_ops_m88
,
1381 <<<<<<< HEAD
:drivers
/net
/e1000e
/82571.c
1382 .nvm_ops
= &e82573_nvm_ops
,
1384 .nvm_ops
= &e82571_nvm_ops
,
1385 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/net
/e1000e
/82571.c