1 /*******************************************************************************
4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 The full GNU General Public License is included in this distribution in the
24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28 *******************************************************************************/
31 * Shared functions for accessing and configuring the MAC
36 static int32_t e1000_set_phy_type(struct e1000_hw *hw);
37 static void e1000_phy_init_script(struct e1000_hw *hw);
38 static int32_t e1000_setup_copper_link(struct e1000_hw *hw);
39 static int32_t e1000_setup_fiber_serdes_link(struct e1000_hw *hw);
40 static int32_t e1000_adjust_serdes_amplitude(struct e1000_hw *hw);
41 static int32_t e1000_phy_force_speed_duplex(struct e1000_hw *hw);
42 static int32_t e1000_config_mac_to_phy(struct e1000_hw *hw);
43 static void e1000_raise_mdi_clk(struct e1000_hw *hw, uint32_t *ctrl);
44 static void e1000_lower_mdi_clk(struct e1000_hw *hw, uint32_t *ctrl);
45 static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, uint32_t data,
47 static uint16_t e1000_shift_in_mdi_bits(struct e1000_hw *hw);
48 static int32_t e1000_phy_reset_dsp(struct e1000_hw *hw);
49 static int32_t e1000_write_eeprom_spi(struct e1000_hw *hw, uint16_t offset,
50 uint16_t words, uint16_t *data);
51 static int32_t e1000_write_eeprom_microwire(struct e1000_hw *hw,
52 uint16_t offset, uint16_t words,
54 static int32_t e1000_spi_eeprom_ready(struct e1000_hw *hw);
55 static void e1000_raise_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
56 static void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
57 static void e1000_shift_out_ee_bits(struct e1000_hw *hw, uint16_t data,
59 static int32_t e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr,
61 static int32_t e1000_read_phy_reg_ex(struct e1000_hw *hw,uint32_t reg_addr,
63 static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw, uint16_t count);
64 static int32_t e1000_acquire_eeprom(struct e1000_hw *hw);
65 static void e1000_release_eeprom(struct e1000_hw *hw);
66 static void e1000_standby_eeprom(struct e1000_hw *hw);
67 static int32_t e1000_set_vco_speed(struct e1000_hw *hw);
68 static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw);
69 static int32_t e1000_set_phy_mode(struct e1000_hw *hw);
70 static int32_t e1000_host_if_read_cookie(struct e1000_hw *hw, uint8_t *buffer);
71 static uint8_t e1000_calculate_mng_checksum(char *buffer, uint32_t length);
72 static uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
73 static int32_t e1000_check_downshift(struct e1000_hw *hw);
74 static int32_t e1000_check_polarity(struct e1000_hw *hw, uint16_t *polarity);
75 static void e1000_clear_hw_cntrs(struct e1000_hw *hw);
76 static void e1000_clear_vfta(struct e1000_hw *hw);
77 static int32_t e1000_commit_shadow_ram(struct e1000_hw *hw);
78 static int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw,
80 static int32_t e1000_config_fc_after_link_up(struct e1000_hw *hw);
81 static int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
82 static int32_t e1000_get_auto_rd_done(struct e1000_hw *hw);
83 static int32_t e1000_get_cable_length(struct e1000_hw *hw,
85 uint16_t *max_length);
86 static int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw);
87 static int32_t e1000_get_phy_cfg_done(struct e1000_hw *hw);
88 static int32_t e1000_id_led_init(struct e1000_hw * hw);
89 static void e1000_init_rx_addrs(struct e1000_hw *hw);
90 static boolean_t e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw);
91 static int32_t e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd);
92 static void e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw);
93 static int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset,
94 uint16_t words, uint16_t *data);
95 static int32_t e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active);
96 static int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
97 static int32_t e1000_wait_autoneg(struct e1000_hw *hw);
99 static void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset,
102 #define E1000_WRITE_REG_IO(a, reg, val) \
103 e1000_write_reg_io((a), E1000_##reg, val)
104 static int32_t e1000_configure_kmrn_for_10_100(struct e1000_hw *hw,
106 static int32_t e1000_configure_kmrn_for_1000(struct e1000_hw *hw);
108 static int32_t e1000_erase_ich8_4k_segment(struct e1000_hw *hw,
110 static int32_t e1000_get_software_flag(struct e1000_hw *hw);
111 static int32_t e1000_get_software_semaphore(struct e1000_hw *hw);
112 static int32_t e1000_init_lcd_from_nvm(struct e1000_hw *hw);
113 static int32_t e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw);
114 static int32_t e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset,
115 uint16_t words, uint16_t *data);
116 static int32_t e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index,
118 static int32_t e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index,
120 static int32_t e1000_read_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr,
122 static void e1000_release_software_flag(struct e1000_hw *hw);
123 static void e1000_release_software_semaphore(struct e1000_hw *hw);
124 static int32_t e1000_set_pci_ex_no_snoop(struct e1000_hw *hw,
126 static int32_t e1000_verify_write_ich8_byte(struct e1000_hw *hw,
127 uint32_t index, uint8_t byte);
128 static int32_t e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset,
129 uint16_t words, uint16_t *data);
130 static int32_t e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index,
132 static int32_t e1000_write_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr,
135 /* IGP cable length table */
137 uint16_t e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] =
138 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
139 5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
140 25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
141 40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
142 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
143 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
144 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
145 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
148 uint16_t e1000_igp_2_cable_length_table[IGP02E1000_AGC_LENGTH_TABLE_SIZE] =
149 { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
150 0, 0, 0, 3, 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41,
151 6, 10, 14, 18, 22, 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61,
152 21, 26, 31, 35, 40, 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82,
153 40, 45, 51, 56, 61, 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104,
154 60, 66, 72, 77, 82, 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121,
155 83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
156 104, 109, 114, 118, 121, 124};
159 /******************************************************************************
160 * Set the phy type member in the hw struct.
162 * hw - Struct containing variables accessed by shared code
163 *****************************************************************************/
165 e1000_set_phy_type(struct e1000_hw *hw)
167 DEBUGFUNC("e1000_set_phy_type");
169 if(hw->mac_type == e1000_undefined)
170 return -E1000_ERR_PHY_TYPE;
173 case M88E1000_E_PHY_ID:
174 case M88E1000_I_PHY_ID:
175 case M88E1011_I_PHY_ID:
176 case M88E1111_I_PHY_ID:
177 hw->phy_type = e1000_phy_m88;
179 case IGP01E1000_I_PHY_ID:
180 if(hw->mac_type == e1000_82541 ||
181 hw->mac_type == e1000_82541_rev_2 ||
182 hw->mac_type == e1000_82547 ||
183 hw->mac_type == e1000_82547_rev_2) {
184 hw->phy_type = e1000_phy_igp;
187 case IGP03E1000_E_PHY_ID:
188 hw->phy_type = e1000_phy_igp_3;
191 case IFE_PLUS_E_PHY_ID:
193 hw->phy_type = e1000_phy_ife;
195 case GG82563_E_PHY_ID:
196 if (hw->mac_type == e1000_80003es2lan) {
197 hw->phy_type = e1000_phy_gg82563;
202 /* Should never have loaded on this device */
203 hw->phy_type = e1000_phy_undefined;
204 return -E1000_ERR_PHY_TYPE;
207 return E1000_SUCCESS;
210 /******************************************************************************
211 * IGP phy init script - initializes the GbE PHY
213 * hw - Struct containing variables accessed by shared code
214 *****************************************************************************/
216 e1000_phy_init_script(struct e1000_hw *hw)
219 uint16_t phy_saved_data;
221 DEBUGFUNC("e1000_phy_init_script");
223 if(hw->phy_init_script) {
226 /* Save off the current value of register 0x2F5B to be restored at
227 * the end of this routine. */
228 ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
230 /* Disabled the PHY transmitter */
231 e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
235 e1000_write_phy_reg(hw,0x0000,0x0140);
239 switch(hw->mac_type) {
242 e1000_write_phy_reg(hw, 0x1F95, 0x0001);
244 e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
246 e1000_write_phy_reg(hw, 0x1F79, 0x0018);
248 e1000_write_phy_reg(hw, 0x1F30, 0x1600);
250 e1000_write_phy_reg(hw, 0x1F31, 0x0014);
252 e1000_write_phy_reg(hw, 0x1F32, 0x161C);
254 e1000_write_phy_reg(hw, 0x1F94, 0x0003);
256 e1000_write_phy_reg(hw, 0x1F96, 0x003F);
258 e1000_write_phy_reg(hw, 0x2010, 0x0008);
261 case e1000_82541_rev_2:
262 case e1000_82547_rev_2:
263 e1000_write_phy_reg(hw, 0x1F73, 0x0099);
269 e1000_write_phy_reg(hw, 0x0000, 0x3300);
273 /* Now enable the transmitter */
274 e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
276 if(hw->mac_type == e1000_82547) {
277 uint16_t fused, fine, coarse;
279 /* Move to analog registers page */
280 e1000_read_phy_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS, &fused);
282 if(!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
283 e1000_read_phy_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS, &fused);
285 fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
286 coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
288 if(coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
289 coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
290 fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
291 } else if(coarse == IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
292 fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
294 fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
295 (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
296 (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
298 e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_CONTROL, fused);
299 e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_BYPASS,
300 IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
306 /******************************************************************************
307 * Set the mac type member in the hw struct.
309 * hw - Struct containing variables accessed by shared code
310 *****************************************************************************/
312 e1000_set_mac_type(struct e1000_hw *hw)
314 DEBUGFUNC("e1000_set_mac_type");
316 switch (hw->device_id) {
317 case E1000_DEV_ID_82542:
318 switch (hw->revision_id) {
319 case E1000_82542_2_0_REV_ID:
320 hw->mac_type = e1000_82542_rev2_0;
322 case E1000_82542_2_1_REV_ID:
323 hw->mac_type = e1000_82542_rev2_1;
326 /* Invalid 82542 revision ID */
327 return -E1000_ERR_MAC_TYPE;
330 case E1000_DEV_ID_82543GC_FIBER:
331 case E1000_DEV_ID_82543GC_COPPER:
332 hw->mac_type = e1000_82543;
334 case E1000_DEV_ID_82544EI_COPPER:
335 case E1000_DEV_ID_82544EI_FIBER:
336 case E1000_DEV_ID_82544GC_COPPER:
337 case E1000_DEV_ID_82544GC_LOM:
338 hw->mac_type = e1000_82544;
340 case E1000_DEV_ID_82540EM:
341 case E1000_DEV_ID_82540EM_LOM:
342 case E1000_DEV_ID_82540EP:
343 case E1000_DEV_ID_82540EP_LOM:
344 case E1000_DEV_ID_82540EP_LP:
345 hw->mac_type = e1000_82540;
347 case E1000_DEV_ID_82545EM_COPPER:
348 case E1000_DEV_ID_82545EM_FIBER:
349 hw->mac_type = e1000_82545;
351 case E1000_DEV_ID_82545GM_COPPER:
352 case E1000_DEV_ID_82545GM_FIBER:
353 case E1000_DEV_ID_82545GM_SERDES:
354 hw->mac_type = e1000_82545_rev_3;
356 case E1000_DEV_ID_82546EB_COPPER:
357 case E1000_DEV_ID_82546EB_FIBER:
358 case E1000_DEV_ID_82546EB_QUAD_COPPER:
359 hw->mac_type = e1000_82546;
361 case E1000_DEV_ID_82546GB_COPPER:
362 case E1000_DEV_ID_82546GB_FIBER:
363 case E1000_DEV_ID_82546GB_SERDES:
364 case E1000_DEV_ID_82546GB_PCIE:
365 case E1000_DEV_ID_82546GB_QUAD_COPPER:
366 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
367 hw->mac_type = e1000_82546_rev_3;
369 case E1000_DEV_ID_82541EI:
370 case E1000_DEV_ID_82541EI_MOBILE:
371 case E1000_DEV_ID_82541ER_LOM:
372 hw->mac_type = e1000_82541;
374 case E1000_DEV_ID_82541ER:
375 case E1000_DEV_ID_82541GI:
376 case E1000_DEV_ID_82541GI_LF:
377 case E1000_DEV_ID_82541GI_MOBILE:
378 hw->mac_type = e1000_82541_rev_2;
380 case E1000_DEV_ID_82547EI:
381 case E1000_DEV_ID_82547EI_MOBILE:
382 hw->mac_type = e1000_82547;
384 case E1000_DEV_ID_82547GI:
385 hw->mac_type = e1000_82547_rev_2;
387 case E1000_DEV_ID_82571EB_COPPER:
388 case E1000_DEV_ID_82571EB_FIBER:
389 case E1000_DEV_ID_82571EB_SERDES:
390 hw->mac_type = e1000_82571;
392 case E1000_DEV_ID_82572EI_COPPER:
393 case E1000_DEV_ID_82572EI_FIBER:
394 case E1000_DEV_ID_82572EI_SERDES:
395 case E1000_DEV_ID_82572EI:
396 hw->mac_type = e1000_82572;
398 case E1000_DEV_ID_82573E:
399 case E1000_DEV_ID_82573E_IAMT:
400 case E1000_DEV_ID_82573L:
401 hw->mac_type = e1000_82573;
403 case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
404 case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
405 case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
406 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
407 hw->mac_type = e1000_80003es2lan;
409 case E1000_DEV_ID_ICH8_IGP_M_AMT:
410 case E1000_DEV_ID_ICH8_IGP_AMT:
411 case E1000_DEV_ID_ICH8_IGP_C:
412 case E1000_DEV_ID_ICH8_IFE:
413 case E1000_DEV_ID_ICH8_IGP_M:
414 hw->mac_type = e1000_ich8lan;
417 /* Should never have loaded on this device */
418 return -E1000_ERR_MAC_TYPE;
421 switch(hw->mac_type) {
423 hw->swfwhw_semaphore_present = TRUE;
424 hw->asf_firmware_present = TRUE;
426 case e1000_80003es2lan:
427 hw->swfw_sync_present = TRUE;
432 hw->eeprom_semaphore_present = TRUE;
436 case e1000_82541_rev_2:
437 case e1000_82547_rev_2:
438 hw->asf_firmware_present = TRUE;
444 return E1000_SUCCESS;
447 /*****************************************************************************
448 * Set media type and TBI compatibility.
450 * hw - Struct containing variables accessed by shared code
451 * **************************************************************************/
453 e1000_set_media_type(struct e1000_hw *hw)
457 DEBUGFUNC("e1000_set_media_type");
459 if(hw->mac_type != e1000_82543) {
460 /* tbi_compatibility is only valid on 82543 */
461 hw->tbi_compatibility_en = FALSE;
464 switch (hw->device_id) {
465 case E1000_DEV_ID_82545GM_SERDES:
466 case E1000_DEV_ID_82546GB_SERDES:
467 case E1000_DEV_ID_82571EB_SERDES:
468 case E1000_DEV_ID_82572EI_SERDES:
469 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
470 hw->media_type = e1000_media_type_internal_serdes;
473 switch (hw->mac_type) {
474 case e1000_82542_rev2_0:
475 case e1000_82542_rev2_1:
476 hw->media_type = e1000_media_type_fiber;
480 /* The STATUS_TBIMODE bit is reserved or reused for the this
483 hw->media_type = e1000_media_type_copper;
486 status = E1000_READ_REG(hw, STATUS);
487 if (status & E1000_STATUS_TBIMODE) {
488 hw->media_type = e1000_media_type_fiber;
489 /* tbi_compatibility not valid on fiber */
490 hw->tbi_compatibility_en = FALSE;
492 hw->media_type = e1000_media_type_copper;
499 /******************************************************************************
500 * Reset the transmit and receive units; mask and clear all interrupts.
502 * hw - Struct containing variables accessed by shared code
503 *****************************************************************************/
505 e1000_reset_hw(struct e1000_hw *hw)
513 uint32_t extcnf_ctrl;
516 DEBUGFUNC("e1000_reset_hw");
518 /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
519 if(hw->mac_type == e1000_82542_rev2_0) {
520 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
521 e1000_pci_clear_mwi(hw);
524 if(hw->bus_type == e1000_bus_type_pci_express) {
525 /* Prevent the PCI-E bus from sticking if there is no TLP connection
526 * on the last TLP read/write transaction when MAC is reset.
528 if(e1000_disable_pciex_master(hw) != E1000_SUCCESS) {
529 DEBUGOUT("PCI-E Master disable polling has failed.\n");
533 /* Clear interrupt mask to stop board from generating interrupts */
534 DEBUGOUT("Masking off all interrupts\n");
535 E1000_WRITE_REG(hw, IMC, 0xffffffff);
537 /* Disable the Transmit and Receive units. Then delay to allow
538 * any pending transactions to complete before we hit the MAC with
541 E1000_WRITE_REG(hw, RCTL, 0);
542 E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
543 E1000_WRITE_FLUSH(hw);
545 /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
546 hw->tbi_compatibility_on = FALSE;
548 /* Delay to allow any outstanding PCI transactions to complete before
549 * resetting the device
553 ctrl = E1000_READ_REG(hw, CTRL);
555 /* Must reset the PHY before resetting the MAC */
556 if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
557 E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
561 /* Must acquire the MDIO ownership before MAC reset.
562 * Ownership defaults to firmware after a reset. */
563 if(hw->mac_type == e1000_82573) {
566 extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
567 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
570 E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
571 extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
573 if(extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
576 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
583 /* Workaround for ICH8 bit corruption issue in FIFO memory */
584 if (hw->mac_type == e1000_ich8lan) {
585 /* Set Tx and Rx buffer allocation to 8k apiece. */
586 E1000_WRITE_REG(hw, PBA, E1000_PBA_8K);
587 /* Set Packet Buffer Size to 16k. */
588 E1000_WRITE_REG(hw, PBS, E1000_PBS_16K);
591 /* Issue a global reset to the MAC. This will reset the chip's
592 * transmit, receive, DMA, and link units. It will not effect
593 * the current PCI configuration. The global reset bit is self-
594 * clearing, and should clear within a microsecond.
596 DEBUGOUT("Issuing a global reset to MAC\n");
598 switch(hw->mac_type) {
604 case e1000_82541_rev_2:
605 /* These controllers can't ack the 64-bit write when issuing the
606 * reset, so use IO-mapping as a workaround to issue the reset */
607 E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));
609 case e1000_82545_rev_3:
610 case e1000_82546_rev_3:
611 /* Reset is performed on a shadow of the control register */
612 E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST));
615 if (!hw->phy_reset_disable &&
616 e1000_check_phy_reset_block(hw) == E1000_SUCCESS) {
617 /* e1000_ich8lan PHY HW reset requires MAC CORE reset
618 * at the same time to make sure the interface between
619 * MAC and the external PHY is reset.
621 ctrl |= E1000_CTRL_PHY_RST;
624 e1000_get_software_flag(hw);
625 E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
629 E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
633 /* After MAC reset, force reload of EEPROM to restore power-on settings to
634 * device. Later controllers reload the EEPROM automatically, so just wait
635 * for reload to complete.
637 switch(hw->mac_type) {
638 case e1000_82542_rev2_0:
639 case e1000_82542_rev2_1:
642 /* Wait for reset to complete */
644 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
645 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
646 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
647 E1000_WRITE_FLUSH(hw);
648 /* Wait for EEPROM reload */
652 case e1000_82541_rev_2:
654 case e1000_82547_rev_2:
655 /* Wait for EEPROM reload */
659 if (e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
661 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
662 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
663 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
664 E1000_WRITE_FLUSH(hw);
670 case e1000_80003es2lan:
671 ret_val = e1000_get_auto_rd_done(hw);
673 /* We don't want to continue accessing MAC registers. */
677 /* Wait for EEPROM reload (it happens automatically) */
682 /* Disable HW ARPs on ASF enabled adapters */
683 if(hw->mac_type >= e1000_82540 && hw->mac_type <= e1000_82547_rev_2) {
684 manc = E1000_READ_REG(hw, MANC);
685 manc &= ~(E1000_MANC_ARP_EN);
686 E1000_WRITE_REG(hw, MANC, manc);
689 if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
690 e1000_phy_init_script(hw);
692 /* Configure activity LED after PHY reset */
693 led_ctrl = E1000_READ_REG(hw, LEDCTL);
694 led_ctrl &= IGP_ACTIVITY_LED_MASK;
695 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
696 E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
699 /* Clear interrupt mask to stop board from generating interrupts */
700 DEBUGOUT("Masking off all interrupts\n");
701 E1000_WRITE_REG(hw, IMC, 0xffffffff);
703 /* Clear any pending interrupt events. */
704 icr = E1000_READ_REG(hw, ICR);
706 /* If MWI was previously enabled, reenable it. */
707 if(hw->mac_type == e1000_82542_rev2_0) {
708 if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
709 e1000_pci_set_mwi(hw);
712 if (hw->mac_type == e1000_ich8lan) {
713 uint32_t kab = E1000_READ_REG(hw, KABGTXD);
714 kab |= E1000_KABGTXD_BGSQLBIAS;
715 E1000_WRITE_REG(hw, KABGTXD, kab);
718 return E1000_SUCCESS;
721 /******************************************************************************
722 * Performs basic configuration of the adapter.
724 * hw - Struct containing variables accessed by shared code
726 * Assumes that the controller has previously been reset and is in a
727 * post-reset uninitialized state. Initializes the receive address registers,
728 * multicast table, and VLAN filter table. Calls routines to setup link
729 * configuration and flow control settings. Clears all on-chip counters. Leaves
730 * the transmit and receive units disabled and uninitialized.
731 *****************************************************************************/
733 e1000_init_hw(struct e1000_hw *hw)
738 uint16_t pcix_cmd_word;
739 uint16_t pcix_stat_hi_word;
746 DEBUGFUNC("e1000_init_hw");
748 /* force full DMA clock frequency for 10/100 on ICH8 A0-B0 */
749 if (hw->mac_type == e1000_ich8lan) {
750 reg_data = E1000_READ_REG(hw, TARC0);
751 reg_data |= 0x30000000;
752 E1000_WRITE_REG(hw, TARC0, reg_data);
754 reg_data = E1000_READ_REG(hw, STATUS);
755 reg_data &= ~0x80000000;
756 E1000_WRITE_REG(hw, STATUS, reg_data);
759 /* Initialize Identification LED */
760 ret_val = e1000_id_led_init(hw);
762 DEBUGOUT("Error Initializing Identification LED\n");
766 /* Set the media type and TBI compatibility */
767 e1000_set_media_type(hw);
769 /* Disabling VLAN filtering. */
770 DEBUGOUT("Initializing the IEEE VLAN\n");
771 /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */
772 if (hw->mac_type != e1000_ich8lan) {
773 if (hw->mac_type < e1000_82545_rev_3)
774 E1000_WRITE_REG(hw, VET, 0);
775 e1000_clear_vfta(hw);
778 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
779 if(hw->mac_type == e1000_82542_rev2_0) {
780 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
781 e1000_pci_clear_mwi(hw);
782 E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
783 E1000_WRITE_FLUSH(hw);
787 /* Setup the receive address. This involves initializing all of the Receive
788 * Address Registers (RARs 0 - 15).
790 e1000_init_rx_addrs(hw);
792 /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
793 if(hw->mac_type == e1000_82542_rev2_0) {
794 E1000_WRITE_REG(hw, RCTL, 0);
795 E1000_WRITE_FLUSH(hw);
797 if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
798 e1000_pci_set_mwi(hw);
801 /* Zero out the Multicast HASH table */
802 DEBUGOUT("Zeroing the MTA\n");
803 mta_size = E1000_MC_TBL_SIZE;
804 if (hw->mac_type == e1000_ich8lan)
805 mta_size = E1000_MC_TBL_SIZE_ICH8LAN;
806 for(i = 0; i < mta_size; i++) {
807 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
808 /* use write flush to prevent Memory Write Block (MWB) from
809 * occuring when accessing our register space */
810 E1000_WRITE_FLUSH(hw);
813 /* Set the PCI priority bit correctly in the CTRL register. This
814 * determines if the adapter gives priority to receives, or if it
815 * gives equal priority to transmits and receives. Valid only on
816 * 82542 and 82543 silicon.
818 if(hw->dma_fairness && hw->mac_type <= e1000_82543) {
819 ctrl = E1000_READ_REG(hw, CTRL);
820 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
823 switch(hw->mac_type) {
824 case e1000_82545_rev_3:
825 case e1000_82546_rev_3:
828 /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
829 if(hw->bus_type == e1000_bus_type_pcix) {
830 e1000_read_pci_cfg(hw, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
831 e1000_read_pci_cfg(hw, PCIX_STATUS_REGISTER_HI,
833 cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
834 PCIX_COMMAND_MMRBC_SHIFT;
835 stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
836 PCIX_STATUS_HI_MMRBC_SHIFT;
837 if(stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
838 stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
839 if(cmd_mmrbc > stat_mmrbc) {
840 pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
841 pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
842 e1000_write_pci_cfg(hw, PCIX_COMMAND_REGISTER,
849 /* More time needed for PHY to initialize */
850 if (hw->mac_type == e1000_ich8lan)
853 /* Call a subroutine to configure the link and setup flow control. */
854 ret_val = e1000_setup_link(hw);
856 /* Set the transmit descriptor write-back policy */
857 if(hw->mac_type > e1000_82544) {
858 ctrl = E1000_READ_REG(hw, TXDCTL);
859 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
860 switch (hw->mac_type) {
867 case e1000_80003es2lan:
868 ctrl |= E1000_TXDCTL_COUNT_DESC;
871 E1000_WRITE_REG(hw, TXDCTL, ctrl);
874 if (hw->mac_type == e1000_82573) {
875 e1000_enable_tx_pkt_filtering(hw);
878 switch (hw->mac_type) {
881 case e1000_80003es2lan:
882 /* Enable retransmit on late collisions */
883 reg_data = E1000_READ_REG(hw, TCTL);
884 reg_data |= E1000_TCTL_RTLC;
885 E1000_WRITE_REG(hw, TCTL, reg_data);
887 /* Configure Gigabit Carry Extend Padding */
888 reg_data = E1000_READ_REG(hw, TCTL_EXT);
889 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
890 reg_data |= DEFAULT_80003ES2LAN_TCTL_EXT_GCEX;
891 E1000_WRITE_REG(hw, TCTL_EXT, reg_data);
893 /* Configure Transmit Inter-Packet Gap */
894 reg_data = E1000_READ_REG(hw, TIPG);
895 reg_data &= ~E1000_TIPG_IPGT_MASK;
896 reg_data |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
897 E1000_WRITE_REG(hw, TIPG, reg_data);
899 reg_data = E1000_READ_REG_ARRAY(hw, FFLT, 0x0001);
900 reg_data &= ~0x00100000;
901 E1000_WRITE_REG_ARRAY(hw, FFLT, 0x0001, reg_data);
906 ctrl = E1000_READ_REG(hw, TXDCTL1);
907 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
908 if(hw->mac_type >= e1000_82571)
909 ctrl |= E1000_TXDCTL_COUNT_DESC;
910 E1000_WRITE_REG(hw, TXDCTL1, ctrl);
916 if (hw->mac_type == e1000_82573) {
917 uint32_t gcr = E1000_READ_REG(hw, GCR);
918 gcr |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
919 E1000_WRITE_REG(hw, GCR, gcr);
922 /* Clear all of the statistics registers (clear on read). It is
923 * important that we do this after we have tried to establish link
924 * because the symbol error count will increment wildly if there
927 e1000_clear_hw_cntrs(hw);
929 /* ICH8 No-snoop bits are opposite polarity.
930 * Set to snoop by default after reset. */
931 if (hw->mac_type == e1000_ich8lan)
932 e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL);
934 if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER ||
935 hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {
936 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
937 /* Relaxed ordering must be disabled to avoid a parity
938 * error crash in a PCI slot. */
939 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
940 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
946 /******************************************************************************
947 * Adjust SERDES output amplitude based on EEPROM setting.
949 * hw - Struct containing variables accessed by shared code.
950 *****************************************************************************/
952 e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
954 uint16_t eeprom_data;
957 DEBUGFUNC("e1000_adjust_serdes_amplitude");
959 if(hw->media_type != e1000_media_type_internal_serdes)
960 return E1000_SUCCESS;
962 switch(hw->mac_type) {
963 case e1000_82545_rev_3:
964 case e1000_82546_rev_3:
967 return E1000_SUCCESS;
970 ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1, &eeprom_data);
975 if(eeprom_data != EEPROM_RESERVED_WORD) {
976 /* Adjust SERDES output amplitude only. */
977 eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
978 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL, eeprom_data);
983 return E1000_SUCCESS;
986 /******************************************************************************
987 * Configures flow control and link settings.
989 * hw - Struct containing variables accessed by shared code
991 * Determines which flow control settings to use. Calls the apropriate media-
992 * specific link configuration function. Configures the flow control settings.
993 * Assuming the adapter has a valid link partner, a valid link should be
994 * established. Assumes the hardware has previously been reset and the
995 * transmitter and receiver are not enabled.
996 *****************************************************************************/
998 e1000_setup_link(struct e1000_hw *hw)
1002 uint16_t eeprom_data;
1004 DEBUGFUNC("e1000_setup_link");
1006 /* In the case of the phy reset being blocked, we already have a link.
1007 * We do not have to set it up again. */
1008 if (e1000_check_phy_reset_block(hw))
1009 return E1000_SUCCESS;
1011 /* Read and store word 0x0F of the EEPROM. This word contains bits
1012 * that determine the hardware's default PAUSE (flow control) mode,
1013 * a bit that determines whether the HW defaults to enabling or
1014 * disabling auto-negotiation, and the direction of the
1015 * SW defined pins. If there is no SW over-ride of the flow
1016 * control setting, then the variable hw->fc will
1017 * be initialized based on a value in the EEPROM.
1019 if (hw->fc == e1000_fc_default) {
1020 switch (hw->mac_type) {
1023 hw->fc = e1000_fc_full;
1026 ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
1029 DEBUGOUT("EEPROM Read Error\n");
1030 return -E1000_ERR_EEPROM;
1032 if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
1033 hw->fc = e1000_fc_none;
1034 else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
1035 EEPROM_WORD0F_ASM_DIR)
1036 hw->fc = e1000_fc_tx_pause;
1038 hw->fc = e1000_fc_full;
1043 /* We want to save off the original Flow Control configuration just
1044 * in case we get disconnected and then reconnected into a different
1045 * hub or switch with different Flow Control capabilities.
1047 if(hw->mac_type == e1000_82542_rev2_0)
1048 hw->fc &= (~e1000_fc_tx_pause);
1050 if((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
1051 hw->fc &= (~e1000_fc_rx_pause);
1053 hw->original_fc = hw->fc;
1055 DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
1057 /* Take the 4 bits from EEPROM word 0x0F that determine the initial
1058 * polarity value for the SW controlled pins, and setup the
1059 * Extended Device Control reg with that info.
1060 * This is needed because one of the SW controlled pins is used for
1061 * signal detection. So this should be done before e1000_setup_pcs_link()
1062 * or e1000_phy_setup() is called.
1064 if (hw->mac_type == e1000_82543) {
1065 ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
1068 DEBUGOUT("EEPROM Read Error\n");
1069 return -E1000_ERR_EEPROM;
1071 ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
1073 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
1076 /* Call the necessary subroutine to configure the link. */
1077 ret_val = (hw->media_type == e1000_media_type_copper) ?
1078 e1000_setup_copper_link(hw) :
1079 e1000_setup_fiber_serdes_link(hw);
1081 /* Initialize the flow control address, type, and PAUSE timer
1082 * registers to their default values. This is done even if flow
1083 * control is disabled, because it does not hurt anything to
1084 * initialize these registers.
1086 DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
1088 /* FCAL/H and FCT are hardcoded to standard values in e1000_ich8lan. */
1089 if (hw->mac_type != e1000_ich8lan) {
1090 E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
1091 E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
1092 E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
1095 E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
1097 /* Set the flow control receive threshold registers. Normally,
1098 * these registers will be set to a default threshold that may be
1099 * adjusted later by the driver's runtime code. However, if the
1100 * ability to transmit pause frames in not enabled, then these
1101 * registers will be set to 0.
1103 if(!(hw->fc & e1000_fc_tx_pause)) {
1104 E1000_WRITE_REG(hw, FCRTL, 0);
1105 E1000_WRITE_REG(hw, FCRTH, 0);
1107 /* We need to set up the Receive Threshold high and low water marks
1108 * as well as (optionally) enabling the transmission of XON frames.
1110 if(hw->fc_send_xon) {
1111 E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
1112 E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
1114 E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
1115 E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
1121 /******************************************************************************
1122 * Sets up link for a fiber based or serdes based adapter
1124 * hw - Struct containing variables accessed by shared code
1126 * Manipulates Physical Coding Sublayer functions in order to configure
1127 * link. Assumes the hardware has been previously reset and the transmitter
1128 * and receiver are not enabled.
1129 *****************************************************************************/
1131 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
1137 uint32_t signal = 0;
1140 DEBUGFUNC("e1000_setup_fiber_serdes_link");
1142 /* On 82571 and 82572 Fiber connections, SerDes loopback mode persists
1143 * until explicitly turned off or a power cycle is performed. A read to
1144 * the register does not indicate its status. Therefore, we ensure
1145 * loopback mode is disabled during initialization.
1147 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572)
1148 E1000_WRITE_REG(hw, SCTL, E1000_DISABLE_SERDES_LOOPBACK);
1150 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
1151 * set when the optics detect a signal. On older adapters, it will be
1152 * cleared when there is a signal. This applies to fiber media only.
1153 * If we're on serdes media, adjust the output amplitude to value set in
1156 ctrl = E1000_READ_REG(hw, CTRL);
1157 if(hw->media_type == e1000_media_type_fiber)
1158 signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
1160 ret_val = e1000_adjust_serdes_amplitude(hw);
1164 /* Take the link out of reset */
1165 ctrl &= ~(E1000_CTRL_LRST);
1167 /* Adjust VCO speed to improve BER performance */
1168 ret_val = e1000_set_vco_speed(hw);
1172 e1000_config_collision_dist(hw);
1174 /* Check for a software override of the flow control settings, and setup
1175 * the device accordingly. If auto-negotiation is enabled, then software
1176 * will have to set the "PAUSE" bits to the correct value in the Tranmsit
1177 * Config Word Register (TXCW) and re-start auto-negotiation. However, if
1178 * auto-negotiation is disabled, then software will have to manually
1179 * configure the two flow control enable bits in the CTRL register.
1181 * The possible values of the "fc" parameter are:
1182 * 0: Flow control is completely disabled
1183 * 1: Rx flow control is enabled (we can receive pause frames, but
1184 * not send pause frames).
1185 * 2: Tx flow control is enabled (we can send pause frames but we do
1186 * not support receiving pause frames).
1187 * 3: Both Rx and TX flow control (symmetric) are enabled.
1191 /* Flow control is completely disabled by a software over-ride. */
1192 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
1194 case e1000_fc_rx_pause:
1195 /* RX Flow control is enabled and TX Flow control is disabled by a
1196 * software over-ride. Since there really isn't a way to advertise
1197 * that we are capable of RX Pause ONLY, we will advertise that we
1198 * support both symmetric and asymmetric RX PAUSE. Later, we will
1199 * disable the adapter's ability to send PAUSE frames.
1201 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
1203 case e1000_fc_tx_pause:
1204 /* TX Flow control is enabled, and RX Flow control is disabled, by a
1205 * software over-ride.
1207 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
1210 /* Flow control (both RX and TX) is enabled by a software over-ride. */
1211 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
1214 DEBUGOUT("Flow control param set incorrectly\n");
1215 return -E1000_ERR_CONFIG;
1219 /* Since auto-negotiation is enabled, take the link out of reset (the link
1220 * will be in reset, because we previously reset the chip). This will
1221 * restart auto-negotiation. If auto-neogtiation is successful then the
1222 * link-up status bit will be set and the flow control enable bits (RFCE
1223 * and TFCE) will be set according to their negotiated value.
1225 DEBUGOUT("Auto-negotiation enabled\n");
1227 E1000_WRITE_REG(hw, TXCW, txcw);
1228 E1000_WRITE_REG(hw, CTRL, ctrl);
1229 E1000_WRITE_FLUSH(hw);
1234 /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
1235 * indication in the Device Status Register. Time-out if a link isn't
1236 * seen in 500 milliseconds seconds (Auto-negotiation should complete in
1237 * less than 500 milliseconds even if the other end is doing it in SW).
1238 * For internal serdes, we just assume a signal is present, then poll.
1240 if(hw->media_type == e1000_media_type_internal_serdes ||
1241 (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
1242 DEBUGOUT("Looking for Link\n");
1243 for(i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
1245 status = E1000_READ_REG(hw, STATUS);
1246 if(status & E1000_STATUS_LU) break;
1248 if(i == (LINK_UP_TIMEOUT / 10)) {
1249 DEBUGOUT("Never got a valid link from auto-neg!!!\n");
1250 hw->autoneg_failed = 1;
1251 /* AutoNeg failed to achieve a link, so we'll call
1252 * e1000_check_for_link. This routine will force the link up if
1253 * we detect a signal. This will allow us to communicate with
1254 * non-autonegotiating link partners.
1256 ret_val = e1000_check_for_link(hw);
1258 DEBUGOUT("Error while checking for link\n");
1261 hw->autoneg_failed = 0;
1263 hw->autoneg_failed = 0;
1264 DEBUGOUT("Valid Link Found\n");
1267 DEBUGOUT("No Signal Detected\n");
1269 return E1000_SUCCESS;
1272 /******************************************************************************
1273 * Make sure we have a valid PHY and change PHY mode before link setup.
1275 * hw - Struct containing variables accessed by shared code
1276 ******************************************************************************/
1278 e1000_copper_link_preconfig(struct e1000_hw *hw)
1284 DEBUGFUNC("e1000_copper_link_preconfig");
1286 ctrl = E1000_READ_REG(hw, CTRL);
1287 /* With 82543, we need to force speed and duplex on the MAC equal to what
1288 * the PHY speed and duplex configuration is. In addition, we need to
1289 * perform a hardware reset on the PHY to take it out of reset.
1291 if(hw->mac_type > e1000_82543) {
1292 ctrl |= E1000_CTRL_SLU;
1293 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1294 E1000_WRITE_REG(hw, CTRL, ctrl);
1296 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
1297 E1000_WRITE_REG(hw, CTRL, ctrl);
1298 ret_val = e1000_phy_hw_reset(hw);
1303 /* Make sure we have a valid PHY */
1304 ret_val = e1000_detect_gig_phy(hw);
1306 DEBUGOUT("Error, did not detect valid phy.\n");
1309 DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
1311 /* Set PHY to class A mode (if necessary) */
1312 ret_val = e1000_set_phy_mode(hw);
1316 if((hw->mac_type == e1000_82545_rev_3) ||
1317 (hw->mac_type == e1000_82546_rev_3)) {
1318 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
1319 phy_data |= 0x00000008;
1320 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
1323 if(hw->mac_type <= e1000_82543 ||
1324 hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
1325 hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
1326 hw->phy_reset_disable = FALSE;
1328 return E1000_SUCCESS;
1332 /********************************************************************
1333 * Copper link setup for e1000_phy_igp series.
1335 * hw - Struct containing variables accessed by shared code
1336 *********************************************************************/
1338 e1000_copper_link_igp_setup(struct e1000_hw *hw)
1344 DEBUGFUNC("e1000_copper_link_igp_setup");
1346 if (hw->phy_reset_disable)
1347 return E1000_SUCCESS;
1349 ret_val = e1000_phy_reset(hw);
1351 DEBUGOUT("Error Resetting the PHY\n");
1355 /* Wait 10ms for MAC to configure PHY from eeprom settings */
1357 if (hw->mac_type != e1000_ich8lan) {
1358 /* Configure activity LED after PHY reset */
1359 led_ctrl = E1000_READ_REG(hw, LEDCTL);
1360 led_ctrl &= IGP_ACTIVITY_LED_MASK;
1361 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
1362 E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
1365 /* The NVM settings will configure LPLU in D3 for IGP2 and IGP3 PHYs */
1366 if (hw->phy_type == e1000_phy_igp) {
1367 /* disable lplu d3 during driver init */
1368 ret_val = e1000_set_d3_lplu_state(hw, FALSE);
1370 DEBUGOUT("Error Disabling LPLU D3\n");
1375 /* disable lplu d0 during driver init */
1376 ret_val = e1000_set_d0_lplu_state(hw, FALSE);
1378 DEBUGOUT("Error Disabling LPLU D0\n");
1381 /* Configure mdi-mdix settings */
1382 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
1386 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
1387 hw->dsp_config_state = e1000_dsp_config_disabled;
1388 /* Force MDI for earlier revs of the IGP PHY */
1389 phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | IGP01E1000_PSCR_FORCE_MDI_MDIX);
1393 hw->dsp_config_state = e1000_dsp_config_enabled;
1394 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
1398 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
1401 phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
1405 phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
1409 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
1413 /* set auto-master slave resolution settings */
1415 e1000_ms_type phy_ms_setting = hw->master_slave;
1417 if(hw->ffe_config_state == e1000_ffe_config_active)
1418 hw->ffe_config_state = e1000_ffe_config_enabled;
1420 if(hw->dsp_config_state == e1000_dsp_config_activated)
1421 hw->dsp_config_state = e1000_dsp_config_enabled;
1423 /* when autonegotiation advertisment is only 1000Mbps then we
1424 * should disable SmartSpeed and enable Auto MasterSlave
1425 * resolution as hardware default. */
1426 if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
1427 /* Disable SmartSpeed */
1428 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
1431 phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1432 ret_val = e1000_write_phy_reg(hw,
1433 IGP01E1000_PHY_PORT_CONFIG,
1437 /* Set auto Master/Slave resolution process */
1438 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1441 phy_data &= ~CR_1000T_MS_ENABLE;
1442 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1447 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1451 /* load defaults for future use */
1452 hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
1453 ((phy_data & CR_1000T_MS_VALUE) ?
1454 e1000_ms_force_master :
1455 e1000_ms_force_slave) :
1458 switch (phy_ms_setting) {
1459 case e1000_ms_force_master:
1460 phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
1462 case e1000_ms_force_slave:
1463 phy_data |= CR_1000T_MS_ENABLE;
1464 phy_data &= ~(CR_1000T_MS_VALUE);
1467 phy_data &= ~CR_1000T_MS_ENABLE;
1471 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1476 return E1000_SUCCESS;
1479 /********************************************************************
1480 * Copper link setup for e1000_phy_gg82563 series.
1482 * hw - Struct containing variables accessed by shared code
1483 *********************************************************************/
1485 e1000_copper_link_ggp_setup(struct e1000_hw *hw)
1491 DEBUGFUNC("e1000_copper_link_ggp_setup");
1493 if(!hw->phy_reset_disable) {
1495 /* Enable CRS on TX for half-duplex operation. */
1496 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
1501 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
1502 /* Use 25MHz for both link down and 1000BASE-T for Tx clock */
1503 phy_data |= GG82563_MSCR_TX_CLK_1000MBPS_25MHZ;
1505 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
1511 * MDI/MDI-X = 0 (default)
1512 * 0 - Auto for all speeds
1515 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1517 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL, &phy_data);
1521 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
1525 phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
1528 phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
1532 phy_data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
1537 * disable_polarity_correction = 0 (default)
1538 * Automatic Correction for Reversed Cable Polarity
1542 phy_data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1543 if(hw->disable_polarity_correction == 1)
1544 phy_data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1545 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL, phy_data);
1550 /* SW Reset the PHY so all changes take effect */
1551 ret_val = e1000_phy_reset(hw);
1553 DEBUGOUT("Error Resetting the PHY\n");
1556 } /* phy_reset_disable */
1558 if (hw->mac_type == e1000_80003es2lan) {
1559 /* Bypass RX and TX FIFO's */
1560 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_FIFO_CTRL,
1561 E1000_KUMCTRLSTA_FIFO_CTRL_RX_BYPASS |
1562 E1000_KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
1566 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, &phy_data);
1570 phy_data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
1571 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, phy_data);
1576 reg_data = E1000_READ_REG(hw, CTRL_EXT);
1577 reg_data &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
1578 E1000_WRITE_REG(hw, CTRL_EXT, reg_data);
1580 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
1585 /* Do not init these registers when the HW is in IAMT mode, since the
1586 * firmware will have already initialized them. We only initialize
1587 * them if the HW is not in IAMT mode.
1589 if (e1000_check_mng_mode(hw) == FALSE) {
1590 /* Enable Electrical Idle on the PHY */
1591 phy_data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
1592 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
1597 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
1602 phy_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1604 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
1610 /* Workaround: Disable padding in Kumeran interface in the MAC
1611 * and in the PHY to avoid CRC errors.
1613 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
1617 phy_data |= GG82563_ICR_DIS_PADDING;
1618 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
1624 return E1000_SUCCESS;
1627 /********************************************************************
1628 * Copper link setup for e1000_phy_m88 series.
1630 * hw - Struct containing variables accessed by shared code
1631 *********************************************************************/
1633 e1000_copper_link_mgp_setup(struct e1000_hw *hw)
1638 DEBUGFUNC("e1000_copper_link_mgp_setup");
1640 if(hw->phy_reset_disable)
1641 return E1000_SUCCESS;
1643 /* Enable CRS on TX. This must be set for half-duplex operation. */
1644 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
1648 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1651 * MDI/MDI-X = 0 (default)
1652 * 0 - Auto for all speeds
1655 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1657 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
1661 phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
1664 phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
1667 phy_data |= M88E1000_PSCR_AUTO_X_1000T;
1671 phy_data |= M88E1000_PSCR_AUTO_X_MODE;
1676 * disable_polarity_correction = 0 (default)
1677 * Automatic Correction for Reversed Cable Polarity
1681 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
1682 if(hw->disable_polarity_correction == 1)
1683 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
1684 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
1688 if (hw->phy_revision < M88E1011_I_REV_4) {
1689 /* Force TX_CLK in the Extended PHY Specific Control Register
1692 ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
1696 phy_data |= M88E1000_EPSCR_TX_CLK_25;
1698 if ((hw->phy_revision == E1000_REVISION_2) &&
1699 (hw->phy_id == M88E1111_I_PHY_ID)) {
1700 /* Vidalia Phy, set the downshift counter to 5x */
1701 phy_data &= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK);
1702 phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X;
1703 ret_val = e1000_write_phy_reg(hw,
1704 M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
1708 /* Configure Master and Slave downshift values */
1709 phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
1710 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
1711 phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
1712 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
1713 ret_val = e1000_write_phy_reg(hw,
1714 M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
1720 /* SW Reset the PHY so all changes take effect */
1721 ret_val = e1000_phy_reset(hw);
1723 DEBUGOUT("Error Resetting the PHY\n");
1727 return E1000_SUCCESS;
1730 /********************************************************************
1731 * Setup auto-negotiation and flow control advertisements,
1732 * and then perform auto-negotiation.
1734 * hw - Struct containing variables accessed by shared code
1735 *********************************************************************/
1737 e1000_copper_link_autoneg(struct e1000_hw *hw)
1742 DEBUGFUNC("e1000_copper_link_autoneg");
1744 /* Perform some bounds checking on the hw->autoneg_advertised
1745 * parameter. If this variable is zero, then set it to the default.
1747 hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
1749 /* If autoneg_advertised is zero, we assume it was not defaulted
1750 * by the calling code so we set to advertise full capability.
1752 if(hw->autoneg_advertised == 0)
1753 hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
1755 /* IFE phy only supports 10/100 */
1756 if (hw->phy_type == e1000_phy_ife)
1757 hw->autoneg_advertised &= AUTONEG_ADVERTISE_10_100_ALL;
1759 DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
1760 ret_val = e1000_phy_setup_autoneg(hw);
1762 DEBUGOUT("Error Setting up Auto-Negotiation\n");
1765 DEBUGOUT("Restarting Auto-Neg\n");
1767 /* Restart auto-negotiation by setting the Auto Neg Enable bit and
1768 * the Auto Neg Restart bit in the PHY control register.
1770 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
1774 phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
1775 ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
1779 /* Does the user want to wait for Auto-Neg to complete here, or
1780 * check at a later time (for example, callback routine).
1782 if(hw->wait_autoneg_complete) {
1783 ret_val = e1000_wait_autoneg(hw);
1785 DEBUGOUT("Error while waiting for autoneg to complete\n");
1790 hw->get_link_status = TRUE;
1792 return E1000_SUCCESS;
1796 /******************************************************************************
1797 * Config the MAC and the PHY after link is up.
1798 * 1) Set up the MAC to the current PHY speed/duplex
1799 * if we are on 82543. If we
1800 * are on newer silicon, we only need to configure
1801 * collision distance in the Transmit Control Register.
1802 * 2) Set up flow control on the MAC to that established with
1804 * 3) Config DSP to improve Gigabit link quality for some PHY revisions.
1806 * hw - Struct containing variables accessed by shared code
1807 ******************************************************************************/
1809 e1000_copper_link_postconfig(struct e1000_hw *hw)
1812 DEBUGFUNC("e1000_copper_link_postconfig");
1814 if(hw->mac_type >= e1000_82544) {
1815 e1000_config_collision_dist(hw);
1817 ret_val = e1000_config_mac_to_phy(hw);
1819 DEBUGOUT("Error configuring MAC to PHY settings\n");
1823 ret_val = e1000_config_fc_after_link_up(hw);
1825 DEBUGOUT("Error Configuring Flow Control\n");
1829 /* Config DSP to improve Giga link quality */
1830 if(hw->phy_type == e1000_phy_igp) {
1831 ret_val = e1000_config_dsp_after_link_change(hw, TRUE);
1833 DEBUGOUT("Error Configuring DSP after link up\n");
1838 return E1000_SUCCESS;
1841 /******************************************************************************
1842 * Detects which PHY is present and setup the speed and duplex
1844 * hw - Struct containing variables accessed by shared code
1845 ******************************************************************************/
1847 e1000_setup_copper_link(struct e1000_hw *hw)
1854 DEBUGFUNC("e1000_setup_copper_link");
1856 switch (hw->mac_type) {
1857 case e1000_80003es2lan:
1859 /* Set the mac to wait the maximum time between each
1860 * iteration and increase the max iterations when
1861 * polling the phy; this fixes erroneous timeouts at 10Mbps. */
1862 ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF);
1865 ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data);
1869 ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data);
1876 /* Check if it is a valid PHY and set PHY mode if necessary. */
1877 ret_val = e1000_copper_link_preconfig(hw);
1881 switch (hw->mac_type) {
1882 case e1000_80003es2lan:
1883 /* Kumeran registers are written-only */
1884 reg_data = E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT;
1885 reg_data |= E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING;
1886 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_INB_CTRL,
1895 if (hw->phy_type == e1000_phy_igp ||
1896 hw->phy_type == e1000_phy_igp_3 ||
1897 hw->phy_type == e1000_phy_igp_2) {
1898 ret_val = e1000_copper_link_igp_setup(hw);
1901 } else if (hw->phy_type == e1000_phy_m88) {
1902 ret_val = e1000_copper_link_mgp_setup(hw);
1905 } else if (hw->phy_type == e1000_phy_gg82563) {
1906 ret_val = e1000_copper_link_ggp_setup(hw);
1912 /* Setup autoneg and flow control advertisement
1913 * and perform autonegotiation */
1914 ret_val = e1000_copper_link_autoneg(hw);
1918 /* PHY will be set to 10H, 10F, 100H,or 100F
1919 * depending on value from forced_speed_duplex. */
1920 DEBUGOUT("Forcing speed and duplex\n");
1921 ret_val = e1000_phy_force_speed_duplex(hw);
1923 DEBUGOUT("Error Forcing Speed and Duplex\n");
1928 /* Check link status. Wait up to 100 microseconds for link to become
1931 for(i = 0; i < 10; i++) {
1932 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
1935 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
1939 if(phy_data & MII_SR_LINK_STATUS) {
1940 /* Config the MAC and PHY after link is up */
1941 ret_val = e1000_copper_link_postconfig(hw);
1945 DEBUGOUT("Valid link established!!!\n");
1946 return E1000_SUCCESS;
1951 DEBUGOUT("Unable to establish link!!!\n");
1952 return E1000_SUCCESS;
1955 /******************************************************************************
1956 * Configure the MAC-to-PHY interface for 10/100Mbps
1958 * hw - Struct containing variables accessed by shared code
1959 ******************************************************************************/
1961 e1000_configure_kmrn_for_10_100(struct e1000_hw *hw, uint16_t duplex)
1963 int32_t ret_val = E1000_SUCCESS;
1967 DEBUGFUNC("e1000_configure_kmrn_for_10_100");
1969 reg_data = E1000_KUMCTRLSTA_HD_CTRL_10_100_DEFAULT;
1970 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
1975 /* Configure Transmit Inter-Packet Gap */
1976 tipg = E1000_READ_REG(hw, TIPG);
1977 tipg &= ~E1000_TIPG_IPGT_MASK;
1978 tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_10_100;
1979 E1000_WRITE_REG(hw, TIPG, tipg);
1981 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
1986 if (duplex == HALF_DUPLEX)
1987 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1989 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1991 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1997 e1000_configure_kmrn_for_1000(struct e1000_hw *hw)
1999 int32_t ret_val = E1000_SUCCESS;
2003 DEBUGFUNC("e1000_configure_kmrn_for_1000");
2005 reg_data = E1000_KUMCTRLSTA_HD_CTRL_1000_DEFAULT;
2006 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
2011 /* Configure Transmit Inter-Packet Gap */
2012 tipg = E1000_READ_REG(hw, TIPG);
2013 tipg &= ~E1000_TIPG_IPGT_MASK;
2014 tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
2015 E1000_WRITE_REG(hw, TIPG, tipg);
2017 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
2022 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
2023 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
2028 /******************************************************************************
2029 * Configures PHY autoneg and flow control advertisement settings
2031 * hw - Struct containing variables accessed by shared code
2032 ******************************************************************************/
2034 e1000_phy_setup_autoneg(struct e1000_hw *hw)
2037 uint16_t mii_autoneg_adv_reg;
2038 uint16_t mii_1000t_ctrl_reg;
2040 DEBUGFUNC("e1000_phy_setup_autoneg");
2042 /* Read the MII Auto-Neg Advertisement Register (Address 4). */
2043 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
2047 if (hw->phy_type != e1000_phy_ife) {
2048 /* Read the MII 1000Base-T Control Register (Address 9). */
2049 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
2053 mii_1000t_ctrl_reg=0;
2055 /* Need to parse both autoneg_advertised and fc and set up
2056 * the appropriate PHY registers. First we will parse for
2057 * autoneg_advertised software override. Since we can advertise
2058 * a plethora of combinations, we need to check each bit
2062 /* First we clear all the 10/100 mb speed bits in the Auto-Neg
2063 * Advertisement Register (Address 4) and the 1000 mb speed bits in
2064 * the 1000Base-T Control Register (Address 9).
2066 mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
2067 mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
2069 DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
2071 /* Do we want to advertise 10 Mb Half Duplex? */
2072 if(hw->autoneg_advertised & ADVERTISE_10_HALF) {
2073 DEBUGOUT("Advertise 10mb Half duplex\n");
2074 mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
2077 /* Do we want to advertise 10 Mb Full Duplex? */
2078 if(hw->autoneg_advertised & ADVERTISE_10_FULL) {
2079 DEBUGOUT("Advertise 10mb Full duplex\n");
2080 mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
2083 /* Do we want to advertise 100 Mb Half Duplex? */
2084 if(hw->autoneg_advertised & ADVERTISE_100_HALF) {
2085 DEBUGOUT("Advertise 100mb Half duplex\n");
2086 mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
2089 /* Do we want to advertise 100 Mb Full Duplex? */
2090 if(hw->autoneg_advertised & ADVERTISE_100_FULL) {
2091 DEBUGOUT("Advertise 100mb Full duplex\n");
2092 mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
2095 /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
2096 if(hw->autoneg_advertised & ADVERTISE_1000_HALF) {
2097 DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
2100 /* Do we want to advertise 1000 Mb Full Duplex? */
2101 if(hw->autoneg_advertised & ADVERTISE_1000_FULL) {
2102 DEBUGOUT("Advertise 1000mb Full duplex\n");
2103 mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
2104 if (hw->phy_type == e1000_phy_ife) {
2105 DEBUGOUT("e1000_phy_ife is a 10/100 PHY. Gigabit speed is not supported.\n");
2109 /* Check for a software override of the flow control settings, and
2110 * setup the PHY advertisement registers accordingly. If
2111 * auto-negotiation is enabled, then software will have to set the
2112 * "PAUSE" bits to the correct value in the Auto-Negotiation
2113 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
2115 * The possible values of the "fc" parameter are:
2116 * 0: Flow control is completely disabled
2117 * 1: Rx flow control is enabled (we can receive pause frames
2118 * but not send pause frames).
2119 * 2: Tx flow control is enabled (we can send pause frames
2120 * but we do not support receiving pause frames).
2121 * 3: Both Rx and TX flow control (symmetric) are enabled.
2122 * other: No software override. The flow control configuration
2123 * in the EEPROM is used.
2126 case e1000_fc_none: /* 0 */
2127 /* Flow control (RX & TX) is completely disabled by a
2128 * software over-ride.
2130 mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
2132 case e1000_fc_rx_pause: /* 1 */
2133 /* RX Flow control is enabled, and TX Flow control is
2134 * disabled, by a software over-ride.
2136 /* Since there really isn't a way to advertise that we are
2137 * capable of RX Pause ONLY, we will advertise that we
2138 * support both symmetric and asymmetric RX PAUSE. Later
2139 * (in e1000_config_fc_after_link_up) we will disable the
2140 *hw's ability to send PAUSE frames.
2142 mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
2144 case e1000_fc_tx_pause: /* 2 */
2145 /* TX Flow control is enabled, and RX Flow control is
2146 * disabled, by a software over-ride.
2148 mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
2149 mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
2151 case e1000_fc_full: /* 3 */
2152 /* Flow control (both RX and TX) is enabled by a software
2155 mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
2158 DEBUGOUT("Flow control param set incorrectly\n");
2159 return -E1000_ERR_CONFIG;
2162 ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
2166 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
2168 if (hw->phy_type != e1000_phy_ife) {
2169 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
2174 return E1000_SUCCESS;
2177 /******************************************************************************
2178 * Force PHY speed and duplex settings to hw->forced_speed_duplex
2180 * hw - Struct containing variables accessed by shared code
2181 ******************************************************************************/
2183 e1000_phy_force_speed_duplex(struct e1000_hw *hw)
2187 uint16_t mii_ctrl_reg;
2188 uint16_t mii_status_reg;
2192 DEBUGFUNC("e1000_phy_force_speed_duplex");
2194 /* Turn off Flow control if we are forcing speed and duplex. */
2195 hw->fc = e1000_fc_none;
2197 DEBUGOUT1("hw->fc = %d\n", hw->fc);
2199 /* Read the Device Control Register. */
2200 ctrl = E1000_READ_REG(hw, CTRL);
2202 /* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
2203 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
2204 ctrl &= ~(DEVICE_SPEED_MASK);
2206 /* Clear the Auto Speed Detect Enable bit. */
2207 ctrl &= ~E1000_CTRL_ASDE;
2209 /* Read the MII Control Register. */
2210 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &mii_ctrl_reg);
2214 /* We need to disable autoneg in order to force link and duplex. */
2216 mii_ctrl_reg &= ~MII_CR_AUTO_NEG_EN;
2218 /* Are we forcing Full or Half Duplex? */
2219 if(hw->forced_speed_duplex == e1000_100_full ||
2220 hw->forced_speed_duplex == e1000_10_full) {
2221 /* We want to force full duplex so we SET the full duplex bits in the
2222 * Device and MII Control Registers.
2224 ctrl |= E1000_CTRL_FD;
2225 mii_ctrl_reg |= MII_CR_FULL_DUPLEX;
2226 DEBUGOUT("Full Duplex\n");
2228 /* We want to force half duplex so we CLEAR the full duplex bits in
2229 * the Device and MII Control Registers.
2231 ctrl &= ~E1000_CTRL_FD;
2232 mii_ctrl_reg &= ~MII_CR_FULL_DUPLEX;
2233 DEBUGOUT("Half Duplex\n");
2236 /* Are we forcing 100Mbps??? */
2237 if(hw->forced_speed_duplex == e1000_100_full ||
2238 hw->forced_speed_duplex == e1000_100_half) {
2239 /* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
2240 ctrl |= E1000_CTRL_SPD_100;
2241 mii_ctrl_reg |= MII_CR_SPEED_100;
2242 mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
2243 DEBUGOUT("Forcing 100mb ");
2245 /* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
2246 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2247 mii_ctrl_reg |= MII_CR_SPEED_10;
2248 mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
2249 DEBUGOUT("Forcing 10mb ");
2252 e1000_config_collision_dist(hw);
2254 /* Write the configured values back to the Device Control Reg. */
2255 E1000_WRITE_REG(hw, CTRL, ctrl);
2257 if ((hw->phy_type == e1000_phy_m88) ||
2258 (hw->phy_type == e1000_phy_gg82563)) {
2259 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
2263 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
2264 * forced whenever speed are duplex are forced.
2266 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
2267 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
2271 DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data);
2273 /* Need to reset the PHY or these changes will be ignored */
2274 mii_ctrl_reg |= MII_CR_RESET;
2275 /* Disable MDI-X support for 10/100 */
2276 } else if (hw->phy_type == e1000_phy_ife) {
2277 ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
2281 phy_data &= ~IFE_PMC_AUTO_MDIX;
2282 phy_data &= ~IFE_PMC_FORCE_MDIX;
2284 ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data);
2288 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
2289 * forced whenever speed or duplex are forced.
2291 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
2295 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
2296 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
2298 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
2303 /* Write back the modified PHY MII control register. */
2304 ret_val = e1000_write_phy_reg(hw, PHY_CTRL, mii_ctrl_reg);
2310 /* The wait_autoneg_complete flag may be a little misleading here.
2311 * Since we are forcing speed and duplex, Auto-Neg is not enabled.
2312 * But we do want to delay for a period while forcing only so we
2313 * don't generate false No Link messages. So we will wait here
2314 * only if the user has set wait_autoneg_complete to 1, which is
2317 if(hw->wait_autoneg_complete) {
2318 /* We will wait for autoneg to complete. */
2319 DEBUGOUT("Waiting for forced speed/duplex link.\n");
2322 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
2323 for(i = PHY_FORCE_TIME; i > 0; i--) {
2324 /* Read the MII Status Register and wait for Auto-Neg Complete bit
2327 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2331 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2335 if(mii_status_reg & MII_SR_LINK_STATUS) break;
2339 ((hw->phy_type == e1000_phy_m88) ||
2340 (hw->phy_type == e1000_phy_gg82563))) {
2341 /* We didn't get link. Reset the DSP and wait again for link. */
2342 ret_val = e1000_phy_reset_dsp(hw);
2344 DEBUGOUT("Error Resetting PHY DSP\n");
2348 /* This loop will early-out if the link condition has been met. */
2349 for(i = PHY_FORCE_TIME; i > 0; i--) {
2350 if(mii_status_reg & MII_SR_LINK_STATUS) break;
2352 /* Read the MII Status Register and wait for Auto-Neg Complete bit
2355 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2359 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2365 if (hw->phy_type == e1000_phy_m88) {
2366 /* Because we reset the PHY above, we need to re-force TX_CLK in the
2367 * Extended PHY Specific Control Register to 25MHz clock. This value
2368 * defaults back to a 2.5MHz clock when the PHY is reset.
2370 ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
2374 phy_data |= M88E1000_EPSCR_TX_CLK_25;
2375 ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
2379 /* In addition, because of the s/w reset above, we need to enable CRS on
2380 * TX. This must be set for both full and half duplex operation.
2382 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
2386 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
2387 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
2391 if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
2393 (hw->forced_speed_duplex == e1000_10_full ||
2394 hw->forced_speed_duplex == e1000_10_half)) {
2395 ret_val = e1000_polarity_reversal_workaround(hw);
2399 } else if (hw->phy_type == e1000_phy_gg82563) {
2400 /* The TX_CLK of the Extended PHY Specific Control Register defaults
2401 * to 2.5MHz on a reset. We need to re-force it back to 25MHz, if
2402 * we're not in a forced 10/duplex configuration. */
2403 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
2407 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
2408 if ((hw->forced_speed_duplex == e1000_10_full) ||
2409 (hw->forced_speed_duplex == e1000_10_half))
2410 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5MHZ;
2412 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25MHZ;
2414 /* Also due to the reset, we need to enable CRS on Tx. */
2415 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
2417 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
2421 return E1000_SUCCESS;
2424 /******************************************************************************
2425 * Sets the collision distance in the Transmit Control register
2427 * hw - Struct containing variables accessed by shared code
2429 * Link should have been established previously. Reads the speed and duplex
2430 * information from the Device Status register.
2431 ******************************************************************************/
2433 e1000_config_collision_dist(struct e1000_hw *hw)
2435 uint32_t tctl, coll_dist;
2437 DEBUGFUNC("e1000_config_collision_dist");
2439 if (hw->mac_type < e1000_82543)
2440 coll_dist = E1000_COLLISION_DISTANCE_82542;
2442 coll_dist = E1000_COLLISION_DISTANCE;
2444 tctl = E1000_READ_REG(hw, TCTL);
2446 tctl &= ~E1000_TCTL_COLD;
2447 tctl |= coll_dist << E1000_COLD_SHIFT;
2449 E1000_WRITE_REG(hw, TCTL, tctl);
2450 E1000_WRITE_FLUSH(hw);
2453 /******************************************************************************
2454 * Sets MAC speed and duplex settings to reflect the those in the PHY
2456 * hw - Struct containing variables accessed by shared code
2457 * mii_reg - data to write to the MII control register
2459 * The contents of the PHY register containing the needed information need to
2461 ******************************************************************************/
2463 e1000_config_mac_to_phy(struct e1000_hw *hw)
2469 DEBUGFUNC("e1000_config_mac_to_phy");
2471 /* 82544 or newer MAC, Auto Speed Detection takes care of
2472 * MAC speed/duplex configuration.*/
2473 if (hw->mac_type >= e1000_82544)
2474 return E1000_SUCCESS;
2476 /* Read the Device Control Register and set the bits to Force Speed
2479 ctrl = E1000_READ_REG(hw, CTRL);
2480 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
2481 ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
2483 /* Set up duplex in the Device Control and Transmit Control
2484 * registers depending on negotiated values.
2486 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
2490 if(phy_data & M88E1000_PSSR_DPLX)
2491 ctrl |= E1000_CTRL_FD;
2493 ctrl &= ~E1000_CTRL_FD;
2495 e1000_config_collision_dist(hw);
2497 /* Set up speed in the Device Control register depending on
2498 * negotiated values.
2500 if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
2501 ctrl |= E1000_CTRL_SPD_1000;
2502 else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
2503 ctrl |= E1000_CTRL_SPD_100;
2505 /* Write the configured values back to the Device Control Reg. */
2506 E1000_WRITE_REG(hw, CTRL, ctrl);
2507 return E1000_SUCCESS;
2510 /******************************************************************************
2511 * Forces the MAC's flow control settings.
2513 * hw - Struct containing variables accessed by shared code
2515 * Sets the TFCE and RFCE bits in the device control register to reflect
2516 * the adapter settings. TFCE and RFCE need to be explicitly set by
2517 * software when a Copper PHY is used because autonegotiation is managed
2518 * by the PHY rather than the MAC. Software must also configure these
2519 * bits when link is forced on a fiber connection.
2520 *****************************************************************************/
2522 e1000_force_mac_fc(struct e1000_hw *hw)
2526 DEBUGFUNC("e1000_force_mac_fc");
2528 /* Get the current configuration of the Device Control Register */
2529 ctrl = E1000_READ_REG(hw, CTRL);
2531 /* Because we didn't get link via the internal auto-negotiation
2532 * mechanism (we either forced link or we got link via PHY
2533 * auto-neg), we have to manually enable/disable transmit an
2534 * receive flow control.
2536 * The "Case" statement below enables/disable flow control
2537 * according to the "hw->fc" parameter.
2539 * The possible values of the "fc" parameter are:
2540 * 0: Flow control is completely disabled
2541 * 1: Rx flow control is enabled (we can receive pause
2542 * frames but not send pause frames).
2543 * 2: Tx flow control is enabled (we can send pause frames
2544 * frames but we do not receive pause frames).
2545 * 3: Both Rx and TX flow control (symmetric) is enabled.
2546 * other: No other values should be possible at this point.
2551 ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
2553 case e1000_fc_rx_pause:
2554 ctrl &= (~E1000_CTRL_TFCE);
2555 ctrl |= E1000_CTRL_RFCE;
2557 case e1000_fc_tx_pause:
2558 ctrl &= (~E1000_CTRL_RFCE);
2559 ctrl |= E1000_CTRL_TFCE;
2562 ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
2565 DEBUGOUT("Flow control param set incorrectly\n");
2566 return -E1000_ERR_CONFIG;
2569 /* Disable TX Flow Control for 82542 (rev 2.0) */
2570 if(hw->mac_type == e1000_82542_rev2_0)
2571 ctrl &= (~E1000_CTRL_TFCE);
2573 E1000_WRITE_REG(hw, CTRL, ctrl);
2574 return E1000_SUCCESS;
2577 /******************************************************************************
2578 * Configures flow control settings after link is established
2580 * hw - Struct containing variables accessed by shared code
2582 * Should be called immediately after a valid link has been established.
2583 * Forces MAC flow control settings if link was forced. When in MII/GMII mode
2584 * and autonegotiation is enabled, the MAC flow control settings will be set
2585 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
2586 * and RFCE bits will be automaticaly set to the negotiated flow control mode.
2587 *****************************************************************************/
2589 e1000_config_fc_after_link_up(struct e1000_hw *hw)
2592 uint16_t mii_status_reg;
2593 uint16_t mii_nway_adv_reg;
2594 uint16_t mii_nway_lp_ability_reg;
2598 DEBUGFUNC("e1000_config_fc_after_link_up");
2600 /* Check for the case where we have fiber media and auto-neg failed
2601 * so we had to force link. In this case, we need to force the
2602 * configuration of the MAC to match the "fc" parameter.
2604 if(((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
2605 ((hw->media_type == e1000_media_type_internal_serdes) && (hw->autoneg_failed)) ||
2606 ((hw->media_type == e1000_media_type_copper) && (!hw->autoneg))) {
2607 ret_val = e1000_force_mac_fc(hw);
2609 DEBUGOUT("Error forcing flow control settings\n");
2614 /* Check for the case where we have copper media and auto-neg is
2615 * enabled. In this case, we need to check and see if Auto-Neg
2616 * has completed, and if so, how the PHY and link partner has
2617 * flow control configured.
2619 if((hw->media_type == e1000_media_type_copper) && hw->autoneg) {
2620 /* Read the MII Status Register and check to see if AutoNeg
2621 * has completed. We read this twice because this reg has
2622 * some "sticky" (latched) bits.
2624 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2627 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2631 if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
2632 /* The AutoNeg process has completed, so we now need to
2633 * read both the Auto Negotiation Advertisement Register
2634 * (Address 4) and the Auto_Negotiation Base Page Ability
2635 * Register (Address 5) to determine how flow control was
2638 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
2642 ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
2643 &mii_nway_lp_ability_reg);
2647 /* Two bits in the Auto Negotiation Advertisement Register
2648 * (Address 4) and two bits in the Auto Negotiation Base
2649 * Page Ability Register (Address 5) determine flow control
2650 * for both the PHY and the link partner. The following
2651 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
2652 * 1999, describes these PAUSE resolution bits and how flow
2653 * control is determined based upon these settings.
2654 * NOTE: DC = Don't Care
2656 * LOCAL DEVICE | LINK PARTNER
2657 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
2658 *-------|---------|-------|---------|--------------------
2659 * 0 | 0 | DC | DC | e1000_fc_none
2660 * 0 | 1 | 0 | DC | e1000_fc_none
2661 * 0 | 1 | 1 | 0 | e1000_fc_none
2662 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
2663 * 1 | 0 | 0 | DC | e1000_fc_none
2664 * 1 | DC | 1 | DC | e1000_fc_full
2665 * 1 | 1 | 0 | 0 | e1000_fc_none
2666 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
2669 /* Are both PAUSE bits set to 1? If so, this implies
2670 * Symmetric Flow Control is enabled at both ends. The
2671 * ASM_DIR bits are irrelevant per the spec.
2673 * For Symmetric Flow Control:
2675 * LOCAL DEVICE | LINK PARTNER
2676 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2677 *-------|---------|-------|---------|--------------------
2678 * 1 | DC | 1 | DC | e1000_fc_full
2681 if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
2682 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
2683 /* Now we need to check if the user selected RX ONLY
2684 * of pause frames. In this case, we had to advertise
2685 * FULL flow control because we could not advertise RX
2686 * ONLY. Hence, we must now check to see if we need to
2687 * turn OFF the TRANSMISSION of PAUSE frames.
2689 if(hw->original_fc == e1000_fc_full) {
2690 hw->fc = e1000_fc_full;
2691 DEBUGOUT("Flow Control = FULL.\n");
2693 hw->fc = e1000_fc_rx_pause;
2694 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2697 /* For receiving PAUSE frames ONLY.
2699 * LOCAL DEVICE | LINK PARTNER
2700 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2701 *-------|---------|-------|---------|--------------------
2702 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
2705 else if(!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
2706 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
2707 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
2708 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
2709 hw->fc = e1000_fc_tx_pause;
2710 DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
2712 /* For transmitting PAUSE frames ONLY.
2714 * LOCAL DEVICE | LINK PARTNER
2715 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2716 *-------|---------|-------|---------|--------------------
2717 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
2720 else if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
2721 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
2722 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
2723 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
2724 hw->fc = e1000_fc_rx_pause;
2725 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2727 /* Per the IEEE spec, at this point flow control should be
2728 * disabled. However, we want to consider that we could
2729 * be connected to a legacy switch that doesn't advertise
2730 * desired flow control, but can be forced on the link
2731 * partner. So if we advertised no flow control, that is
2732 * what we will resolve to. If we advertised some kind of
2733 * receive capability (Rx Pause Only or Full Flow Control)
2734 * and the link partner advertised none, we will configure
2735 * ourselves to enable Rx Flow Control only. We can do
2736 * this safely for two reasons: If the link partner really
2737 * didn't want flow control enabled, and we enable Rx, no
2738 * harm done since we won't be receiving any PAUSE frames
2739 * anyway. If the intent on the link partner was to have
2740 * flow control enabled, then by us enabling RX only, we
2741 * can at least receive pause frames and process them.
2742 * This is a good idea because in most cases, since we are
2743 * predominantly a server NIC, more times than not we will
2744 * be asked to delay transmission of packets than asking
2745 * our link partner to pause transmission of frames.
2747 else if((hw->original_fc == e1000_fc_none ||
2748 hw->original_fc == e1000_fc_tx_pause) ||
2749 hw->fc_strict_ieee) {
2750 hw->fc = e1000_fc_none;
2751 DEBUGOUT("Flow Control = NONE.\n");
2753 hw->fc = e1000_fc_rx_pause;
2754 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2757 /* Now we need to do one last check... If we auto-
2758 * negotiated to HALF DUPLEX, flow control should not be
2759 * enabled per IEEE 802.3 spec.
2761 ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
2763 DEBUGOUT("Error getting link speed and duplex\n");
2767 if(duplex == HALF_DUPLEX)
2768 hw->fc = e1000_fc_none;
2770 /* Now we call a subroutine to actually force the MAC
2771 * controller to use the correct flow control settings.
2773 ret_val = e1000_force_mac_fc(hw);
2775 DEBUGOUT("Error forcing flow control settings\n");
2779 DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
2782 return E1000_SUCCESS;
2785 /******************************************************************************
2786 * Checks to see if the link status of the hardware has changed.
2788 * hw - Struct containing variables accessed by shared code
2790 * Called by any function that needs to check the link status of the adapter.
2791 *****************************************************************************/
2793 e1000_check_for_link(struct e1000_hw *hw)
2800 uint32_t signal = 0;
2804 DEBUGFUNC("e1000_check_for_link");
2806 ctrl = E1000_READ_REG(hw, CTRL);
2807 status = E1000_READ_REG(hw, STATUS);
2809 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
2810 * set when the optics detect a signal. On older adapters, it will be
2811 * cleared when there is a signal. This applies to fiber media only.
2813 if((hw->media_type == e1000_media_type_fiber) ||
2814 (hw->media_type == e1000_media_type_internal_serdes)) {
2815 rxcw = E1000_READ_REG(hw, RXCW);
2817 if(hw->media_type == e1000_media_type_fiber) {
2818 signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
2819 if(status & E1000_STATUS_LU)
2820 hw->get_link_status = FALSE;
2824 /* If we have a copper PHY then we only want to go out to the PHY
2825 * registers to see if Auto-Neg has completed and/or if our link
2826 * status has changed. The get_link_status flag will be set if we
2827 * receive a Link Status Change interrupt or we have Rx Sequence
2830 if((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
2831 /* First we want to see if the MII Status Register reports
2832 * link. If so, then we want to get the current speed/duplex
2834 * Read the register twice since the link bit is sticky.
2836 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
2839 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
2843 if(phy_data & MII_SR_LINK_STATUS) {
2844 hw->get_link_status = FALSE;
2845 /* Check if there was DownShift, must be checked immediately after
2847 e1000_check_downshift(hw);
2849 /* If we are on 82544 or 82543 silicon and speed/duplex
2850 * are forced to 10H or 10F, then we will implement the polarity
2851 * reversal workaround. We disable interrupts first, and upon
2852 * returning, place the devices interrupt state to its previous
2853 * value except for the link status change interrupt which will
2854 * happen due to the execution of this workaround.
2857 if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
2859 (hw->forced_speed_duplex == e1000_10_full ||
2860 hw->forced_speed_duplex == e1000_10_half)) {
2861 E1000_WRITE_REG(hw, IMC, 0xffffffff);
2862 ret_val = e1000_polarity_reversal_workaround(hw);
2863 icr = E1000_READ_REG(hw, ICR);
2864 E1000_WRITE_REG(hw, ICS, (icr & ~E1000_ICS_LSC));
2865 E1000_WRITE_REG(hw, IMS, IMS_ENABLE_MASK);
2869 /* No link detected */
2870 e1000_config_dsp_after_link_change(hw, FALSE);
2874 /* If we are forcing speed/duplex, then we simply return since
2875 * we have already determined whether we have link or not.
2877 if(!hw->autoneg) return -E1000_ERR_CONFIG;
2879 /* optimize the dsp settings for the igp phy */
2880 e1000_config_dsp_after_link_change(hw, TRUE);
2882 /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
2883 * have Si on board that is 82544 or newer, Auto
2884 * Speed Detection takes care of MAC speed/duplex
2885 * configuration. So we only need to configure Collision
2886 * Distance in the MAC. Otherwise, we need to force
2887 * speed/duplex on the MAC to the current PHY speed/duplex
2890 if(hw->mac_type >= e1000_82544)
2891 e1000_config_collision_dist(hw);
2893 ret_val = e1000_config_mac_to_phy(hw);
2895 DEBUGOUT("Error configuring MAC to PHY settings\n");
2900 /* Configure Flow Control now that Auto-Neg has completed. First, we
2901 * need to restore the desired flow control settings because we may
2902 * have had to re-autoneg with a different link partner.
2904 ret_val = e1000_config_fc_after_link_up(hw);
2906 DEBUGOUT("Error configuring flow control\n");
2910 /* At this point we know that we are on copper and we have
2911 * auto-negotiated link. These are conditions for checking the link
2912 * partner capability register. We use the link speed to determine if
2913 * TBI compatibility needs to be turned on or off. If the link is not
2914 * at gigabit speed, then TBI compatibility is not needed. If we are
2915 * at gigabit speed, we turn on TBI compatibility.
2917 if(hw->tbi_compatibility_en) {
2918 uint16_t speed, duplex;
2919 ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
2921 DEBUGOUT("Error getting link speed and duplex\n");
2924 if (speed != SPEED_1000) {
2925 /* If link speed is not set to gigabit speed, we do not need
2926 * to enable TBI compatibility.
2928 if(hw->tbi_compatibility_on) {
2929 /* If we previously were in the mode, turn it off. */
2930 rctl = E1000_READ_REG(hw, RCTL);
2931 rctl &= ~E1000_RCTL_SBP;
2932 E1000_WRITE_REG(hw, RCTL, rctl);
2933 hw->tbi_compatibility_on = FALSE;
2936 /* If TBI compatibility is was previously off, turn it on. For
2937 * compatibility with a TBI link partner, we will store bad
2938 * packets. Some frames have an additional byte on the end and
2939 * will look like CRC errors to to the hardware.
2941 if(!hw->tbi_compatibility_on) {
2942 hw->tbi_compatibility_on = TRUE;
2943 rctl = E1000_READ_REG(hw, RCTL);
2944 rctl |= E1000_RCTL_SBP;
2945 E1000_WRITE_REG(hw, RCTL, rctl);
2950 /* If we don't have link (auto-negotiation failed or link partner cannot
2951 * auto-negotiate), the cable is plugged in (we have signal), and our
2952 * link partner is not trying to auto-negotiate with us (we are receiving
2953 * idles or data), we need to force link up. We also need to give
2954 * auto-negotiation time to complete, in case the cable was just plugged
2955 * in. The autoneg_failed flag does this.
2957 else if((((hw->media_type == e1000_media_type_fiber) &&
2958 ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
2959 (hw->media_type == e1000_media_type_internal_serdes)) &&
2960 (!(status & E1000_STATUS_LU)) &&
2961 (!(rxcw & E1000_RXCW_C))) {
2962 if(hw->autoneg_failed == 0) {
2963 hw->autoneg_failed = 1;
2966 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
2968 /* Disable auto-negotiation in the TXCW register */
2969 E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
2971 /* Force link-up and also force full-duplex. */
2972 ctrl = E1000_READ_REG(hw, CTRL);
2973 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
2974 E1000_WRITE_REG(hw, CTRL, ctrl);
2976 /* Configure Flow Control after forcing link up. */
2977 ret_val = e1000_config_fc_after_link_up(hw);
2979 DEBUGOUT("Error configuring flow control\n");
2983 /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
2984 * auto-negotiation in the TXCW register and disable forced link in the
2985 * Device Control register in an attempt to auto-negotiate with our link
2988 else if(((hw->media_type == e1000_media_type_fiber) ||
2989 (hw->media_type == e1000_media_type_internal_serdes)) &&
2990 (ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
2991 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
2992 E1000_WRITE_REG(hw, TXCW, hw->txcw);
2993 E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
2995 hw->serdes_link_down = FALSE;
2997 /* If we force link for non-auto-negotiation switch, check link status
2998 * based on MAC synchronization for internal serdes media type.
3000 else if((hw->media_type == e1000_media_type_internal_serdes) &&
3001 !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
3002 /* SYNCH bit and IV bit are sticky. */
3004 if(E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
3005 if(!(rxcw & E1000_RXCW_IV)) {
3006 hw->serdes_link_down = FALSE;
3007 DEBUGOUT("SERDES: Link is up.\n");
3010 hw->serdes_link_down = TRUE;
3011 DEBUGOUT("SERDES: Link is down.\n");
3014 if((hw->media_type == e1000_media_type_internal_serdes) &&
3015 (E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
3016 hw->serdes_link_down = !(E1000_STATUS_LU & E1000_READ_REG(hw, STATUS));
3018 return E1000_SUCCESS;
3021 /******************************************************************************
3022 * Detects the current speed and duplex settings of the hardware.
3024 * hw - Struct containing variables accessed by shared code
3025 * speed - Speed of the connection
3026 * duplex - Duplex setting of the connection
3027 *****************************************************************************/
3029 e1000_get_speed_and_duplex(struct e1000_hw *hw,
3037 DEBUGFUNC("e1000_get_speed_and_duplex");
3039 if(hw->mac_type >= e1000_82543) {
3040 status = E1000_READ_REG(hw, STATUS);
3041 if(status & E1000_STATUS_SPEED_1000) {
3042 *speed = SPEED_1000;
3043 DEBUGOUT("1000 Mbs, ");
3044 } else if(status & E1000_STATUS_SPEED_100) {
3046 DEBUGOUT("100 Mbs, ");
3049 DEBUGOUT("10 Mbs, ");
3052 if(status & E1000_STATUS_FD) {
3053 *duplex = FULL_DUPLEX;
3054 DEBUGOUT("Full Duplex\n");
3056 *duplex = HALF_DUPLEX;
3057 DEBUGOUT(" Half Duplex\n");
3060 DEBUGOUT("1000 Mbs, Full Duplex\n");
3061 *speed = SPEED_1000;
3062 *duplex = FULL_DUPLEX;
3065 /* IGP01 PHY may advertise full duplex operation after speed downgrade even
3066 * if it is operating at half duplex. Here we set the duplex settings to
3067 * match the duplex in the link partner's capabilities.
3069 if(hw->phy_type == e1000_phy_igp && hw->speed_downgraded) {
3070 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_EXP, &phy_data);
3074 if(!(phy_data & NWAY_ER_LP_NWAY_CAPS))
3075 *duplex = HALF_DUPLEX;
3077 ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY, &phy_data);
3080 if((*speed == SPEED_100 && !(phy_data & NWAY_LPAR_100TX_FD_CAPS)) ||
3081 (*speed == SPEED_10 && !(phy_data & NWAY_LPAR_10T_FD_CAPS)))
3082 *duplex = HALF_DUPLEX;
3086 if ((hw->mac_type == e1000_80003es2lan) &&
3087 (hw->media_type == e1000_media_type_copper)) {
3088 if (*speed == SPEED_1000)
3089 ret_val = e1000_configure_kmrn_for_1000(hw);
3091 ret_val = e1000_configure_kmrn_for_10_100(hw, *duplex);
3096 if ((hw->phy_type == e1000_phy_igp_3) && (*speed == SPEED_1000)) {
3097 ret_val = e1000_kumeran_lock_loss_workaround(hw);
3102 return E1000_SUCCESS;
3105 /******************************************************************************
3106 * Blocks until autoneg completes or times out (~4.5 seconds)
3108 * hw - Struct containing variables accessed by shared code
3109 ******************************************************************************/
3111 e1000_wait_autoneg(struct e1000_hw *hw)
3117 DEBUGFUNC("e1000_wait_autoneg");
3118 DEBUGOUT("Waiting for Auto-Neg to complete.\n");
3120 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
3121 for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
3122 /* Read the MII Status Register and wait for Auto-Neg
3123 * Complete bit to be set.
3125 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
3128 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
3131 if(phy_data & MII_SR_AUTONEG_COMPLETE) {
3132 return E1000_SUCCESS;
3136 return E1000_SUCCESS;
3139 /******************************************************************************
3140 * Raises the Management Data Clock
3142 * hw - Struct containing variables accessed by shared code
3143 * ctrl - Device control register's current value
3144 ******************************************************************************/
3146 e1000_raise_mdi_clk(struct e1000_hw *hw,
3149 /* Raise the clock input to the Management Data Clock (by setting the MDC
3150 * bit), and then delay 10 microseconds.
3152 E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
3153 E1000_WRITE_FLUSH(hw);
3157 /******************************************************************************
3158 * Lowers the Management Data Clock
3160 * hw - Struct containing variables accessed by shared code
3161 * ctrl - Device control register's current value
3162 ******************************************************************************/
3164 e1000_lower_mdi_clk(struct e1000_hw *hw,
3167 /* Lower the clock input to the Management Data Clock (by clearing the MDC
3168 * bit), and then delay 10 microseconds.
3170 E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
3171 E1000_WRITE_FLUSH(hw);
3175 /******************************************************************************
3176 * Shifts data bits out to the PHY
3178 * hw - Struct containing variables accessed by shared code
3179 * data - Data to send out to the PHY
3180 * count - Number of bits to shift out
3182 * Bits are shifted out in MSB to LSB order.
3183 ******************************************************************************/
3185 e1000_shift_out_mdi_bits(struct e1000_hw *hw,
3192 /* We need to shift "count" number of bits out to the PHY. So, the value
3193 * in the "data" parameter will be shifted out to the PHY one bit at a
3194 * time. In order to do this, "data" must be broken down into bits.
3197 mask <<= (count - 1);
3199 ctrl = E1000_READ_REG(hw, CTRL);
3201 /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
3202 ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
3205 /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
3206 * then raising and lowering the Management Data Clock. A "0" is
3207 * shifted out to the PHY by setting the MDIO bit to "0" and then
3208 * raising and lowering the clock.
3210 if(data & mask) ctrl |= E1000_CTRL_MDIO;
3211 else ctrl &= ~E1000_CTRL_MDIO;
3213 E1000_WRITE_REG(hw, CTRL, ctrl);
3214 E1000_WRITE_FLUSH(hw);
3218 e1000_raise_mdi_clk(hw, &ctrl);
3219 e1000_lower_mdi_clk(hw, &ctrl);
3225 /******************************************************************************
3226 * Shifts data bits in from the PHY
3228 * hw - Struct containing variables accessed by shared code
3230 * Bits are shifted in in MSB to LSB order.
3231 ******************************************************************************/
3233 e1000_shift_in_mdi_bits(struct e1000_hw *hw)
3239 /* In order to read a register from the PHY, we need to shift in a total
3240 * of 18 bits from the PHY. The first two bit (turnaround) times are used
3241 * to avoid contention on the MDIO pin when a read operation is performed.
3242 * These two bits are ignored by us and thrown away. Bits are "shifted in"
3243 * by raising the input to the Management Data Clock (setting the MDC bit),
3244 * and then reading the value of the MDIO bit.
3246 ctrl = E1000_READ_REG(hw, CTRL);
3248 /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
3249 ctrl &= ~E1000_CTRL_MDIO_DIR;
3250 ctrl &= ~E1000_CTRL_MDIO;
3252 E1000_WRITE_REG(hw, CTRL, ctrl);
3253 E1000_WRITE_FLUSH(hw);
3255 /* Raise and Lower the clock before reading in the data. This accounts for
3256 * the turnaround bits. The first clock occurred when we clocked out the
3257 * last bit of the Register Address.
3259 e1000_raise_mdi_clk(hw, &ctrl);
3260 e1000_lower_mdi_clk(hw, &ctrl);
3262 for(data = 0, i = 0; i < 16; i++) {
3264 e1000_raise_mdi_clk(hw, &ctrl);
3265 ctrl = E1000_READ_REG(hw, CTRL);
3266 /* Check to see if we shifted in a "1". */
3267 if(ctrl & E1000_CTRL_MDIO) data |= 1;
3268 e1000_lower_mdi_clk(hw, &ctrl);
3271 e1000_raise_mdi_clk(hw, &ctrl);
3272 e1000_lower_mdi_clk(hw, &ctrl);
3278 e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask)
3280 uint32_t swfw_sync = 0;
3281 uint32_t swmask = mask;
3282 uint32_t fwmask = mask << 16;
3283 int32_t timeout = 200;
3285 DEBUGFUNC("e1000_swfw_sync_acquire");
3287 if (hw->swfwhw_semaphore_present)
3288 return e1000_get_software_flag(hw);
3290 if (!hw->swfw_sync_present)
3291 return e1000_get_hw_eeprom_semaphore(hw);
3294 if (e1000_get_hw_eeprom_semaphore(hw))
3295 return -E1000_ERR_SWFW_SYNC;
3297 swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
3298 if (!(swfw_sync & (fwmask | swmask))) {
3302 /* firmware currently using resource (fwmask) */
3303 /* or other software thread currently using resource (swmask) */
3304 e1000_put_hw_eeprom_semaphore(hw);
3310 DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
3311 return -E1000_ERR_SWFW_SYNC;
3314 swfw_sync |= swmask;
3315 E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
3317 e1000_put_hw_eeprom_semaphore(hw);
3318 return E1000_SUCCESS;
3322 e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask)
3325 uint32_t swmask = mask;
3327 DEBUGFUNC("e1000_swfw_sync_release");
3329 if (hw->swfwhw_semaphore_present) {
3330 e1000_release_software_flag(hw);
3334 if (!hw->swfw_sync_present) {
3335 e1000_put_hw_eeprom_semaphore(hw);
3339 /* if (e1000_get_hw_eeprom_semaphore(hw))
3340 * return -E1000_ERR_SWFW_SYNC; */
3341 while (e1000_get_hw_eeprom_semaphore(hw) != E1000_SUCCESS);
3344 swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
3345 swfw_sync &= ~swmask;
3346 E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
3348 e1000_put_hw_eeprom_semaphore(hw);
3351 /*****************************************************************************
3352 * Reads the value from a PHY register, if the value is on a specific non zero
3353 * page, sets the page first.
3354 * hw - Struct containing variables accessed by shared code
3355 * reg_addr - address of the PHY register to read
3356 ******************************************************************************/
3358 e1000_read_phy_reg(struct e1000_hw *hw,
3365 DEBUGFUNC("e1000_read_phy_reg");
3367 if ((hw->mac_type == e1000_80003es2lan) &&
3368 (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
3369 swfw = E1000_SWFW_PHY1_SM;
3371 swfw = E1000_SWFW_PHY0_SM;
3373 if (e1000_swfw_sync_acquire(hw, swfw))
3374 return -E1000_ERR_SWFW_SYNC;
3376 if ((hw->phy_type == e1000_phy_igp ||
3377 hw->phy_type == e1000_phy_igp_3 ||
3378 hw->phy_type == e1000_phy_igp_2) &&
3379 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
3380 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
3381 (uint16_t)reg_addr);