1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 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 * 80003ES2LAN Gigabit Ethernet Controller (Copper)
31 * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
34 #include <linux/netdevice.h>
35 #include <linux/ethtool.h>
36 #include <linux/delay.h>
37 #include <linux/pci.h>
41 #define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00
42 #define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL 0x02
43 #define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL 0x10
44 #define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE 0x1F
46 #define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS 0x0008
47 #define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS 0x0800
48 #define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING 0x0010
50 #define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004
51 #define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000
52 #define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000
54 #define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */
55 #define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000
57 #define DEFAULT_TIPG_IPGT_1000_80003ES2LAN 0x8
58 #define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN 0x9
60 /* GG82563 PHY Specific Status Register (Page 0, Register 16 */
61 #define GG82563_PSCR_POLARITY_REVERSAL_DISABLE 0x0002 /* 1=Reversal Disab. */
62 #define GG82563_PSCR_CROSSOVER_MODE_MASK 0x0060
63 #define GG82563_PSCR_CROSSOVER_MODE_MDI 0x0000 /* 00=Manual MDI */
64 #define GG82563_PSCR_CROSSOVER_MODE_MDIX 0x0020 /* 01=Manual MDIX */
65 #define GG82563_PSCR_CROSSOVER_MODE_AUTO 0x0060 /* 11=Auto crossover */
67 /* PHY Specific Control Register 2 (Page 0, Register 26) */
68 #define GG82563_PSCR2_REVERSE_AUTO_NEG 0x2000
69 /* 1=Reverse Auto-Negotiation */
71 /* MAC Specific Control Register (Page 2, Register 21) */
72 /* Tx clock speed for Link Down and 1000BASE-T for the following speeds */
73 #define GG82563_MSCR_TX_CLK_MASK 0x0007
74 #define GG82563_MSCR_TX_CLK_10MBPS_2_5 0x0004
75 #define GG82563_MSCR_TX_CLK_100MBPS_25 0x0005
76 #define GG82563_MSCR_TX_CLK_1000MBPS_25 0x0007
78 #define GG82563_MSCR_ASSERT_CRS_ON_TX 0x0010 /* 1=Assert */
80 /* DSP Distance Register (Page 5, Register 26) */
81 #define GG82563_DSPD_CABLE_LENGTH 0x0007 /* 0 = <50M
87 /* Kumeran Mode Control Register (Page 193, Register 16) */
88 #define GG82563_KMCR_PASS_FALSE_CARRIER 0x0800
90 /* Max number of times Kumeran read/write should be validated */
91 #define GG82563_MAX_KMRN_RETRY 0x5
93 /* Power Management Control Register (Page 193, Register 20) */
94 #define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE 0x0001
95 /* 1=Enable SERDES Electrical Idle */
97 /* In-Band Control Register (Page 194, Register 18) */
98 #define GG82563_ICR_DIS_PADDING 0x0010 /* Disable Padding */
101 * A table for the GG82563 cable length where the range is defined
102 * with a lower bound at "index" and the upper bound at
105 static const u16 e1000_gg82563_cable_length_table[] =
106 { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
108 static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
109 static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
110 static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
111 static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
112 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
113 static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
114 static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
115 static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
116 static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
118 static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
122 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
123 * @hw: pointer to the HW structure
125 * This is a function pointer entry point called by the api module.
127 static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
129 struct e1000_phy_info *phy = &hw->phy;
132 if (hw->phy.media_type != e1000_media_type_copper) {
133 phy->type = e1000_phy_none;
138 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
139 phy->reset_delay_us = 100;
140 phy->type = e1000_phy_gg82563;
142 /* This can only be done after all function pointers are setup. */
143 ret_val = e1000e_get_phy_id(hw);
146 if (phy->id != GG82563_E_PHY_ID)
147 return -E1000_ERR_PHY;
153 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
154 * @hw: pointer to the HW structure
156 * This is a function pointer entry point called by the api module.
158 static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
160 struct e1000_nvm_info *nvm = &hw->nvm;
161 u32 eecd = er32(EECD);
164 nvm->opcode_bits = 8;
166 switch (nvm->override) {
167 case e1000_nvm_override_spi_large:
169 nvm->address_bits = 16;
171 case e1000_nvm_override_spi_small:
173 nvm->address_bits = 8;
176 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
177 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
181 nvm->type = e1000_nvm_eeprom_spi;
183 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
184 E1000_EECD_SIZE_EX_SHIFT);
187 * Added to a constant, "size" becomes the left-shift value
188 * for setting word_size.
190 size += NVM_WORD_SIZE_BASE_SHIFT;
192 /* EEPROM access above 16k is unsupported */
195 nvm->word_size = 1 << size;
201 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
202 * @hw: pointer to the HW structure
204 * This is a function pointer entry point called by the api module.
206 static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
208 struct e1000_hw *hw = &adapter->hw;
209 struct e1000_mac_info *mac = &hw->mac;
210 struct e1000_mac_operations *func = &mac->ops;
213 switch (adapter->pdev->device) {
214 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
215 hw->phy.media_type = e1000_media_type_internal_serdes;
218 hw->phy.media_type = e1000_media_type_copper;
222 /* Set mta register count */
223 mac->mta_reg_count = 128;
224 /* Set rar entry count */
225 mac->rar_entry_count = E1000_RAR_ENTRIES;
226 /* Set if manageability features are enabled. */
227 mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK) ? 1 : 0;
230 switch (hw->phy.media_type) {
231 case e1000_media_type_copper:
232 func->setup_physical_interface = e1000_setup_copper_link_80003es2lan;
233 func->check_for_link = e1000e_check_for_copper_link;
235 case e1000_media_type_fiber:
236 func->setup_physical_interface = e1000e_setup_fiber_serdes_link;
237 func->check_for_link = e1000e_check_for_fiber_link;
239 case e1000_media_type_internal_serdes:
240 func->setup_physical_interface = e1000e_setup_fiber_serdes_link;
241 func->check_for_link = e1000e_check_for_serdes_link;
244 return -E1000_ERR_CONFIG;
251 static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
253 struct e1000_hw *hw = &adapter->hw;
256 rc = e1000_init_mac_params_80003es2lan(adapter);
260 rc = e1000_init_nvm_params_80003es2lan(hw);
264 rc = e1000_init_phy_params_80003es2lan(hw);
272 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
273 * @hw: pointer to the HW structure
275 * A wrapper to acquire access rights to the correct PHY. This is a
276 * function pointer entry point called by the api module.
278 static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
282 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
283 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
287 * e1000_release_phy_80003es2lan - Release rights to access PHY
288 * @hw: pointer to the HW structure
290 * A wrapper to release access rights to the correct PHY. This is a
291 * function pointer entry point called by the api module.
293 static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
297 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
298 e1000_release_swfw_sync_80003es2lan(hw, mask);
302 * e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register
303 * @hw: pointer to the HW structure
305 * Acquire the semaphore to access the Kumeran interface.
308 static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
312 mask = E1000_SWFW_CSR_SM;
314 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
318 * e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register
319 * @hw: pointer to the HW structure
321 * Release the semaphore used to access the Kumeran interface
323 static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
327 mask = E1000_SWFW_CSR_SM;
329 e1000_release_swfw_sync_80003es2lan(hw, mask);
333 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
334 * @hw: pointer to the HW structure
336 * Acquire the semaphore to access the EEPROM. This is a function
337 * pointer entry point called by the api module.
339 static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
343 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
347 ret_val = e1000e_acquire_nvm(hw);
350 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
356 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
357 * @hw: pointer to the HW structure
359 * Release the semaphore used to access the EEPROM. This is a
360 * function pointer entry point called by the api module.
362 static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
364 e1000e_release_nvm(hw);
365 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
369 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
370 * @hw: pointer to the HW structure
371 * @mask: specifies which semaphore to acquire
373 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
374 * will also specify which port we're acquiring the lock for.
376 static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
380 u32 fwmask = mask << 16;
384 while (i < timeout) {
385 if (e1000e_get_hw_semaphore(hw))
386 return -E1000_ERR_SWFW_SYNC;
388 swfw_sync = er32(SW_FW_SYNC);
389 if (!(swfw_sync & (fwmask | swmask)))
393 * Firmware currently using resource (fwmask)
394 * or other software thread using resource (swmask)
396 e1000e_put_hw_semaphore(hw);
403 "Driver can't access resource, SW_FW_SYNC timeout.\n");
404 return -E1000_ERR_SWFW_SYNC;
408 ew32(SW_FW_SYNC, swfw_sync);
410 e1000e_put_hw_semaphore(hw);
416 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
417 * @hw: pointer to the HW structure
418 * @mask: specifies which semaphore to acquire
420 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
421 * will also specify which port we're releasing the lock for.
423 static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
427 while (e1000e_get_hw_semaphore(hw) != 0);
430 swfw_sync = er32(SW_FW_SYNC);
432 ew32(SW_FW_SYNC, swfw_sync);
434 e1000e_put_hw_semaphore(hw);
438 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
439 * @hw: pointer to the HW structure
440 * @offset: offset of the register to read
441 * @data: pointer to the data returned from the operation
443 * Read the GG82563 PHY register. This is a function pointer entry
444 * point called by the api module.
446 static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
447 u32 offset, u16 *data)
453 ret_val = e1000_acquire_phy_80003es2lan(hw);
457 /* Select Configuration Page */
458 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
459 page_select = GG82563_PHY_PAGE_SELECT;
462 * Use Alternative Page Select register to access
463 * registers 30 and 31
465 page_select = GG82563_PHY_PAGE_SELECT_ALT;
468 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
469 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
471 e1000_release_phy_80003es2lan(hw);
476 * The "ready" bit in the MDIC register may be incorrectly set
477 * before the device has completed the "Page Select" MDI
478 * transaction. So we wait 200us after each MDI command...
482 /* ...and verify the command was successful. */
483 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
485 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
486 ret_val = -E1000_ERR_PHY;
487 e1000_release_phy_80003es2lan(hw);
493 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
497 e1000_release_phy_80003es2lan(hw);
503 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
504 * @hw: pointer to the HW structure
505 * @offset: offset of the register to read
506 * @data: value to write to the register
508 * Write to the GG82563 PHY register. This is a function pointer entry
509 * point called by the api module.
511 static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
512 u32 offset, u16 data)
518 ret_val = e1000_acquire_phy_80003es2lan(hw);
522 /* Select Configuration Page */
523 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
524 page_select = GG82563_PHY_PAGE_SELECT;
527 * Use Alternative Page Select register to access
528 * registers 30 and 31
530 page_select = GG82563_PHY_PAGE_SELECT_ALT;
533 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
534 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
536 e1000_release_phy_80003es2lan(hw);
542 * The "ready" bit in the MDIC register may be incorrectly set
543 * before the device has completed the "Page Select" MDI
544 * transaction. So we wait 200us after each MDI command...
548 /* ...and verify the command was successful. */
549 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
551 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
552 e1000_release_phy_80003es2lan(hw);
553 return -E1000_ERR_PHY;
558 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
562 e1000_release_phy_80003es2lan(hw);
568 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
569 * @hw: pointer to the HW structure
570 * @offset: offset of the register to read
571 * @words: number of words to write
572 * @data: buffer of data to write to the NVM
574 * Write "words" of data to the ESB2 NVM. This is a function
575 * pointer entry point called by the api module.
577 static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
578 u16 words, u16 *data)
580 return e1000e_write_nvm_spi(hw, offset, words, data);
584 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
585 * @hw: pointer to the HW structure
587 * Wait a specific amount of time for manageability processes to complete.
588 * This is a function pointer entry point called by the phy module.
590 static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
592 s32 timeout = PHY_CFG_TIMEOUT;
593 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
595 if (hw->bus.func == 1)
596 mask = E1000_NVM_CFG_DONE_PORT_1;
599 if (er32(EEMNGCTL) & mask)
605 hw_dbg(hw, "MNG configuration cycle has not completed.\n");
606 return -E1000_ERR_RESET;
613 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
614 * @hw: pointer to the HW structure
616 * Force the speed and duplex settings onto the PHY. This is a
617 * function pointer entry point called by the phy module.
619 static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
626 * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
627 * forced whenever speed and duplex are forced.
629 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
633 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
634 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
638 hw_dbg(hw, "GG82563 PSCR: %X\n", phy_data);
640 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
644 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
646 /* Reset the phy to commit changes. */
647 phy_data |= MII_CR_RESET;
649 ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
655 if (hw->phy.autoneg_wait_to_complete) {
656 hw_dbg(hw, "Waiting for forced speed/duplex link "
657 "on GG82563 phy.\n");
659 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
666 * We didn't get link.
667 * Reset the DSP and cross our fingers.
669 ret_val = e1000e_phy_reset_dsp(hw);
675 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
681 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
686 * Resetting the phy means we need to verify the TX_CLK corresponds
687 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
689 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
690 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
691 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
693 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
696 * In addition, we must re-enable CRS on Tx for both half and full
699 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
700 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
706 * e1000_get_cable_length_80003es2lan - Set approximate cable length
707 * @hw: pointer to the HW structure
709 * Find the approximate cable length as measured by the GG82563 PHY.
710 * This is a function pointer entry point called by the phy module.
712 static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
714 struct e1000_phy_info *phy = &hw->phy;
719 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
723 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
724 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
725 phy->max_cable_length = e1000_gg82563_cable_length_table[index+5];
727 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
733 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
734 * @hw: pointer to the HW structure
735 * @speed: pointer to speed buffer
736 * @duplex: pointer to duplex buffer
738 * Retrieve the current speed and duplex configuration.
739 * This is a function pointer entry point called by the api module.
741 static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
746 if (hw->phy.media_type == e1000_media_type_copper) {
747 ret_val = e1000e_get_speed_and_duplex_copper(hw,
750 hw->phy.ops.cfg_on_link_up(hw);
752 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
761 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
762 * @hw: pointer to the HW structure
764 * Perform a global reset to the ESB2 controller.
765 * This is a function pointer entry point called by the api module.
767 static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
774 * Prevent the PCI-E bus from sticking if there is no TLP connection
775 * on the last TLP read/write transaction when MAC is reset.
777 ret_val = e1000e_disable_pcie_master(hw);
779 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
781 hw_dbg(hw, "Masking off all interrupts\n");
782 ew32(IMC, 0xffffffff);
785 ew32(TCTL, E1000_TCTL_PSP);
792 ret_val = e1000_acquire_phy_80003es2lan(hw);
793 hw_dbg(hw, "Issuing a global reset to MAC\n");
794 ew32(CTRL, ctrl | E1000_CTRL_RST);
795 e1000_release_phy_80003es2lan(hw);
797 ret_val = e1000e_get_auto_rd_done(hw);
799 /* We don't want to continue accessing MAC registers. */
802 /* Clear any pending interrupt events. */
803 ew32(IMC, 0xffffffff);
810 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
811 * @hw: pointer to the HW structure
813 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
814 * This is a function pointer entry point called by the api module.
816 static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
818 struct e1000_mac_info *mac = &hw->mac;
823 e1000_initialize_hw_bits_80003es2lan(hw);
825 /* Initialize identification LED */
826 ret_val = e1000e_id_led_init(hw);
828 hw_dbg(hw, "Error initializing identification LED\n");
832 /* Disabling VLAN filtering */
833 hw_dbg(hw, "Initializing the IEEE VLAN\n");
834 e1000e_clear_vfta(hw);
836 /* Setup the receive address. */
837 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
839 /* Zero out the Multicast HASH table */
840 hw_dbg(hw, "Zeroing the MTA\n");
841 for (i = 0; i < mac->mta_reg_count; i++)
842 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
844 /* Setup link and flow control */
845 ret_val = e1000e_setup_link(hw);
847 /* Set the transmit descriptor write-back policy */
848 reg_data = er32(TXDCTL(0));
849 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
850 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
851 ew32(TXDCTL(0), reg_data);
853 /* ...for both queues. */
854 reg_data = er32(TXDCTL(1));
855 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
856 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
857 ew32(TXDCTL(1), reg_data);
859 /* Enable retransmit on late collisions */
860 reg_data = er32(TCTL);
861 reg_data |= E1000_TCTL_RTLC;
862 ew32(TCTL, reg_data);
864 /* Configure Gigabit Carry Extend Padding */
865 reg_data = er32(TCTL_EXT);
866 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
867 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
868 ew32(TCTL_EXT, reg_data);
870 /* Configure Transmit Inter-Packet Gap */
871 reg_data = er32(TIPG);
872 reg_data &= ~E1000_TIPG_IPGT_MASK;
873 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
874 ew32(TIPG, reg_data);
876 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
877 reg_data &= ~0x00100000;
878 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
881 * Clear all of the statistics registers (clear on read). It is
882 * important that we do this after we have tried to establish link
883 * because the symbol error count will increment wildly if there
886 e1000_clear_hw_cntrs_80003es2lan(hw);
892 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
893 * @hw: pointer to the HW structure
895 * Initializes required hardware-dependent bits needed for normal operation.
897 static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
901 /* Transmit Descriptor Control 0 */
902 reg = er32(TXDCTL(0));
904 ew32(TXDCTL(0), reg);
906 /* Transmit Descriptor Control 1 */
907 reg = er32(TXDCTL(1));
909 ew32(TXDCTL(1), reg);
911 /* Transmit Arbitration Control 0 */
913 reg &= ~(0xF << 27); /* 30:27 */
914 if (hw->phy.media_type != e1000_media_type_copper)
918 /* Transmit Arbitration Control 1 */
920 if (er32(TCTL) & E1000_TCTL_MULR)
928 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
929 * @hw: pointer to the HW structure
931 * Setup some GG82563 PHY registers for obtaining link
933 static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
935 struct e1000_phy_info *phy = &hw->phy;
940 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
944 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
945 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
946 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
948 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
954 * MDI/MDI-X = 0 (default)
955 * 0 - Auto for all speeds
958 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
960 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
964 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
968 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
971 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
975 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
981 * disable_polarity_correction = 0 (default)
982 * Automatic Correction for Reversed Cable Polarity
986 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
987 if (phy->disable_polarity_correction)
988 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
990 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
994 /* SW Reset the PHY so all changes take effect */
995 ret_val = e1000e_commit_phy(hw);
997 hw_dbg(hw, "Error Resetting the PHY\n");
1001 /* Bypass Rx and Tx FIFO's */
1002 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1003 E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL,
1004 E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
1005 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
1009 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
1010 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
1014 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
1015 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1016 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
1021 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
1025 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
1026 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
1030 ctrl_ext = er32(CTRL_EXT);
1031 ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
1032 ew32(CTRL_EXT, ctrl_ext);
1034 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
1039 * Do not init these registers when the HW is in IAMT mode, since the
1040 * firmware will have already initialized them. We only initialize
1041 * them if the HW is not in IAMT mode.
1043 if (!e1000e_check_mng_mode(hw)) {
1044 /* Enable Electrical Idle on the PHY */
1045 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
1046 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
1050 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
1054 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1055 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1061 * Workaround: Disable padding in Kumeran interface in the MAC
1062 * and in the PHY to avoid CRC errors.
1064 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1068 data |= GG82563_ICR_DIS_PADDING;
1069 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1077 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1078 * @hw: pointer to the HW structure
1080 * Essentially a wrapper for setting up all things "copper" related.
1081 * This is a function pointer entry point called by the mac module.
1083 static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1090 ctrl |= E1000_CTRL_SLU;
1091 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1095 * Set the mac to wait the maximum time between each
1096 * iteration and increase the max iterations when
1097 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1099 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
1103 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1108 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1112 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
1113 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1117 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
1118 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1119 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1124 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1128 ret_val = e1000e_setup_copper_link(hw);
1134 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1135 * @hw: pointer to the HW structure
1136 * @duplex: current duplex setting
1138 * Configure the KMRN interface by applying last minute quirks for
1141 static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1147 if (hw->phy.media_type == e1000_media_type_copper) {
1148 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
1153 if (speed == SPEED_1000)
1154 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1156 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1163 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1164 * @hw: pointer to the HW structure
1165 * @duplex: current duplex setting
1167 * Configure the KMRN interface by applying last minute quirks for
1170 static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1175 u16 reg_data, reg_data2;
1177 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
1178 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1179 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1184 /* Configure Transmit Inter-Packet Gap */
1186 tipg &= ~E1000_TIPG_IPGT_MASK;
1187 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1191 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
1195 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data2);
1199 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
1201 if (duplex == HALF_DUPLEX)
1202 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1204 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1206 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1212 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1213 * @hw: pointer to the HW structure
1215 * Configure the KMRN interface by applying last minute quirks for
1216 * gigabit operation.
1218 static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1221 u16 reg_data, reg_data2;
1225 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
1226 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1227 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1232 /* Configure Transmit Inter-Packet Gap */
1234 tipg &= ~E1000_TIPG_IPGT_MASK;
1235 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1239 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
1243 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data2);
1247 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
1249 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1250 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1256 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1257 * @hw: pointer to the HW structure
1258 * @offset: register offset to be read
1259 * @data: pointer to the read data
1261 * Acquire semaphore, then read the PHY register at offset
1262 * using the kumeran interface. The information retrieved is stored in data.
1263 * Release the semaphore before exiting.
1265 s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 *data)
1270 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1274 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1275 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
1276 ew32(KMRNCTRLSTA, kmrnctrlsta);
1280 kmrnctrlsta = er32(KMRNCTRLSTA);
1281 *data = (u16)kmrnctrlsta;
1283 e1000_release_mac_csr_80003es2lan(hw);
1289 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1290 * @hw: pointer to the HW structure
1291 * @offset: register offset to write to
1292 * @data: data to write at register offset
1294 * Acquire semaphore, then write the data to PHY register
1295 * at the offset using the kumeran interface. Release semaphore
1298 s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 data)
1303 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1307 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1308 E1000_KMRNCTRLSTA_OFFSET) | data;
1309 ew32(KMRNCTRLSTA, kmrnctrlsta);
1313 e1000_release_mac_csr_80003es2lan(hw);
1319 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1320 * @hw: pointer to the HW structure
1322 * Clears the hardware counters by reading the counter registers.
1324 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1328 e1000e_clear_hw_cntrs_base(hw);
1331 temp = er32(PRC127);
1332 temp = er32(PRC255);
1333 temp = er32(PRC511);
1334 temp = er32(PRC1023);
1335 temp = er32(PRC1522);
1337 temp = er32(PTC127);
1338 temp = er32(PTC255);
1339 temp = er32(PTC511);
1340 temp = er32(PTC1023);
1341 temp = er32(PTC1522);
1343 temp = er32(ALGNERRC);
1344 temp = er32(RXERRC);
1346 temp = er32(CEXTERR);
1348 temp = er32(TSCTFC);
1350 temp = er32(MGTPRC);
1351 temp = er32(MGTPDC);
1352 temp = er32(MGTPTC);
1355 temp = er32(ICRXOC);
1357 temp = er32(ICRXPTC);
1358 temp = er32(ICRXATC);
1359 temp = er32(ICTXPTC);
1360 temp = er32(ICTXATC);
1361 temp = er32(ICTXQEC);
1362 temp = er32(ICTXQMTC);
1363 temp = er32(ICRXDMTC);
1366 static struct e1000_mac_operations es2_mac_ops = {
1367 .check_mng_mode = e1000e_check_mng_mode_generic,
1368 /* check_for_link dependent on media type */
1369 .cleanup_led = e1000e_cleanup_led_generic,
1370 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1371 .get_bus_info = e1000e_get_bus_info_pcie,
1372 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1373 .led_on = e1000e_led_on_generic,
1374 .led_off = e1000e_led_off_generic,
1375 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
1376 .reset_hw = e1000_reset_hw_80003es2lan,
1377 .init_hw = e1000_init_hw_80003es2lan,
1378 .setup_link = e1000e_setup_link,
1379 /* setup_physical_interface dependent on media type */
1382 static struct e1000_phy_operations es2_phy_ops = {
1383 .acquire_phy = e1000_acquire_phy_80003es2lan,
1384 .check_reset_block = e1000e_check_reset_block_generic,
1385 .commit_phy = e1000e_phy_sw_reset,
1386 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1387 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1388 .get_cable_length = e1000_get_cable_length_80003es2lan,
1389 .get_phy_info = e1000e_get_phy_info_m88,
1390 .read_phy_reg = e1000_read_phy_reg_gg82563_80003es2lan,
1391 .release_phy = e1000_release_phy_80003es2lan,
1392 .reset_phy = e1000e_phy_hw_reset_generic,
1393 .set_d0_lplu_state = NULL,
1394 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1395 .write_phy_reg = e1000_write_phy_reg_gg82563_80003es2lan,
1396 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
1399 static struct e1000_nvm_operations es2_nvm_ops = {
1400 .acquire_nvm = e1000_acquire_nvm_80003es2lan,
1401 .read_nvm = e1000e_read_nvm_eerd,
1402 .release_nvm = e1000_release_nvm_80003es2lan,
1403 .update_nvm = e1000e_update_nvm_checksum_generic,
1404 .valid_led_default = e1000e_valid_led_default,
1405 .validate_nvm = e1000e_validate_nvm_checksum_generic,
1406 .write_nvm = e1000_write_nvm_80003es2lan,
1409 struct e1000_info e1000_es2_info = {
1410 .mac = e1000_80003es2lan,
1411 .flags = FLAG_HAS_HW_VLAN_FILTER
1412 | FLAG_HAS_JUMBO_FRAMES
1414 | FLAG_APME_IN_CTRL3
1415 | FLAG_RX_CSUM_ENABLED
1416 | FLAG_HAS_CTRLEXT_ON_LOAD
1417 | FLAG_RX_NEEDS_RESTART /* errata */
1418 | FLAG_TARC_SET_BIT_ZERO /* errata */
1419 | FLAG_APME_CHECK_PORT_B
1420 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
1421 | FLAG_TIPG_MEDIUM_FOR_80003ESLAN,
1423 .get_variants = e1000_get_variants_80003es2lan,
1424 .mac_ops = &es2_mac_ops,
1425 .phy_ops = &es2_phy_ops,
1426 .nvm_ops = &es2_nvm_ops,