1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2013 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 *******************************************************************************/
29 /* 80003ES2LAN Gigabit Ethernet Controller (Copper)
30 * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
35 /* A table for the GG82563 cable length where the range is defined
36 * with a lower bound at "index" and the upper bound at
39 static const u16 e1000_gg82563_cable_length_table[] = {
40 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
42 #define GG82563_CABLE_LENGTH_TABLE_SIZE \
43 ARRAY_SIZE(e1000_gg82563_cable_length_table)
45 static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
46 static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
47 static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
48 static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
49 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
50 static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
51 static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
52 static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
54 static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
56 static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
59 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
60 * @hw: pointer to the HW structure
62 static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
64 struct e1000_phy_info *phy = &hw->phy;
67 if (hw->phy.media_type != e1000_media_type_copper) {
68 phy->type = e1000_phy_none;
71 phy->ops.power_up = e1000_power_up_phy_copper;
72 phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
76 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
77 phy->reset_delay_us = 100;
78 phy->type = e1000_phy_gg82563;
80 /* This can only be done after all function pointers are setup. */
81 ret_val = e1000e_get_phy_id(hw);
84 if (phy->id != GG82563_E_PHY_ID)
85 return -E1000_ERR_PHY;
91 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
92 * @hw: pointer to the HW structure
94 static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
96 struct e1000_nvm_info *nvm = &hw->nvm;
97 u32 eecd = er32(EECD);
100 nvm->opcode_bits = 8;
102 switch (nvm->override) {
103 case e1000_nvm_override_spi_large:
105 nvm->address_bits = 16;
107 case e1000_nvm_override_spi_small:
109 nvm->address_bits = 8;
112 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
113 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
117 nvm->type = e1000_nvm_eeprom_spi;
119 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
120 E1000_EECD_SIZE_EX_SHIFT);
122 /* Added to a constant, "size" becomes the left-shift value
123 * for setting word_size.
125 size += NVM_WORD_SIZE_BASE_SHIFT;
127 /* EEPROM access above 16k is unsupported */
130 nvm->word_size = 1 << size;
136 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
137 * @hw: pointer to the HW structure
139 static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
141 struct e1000_mac_info *mac = &hw->mac;
143 /* Set media type and media-dependent function pointers */
144 switch (hw->adapter->pdev->device) {
145 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
146 hw->phy.media_type = e1000_media_type_internal_serdes;
147 mac->ops.check_for_link = e1000e_check_for_serdes_link;
148 mac->ops.setup_physical_interface =
149 e1000e_setup_fiber_serdes_link;
152 hw->phy.media_type = e1000_media_type_copper;
153 mac->ops.check_for_link = e1000e_check_for_copper_link;
154 mac->ops.setup_physical_interface =
155 e1000_setup_copper_link_80003es2lan;
159 /* Set mta register count */
160 mac->mta_reg_count = 128;
161 /* Set rar entry count */
162 mac->rar_entry_count = E1000_RAR_ENTRIES;
164 mac->has_fwsm = true;
165 /* ARC supported; valid only if manageability features are enabled. */
166 mac->arc_subsystem_valid = !!(er32(FWSM) & E1000_FWSM_MODE_MASK);
167 /* Adaptive IFS not supported */
168 mac->adaptive_ifs = false;
170 /* set lan id for port to determine which phy lock to use */
171 hw->mac.ops.set_lan_id(hw);
176 static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
178 struct e1000_hw *hw = &adapter->hw;
181 rc = e1000_init_mac_params_80003es2lan(hw);
185 rc = e1000_init_nvm_params_80003es2lan(hw);
189 rc = e1000_init_phy_params_80003es2lan(hw);
197 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
198 * @hw: pointer to the HW structure
200 * A wrapper to acquire access rights to the correct PHY.
202 static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
206 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
207 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
211 * e1000_release_phy_80003es2lan - Release rights to access PHY
212 * @hw: pointer to the HW structure
214 * A wrapper to release access rights to the correct PHY.
216 static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
220 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
221 e1000_release_swfw_sync_80003es2lan(hw, mask);
225 * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
226 * @hw: pointer to the HW structure
228 * Acquire the semaphore to access the Kumeran interface.
231 static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
235 mask = E1000_SWFW_CSR_SM;
237 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
241 * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
242 * @hw: pointer to the HW structure
244 * Release the semaphore used to access the Kumeran interface
246 static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
250 mask = E1000_SWFW_CSR_SM;
252 e1000_release_swfw_sync_80003es2lan(hw, mask);
256 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
257 * @hw: pointer to the HW structure
259 * Acquire the semaphore to access the EEPROM.
261 static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
265 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
269 ret_val = e1000e_acquire_nvm(hw);
272 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
278 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
279 * @hw: pointer to the HW structure
281 * Release the semaphore used to access the EEPROM.
283 static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
285 e1000e_release_nvm(hw);
286 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
290 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
291 * @hw: pointer to the HW structure
292 * @mask: specifies which semaphore to acquire
294 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
295 * will also specify which port we're acquiring the lock for.
297 static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
301 u32 fwmask = mask << 16;
305 while (i < timeout) {
306 if (e1000e_get_hw_semaphore(hw))
307 return -E1000_ERR_SWFW_SYNC;
309 swfw_sync = er32(SW_FW_SYNC);
310 if (!(swfw_sync & (fwmask | swmask)))
313 /* Firmware currently using resource (fwmask)
314 * or other software thread using resource (swmask)
316 e1000e_put_hw_semaphore(hw);
322 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
323 return -E1000_ERR_SWFW_SYNC;
327 ew32(SW_FW_SYNC, swfw_sync);
329 e1000e_put_hw_semaphore(hw);
335 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
336 * @hw: pointer to the HW structure
337 * @mask: specifies which semaphore to acquire
339 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
340 * will also specify which port we're releasing the lock for.
342 static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
346 while (e1000e_get_hw_semaphore(hw) != 0)
349 swfw_sync = er32(SW_FW_SYNC);
351 ew32(SW_FW_SYNC, swfw_sync);
353 e1000e_put_hw_semaphore(hw);
357 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
358 * @hw: pointer to the HW structure
359 * @offset: offset of the register to read
360 * @data: pointer to the data returned from the operation
362 * Read the GG82563 PHY register.
364 static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
365 u32 offset, u16 *data)
371 ret_val = e1000_acquire_phy_80003es2lan(hw);
375 /* Select Configuration Page */
376 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
377 page_select = GG82563_PHY_PAGE_SELECT;
379 /* Use Alternative Page Select register to access
380 * registers 30 and 31
382 page_select = GG82563_PHY_PAGE_SELECT_ALT;
385 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
386 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
388 e1000_release_phy_80003es2lan(hw);
392 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
393 /* The "ready" bit in the MDIC register may be incorrectly set
394 * before the device has completed the "Page Select" MDI
395 * transaction. So we wait 200us after each MDI command...
399 /* ...and verify the command was successful. */
400 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
402 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
403 e1000_release_phy_80003es2lan(hw);
404 return -E1000_ERR_PHY;
409 ret_val = e1000e_read_phy_reg_mdic(hw,
410 MAX_PHY_REG_ADDRESS & offset,
415 ret_val = e1000e_read_phy_reg_mdic(hw,
416 MAX_PHY_REG_ADDRESS & offset,
420 e1000_release_phy_80003es2lan(hw);
426 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
427 * @hw: pointer to the HW structure
428 * @offset: offset of the register to read
429 * @data: value to write to the register
431 * Write to the GG82563 PHY register.
433 static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
434 u32 offset, u16 data)
440 ret_val = e1000_acquire_phy_80003es2lan(hw);
444 /* Select Configuration Page */
445 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
446 page_select = GG82563_PHY_PAGE_SELECT;
448 /* Use Alternative Page Select register to access
449 * registers 30 and 31
451 page_select = GG82563_PHY_PAGE_SELECT_ALT;
454 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
455 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
457 e1000_release_phy_80003es2lan(hw);
461 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
462 /* The "ready" bit in the MDIC register may be incorrectly set
463 * before the device has completed the "Page Select" MDI
464 * transaction. So we wait 200us after each MDI command...
468 /* ...and verify the command was successful. */
469 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
471 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
472 e1000_release_phy_80003es2lan(hw);
473 return -E1000_ERR_PHY;
478 ret_val = e1000e_write_phy_reg_mdic(hw,
479 MAX_PHY_REG_ADDRESS &
484 ret_val = e1000e_write_phy_reg_mdic(hw,
485 MAX_PHY_REG_ADDRESS &
489 e1000_release_phy_80003es2lan(hw);
495 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
496 * @hw: pointer to the HW structure
497 * @offset: offset of the register to read
498 * @words: number of words to write
499 * @data: buffer of data to write to the NVM
501 * Write "words" of data to the ESB2 NVM.
503 static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
504 u16 words, u16 *data)
506 return e1000e_write_nvm_spi(hw, offset, words, data);
510 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
511 * @hw: pointer to the HW structure
513 * Wait a specific amount of time for manageability processes to complete.
514 * This is a function pointer entry point called by the phy module.
516 static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
518 s32 timeout = PHY_CFG_TIMEOUT;
519 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
521 if (hw->bus.func == 1)
522 mask = E1000_NVM_CFG_DONE_PORT_1;
525 if (er32(EEMNGCTL) & mask)
527 usleep_range(1000, 2000);
531 e_dbg("MNG configuration cycle has not completed.\n");
532 return -E1000_ERR_RESET;
539 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
540 * @hw: pointer to the HW structure
542 * Force the speed and duplex settings onto the PHY. This is a
543 * function pointer entry point called by the phy module.
545 static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
551 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
552 * forced whenever speed and duplex are forced.
554 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
558 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
559 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
563 e_dbg("GG82563 PSCR: %X\n", phy_data);
565 ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);
569 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
571 /* Reset the phy to commit changes. */
572 phy_data |= BMCR_RESET;
574 ret_val = e1e_wphy(hw, MII_BMCR, phy_data);
580 if (hw->phy.autoneg_wait_to_complete) {
581 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
583 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
589 /* We didn't get link.
590 * Reset the DSP and cross our fingers.
592 ret_val = e1000e_phy_reset_dsp(hw);
598 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
604 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
608 /* Resetting the phy means we need to verify the TX_CLK corresponds
609 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
611 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
612 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
613 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
615 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
617 /* In addition, we must re-enable CRS on Tx for both half and full
620 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
621 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
627 * e1000_get_cable_length_80003es2lan - Set approximate cable length
628 * @hw: pointer to the HW structure
630 * Find the approximate cable length as measured by the GG82563 PHY.
631 * This is a function pointer entry point called by the phy module.
633 static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
635 struct e1000_phy_info *phy = &hw->phy;
639 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
643 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
645 if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
646 return -E1000_ERR_PHY;
648 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
649 phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
651 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
657 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
658 * @hw: pointer to the HW structure
659 * @speed: pointer to speed buffer
660 * @duplex: pointer to duplex buffer
662 * Retrieve the current speed and duplex configuration.
664 static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
669 if (hw->phy.media_type == e1000_media_type_copper) {
670 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
671 hw->phy.ops.cfg_on_link_up(hw);
673 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
682 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
683 * @hw: pointer to the HW structure
685 * Perform a global reset to the ESB2 controller.
687 static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
693 /* Prevent the PCI-E bus from sticking if there is no TLP connection
694 * on the last TLP read/write transaction when MAC is reset.
696 ret_val = e1000e_disable_pcie_master(hw);
698 e_dbg("PCI-E Master disable polling has failed.\n");
700 e_dbg("Masking off all interrupts\n");
701 ew32(IMC, 0xffffffff);
704 ew32(TCTL, E1000_TCTL_PSP);
707 usleep_range(10000, 20000);
711 ret_val = e1000_acquire_phy_80003es2lan(hw);
715 e_dbg("Issuing a global reset to MAC\n");
716 ew32(CTRL, ctrl | E1000_CTRL_RST);
717 e1000_release_phy_80003es2lan(hw);
719 /* Disable IBIST slave mode (far-end loopback) */
720 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
722 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
723 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
726 ret_val = e1000e_get_auto_rd_done(hw);
728 /* We don't want to continue accessing MAC registers. */
731 /* Clear any pending interrupt events. */
732 ew32(IMC, 0xffffffff);
735 return e1000_check_alt_mac_addr_generic(hw);
739 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
740 * @hw: pointer to the HW structure
742 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
744 static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
746 struct e1000_mac_info *mac = &hw->mac;
752 e1000_initialize_hw_bits_80003es2lan(hw);
754 /* Initialize identification LED */
755 ret_val = mac->ops.id_led_init(hw);
756 /* An error is not fatal and we should not stop init due to this */
758 e_dbg("Error initializing identification LED\n");
760 /* Disabling VLAN filtering */
761 e_dbg("Initializing the IEEE VLAN\n");
762 mac->ops.clear_vfta(hw);
764 /* Setup the receive address. */
765 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
767 /* Zero out the Multicast HASH table */
768 e_dbg("Zeroing the MTA\n");
769 for (i = 0; i < mac->mta_reg_count; i++)
770 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
772 /* Setup link and flow control */
773 ret_val = mac->ops.setup_link(hw);
777 /* Disable IBIST slave mode (far-end loopback) */
778 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
780 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
781 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
784 /* Set the transmit descriptor write-back policy */
785 reg_data = er32(TXDCTL(0));
786 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
787 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
788 ew32(TXDCTL(0), reg_data);
790 /* ...for both queues. */
791 reg_data = er32(TXDCTL(1));
792 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
793 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
794 ew32(TXDCTL(1), reg_data);
796 /* Enable retransmit on late collisions */
797 reg_data = er32(TCTL);
798 reg_data |= E1000_TCTL_RTLC;
799 ew32(TCTL, reg_data);
801 /* Configure Gigabit Carry Extend Padding */
802 reg_data = er32(TCTL_EXT);
803 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
804 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
805 ew32(TCTL_EXT, reg_data);
807 /* Configure Transmit Inter-Packet Gap */
808 reg_data = er32(TIPG);
809 reg_data &= ~E1000_TIPG_IPGT_MASK;
810 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
811 ew32(TIPG, reg_data);
813 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
814 reg_data &= ~0x00100000;
815 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
817 /* default to true to enable the MDIC W/A */
818 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
821 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET >>
822 E1000_KMRNCTRLSTA_OFFSET_SHIFT, &i);
824 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
825 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
826 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
829 /* Clear all of the statistics registers (clear on read). It is
830 * important that we do this after we have tried to establish link
831 * because the symbol error count will increment wildly if there
834 e1000_clear_hw_cntrs_80003es2lan(hw);
840 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
841 * @hw: pointer to the HW structure
843 * Initializes required hardware-dependent bits needed for normal operation.
845 static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
849 /* Transmit Descriptor Control 0 */
850 reg = er32(TXDCTL(0));
852 ew32(TXDCTL(0), reg);
854 /* Transmit Descriptor Control 1 */
855 reg = er32(TXDCTL(1));
857 ew32(TXDCTL(1), reg);
859 /* Transmit Arbitration Control 0 */
861 reg &= ~(0xF << 27); /* 30:27 */
862 if (hw->phy.media_type != e1000_media_type_copper)
866 /* Transmit Arbitration Control 1 */
868 if (er32(TCTL) & E1000_TCTL_MULR)
874 /* Disable IPv6 extension header parsing because some malformed
875 * IPv6 headers can hang the Rx.
878 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
883 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
884 * @hw: pointer to the HW structure
886 * Setup some GG82563 PHY registers for obtaining link
888 static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
890 struct e1000_phy_info *phy = &hw->phy;
895 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
899 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
900 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
901 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
903 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
908 * MDI/MDI-X = 0 (default)
909 * 0 - Auto for all speeds
912 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
914 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
918 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
922 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
925 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
929 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
934 * disable_polarity_correction = 0 (default)
935 * Automatic Correction for Reversed Cable Polarity
939 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
940 if (phy->disable_polarity_correction)
941 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
943 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
947 /* SW Reset the PHY so all changes take effect */
948 ret_val = hw->phy.ops.commit(hw);
950 e_dbg("Error Resetting the PHY\n");
954 /* Bypass Rx and Tx FIFO's */
955 reg = E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL;
956 data = (E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
957 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
958 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
962 reg = E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE;
963 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, reg, &data);
966 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
967 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
971 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
975 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
976 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
980 reg = er32(CTRL_EXT);
981 reg &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
984 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
988 /* Do not init these registers when the HW is in IAMT mode, since the
989 * firmware will have already initialized them. We only initialize
990 * them if the HW is not in IAMT mode.
992 if (!hw->mac.ops.check_mng_mode(hw)) {
993 /* Enable Electrical Idle on the PHY */
994 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
995 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
999 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
1003 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1004 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1009 /* Workaround: Disable padding in Kumeran interface in the MAC
1010 * and in the PHY to avoid CRC errors.
1012 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1016 data |= GG82563_ICR_DIS_PADDING;
1017 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1025 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1026 * @hw: pointer to the HW structure
1028 * Essentially a wrapper for setting up all things "copper" related.
1029 * This is a function pointer entry point called by the mac module.
1031 static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1038 ctrl |= E1000_CTRL_SLU;
1039 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1042 /* Set the mac to wait the maximum time between each
1043 * iteration and increase the max iterations when
1044 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1046 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
1050 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1055 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1060 e1000_read_kmrn_reg_80003es2lan(hw,
1061 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1065 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
1067 e1000_write_kmrn_reg_80003es2lan(hw,
1068 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1073 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1077 return e1000e_setup_copper_link(hw);
1081 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1082 * @hw: pointer to the HW structure
1083 * @duplex: current duplex setting
1085 * Configure the KMRN interface by applying last minute quirks for
1088 static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1094 if (hw->phy.media_type == e1000_media_type_copper) {
1095 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
1100 if (speed == SPEED_1000)
1101 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1103 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1110 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1111 * @hw: pointer to the HW structure
1112 * @duplex: current duplex setting
1114 * Configure the KMRN interface by applying last minute quirks for
1117 static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1122 u16 reg_data, reg_data2;
1124 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
1126 e1000_write_kmrn_reg_80003es2lan(hw,
1127 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1132 /* Configure Transmit Inter-Packet Gap */
1134 tipg &= ~E1000_TIPG_IPGT_MASK;
1135 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1139 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
1143 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data2);
1147 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
1149 if (duplex == HALF_DUPLEX)
1150 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1152 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1154 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1158 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1159 * @hw: pointer to the HW structure
1161 * Configure the KMRN interface by applying last minute quirks for
1162 * gigabit operation.
1164 static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1167 u16 reg_data, reg_data2;
1171 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
1173 e1000_write_kmrn_reg_80003es2lan(hw,
1174 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1179 /* Configure Transmit Inter-Packet Gap */
1181 tipg &= ~E1000_TIPG_IPGT_MASK;
1182 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1186 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
1190 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data2);
1194 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
1196 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1198 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1202 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1203 * @hw: pointer to the HW structure
1204 * @offset: register offset to be read
1205 * @data: pointer to the read data
1207 * Acquire semaphore, then read the PHY register at offset
1208 * using the kumeran interface. The information retrieved is stored in data.
1209 * Release the semaphore before exiting.
1211 static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1217 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1221 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1222 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
1223 ew32(KMRNCTRLSTA, kmrnctrlsta);
1228 kmrnctrlsta = er32(KMRNCTRLSTA);
1229 *data = (u16)kmrnctrlsta;
1231 e1000_release_mac_csr_80003es2lan(hw);
1237 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1238 * @hw: pointer to the HW structure
1239 * @offset: register offset to write to
1240 * @data: data to write at register offset
1242 * Acquire semaphore, then write the data to PHY register
1243 * at the offset using the kumeran interface. Release semaphore
1246 static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1252 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1256 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1257 E1000_KMRNCTRLSTA_OFFSET) | data;
1258 ew32(KMRNCTRLSTA, kmrnctrlsta);
1263 e1000_release_mac_csr_80003es2lan(hw);
1269 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1270 * @hw: pointer to the HW structure
1272 static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1276 /* If there's an alternate MAC address place it in RAR0
1277 * so that it will override the Si installed default perm
1280 ret_val = e1000_check_alt_mac_addr_generic(hw);
1284 return e1000_read_mac_addr_generic(hw);
1288 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1289 * @hw: pointer to the HW structure
1291 * In the case of a PHY power down to save power, or to turn off link during a
1292 * driver unload, or wake on lan is not enabled, remove the link.
1294 static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
1296 /* If the management interface is not enabled, then power down */
1297 if (!(hw->mac.ops.check_mng_mode(hw) ||
1298 hw->phy.ops.check_reset_block(hw)))
1299 e1000_power_down_phy_copper(hw);
1303 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1304 * @hw: pointer to the HW structure
1306 * Clears the hardware counters by reading the counter registers.
1308 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1310 e1000e_clear_hw_cntrs_base(hw);
1348 static const struct e1000_mac_operations es2_mac_ops = {
1349 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
1350 .id_led_init = e1000e_id_led_init_generic,
1351 .blink_led = e1000e_blink_led_generic,
1352 .check_mng_mode = e1000e_check_mng_mode_generic,
1353 /* check_for_link dependent on media type */
1354 .cleanup_led = e1000e_cleanup_led_generic,
1355 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1356 .get_bus_info = e1000e_get_bus_info_pcie,
1357 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
1358 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1359 .led_on = e1000e_led_on_generic,
1360 .led_off = e1000e_led_off_generic,
1361 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
1362 .write_vfta = e1000_write_vfta_generic,
1363 .clear_vfta = e1000_clear_vfta_generic,
1364 .reset_hw = e1000_reset_hw_80003es2lan,
1365 .init_hw = e1000_init_hw_80003es2lan,
1366 .setup_link = e1000e_setup_link_generic,
1367 /* setup_physical_interface dependent on media type */
1368 .setup_led = e1000e_setup_led_generic,
1369 .config_collision_dist = e1000e_config_collision_dist_generic,
1370 .rar_set = e1000e_rar_set_generic,
1373 static const struct e1000_phy_operations es2_phy_ops = {
1374 .acquire = e1000_acquire_phy_80003es2lan,
1375 .check_polarity = e1000_check_polarity_m88,
1376 .check_reset_block = e1000e_check_reset_block_generic,
1377 .commit = e1000e_phy_sw_reset,
1378 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1379 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1380 .get_cable_length = e1000_get_cable_length_80003es2lan,
1381 .get_info = e1000e_get_phy_info_m88,
1382 .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
1383 .release = e1000_release_phy_80003es2lan,
1384 .reset = e1000e_phy_hw_reset_generic,
1385 .set_d0_lplu_state = NULL,
1386 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1387 .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
1388 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
1391 static const struct e1000_nvm_operations es2_nvm_ops = {
1392 .acquire = e1000_acquire_nvm_80003es2lan,
1393 .read = e1000e_read_nvm_eerd,
1394 .release = e1000_release_nvm_80003es2lan,
1395 .reload = e1000e_reload_nvm_generic,
1396 .update = e1000e_update_nvm_checksum_generic,
1397 .valid_led_default = e1000e_valid_led_default,
1398 .validate = e1000e_validate_nvm_checksum_generic,
1399 .write = e1000_write_nvm_80003es2lan,
1402 const struct e1000_info e1000_es2_info = {
1403 .mac = e1000_80003es2lan,
1404 .flags = FLAG_HAS_HW_VLAN_FILTER
1405 | FLAG_HAS_JUMBO_FRAMES
1407 | FLAG_APME_IN_CTRL3
1408 | FLAG_HAS_CTRLEXT_ON_LOAD
1409 | FLAG_RX_NEEDS_RESTART /* errata */
1410 | FLAG_TARC_SET_BIT_ZERO /* errata */
1411 | FLAG_APME_CHECK_PORT_B
1412 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
1413 .flags2 = FLAG2_DMA_BURST,
1415 .max_hw_frame_size = DEFAULT_JUMBO,
1416 .get_variants = e1000_get_variants_80003es2lan,
1417 .mac_ops = &es2_mac_ops,
1418 .phy_ops = &es2_phy_ops,
1419 .nvm_ops = &es2_nvm_ops,