1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2006 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
30 * Shared functions for accessing and configuring the MAC
35 static s32
e1000_check_downshift(struct e1000_hw
*hw
);
36 static s32
e1000_check_polarity(struct e1000_hw
*hw
,
37 e1000_rev_polarity
*polarity
);
38 static void e1000_clear_hw_cntrs(struct e1000_hw
*hw
);
39 static void e1000_clear_vfta(struct e1000_hw
*hw
);
40 static s32
e1000_config_dsp_after_link_change(struct e1000_hw
*hw
,
42 static s32
e1000_config_fc_after_link_up(struct e1000_hw
*hw
);
43 static s32
e1000_detect_gig_phy(struct e1000_hw
*hw
);
44 static s32
e1000_get_auto_rd_done(struct e1000_hw
*hw
);
45 static s32
e1000_get_cable_length(struct e1000_hw
*hw
, u16
*min_length
,
47 static s32
e1000_get_phy_cfg_done(struct e1000_hw
*hw
);
48 static s32
e1000_id_led_init(struct e1000_hw
*hw
);
49 static void e1000_init_rx_addrs(struct e1000_hw
*hw
);
50 static s32
e1000_phy_igp_get_info(struct e1000_hw
*hw
,
51 struct e1000_phy_info
*phy_info
);
52 static s32
e1000_phy_m88_get_info(struct e1000_hw
*hw
,
53 struct e1000_phy_info
*phy_info
);
54 static s32
e1000_set_d3_lplu_state(struct e1000_hw
*hw
, bool active
);
55 static s32
e1000_wait_autoneg(struct e1000_hw
*hw
);
56 static void e1000_write_reg_io(struct e1000_hw
*hw
, u32 offset
, u32 value
);
57 static s32
e1000_set_phy_type(struct e1000_hw
*hw
);
58 static void e1000_phy_init_script(struct e1000_hw
*hw
);
59 static s32
e1000_setup_copper_link(struct e1000_hw
*hw
);
60 static s32
e1000_setup_fiber_serdes_link(struct e1000_hw
*hw
);
61 static s32
e1000_adjust_serdes_amplitude(struct e1000_hw
*hw
);
62 static s32
e1000_phy_force_speed_duplex(struct e1000_hw
*hw
);
63 static s32
e1000_config_mac_to_phy(struct e1000_hw
*hw
);
64 static void e1000_raise_mdi_clk(struct e1000_hw
*hw
, u32
*ctrl
);
65 static void e1000_lower_mdi_clk(struct e1000_hw
*hw
, u32
*ctrl
);
66 static void e1000_shift_out_mdi_bits(struct e1000_hw
*hw
, u32 data
, u16 count
);
67 static u16
e1000_shift_in_mdi_bits(struct e1000_hw
*hw
);
68 static s32
e1000_phy_reset_dsp(struct e1000_hw
*hw
);
69 static s32
e1000_write_eeprom_spi(struct e1000_hw
*hw
, u16 offset
,
70 u16 words
, u16
*data
);
71 static s32
e1000_write_eeprom_microwire(struct e1000_hw
*hw
, u16 offset
,
72 u16 words
, u16
*data
);
73 static s32
e1000_spi_eeprom_ready(struct e1000_hw
*hw
);
74 static void e1000_raise_ee_clk(struct e1000_hw
*hw
, u32
*eecd
);
75 static void e1000_lower_ee_clk(struct e1000_hw
*hw
, u32
*eecd
);
76 static void e1000_shift_out_ee_bits(struct e1000_hw
*hw
, u16 data
, u16 count
);
77 static s32
e1000_write_phy_reg_ex(struct e1000_hw
*hw
, u32 reg_addr
,
79 static s32
e1000_read_phy_reg_ex(struct e1000_hw
*hw
, u32 reg_addr
,
81 static u16
e1000_shift_in_ee_bits(struct e1000_hw
*hw
, u16 count
);
82 static s32
e1000_acquire_eeprom(struct e1000_hw
*hw
);
83 static void e1000_release_eeprom(struct e1000_hw
*hw
);
84 static void e1000_standby_eeprom(struct e1000_hw
*hw
);
85 static s32
e1000_set_vco_speed(struct e1000_hw
*hw
);
86 static s32
e1000_polarity_reversal_workaround(struct e1000_hw
*hw
);
87 static s32
e1000_set_phy_mode(struct e1000_hw
*hw
);
88 static s32
e1000_do_read_eeprom(struct e1000_hw
*hw
, u16 offset
, u16 words
,
90 static s32
e1000_do_write_eeprom(struct e1000_hw
*hw
, u16 offset
, u16 words
,
93 /* IGP cable length table */
95 u16 e1000_igp_cable_length_table
[IGP01E1000_AGC_LENGTH_TABLE_SIZE
] = {
96 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
97 5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
98 25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
99 40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
100 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
101 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100,
103 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
105 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120,
109 static DEFINE_SPINLOCK(e1000_eeprom_lock
);
112 * e1000_set_phy_type - Set the phy type member in the hw struct.
113 * @hw: Struct containing variables accessed by shared code
115 static s32
e1000_set_phy_type(struct e1000_hw
*hw
)
117 e_dbg("e1000_set_phy_type");
119 if (hw
->mac_type
== e1000_undefined
)
120 return -E1000_ERR_PHY_TYPE
;
122 switch (hw
->phy_id
) {
123 case M88E1000_E_PHY_ID
:
124 case M88E1000_I_PHY_ID
:
125 case M88E1011_I_PHY_ID
:
126 case M88E1111_I_PHY_ID
:
127 case M88E1118_E_PHY_ID
:
128 hw
->phy_type
= e1000_phy_m88
;
130 case IGP01E1000_I_PHY_ID
:
131 if (hw
->mac_type
== e1000_82541
||
132 hw
->mac_type
== e1000_82541_rev_2
||
133 hw
->mac_type
== e1000_82547
||
134 hw
->mac_type
== e1000_82547_rev_2
)
135 hw
->phy_type
= e1000_phy_igp
;
137 case RTL8211B_PHY_ID
:
138 hw
->phy_type
= e1000_phy_8211
;
140 case RTL8201N_PHY_ID
:
141 hw
->phy_type
= e1000_phy_8201
;
144 /* Should never have loaded on this device */
145 hw
->phy_type
= e1000_phy_undefined
;
146 return -E1000_ERR_PHY_TYPE
;
149 return E1000_SUCCESS
;
153 * e1000_phy_init_script - IGP phy init script - initializes the GbE PHY
154 * @hw: Struct containing variables accessed by shared code
156 static void e1000_phy_init_script(struct e1000_hw
*hw
)
161 e_dbg("e1000_phy_init_script");
163 if (hw
->phy_init_script
) {
166 /* Save off the current value of register 0x2F5B to be restored at
167 * the end of this routine. */
168 ret_val
= e1000_read_phy_reg(hw
, 0x2F5B, &phy_saved_data
);
170 /* Disabled the PHY transmitter */
171 e1000_write_phy_reg(hw
, 0x2F5B, 0x0003);
174 e1000_write_phy_reg(hw
, 0x0000, 0x0140);
177 switch (hw
->mac_type
) {
180 e1000_write_phy_reg(hw
, 0x1F95, 0x0001);
181 e1000_write_phy_reg(hw
, 0x1F71, 0xBD21);
182 e1000_write_phy_reg(hw
, 0x1F79, 0x0018);
183 e1000_write_phy_reg(hw
, 0x1F30, 0x1600);
184 e1000_write_phy_reg(hw
, 0x1F31, 0x0014);
185 e1000_write_phy_reg(hw
, 0x1F32, 0x161C);
186 e1000_write_phy_reg(hw
, 0x1F94, 0x0003);
187 e1000_write_phy_reg(hw
, 0x1F96, 0x003F);
188 e1000_write_phy_reg(hw
, 0x2010, 0x0008);
191 case e1000_82541_rev_2
:
192 case e1000_82547_rev_2
:
193 e1000_write_phy_reg(hw
, 0x1F73, 0x0099);
199 e1000_write_phy_reg(hw
, 0x0000, 0x3300);
202 /* Now enable the transmitter */
203 e1000_write_phy_reg(hw
, 0x2F5B, phy_saved_data
);
205 if (hw
->mac_type
== e1000_82547
) {
206 u16 fused
, fine
, coarse
;
208 /* Move to analog registers page */
209 e1000_read_phy_reg(hw
,
210 IGP01E1000_ANALOG_SPARE_FUSE_STATUS
,
213 if (!(fused
& IGP01E1000_ANALOG_SPARE_FUSE_ENABLED
)) {
214 e1000_read_phy_reg(hw
,
215 IGP01E1000_ANALOG_FUSE_STATUS
,
218 fine
= fused
& IGP01E1000_ANALOG_FUSE_FINE_MASK
;
220 fused
& IGP01E1000_ANALOG_FUSE_COARSE_MASK
;
223 IGP01E1000_ANALOG_FUSE_COARSE_THRESH
) {
225 IGP01E1000_ANALOG_FUSE_COARSE_10
;
226 fine
-= IGP01E1000_ANALOG_FUSE_FINE_1
;
228 IGP01E1000_ANALOG_FUSE_COARSE_THRESH
)
229 fine
-= IGP01E1000_ANALOG_FUSE_FINE_10
;
232 (fused
& IGP01E1000_ANALOG_FUSE_POLY_MASK
) |
233 (fine
& IGP01E1000_ANALOG_FUSE_FINE_MASK
) |
235 IGP01E1000_ANALOG_FUSE_COARSE_MASK
);
237 e1000_write_phy_reg(hw
,
238 IGP01E1000_ANALOG_FUSE_CONTROL
,
240 e1000_write_phy_reg(hw
,
241 IGP01E1000_ANALOG_FUSE_BYPASS
,
242 IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL
);
249 * e1000_set_mac_type - Set the mac type member in the hw struct.
250 * @hw: Struct containing variables accessed by shared code
252 s32
e1000_set_mac_type(struct e1000_hw
*hw
)
254 e_dbg("e1000_set_mac_type");
256 switch (hw
->device_id
) {
257 case E1000_DEV_ID_82542
:
258 switch (hw
->revision_id
) {
259 case E1000_82542_2_0_REV_ID
:
260 hw
->mac_type
= e1000_82542_rev2_0
;
262 case E1000_82542_2_1_REV_ID
:
263 hw
->mac_type
= e1000_82542_rev2_1
;
266 /* Invalid 82542 revision ID */
267 return -E1000_ERR_MAC_TYPE
;
270 case E1000_DEV_ID_82543GC_FIBER
:
271 case E1000_DEV_ID_82543GC_COPPER
:
272 hw
->mac_type
= e1000_82543
;
274 case E1000_DEV_ID_82544EI_COPPER
:
275 case E1000_DEV_ID_82544EI_FIBER
:
276 case E1000_DEV_ID_82544GC_COPPER
:
277 case E1000_DEV_ID_82544GC_LOM
:
278 hw
->mac_type
= e1000_82544
;
280 case E1000_DEV_ID_82540EM
:
281 case E1000_DEV_ID_82540EM_LOM
:
282 case E1000_DEV_ID_82540EP
:
283 case E1000_DEV_ID_82540EP_LOM
:
284 case E1000_DEV_ID_82540EP_LP
:
285 hw
->mac_type
= e1000_82540
;
287 case E1000_DEV_ID_82545EM_COPPER
:
288 case E1000_DEV_ID_82545EM_FIBER
:
289 hw
->mac_type
= e1000_82545
;
291 case E1000_DEV_ID_82545GM_COPPER
:
292 case E1000_DEV_ID_82545GM_FIBER
:
293 case E1000_DEV_ID_82545GM_SERDES
:
294 hw
->mac_type
= e1000_82545_rev_3
;
296 case E1000_DEV_ID_82546EB_COPPER
:
297 case E1000_DEV_ID_82546EB_FIBER
:
298 case E1000_DEV_ID_82546EB_QUAD_COPPER
:
299 hw
->mac_type
= e1000_82546
;
301 case E1000_DEV_ID_82546GB_COPPER
:
302 case E1000_DEV_ID_82546GB_FIBER
:
303 case E1000_DEV_ID_82546GB_SERDES
:
304 case E1000_DEV_ID_82546GB_PCIE
:
305 case E1000_DEV_ID_82546GB_QUAD_COPPER
:
306 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
307 hw
->mac_type
= e1000_82546_rev_3
;
309 case E1000_DEV_ID_82541EI
:
310 case E1000_DEV_ID_82541EI_MOBILE
:
311 case E1000_DEV_ID_82541ER_LOM
:
312 hw
->mac_type
= e1000_82541
;
314 case E1000_DEV_ID_82541ER
:
315 case E1000_DEV_ID_82541GI
:
316 case E1000_DEV_ID_82541GI_LF
:
317 case E1000_DEV_ID_82541GI_MOBILE
:
318 hw
->mac_type
= e1000_82541_rev_2
;
320 case E1000_DEV_ID_82547EI
:
321 case E1000_DEV_ID_82547EI_MOBILE
:
322 hw
->mac_type
= e1000_82547
;
324 case E1000_DEV_ID_82547GI
:
325 hw
->mac_type
= e1000_82547_rev_2
;
327 case E1000_DEV_ID_INTEL_CE4100_GBE
:
328 hw
->mac_type
= e1000_ce4100
;
331 /* Should never have loaded on this device */
332 return -E1000_ERR_MAC_TYPE
;
335 switch (hw
->mac_type
) {
338 case e1000_82541_rev_2
:
339 case e1000_82547_rev_2
:
340 hw
->asf_firmware_present
= true;
346 /* The 82543 chip does not count tx_carrier_errors properly in
349 if (hw
->mac_type
== e1000_82543
)
350 hw
->bad_tx_carr_stats_fd
= true;
352 if (hw
->mac_type
> e1000_82544
)
353 hw
->has_smbus
= true;
355 return E1000_SUCCESS
;
359 * e1000_set_media_type - Set media type and TBI compatibility.
360 * @hw: Struct containing variables accessed by shared code
362 void e1000_set_media_type(struct e1000_hw
*hw
)
366 e_dbg("e1000_set_media_type");
368 if (hw
->mac_type
!= e1000_82543
) {
369 /* tbi_compatibility is only valid on 82543 */
370 hw
->tbi_compatibility_en
= false;
373 switch (hw
->device_id
) {
374 case E1000_DEV_ID_82545GM_SERDES
:
375 case E1000_DEV_ID_82546GB_SERDES
:
376 hw
->media_type
= e1000_media_type_internal_serdes
;
379 switch (hw
->mac_type
) {
380 case e1000_82542_rev2_0
:
381 case e1000_82542_rev2_1
:
382 hw
->media_type
= e1000_media_type_fiber
;
385 hw
->media_type
= e1000_media_type_copper
;
388 status
= er32(STATUS
);
389 if (status
& E1000_STATUS_TBIMODE
) {
390 hw
->media_type
= e1000_media_type_fiber
;
391 /* tbi_compatibility not valid on fiber */
392 hw
->tbi_compatibility_en
= false;
394 hw
->media_type
= e1000_media_type_copper
;
402 * e1000_reset_hw: reset the hardware completely
403 * @hw: Struct containing variables accessed by shared code
405 * Reset the transmit and receive units; mask and clear all interrupts.
407 s32
e1000_reset_hw(struct e1000_hw
*hw
)
416 e_dbg("e1000_reset_hw");
418 /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
419 if (hw
->mac_type
== e1000_82542_rev2_0
) {
420 e_dbg("Disabling MWI on 82542 rev 2.0\n");
421 e1000_pci_clear_mwi(hw
);
424 /* Clear interrupt mask to stop board from generating interrupts */
425 e_dbg("Masking off all interrupts\n");
426 ew32(IMC
, 0xffffffff);
428 /* Disable the Transmit and Receive units. Then delay to allow
429 * any pending transactions to complete before we hit the MAC with
433 ew32(TCTL
, E1000_TCTL_PSP
);
436 /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
437 hw
->tbi_compatibility_on
= false;
439 /* Delay to allow any outstanding PCI transactions to complete before
440 * resetting the device
446 /* Must reset the PHY before resetting the MAC */
447 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
448 ew32(CTRL
, (ctrl
| E1000_CTRL_PHY_RST
));
453 /* Issue a global reset to the MAC. This will reset the chip's
454 * transmit, receive, DMA, and link units. It will not effect
455 * the current PCI configuration. The global reset bit is self-
456 * clearing, and should clear within a microsecond.
458 e_dbg("Issuing a global reset to MAC\n");
460 switch (hw
->mac_type
) {
466 case e1000_82541_rev_2
:
467 /* These controllers can't ack the 64-bit write when issuing the
468 * reset, so use IO-mapping as a workaround to issue the reset */
469 E1000_WRITE_REG_IO(hw
, CTRL
, (ctrl
| E1000_CTRL_RST
));
471 case e1000_82545_rev_3
:
472 case e1000_82546_rev_3
:
473 /* Reset is performed on a shadow of the control register */
474 ew32(CTRL_DUP
, (ctrl
| E1000_CTRL_RST
));
478 ew32(CTRL
, (ctrl
| E1000_CTRL_RST
));
482 /* After MAC reset, force reload of EEPROM to restore power-on settings to
483 * device. Later controllers reload the EEPROM automatically, so just wait
484 * for reload to complete.
486 switch (hw
->mac_type
) {
487 case e1000_82542_rev2_0
:
488 case e1000_82542_rev2_1
:
491 /* Wait for reset to complete */
493 ctrl_ext
= er32(CTRL_EXT
);
494 ctrl_ext
|= E1000_CTRL_EXT_EE_RST
;
495 ew32(CTRL_EXT
, ctrl_ext
);
497 /* Wait for EEPROM reload */
501 case e1000_82541_rev_2
:
503 case e1000_82547_rev_2
:
504 /* Wait for EEPROM reload */
508 /* Auto read done will delay 5ms or poll based on mac type */
509 ret_val
= e1000_get_auto_rd_done(hw
);
515 /* Disable HW ARPs on ASF enabled adapters */
516 if (hw
->mac_type
>= e1000_82540
) {
518 manc
&= ~(E1000_MANC_ARP_EN
);
522 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
523 e1000_phy_init_script(hw
);
525 /* Configure activity LED after PHY reset */
526 led_ctrl
= er32(LEDCTL
);
527 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
528 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
529 ew32(LEDCTL
, led_ctrl
);
532 /* Clear interrupt mask to stop board from generating interrupts */
533 e_dbg("Masking off all interrupts\n");
534 ew32(IMC
, 0xffffffff);
536 /* Clear any pending interrupt events. */
539 /* If MWI was previously enabled, reenable it. */
540 if (hw
->mac_type
== e1000_82542_rev2_0
) {
541 if (hw
->pci_cmd_word
& PCI_COMMAND_INVALIDATE
)
542 e1000_pci_set_mwi(hw
);
545 return E1000_SUCCESS
;
549 * e1000_init_hw: Performs basic configuration of the adapter.
550 * @hw: Struct containing variables accessed by shared code
552 * Assumes that the controller has previously been reset and is in a
553 * post-reset uninitialized state. Initializes the receive address registers,
554 * multicast table, and VLAN filter table. Calls routines to setup link
555 * configuration and flow control settings. Clears all on-chip counters. Leaves
556 * the transmit and receive units disabled and uninitialized.
558 s32
e1000_init_hw(struct e1000_hw
*hw
)
566 e_dbg("e1000_init_hw");
568 /* Initialize Identification LED */
569 ret_val
= e1000_id_led_init(hw
);
571 e_dbg("Error Initializing Identification LED\n");
575 /* Set the media type and TBI compatibility */
576 e1000_set_media_type(hw
);
578 /* Disabling VLAN filtering. */
579 e_dbg("Initializing the IEEE VLAN\n");
580 if (hw
->mac_type
< e1000_82545_rev_3
)
582 e1000_clear_vfta(hw
);
584 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
585 if (hw
->mac_type
== e1000_82542_rev2_0
) {
586 e_dbg("Disabling MWI on 82542 rev 2.0\n");
587 e1000_pci_clear_mwi(hw
);
588 ew32(RCTL
, E1000_RCTL_RST
);
593 /* Setup the receive address. This involves initializing all of the Receive
594 * Address Registers (RARs 0 - 15).
596 e1000_init_rx_addrs(hw
);
598 /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
599 if (hw
->mac_type
== e1000_82542_rev2_0
) {
603 if (hw
->pci_cmd_word
& PCI_COMMAND_INVALIDATE
)
604 e1000_pci_set_mwi(hw
);
607 /* Zero out the Multicast HASH table */
608 e_dbg("Zeroing the MTA\n");
609 mta_size
= E1000_MC_TBL_SIZE
;
610 for (i
= 0; i
< mta_size
; i
++) {
611 E1000_WRITE_REG_ARRAY(hw
, MTA
, i
, 0);
612 /* use write flush to prevent Memory Write Block (MWB) from
613 * occurring when accessing our register space */
617 /* Set the PCI priority bit correctly in the CTRL register. This
618 * determines if the adapter gives priority to receives, or if it
619 * gives equal priority to transmits and receives. Valid only on
620 * 82542 and 82543 silicon.
622 if (hw
->dma_fairness
&& hw
->mac_type
<= e1000_82543
) {
624 ew32(CTRL
, ctrl
| E1000_CTRL_PRIOR
);
627 switch (hw
->mac_type
) {
628 case e1000_82545_rev_3
:
629 case e1000_82546_rev_3
:
632 /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
633 if (hw
->bus_type
== e1000_bus_type_pcix
634 && e1000_pcix_get_mmrbc(hw
) > 2048)
635 e1000_pcix_set_mmrbc(hw
, 2048);
639 /* Call a subroutine to configure the link and setup flow control. */
640 ret_val
= e1000_setup_link(hw
);
642 /* Set the transmit descriptor write-back policy */
643 if (hw
->mac_type
> e1000_82544
) {
646 (ctrl
& ~E1000_TXDCTL_WTHRESH
) |
647 E1000_TXDCTL_FULL_TX_DESC_WB
;
651 /* Clear all of the statistics registers (clear on read). It is
652 * important that we do this after we have tried to establish link
653 * because the symbol error count will increment wildly if there
656 e1000_clear_hw_cntrs(hw
);
658 if (hw
->device_id
== E1000_DEV_ID_82546GB_QUAD_COPPER
||
659 hw
->device_id
== E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
) {
660 ctrl_ext
= er32(CTRL_EXT
);
661 /* Relaxed ordering must be disabled to avoid a parity
662 * error crash in a PCI slot. */
663 ctrl_ext
|= E1000_CTRL_EXT_RO_DIS
;
664 ew32(CTRL_EXT
, ctrl_ext
);
671 * e1000_adjust_serdes_amplitude - Adjust SERDES output amplitude based on EEPROM setting.
672 * @hw: Struct containing variables accessed by shared code.
674 static s32
e1000_adjust_serdes_amplitude(struct e1000_hw
*hw
)
679 e_dbg("e1000_adjust_serdes_amplitude");
681 if (hw
->media_type
!= e1000_media_type_internal_serdes
)
682 return E1000_SUCCESS
;
684 switch (hw
->mac_type
) {
685 case e1000_82545_rev_3
:
686 case e1000_82546_rev_3
:
689 return E1000_SUCCESS
;
692 ret_val
= e1000_read_eeprom(hw
, EEPROM_SERDES_AMPLITUDE
, 1,
698 if (eeprom_data
!= EEPROM_RESERVED_WORD
) {
699 /* Adjust SERDES output amplitude only. */
700 eeprom_data
&= EEPROM_SERDES_AMPLITUDE_MASK
;
702 e1000_write_phy_reg(hw
, M88E1000_PHY_EXT_CTRL
, eeprom_data
);
707 return E1000_SUCCESS
;
711 * e1000_setup_link - Configures flow control and link settings.
712 * @hw: Struct containing variables accessed by shared code
714 * Determines which flow control settings to use. Calls the appropriate media-
715 * specific link configuration function. Configures the flow control settings.
716 * Assuming the adapter has a valid link partner, a valid link should be
717 * established. Assumes the hardware has previously been reset and the
718 * transmitter and receiver are not enabled.
720 s32
e1000_setup_link(struct e1000_hw
*hw
)
726 e_dbg("e1000_setup_link");
728 /* Read and store word 0x0F of the EEPROM. This word contains bits
729 * that determine the hardware's default PAUSE (flow control) mode,
730 * a bit that determines whether the HW defaults to enabling or
731 * disabling auto-negotiation, and the direction of the
732 * SW defined pins. If there is no SW over-ride of the flow
733 * control setting, then the variable hw->fc will
734 * be initialized based on a value in the EEPROM.
736 if (hw
->fc
== E1000_FC_DEFAULT
) {
737 ret_val
= e1000_read_eeprom(hw
, EEPROM_INIT_CONTROL2_REG
,
740 e_dbg("EEPROM Read Error\n");
741 return -E1000_ERR_EEPROM
;
743 if ((eeprom_data
& EEPROM_WORD0F_PAUSE_MASK
) == 0)
744 hw
->fc
= E1000_FC_NONE
;
745 else if ((eeprom_data
& EEPROM_WORD0F_PAUSE_MASK
) ==
746 EEPROM_WORD0F_ASM_DIR
)
747 hw
->fc
= E1000_FC_TX_PAUSE
;
749 hw
->fc
= E1000_FC_FULL
;
752 /* We want to save off the original Flow Control configuration just
753 * in case we get disconnected and then reconnected into a different
754 * hub or switch with different Flow Control capabilities.
756 if (hw
->mac_type
== e1000_82542_rev2_0
)
757 hw
->fc
&= (~E1000_FC_TX_PAUSE
);
759 if ((hw
->mac_type
< e1000_82543
) && (hw
->report_tx_early
== 1))
760 hw
->fc
&= (~E1000_FC_RX_PAUSE
);
762 hw
->original_fc
= hw
->fc
;
764 e_dbg("After fix-ups FlowControl is now = %x\n", hw
->fc
);
766 /* Take the 4 bits from EEPROM word 0x0F that determine the initial
767 * polarity value for the SW controlled pins, and setup the
768 * Extended Device Control reg with that info.
769 * This is needed because one of the SW controlled pins is used for
770 * signal detection. So this should be done before e1000_setup_pcs_link()
771 * or e1000_phy_setup() is called.
773 if (hw
->mac_type
== e1000_82543
) {
774 ret_val
= e1000_read_eeprom(hw
, EEPROM_INIT_CONTROL2_REG
,
777 e_dbg("EEPROM Read Error\n");
778 return -E1000_ERR_EEPROM
;
780 ctrl_ext
= ((eeprom_data
& EEPROM_WORD0F_SWPDIO_EXT
) <<
782 ew32(CTRL_EXT
, ctrl_ext
);
785 /* Call the necessary subroutine to configure the link. */
786 ret_val
= (hw
->media_type
== e1000_media_type_copper
) ?
787 e1000_setup_copper_link(hw
) : e1000_setup_fiber_serdes_link(hw
);
789 /* Initialize the flow control address, type, and PAUSE timer
790 * registers to their default values. This is done even if flow
791 * control is disabled, because it does not hurt anything to
792 * initialize these registers.
794 e_dbg("Initializing the Flow Control address, type and timer regs\n");
796 ew32(FCT
, FLOW_CONTROL_TYPE
);
797 ew32(FCAH
, FLOW_CONTROL_ADDRESS_HIGH
);
798 ew32(FCAL
, FLOW_CONTROL_ADDRESS_LOW
);
800 ew32(FCTTV
, hw
->fc_pause_time
);
802 /* Set the flow control receive threshold registers. Normally,
803 * these registers will be set to a default threshold that may be
804 * adjusted later by the driver's runtime code. However, if the
805 * ability to transmit pause frames in not enabled, then these
806 * registers will be set to 0.
808 if (!(hw
->fc
& E1000_FC_TX_PAUSE
)) {
812 /* We need to set up the Receive Threshold high and low water marks
813 * as well as (optionally) enabling the transmission of XON frames.
815 if (hw
->fc_send_xon
) {
816 ew32(FCRTL
, (hw
->fc_low_water
| E1000_FCRTL_XONE
));
817 ew32(FCRTH
, hw
->fc_high_water
);
819 ew32(FCRTL
, hw
->fc_low_water
);
820 ew32(FCRTH
, hw
->fc_high_water
);
827 * e1000_setup_fiber_serdes_link - prepare fiber or serdes link
828 * @hw: Struct containing variables accessed by shared code
830 * Manipulates Physical Coding Sublayer functions in order to configure
831 * link. Assumes the hardware has been previously reset and the transmitter
832 * and receiver are not enabled.
834 static s32
e1000_setup_fiber_serdes_link(struct e1000_hw
*hw
)
843 e_dbg("e1000_setup_fiber_serdes_link");
845 /* On adapters with a MAC newer than 82544, SWDP 1 will be
846 * set when the optics detect a signal. On older adapters, it will be
847 * cleared when there is a signal. This applies to fiber media only.
848 * If we're on serdes media, adjust the output amplitude to value
852 if (hw
->media_type
== e1000_media_type_fiber
)
853 signal
= (hw
->mac_type
> e1000_82544
) ? E1000_CTRL_SWDPIN1
: 0;
855 ret_val
= e1000_adjust_serdes_amplitude(hw
);
859 /* Take the link out of reset */
860 ctrl
&= ~(E1000_CTRL_LRST
);
862 /* Adjust VCO speed to improve BER performance */
863 ret_val
= e1000_set_vco_speed(hw
);
867 e1000_config_collision_dist(hw
);
869 /* Check for a software override of the flow control settings, and setup
870 * the device accordingly. If auto-negotiation is enabled, then software
871 * will have to set the "PAUSE" bits to the correct value in the Tranmsit
872 * Config Word Register (TXCW) and re-start auto-negotiation. However, if
873 * auto-negotiation is disabled, then software will have to manually
874 * configure the two flow control enable bits in the CTRL register.
876 * The possible values of the "fc" parameter are:
877 * 0: Flow control is completely disabled
878 * 1: Rx flow control is enabled (we can receive pause frames, but
879 * not send pause frames).
880 * 2: Tx flow control is enabled (we can send pause frames but we do
881 * not support receiving pause frames).
882 * 3: Both Rx and TX flow control (symmetric) are enabled.
886 /* Flow control is completely disabled by a software over-ride. */
887 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
);
889 case E1000_FC_RX_PAUSE
:
890 /* RX Flow control is enabled and TX Flow control is disabled by a
891 * software over-ride. Since there really isn't a way to advertise
892 * that we are capable of RX Pause ONLY, we will advertise that we
893 * support both symmetric and asymmetric RX PAUSE. Later, we will
894 * disable the adapter's ability to send PAUSE frames.
896 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
| E1000_TXCW_PAUSE_MASK
);
898 case E1000_FC_TX_PAUSE
:
899 /* TX Flow control is enabled, and RX Flow control is disabled, by a
900 * software over-ride.
902 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
| E1000_TXCW_ASM_DIR
);
905 /* Flow control (both RX and TX) is enabled by a software over-ride. */
906 txcw
= (E1000_TXCW_ANE
| E1000_TXCW_FD
| E1000_TXCW_PAUSE_MASK
);
909 e_dbg("Flow control param set incorrectly\n");
910 return -E1000_ERR_CONFIG
;
914 /* Since auto-negotiation is enabled, take the link out of reset (the link
915 * will be in reset, because we previously reset the chip). This will
916 * restart auto-negotiation. If auto-negotiation is successful then the
917 * link-up status bit will be set and the flow control enable bits (RFCE
918 * and TFCE) will be set according to their negotiated value.
920 e_dbg("Auto-negotiation enabled\n");
929 /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
930 * indication in the Device Status Register. Time-out if a link isn't
931 * seen in 500 milliseconds seconds (Auto-negotiation should complete in
932 * less than 500 milliseconds even if the other end is doing it in SW).
933 * For internal serdes, we just assume a signal is present, then poll.
935 if (hw
->media_type
== e1000_media_type_internal_serdes
||
936 (er32(CTRL
) & E1000_CTRL_SWDPIN1
) == signal
) {
937 e_dbg("Looking for Link\n");
938 for (i
= 0; i
< (LINK_UP_TIMEOUT
/ 10); i
++) {
940 status
= er32(STATUS
);
941 if (status
& E1000_STATUS_LU
)
944 if (i
== (LINK_UP_TIMEOUT
/ 10)) {
945 e_dbg("Never got a valid link from auto-neg!!!\n");
946 hw
->autoneg_failed
= 1;
947 /* AutoNeg failed to achieve a link, so we'll call
948 * e1000_check_for_link. This routine will force the link up if
949 * we detect a signal. This will allow us to communicate with
950 * non-autonegotiating link partners.
952 ret_val
= e1000_check_for_link(hw
);
954 e_dbg("Error while checking for link\n");
957 hw
->autoneg_failed
= 0;
959 hw
->autoneg_failed
= 0;
960 e_dbg("Valid Link Found\n");
963 e_dbg("No Signal Detected\n");
965 return E1000_SUCCESS
;
969 * e1000_copper_link_rtl_setup - Copper link setup for e1000_phy_rtl series.
970 * @hw: Struct containing variables accessed by shared code
972 * Commits changes to PHY configuration by calling e1000_phy_reset().
974 static s32
e1000_copper_link_rtl_setup(struct e1000_hw
*hw
)
978 /* SW reset the PHY so all changes take effect */
979 ret_val
= e1000_phy_reset(hw
);
981 e_dbg("Error Resetting the PHY\n");
985 return E1000_SUCCESS
;
988 static s32
gbe_dhg_phy_setup(struct e1000_hw
*hw
)
993 switch (hw
->phy_type
) {
995 ret_val
= e1000_copper_link_rtl_setup(hw
);
997 e_dbg("e1000_copper_link_rtl_setup failed!\n");
1001 case e1000_phy_8201
:
1003 ctrl_aux
= er32(CTL_AUX
);
1004 ctrl_aux
|= E1000_CTL_AUX_RMII
;
1005 ew32(CTL_AUX
, ctrl_aux
);
1006 E1000_WRITE_FLUSH();
1008 /* Disable the J/K bits required for receive */
1009 ctrl_aux
= er32(CTL_AUX
);
1012 ew32(CTL_AUX
, ctrl_aux
);
1013 E1000_WRITE_FLUSH();
1014 ret_val
= e1000_copper_link_rtl_setup(hw
);
1017 e_dbg("e1000_copper_link_rtl_setup failed!\n");
1022 e_dbg("Error Resetting the PHY\n");
1023 return E1000_ERR_PHY_TYPE
;
1026 return E1000_SUCCESS
;
1030 * e1000_copper_link_preconfig - early configuration for copper
1031 * @hw: Struct containing variables accessed by shared code
1033 * Make sure we have a valid PHY and change PHY mode before link setup.
1035 static s32
e1000_copper_link_preconfig(struct e1000_hw
*hw
)
1041 e_dbg("e1000_copper_link_preconfig");
1044 /* With 82543, we need to force speed and duplex on the MAC equal to what
1045 * the PHY speed and duplex configuration is. In addition, we need to
1046 * perform a hardware reset on the PHY to take it out of reset.
1048 if (hw
->mac_type
> e1000_82543
) {
1049 ctrl
|= E1000_CTRL_SLU
;
1050 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1054 (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
| E1000_CTRL_SLU
);
1056 ret_val
= e1000_phy_hw_reset(hw
);
1061 /* Make sure we have a valid PHY */
1062 ret_val
= e1000_detect_gig_phy(hw
);
1064 e_dbg("Error, did not detect valid phy.\n");
1067 e_dbg("Phy ID = %x\n", hw
->phy_id
);
1069 /* Set PHY to class A mode (if necessary) */
1070 ret_val
= e1000_set_phy_mode(hw
);
1074 if ((hw
->mac_type
== e1000_82545_rev_3
) ||
1075 (hw
->mac_type
== e1000_82546_rev_3
)) {
1077 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
1078 phy_data
|= 0x00000008;
1080 e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
1083 if (hw
->mac_type
<= e1000_82543
||
1084 hw
->mac_type
== e1000_82541
|| hw
->mac_type
== e1000_82547
||
1085 hw
->mac_type
== e1000_82541_rev_2
1086 || hw
->mac_type
== e1000_82547_rev_2
)
1087 hw
->phy_reset_disable
= false;
1089 return E1000_SUCCESS
;
1093 * e1000_copper_link_igp_setup - Copper link setup for e1000_phy_igp series.
1094 * @hw: Struct containing variables accessed by shared code
1096 static s32
e1000_copper_link_igp_setup(struct e1000_hw
*hw
)
1102 e_dbg("e1000_copper_link_igp_setup");
1104 if (hw
->phy_reset_disable
)
1105 return E1000_SUCCESS
;
1107 ret_val
= e1000_phy_reset(hw
);
1109 e_dbg("Error Resetting the PHY\n");
1113 /* Wait 15ms for MAC to configure PHY from eeprom settings */
1115 /* Configure activity LED after PHY reset */
1116 led_ctrl
= er32(LEDCTL
);
1117 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
1118 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
1119 ew32(LEDCTL
, led_ctrl
);
1121 /* The NVM settings will configure LPLU in D3 for IGP2 and IGP3 PHYs */
1122 if (hw
->phy_type
== e1000_phy_igp
) {
1123 /* disable lplu d3 during driver init */
1124 ret_val
= e1000_set_d3_lplu_state(hw
, false);
1126 e_dbg("Error Disabling LPLU D3\n");
1131 /* Configure mdi-mdix settings */
1132 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, &phy_data
);
1136 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
1137 hw
->dsp_config_state
= e1000_dsp_config_disabled
;
1138 /* Force MDI for earlier revs of the IGP PHY */
1140 ~(IGP01E1000_PSCR_AUTO_MDIX
|
1141 IGP01E1000_PSCR_FORCE_MDI_MDIX
);
1145 hw
->dsp_config_state
= e1000_dsp_config_enabled
;
1146 phy_data
&= ~IGP01E1000_PSCR_AUTO_MDIX
;
1150 phy_data
&= ~IGP01E1000_PSCR_FORCE_MDI_MDIX
;
1153 phy_data
|= IGP01E1000_PSCR_FORCE_MDI_MDIX
;
1157 phy_data
|= IGP01E1000_PSCR_AUTO_MDIX
;
1161 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, phy_data
);
1165 /* set auto-master slave resolution settings */
1167 e1000_ms_type phy_ms_setting
= hw
->master_slave
;
1169 if (hw
->ffe_config_state
== e1000_ffe_config_active
)
1170 hw
->ffe_config_state
= e1000_ffe_config_enabled
;
1172 if (hw
->dsp_config_state
== e1000_dsp_config_activated
)
1173 hw
->dsp_config_state
= e1000_dsp_config_enabled
;
1175 /* when autonegotiation advertisement is only 1000Mbps then we
1176 * should disable SmartSpeed and enable Auto MasterSlave
1177 * resolution as hardware default. */
1178 if (hw
->autoneg_advertised
== ADVERTISE_1000_FULL
) {
1179 /* Disable SmartSpeed */
1181 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1185 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1187 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1191 /* Set auto Master/Slave resolution process */
1193 e1000_read_phy_reg(hw
, PHY_1000T_CTRL
, &phy_data
);
1196 phy_data
&= ~CR_1000T_MS_ENABLE
;
1198 e1000_write_phy_reg(hw
, PHY_1000T_CTRL
, phy_data
);
1203 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_CTRL
, &phy_data
);
1207 /* load defaults for future use */
1208 hw
->original_master_slave
= (phy_data
& CR_1000T_MS_ENABLE
) ?
1209 ((phy_data
& CR_1000T_MS_VALUE
) ?
1210 e1000_ms_force_master
:
1211 e1000_ms_force_slave
) : e1000_ms_auto
;
1213 switch (phy_ms_setting
) {
1214 case e1000_ms_force_master
:
1215 phy_data
|= (CR_1000T_MS_ENABLE
| CR_1000T_MS_VALUE
);
1217 case e1000_ms_force_slave
:
1218 phy_data
|= CR_1000T_MS_ENABLE
;
1219 phy_data
&= ~(CR_1000T_MS_VALUE
);
1222 phy_data
&= ~CR_1000T_MS_ENABLE
;
1226 ret_val
= e1000_write_phy_reg(hw
, PHY_1000T_CTRL
, phy_data
);
1231 return E1000_SUCCESS
;
1235 * e1000_copper_link_mgp_setup - Copper link setup for e1000_phy_m88 series.
1236 * @hw: Struct containing variables accessed by shared code
1238 static s32
e1000_copper_link_mgp_setup(struct e1000_hw
*hw
)
1243 e_dbg("e1000_copper_link_mgp_setup");
1245 if (hw
->phy_reset_disable
)
1246 return E1000_SUCCESS
;
1248 /* Enable CRS on TX. This must be set for half-duplex operation. */
1249 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
1253 phy_data
|= M88E1000_PSCR_ASSERT_CRS_ON_TX
;
1256 * MDI/MDI-X = 0 (default)
1257 * 0 - Auto for all speeds
1260 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1262 phy_data
&= ~M88E1000_PSCR_AUTO_X_MODE
;
1266 phy_data
|= M88E1000_PSCR_MDI_MANUAL_MODE
;
1269 phy_data
|= M88E1000_PSCR_MDIX_MANUAL_MODE
;
1272 phy_data
|= M88E1000_PSCR_AUTO_X_1000T
;
1276 phy_data
|= M88E1000_PSCR_AUTO_X_MODE
;
1281 * disable_polarity_correction = 0 (default)
1282 * Automatic Correction for Reversed Cable Polarity
1286 phy_data
&= ~M88E1000_PSCR_POLARITY_REVERSAL
;
1287 if (hw
->disable_polarity_correction
== 1)
1288 phy_data
|= M88E1000_PSCR_POLARITY_REVERSAL
;
1289 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
1293 if (hw
->phy_revision
< M88E1011_I_REV_4
) {
1294 /* Force TX_CLK in the Extended PHY Specific Control Register
1298 e1000_read_phy_reg(hw
, M88E1000_EXT_PHY_SPEC_CTRL
,
1303 phy_data
|= M88E1000_EPSCR_TX_CLK_25
;
1305 if ((hw
->phy_revision
== E1000_REVISION_2
) &&
1306 (hw
->phy_id
== M88E1111_I_PHY_ID
)) {
1307 /* Vidalia Phy, set the downshift counter to 5x */
1308 phy_data
&= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK
);
1309 phy_data
|= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X
;
1310 ret_val
= e1000_write_phy_reg(hw
,
1311 M88E1000_EXT_PHY_SPEC_CTRL
,
1316 /* Configure Master and Slave downshift values */
1317 phy_data
&= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK
|
1318 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK
);
1319 phy_data
|= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X
|
1320 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X
);
1321 ret_val
= e1000_write_phy_reg(hw
,
1322 M88E1000_EXT_PHY_SPEC_CTRL
,
1329 /* SW Reset the PHY so all changes take effect */
1330 ret_val
= e1000_phy_reset(hw
);
1332 e_dbg("Error Resetting the PHY\n");
1336 return E1000_SUCCESS
;
1340 * e1000_copper_link_autoneg - setup auto-neg
1341 * @hw: Struct containing variables accessed by shared code
1343 * Setup auto-negotiation and flow control advertisements,
1344 * and then perform auto-negotiation.
1346 static s32
e1000_copper_link_autoneg(struct e1000_hw
*hw
)
1351 e_dbg("e1000_copper_link_autoneg");
1353 /* Perform some bounds checking on the hw->autoneg_advertised
1354 * parameter. If this variable is zero, then set it to the default.
1356 hw
->autoneg_advertised
&= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
1358 /* If autoneg_advertised is zero, we assume it was not defaulted
1359 * by the calling code so we set to advertise full capability.
1361 if (hw
->autoneg_advertised
== 0)
1362 hw
->autoneg_advertised
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
1364 /* IFE/RTL8201N PHY only supports 10/100 */
1365 if (hw
->phy_type
== e1000_phy_8201
)
1366 hw
->autoneg_advertised
&= AUTONEG_ADVERTISE_10_100_ALL
;
1368 e_dbg("Reconfiguring auto-neg advertisement params\n");
1369 ret_val
= e1000_phy_setup_autoneg(hw
);
1371 e_dbg("Error Setting up Auto-Negotiation\n");
1374 e_dbg("Restarting Auto-Neg\n");
1376 /* Restart auto-negotiation by setting the Auto Neg Enable bit and
1377 * the Auto Neg Restart bit in the PHY control register.
1379 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_data
);
1383 phy_data
|= (MII_CR_AUTO_NEG_EN
| MII_CR_RESTART_AUTO_NEG
);
1384 ret_val
= e1000_write_phy_reg(hw
, PHY_CTRL
, phy_data
);
1388 /* Does the user want to wait for Auto-Neg to complete here, or
1389 * check at a later time (for example, callback routine).
1391 if (hw
->wait_autoneg_complete
) {
1392 ret_val
= e1000_wait_autoneg(hw
);
1395 ("Error while waiting for autoneg to complete\n");
1400 hw
->get_link_status
= true;
1402 return E1000_SUCCESS
;
1406 * e1000_copper_link_postconfig - post link setup
1407 * @hw: Struct containing variables accessed by shared code
1409 * Config the MAC and the PHY after link is up.
1410 * 1) Set up the MAC to the current PHY speed/duplex
1411 * if we are on 82543. If we
1412 * are on newer silicon, we only need to configure
1413 * collision distance in the Transmit Control Register.
1414 * 2) Set up flow control on the MAC to that established with
1416 * 3) Config DSP to improve Gigabit link quality for some PHY revisions.
1418 static s32
e1000_copper_link_postconfig(struct e1000_hw
*hw
)
1421 e_dbg("e1000_copper_link_postconfig");
1423 if ((hw
->mac_type
>= e1000_82544
) && (hw
->mac_type
!= e1000_ce4100
)) {
1424 e1000_config_collision_dist(hw
);
1426 ret_val
= e1000_config_mac_to_phy(hw
);
1428 e_dbg("Error configuring MAC to PHY settings\n");
1432 ret_val
= e1000_config_fc_after_link_up(hw
);
1434 e_dbg("Error Configuring Flow Control\n");
1438 /* Config DSP to improve Giga link quality */
1439 if (hw
->phy_type
== e1000_phy_igp
) {
1440 ret_val
= e1000_config_dsp_after_link_change(hw
, true);
1442 e_dbg("Error Configuring DSP after link up\n");
1447 return E1000_SUCCESS
;
1451 * e1000_setup_copper_link - phy/speed/duplex setting
1452 * @hw: Struct containing variables accessed by shared code
1454 * Detects which PHY is present and sets up the speed and duplex
1456 static s32
e1000_setup_copper_link(struct e1000_hw
*hw
)
1462 e_dbg("e1000_setup_copper_link");
1464 /* Check if it is a valid PHY and set PHY mode if necessary. */
1465 ret_val
= e1000_copper_link_preconfig(hw
);
1469 if (hw
->phy_type
== e1000_phy_igp
) {
1470 ret_val
= e1000_copper_link_igp_setup(hw
);
1473 } else if (hw
->phy_type
== e1000_phy_m88
) {
1474 ret_val
= e1000_copper_link_mgp_setup(hw
);
1478 ret_val
= gbe_dhg_phy_setup(hw
);
1480 e_dbg("gbe_dhg_phy_setup failed!\n");
1486 /* Setup autoneg and flow control advertisement
1487 * and perform autonegotiation */
1488 ret_val
= e1000_copper_link_autoneg(hw
);
1492 /* PHY will be set to 10H, 10F, 100H,or 100F
1493 * depending on value from forced_speed_duplex. */
1494 e_dbg("Forcing speed and duplex\n");
1495 ret_val
= e1000_phy_force_speed_duplex(hw
);
1497 e_dbg("Error Forcing Speed and Duplex\n");
1502 /* Check link status. Wait up to 100 microseconds for link to become
1505 for (i
= 0; i
< 10; i
++) {
1506 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
1509 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
1513 if (phy_data
& MII_SR_LINK_STATUS
) {
1514 /* Config the MAC and PHY after link is up */
1515 ret_val
= e1000_copper_link_postconfig(hw
);
1519 e_dbg("Valid link established!!!\n");
1520 return E1000_SUCCESS
;
1525 e_dbg("Unable to establish link!!!\n");
1526 return E1000_SUCCESS
;
1530 * e1000_phy_setup_autoneg - phy settings
1531 * @hw: Struct containing variables accessed by shared code
1533 * Configures PHY autoneg and flow control advertisement settings
1535 s32
e1000_phy_setup_autoneg(struct e1000_hw
*hw
)
1538 u16 mii_autoneg_adv_reg
;
1539 u16 mii_1000t_ctrl_reg
;
1541 e_dbg("e1000_phy_setup_autoneg");
1543 /* Read the MII Auto-Neg Advertisement Register (Address 4). */
1544 ret_val
= e1000_read_phy_reg(hw
, PHY_AUTONEG_ADV
, &mii_autoneg_adv_reg
);
1548 /* Read the MII 1000Base-T Control Register (Address 9). */
1549 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_CTRL
, &mii_1000t_ctrl_reg
);
1552 else if (hw
->phy_type
== e1000_phy_8201
)
1553 mii_1000t_ctrl_reg
&= ~REG9_SPEED_MASK
;
1555 /* Need to parse both autoneg_advertised and fc and set up
1556 * the appropriate PHY registers. First we will parse for
1557 * autoneg_advertised software override. Since we can advertise
1558 * a plethora of combinations, we need to check each bit
1562 /* First we clear all the 10/100 mb speed bits in the Auto-Neg
1563 * Advertisement Register (Address 4) and the 1000 mb speed bits in
1564 * the 1000Base-T Control Register (Address 9).
1566 mii_autoneg_adv_reg
&= ~REG4_SPEED_MASK
;
1567 mii_1000t_ctrl_reg
&= ~REG9_SPEED_MASK
;
1569 e_dbg("autoneg_advertised %x\n", hw
->autoneg_advertised
);
1571 /* Do we want to advertise 10 Mb Half Duplex? */
1572 if (hw
->autoneg_advertised
& ADVERTISE_10_HALF
) {
1573 e_dbg("Advertise 10mb Half duplex\n");
1574 mii_autoneg_adv_reg
|= NWAY_AR_10T_HD_CAPS
;
1577 /* Do we want to advertise 10 Mb Full Duplex? */
1578 if (hw
->autoneg_advertised
& ADVERTISE_10_FULL
) {
1579 e_dbg("Advertise 10mb Full duplex\n");
1580 mii_autoneg_adv_reg
|= NWAY_AR_10T_FD_CAPS
;
1583 /* Do we want to advertise 100 Mb Half Duplex? */
1584 if (hw
->autoneg_advertised
& ADVERTISE_100_HALF
) {
1585 e_dbg("Advertise 100mb Half duplex\n");
1586 mii_autoneg_adv_reg
|= NWAY_AR_100TX_HD_CAPS
;
1589 /* Do we want to advertise 100 Mb Full Duplex? */
1590 if (hw
->autoneg_advertised
& ADVERTISE_100_FULL
) {
1591 e_dbg("Advertise 100mb Full duplex\n");
1592 mii_autoneg_adv_reg
|= NWAY_AR_100TX_FD_CAPS
;
1595 /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
1596 if (hw
->autoneg_advertised
& ADVERTISE_1000_HALF
) {
1598 ("Advertise 1000mb Half duplex requested, request denied!\n");
1601 /* Do we want to advertise 1000 Mb Full Duplex? */
1602 if (hw
->autoneg_advertised
& ADVERTISE_1000_FULL
) {
1603 e_dbg("Advertise 1000mb Full duplex\n");
1604 mii_1000t_ctrl_reg
|= CR_1000T_FD_CAPS
;
1607 /* Check for a software override of the flow control settings, and
1608 * setup the PHY advertisement registers accordingly. If
1609 * auto-negotiation is enabled, then software will have to set the
1610 * "PAUSE" bits to the correct value in the Auto-Negotiation
1611 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
1613 * The possible values of the "fc" parameter are:
1614 * 0: Flow control is completely disabled
1615 * 1: Rx flow control is enabled (we can receive pause frames
1616 * but not send pause frames).
1617 * 2: Tx flow control is enabled (we can send pause frames
1618 * but we do not support receiving pause frames).
1619 * 3: Both Rx and TX flow control (symmetric) are enabled.
1620 * other: No software override. The flow control configuration
1621 * in the EEPROM is used.
1624 case E1000_FC_NONE
: /* 0 */
1625 /* Flow control (RX & TX) is completely disabled by a
1626 * software over-ride.
1628 mii_autoneg_adv_reg
&= ~(NWAY_AR_ASM_DIR
| NWAY_AR_PAUSE
);
1630 case E1000_FC_RX_PAUSE
: /* 1 */
1631 /* RX Flow control is enabled, and TX Flow control is
1632 * disabled, by a software over-ride.
1634 /* Since there really isn't a way to advertise that we are
1635 * capable of RX Pause ONLY, we will advertise that we
1636 * support both symmetric and asymmetric RX PAUSE. Later
1637 * (in e1000_config_fc_after_link_up) we will disable the
1638 *hw's ability to send PAUSE frames.
1640 mii_autoneg_adv_reg
|= (NWAY_AR_ASM_DIR
| NWAY_AR_PAUSE
);
1642 case E1000_FC_TX_PAUSE
: /* 2 */
1643 /* TX Flow control is enabled, and RX Flow control is
1644 * disabled, by a software over-ride.
1646 mii_autoneg_adv_reg
|= NWAY_AR_ASM_DIR
;
1647 mii_autoneg_adv_reg
&= ~NWAY_AR_PAUSE
;
1649 case E1000_FC_FULL
: /* 3 */
1650 /* Flow control (both RX and TX) is enabled by a software
1653 mii_autoneg_adv_reg
|= (NWAY_AR_ASM_DIR
| NWAY_AR_PAUSE
);
1656 e_dbg("Flow control param set incorrectly\n");
1657 return -E1000_ERR_CONFIG
;
1660 ret_val
= e1000_write_phy_reg(hw
, PHY_AUTONEG_ADV
, mii_autoneg_adv_reg
);
1664 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg
);
1666 if (hw
->phy_type
== e1000_phy_8201
) {
1667 mii_1000t_ctrl_reg
= 0;
1669 ret_val
= e1000_write_phy_reg(hw
, PHY_1000T_CTRL
,
1670 mii_1000t_ctrl_reg
);
1675 return E1000_SUCCESS
;
1679 * e1000_phy_force_speed_duplex - force link settings
1680 * @hw: Struct containing variables accessed by shared code
1682 * Force PHY speed and duplex settings to hw->forced_speed_duplex
1684 static s32
e1000_phy_force_speed_duplex(struct e1000_hw
*hw
)
1693 e_dbg("e1000_phy_force_speed_duplex");
1695 /* Turn off Flow control if we are forcing speed and duplex. */
1696 hw
->fc
= E1000_FC_NONE
;
1698 e_dbg("hw->fc = %d\n", hw
->fc
);
1700 /* Read the Device Control Register. */
1703 /* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
1704 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1705 ctrl
&= ~(DEVICE_SPEED_MASK
);
1707 /* Clear the Auto Speed Detect Enable bit. */
1708 ctrl
&= ~E1000_CTRL_ASDE
;
1710 /* Read the MII Control Register. */
1711 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &mii_ctrl_reg
);
1715 /* We need to disable autoneg in order to force link and duplex. */
1717 mii_ctrl_reg
&= ~MII_CR_AUTO_NEG_EN
;
1719 /* Are we forcing Full or Half Duplex? */
1720 if (hw
->forced_speed_duplex
== e1000_100_full
||
1721 hw
->forced_speed_duplex
== e1000_10_full
) {
1722 /* We want to force full duplex so we SET the full duplex bits in the
1723 * Device and MII Control Registers.
1725 ctrl
|= E1000_CTRL_FD
;
1726 mii_ctrl_reg
|= MII_CR_FULL_DUPLEX
;
1727 e_dbg("Full Duplex\n");
1729 /* We want to force half duplex so we CLEAR the full duplex bits in
1730 * the Device and MII Control Registers.
1732 ctrl
&= ~E1000_CTRL_FD
;
1733 mii_ctrl_reg
&= ~MII_CR_FULL_DUPLEX
;
1734 e_dbg("Half Duplex\n");
1737 /* Are we forcing 100Mbps??? */
1738 if (hw
->forced_speed_duplex
== e1000_100_full
||
1739 hw
->forced_speed_duplex
== e1000_100_half
) {
1740 /* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
1741 ctrl
|= E1000_CTRL_SPD_100
;
1742 mii_ctrl_reg
|= MII_CR_SPEED_100
;
1743 mii_ctrl_reg
&= ~(MII_CR_SPEED_1000
| MII_CR_SPEED_10
);
1744 e_dbg("Forcing 100mb ");
1746 /* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
1747 ctrl
&= ~(E1000_CTRL_SPD_1000
| E1000_CTRL_SPD_100
);
1748 mii_ctrl_reg
|= MII_CR_SPEED_10
;
1749 mii_ctrl_reg
&= ~(MII_CR_SPEED_1000
| MII_CR_SPEED_100
);
1750 e_dbg("Forcing 10mb ");
1753 e1000_config_collision_dist(hw
);
1755 /* Write the configured values back to the Device Control Reg. */
1758 if (hw
->phy_type
== e1000_phy_m88
) {
1760 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
1764 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
1765 * forced whenever speed are duplex are forced.
1767 phy_data
&= ~M88E1000_PSCR_AUTO_X_MODE
;
1769 e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
1773 e_dbg("M88E1000 PSCR: %x\n", phy_data
);
1775 /* Need to reset the PHY or these changes will be ignored */
1776 mii_ctrl_reg
|= MII_CR_RESET
;
1778 /* Disable MDI-X support for 10/100 */
1780 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
1781 * forced whenever speed or duplex are forced.
1784 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, &phy_data
);
1788 phy_data
&= ~IGP01E1000_PSCR_AUTO_MDIX
;
1789 phy_data
&= ~IGP01E1000_PSCR_FORCE_MDI_MDIX
;
1792 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CTRL
, phy_data
);
1797 /* Write back the modified PHY MII control register. */
1798 ret_val
= e1000_write_phy_reg(hw
, PHY_CTRL
, mii_ctrl_reg
);
1804 /* The wait_autoneg_complete flag may be a little misleading here.
1805 * Since we are forcing speed and duplex, Auto-Neg is not enabled.
1806 * But we do want to delay for a period while forcing only so we
1807 * don't generate false No Link messages. So we will wait here
1808 * only if the user has set wait_autoneg_complete to 1, which is
1811 if (hw
->wait_autoneg_complete
) {
1812 /* We will wait for autoneg to complete. */
1813 e_dbg("Waiting for forced speed/duplex link.\n");
1816 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
1817 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
1818 /* Read the MII Status Register and wait for Auto-Neg Complete bit
1822 e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
1827 e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
1831 if (mii_status_reg
& MII_SR_LINK_STATUS
)
1835 if ((i
== 0) && (hw
->phy_type
== e1000_phy_m88
)) {
1836 /* We didn't get link. Reset the DSP and wait again for link. */
1837 ret_val
= e1000_phy_reset_dsp(hw
);
1839 e_dbg("Error Resetting PHY DSP\n");
1843 /* This loop will early-out if the link condition has been met. */
1844 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
1845 if (mii_status_reg
& MII_SR_LINK_STATUS
)
1848 /* Read the MII Status Register and wait for Auto-Neg Complete bit
1852 e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
1857 e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
1863 if (hw
->phy_type
== e1000_phy_m88
) {
1864 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1865 * Extended PHY Specific Control Register to 25MHz clock. This value
1866 * defaults back to a 2.5MHz clock when the PHY is reset.
1869 e1000_read_phy_reg(hw
, M88E1000_EXT_PHY_SPEC_CTRL
,
1874 phy_data
|= M88E1000_EPSCR_TX_CLK_25
;
1876 e1000_write_phy_reg(hw
, M88E1000_EXT_PHY_SPEC_CTRL
,
1881 /* In addition, because of the s/w reset above, we need to enable CRS on
1882 * TX. This must be set for both full and half duplex operation.
1885 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
1889 phy_data
|= M88E1000_PSCR_ASSERT_CRS_ON_TX
;
1891 e1000_write_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, phy_data
);
1895 if ((hw
->mac_type
== e1000_82544
|| hw
->mac_type
== e1000_82543
)
1897 && (hw
->forced_speed_duplex
== e1000_10_full
1898 || hw
->forced_speed_duplex
== e1000_10_half
)) {
1899 ret_val
= e1000_polarity_reversal_workaround(hw
);
1904 return E1000_SUCCESS
;
1908 * e1000_config_collision_dist - set collision distance register
1909 * @hw: Struct containing variables accessed by shared code
1911 * Sets the collision distance in the Transmit Control register.
1912 * Link should have been established previously. Reads the speed and duplex
1913 * information from the Device Status register.
1915 void e1000_config_collision_dist(struct e1000_hw
*hw
)
1917 u32 tctl
, coll_dist
;
1919 e_dbg("e1000_config_collision_dist");
1921 if (hw
->mac_type
< e1000_82543
)
1922 coll_dist
= E1000_COLLISION_DISTANCE_82542
;
1924 coll_dist
= E1000_COLLISION_DISTANCE
;
1928 tctl
&= ~E1000_TCTL_COLD
;
1929 tctl
|= coll_dist
<< E1000_COLD_SHIFT
;
1932 E1000_WRITE_FLUSH();
1936 * e1000_config_mac_to_phy - sync phy and mac settings
1937 * @hw: Struct containing variables accessed by shared code
1938 * @mii_reg: data to write to the MII control register
1940 * Sets MAC speed and duplex settings to reflect the those in the PHY
1941 * The contents of the PHY register containing the needed information need to
1944 static s32
e1000_config_mac_to_phy(struct e1000_hw
*hw
)
1950 e_dbg("e1000_config_mac_to_phy");
1952 /* 82544 or newer MAC, Auto Speed Detection takes care of
1953 * MAC speed/duplex configuration.*/
1954 if ((hw
->mac_type
>= e1000_82544
) && (hw
->mac_type
!= e1000_ce4100
))
1955 return E1000_SUCCESS
;
1957 /* Read the Device Control Register and set the bits to Force Speed
1961 ctrl
|= (E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
1962 ctrl
&= ~(E1000_CTRL_SPD_SEL
| E1000_CTRL_ILOS
);
1964 switch (hw
->phy_type
) {
1965 case e1000_phy_8201
:
1966 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_data
);
1970 if (phy_data
& RTL_PHY_CTRL_FD
)
1971 ctrl
|= E1000_CTRL_FD
;
1973 ctrl
&= ~E1000_CTRL_FD
;
1975 if (phy_data
& RTL_PHY_CTRL_SPD_100
)
1976 ctrl
|= E1000_CTRL_SPD_100
;
1978 ctrl
|= E1000_CTRL_SPD_10
;
1980 e1000_config_collision_dist(hw
);
1983 /* Set up duplex in the Device Control and Transmit Control
1984 * registers depending on negotiated values.
1986 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
1991 if (phy_data
& M88E1000_PSSR_DPLX
)
1992 ctrl
|= E1000_CTRL_FD
;
1994 ctrl
&= ~E1000_CTRL_FD
;
1996 e1000_config_collision_dist(hw
);
1998 /* Set up speed in the Device Control register depending on
1999 * negotiated values.
2001 if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_1000MBS
)
2002 ctrl
|= E1000_CTRL_SPD_1000
;
2003 else if ((phy_data
& M88E1000_PSSR_SPEED
) ==
2004 M88E1000_PSSR_100MBS
)
2005 ctrl
|= E1000_CTRL_SPD_100
;
2008 /* Write the configured values back to the Device Control Reg. */
2010 return E1000_SUCCESS
;
2014 * e1000_force_mac_fc - force flow control settings
2015 * @hw: Struct containing variables accessed by shared code
2017 * Forces the MAC's flow control settings.
2018 * Sets the TFCE and RFCE bits in the device control register to reflect
2019 * the adapter settings. TFCE and RFCE need to be explicitly set by
2020 * software when a Copper PHY is used because autonegotiation is managed
2021 * by the PHY rather than the MAC. Software must also configure these
2022 * bits when link is forced on a fiber connection.
2024 s32
e1000_force_mac_fc(struct e1000_hw
*hw
)
2028 e_dbg("e1000_force_mac_fc");
2030 /* Get the current configuration of the Device Control Register */
2033 /* Because we didn't get link via the internal auto-negotiation
2034 * mechanism (we either forced link or we got link via PHY
2035 * auto-neg), we have to manually enable/disable transmit an
2036 * receive flow control.
2038 * The "Case" statement below enables/disable flow control
2039 * according to the "hw->fc" parameter.
2041 * The possible values of the "fc" parameter are:
2042 * 0: Flow control is completely disabled
2043 * 1: Rx flow control is enabled (we can receive pause
2044 * frames but not send pause frames).
2045 * 2: Tx flow control is enabled (we can send pause frames
2046 * frames but we do not receive pause frames).
2047 * 3: Both Rx and TX flow control (symmetric) is enabled.
2048 * other: No other values should be possible at this point.
2053 ctrl
&= (~(E1000_CTRL_TFCE
| E1000_CTRL_RFCE
));
2055 case E1000_FC_RX_PAUSE
:
2056 ctrl
&= (~E1000_CTRL_TFCE
);
2057 ctrl
|= E1000_CTRL_RFCE
;
2059 case E1000_FC_TX_PAUSE
:
2060 ctrl
&= (~E1000_CTRL_RFCE
);
2061 ctrl
|= E1000_CTRL_TFCE
;
2064 ctrl
|= (E1000_CTRL_TFCE
| E1000_CTRL_RFCE
);
2067 e_dbg("Flow control param set incorrectly\n");
2068 return -E1000_ERR_CONFIG
;
2071 /* Disable TX Flow Control for 82542 (rev 2.0) */
2072 if (hw
->mac_type
== e1000_82542_rev2_0
)
2073 ctrl
&= (~E1000_CTRL_TFCE
);
2076 return E1000_SUCCESS
;
2080 * e1000_config_fc_after_link_up - configure flow control after autoneg
2081 * @hw: Struct containing variables accessed by shared code
2083 * Configures flow control settings after link is established
2084 * Should be called immediately after a valid link has been established.
2085 * Forces MAC flow control settings if link was forced. When in MII/GMII mode
2086 * and autonegotiation is enabled, the MAC flow control settings will be set
2087 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
2088 * and RFCE bits will be automatically set to the negotiated flow control mode.
2090 static s32
e1000_config_fc_after_link_up(struct e1000_hw
*hw
)
2094 u16 mii_nway_adv_reg
;
2095 u16 mii_nway_lp_ability_reg
;
2099 e_dbg("e1000_config_fc_after_link_up");
2101 /* Check for the case where we have fiber media and auto-neg failed
2102 * so we had to force link. In this case, we need to force the
2103 * configuration of the MAC to match the "fc" parameter.
2105 if (((hw
->media_type
== e1000_media_type_fiber
) && (hw
->autoneg_failed
))
2106 || ((hw
->media_type
== e1000_media_type_internal_serdes
)
2107 && (hw
->autoneg_failed
))
2108 || ((hw
->media_type
== e1000_media_type_copper
)
2109 && (!hw
->autoneg
))) {
2110 ret_val
= e1000_force_mac_fc(hw
);
2112 e_dbg("Error forcing flow control settings\n");
2117 /* Check for the case where we have copper media and auto-neg is
2118 * enabled. In this case, we need to check and see if Auto-Neg
2119 * has completed, and if so, how the PHY and link partner has
2120 * flow control configured.
2122 if ((hw
->media_type
== e1000_media_type_copper
) && hw
->autoneg
) {
2123 /* Read the MII Status Register and check to see if AutoNeg
2124 * has completed. We read this twice because this reg has
2125 * some "sticky" (latched) bits.
2127 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2130 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
2134 if (mii_status_reg
& MII_SR_AUTONEG_COMPLETE
) {
2135 /* The AutoNeg process has completed, so we now need to
2136 * read both the Auto Negotiation Advertisement Register
2137 * (Address 4) and the Auto_Negotiation Base Page Ability
2138 * Register (Address 5) to determine how flow control was
2141 ret_val
= e1000_read_phy_reg(hw
, PHY_AUTONEG_ADV
,
2145 ret_val
= e1000_read_phy_reg(hw
, PHY_LP_ABILITY
,
2146 &mii_nway_lp_ability_reg
);
2150 /* Two bits in the Auto Negotiation Advertisement Register
2151 * (Address 4) and two bits in the Auto Negotiation Base
2152 * Page Ability Register (Address 5) determine flow control
2153 * for both the PHY and the link partner. The following
2154 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
2155 * 1999, describes these PAUSE resolution bits and how flow
2156 * control is determined based upon these settings.
2157 * NOTE: DC = Don't Care
2159 * LOCAL DEVICE | LINK PARTNER
2160 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
2161 *-------|---------|-------|---------|--------------------
2162 * 0 | 0 | DC | DC | E1000_FC_NONE
2163 * 0 | 1 | 0 | DC | E1000_FC_NONE
2164 * 0 | 1 | 1 | 0 | E1000_FC_NONE
2165 * 0 | 1 | 1 | 1 | E1000_FC_TX_PAUSE
2166 * 1 | 0 | 0 | DC | E1000_FC_NONE
2167 * 1 | DC | 1 | DC | E1000_FC_FULL
2168 * 1 | 1 | 0 | 0 | E1000_FC_NONE
2169 * 1 | 1 | 0 | 1 | E1000_FC_RX_PAUSE
2172 /* Are both PAUSE bits set to 1? If so, this implies
2173 * Symmetric Flow Control is enabled at both ends. The
2174 * ASM_DIR bits are irrelevant per the spec.
2176 * For Symmetric Flow Control:
2178 * LOCAL DEVICE | LINK PARTNER
2179 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2180 *-------|---------|-------|---------|--------------------
2181 * 1 | DC | 1 | DC | E1000_FC_FULL
2184 if ((mii_nway_adv_reg
& NWAY_AR_PAUSE
) &&
2185 (mii_nway_lp_ability_reg
& NWAY_LPAR_PAUSE
)) {
2186 /* Now we need to check if the user selected RX ONLY
2187 * of pause frames. In this case, we had to advertise
2188 * FULL flow control because we could not advertise RX
2189 * ONLY. Hence, we must now check to see if we need to
2190 * turn OFF the TRANSMISSION of PAUSE frames.
2192 if (hw
->original_fc
== E1000_FC_FULL
) {
2193 hw
->fc
= E1000_FC_FULL
;
2194 e_dbg("Flow Control = FULL.\n");
2196 hw
->fc
= E1000_FC_RX_PAUSE
;
2198 ("Flow Control = RX PAUSE frames only.\n");
2201 /* For receiving PAUSE frames ONLY.
2203 * LOCAL DEVICE | LINK PARTNER
2204 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2205 *-------|---------|-------|---------|--------------------
2206 * 0 | 1 | 1 | 1 | E1000_FC_TX_PAUSE
2209 else if (!(mii_nway_adv_reg
& NWAY_AR_PAUSE
) &&
2210 (mii_nway_adv_reg
& NWAY_AR_ASM_DIR
) &&
2211 (mii_nway_lp_ability_reg
& NWAY_LPAR_PAUSE
) &&
2212 (mii_nway_lp_ability_reg
& NWAY_LPAR_ASM_DIR
))
2214 hw
->fc
= E1000_FC_TX_PAUSE
;
2216 ("Flow Control = TX PAUSE frames only.\n");
2218 /* For transmitting PAUSE frames ONLY.
2220 * LOCAL DEVICE | LINK PARTNER
2221 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2222 *-------|---------|-------|---------|--------------------
2223 * 1 | 1 | 0 | 1 | E1000_FC_RX_PAUSE
2226 else if ((mii_nway_adv_reg
& NWAY_AR_PAUSE
) &&
2227 (mii_nway_adv_reg
& NWAY_AR_ASM_DIR
) &&
2228 !(mii_nway_lp_ability_reg
& NWAY_LPAR_PAUSE
) &&
2229 (mii_nway_lp_ability_reg
& NWAY_LPAR_ASM_DIR
))
2231 hw
->fc
= E1000_FC_RX_PAUSE
;
2233 ("Flow Control = RX PAUSE frames only.\n");
2235 /* Per the IEEE spec, at this point flow control should be
2236 * disabled. However, we want to consider that we could
2237 * be connected to a legacy switch that doesn't advertise
2238 * desired flow control, but can be forced on the link
2239 * partner. So if we advertised no flow control, that is
2240 * what we will resolve to. If we advertised some kind of
2241 * receive capability (Rx Pause Only or Full Flow Control)
2242 * and the link partner advertised none, we will configure
2243 * ourselves to enable Rx Flow Control only. We can do
2244 * this safely for two reasons: If the link partner really
2245 * didn't want flow control enabled, and we enable Rx, no
2246 * harm done since we won't be receiving any PAUSE frames
2247 * anyway. If the intent on the link partner was to have
2248 * flow control enabled, then by us enabling RX only, we
2249 * can at least receive pause frames and process them.
2250 * This is a good idea because in most cases, since we are
2251 * predominantly a server NIC, more times than not we will
2252 * be asked to delay transmission of packets than asking
2253 * our link partner to pause transmission of frames.
2255 else if ((hw
->original_fc
== E1000_FC_NONE
||
2256 hw
->original_fc
== E1000_FC_TX_PAUSE
) ||
2257 hw
->fc_strict_ieee
) {
2258 hw
->fc
= E1000_FC_NONE
;
2259 e_dbg("Flow Control = NONE.\n");
2261 hw
->fc
= E1000_FC_RX_PAUSE
;
2263 ("Flow Control = RX PAUSE frames only.\n");
2266 /* Now we need to do one last check... If we auto-
2267 * negotiated to HALF DUPLEX, flow control should not be
2268 * enabled per IEEE 802.3 spec.
2271 e1000_get_speed_and_duplex(hw
, &speed
, &duplex
);
2274 ("Error getting link speed and duplex\n");
2278 if (duplex
== HALF_DUPLEX
)
2279 hw
->fc
= E1000_FC_NONE
;
2281 /* Now we call a subroutine to actually force the MAC
2282 * controller to use the correct flow control settings.
2284 ret_val
= e1000_force_mac_fc(hw
);
2287 ("Error forcing flow control settings\n");
2292 ("Copper PHY and Auto Neg has not completed.\n");
2295 return E1000_SUCCESS
;
2299 * e1000_check_for_serdes_link_generic - Check for link (Serdes)
2300 * @hw: pointer to the HW structure
2302 * Checks for link up on the hardware. If link is not up and we have
2303 * a signal, then we need to force link up.
2305 static s32
e1000_check_for_serdes_link_generic(struct e1000_hw
*hw
)
2310 s32 ret_val
= E1000_SUCCESS
;
2312 e_dbg("e1000_check_for_serdes_link_generic");
2315 status
= er32(STATUS
);
2319 * If we don't have link (auto-negotiation failed or link partner
2320 * cannot auto-negotiate), and our link partner is not trying to
2321 * auto-negotiate with us (we are receiving idles or data),
2322 * we need to force link up. We also need to give auto-negotiation
2325 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
2326 if ((!(status
& E1000_STATUS_LU
)) && (!(rxcw
& E1000_RXCW_C
))) {
2327 if (hw
->autoneg_failed
== 0) {
2328 hw
->autoneg_failed
= 1;
2331 e_dbg("NOT RXing /C/, disable AutoNeg and force link.\n");
2333 /* Disable auto-negotiation in the TXCW register */
2334 ew32(TXCW
, (hw
->txcw
& ~E1000_TXCW_ANE
));
2336 /* Force link-up and also force full-duplex. */
2338 ctrl
|= (E1000_CTRL_SLU
| E1000_CTRL_FD
);
2341 /* Configure Flow Control after forcing link up. */
2342 ret_val
= e1000_config_fc_after_link_up(hw
);
2344 e_dbg("Error configuring flow control\n");
2347 } else if ((ctrl
& E1000_CTRL_SLU
) && (rxcw
& E1000_RXCW_C
)) {
2349 * If we are forcing link and we are receiving /C/ ordered
2350 * sets, re-enable auto-negotiation in the TXCW register
2351 * and disable forced link in the Device Control register
2352 * in an attempt to auto-negotiate with our link partner.
2354 e_dbg("RXing /C/, enable AutoNeg and stop forcing link.\n");
2355 ew32(TXCW
, hw
->txcw
);
2356 ew32(CTRL
, (ctrl
& ~E1000_CTRL_SLU
));
2358 hw
->serdes_has_link
= true;
2359 } else if (!(E1000_TXCW_ANE
& er32(TXCW
))) {
2361 * If we force link for non-auto-negotiation switch, check
2362 * link status based on MAC synchronization for internal
2363 * serdes media type.
2365 /* SYNCH bit and IV bit are sticky. */
2368 if (rxcw
& E1000_RXCW_SYNCH
) {
2369 if (!(rxcw
& E1000_RXCW_IV
)) {
2370 hw
->serdes_has_link
= true;
2371 e_dbg("SERDES: Link up - forced.\n");
2374 hw
->serdes_has_link
= false;
2375 e_dbg("SERDES: Link down - force failed.\n");
2379 if (E1000_TXCW_ANE
& er32(TXCW
)) {
2380 status
= er32(STATUS
);
2381 if (status
& E1000_STATUS_LU
) {
2382 /* SYNCH bit and IV bit are sticky, so reread rxcw. */
2385 if (rxcw
& E1000_RXCW_SYNCH
) {
2386 if (!(rxcw
& E1000_RXCW_IV
)) {
2387 hw
->serdes_has_link
= true;
2388 e_dbg("SERDES: Link up - autoneg "
2389 "completed successfully.\n");
2391 hw
->serdes_has_link
= false;
2392 e_dbg("SERDES: Link down - invalid"
2393 "codewords detected in autoneg.\n");
2396 hw
->serdes_has_link
= false;
2397 e_dbg("SERDES: Link down - no sync.\n");
2400 hw
->serdes_has_link
= false;
2401 e_dbg("SERDES: Link down - autoneg failed\n");
2410 * e1000_check_for_link
2411 * @hw: Struct containing variables accessed by shared code
2413 * Checks to see if the link status of the hardware has changed.
2414 * Called by any function that needs to check the link status of the adapter.
2416 s32
e1000_check_for_link(struct e1000_hw
*hw
)
2427 e_dbg("e1000_check_for_link");
2430 status
= er32(STATUS
);
2432 /* On adapters with a MAC newer than 82544, SW Definable pin 1 will be
2433 * set when the optics detect a signal. On older adapters, it will be
2434 * cleared when there is a signal. This applies to fiber media only.
2436 if ((hw
->media_type
== e1000_media_type_fiber
) ||
2437 (hw
->media_type
== e1000_media_type_internal_serdes
)) {
2440 if (hw
->media_type
== e1000_media_type_fiber
) {
2443 e1000_82544
) ? E1000_CTRL_SWDPIN1
: 0;
2444 if (status
& E1000_STATUS_LU
)
2445 hw
->get_link_status
= false;
2449 /* If we have a copper PHY then we only want to go out to the PHY
2450 * registers to see if Auto-Neg has completed and/or if our link
2451 * status has changed. The get_link_status flag will be set if we
2452 * receive a Link Status Change interrupt or we have Rx Sequence
2455 if ((hw
->media_type
== e1000_media_type_copper
) && hw
->get_link_status
) {
2456 /* First we want to see if the MII Status Register reports
2457 * link. If so, then we want to get the current speed/duplex
2459 * Read the register twice since the link bit is sticky.
2461 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
2464 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
2468 if (phy_data
& MII_SR_LINK_STATUS
) {
2469 hw
->get_link_status
= false;
2470 /* Check if there was DownShift, must be checked immediately after
2472 e1000_check_downshift(hw
);
2474 /* If we are on 82544 or 82543 silicon and speed/duplex
2475 * are forced to 10H or 10F, then we will implement the polarity
2476 * reversal workaround. We disable interrupts first, and upon
2477 * returning, place the devices interrupt state to its previous
2478 * value except for the link status change interrupt which will
2479 * happen due to the execution of this workaround.
2482 if ((hw
->mac_type
== e1000_82544
2483 || hw
->mac_type
== e1000_82543
) && (!hw
->autoneg
)
2484 && (hw
->forced_speed_duplex
== e1000_10_full
2485 || hw
->forced_speed_duplex
== e1000_10_half
)) {
2486 ew32(IMC
, 0xffffffff);
2488 e1000_polarity_reversal_workaround(hw
);
2490 ew32(ICS
, (icr
& ~E1000_ICS_LSC
));
2491 ew32(IMS
, IMS_ENABLE_MASK
);
2495 /* No link detected */
2496 e1000_config_dsp_after_link_change(hw
, false);
2500 /* If we are forcing speed/duplex, then we simply return since
2501 * we have already determined whether we have link or not.
2504 return -E1000_ERR_CONFIG
;
2506 /* optimize the dsp settings for the igp phy */
2507 e1000_config_dsp_after_link_change(hw
, true);
2509 /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
2510 * have Si on board that is 82544 or newer, Auto
2511 * Speed Detection takes care of MAC speed/duplex
2512 * configuration. So we only need to configure Collision
2513 * Distance in the MAC. Otherwise, we need to force
2514 * speed/duplex on the MAC to the current PHY speed/duplex
2517 if ((hw
->mac_type
>= e1000_82544
) &&
2518 (hw
->mac_type
!= e1000_ce4100
))
2519 e1000_config_collision_dist(hw
);
2521 ret_val
= e1000_config_mac_to_phy(hw
);
2524 ("Error configuring MAC to PHY settings\n");
2529 /* Configure Flow Control now that Auto-Neg has completed. First, we
2530 * need to restore the desired flow control settings because we may
2531 * have had to re-autoneg with a different link partner.
2533 ret_val
= e1000_config_fc_after_link_up(hw
);
2535 e_dbg("Error configuring flow control\n");
2539 /* At this point we know that we are on copper and we have
2540 * auto-negotiated link. These are conditions for checking the link
2541 * partner capability register. We use the link speed to determine if
2542 * TBI compatibility needs to be turned on or off. If the link is not
2543 * at gigabit speed, then TBI compatibility is not needed. If we are
2544 * at gigabit speed, we turn on TBI compatibility.
2546 if (hw
->tbi_compatibility_en
) {
2549 e1000_get_speed_and_duplex(hw
, &speed
, &duplex
);
2552 ("Error getting link speed and duplex\n");
2555 if (speed
!= SPEED_1000
) {
2556 /* If link speed is not set to gigabit speed, we do not need
2557 * to enable TBI compatibility.
2559 if (hw
->tbi_compatibility_on
) {
2560 /* If we previously were in the mode, turn it off. */
2562 rctl
&= ~E1000_RCTL_SBP
;
2564 hw
->tbi_compatibility_on
= false;
2567 /* If TBI compatibility is was previously off, turn it on. For
2568 * compatibility with a TBI link partner, we will store bad
2569 * packets. Some frames have an additional byte on the end and
2570 * will look like CRC errors to to the hardware.
2572 if (!hw
->tbi_compatibility_on
) {
2573 hw
->tbi_compatibility_on
= true;
2575 rctl
|= E1000_RCTL_SBP
;
2582 if ((hw
->media_type
== e1000_media_type_fiber
) ||
2583 (hw
->media_type
== e1000_media_type_internal_serdes
))
2584 e1000_check_for_serdes_link_generic(hw
);
2586 return E1000_SUCCESS
;
2590 * e1000_get_speed_and_duplex
2591 * @hw: Struct containing variables accessed by shared code
2592 * @speed: Speed of the connection
2593 * @duplex: Duplex setting of the connection
2595 * Detects the current speed and duplex settings of the hardware.
2597 s32
e1000_get_speed_and_duplex(struct e1000_hw
*hw
, u16
*speed
, u16
*duplex
)
2603 e_dbg("e1000_get_speed_and_duplex");
2605 if (hw
->mac_type
>= e1000_82543
) {
2606 status
= er32(STATUS
);
2607 if (status
& E1000_STATUS_SPEED_1000
) {
2608 *speed
= SPEED_1000
;
2609 e_dbg("1000 Mbs, ");
2610 } else if (status
& E1000_STATUS_SPEED_100
) {
2618 if (status
& E1000_STATUS_FD
) {
2619 *duplex
= FULL_DUPLEX
;
2620 e_dbg("Full Duplex\n");
2622 *duplex
= HALF_DUPLEX
;
2623 e_dbg(" Half Duplex\n");
2626 e_dbg("1000 Mbs, Full Duplex\n");
2627 *speed
= SPEED_1000
;
2628 *duplex
= FULL_DUPLEX
;
2631 /* IGP01 PHY may advertise full duplex operation after speed downgrade even
2632 * if it is operating at half duplex. Here we set the duplex settings to
2633 * match the duplex in the link partner's capabilities.
2635 if (hw
->phy_type
== e1000_phy_igp
&& hw
->speed_downgraded
) {
2636 ret_val
= e1000_read_phy_reg(hw
, PHY_AUTONEG_EXP
, &phy_data
);
2640 if (!(phy_data
& NWAY_ER_LP_NWAY_CAPS
))
2641 *duplex
= HALF_DUPLEX
;
2644 e1000_read_phy_reg(hw
, PHY_LP_ABILITY
, &phy_data
);
2647 if ((*speed
== SPEED_100
2648 && !(phy_data
& NWAY_LPAR_100TX_FD_CAPS
))
2649 || (*speed
== SPEED_10
2650 && !(phy_data
& NWAY_LPAR_10T_FD_CAPS
)))
2651 *duplex
= HALF_DUPLEX
;
2655 return E1000_SUCCESS
;
2659 * e1000_wait_autoneg
2660 * @hw: Struct containing variables accessed by shared code
2662 * Blocks until autoneg completes or times out (~4.5 seconds)
2664 static s32
e1000_wait_autoneg(struct e1000_hw
*hw
)
2670 e_dbg("e1000_wait_autoneg");
2671 e_dbg("Waiting for Auto-Neg to complete.\n");
2673 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
2674 for (i
= PHY_AUTO_NEG_TIME
; i
> 0; i
--) {
2675 /* Read the MII Status Register and wait for Auto-Neg
2676 * Complete bit to be set.
2678 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
2681 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
2684 if (phy_data
& MII_SR_AUTONEG_COMPLETE
) {
2685 return E1000_SUCCESS
;
2689 return E1000_SUCCESS
;
2693 * e1000_raise_mdi_clk - Raises the Management Data Clock
2694 * @hw: Struct containing variables accessed by shared code
2695 * @ctrl: Device control register's current value
2697 static void e1000_raise_mdi_clk(struct e1000_hw
*hw
, u32
*ctrl
)
2699 /* Raise the clock input to the Management Data Clock (by setting the MDC
2700 * bit), and then delay 10 microseconds.
2702 ew32(CTRL
, (*ctrl
| E1000_CTRL_MDC
));
2703 E1000_WRITE_FLUSH();
2708 * e1000_lower_mdi_clk - Lowers the Management Data Clock
2709 * @hw: Struct containing variables accessed by shared code
2710 * @ctrl: Device control register's current value
2712 static void e1000_lower_mdi_clk(struct e1000_hw
*hw
, u32
*ctrl
)
2714 /* Lower the clock input to the Management Data Clock (by clearing the MDC
2715 * bit), and then delay 10 microseconds.
2717 ew32(CTRL
, (*ctrl
& ~E1000_CTRL_MDC
));
2718 E1000_WRITE_FLUSH();
2723 * e1000_shift_out_mdi_bits - Shifts data bits out to the PHY
2724 * @hw: Struct containing variables accessed by shared code
2725 * @data: Data to send out to the PHY
2726 * @count: Number of bits to shift out
2728 * Bits are shifted out in MSB to LSB order.
2730 static void e1000_shift_out_mdi_bits(struct e1000_hw
*hw
, u32 data
, u16 count
)
2735 /* We need to shift "count" number of bits out to the PHY. So, the value
2736 * in the "data" parameter will be shifted out to the PHY one bit at a
2737 * time. In order to do this, "data" must be broken down into bits.
2740 mask
<<= (count
- 1);
2744 /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
2745 ctrl
|= (E1000_CTRL_MDIO_DIR
| E1000_CTRL_MDC_DIR
);
2748 /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
2749 * then raising and lowering the Management Data Clock. A "0" is
2750 * shifted out to the PHY by setting the MDIO bit to "0" and then
2751 * raising and lowering the clock.
2754 ctrl
|= E1000_CTRL_MDIO
;
2756 ctrl
&= ~E1000_CTRL_MDIO
;
2759 E1000_WRITE_FLUSH();
2763 e1000_raise_mdi_clk(hw
, &ctrl
);
2764 e1000_lower_mdi_clk(hw
, &ctrl
);
2771 * e1000_shift_in_mdi_bits - Shifts data bits in from the PHY
2772 * @hw: Struct containing variables accessed by shared code
2774 * Bits are shifted in in MSB to LSB order.
2776 static u16
e1000_shift_in_mdi_bits(struct e1000_hw
*hw
)
2782 /* In order to read a register from the PHY, we need to shift in a total
2783 * of 18 bits from the PHY. The first two bit (turnaround) times are used
2784 * to avoid contention on the MDIO pin when a read operation is performed.
2785 * These two bits are ignored by us and thrown away. Bits are "shifted in"
2786 * by raising the input to the Management Data Clock (setting the MDC bit),
2787 * and then reading the value of the MDIO bit.
2791 /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
2792 ctrl
&= ~E1000_CTRL_MDIO_DIR
;
2793 ctrl
&= ~E1000_CTRL_MDIO
;
2796 E1000_WRITE_FLUSH();
2798 /* Raise and Lower the clock before reading in the data. This accounts for
2799 * the turnaround bits. The first clock occurred when we clocked out the
2800 * last bit of the Register Address.
2802 e1000_raise_mdi_clk(hw
, &ctrl
);
2803 e1000_lower_mdi_clk(hw
, &ctrl
);
2805 for (data
= 0, i
= 0; i
< 16; i
++) {
2807 e1000_raise_mdi_clk(hw
, &ctrl
);
2809 /* Check to see if we shifted in a "1". */
2810 if (ctrl
& E1000_CTRL_MDIO
)
2812 e1000_lower_mdi_clk(hw
, &ctrl
);
2815 e1000_raise_mdi_clk(hw
, &ctrl
);
2816 e1000_lower_mdi_clk(hw
, &ctrl
);
2823 * e1000_read_phy_reg - read a phy register
2824 * @hw: Struct containing variables accessed by shared code
2825 * @reg_addr: address of the PHY register to read
2827 * Reads the value from a PHY register, if the value is on a specific non zero
2828 * page, sets the page first.
2830 s32
e1000_read_phy_reg(struct e1000_hw
*hw
, u32 reg_addr
, u16
*phy_data
)
2834 e_dbg("e1000_read_phy_reg");
2836 if ((hw
->phy_type
== e1000_phy_igp
) &&
2837 (reg_addr
> MAX_PHY_MULTI_PAGE_REG
)) {
2838 ret_val
= e1000_write_phy_reg_ex(hw
, IGP01E1000_PHY_PAGE_SELECT
,
2844 ret_val
= e1000_read_phy_reg_ex(hw
, MAX_PHY_REG_ADDRESS
& reg_addr
,
2850 static s32
e1000_read_phy_reg_ex(struct e1000_hw
*hw
, u32 reg_addr
,
2855 const u32 phy_addr
= (hw
->mac_type
== e1000_ce4100
) ? hw
->phy_addr
: 1;
2857 e_dbg("e1000_read_phy_reg_ex");
2859 if (reg_addr
> MAX_PHY_REG_ADDRESS
) {
2860 e_dbg("PHY Address %d is out of range\n", reg_addr
);
2861 return -E1000_ERR_PARAM
;
2864 if (hw
->mac_type
> e1000_82543
) {
2865 /* Set up Op-code, Phy Address, and register address in the MDI
2866 * Control register. The MAC will take care of interfacing with the
2867 * PHY to retrieve the desired data.
2869 if (hw
->mac_type
== e1000_ce4100
) {
2870 mdic
= ((reg_addr
<< E1000_MDIC_REG_SHIFT
) |
2871 (phy_addr
<< E1000_MDIC_PHY_SHIFT
) |
2872 (INTEL_CE_GBE_MDIC_OP_READ
) |
2873 (INTEL_CE_GBE_MDIC_GO
));
2875 writel(mdic
, E1000_MDIO_CMD
);
2877 /* Poll the ready bit to see if the MDI read
2880 for (i
= 0; i
< 64; i
++) {
2882 mdic
= readl(E1000_MDIO_CMD
);
2883 if (!(mdic
& INTEL_CE_GBE_MDIC_GO
))
2887 if (mdic
& INTEL_CE_GBE_MDIC_GO
) {
2888 e_dbg("MDI Read did not complete\n");
2889 return -E1000_ERR_PHY
;
2892 mdic
= readl(E1000_MDIO_STS
);
2893 if (mdic
& INTEL_CE_GBE_MDIC_READ_ERROR
) {
2894 e_dbg("MDI Read Error\n");
2895 return -E1000_ERR_PHY
;
2897 *phy_data
= (u16
) mdic
;
2899 mdic
= ((reg_addr
<< E1000_MDIC_REG_SHIFT
) |
2900 (phy_addr
<< E1000_MDIC_PHY_SHIFT
) |
2901 (E1000_MDIC_OP_READ
));
2905 /* Poll the ready bit to see if the MDI read
2908 for (i
= 0; i
< 64; i
++) {
2911 if (mdic
& E1000_MDIC_READY
)
2914 if (!(mdic
& E1000_MDIC_READY
)) {
2915 e_dbg("MDI Read did not complete\n");
2916 return -E1000_ERR_PHY
;
2918 if (mdic
& E1000_MDIC_ERROR
) {
2919 e_dbg("MDI Error\n");
2920 return -E1000_ERR_PHY
;
2922 *phy_data
= (u16
) mdic
;
2925 /* We must first send a preamble through the MDIO pin to signal the
2926 * beginning of an MII instruction. This is done by sending 32
2927 * consecutive "1" bits.
2929 e1000_shift_out_mdi_bits(hw
, PHY_PREAMBLE
, PHY_PREAMBLE_SIZE
);
2931 /* Now combine the next few fields that are required for a read
2932 * operation. We use this method instead of calling the
2933 * e1000_shift_out_mdi_bits routine five different times. The format of
2934 * a MII read instruction consists of a shift out of 14 bits and is
2935 * defined as follows:
2936 * <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
2937 * followed by a shift in of 18 bits. This first two bits shifted in
2938 * are TurnAround bits used to avoid contention on the MDIO pin when a
2939 * READ operation is performed. These two bits are thrown away
2940 * followed by a shift in of 16 bits which contains the desired data.
2942 mdic
= ((reg_addr
) | (phy_addr
<< 5) |
2943 (PHY_OP_READ
<< 10) | (PHY_SOF
<< 12));
2945 e1000_shift_out_mdi_bits(hw
, mdic
, 14);
2947 /* Now that we've shifted out the read command to the MII, we need to
2948 * "shift in" the 16-bit value (18 total bits) of the requested PHY
2951 *phy_data
= e1000_shift_in_mdi_bits(hw
);
2953 return E1000_SUCCESS
;
2957 * e1000_write_phy_reg - write a phy register
2959 * @hw: Struct containing variables accessed by shared code
2960 * @reg_addr: address of the PHY register to write
2961 * @data: data to write to the PHY
2963 * Writes a value to a PHY register
2965 s32
e1000_write_phy_reg(struct e1000_hw
*hw
, u32 reg_addr
, u16 phy_data
)
2969 e_dbg("e1000_write_phy_reg");
2971 if ((hw
->phy_type
== e1000_phy_igp
) &&
2972 (reg_addr
> MAX_PHY_MULTI_PAGE_REG
)) {
2973 ret_val
= e1000_write_phy_reg_ex(hw
, IGP01E1000_PHY_PAGE_SELECT
,
2979 ret_val
= e1000_write_phy_reg_ex(hw
, MAX_PHY_REG_ADDRESS
& reg_addr
,
2985 static s32
e1000_write_phy_reg_ex(struct e1000_hw
*hw
, u32 reg_addr
,
2990 const u32 phy_addr
= (hw
->mac_type
== e1000_ce4100
) ? hw
->phy_addr
: 1;
2992 e_dbg("e1000_write_phy_reg_ex");
2994 if (reg_addr
> MAX_PHY_REG_ADDRESS
) {
2995 e_dbg("PHY Address %d is out of range\n", reg_addr
);
2996 return -E1000_ERR_PARAM
;
2999 if (hw
->mac_type
> e1000_82543
) {
3000 /* Set up Op-code, Phy Address, register address, and data
3001 * intended for the PHY register in the MDI Control register.
3002 * The MAC will take care of interfacing with the PHY to send
3005 if (hw
->mac_type
== e1000_ce4100
) {
3006 mdic
= (((u32
) phy_data
) |
3007 (reg_addr
<< E1000_MDIC_REG_SHIFT
) |
3008 (phy_addr
<< E1000_MDIC_PHY_SHIFT
) |
3009 (INTEL_CE_GBE_MDIC_OP_WRITE
) |
3010 (INTEL_CE_GBE_MDIC_GO
));
3012 writel(mdic
, E1000_MDIO_CMD
);
3014 /* Poll the ready bit to see if the MDI read
3017 for (i
= 0; i
< 640; i
++) {
3019 mdic
= readl(E1000_MDIO_CMD
);
3020 if (!(mdic
& INTEL_CE_GBE_MDIC_GO
))
3023 if (mdic
& INTEL_CE_GBE_MDIC_GO
) {
3024 e_dbg("MDI Write did not complete\n");
3025 return -E1000_ERR_PHY
;
3028 mdic
= (((u32
) phy_data
) |
3029 (reg_addr
<< E1000_MDIC_REG_SHIFT
) |
3030 (phy_addr
<< E1000_MDIC_PHY_SHIFT
) |
3031 (E1000_MDIC_OP_WRITE
));
3035 /* Poll the ready bit to see if the MDI read
3038 for (i
= 0; i
< 641; i
++) {
3041 if (mdic
& E1000_MDIC_READY
)
3044 if (!(mdic
& E1000_MDIC_READY
)) {
3045 e_dbg("MDI Write did not complete\n");
3046 return -E1000_ERR_PHY
;
3050 /* We'll need to use the SW defined pins to shift the write command
3051 * out to the PHY. We first send a preamble to the PHY to signal the
3052 * beginning of the MII instruction. This is done by sending 32
3053 * consecutive "1" bits.
3055 e1000_shift_out_mdi_bits(hw
, PHY_PREAMBLE
, PHY_PREAMBLE_SIZE
);
3057 /* Now combine the remaining required fields that will indicate a
3058 * write operation. We use this method instead of calling the
3059 * e1000_shift_out_mdi_bits routine for each field in the command. The
3060 * format of a MII write instruction is as follows:
3061 * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
3063 mdic
= ((PHY_TURNAROUND
) | (reg_addr
<< 2) | (phy_addr
<< 7) |
3064 (PHY_OP_WRITE
<< 12) | (PHY_SOF
<< 14));
3066 mdic
|= (u32
) phy_data
;
3068 e1000_shift_out_mdi_bits(hw
, mdic
, 32);
3071 return E1000_SUCCESS
;
3075 * e1000_phy_hw_reset - reset the phy, hardware style
3076 * @hw: Struct containing variables accessed by shared code
3078 * Returns the PHY to the power-on reset state
3080 s32
e1000_phy_hw_reset(struct e1000_hw
*hw
)
3085 e_dbg("e1000_phy_hw_reset");
3087 e_dbg("Resetting Phy...\n");
3089 if (hw
->mac_type
> e1000_82543
) {
3090 /* Read the device control register and assert the E1000_CTRL_PHY_RST
3091 * bit. Then, take it out of reset.
3092 * For e1000 hardware, we delay for 10ms between the assert
3096 ew32(CTRL
, ctrl
| E1000_CTRL_PHY_RST
);
3097 E1000_WRITE_FLUSH();
3102 E1000_WRITE_FLUSH();
3105 /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
3106 * bit to put the PHY into reset. Then, take it out of reset.
3108 ctrl_ext
= er32(CTRL_EXT
);
3109 ctrl_ext
|= E1000_CTRL_EXT_SDP4_DIR
;
3110 ctrl_ext
&= ~E1000_CTRL_EXT_SDP4_DATA
;
3111 ew32(CTRL_EXT
, ctrl_ext
);
3112 E1000_WRITE_FLUSH();
3114 ctrl_ext
|= E1000_CTRL_EXT_SDP4_DATA
;
3115 ew32(CTRL_EXT
, ctrl_ext
);
3116 E1000_WRITE_FLUSH();
3120 if ((hw
->mac_type
== e1000_82541
) || (hw
->mac_type
== e1000_82547
)) {
3121 /* Configure activity LED after PHY reset */
3122 led_ctrl
= er32(LEDCTL
);
3123 led_ctrl
&= IGP_ACTIVITY_LED_MASK
;
3124 led_ctrl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
3125 ew32(LEDCTL
, led_ctrl
);
3128 /* Wait for FW to finish PHY configuration. */
3129 return e1000_get_phy_cfg_done(hw
);
3133 * e1000_phy_reset - reset the phy to commit settings
3134 * @hw: Struct containing variables accessed by shared code
3137 * Sets bit 15 of the MII Control register
3139 s32
e1000_phy_reset(struct e1000_hw
*hw
)
3144 e_dbg("e1000_phy_reset");
3146 switch (hw
->phy_type
) {
3148 ret_val
= e1000_phy_hw_reset(hw
);
3153 ret_val
= e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_data
);
3157 phy_data
|= MII_CR_RESET
;
3158 ret_val
= e1000_write_phy_reg(hw
, PHY_CTRL
, phy_data
);
3166 if (hw
->phy_type
== e1000_phy_igp
)
3167 e1000_phy_init_script(hw
);
3169 return E1000_SUCCESS
;
3173 * e1000_detect_gig_phy - check the phy type
3174 * @hw: Struct containing variables accessed by shared code
3176 * Probes the expected PHY address for known PHY IDs
3178 static s32
e1000_detect_gig_phy(struct e1000_hw
*hw
)
3180 s32 phy_init_status
, ret_val
;
3181 u16 phy_id_high
, phy_id_low
;
3184 e_dbg("e1000_detect_gig_phy");
3186 if (hw
->phy_id
!= 0)
3187 return E1000_SUCCESS
;
3189 /* Read the PHY ID Registers to identify which PHY is onboard. */
3190 ret_val
= e1000_read_phy_reg(hw
, PHY_ID1
, &phy_id_high
);
3194 hw
->phy_id
= (u32
) (phy_id_high
<< 16);
3196 ret_val
= e1000_read_phy_reg(hw
, PHY_ID2
, &phy_id_low
);
3200 hw
->phy_id
|= (u32
) (phy_id_low
& PHY_REVISION_MASK
);
3201 hw
->phy_revision
= (u32
) phy_id_low
& ~PHY_REVISION_MASK
;
3203 switch (hw
->mac_type
) {
3205 if (hw
->phy_id
== M88E1000_E_PHY_ID
)
3209 if (hw
->phy_id
== M88E1000_I_PHY_ID
)
3214 case e1000_82545_rev_3
:
3216 case e1000_82546_rev_3
:
3217 if (hw
->phy_id
== M88E1011_I_PHY_ID
)
3221 if ((hw
->phy_id
== RTL8211B_PHY_ID
) ||
3222 (hw
->phy_id
== RTL8201N_PHY_ID
) ||
3223 (hw
->phy_id
== M88E1118_E_PHY_ID
))
3227 case e1000_82541_rev_2
:
3229 case e1000_82547_rev_2
:
3230 if (hw
->phy_id
== IGP01E1000_I_PHY_ID
)
3234 e_dbg("Invalid MAC type %d\n", hw
->mac_type
);
3235 return -E1000_ERR_CONFIG
;
3237 phy_init_status
= e1000_set_phy_type(hw
);
3239 if ((match
) && (phy_init_status
== E1000_SUCCESS
)) {
3240 e_dbg("PHY ID 0x%X detected\n", hw
->phy_id
);
3241 return E1000_SUCCESS
;
3243 e_dbg("Invalid PHY ID 0x%X\n", hw
->phy_id
);
3244 return -E1000_ERR_PHY
;
3248 * e1000_phy_reset_dsp - reset DSP
3249 * @hw: Struct containing variables accessed by shared code
3251 * Resets the PHY's DSP
3253 static s32
e1000_phy_reset_dsp(struct e1000_hw
*hw
)
3256 e_dbg("e1000_phy_reset_dsp");
3259 ret_val
= e1000_write_phy_reg(hw
, 29, 0x001d);
3262 ret_val
= e1000_write_phy_reg(hw
, 30, 0x00c1);
3265 ret_val
= e1000_write_phy_reg(hw
, 30, 0x0000);
3268 ret_val
= E1000_SUCCESS
;
3275 * e1000_phy_igp_get_info - get igp specific registers
3276 * @hw: Struct containing variables accessed by shared code
3277 * @phy_info: PHY information structure
3279 * Get PHY information from various PHY registers for igp PHY only.
3281 static s32
e1000_phy_igp_get_info(struct e1000_hw
*hw
,
3282 struct e1000_phy_info
*phy_info
)
3285 u16 phy_data
, min_length
, max_length
, average
;
3286 e1000_rev_polarity polarity
;
3288 e_dbg("e1000_phy_igp_get_info");
3290 /* The downshift status is checked only once, after link is established,
3291 * and it stored in the hw->speed_downgraded parameter. */
3292 phy_info
->downshift
= (e1000_downshift
) hw
->speed_downgraded
;
3294 /* IGP01E1000 does not need to support it. */
3295 phy_info
->extended_10bt_distance
= e1000_10bt_ext_dist_enable_normal
;
3297 /* IGP01E1000 always correct polarity reversal */
3298 phy_info
->polarity_correction
= e1000_polarity_reversal_enabled
;
3300 /* Check polarity status */
3301 ret_val
= e1000_check_polarity(hw
, &polarity
);
3305 phy_info
->cable_polarity
= polarity
;
3307 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_STATUS
, &phy_data
);
3311 phy_info
->mdix_mode
=
3312 (e1000_auto_x_mode
) ((phy_data
& IGP01E1000_PSSR_MDIX
) >>
3313 IGP01E1000_PSSR_MDIX_SHIFT
);
3315 if ((phy_data
& IGP01E1000_PSSR_SPEED_MASK
) ==
3316 IGP01E1000_PSSR_SPEED_1000MBPS
) {
3317 /* Local/Remote Receiver Information are only valid at 1000 Mbps */
3318 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
3322 phy_info
->local_rx
= ((phy_data
& SR_1000T_LOCAL_RX_STATUS
) >>
3323 SR_1000T_LOCAL_RX_STATUS_SHIFT
) ?
3324 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
3325 phy_info
->remote_rx
= ((phy_data
& SR_1000T_REMOTE_RX_STATUS
) >>
3326 SR_1000T_REMOTE_RX_STATUS_SHIFT
) ?
3327 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
3329 /* Get cable length */
3330 ret_val
= e1000_get_cable_length(hw
, &min_length
, &max_length
);
3334 /* Translate to old method */
3335 average
= (max_length
+ min_length
) / 2;
3337 if (average
<= e1000_igp_cable_length_50
)
3338 phy_info
->cable_length
= e1000_cable_length_50
;
3339 else if (average
<= e1000_igp_cable_length_80
)
3340 phy_info
->cable_length
= e1000_cable_length_50_80
;
3341 else if (average
<= e1000_igp_cable_length_110
)
3342 phy_info
->cable_length
= e1000_cable_length_80_110
;
3343 else if (average
<= e1000_igp_cable_length_140
)
3344 phy_info
->cable_length
= e1000_cable_length_110_140
;
3346 phy_info
->cable_length
= e1000_cable_length_140
;
3349 return E1000_SUCCESS
;
3353 * e1000_phy_m88_get_info - get m88 specific registers
3354 * @hw: Struct containing variables accessed by shared code
3355 * @phy_info: PHY information structure
3357 * Get PHY information from various PHY registers for m88 PHY only.
3359 static s32
e1000_phy_m88_get_info(struct e1000_hw
*hw
,
3360 struct e1000_phy_info
*phy_info
)
3364 e1000_rev_polarity polarity
;
3366 e_dbg("e1000_phy_m88_get_info");
3368 /* The downshift status is checked only once, after link is established,
3369 * and it stored in the hw->speed_downgraded parameter. */
3370 phy_info
->downshift
= (e1000_downshift
) hw
->speed_downgraded
;
3372 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
3376 phy_info
->extended_10bt_distance
=
3377 ((phy_data
& M88E1000_PSCR_10BT_EXT_DIST_ENABLE
) >>
3378 M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT
) ?
3379 e1000_10bt_ext_dist_enable_lower
:
3380 e1000_10bt_ext_dist_enable_normal
;
3382 phy_info
->polarity_correction
=
3383 ((phy_data
& M88E1000_PSCR_POLARITY_REVERSAL
) >>
3384 M88E1000_PSCR_POLARITY_REVERSAL_SHIFT
) ?
3385 e1000_polarity_reversal_disabled
: e1000_polarity_reversal_enabled
;
3387 /* Check polarity status */
3388 ret_val
= e1000_check_polarity(hw
, &polarity
);
3391 phy_info
->cable_polarity
= polarity
;
3393 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
, &phy_data
);
3397 phy_info
->mdix_mode
=
3398 (e1000_auto_x_mode
) ((phy_data
& M88E1000_PSSR_MDIX
) >>
3399 M88E1000_PSSR_MDIX_SHIFT
);
3401 if ((phy_data
& M88E1000_PSSR_SPEED
) == M88E1000_PSSR_1000MBS
) {
3402 /* Cable Length Estimation and Local/Remote Receiver Information
3403 * are only valid at 1000 Mbps.
3405 phy_info
->cable_length
=
3406 (e1000_cable_length
) ((phy_data
&
3407 M88E1000_PSSR_CABLE_LENGTH
) >>
3408 M88E1000_PSSR_CABLE_LENGTH_SHIFT
);
3410 ret_val
= e1000_read_phy_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
3414 phy_info
->local_rx
= ((phy_data
& SR_1000T_LOCAL_RX_STATUS
) >>
3415 SR_1000T_LOCAL_RX_STATUS_SHIFT
) ?
3416 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
3417 phy_info
->remote_rx
= ((phy_data
& SR_1000T_REMOTE_RX_STATUS
) >>
3418 SR_1000T_REMOTE_RX_STATUS_SHIFT
) ?
3419 e1000_1000t_rx_status_ok
: e1000_1000t_rx_status_not_ok
;
3423 return E1000_SUCCESS
;
3427 * e1000_phy_get_info - request phy info
3428 * @hw: Struct containing variables accessed by shared code
3429 * @phy_info: PHY information structure
3431 * Get PHY information from various PHY registers
3433 s32
e1000_phy_get_info(struct e1000_hw
*hw
, struct e1000_phy_info
*phy_info
)
3438 e_dbg("e1000_phy_get_info");
3440 phy_info
->cable_length
= e1000_cable_length_undefined
;
3441 phy_info
->extended_10bt_distance
= e1000_10bt_ext_dist_enable_undefined
;
3442 phy_info
->cable_polarity
= e1000_rev_polarity_undefined
;
3443 phy_info
->downshift
= e1000_downshift_undefined
;
3444 phy_info
->polarity_correction
= e1000_polarity_reversal_undefined
;
3445 phy_info
->mdix_mode
= e1000_auto_x_mode_undefined
;
3446 phy_info
->local_rx
= e1000_1000t_rx_status_undefined
;
3447 phy_info
->remote_rx
= e1000_1000t_rx_status_undefined
;
3449 if (hw
->media_type
!= e1000_media_type_copper
) {
3450 e_dbg("PHY info is only valid for copper media\n");
3451 return -E1000_ERR_CONFIG
;
3454 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
3458 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &phy_data
);
3462 if ((phy_data
& MII_SR_LINK_STATUS
) != MII_SR_LINK_STATUS
) {
3463 e_dbg("PHY info is only valid if link is up\n");
3464 return -E1000_ERR_CONFIG
;
3467 if (hw
->phy_type
== e1000_phy_igp
)
3468 return e1000_phy_igp_get_info(hw
, phy_info
);
3469 else if ((hw
->phy_type
== e1000_phy_8211
) ||
3470 (hw
->phy_type
== e1000_phy_8201
))
3471 return E1000_SUCCESS
;
3473 return e1000_phy_m88_get_info(hw
, phy_info
);
3476 s32
e1000_validate_mdi_setting(struct e1000_hw
*hw
)
3478 e_dbg("e1000_validate_mdi_settings");
3480 if (!hw
->autoneg
&& (hw
->mdix
== 0 || hw
->mdix
== 3)) {
3481 e_dbg("Invalid MDI setting detected\n");
3483 return -E1000_ERR_CONFIG
;
3485 return E1000_SUCCESS
;
3489 * e1000_init_eeprom_params - initialize sw eeprom vars
3490 * @hw: Struct containing variables accessed by shared code
3492 * Sets up eeprom variables in the hw struct. Must be called after mac_type
3495 s32
e1000_init_eeprom_params(struct e1000_hw
*hw
)
3497 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
3498 u32 eecd
= er32(EECD
);
3499 s32 ret_val
= E1000_SUCCESS
;
3502 e_dbg("e1000_init_eeprom_params");
3504 switch (hw
->mac_type
) {
3505 case e1000_82542_rev2_0
:
3506 case e1000_82542_rev2_1
:
3509 eeprom
->type
= e1000_eeprom_microwire
;
3510 eeprom
->word_size
= 64;
3511 eeprom
->opcode_bits
= 3;
3512 eeprom
->address_bits
= 6;
3513 eeprom
->delay_usec
= 50;
3517 case e1000_82545_rev_3
:
3519 case e1000_82546_rev_3
:
3520 eeprom
->type
= e1000_eeprom_microwire
;
3521 eeprom
->opcode_bits
= 3;
3522 eeprom
->delay_usec
= 50;
3523 if (eecd
& E1000_EECD_SIZE
) {
3524 eeprom
->word_size
= 256;
3525 eeprom
->address_bits
= 8;
3527 eeprom
->word_size
= 64;
3528 eeprom
->address_bits
= 6;
3532 case e1000_82541_rev_2
:
3534 case e1000_82547_rev_2
:
3535 if (eecd
& E1000_EECD_TYPE
) {
3536 eeprom
->type
= e1000_eeprom_spi
;
3537 eeprom
->opcode_bits
= 8;
3538 eeprom
->delay_usec
= 1;
3539 if (eecd
& E1000_EECD_ADDR_BITS
) {
3540 eeprom
->page_size
= 32;
3541 eeprom
->address_bits
= 16;
3543 eeprom
->page_size
= 8;
3544 eeprom
->address_bits
= 8;
3547 eeprom
->type
= e1000_eeprom_microwire
;
3548 eeprom
->opcode_bits
= 3;
3549 eeprom
->delay_usec
= 50;
3550 if (eecd
& E1000_EECD_ADDR_BITS
) {
3551 eeprom
->word_size
= 256;
3552 eeprom
->address_bits
= 8;
3554 eeprom
->word_size
= 64;
3555 eeprom
->address_bits
= 6;
3563 if (eeprom
->type
== e1000_eeprom_spi
) {
3564 /* eeprom_size will be an enum [0..8] that maps to eeprom sizes 128B to
3565 * 32KB (incremented by powers of 2).
3567 /* Set to default value for initial eeprom read. */
3568 eeprom
->word_size
= 64;
3569 ret_val
= e1000_read_eeprom(hw
, EEPROM_CFG
, 1, &eeprom_size
);
3573 (eeprom_size
& EEPROM_SIZE_MASK
) >> EEPROM_SIZE_SHIFT
;
3574 /* 256B eeprom size was not supported in earlier hardware, so we
3575 * bump eeprom_size up one to ensure that "1" (which maps to 256B)
3576 * is never the result used in the shifting logic below. */
3580 eeprom
->word_size
= 1 << (eeprom_size
+ EEPROM_WORD_SIZE_SHIFT
);
3586 * e1000_raise_ee_clk - Raises the EEPROM's clock input.
3587 * @hw: Struct containing variables accessed by shared code
3588 * @eecd: EECD's current value
3590 static void e1000_raise_ee_clk(struct e1000_hw
*hw
, u32
*eecd
)
3592 /* Raise the clock input to the EEPROM (by setting the SK bit), and then
3593 * wait <delay> microseconds.
3595 *eecd
= *eecd
| E1000_EECD_SK
;
3597 E1000_WRITE_FLUSH();
3598 udelay(hw
->eeprom
.delay_usec
);
3602 * e1000_lower_ee_clk - Lowers the EEPROM's clock input.
3603 * @hw: Struct containing variables accessed by shared code
3604 * @eecd: EECD's current value
3606 static void e1000_lower_ee_clk(struct e1000_hw
*hw
, u32
*eecd
)
3608 /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
3609 * wait 50 microseconds.
3611 *eecd
= *eecd
& ~E1000_EECD_SK
;
3613 E1000_WRITE_FLUSH();
3614 udelay(hw
->eeprom
.delay_usec
);
3618 * e1000_shift_out_ee_bits - Shift data bits out to the EEPROM.
3619 * @hw: Struct containing variables accessed by shared code
3620 * @data: data to send to the EEPROM
3621 * @count: number of bits to shift out
3623 static void e1000_shift_out_ee_bits(struct e1000_hw
*hw
, u16 data
, u16 count
)
3625 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
3629 /* We need to shift "count" bits out to the EEPROM. So, value in the
3630 * "data" parameter will be shifted out to the EEPROM one bit at a time.
3631 * In order to do this, "data" must be broken down into bits.
3633 mask
= 0x01 << (count
- 1);
3635 if (eeprom
->type
== e1000_eeprom_microwire
) {
3636 eecd
&= ~E1000_EECD_DO
;
3637 } else if (eeprom
->type
== e1000_eeprom_spi
) {
3638 eecd
|= E1000_EECD_DO
;
3641 /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
3642 * and then raising and then lowering the clock (the SK bit controls
3643 * the clock input to the EEPROM). A "0" is shifted out to the EEPROM
3644 * by setting "DI" to "0" and then raising and then lowering the clock.
3646 eecd
&= ~E1000_EECD_DI
;
3649 eecd
|= E1000_EECD_DI
;
3652 E1000_WRITE_FLUSH();
3654 udelay(eeprom
->delay_usec
);
3656 e1000_raise_ee_clk(hw
, &eecd
);
3657 e1000_lower_ee_clk(hw
, &eecd
);
3663 /* We leave the "DI" bit set to "0" when we leave this routine. */
3664 eecd
&= ~E1000_EECD_DI
;
3669 * e1000_shift_in_ee_bits - Shift data bits in from the EEPROM
3670 * @hw: Struct containing variables accessed by shared code
3671 * @count: number of bits to shift in
3673 static u16
e1000_shift_in_ee_bits(struct e1000_hw
*hw
, u16 count
)
3679 /* In order to read a register from the EEPROM, we need to shift 'count'
3680 * bits in from the EEPROM. Bits are "shifted in" by raising the clock
3681 * input to the EEPROM (setting the SK bit), and then reading the value of
3682 * the "DO" bit. During this "shifting in" process the "DI" bit should
3688 eecd
&= ~(E1000_EECD_DO
| E1000_EECD_DI
);
3691 for (i
= 0; i
< count
; i
++) {
3693 e1000_raise_ee_clk(hw
, &eecd
);
3697 eecd
&= ~(E1000_EECD_DI
);
3698 if (eecd
& E1000_EECD_DO
)
3701 e1000_lower_ee_clk(hw
, &eecd
);
3708 * e1000_acquire_eeprom - Prepares EEPROM for access
3709 * @hw: Struct containing variables accessed by shared code
3711 * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
3712 * function should be called before issuing a command to the EEPROM.
3714 static s32
e1000_acquire_eeprom(struct e1000_hw
*hw
)
3716 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
3719 e_dbg("e1000_acquire_eeprom");
3723 /* Request EEPROM Access */
3724 if (hw
->mac_type
> e1000_82544
) {
3725 eecd
|= E1000_EECD_REQ
;
3728 while ((!(eecd
& E1000_EECD_GNT
)) &&
3729 (i
< E1000_EEPROM_GRANT_ATTEMPTS
)) {
3734 if (!(eecd
& E1000_EECD_GNT
)) {
3735 eecd
&= ~E1000_EECD_REQ
;
3737 e_dbg("Could not acquire EEPROM grant\n");
3738 return -E1000_ERR_EEPROM
;
3742 /* Setup EEPROM for Read/Write */
3744 if (eeprom
->type
== e1000_eeprom_microwire
) {
3745 /* Clear SK and DI */
3746 eecd
&= ~(E1000_EECD_DI
| E1000_EECD_SK
);
3750 eecd
|= E1000_EECD_CS
;
3752 } else if (eeprom
->type
== e1000_eeprom_spi
) {
3753 /* Clear SK and CS */
3754 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_SK
);
3756 E1000_WRITE_FLUSH();
3760 return E1000_SUCCESS
;
3764 * e1000_standby_eeprom - Returns EEPROM to a "standby" state
3765 * @hw: Struct containing variables accessed by shared code
3767 static void e1000_standby_eeprom(struct e1000_hw
*hw
)
3769 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
3774 if (eeprom
->type
== e1000_eeprom_microwire
) {
3775 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_SK
);
3777 E1000_WRITE_FLUSH();
3778 udelay(eeprom
->delay_usec
);
3781 eecd
|= E1000_EECD_SK
;
3783 E1000_WRITE_FLUSH();
3784 udelay(eeprom
->delay_usec
);
3787 eecd
|= E1000_EECD_CS
;
3789 E1000_WRITE_FLUSH();
3790 udelay(eeprom
->delay_usec
);
3793 eecd
&= ~E1000_EECD_SK
;
3795 E1000_WRITE_FLUSH();
3796 udelay(eeprom
->delay_usec
);
3797 } else if (eeprom
->type
== e1000_eeprom_spi
) {
3798 /* Toggle CS to flush commands */
3799 eecd
|= E1000_EECD_CS
;
3801 E1000_WRITE_FLUSH();
3802 udelay(eeprom
->delay_usec
);
3803 eecd
&= ~E1000_EECD_CS
;
3805 E1000_WRITE_FLUSH();
3806 udelay(eeprom
->delay_usec
);
3811 * e1000_release_eeprom - drop chip select
3812 * @hw: Struct containing variables accessed by shared code
3814 * Terminates a command by inverting the EEPROM's chip select pin
3816 static void e1000_release_eeprom(struct e1000_hw
*hw
)
3820 e_dbg("e1000_release_eeprom");
3824 if (hw
->eeprom
.type
== e1000_eeprom_spi
) {
3825 eecd
|= E1000_EECD_CS
; /* Pull CS high */
3826 eecd
&= ~E1000_EECD_SK
; /* Lower SCK */
3829 E1000_WRITE_FLUSH();
3831 udelay(hw
->eeprom
.delay_usec
);
3832 } else if (hw
->eeprom
.type
== e1000_eeprom_microwire
) {
3833 /* cleanup eeprom */
3835 /* CS on Microwire is active-high */
3836 eecd
&= ~(E1000_EECD_CS
| E1000_EECD_DI
);
3840 /* Rising edge of clock */
3841 eecd
|= E1000_EECD_SK
;
3843 E1000_WRITE_FLUSH();
3844 udelay(hw
->eeprom
.delay_usec
);
3846 /* Falling edge of clock */
3847 eecd
&= ~E1000_EECD_SK
;
3849 E1000_WRITE_FLUSH();
3850 udelay(hw
->eeprom
.delay_usec
);
3853 /* Stop requesting EEPROM access */
3854 if (hw
->mac_type
> e1000_82544
) {
3855 eecd
&= ~E1000_EECD_REQ
;
3861 * e1000_spi_eeprom_ready - Reads a 16 bit word from the EEPROM.
3862 * @hw: Struct containing variables accessed by shared code
3864 static s32
e1000_spi_eeprom_ready(struct e1000_hw
*hw
)
3866 u16 retry_count
= 0;
3869 e_dbg("e1000_spi_eeprom_ready");
3871 /* Read "Status Register" repeatedly until the LSB is cleared. The
3872 * EEPROM will signal that the command has been completed by clearing
3873 * bit 0 of the internal status register. If it's not cleared within
3874 * 5 milliseconds, then error out.
3878 e1000_shift_out_ee_bits(hw
, EEPROM_RDSR_OPCODE_SPI
,
3879 hw
->eeprom
.opcode_bits
);
3880 spi_stat_reg
= (u8
) e1000_shift_in_ee_bits(hw
, 8);
3881 if (!(spi_stat_reg
& EEPROM_STATUS_RDY_SPI
))
3887 e1000_standby_eeprom(hw
);
3888 } while (retry_count
< EEPROM_MAX_RETRY_SPI
);
3890 /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
3891 * only 0-5mSec on 5V devices)
3893 if (retry_count
>= EEPROM_MAX_RETRY_SPI
) {
3894 e_dbg("SPI EEPROM Status error\n");
3895 return -E1000_ERR_EEPROM
;
3898 return E1000_SUCCESS
;
3902 * e1000_read_eeprom - Reads a 16 bit word from the EEPROM.
3903 * @hw: Struct containing variables accessed by shared code
3904 * @offset: offset of word in the EEPROM to read
3905 * @data: word read from the EEPROM
3906 * @words: number of words to read
3908 s32
e1000_read_eeprom(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
3911 spin_lock(&e1000_eeprom_lock
);
3912 ret
= e1000_do_read_eeprom(hw
, offset
, words
, data
);
3913 spin_unlock(&e1000_eeprom_lock
);
3917 static s32
e1000_do_read_eeprom(struct e1000_hw
*hw
, u16 offset
, u16 words
,
3920 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
3923 e_dbg("e1000_read_eeprom");
3925 if (hw
->mac_type
== e1000_ce4100
) {
3926 GBE_CONFIG_FLASH_READ(GBE_CONFIG_BASE_VIRT
, offset
, words
,
3928 return E1000_SUCCESS
;
3931 /* If eeprom is not yet detected, do so now */
3932 if (eeprom
->word_size
== 0)
3933 e1000_init_eeprom_params(hw
);
3935 /* A check for invalid values: offset too large, too many words, and not
3938 if ((offset
>= eeprom
->word_size
)
3939 || (words
> eeprom
->word_size
- offset
) || (words
== 0)) {
3940 e_dbg("\"words\" parameter out of bounds. Words = %d,"
3941 "size = %d\n", offset
, eeprom
->word_size
);
3942 return -E1000_ERR_EEPROM
;
3945 /* EEPROM's that don't use EERD to read require us to bit-bang the SPI
3946 * directly. In this case, we need to acquire the EEPROM so that
3947 * FW or other port software does not interrupt.
3949 /* Prepare the EEPROM for bit-bang reading */
3950 if (e1000_acquire_eeprom(hw
) != E1000_SUCCESS
)
3951 return -E1000_ERR_EEPROM
;
3953 /* Set up the SPI or Microwire EEPROM for bit-bang reading. We have
3954 * acquired the EEPROM at this point, so any returns should release it */
3955 if (eeprom
->type
== e1000_eeprom_spi
) {
3957 u8 read_opcode
= EEPROM_READ_OPCODE_SPI
;
3959 if (e1000_spi_eeprom_ready(hw
)) {
3960 e1000_release_eeprom(hw
);
3961 return -E1000_ERR_EEPROM
;
3964 e1000_standby_eeprom(hw
);
3966 /* Some SPI eeproms use the 8th address bit embedded in the opcode */
3967 if ((eeprom
->address_bits
== 8) && (offset
>= 128))
3968 read_opcode
|= EEPROM_A8_OPCODE_SPI
;
3970 /* Send the READ command (opcode + addr) */
3971 e1000_shift_out_ee_bits(hw
, read_opcode
, eeprom
->opcode_bits
);
3972 e1000_shift_out_ee_bits(hw
, (u16
) (offset
* 2),
3973 eeprom
->address_bits
);
3975 /* Read the data. The address of the eeprom internally increments with
3976 * each byte (spi) being read, saving on the overhead of eeprom setup
3977 * and tear-down. The address counter will roll over if reading beyond
3978 * the size of the eeprom, thus allowing the entire memory to be read
3979 * starting from any offset. */
3980 for (i
= 0; i
< words
; i
++) {
3981 word_in
= e1000_shift_in_ee_bits(hw
, 16);
3982 data
[i
] = (word_in
>> 8) | (word_in
<< 8);
3984 } else if (eeprom
->type
== e1000_eeprom_microwire
) {
3985 for (i
= 0; i
< words
; i
++) {
3986 /* Send the READ command (opcode + addr) */
3987 e1000_shift_out_ee_bits(hw
,
3988 EEPROM_READ_OPCODE_MICROWIRE
,
3989 eeprom
->opcode_bits
);
3990 e1000_shift_out_ee_bits(hw
, (u16
) (offset
+ i
),
3991 eeprom
->address_bits
);
3993 /* Read the data. For microwire, each word requires the overhead
3994 * of eeprom setup and tear-down. */
3995 data
[i
] = e1000_shift_in_ee_bits(hw
, 16);
3996 e1000_standby_eeprom(hw
);
4000 /* End this read operation */
4001 e1000_release_eeprom(hw
);
4003 return E1000_SUCCESS
;
4007 * e1000_validate_eeprom_checksum - Verifies that the EEPROM has a valid checksum
4008 * @hw: Struct containing variables accessed by shared code
4010 * Reads the first 64 16 bit words of the EEPROM and sums the values read.
4011 * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
4014 s32
e1000_validate_eeprom_checksum(struct e1000_hw
*hw
)
4019 e_dbg("e1000_validate_eeprom_checksum");
4021 for (i
= 0; i
< (EEPROM_CHECKSUM_REG
+ 1); i
++) {
4022 if (e1000_read_eeprom(hw
, i
, 1, &eeprom_data
) < 0) {
4023 e_dbg("EEPROM Read Error\n");
4024 return -E1000_ERR_EEPROM
;
4026 checksum
+= eeprom_data
;
4029 if (checksum
== (u16
) EEPROM_SUM
)
4030 return E1000_SUCCESS
;
4032 e_dbg("EEPROM Checksum Invalid\n");
4033 return -E1000_ERR_EEPROM
;
4038 * e1000_update_eeprom_checksum - Calculates/writes the EEPROM checksum
4039 * @hw: Struct containing variables accessed by shared code
4041 * Sums the first 63 16 bit words of the EEPROM. Subtracts the sum from 0xBABA.
4042 * Writes the difference to word offset 63 of the EEPROM.
4044 s32
e1000_update_eeprom_checksum(struct e1000_hw
*hw
)
4049 e_dbg("e1000_update_eeprom_checksum");
4051 for (i
= 0; i
< EEPROM_CHECKSUM_REG
; i
++) {
4052 if (e1000_read_eeprom(hw
, i
, 1, &eeprom_data
) < 0) {
4053 e_dbg("EEPROM Read Error\n");
4054 return -E1000_ERR_EEPROM
;
4056 checksum
+= eeprom_data
;
4058 checksum
= (u16
) EEPROM_SUM
- checksum
;
4059 if (e1000_write_eeprom(hw
, EEPROM_CHECKSUM_REG
, 1, &checksum
) < 0) {
4060 e_dbg("EEPROM Write Error\n");
4061 return -E1000_ERR_EEPROM
;
4063 return E1000_SUCCESS
;
4067 * e1000_write_eeprom - write words to the different EEPROM types.
4068 * @hw: Struct containing variables accessed by shared code
4069 * @offset: offset within the EEPROM to be written to
4070 * @words: number of words to write
4071 * @data: 16 bit word to be written to the EEPROM
4073 * If e1000_update_eeprom_checksum is not called after this function, the
4074 * EEPROM will most likely contain an invalid checksum.
4076 s32
e1000_write_eeprom(struct e1000_hw
*hw
, u16 offset
, u16 words
, u16
*data
)
4079 spin_lock(&e1000_eeprom_lock
);
4080 ret
= e1000_do_write_eeprom(hw
, offset
, words
, data
);
4081 spin_unlock(&e1000_eeprom_lock
);
4085 static s32
e1000_do_write_eeprom(struct e1000_hw
*hw
, u16 offset
, u16 words
,
4088 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4091 e_dbg("e1000_write_eeprom");
4093 if (hw
->mac_type
== e1000_ce4100
) {
4094 GBE_CONFIG_FLASH_WRITE(GBE_CONFIG_BASE_VIRT
, offset
, words
,
4096 return E1000_SUCCESS
;
4099 /* If eeprom is not yet detected, do so now */
4100 if (eeprom
->word_size
== 0)
4101 e1000_init_eeprom_params(hw
);
4103 /* A check for invalid values: offset too large, too many words, and not
4106 if ((offset
>= eeprom
->word_size
)
4107 || (words
> eeprom
->word_size
- offset
) || (words
== 0)) {
4108 e_dbg("\"words\" parameter out of bounds\n");
4109 return -E1000_ERR_EEPROM
;
4112 /* Prepare the EEPROM for writing */
4113 if (e1000_acquire_eeprom(hw
) != E1000_SUCCESS
)
4114 return -E1000_ERR_EEPROM
;
4116 if (eeprom
->type
== e1000_eeprom_microwire
) {
4117 status
= e1000_write_eeprom_microwire(hw
, offset
, words
, data
);
4119 status
= e1000_write_eeprom_spi(hw
, offset
, words
, data
);
4123 /* Done with writing */
4124 e1000_release_eeprom(hw
);
4130 * e1000_write_eeprom_spi - Writes a 16 bit word to a given offset in an SPI EEPROM.
4131 * @hw: Struct containing variables accessed by shared code
4132 * @offset: offset within the EEPROM to be written to
4133 * @words: number of words to write
4134 * @data: pointer to array of 8 bit words to be written to the EEPROM
4136 static s32
e1000_write_eeprom_spi(struct e1000_hw
*hw
, u16 offset
, u16 words
,
4139 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4142 e_dbg("e1000_write_eeprom_spi");
4144 while (widx
< words
) {
4145 u8 write_opcode
= EEPROM_WRITE_OPCODE_SPI
;
4147 if (e1000_spi_eeprom_ready(hw
))
4148 return -E1000_ERR_EEPROM
;
4150 e1000_standby_eeprom(hw
);
4152 /* Send the WRITE ENABLE command (8 bit opcode ) */
4153 e1000_shift_out_ee_bits(hw
, EEPROM_WREN_OPCODE_SPI
,
4154 eeprom
->opcode_bits
);
4156 e1000_standby_eeprom(hw
);
4158 /* Some SPI eeproms use the 8th address bit embedded in the opcode */
4159 if ((eeprom
->address_bits
== 8) && (offset
>= 128))
4160 write_opcode
|= EEPROM_A8_OPCODE_SPI
;
4162 /* Send the Write command (8-bit opcode + addr) */
4163 e1000_shift_out_ee_bits(hw
, write_opcode
, eeprom
->opcode_bits
);
4165 e1000_shift_out_ee_bits(hw
, (u16
) ((offset
+ widx
) * 2),
4166 eeprom
->address_bits
);
4170 /* Loop to allow for up to whole page write (32 bytes) of eeprom */
4171 while (widx
< words
) {
4172 u16 word_out
= data
[widx
];
4173 word_out
= (word_out
>> 8) | (word_out
<< 8);
4174 e1000_shift_out_ee_bits(hw
, word_out
, 16);
4177 /* Some larger eeprom sizes are capable of a 32-byte PAGE WRITE
4178 * operation, while the smaller eeproms are capable of an 8-byte
4179 * PAGE WRITE operation. Break the inner loop to pass new address
4181 if ((((offset
+ widx
) * 2) % eeprom
->page_size
) == 0) {
4182 e1000_standby_eeprom(hw
);
4188 return E1000_SUCCESS
;
4192 * e1000_write_eeprom_microwire - Writes a 16 bit word to a given offset in a Microwire EEPROM.
4193 * @hw: Struct containing variables accessed by shared code
4194 * @offset: offset within the EEPROM to be written to
4195 * @words: number of words to write
4196 * @data: pointer to array of 8 bit words to be written to the EEPROM
4198 static s32
e1000_write_eeprom_microwire(struct e1000_hw
*hw
, u16 offset
,
4199 u16 words
, u16
*data
)
4201 struct e1000_eeprom_info
*eeprom
= &hw
->eeprom
;
4203 u16 words_written
= 0;
4206 e_dbg("e1000_write_eeprom_microwire");
4208 /* Send the write enable command to the EEPROM (3-bit opcode plus
4209 * 6/8-bit dummy address beginning with 11). It's less work to include
4210 * the 11 of the dummy address as part of the opcode than it is to shift
4211 * it over the correct number of bits for the address. This puts the
4212 * EEPROM into write/erase mode.
4214 e1000_shift_out_ee_bits(hw
, EEPROM_EWEN_OPCODE_MICROWIRE
,
4215 (u16
) (eeprom
->opcode_bits
+ 2));
4217 e1000_shift_out_ee_bits(hw
, 0, (u16
) (eeprom
->address_bits
- 2));
4219 /* Prepare the EEPROM */
4220 e1000_standby_eeprom(hw
);
4222 while (words_written
< words
) {
4223 /* Send the Write command (3-bit opcode + addr) */
4224 e1000_shift_out_ee_bits(hw
, EEPROM_WRITE_OPCODE_MICROWIRE
,
4225 eeprom
->opcode_bits
);
4227 e1000_shift_out_ee_bits(hw
, (u16
) (offset
+ words_written
),
4228 eeprom
->address_bits
);
4231 e1000_shift_out_ee_bits(hw
, data
[words_written
], 16);
4233 /* Toggle the CS line. This in effect tells the EEPROM to execute
4234 * the previous command.
4236 e1000_standby_eeprom(hw
);
4238 /* Read DO repeatedly until it is high (equal to '1'). The EEPROM will
4239 * signal that the command has been completed by raising the DO signal.
4240 * If DO does not go high in 10 milliseconds, then error out.
4242 for (i
= 0; i
< 200; i
++) {
4244 if (eecd
& E1000_EECD_DO
)
4249 e_dbg("EEPROM Write did not complete\n");
4250 return -E1000_ERR_EEPROM
;
4253 /* Recover from write */
4254 e1000_standby_eeprom(hw
);
4259 /* Send the write disable command to the EEPROM (3-bit opcode plus
4260 * 6/8-bit dummy address beginning with 10). It's less work to include
4261 * the 10 of the dummy address as part of the opcode than it is to shift
4262 * it over the correct number of bits for the address. This takes the
4263 * EEPROM out of write/erase mode.
4265 e1000_shift_out_ee_bits(hw
, EEPROM_EWDS_OPCODE_MICROWIRE
,
4266 (u16
) (eeprom
->opcode_bits
+ 2));
4268 e1000_shift_out_ee_bits(hw
, 0, (u16
) (eeprom
->address_bits
- 2));
4270 return E1000_SUCCESS
;
4274 * e1000_read_mac_addr - read the adapters MAC from eeprom
4275 * @hw: Struct containing variables accessed by shared code
4277 * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
4278 * second function of dual function devices
4280 s32
e1000_read_mac_addr(struct e1000_hw
*hw
)
4285 e_dbg("e1000_read_mac_addr");
4287 for (i
= 0; i
< NODE_ADDRESS_SIZE
; i
+= 2) {
4289 if (e1000_read_eeprom(hw
, offset
, 1, &eeprom_data
) < 0) {
4290 e_dbg("EEPROM Read Error\n");
4291 return -E1000_ERR_EEPROM
;
4293 hw
->perm_mac_addr
[i
] = (u8
) (eeprom_data
& 0x00FF);
4294 hw
->perm_mac_addr
[i
+ 1] = (u8
) (eeprom_data
>> 8);
4297 switch (hw
->mac_type
) {
4301 case e1000_82546_rev_3
:
4302 if (er32(STATUS
) & E1000_STATUS_FUNC_1
)
4303 hw
->perm_mac_addr
[5] ^= 0x01;
4307 for (i
= 0; i
< NODE_ADDRESS_SIZE
; i
++)
4308 hw
->mac_addr
[i
] = hw
->perm_mac_addr
[i
];
4309 return E1000_SUCCESS
;
4313 * e1000_init_rx_addrs - Initializes receive address filters.
4314 * @hw: Struct containing variables accessed by shared code
4316 * Places the MAC address in receive address register 0 and clears the rest
4317 * of the receive address registers. Clears the multicast table. Assumes
4318 * the receiver is in reset when the routine is called.
4320 static void e1000_init_rx_addrs(struct e1000_hw
*hw
)
4325 e_dbg("e1000_init_rx_addrs");
4327 /* Setup the receive address. */
4328 e_dbg("Programming MAC Address into RAR[0]\n");
4330 e1000_rar_set(hw
, hw
->mac_addr
, 0);
4332 rar_num
= E1000_RAR_ENTRIES
;
4334 /* Zero out the other 15 receive addresses. */
4335 e_dbg("Clearing RAR[1-15]\n");
4336 for (i
= 1; i
< rar_num
; i
++) {
4337 E1000_WRITE_REG_ARRAY(hw
, RA
, (i
<< 1), 0);
4338 E1000_WRITE_FLUSH();
4339 E1000_WRITE_REG_ARRAY(hw
, RA
, ((i
<< 1) + 1), 0);
4340 E1000_WRITE_FLUSH();
4345 * e1000_hash_mc_addr - Hashes an address to determine its location in the multicast table
4346 * @hw: Struct containing variables accessed by shared code
4347 * @mc_addr: the multicast address to hash
4349 u32
e1000_hash_mc_addr(struct e1000_hw
*hw
, u8
*mc_addr
)
4353 /* The portion of the address that is used for the hash table is
4354 * determined by the mc_filter_type setting.
4356 switch (hw
->mc_filter_type
) {
4357 /* [0] [1] [2] [3] [4] [5]
4362 /* [47:36] i.e. 0x563 for above example address */
4363 hash_value
= ((mc_addr
[4] >> 4) | (((u16
) mc_addr
[5]) << 4));
4366 /* [46:35] i.e. 0xAC6 for above example address */
4367 hash_value
= ((mc_addr
[4] >> 3) | (((u16
) mc_addr
[5]) << 5));
4370 /* [45:34] i.e. 0x5D8 for above example address */
4371 hash_value
= ((mc_addr
[4] >> 2) | (((u16
) mc_addr
[5]) << 6));
4374 /* [43:32] i.e. 0x634 for above example address */
4375 hash_value
= ((mc_addr
[4]) | (((u16
) mc_addr
[5]) << 8));
4379 hash_value
&= 0xFFF;
4384 * e1000_rar_set - Puts an ethernet address into a receive address register.
4385 * @hw: Struct containing variables accessed by shared code
4386 * @addr: Address to put into receive address register
4387 * @index: Receive address register to write
4389 void e1000_rar_set(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
4391 u32 rar_low
, rar_high
;
4393 /* HW expects these in little endian so we reverse the byte order
4394 * from network order (big endian) to little endian
4396 rar_low
= ((u32
) addr
[0] | ((u32
) addr
[1] << 8) |
4397 ((u32
) addr
[2] << 16) | ((u32
) addr
[3] << 24));
4398 rar_high
= ((u32
) addr
[4] | ((u32
) addr
[5] << 8));
4400 /* Disable Rx and flush all Rx frames before enabling RSS to avoid Rx
4404 * If there are any Rx frames queued up or otherwise present in the HW
4405 * before RSS is enabled, and then we enable RSS, the HW Rx unit will
4406 * hang. To work around this issue, we have to disable receives and
4407 * flush out all Rx frames before we enable RSS. To do so, we modify we
4408 * redirect all Rx traffic to manageability and then reset the HW.
4409 * This flushes away Rx frames, and (since the redirections to
4410 * manageability persists across resets) keeps new ones from coming in
4411 * while we work. Then, we clear the Address Valid AV bit for all MAC
4412 * addresses and undo the re-direction to manageability.
4413 * Now, frames are coming in again, but the MAC won't accept them, so
4414 * far so good. We now proceed to initialize RSS (if necessary) and
4415 * configure the Rx unit. Last, we re-enable the AV bits and continue
4418 switch (hw
->mac_type
) {
4420 /* Indicate to hardware the Address is Valid. */
4421 rar_high
|= E1000_RAH_AV
;
4425 E1000_WRITE_REG_ARRAY(hw
, RA
, (index
<< 1), rar_low
);
4426 E1000_WRITE_FLUSH();
4427 E1000_WRITE_REG_ARRAY(hw
, RA
, ((index
<< 1) + 1), rar_high
);
4428 E1000_WRITE_FLUSH();
4432 * e1000_write_vfta - Writes a value to the specified offset in the VLAN filter table.
4433 * @hw: Struct containing variables accessed by shared code
4434 * @offset: Offset in VLAN filer table to write
4435 * @value: Value to write into VLAN filter table
4437 void e1000_write_vfta(struct e1000_hw
*hw
, u32 offset
, u32 value
)
4441 if ((hw
->mac_type
== e1000_82544
) && ((offset
& 0x1) == 1)) {
4442 temp
= E1000_READ_REG_ARRAY(hw
, VFTA
, (offset
- 1));
4443 E1000_WRITE_REG_ARRAY(hw
, VFTA
, offset
, value
);
4444 E1000_WRITE_FLUSH();
4445 E1000_WRITE_REG_ARRAY(hw
, VFTA
, (offset
- 1), temp
);
4446 E1000_WRITE_FLUSH();
4448 E1000_WRITE_REG_ARRAY(hw
, VFTA
, offset
, value
);
4449 E1000_WRITE_FLUSH();
4454 * e1000_clear_vfta - Clears the VLAN filer table
4455 * @hw: Struct containing variables accessed by shared code
4457 static void e1000_clear_vfta(struct e1000_hw
*hw
)
4461 u32 vfta_offset
= 0;
4462 u32 vfta_bit_in_reg
= 0;
4464 for (offset
= 0; offset
< E1000_VLAN_FILTER_TBL_SIZE
; offset
++) {
4465 /* If the offset we want to clear is the same offset of the
4466 * manageability VLAN ID, then clear all bits except that of the
4467 * manageability unit */
4468 vfta_value
= (offset
== vfta_offset
) ? vfta_bit_in_reg
: 0;
4469 E1000_WRITE_REG_ARRAY(hw
, VFTA
, offset
, vfta_value
);
4470 E1000_WRITE_FLUSH();
4474 static s32
e1000_id_led_init(struct e1000_hw
*hw
)
4477 const u32 ledctl_mask
= 0x000000FF;
4478 const u32 ledctl_on
= E1000_LEDCTL_MODE_LED_ON
;
4479 const u32 ledctl_off
= E1000_LEDCTL_MODE_LED_OFF
;
4480 u16 eeprom_data
, i
, temp
;
4481 const u16 led_mask
= 0x0F;
4483 e_dbg("e1000_id_led_init");
4485 if (hw
->mac_type
< e1000_82540
) {
4487 return E1000_SUCCESS
;
4490 ledctl
= er32(LEDCTL
);
4491 hw
->ledctl_default
= ledctl
;
4492 hw
->ledctl_mode1
= hw
->ledctl_default
;
4493 hw
->ledctl_mode2
= hw
->ledctl_default
;
4495 if (e1000_read_eeprom(hw
, EEPROM_ID_LED_SETTINGS
, 1, &eeprom_data
) < 0) {
4496 e_dbg("EEPROM Read Error\n");
4497 return -E1000_ERR_EEPROM
;
4500 if ((eeprom_data
== ID_LED_RESERVED_0000
) ||
4501 (eeprom_data
== ID_LED_RESERVED_FFFF
)) {
4502 eeprom_data
= ID_LED_DEFAULT
;
4505 for (i
= 0; i
< 4; i
++) {
4506 temp
= (eeprom_data
>> (i
<< 2)) & led_mask
;
4508 case ID_LED_ON1_DEF2
:
4509 case ID_LED_ON1_ON2
:
4510 case ID_LED_ON1_OFF2
:
4511 hw
->ledctl_mode1
&= ~(ledctl_mask
<< (i
<< 3));
4512 hw
->ledctl_mode1
|= ledctl_on
<< (i
<< 3);
4514 case ID_LED_OFF1_DEF2
:
4515 case ID_LED_OFF1_ON2
:
4516 case ID_LED_OFF1_OFF2
:
4517 hw
->ledctl_mode1
&= ~(ledctl_mask
<< (i
<< 3));
4518 hw
->ledctl_mode1
|= ledctl_off
<< (i
<< 3);
4525 case ID_LED_DEF1_ON2
:
4526 case ID_LED_ON1_ON2
:
4527 case ID_LED_OFF1_ON2
:
4528 hw
->ledctl_mode2
&= ~(ledctl_mask
<< (i
<< 3));
4529 hw
->ledctl_mode2
|= ledctl_on
<< (i
<< 3);
4531 case ID_LED_DEF1_OFF2
:
4532 case ID_LED_ON1_OFF2
:
4533 case ID_LED_OFF1_OFF2
:
4534 hw
->ledctl_mode2
&= ~(ledctl_mask
<< (i
<< 3));
4535 hw
->ledctl_mode2
|= ledctl_off
<< (i
<< 3);
4542 return E1000_SUCCESS
;
4547 * @hw: Struct containing variables accessed by shared code
4549 * Prepares SW controlable LED for use and saves the current state of the LED.
4551 s32
e1000_setup_led(struct e1000_hw
*hw
)
4554 s32 ret_val
= E1000_SUCCESS
;
4556 e_dbg("e1000_setup_led");
4558 switch (hw
->mac_type
) {
4559 case e1000_82542_rev2_0
:
4560 case e1000_82542_rev2_1
:
4563 /* No setup necessary */
4567 case e1000_82541_rev_2
:
4568 case e1000_82547_rev_2
:
4569 /* Turn off PHY Smart Power Down (if enabled) */
4570 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
4571 &hw
->phy_spd_default
);
4574 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
4575 (u16
) (hw
->phy_spd_default
&
4576 ~IGP01E1000_GMII_SPD
));
4581 if (hw
->media_type
== e1000_media_type_fiber
) {
4582 ledctl
= er32(LEDCTL
);
4583 /* Save current LEDCTL settings */
4584 hw
->ledctl_default
= ledctl
;
4586 ledctl
&= ~(E1000_LEDCTL_LED0_IVRT
|
4587 E1000_LEDCTL_LED0_BLINK
|
4588 E1000_LEDCTL_LED0_MODE_MASK
);
4589 ledctl
|= (E1000_LEDCTL_MODE_LED_OFF
<<
4590 E1000_LEDCTL_LED0_MODE_SHIFT
);
4591 ew32(LEDCTL
, ledctl
);
4592 } else if (hw
->media_type
== e1000_media_type_copper
)
4593 ew32(LEDCTL
, hw
->ledctl_mode1
);
4597 return E1000_SUCCESS
;
4601 * e1000_cleanup_led - Restores the saved state of the SW controlable LED.
4602 * @hw: Struct containing variables accessed by shared code
4604 s32
e1000_cleanup_led(struct e1000_hw
*hw
)
4606 s32 ret_val
= E1000_SUCCESS
;
4608 e_dbg("e1000_cleanup_led");
4610 switch (hw
->mac_type
) {
4611 case e1000_82542_rev2_0
:
4612 case e1000_82542_rev2_1
:
4615 /* No cleanup necessary */
4619 case e1000_82541_rev_2
:
4620 case e1000_82547_rev_2
:
4621 /* Turn on PHY Smart Power Down (if previously enabled) */
4622 ret_val
= e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
4623 hw
->phy_spd_default
);
4628 /* Restore LEDCTL settings */
4629 ew32(LEDCTL
, hw
->ledctl_default
);
4633 return E1000_SUCCESS
;
4637 * e1000_led_on - Turns on the software controllable LED
4638 * @hw: Struct containing variables accessed by shared code
4640 s32
e1000_led_on(struct e1000_hw
*hw
)
4642 u32 ctrl
= er32(CTRL
);
4644 e_dbg("e1000_led_on");
4646 switch (hw
->mac_type
) {
4647 case e1000_82542_rev2_0
:
4648 case e1000_82542_rev2_1
:
4650 /* Set SW Defineable Pin 0 to turn on the LED */
4651 ctrl
|= E1000_CTRL_SWDPIN0
;
4652 ctrl
|= E1000_CTRL_SWDPIO0
;
4655 if (hw
->media_type
== e1000_media_type_fiber
) {
4656 /* Set SW Defineable Pin 0 to turn on the LED */
4657 ctrl
|= E1000_CTRL_SWDPIN0
;
4658 ctrl
|= E1000_CTRL_SWDPIO0
;
4660 /* Clear SW Defineable Pin 0 to turn on the LED */
4661 ctrl
&= ~E1000_CTRL_SWDPIN0
;
4662 ctrl
|= E1000_CTRL_SWDPIO0
;
4666 if (hw
->media_type
== e1000_media_type_fiber
) {
4667 /* Clear SW Defineable Pin 0 to turn on the LED */
4668 ctrl
&= ~E1000_CTRL_SWDPIN0
;
4669 ctrl
|= E1000_CTRL_SWDPIO0
;
4670 } else if (hw
->media_type
== e1000_media_type_copper
) {
4671 ew32(LEDCTL
, hw
->ledctl_mode2
);
4672 return E1000_SUCCESS
;
4679 return E1000_SUCCESS
;
4683 * e1000_led_off - Turns off the software controllable LED
4684 * @hw: Struct containing variables accessed by shared code
4686 s32
e1000_led_off(struct e1000_hw
*hw
)
4688 u32 ctrl
= er32(CTRL
);
4690 e_dbg("e1000_led_off");
4692 switch (hw
->mac_type
) {
4693 case e1000_82542_rev2_0
:
4694 case e1000_82542_rev2_1
:
4696 /* Clear SW Defineable Pin 0 to turn off the LED */
4697 ctrl
&= ~E1000_CTRL_SWDPIN0
;
4698 ctrl
|= E1000_CTRL_SWDPIO0
;
4701 if (hw
->media_type
== e1000_media_type_fiber
) {
4702 /* Clear SW Defineable Pin 0 to turn off the LED */
4703 ctrl
&= ~E1000_CTRL_SWDPIN0
;
4704 ctrl
|= E1000_CTRL_SWDPIO0
;
4706 /* Set SW Defineable Pin 0 to turn off the LED */
4707 ctrl
|= E1000_CTRL_SWDPIN0
;
4708 ctrl
|= E1000_CTRL_SWDPIO0
;
4712 if (hw
->media_type
== e1000_media_type_fiber
) {
4713 /* Set SW Defineable Pin 0 to turn off the LED */
4714 ctrl
|= E1000_CTRL_SWDPIN0
;
4715 ctrl
|= E1000_CTRL_SWDPIO0
;
4716 } else if (hw
->media_type
== e1000_media_type_copper
) {
4717 ew32(LEDCTL
, hw
->ledctl_mode1
);
4718 return E1000_SUCCESS
;
4725 return E1000_SUCCESS
;
4729 * e1000_clear_hw_cntrs - Clears all hardware statistics counters.
4730 * @hw: Struct containing variables accessed by shared code
4732 static void e1000_clear_hw_cntrs(struct e1000_hw
*hw
)
4736 temp
= er32(CRCERRS
);
4737 temp
= er32(SYMERRS
);
4742 temp
= er32(LATECOL
);
4747 temp
= er32(XONRXC
);
4748 temp
= er32(XONTXC
);
4749 temp
= er32(XOFFRXC
);
4750 temp
= er32(XOFFTXC
);
4754 temp
= er32(PRC127
);
4755 temp
= er32(PRC255
);
4756 temp
= er32(PRC511
);
4757 temp
= er32(PRC1023
);
4758 temp
= er32(PRC1522
);
4781 temp
= er32(PTC127
);
4782 temp
= er32(PTC255
);
4783 temp
= er32(PTC511
);
4784 temp
= er32(PTC1023
);
4785 temp
= er32(PTC1522
);
4790 if (hw
->mac_type
< e1000_82543
)
4793 temp
= er32(ALGNERRC
);
4794 temp
= er32(RXERRC
);
4796 temp
= er32(CEXTERR
);
4798 temp
= er32(TSCTFC
);
4800 if (hw
->mac_type
<= e1000_82544
)
4803 temp
= er32(MGTPRC
);
4804 temp
= er32(MGTPDC
);
4805 temp
= er32(MGTPTC
);
4809 * e1000_reset_adaptive - Resets Adaptive IFS to its default state.
4810 * @hw: Struct containing variables accessed by shared code
4812 * Call this after e1000_init_hw. You may override the IFS defaults by setting
4813 * hw->ifs_params_forced to true. However, you must initialize hw->
4814 * current_ifs_val, ifs_min_val, ifs_max_val, ifs_step_size, and ifs_ratio
4815 * before calling this function.
4817 void e1000_reset_adaptive(struct e1000_hw
*hw
)
4819 e_dbg("e1000_reset_adaptive");
4821 if (hw
->adaptive_ifs
) {
4822 if (!hw
->ifs_params_forced
) {
4823 hw
->current_ifs_val
= 0;
4824 hw
->ifs_min_val
= IFS_MIN
;
4825 hw
->ifs_max_val
= IFS_MAX
;
4826 hw
->ifs_step_size
= IFS_STEP
;
4827 hw
->ifs_ratio
= IFS_RATIO
;
4829 hw
->in_ifs_mode
= false;
4832 e_dbg("Not in Adaptive IFS mode!\n");
4837 * e1000_update_adaptive - update adaptive IFS
4838 * @hw: Struct containing variables accessed by shared code
4839 * @tx_packets: Number of transmits since last callback
4840 * @total_collisions: Number of collisions since last callback
4842 * Called during the callback/watchdog routine to update IFS value based on
4843 * the ratio of transmits to collisions.
4845 void e1000_update_adaptive(struct e1000_hw
*hw
)
4847 e_dbg("e1000_update_adaptive");
4849 if (hw
->adaptive_ifs
) {
4850 if ((hw
->collision_delta
*hw
->ifs_ratio
) > hw
->tx_packet_delta
) {
4851 if (hw
->tx_packet_delta
> MIN_NUM_XMITS
) {
4852 hw
->in_ifs_mode
= true;
4853 if (hw
->current_ifs_val
< hw
->ifs_max_val
) {
4854 if (hw
->current_ifs_val
== 0)
4855 hw
->current_ifs_val
=
4858 hw
->current_ifs_val
+=
4860 ew32(AIT
, hw
->current_ifs_val
);
4865 && (hw
->tx_packet_delta
<= MIN_NUM_XMITS
)) {
4866 hw
->current_ifs_val
= 0;
4867 hw
->in_ifs_mode
= false;
4872 e_dbg("Not in Adaptive IFS mode!\n");
4877 * e1000_tbi_adjust_stats
4878 * @hw: Struct containing variables accessed by shared code
4879 * @frame_len: The length of the frame in question
4880 * @mac_addr: The Ethernet destination address of the frame in question
4882 * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT
4884 void e1000_tbi_adjust_stats(struct e1000_hw
*hw
, struct e1000_hw_stats
*stats
,
4885 u32 frame_len
, u8
*mac_addr
)
4889 /* First adjust the frame length. */
4891 /* We need to adjust the statistics counters, since the hardware
4892 * counters overcount this packet as a CRC error and undercount
4893 * the packet as a good packet
4895 /* This packet should not be counted as a CRC error. */
4897 /* This packet does count as a Good Packet Received. */
4900 /* Adjust the Good Octets received counters */
4901 carry_bit
= 0x80000000 & stats
->gorcl
;
4902 stats
->gorcl
+= frame_len
;
4903 /* If the high bit of Gorcl (the low 32 bits of the Good Octets
4904 * Received Count) was one before the addition,
4905 * AND it is zero after, then we lost the carry out,
4906 * need to add one to Gorch (Good Octets Received Count High).
4907 * This could be simplified if all environments supported
4910 if (carry_bit
&& ((stats
->gorcl
& 0x80000000) == 0))
4912 /* Is this a broadcast or multicast? Check broadcast first,
4913 * since the test for a multicast frame will test positive on
4914 * a broadcast frame.
4916 if ((mac_addr
[0] == (u8
) 0xff) && (mac_addr
[1] == (u8
) 0xff))
4917 /* Broadcast packet */
4919 else if (*mac_addr
& 0x01)
4920 /* Multicast packet */
4923 if (frame_len
== hw
->max_frame_size
) {
4924 /* In this case, the hardware has overcounted the number of
4931 /* Adjust the bin counters when the extra byte put the frame in the
4932 * wrong bin. Remember that the frame_len was adjusted above.
4934 if (frame_len
== 64) {
4937 } else if (frame_len
== 127) {
4940 } else if (frame_len
== 255) {
4943 } else if (frame_len
== 511) {
4946 } else if (frame_len
== 1023) {
4949 } else if (frame_len
== 1522) {
4955 * e1000_get_bus_info
4956 * @hw: Struct containing variables accessed by shared code
4958 * Gets the current PCI bus type, speed, and width of the hardware
4960 void e1000_get_bus_info(struct e1000_hw
*hw
)
4964 switch (hw
->mac_type
) {
4965 case e1000_82542_rev2_0
:
4966 case e1000_82542_rev2_1
:
4967 hw
->bus_type
= e1000_bus_type_pci
;
4968 hw
->bus_speed
= e1000_bus_speed_unknown
;
4969 hw
->bus_width
= e1000_bus_width_unknown
;
4972 status
= er32(STATUS
);
4973 hw
->bus_type
= (status
& E1000_STATUS_PCIX_MODE
) ?
4974 e1000_bus_type_pcix
: e1000_bus_type_pci
;
4976 if (hw
->device_id
== E1000_DEV_ID_82546EB_QUAD_COPPER
) {
4977 hw
->bus_speed
= (hw
->bus_type
== e1000_bus_type_pci
) ?
4978 e1000_bus_speed_66
: e1000_bus_speed_120
;
4979 } else if (hw
->bus_type
== e1000_bus_type_pci
) {
4980 hw
->bus_speed
= (status
& E1000_STATUS_PCI66
) ?
4981 e1000_bus_speed_66
: e1000_bus_speed_33
;
4983 switch (status
& E1000_STATUS_PCIX_SPEED
) {
4984 case E1000_STATUS_PCIX_SPEED_66
:
4985 hw
->bus_speed
= e1000_bus_speed_66
;
4987 case E1000_STATUS_PCIX_SPEED_100
:
4988 hw
->bus_speed
= e1000_bus_speed_100
;
4990 case E1000_STATUS_PCIX_SPEED_133
:
4991 hw
->bus_speed
= e1000_bus_speed_133
;
4994 hw
->bus_speed
= e1000_bus_speed_reserved
;
4998 hw
->bus_width
= (status
& E1000_STATUS_BUS64
) ?
4999 e1000_bus_width_64
: e1000_bus_width_32
;
5005 * e1000_write_reg_io
5006 * @hw: Struct containing variables accessed by shared code
5007 * @offset: offset to write to
5008 * @value: value to write
5010 * Writes a value to one of the devices registers using port I/O (as opposed to
5011 * memory mapped I/O). Only 82544 and newer devices support port I/O.
5013 static void e1000_write_reg_io(struct e1000_hw
*hw
, u32 offset
, u32 value
)
5015 unsigned long io_addr
= hw
->io_base
;
5016 unsigned long io_data
= hw
->io_base
+ 4;
5018 e1000_io_write(hw
, io_addr
, offset
);
5019 e1000_io_write(hw
, io_data
, value
);
5023 * e1000_get_cable_length - Estimates the cable length.
5024 * @hw: Struct containing variables accessed by shared code
5025 * @min_length: The estimated minimum length
5026 * @max_length: The estimated maximum length
5028 * returns: - E1000_ERR_XXX
5031 * This function always returns a ranged length (minimum & maximum).
5032 * So for M88 phy's, this function interprets the one value returned from the
5033 * register to the minimum and maximum range.
5034 * For IGP phy's, the function calculates the range by the AGC registers.
5036 static s32
e1000_get_cable_length(struct e1000_hw
*hw
, u16
*min_length
,
5044 e_dbg("e1000_get_cable_length");
5046 *min_length
= *max_length
= 0;
5048 /* Use old method for Phy older than IGP */
5049 if (hw
->phy_type
== e1000_phy_m88
) {
5051 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
5055 cable_length
= (phy_data
& M88E1000_PSSR_CABLE_LENGTH
) >>
5056 M88E1000_PSSR_CABLE_LENGTH_SHIFT
;
5058 /* Convert the enum value to ranged values */
5059 switch (cable_length
) {
5060 case e1000_cable_length_50
:
5062 *max_length
= e1000_igp_cable_length_50
;
5064 case e1000_cable_length_50_80
:
5065 *min_length
= e1000_igp_cable_length_50
;
5066 *max_length
= e1000_igp_cable_length_80
;
5068 case e1000_cable_length_80_110
:
5069 *min_length
= e1000_igp_cable_length_80
;
5070 *max_length
= e1000_igp_cable_length_110
;
5072 case e1000_cable_length_110_140
:
5073 *min_length
= e1000_igp_cable_length_110
;
5074 *max_length
= e1000_igp_cable_length_140
;
5076 case e1000_cable_length_140
:
5077 *min_length
= e1000_igp_cable_length_140
;
5078 *max_length
= e1000_igp_cable_length_170
;
5081 return -E1000_ERR_PHY
;
5084 } else if (hw
->phy_type
== e1000_phy_igp
) { /* For IGP PHY */
5086 u16 min_agc_value
= IGP01E1000_AGC_LENGTH_TABLE_SIZE
;
5087 static const u16 agc_reg_array
[IGP01E1000_PHY_CHANNEL_NUM
] = {
5088 IGP01E1000_PHY_AGC_A
,
5089 IGP01E1000_PHY_AGC_B
,
5090 IGP01E1000_PHY_AGC_C
,
5091 IGP01E1000_PHY_AGC_D
5093 /* Read the AGC registers for all channels */
5094 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
5097 e1000_read_phy_reg(hw
, agc_reg_array
[i
], &phy_data
);
5101 cur_agc_value
= phy_data
>> IGP01E1000_AGC_LENGTH_SHIFT
;
5103 /* Value bound check. */
5104 if ((cur_agc_value
>=
5105 IGP01E1000_AGC_LENGTH_TABLE_SIZE
- 1)
5106 || (cur_agc_value
== 0))
5107 return -E1000_ERR_PHY
;
5109 agc_value
+= cur_agc_value
;
5111 /* Update minimal AGC value. */
5112 if (min_agc_value
> cur_agc_value
)
5113 min_agc_value
= cur_agc_value
;
5116 /* Remove the minimal AGC result for length < 50m */
5118 IGP01E1000_PHY_CHANNEL_NUM
* e1000_igp_cable_length_50
) {
5119 agc_value
-= min_agc_value
;
5121 /* Get the average length of the remaining 3 channels */
5122 agc_value
/= (IGP01E1000_PHY_CHANNEL_NUM
- 1);
5124 /* Get the average length of all the 4 channels. */
5125 agc_value
/= IGP01E1000_PHY_CHANNEL_NUM
;
5128 /* Set the range of the calculated length. */
5129 *min_length
= ((e1000_igp_cable_length_table
[agc_value
] -
5130 IGP01E1000_AGC_RANGE
) > 0) ?
5131 (e1000_igp_cable_length_table
[agc_value
] -
5132 IGP01E1000_AGC_RANGE
) : 0;
5133 *max_length
= e1000_igp_cable_length_table
[agc_value
] +
5134 IGP01E1000_AGC_RANGE
;
5137 return E1000_SUCCESS
;
5141 * e1000_check_polarity - Check the cable polarity
5142 * @hw: Struct containing variables accessed by shared code
5143 * @polarity: output parameter : 0 - Polarity is not reversed
5144 * 1 - Polarity is reversed.
5146 * returns: - E1000_ERR_XXX
5149 * For phy's older than IGP, this function simply reads the polarity bit in the
5150 * Phy Status register. For IGP phy's, this bit is valid only if link speed is
5151 * 10 Mbps. If the link speed is 100 Mbps there is no polarity so this bit will
5152 * return 0. If the link speed is 1000 Mbps the polarity status is in the
5153 * IGP01E1000_PHY_PCS_INIT_REG.
5155 static s32
e1000_check_polarity(struct e1000_hw
*hw
,
5156 e1000_rev_polarity
*polarity
)
5161 e_dbg("e1000_check_polarity");
5163 if (hw
->phy_type
== e1000_phy_m88
) {
5164 /* return the Polarity bit in the Status register. */
5165 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
5169 *polarity
= ((phy_data
& M88E1000_PSSR_REV_POLARITY
) >>
5170 M88E1000_PSSR_REV_POLARITY_SHIFT
) ?
5171 e1000_rev_polarity_reversed
: e1000_rev_polarity_normal
;
5173 } else if (hw
->phy_type
== e1000_phy_igp
) {
5174 /* Read the Status register to check the speed */
5175 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_STATUS
,
5180 /* If speed is 1000 Mbps, must read the IGP01E1000_PHY_PCS_INIT_REG to
5181 * find the polarity status */
5182 if ((phy_data
& IGP01E1000_PSSR_SPEED_MASK
) ==
5183 IGP01E1000_PSSR_SPEED_1000MBPS
) {
5185 /* Read the GIG initialization PCS register (0x00B4) */
5187 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PCS_INIT_REG
,
5192 /* Check the polarity bits */
5193 *polarity
= (phy_data
& IGP01E1000_PHY_POLARITY_MASK
) ?
5194 e1000_rev_polarity_reversed
:
5195 e1000_rev_polarity_normal
;
5197 /* For 10 Mbps, read the polarity bit in the status register. (for
5198 * 100 Mbps this bit is always 0) */
5200 (phy_data
& IGP01E1000_PSSR_POLARITY_REVERSED
) ?
5201 e1000_rev_polarity_reversed
:
5202 e1000_rev_polarity_normal
;
5205 return E1000_SUCCESS
;
5209 * e1000_check_downshift - Check if Downshift occurred
5210 * @hw: Struct containing variables accessed by shared code
5211 * @downshift: output parameter : 0 - No Downshift occurred.
5212 * 1 - Downshift occurred.
5214 * returns: - E1000_ERR_XXX
5217 * For phy's older than IGP, this function reads the Downshift bit in the Phy
5218 * Specific Status register. For IGP phy's, it reads the Downgrade bit in the
5219 * Link Health register. In IGP this bit is latched high, so the driver must
5220 * read it immediately after link is established.
5222 static s32
e1000_check_downshift(struct e1000_hw
*hw
)
5227 e_dbg("e1000_check_downshift");
5229 if (hw
->phy_type
== e1000_phy_igp
) {
5230 ret_val
= e1000_read_phy_reg(hw
, IGP01E1000_PHY_LINK_HEALTH
,
5235 hw
->speed_downgraded
=
5236 (phy_data
& IGP01E1000_PLHR_SS_DOWNGRADE
) ? 1 : 0;
5237 } else if (hw
->phy_type
== e1000_phy_m88
) {
5238 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
,
5243 hw
->speed_downgraded
= (phy_data
& M88E1000_PSSR_DOWNSHIFT
) >>
5244 M88E1000_PSSR_DOWNSHIFT_SHIFT
;
5247 return E1000_SUCCESS
;
5251 * e1000_config_dsp_after_link_change
5252 * @hw: Struct containing variables accessed by shared code
5253 * @link_up: was link up at the time this was called
5255 * returns: - E1000_ERR_PHY if fail to read/write the PHY
5256 * E1000_SUCCESS at any other case.
5258 * 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
5259 * gigabit link is achieved to improve link quality.
5262 static s32
e1000_config_dsp_after_link_change(struct e1000_hw
*hw
, bool link_up
)
5265 u16 phy_data
, phy_saved_data
, speed
, duplex
, i
;
5266 static const u16 dsp_reg_array
[IGP01E1000_PHY_CHANNEL_NUM
] = {
5267 IGP01E1000_PHY_AGC_PARAM_A
,
5268 IGP01E1000_PHY_AGC_PARAM_B
,
5269 IGP01E1000_PHY_AGC_PARAM_C
,
5270 IGP01E1000_PHY_AGC_PARAM_D
5272 u16 min_length
, max_length
;
5274 e_dbg("e1000_config_dsp_after_link_change");
5276 if (hw
->phy_type
!= e1000_phy_igp
)
5277 return E1000_SUCCESS
;
5280 ret_val
= e1000_get_speed_and_duplex(hw
, &speed
, &duplex
);
5282 e_dbg("Error getting link speed and duplex\n");
5286 if (speed
== SPEED_1000
) {
5289 e1000_get_cable_length(hw
, &min_length
,
5294 if ((hw
->dsp_config_state
== e1000_dsp_config_enabled
)
5295 && min_length
>= e1000_igp_cable_length_50
) {
5297 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
5299 e1000_read_phy_reg(hw
,
5306 ~IGP01E1000_PHY_EDAC_MU_INDEX
;
5309 e1000_write_phy_reg(hw
,
5315 hw
->dsp_config_state
=
5316 e1000_dsp_config_activated
;
5319 if ((hw
->ffe_config_state
== e1000_ffe_config_enabled
)
5320 && (min_length
< e1000_igp_cable_length_50
)) {
5322 u16 ffe_idle_err_timeout
=
5323 FFE_IDLE_ERR_COUNT_TIMEOUT_20
;
5326 /* clear previous idle error counts */
5328 e1000_read_phy_reg(hw
, PHY_1000T_STATUS
,
5333 for (i
= 0; i
< ffe_idle_err_timeout
; i
++) {
5336 e1000_read_phy_reg(hw
,
5344 SR_1000T_IDLE_ERROR_CNT
);
5346 SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT
)
5348 hw
->ffe_config_state
=
5349 e1000_ffe_config_active
;
5352 e1000_write_phy_reg(hw
,
5353 IGP01E1000_PHY_DSP_FFE
,
5354 IGP01E1000_PHY_DSP_FFE_CM_CP
);
5361 ffe_idle_err_timeout
=
5362 FFE_IDLE_ERR_COUNT_TIMEOUT_100
;
5367 if (hw
->dsp_config_state
== e1000_dsp_config_activated
) {
5368 /* Save off the current value of register 0x2F5B to be restored at
5369 * the end of the routines. */
5371 e1000_read_phy_reg(hw
, 0x2F5B, &phy_saved_data
);
5376 /* Disable the PHY transmitter */
5377 ret_val
= e1000_write_phy_reg(hw
, 0x2F5B, 0x0003);
5384 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
5385 IGP01E1000_IEEE_FORCE_GIGA
);
5388 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
5390 e1000_read_phy_reg(hw
, dsp_reg_array
[i
],
5395 phy_data
&= ~IGP01E1000_PHY_EDAC_MU_INDEX
;
5396 phy_data
|= IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS
;
5399 e1000_write_phy_reg(hw
, dsp_reg_array
[i
],
5405 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
5406 IGP01E1000_IEEE_RESTART_AUTONEG
);
5412 /* Now enable the transmitter */
5414 e1000_write_phy_reg(hw
, 0x2F5B, phy_saved_data
);
5419 hw
->dsp_config_state
= e1000_dsp_config_enabled
;
5422 if (hw
->ffe_config_state
== e1000_ffe_config_active
) {
5423 /* Save off the current value of register 0x2F5B to be restored at
5424 * the end of the routines. */
5426 e1000_read_phy_reg(hw
, 0x2F5B, &phy_saved_data
);
5431 /* Disable the PHY transmitter */
5432 ret_val
= e1000_write_phy_reg(hw
, 0x2F5B, 0x0003);
5439 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
5440 IGP01E1000_IEEE_FORCE_GIGA
);
5444 e1000_write_phy_reg(hw
, IGP01E1000_PHY_DSP_FFE
,
5445 IGP01E1000_PHY_DSP_FFE_DEFAULT
);
5449 ret_val
= e1000_write_phy_reg(hw
, 0x0000,
5450 IGP01E1000_IEEE_RESTART_AUTONEG
);
5456 /* Now enable the transmitter */
5458 e1000_write_phy_reg(hw
, 0x2F5B, phy_saved_data
);
5463 hw
->ffe_config_state
= e1000_ffe_config_enabled
;
5466 return E1000_SUCCESS
;
5470 * e1000_set_phy_mode - Set PHY to class A mode
5471 * @hw: Struct containing variables accessed by shared code
5473 * Assumes the following operations will follow to enable the new class mode.
5474 * 1. Do a PHY soft reset
5475 * 2. Restart auto-negotiation or force link.
5477 static s32
e1000_set_phy_mode(struct e1000_hw
*hw
)
5482 e_dbg("e1000_set_phy_mode");
5484 if ((hw
->mac_type
== e1000_82545_rev_3
) &&
5485 (hw
->media_type
== e1000_media_type_copper
)) {
5487 e1000_read_eeprom(hw
, EEPROM_PHY_CLASS_WORD
, 1,
5493 if ((eeprom_data
!= EEPROM_RESERVED_WORD
) &&
5494 (eeprom_data
& EEPROM_PHY_CLASS_A
)) {
5496 e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
,
5501 e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
,
5506 hw
->phy_reset_disable
= false;
5510 return E1000_SUCCESS
;
5514 * e1000_set_d3_lplu_state - set d3 link power state
5515 * @hw: Struct containing variables accessed by shared code
5516 * @active: true to enable lplu false to disable lplu.
5518 * This function sets the lplu state according to the active flag. When
5519 * activating lplu this function also disables smart speed and vise versa.
5520 * lplu will not be activated unless the device autonegotiation advertisement
5521 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
5523 * returns: - E1000_ERR_PHY if fail to read/write the PHY
5524 * E1000_SUCCESS at any other case.
5526 static s32
e1000_set_d3_lplu_state(struct e1000_hw
*hw
, bool active
)
5530 e_dbg("e1000_set_d3_lplu_state");
5532 if (hw
->phy_type
!= e1000_phy_igp
)
5533 return E1000_SUCCESS
;
5535 /* During driver activity LPLU should not be used or it will attain link
5536 * from the lowest speeds starting from 10Mbps. The capability is used for
5537 * Dx transitions and states */
5538 if (hw
->mac_type
== e1000_82541_rev_2
5539 || hw
->mac_type
== e1000_82547_rev_2
) {
5541 e1000_read_phy_reg(hw
, IGP01E1000_GMII_FIFO
, &phy_data
);
5547 if (hw
->mac_type
== e1000_82541_rev_2
||
5548 hw
->mac_type
== e1000_82547_rev_2
) {
5549 phy_data
&= ~IGP01E1000_GMII_FLEX_SPD
;
5551 e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
5557 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used during
5558 * Dx states where the power conservation is most important. During
5559 * driver activity we should enable SmartSpeed, so performance is
5561 if (hw
->smart_speed
== e1000_smart_speed_on
) {
5563 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
5568 phy_data
|= IGP01E1000_PSCFR_SMART_SPEED
;
5570 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
5574 } else if (hw
->smart_speed
== e1000_smart_speed_off
) {
5576 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
5581 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
5583 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
5588 } else if ((hw
->autoneg_advertised
== AUTONEG_ADVERTISE_SPEED_DEFAULT
)
5589 || (hw
->autoneg_advertised
== AUTONEG_ADVERTISE_10_ALL
)
5590 || (hw
->autoneg_advertised
==
5591 AUTONEG_ADVERTISE_10_100_ALL
)) {
5593 if (hw
->mac_type
== e1000_82541_rev_2
||
5594 hw
->mac_type
== e1000_82547_rev_2
) {
5595 phy_data
|= IGP01E1000_GMII_FLEX_SPD
;
5597 e1000_write_phy_reg(hw
, IGP01E1000_GMII_FIFO
,
5603 /* When LPLU is enabled we should disable SmartSpeed */
5605 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
5610 phy_data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
5612 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PORT_CONFIG
,
5618 return E1000_SUCCESS
;
5622 * e1000_set_vco_speed
5623 * @hw: Struct containing variables accessed by shared code
5625 * Change VCO speed register to improve Bit Error Rate performance of SERDES.
5627 static s32
e1000_set_vco_speed(struct e1000_hw
*hw
)
5630 u16 default_page
= 0;
5633 e_dbg("e1000_set_vco_speed");
5635 switch (hw
->mac_type
) {
5636 case e1000_82545_rev_3
:
5637 case e1000_82546_rev_3
:
5640 return E1000_SUCCESS
;
5643 /* Set PHY register 30, page 5, bit 8 to 0 */
5646 e1000_read_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, &default_page
);
5650 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0005);
5654 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, &phy_data
);
5658 phy_data
&= ~M88E1000_PHY_VCO_REG_BIT8
;
5659 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, phy_data
);
5663 /* Set PHY register 30, page 4, bit 11 to 1 */
5665 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0004);
5669 ret_val
= e1000_read_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, &phy_data
);
5673 phy_data
|= M88E1000_PHY_VCO_REG_BIT11
;
5674 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, phy_data
);
5679 e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, default_page
);
5683 return E1000_SUCCESS
;
5688 * e1000_enable_mng_pass_thru - check for bmc pass through
5689 * @hw: Struct containing variables accessed by shared code
5691 * Verifies the hardware needs to allow ARPs to be processed by the host
5692 * returns: - true/false
5694 u32
e1000_enable_mng_pass_thru(struct e1000_hw
*hw
)
5698 if (hw
->asf_firmware_present
) {
5701 if (!(manc
& E1000_MANC_RCV_TCO_EN
) ||
5702 !(manc
& E1000_MANC_EN_MAC_ADDR_FILTER
))
5704 if ((manc
& E1000_MANC_SMBUS_EN
) && !(manc
& E1000_MANC_ASF_EN
))
5710 static s32
e1000_polarity_reversal_workaround(struct e1000_hw
*hw
)
5716 /* Polarity reversal workaround for forced 10F/10H links. */
5718 /* Disable the transmitter on the PHY */
5720 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0019);
5723 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFFFF);
5727 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0000);
5731 /* This loop will early-out if the NO link condition has been met. */
5732 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
5733 /* Read the MII Status Register and wait for Link Status bit
5737 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
5741 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
5745 if ((mii_status_reg
& ~MII_SR_LINK_STATUS
) == 0)
5750 /* Recommended delay time after link has been lost */
5753 /* Now we will re-enable th transmitter on the PHY */
5755 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0019);
5759 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFFF0);
5763 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0xFF00);
5767 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_GEN_CONTROL
, 0x0000);
5771 ret_val
= e1000_write_phy_reg(hw
, M88E1000_PHY_PAGE_SELECT
, 0x0000);
5775 /* This loop will early-out if the link condition has been met. */
5776 for (i
= PHY_FORCE_TIME
; i
> 0; i
--) {
5777 /* Read the MII Status Register and wait for Link Status bit
5781 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
5785 ret_val
= e1000_read_phy_reg(hw
, PHY_STATUS
, &mii_status_reg
);
5789 if (mii_status_reg
& MII_SR_LINK_STATUS
)
5793 return E1000_SUCCESS
;
5797 * e1000_get_auto_rd_done
5798 * @hw: Struct containing variables accessed by shared code
5800 * Check for EEPROM Auto Read bit done.
5801 * returns: - E1000_ERR_RESET if fail to reset MAC
5802 * E1000_SUCCESS at any other case.
5804 static s32
e1000_get_auto_rd_done(struct e1000_hw
*hw
)
5806 e_dbg("e1000_get_auto_rd_done");
5808 return E1000_SUCCESS
;
5812 * e1000_get_phy_cfg_done
5813 * @hw: Struct containing variables accessed by shared code
5815 * Checks if the PHY configuration is done
5816 * returns: - E1000_ERR_RESET if fail to reset MAC
5817 * E1000_SUCCESS at any other case.
5819 static s32
e1000_get_phy_cfg_done(struct e1000_hw
*hw
)
5821 e_dbg("e1000_get_phy_cfg_done");
5823 return E1000_SUCCESS
;