1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2009 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
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)
36 #define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00
37 #define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL 0x02
38 #define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL 0x10
39 #define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE 0x1F
41 #define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS 0x0008
42 #define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS 0x0800
43 #define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING 0x0010
45 #define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004
46 #define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000
47 #define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000
49 #define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */
50 #define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000
52 #define DEFAULT_TIPG_IPGT_1000_80003ES2LAN 0x8
53 #define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN 0x9
55 /* GG82563 PHY Specific Status Register (Page 0, Register 16 */
56 #define GG82563_PSCR_POLARITY_REVERSAL_DISABLE 0x0002 /* 1=Reversal Disab. */
57 #define GG82563_PSCR_CROSSOVER_MODE_MASK 0x0060
58 #define GG82563_PSCR_CROSSOVER_MODE_MDI 0x0000 /* 00=Manual MDI */
59 #define GG82563_PSCR_CROSSOVER_MODE_MDIX 0x0020 /* 01=Manual MDIX */
60 #define GG82563_PSCR_CROSSOVER_MODE_AUTO 0x0060 /* 11=Auto crossover */
62 /* PHY Specific Control Register 2 (Page 0, Register 26) */
63 #define GG82563_PSCR2_REVERSE_AUTO_NEG 0x2000
64 /* 1=Reverse Auto-Negotiation */
66 /* MAC Specific Control Register (Page 2, Register 21) */
67 /* Tx clock speed for Link Down and 1000BASE-T for the following speeds */
68 #define GG82563_MSCR_TX_CLK_MASK 0x0007
69 #define GG82563_MSCR_TX_CLK_10MBPS_2_5 0x0004
70 #define GG82563_MSCR_TX_CLK_100MBPS_25 0x0005
71 #define GG82563_MSCR_TX_CLK_1000MBPS_25 0x0007
73 #define GG82563_MSCR_ASSERT_CRS_ON_TX 0x0010 /* 1=Assert */
75 /* DSP Distance Register (Page 5, Register 26) */
76 #define GG82563_DSPD_CABLE_LENGTH 0x0007 /* 0 = <50M
82 /* Kumeran Mode Control Register (Page 193, Register 16) */
83 #define GG82563_KMCR_PASS_FALSE_CARRIER 0x0800
85 /* Max number of times Kumeran read/write should be validated */
86 #define GG82563_MAX_KMRN_RETRY 0x5
88 /* Power Management Control Register (Page 193, Register 20) */
89 #define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE 0x0001
90 /* 1=Enable SERDES Electrical Idle */
92 /* In-Band Control Register (Page 194, Register 18) */
93 #define GG82563_ICR_DIS_PADDING 0x0010 /* Disable Padding */
96 * A table for the GG82563 cable length where the range is defined
97 * with a lower bound at "index" and the upper bound at
100 static const u16 e1000_gg82563_cable_length_table
[] =
101 { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
103 static s32
e1000_setup_copper_link_80003es2lan(struct e1000_hw
*hw
);
104 static s32
e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw
*hw
, u16 mask
);
105 static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw
*hw
, u16 mask
);
106 static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw
*hw
);
107 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw
*hw
);
108 static s32
e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw
*hw
);
109 static s32
e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw
*hw
, u16 duplex
);
110 static s32
e1000_cfg_on_link_up_80003es2lan(struct e1000_hw
*hw
);
111 static s32
e1000_read_kmrn_reg_80003es2lan(struct e1000_hw
*hw
, u32 offset
,
113 static s32
e1000_write_kmrn_reg_80003es2lan(struct e1000_hw
*hw
, u32 offset
,
117 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
118 * @hw: pointer to the HW structure
120 static s32
e1000_init_phy_params_80003es2lan(struct e1000_hw
*hw
)
122 struct e1000_phy_info
*phy
= &hw
->phy
;
125 if (hw
->phy
.media_type
!= e1000_media_type_copper
) {
126 phy
->type
= e1000_phy_none
;
131 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
132 phy
->reset_delay_us
= 100;
133 phy
->type
= e1000_phy_gg82563
;
135 /* This can only be done after all function pointers are setup. */
136 ret_val
= e1000e_get_phy_id(hw
);
139 if (phy
->id
!= GG82563_E_PHY_ID
)
140 return -E1000_ERR_PHY
;
146 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
147 * @hw: pointer to the HW structure
149 static s32
e1000_init_nvm_params_80003es2lan(struct e1000_hw
*hw
)
151 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
152 u32 eecd
= er32(EECD
);
155 nvm
->opcode_bits
= 8;
157 switch (nvm
->override
) {
158 case e1000_nvm_override_spi_large
:
160 nvm
->address_bits
= 16;
162 case e1000_nvm_override_spi_small
:
164 nvm
->address_bits
= 8;
167 nvm
->page_size
= eecd
& E1000_EECD_ADDR_BITS
? 32 : 8;
168 nvm
->address_bits
= eecd
& E1000_EECD_ADDR_BITS
? 16 : 8;
172 nvm
->type
= e1000_nvm_eeprom_spi
;
174 size
= (u16
)((eecd
& E1000_EECD_SIZE_EX_MASK
) >>
175 E1000_EECD_SIZE_EX_SHIFT
);
178 * Added to a constant, "size" becomes the left-shift value
179 * for setting word_size.
181 size
+= NVM_WORD_SIZE_BASE_SHIFT
;
183 /* EEPROM access above 16k is unsupported */
186 nvm
->word_size
= 1 << size
;
192 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
193 * @hw: pointer to the HW structure
195 static s32
e1000_init_mac_params_80003es2lan(struct e1000_adapter
*adapter
)
197 struct e1000_hw
*hw
= &adapter
->hw
;
198 struct e1000_mac_info
*mac
= &hw
->mac
;
199 struct e1000_mac_operations
*func
= &mac
->ops
;
202 switch (adapter
->pdev
->device
) {
203 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT
:
204 hw
->phy
.media_type
= e1000_media_type_internal_serdes
;
207 hw
->phy
.media_type
= e1000_media_type_copper
;
211 /* Set mta register count */
212 mac
->mta_reg_count
= 128;
213 /* Set rar entry count */
214 mac
->rar_entry_count
= E1000_RAR_ENTRIES
;
215 /* Set if manageability features are enabled. */
216 mac
->arc_subsystem_valid
= (er32(FWSM
) & E1000_FWSM_MODE_MASK
)
220 switch (hw
->phy
.media_type
) {
221 case e1000_media_type_copper
:
222 func
->setup_physical_interface
= e1000_setup_copper_link_80003es2lan
;
223 func
->check_for_link
= e1000e_check_for_copper_link
;
225 case e1000_media_type_fiber
:
226 func
->setup_physical_interface
= e1000e_setup_fiber_serdes_link
;
227 func
->check_for_link
= e1000e_check_for_fiber_link
;
229 case e1000_media_type_internal_serdes
:
230 func
->setup_physical_interface
= e1000e_setup_fiber_serdes_link
;
231 func
->check_for_link
= e1000e_check_for_serdes_link
;
234 return -E1000_ERR_CONFIG
;
241 static s32
e1000_get_variants_80003es2lan(struct e1000_adapter
*adapter
)
243 struct e1000_hw
*hw
= &adapter
->hw
;
246 rc
= e1000_init_mac_params_80003es2lan(adapter
);
250 rc
= e1000_init_nvm_params_80003es2lan(hw
);
254 rc
= e1000_init_phy_params_80003es2lan(hw
);
262 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
263 * @hw: pointer to the HW structure
265 * A wrapper to acquire access rights to the correct PHY.
267 static s32
e1000_acquire_phy_80003es2lan(struct e1000_hw
*hw
)
271 mask
= hw
->bus
.func
? E1000_SWFW_PHY1_SM
: E1000_SWFW_PHY0_SM
;
272 return e1000_acquire_swfw_sync_80003es2lan(hw
, mask
);
276 * e1000_release_phy_80003es2lan - Release rights to access PHY
277 * @hw: pointer to the HW structure
279 * A wrapper to release access rights to the correct PHY.
281 static void e1000_release_phy_80003es2lan(struct e1000_hw
*hw
)
285 mask
= hw
->bus
.func
? E1000_SWFW_PHY1_SM
: E1000_SWFW_PHY0_SM
;
286 e1000_release_swfw_sync_80003es2lan(hw
, mask
);
290 * e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register
291 * @hw: pointer to the HW structure
293 * Acquire the semaphore to access the Kumeran interface.
296 static s32
e1000_acquire_mac_csr_80003es2lan(struct e1000_hw
*hw
)
300 mask
= E1000_SWFW_CSR_SM
;
302 return e1000_acquire_swfw_sync_80003es2lan(hw
, mask
);
306 * e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register
307 * @hw: pointer to the HW structure
309 * Release the semaphore used to access the Kumeran interface
311 static void e1000_release_mac_csr_80003es2lan(struct e1000_hw
*hw
)
315 mask
= E1000_SWFW_CSR_SM
;
317 e1000_release_swfw_sync_80003es2lan(hw
, mask
);
321 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
322 * @hw: pointer to the HW structure
324 * Acquire the semaphore to access the EEPROM.
326 static s32
e1000_acquire_nvm_80003es2lan(struct e1000_hw
*hw
)
330 ret_val
= e1000_acquire_swfw_sync_80003es2lan(hw
, E1000_SWFW_EEP_SM
);
334 ret_val
= e1000e_acquire_nvm(hw
);
337 e1000_release_swfw_sync_80003es2lan(hw
, E1000_SWFW_EEP_SM
);
343 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
344 * @hw: pointer to the HW structure
346 * Release the semaphore used to access the EEPROM.
348 static void e1000_release_nvm_80003es2lan(struct e1000_hw
*hw
)
350 e1000e_release_nvm(hw
);
351 e1000_release_swfw_sync_80003es2lan(hw
, E1000_SWFW_EEP_SM
);
355 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
356 * @hw: pointer to the HW structure
357 * @mask: specifies which semaphore to acquire
359 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
360 * will also specify which port we're acquiring the lock for.
362 static s32
e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw
*hw
, u16 mask
)
366 u32 fwmask
= mask
<< 16;
370 while (i
< timeout
) {
371 if (e1000e_get_hw_semaphore(hw
))
372 return -E1000_ERR_SWFW_SYNC
;
374 swfw_sync
= er32(SW_FW_SYNC
);
375 if (!(swfw_sync
& (fwmask
| swmask
)))
379 * Firmware currently using resource (fwmask)
380 * or other software thread using resource (swmask)
382 e1000e_put_hw_semaphore(hw
);
388 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
389 return -E1000_ERR_SWFW_SYNC
;
393 ew32(SW_FW_SYNC
, swfw_sync
);
395 e1000e_put_hw_semaphore(hw
);
401 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
402 * @hw: pointer to the HW structure
403 * @mask: specifies which semaphore to acquire
405 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
406 * will also specify which port we're releasing the lock for.
408 static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw
*hw
, u16 mask
)
412 while (e1000e_get_hw_semaphore(hw
) != 0);
415 swfw_sync
= er32(SW_FW_SYNC
);
417 ew32(SW_FW_SYNC
, swfw_sync
);
419 e1000e_put_hw_semaphore(hw
);
423 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
424 * @hw: pointer to the HW structure
425 * @offset: offset of the register to read
426 * @data: pointer to the data returned from the operation
428 * Read the GG82563 PHY register.
430 static s32
e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw
*hw
,
431 u32 offset
, u16
*data
)
437 ret_val
= e1000_acquire_phy_80003es2lan(hw
);
441 /* Select Configuration Page */
442 if ((offset
& MAX_PHY_REG_ADDRESS
) < GG82563_MIN_ALT_REG
) {
443 page_select
= GG82563_PHY_PAGE_SELECT
;
446 * Use Alternative Page Select register to access
447 * registers 30 and 31
449 page_select
= GG82563_PHY_PAGE_SELECT_ALT
;
452 temp
= (u16
)((u16
)offset
>> GG82563_PAGE_SHIFT
);
453 ret_val
= e1000e_write_phy_reg_mdic(hw
, page_select
, temp
);
455 e1000_release_phy_80003es2lan(hw
);
460 * The "ready" bit in the MDIC register may be incorrectly set
461 * before the device has completed the "Page Select" MDI
462 * transaction. So we wait 200us after each MDI command...
466 /* ...and verify the command was successful. */
467 ret_val
= e1000e_read_phy_reg_mdic(hw
, page_select
, &temp
);
469 if (((u16
)offset
>> GG82563_PAGE_SHIFT
) != temp
) {
470 ret_val
= -E1000_ERR_PHY
;
471 e1000_release_phy_80003es2lan(hw
);
477 ret_val
= e1000e_read_phy_reg_mdic(hw
, MAX_PHY_REG_ADDRESS
& offset
,
481 e1000_release_phy_80003es2lan(hw
);
487 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
488 * @hw: pointer to the HW structure
489 * @offset: offset of the register to read
490 * @data: value to write to the register
492 * Write to the GG82563 PHY register.
494 static s32
e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw
*hw
,
495 u32 offset
, u16 data
)
501 ret_val
= e1000_acquire_phy_80003es2lan(hw
);
505 /* Select Configuration Page */
506 if ((offset
& MAX_PHY_REG_ADDRESS
) < GG82563_MIN_ALT_REG
) {
507 page_select
= GG82563_PHY_PAGE_SELECT
;
510 * Use Alternative Page Select register to access
511 * registers 30 and 31
513 page_select
= GG82563_PHY_PAGE_SELECT_ALT
;
516 temp
= (u16
)((u16
)offset
>> GG82563_PAGE_SHIFT
);
517 ret_val
= e1000e_write_phy_reg_mdic(hw
, page_select
, temp
);
519 e1000_release_phy_80003es2lan(hw
);
525 * The "ready" bit in the MDIC register may be incorrectly set
526 * before the device has completed the "Page Select" MDI
527 * transaction. So we wait 200us after each MDI command...
531 /* ...and verify the command was successful. */
532 ret_val
= e1000e_read_phy_reg_mdic(hw
, page_select
, &temp
);
534 if (((u16
)offset
>> GG82563_PAGE_SHIFT
) != temp
) {
535 e1000_release_phy_80003es2lan(hw
);
536 return -E1000_ERR_PHY
;
541 ret_val
= e1000e_write_phy_reg_mdic(hw
, MAX_PHY_REG_ADDRESS
& offset
,
545 e1000_release_phy_80003es2lan(hw
);
551 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
552 * @hw: pointer to the HW structure
553 * @offset: offset of the register to read
554 * @words: number of words to write
555 * @data: buffer of data to write to the NVM
557 * Write "words" of data to the ESB2 NVM.
559 static s32
e1000_write_nvm_80003es2lan(struct e1000_hw
*hw
, u16 offset
,
560 u16 words
, u16
*data
)
562 return e1000e_write_nvm_spi(hw
, offset
, words
, data
);
566 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
567 * @hw: pointer to the HW structure
569 * Wait a specific amount of time for manageability processes to complete.
570 * This is a function pointer entry point called by the phy module.
572 static s32
e1000_get_cfg_done_80003es2lan(struct e1000_hw
*hw
)
574 s32 timeout
= PHY_CFG_TIMEOUT
;
575 u32 mask
= E1000_NVM_CFG_DONE_PORT_0
;
577 if (hw
->bus
.func
== 1)
578 mask
= E1000_NVM_CFG_DONE_PORT_1
;
581 if (er32(EEMNGCTL
) & mask
)
587 e_dbg("MNG configuration cycle has not completed.\n");
588 return -E1000_ERR_RESET
;
595 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
596 * @hw: pointer to the HW structure
598 * Force the speed and duplex settings onto the PHY. This is a
599 * function pointer entry point called by the phy module.
601 static s32
e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw
*hw
)
608 * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
609 * forced whenever speed and duplex are forced.
611 ret_val
= e1e_rphy(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
615 phy_data
&= ~GG82563_PSCR_CROSSOVER_MODE_AUTO
;
616 ret_val
= e1e_wphy(hw
, GG82563_PHY_SPEC_CTRL
, phy_data
);
620 e_dbg("GG82563 PSCR: %X\n", phy_data
);
622 ret_val
= e1e_rphy(hw
, PHY_CONTROL
, &phy_data
);
626 e1000e_phy_force_speed_duplex_setup(hw
, &phy_data
);
628 /* Reset the phy to commit changes. */
629 phy_data
|= MII_CR_RESET
;
631 ret_val
= e1e_wphy(hw
, PHY_CONTROL
, phy_data
);
637 if (hw
->phy
.autoneg_wait_to_complete
) {
638 e_dbg("Waiting for forced speed/duplex link "
639 "on GG82563 phy.\n");
641 ret_val
= e1000e_phy_has_link_generic(hw
, PHY_FORCE_LIMIT
,
648 * We didn't get link.
649 * Reset the DSP and cross our fingers.
651 ret_val
= e1000e_phy_reset_dsp(hw
);
657 ret_val
= e1000e_phy_has_link_generic(hw
, PHY_FORCE_LIMIT
,
663 ret_val
= e1e_rphy(hw
, GG82563_PHY_MAC_SPEC_CTRL
, &phy_data
);
668 * Resetting the phy means we need to verify the TX_CLK corresponds
669 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
671 phy_data
&= ~GG82563_MSCR_TX_CLK_MASK
;
672 if (hw
->mac
.forced_speed_duplex
& E1000_ALL_10_SPEED
)
673 phy_data
|= GG82563_MSCR_TX_CLK_10MBPS_2_5
;
675 phy_data
|= GG82563_MSCR_TX_CLK_100MBPS_25
;
678 * In addition, we must re-enable CRS on Tx for both half and full
681 phy_data
|= GG82563_MSCR_ASSERT_CRS_ON_TX
;
682 ret_val
= e1e_wphy(hw
, GG82563_PHY_MAC_SPEC_CTRL
, phy_data
);
688 * e1000_get_cable_length_80003es2lan - Set approximate cable length
689 * @hw: pointer to the HW structure
691 * Find the approximate cable length as measured by the GG82563 PHY.
692 * This is a function pointer entry point called by the phy module.
694 static s32
e1000_get_cable_length_80003es2lan(struct e1000_hw
*hw
)
696 struct e1000_phy_info
*phy
= &hw
->phy
;
701 ret_val
= e1e_rphy(hw
, GG82563_PHY_DSP_DISTANCE
, &phy_data
);
705 index
= phy_data
& GG82563_DSPD_CABLE_LENGTH
;
706 phy
->min_cable_length
= e1000_gg82563_cable_length_table
[index
];
707 phy
->max_cable_length
= e1000_gg82563_cable_length_table
[index
+5];
709 phy
->cable_length
= (phy
->min_cable_length
+ phy
->max_cable_length
) / 2;
715 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
716 * @hw: pointer to the HW structure
717 * @speed: pointer to speed buffer
718 * @duplex: pointer to duplex buffer
720 * Retrieve the current speed and duplex configuration.
722 static s32
e1000_get_link_up_info_80003es2lan(struct e1000_hw
*hw
, u16
*speed
,
727 if (hw
->phy
.media_type
== e1000_media_type_copper
) {
728 ret_val
= e1000e_get_speed_and_duplex_copper(hw
,
731 hw
->phy
.ops
.cfg_on_link_up(hw
);
733 ret_val
= e1000e_get_speed_and_duplex_fiber_serdes(hw
,
742 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
743 * @hw: pointer to the HW structure
745 * Perform a global reset to the ESB2 controller.
747 static s32
e1000_reset_hw_80003es2lan(struct e1000_hw
*hw
)
754 * Prevent the PCI-E bus from sticking if there is no TLP connection
755 * on the last TLP read/write transaction when MAC is reset.
757 ret_val
= e1000e_disable_pcie_master(hw
);
759 e_dbg("PCI-E Master disable polling has failed.\n");
761 e_dbg("Masking off all interrupts\n");
762 ew32(IMC
, 0xffffffff);
765 ew32(TCTL
, E1000_TCTL_PSP
);
772 ret_val
= e1000_acquire_phy_80003es2lan(hw
);
773 e_dbg("Issuing a global reset to MAC\n");
774 ew32(CTRL
, ctrl
| E1000_CTRL_RST
);
775 e1000_release_phy_80003es2lan(hw
);
777 ret_val
= e1000e_get_auto_rd_done(hw
);
779 /* We don't want to continue accessing MAC registers. */
782 /* Clear any pending interrupt events. */
783 ew32(IMC
, 0xffffffff);
790 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
791 * @hw: pointer to the HW structure
793 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
795 static s32
e1000_init_hw_80003es2lan(struct e1000_hw
*hw
)
797 struct e1000_mac_info
*mac
= &hw
->mac
;
802 e1000_initialize_hw_bits_80003es2lan(hw
);
804 /* Initialize identification LED */
805 ret_val
= e1000e_id_led_init(hw
);
807 e_dbg("Error initializing identification LED\n");
811 /* Disabling VLAN filtering */
812 e_dbg("Initializing the IEEE VLAN\n");
813 e1000e_clear_vfta(hw
);
815 /* Setup the receive address. */
816 e1000e_init_rx_addrs(hw
, mac
->rar_entry_count
);
818 /* Zero out the Multicast HASH table */
819 e_dbg("Zeroing the MTA\n");
820 for (i
= 0; i
< mac
->mta_reg_count
; i
++)
821 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
823 /* Setup link and flow control */
824 ret_val
= e1000e_setup_link(hw
);
826 /* Set the transmit descriptor write-back policy */
827 reg_data
= er32(TXDCTL(0));
828 reg_data
= (reg_data
& ~E1000_TXDCTL_WTHRESH
) |
829 E1000_TXDCTL_FULL_TX_DESC_WB
| E1000_TXDCTL_COUNT_DESC
;
830 ew32(TXDCTL(0), reg_data
);
832 /* ...for both queues. */
833 reg_data
= er32(TXDCTL(1));
834 reg_data
= (reg_data
& ~E1000_TXDCTL_WTHRESH
) |
835 E1000_TXDCTL_FULL_TX_DESC_WB
| E1000_TXDCTL_COUNT_DESC
;
836 ew32(TXDCTL(1), reg_data
);
838 /* Enable retransmit on late collisions */
839 reg_data
= er32(TCTL
);
840 reg_data
|= E1000_TCTL_RTLC
;
841 ew32(TCTL
, reg_data
);
843 /* Configure Gigabit Carry Extend Padding */
844 reg_data
= er32(TCTL_EXT
);
845 reg_data
&= ~E1000_TCTL_EXT_GCEX_MASK
;
846 reg_data
|= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN
;
847 ew32(TCTL_EXT
, reg_data
);
849 /* Configure Transmit Inter-Packet Gap */
850 reg_data
= er32(TIPG
);
851 reg_data
&= ~E1000_TIPG_IPGT_MASK
;
852 reg_data
|= DEFAULT_TIPG_IPGT_1000_80003ES2LAN
;
853 ew32(TIPG
, reg_data
);
855 reg_data
= E1000_READ_REG_ARRAY(hw
, E1000_FFLT
, 0x0001);
856 reg_data
&= ~0x00100000;
857 E1000_WRITE_REG_ARRAY(hw
, E1000_FFLT
, 0x0001, reg_data
);
860 * Clear all of the statistics registers (clear on read). It is
861 * important that we do this after we have tried to establish link
862 * because the symbol error count will increment wildly if there
865 e1000_clear_hw_cntrs_80003es2lan(hw
);
871 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
872 * @hw: pointer to the HW structure
874 * Initializes required hardware-dependent bits needed for normal operation.
876 static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw
*hw
)
880 /* Transmit Descriptor Control 0 */
881 reg
= er32(TXDCTL(0));
883 ew32(TXDCTL(0), reg
);
885 /* Transmit Descriptor Control 1 */
886 reg
= er32(TXDCTL(1));
888 ew32(TXDCTL(1), reg
);
890 /* Transmit Arbitration Control 0 */
892 reg
&= ~(0xF << 27); /* 30:27 */
893 if (hw
->phy
.media_type
!= e1000_media_type_copper
)
897 /* Transmit Arbitration Control 1 */
899 if (er32(TCTL
) & E1000_TCTL_MULR
)
907 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
908 * @hw: pointer to the HW structure
910 * Setup some GG82563 PHY registers for obtaining link
912 static s32
e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw
*hw
)
914 struct e1000_phy_info
*phy
= &hw
->phy
;
919 ret_val
= e1e_rphy(hw
, GG82563_PHY_MAC_SPEC_CTRL
, &data
);
923 data
|= GG82563_MSCR_ASSERT_CRS_ON_TX
;
924 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
925 data
|= GG82563_MSCR_TX_CLK_1000MBPS_25
;
927 ret_val
= e1e_wphy(hw
, GG82563_PHY_MAC_SPEC_CTRL
, data
);
933 * MDI/MDI-X = 0 (default)
934 * 0 - Auto for all speeds
937 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
939 ret_val
= e1e_rphy(hw
, GG82563_PHY_SPEC_CTRL
, &data
);
943 data
&= ~GG82563_PSCR_CROSSOVER_MODE_MASK
;
947 data
|= GG82563_PSCR_CROSSOVER_MODE_MDI
;
950 data
|= GG82563_PSCR_CROSSOVER_MODE_MDIX
;
954 data
|= GG82563_PSCR_CROSSOVER_MODE_AUTO
;
960 * disable_polarity_correction = 0 (default)
961 * Automatic Correction for Reversed Cable Polarity
965 data
&= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE
;
966 if (phy
->disable_polarity_correction
)
967 data
|= GG82563_PSCR_POLARITY_REVERSAL_DISABLE
;
969 ret_val
= e1e_wphy(hw
, GG82563_PHY_SPEC_CTRL
, data
);
973 /* SW Reset the PHY so all changes take effect */
974 ret_val
= e1000e_commit_phy(hw
);
976 e_dbg("Error Resetting the PHY\n");
980 /* Bypass Rx and Tx FIFO's */
981 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
,
982 E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL
,
983 E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS
|
984 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS
);
988 ret_val
= e1000_read_kmrn_reg_80003es2lan(hw
,
989 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE
,
993 data
|= E1000_KMRNCTRLSTA_OPMODE_E_IDLE
;
994 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
,
995 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE
,
1000 ret_val
= e1e_rphy(hw
, GG82563_PHY_SPEC_CTRL_2
, &data
);
1004 data
&= ~GG82563_PSCR2_REVERSE_AUTO_NEG
;
1005 ret_val
= e1e_wphy(hw
, GG82563_PHY_SPEC_CTRL_2
, data
);
1009 ctrl_ext
= er32(CTRL_EXT
);
1010 ctrl_ext
&= ~(E1000_CTRL_EXT_LINK_MODE_MASK
);
1011 ew32(CTRL_EXT
, ctrl_ext
);
1013 ret_val
= e1e_rphy(hw
, GG82563_PHY_PWR_MGMT_CTRL
, &data
);
1018 * Do not init these registers when the HW is in IAMT mode, since the
1019 * firmware will have already initialized them. We only initialize
1020 * them if the HW is not in IAMT mode.
1022 if (!e1000e_check_mng_mode(hw
)) {
1023 /* Enable Electrical Idle on the PHY */
1024 data
|= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE
;
1025 ret_val
= e1e_wphy(hw
, GG82563_PHY_PWR_MGMT_CTRL
, data
);
1029 ret_val
= e1e_rphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, &data
);
1033 data
&= ~GG82563_KMCR_PASS_FALSE_CARRIER
;
1034 ret_val
= e1e_wphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, data
);
1040 * Workaround: Disable padding in Kumeran interface in the MAC
1041 * and in the PHY to avoid CRC errors.
1043 ret_val
= e1e_rphy(hw
, GG82563_PHY_INBAND_CTRL
, &data
);
1047 data
|= GG82563_ICR_DIS_PADDING
;
1048 ret_val
= e1e_wphy(hw
, GG82563_PHY_INBAND_CTRL
, data
);
1056 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1057 * @hw: pointer to the HW structure
1059 * Essentially a wrapper for setting up all things "copper" related.
1060 * This is a function pointer entry point called by the mac module.
1062 static s32
e1000_setup_copper_link_80003es2lan(struct e1000_hw
*hw
)
1069 ctrl
|= E1000_CTRL_SLU
;
1070 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1074 * Set the mac to wait the maximum time between each
1075 * iteration and increase the max iterations when
1076 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1078 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
, GG82563_REG(0x34, 4),
1082 ret_val
= e1000_read_kmrn_reg_80003es2lan(hw
, GG82563_REG(0x34, 9),
1087 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
, GG82563_REG(0x34, 9),
1091 ret_val
= e1000_read_kmrn_reg_80003es2lan(hw
,
1092 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL
,
1096 reg_data
|= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING
;
1097 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
,
1098 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL
,
1103 ret_val
= e1000_copper_link_setup_gg82563_80003es2lan(hw
);
1107 ret_val
= e1000e_setup_copper_link(hw
);
1113 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1114 * @hw: pointer to the HW structure
1115 * @duplex: current duplex setting
1117 * Configure the KMRN interface by applying last minute quirks for
1120 static s32
e1000_cfg_on_link_up_80003es2lan(struct e1000_hw
*hw
)
1126 if (hw
->phy
.media_type
== e1000_media_type_copper
) {
1127 ret_val
= e1000e_get_speed_and_duplex_copper(hw
, &speed
,
1132 if (speed
== SPEED_1000
)
1133 ret_val
= e1000_cfg_kmrn_1000_80003es2lan(hw
);
1135 ret_val
= e1000_cfg_kmrn_10_100_80003es2lan(hw
, duplex
);
1142 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1143 * @hw: pointer to the HW structure
1144 * @duplex: current duplex setting
1146 * Configure the KMRN interface by applying last minute quirks for
1149 static s32
e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw
*hw
, u16 duplex
)
1154 u16 reg_data
, reg_data2
;
1156 reg_data
= E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT
;
1157 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
,
1158 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL
,
1163 /* Configure Transmit Inter-Packet Gap */
1165 tipg
&= ~E1000_TIPG_IPGT_MASK
;
1166 tipg
|= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN
;
1170 ret_val
= e1e_rphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, ®_data
);
1174 ret_val
= e1e_rphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, ®_data2
);
1178 } while ((reg_data
!= reg_data2
) && (i
< GG82563_MAX_KMRN_RETRY
));
1180 if (duplex
== HALF_DUPLEX
)
1181 reg_data
|= GG82563_KMCR_PASS_FALSE_CARRIER
;
1183 reg_data
&= ~GG82563_KMCR_PASS_FALSE_CARRIER
;
1185 ret_val
= e1e_wphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, reg_data
);
1191 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1192 * @hw: pointer to the HW structure
1194 * Configure the KMRN interface by applying last minute quirks for
1195 * gigabit operation.
1197 static s32
e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw
*hw
)
1200 u16 reg_data
, reg_data2
;
1204 reg_data
= E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT
;
1205 ret_val
= e1000_write_kmrn_reg_80003es2lan(hw
,
1206 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL
,
1211 /* Configure Transmit Inter-Packet Gap */
1213 tipg
&= ~E1000_TIPG_IPGT_MASK
;
1214 tipg
|= DEFAULT_TIPG_IPGT_1000_80003ES2LAN
;
1218 ret_val
= e1e_rphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, ®_data
);
1222 ret_val
= e1e_rphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, ®_data2
);
1226 } while ((reg_data
!= reg_data2
) && (i
< GG82563_MAX_KMRN_RETRY
));
1228 reg_data
&= ~GG82563_KMCR_PASS_FALSE_CARRIER
;
1229 ret_val
= e1e_wphy(hw
, GG82563_PHY_KMRN_MODE_CTRL
, reg_data
);
1235 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1236 * @hw: pointer to the HW structure
1237 * @offset: register offset to be read
1238 * @data: pointer to the read data
1240 * Acquire semaphore, then read the PHY register at offset
1241 * using the kumeran interface. The information retrieved is stored in data.
1242 * Release the semaphore before exiting.
1244 static s32
e1000_read_kmrn_reg_80003es2lan(struct e1000_hw
*hw
, u32 offset
,
1250 ret_val
= e1000_acquire_mac_csr_80003es2lan(hw
);
1254 kmrnctrlsta
= ((offset
<< E1000_KMRNCTRLSTA_OFFSET_SHIFT
) &
1255 E1000_KMRNCTRLSTA_OFFSET
) | E1000_KMRNCTRLSTA_REN
;
1256 ew32(KMRNCTRLSTA
, kmrnctrlsta
);
1260 kmrnctrlsta
= er32(KMRNCTRLSTA
);
1261 *data
= (u16
)kmrnctrlsta
;
1263 e1000_release_mac_csr_80003es2lan(hw
);
1269 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1270 * @hw: pointer to the HW structure
1271 * @offset: register offset to write to
1272 * @data: data to write at register offset
1274 * Acquire semaphore, then write the data to PHY register
1275 * at the offset using the kumeran interface. Release semaphore
1278 static s32
e1000_write_kmrn_reg_80003es2lan(struct e1000_hw
*hw
, u32 offset
,
1284 ret_val
= e1000_acquire_mac_csr_80003es2lan(hw
);
1288 kmrnctrlsta
= ((offset
<< E1000_KMRNCTRLSTA_OFFSET_SHIFT
) &
1289 E1000_KMRNCTRLSTA_OFFSET
) | data
;
1290 ew32(KMRNCTRLSTA
, kmrnctrlsta
);
1294 e1000_release_mac_csr_80003es2lan(hw
);
1300 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1301 * @hw: pointer to the HW structure
1303 * Clears the hardware counters by reading the counter registers.
1305 static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw
*hw
)
1307 e1000e_clear_hw_cntrs_base(hw
);
1345 static struct e1000_mac_operations es2_mac_ops
= {
1346 .id_led_init
= e1000e_id_led_init
,
1347 .check_mng_mode
= e1000e_check_mng_mode_generic
,
1348 /* check_for_link dependent on media type */
1349 .cleanup_led
= e1000e_cleanup_led_generic
,
1350 .clear_hw_cntrs
= e1000_clear_hw_cntrs_80003es2lan
,
1351 .get_bus_info
= e1000e_get_bus_info_pcie
,
1352 .get_link_up_info
= e1000_get_link_up_info_80003es2lan
,
1353 .led_on
= e1000e_led_on_generic
,
1354 .led_off
= e1000e_led_off_generic
,
1355 .update_mc_addr_list
= e1000e_update_mc_addr_list_generic
,
1356 .reset_hw
= e1000_reset_hw_80003es2lan
,
1357 .init_hw
= e1000_init_hw_80003es2lan
,
1358 .setup_link
= e1000e_setup_link
,
1359 /* setup_physical_interface dependent on media type */
1360 .setup_led
= e1000e_setup_led_generic
,
1363 static struct e1000_phy_operations es2_phy_ops
= {
1364 .acquire
= e1000_acquire_phy_80003es2lan
,
1365 .check_reset_block
= e1000e_check_reset_block_generic
,
1366 .commit
= e1000e_phy_sw_reset
,
1367 .force_speed_duplex
= e1000_phy_force_speed_duplex_80003es2lan
,
1368 .get_cfg_done
= e1000_get_cfg_done_80003es2lan
,
1369 .get_cable_length
= e1000_get_cable_length_80003es2lan
,
1370 .get_info
= e1000e_get_phy_info_m88
,
1371 .read_reg
= e1000_read_phy_reg_gg82563_80003es2lan
,
1372 .release
= e1000_release_phy_80003es2lan
,
1373 .reset
= e1000e_phy_hw_reset_generic
,
1374 .set_d0_lplu_state
= NULL
,
1375 .set_d3_lplu_state
= e1000e_set_d3_lplu_state
,
1376 .write_reg
= e1000_write_phy_reg_gg82563_80003es2lan
,
1377 .cfg_on_link_up
= e1000_cfg_on_link_up_80003es2lan
,
1380 static struct e1000_nvm_operations es2_nvm_ops
= {
1381 .acquire
= e1000_acquire_nvm_80003es2lan
,
1382 .read
= e1000e_read_nvm_eerd
,
1383 .release
= e1000_release_nvm_80003es2lan
,
1384 .update
= e1000e_update_nvm_checksum_generic
,
1385 .valid_led_default
= e1000e_valid_led_default
,
1386 .validate
= e1000e_validate_nvm_checksum_generic
,
1387 .write
= e1000_write_nvm_80003es2lan
,
1390 struct e1000_info e1000_es2_info
= {
1391 .mac
= e1000_80003es2lan
,
1392 .flags
= FLAG_HAS_HW_VLAN_FILTER
1393 | FLAG_HAS_JUMBO_FRAMES
1395 | FLAG_APME_IN_CTRL3
1396 | FLAG_RX_CSUM_ENABLED
1397 | FLAG_HAS_CTRLEXT_ON_LOAD
1398 | FLAG_RX_NEEDS_RESTART
/* errata */
1399 | FLAG_TARC_SET_BIT_ZERO
/* errata */
1400 | FLAG_APME_CHECK_PORT_B
1401 | FLAG_DISABLE_FC_PAUSE_TIME
/* errata */
1402 | FLAG_TIPG_MEDIUM_FOR_80003ESLAN
,
1404 .max_hw_frame_size
= DEFAULT_JUMBO
,
1405 .get_variants
= e1000_get_variants_80003es2lan
,
1406 .mac_ops
= &es2_mac_ops
,
1407 .phy_ops
= &es2_phy_ops
,
1408 .nvm_ops
= &es2_nvm_ops
,