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 /* Initialize Identification LED */
749 ret_val = e1000_id_led_init(hw);
751 DEBUGOUT("Error Initializing Identification LED\n");
755 /* Set the media type and TBI compatibility */
756 e1000_set_media_type(hw);
758 /* Disabling VLAN filtering. */
759 DEBUGOUT("Initializing the IEEE VLAN\n");
760 /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */
761 if (hw->mac_type != e1000_ich8lan) {
762 if (hw->mac_type < e1000_82545_rev_3)
763 E1000_WRITE_REG(hw, VET, 0);
764 e1000_clear_vfta(hw);
767 /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
768 if(hw->mac_type == e1000_82542_rev2_0) {
769 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
770 e1000_pci_clear_mwi(hw);
771 E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
772 E1000_WRITE_FLUSH(hw);
776 /* Setup the receive address. This involves initializing all of the Receive
777 * Address Registers (RARs 0 - 15).
779 e1000_init_rx_addrs(hw);
781 /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
782 if(hw->mac_type == e1000_82542_rev2_0) {
783 E1000_WRITE_REG(hw, RCTL, 0);
784 E1000_WRITE_FLUSH(hw);
786 if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
787 e1000_pci_set_mwi(hw);
790 /* Zero out the Multicast HASH table */
791 DEBUGOUT("Zeroing the MTA\n");
792 mta_size = E1000_MC_TBL_SIZE;
793 if (hw->mac_type == e1000_ich8lan)
794 mta_size = E1000_MC_TBL_SIZE_ICH8LAN;
795 for(i = 0; i < mta_size; i++) {
796 E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
797 /* use write flush to prevent Memory Write Block (MWB) from
798 * occuring when accessing our register space */
799 E1000_WRITE_FLUSH(hw);
802 /* Set the PCI priority bit correctly in the CTRL register. This
803 * determines if the adapter gives priority to receives, or if it
804 * gives equal priority to transmits and receives. Valid only on
805 * 82542 and 82543 silicon.
807 if(hw->dma_fairness && hw->mac_type <= e1000_82543) {
808 ctrl = E1000_READ_REG(hw, CTRL);
809 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
812 switch(hw->mac_type) {
813 case e1000_82545_rev_3:
814 case e1000_82546_rev_3:
817 /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
818 if(hw->bus_type == e1000_bus_type_pcix) {
819 e1000_read_pci_cfg(hw, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
820 e1000_read_pci_cfg(hw, PCIX_STATUS_REGISTER_HI,
822 cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
823 PCIX_COMMAND_MMRBC_SHIFT;
824 stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
825 PCIX_STATUS_HI_MMRBC_SHIFT;
826 if(stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
827 stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
828 if(cmd_mmrbc > stat_mmrbc) {
829 pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
830 pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
831 e1000_write_pci_cfg(hw, PCIX_COMMAND_REGISTER,
838 /* More time needed for PHY to initialize */
839 if (hw->mac_type == e1000_ich8lan)
842 /* Call a subroutine to configure the link and setup flow control. */
843 ret_val = e1000_setup_link(hw);
845 /* Set the transmit descriptor write-back policy */
846 if(hw->mac_type > e1000_82544) {
847 ctrl = E1000_READ_REG(hw, TXDCTL);
848 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
849 switch (hw->mac_type) {
856 case e1000_80003es2lan:
857 ctrl |= E1000_TXDCTL_COUNT_DESC;
860 E1000_WRITE_REG(hw, TXDCTL, ctrl);
863 if (hw->mac_type == e1000_82573) {
864 e1000_enable_tx_pkt_filtering(hw);
867 switch (hw->mac_type) {
870 case e1000_80003es2lan:
871 /* Enable retransmit on late collisions */
872 reg_data = E1000_READ_REG(hw, TCTL);
873 reg_data |= E1000_TCTL_RTLC;
874 E1000_WRITE_REG(hw, TCTL, reg_data);
876 /* Configure Gigabit Carry Extend Padding */
877 reg_data = E1000_READ_REG(hw, TCTL_EXT);
878 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
879 reg_data |= DEFAULT_80003ES2LAN_TCTL_EXT_GCEX;
880 E1000_WRITE_REG(hw, TCTL_EXT, reg_data);
882 /* Configure Transmit Inter-Packet Gap */
883 reg_data = E1000_READ_REG(hw, TIPG);
884 reg_data &= ~E1000_TIPG_IPGT_MASK;
885 reg_data |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
886 E1000_WRITE_REG(hw, TIPG, reg_data);
888 reg_data = E1000_READ_REG_ARRAY(hw, FFLT, 0x0001);
889 reg_data &= ~0x00100000;
890 E1000_WRITE_REG_ARRAY(hw, FFLT, 0x0001, reg_data);
895 ctrl = E1000_READ_REG(hw, TXDCTL1);
896 ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
897 if(hw->mac_type >= e1000_82571)
898 ctrl |= E1000_TXDCTL_COUNT_DESC;
899 E1000_WRITE_REG(hw, TXDCTL1, ctrl);
905 if (hw->mac_type == e1000_82573) {
906 uint32_t gcr = E1000_READ_REG(hw, GCR);
907 gcr |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
908 E1000_WRITE_REG(hw, GCR, gcr);
911 /* Clear all of the statistics registers (clear on read). It is
912 * important that we do this after we have tried to establish link
913 * because the symbol error count will increment wildly if there
916 e1000_clear_hw_cntrs(hw);
918 /* ICH8 No-snoop bits are opposite polarity.
919 * Set to snoop by default after reset. */
920 if (hw->mac_type == e1000_ich8lan)
921 e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL);
923 if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER ||
924 hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {
925 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
926 /* Relaxed ordering must be disabled to avoid a parity
927 * error crash in a PCI slot. */
928 ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
929 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
935 /******************************************************************************
936 * Adjust SERDES output amplitude based on EEPROM setting.
938 * hw - Struct containing variables accessed by shared code.
939 *****************************************************************************/
941 e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
943 uint16_t eeprom_data;
946 DEBUGFUNC("e1000_adjust_serdes_amplitude");
948 if(hw->media_type != e1000_media_type_internal_serdes)
949 return E1000_SUCCESS;
951 switch(hw->mac_type) {
952 case e1000_82545_rev_3:
953 case e1000_82546_rev_3:
956 return E1000_SUCCESS;
959 ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1, &eeprom_data);
964 if(eeprom_data != EEPROM_RESERVED_WORD) {
965 /* Adjust SERDES output amplitude only. */
966 eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
967 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL, eeprom_data);
972 return E1000_SUCCESS;
975 /******************************************************************************
976 * Configures flow control and link settings.
978 * hw - Struct containing variables accessed by shared code
980 * Determines which flow control settings to use. Calls the apropriate media-
981 * specific link configuration function. Configures the flow control settings.
982 * Assuming the adapter has a valid link partner, a valid link should be
983 * established. Assumes the hardware has previously been reset and the
984 * transmitter and receiver are not enabled.
985 *****************************************************************************/
987 e1000_setup_link(struct e1000_hw *hw)
991 uint16_t eeprom_data;
993 DEBUGFUNC("e1000_setup_link");
995 /* In the case of the phy reset being blocked, we already have a link.
996 * We do not have to set it up again. */
997 if (e1000_check_phy_reset_block(hw))
998 return E1000_SUCCESS;
1000 /* Read and store word 0x0F of the EEPROM. This word contains bits
1001 * that determine the hardware's default PAUSE (flow control) mode,
1002 * a bit that determines whether the HW defaults to enabling or
1003 * disabling auto-negotiation, and the direction of the
1004 * SW defined pins. If there is no SW over-ride of the flow
1005 * control setting, then the variable hw->fc will
1006 * be initialized based on a value in the EEPROM.
1008 if (hw->fc == e1000_fc_default) {
1009 switch (hw->mac_type) {
1012 hw->fc = e1000_fc_full;
1015 ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
1018 DEBUGOUT("EEPROM Read Error\n");
1019 return -E1000_ERR_EEPROM;
1021 if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
1022 hw->fc = e1000_fc_none;
1023 else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
1024 EEPROM_WORD0F_ASM_DIR)
1025 hw->fc = e1000_fc_tx_pause;
1027 hw->fc = e1000_fc_full;
1032 /* We want to save off the original Flow Control configuration just
1033 * in case we get disconnected and then reconnected into a different
1034 * hub or switch with different Flow Control capabilities.
1036 if(hw->mac_type == e1000_82542_rev2_0)
1037 hw->fc &= (~e1000_fc_tx_pause);
1039 if((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
1040 hw->fc &= (~e1000_fc_rx_pause);
1042 hw->original_fc = hw->fc;
1044 DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
1046 /* Take the 4 bits from EEPROM word 0x0F that determine the initial
1047 * polarity value for the SW controlled pins, and setup the
1048 * Extended Device Control reg with that info.
1049 * This is needed because one of the SW controlled pins is used for
1050 * signal detection. So this should be done before e1000_setup_pcs_link()
1051 * or e1000_phy_setup() is called.
1053 if (hw->mac_type == e1000_82543) {
1054 ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
1057 DEBUGOUT("EEPROM Read Error\n");
1058 return -E1000_ERR_EEPROM;
1060 ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
1062 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
1065 /* Call the necessary subroutine to configure the link. */
1066 ret_val = (hw->media_type == e1000_media_type_copper) ?
1067 e1000_setup_copper_link(hw) :
1068 e1000_setup_fiber_serdes_link(hw);
1070 /* Initialize the flow control address, type, and PAUSE timer
1071 * registers to their default values. This is done even if flow
1072 * control is disabled, because it does not hurt anything to
1073 * initialize these registers.
1075 DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
1077 /* FCAL/H and FCT are hardcoded to standard values in e1000_ich8lan. */
1078 if (hw->mac_type != e1000_ich8lan) {
1079 E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
1080 E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
1081 E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
1084 E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
1086 /* Set the flow control receive threshold registers. Normally,
1087 * these registers will be set to a default threshold that may be
1088 * adjusted later by the driver's runtime code. However, if the
1089 * ability to transmit pause frames in not enabled, then these
1090 * registers will be set to 0.
1092 if(!(hw->fc & e1000_fc_tx_pause)) {
1093 E1000_WRITE_REG(hw, FCRTL, 0);
1094 E1000_WRITE_REG(hw, FCRTH, 0);
1096 /* We need to set up the Receive Threshold high and low water marks
1097 * as well as (optionally) enabling the transmission of XON frames.
1099 if(hw->fc_send_xon) {
1100 E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
1101 E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
1103 E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
1104 E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
1110 /******************************************************************************
1111 * Sets up link for a fiber based or serdes based adapter
1113 * hw - Struct containing variables accessed by shared code
1115 * Manipulates Physical Coding Sublayer functions in order to configure
1116 * link. Assumes the hardware has been previously reset and the transmitter
1117 * and receiver are not enabled.
1118 *****************************************************************************/
1120 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
1126 uint32_t signal = 0;
1129 DEBUGFUNC("e1000_setup_fiber_serdes_link");
1131 /* On 82571 and 82572 Fiber connections, SerDes loopback mode persists
1132 * until explicitly turned off or a power cycle is performed. A read to
1133 * the register does not indicate its status. Therefore, we ensure
1134 * loopback mode is disabled during initialization.
1136 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572)
1137 E1000_WRITE_REG(hw, SCTL, E1000_DISABLE_SERDES_LOOPBACK);
1139 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
1140 * set when the optics detect a signal. On older adapters, it will be
1141 * cleared when there is a signal. This applies to fiber media only.
1142 * If we're on serdes media, adjust the output amplitude to value set in
1145 ctrl = E1000_READ_REG(hw, CTRL);
1146 if(hw->media_type == e1000_media_type_fiber)
1147 signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
1149 ret_val = e1000_adjust_serdes_amplitude(hw);
1153 /* Take the link out of reset */
1154 ctrl &= ~(E1000_CTRL_LRST);
1156 /* Adjust VCO speed to improve BER performance */
1157 ret_val = e1000_set_vco_speed(hw);
1161 e1000_config_collision_dist(hw);
1163 /* Check for a software override of the flow control settings, and setup
1164 * the device accordingly. If auto-negotiation is enabled, then software
1165 * will have to set the "PAUSE" bits to the correct value in the Tranmsit
1166 * Config Word Register (TXCW) and re-start auto-negotiation. However, if
1167 * auto-negotiation is disabled, then software will have to manually
1168 * configure the two flow control enable bits in the CTRL register.
1170 * The possible values of the "fc" parameter are:
1171 * 0: Flow control is completely disabled
1172 * 1: Rx flow control is enabled (we can receive pause frames, but
1173 * not send pause frames).
1174 * 2: Tx flow control is enabled (we can send pause frames but we do
1175 * not support receiving pause frames).
1176 * 3: Both Rx and TX flow control (symmetric) are enabled.
1180 /* Flow control is completely disabled by a software over-ride. */
1181 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
1183 case e1000_fc_rx_pause:
1184 /* RX Flow control is enabled and TX Flow control is disabled by a
1185 * software over-ride. Since there really isn't a way to advertise
1186 * that we are capable of RX Pause ONLY, we will advertise that we
1187 * support both symmetric and asymmetric RX PAUSE. Later, we will
1188 * disable the adapter's ability to send PAUSE frames.
1190 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
1192 case e1000_fc_tx_pause:
1193 /* TX Flow control is enabled, and RX Flow control is disabled, by a
1194 * software over-ride.
1196 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
1199 /* Flow control (both RX and TX) is enabled by a software over-ride. */
1200 txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
1203 DEBUGOUT("Flow control param set incorrectly\n");
1204 return -E1000_ERR_CONFIG;
1208 /* Since auto-negotiation is enabled, take the link out of reset (the link
1209 * will be in reset, because we previously reset the chip). This will
1210 * restart auto-negotiation. If auto-neogtiation is successful then the
1211 * link-up status bit will be set and the flow control enable bits (RFCE
1212 * and TFCE) will be set according to their negotiated value.
1214 DEBUGOUT("Auto-negotiation enabled\n");
1216 E1000_WRITE_REG(hw, TXCW, txcw);
1217 E1000_WRITE_REG(hw, CTRL, ctrl);
1218 E1000_WRITE_FLUSH(hw);
1223 /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
1224 * indication in the Device Status Register. Time-out if a link isn't
1225 * seen in 500 milliseconds seconds (Auto-negotiation should complete in
1226 * less than 500 milliseconds even if the other end is doing it in SW).
1227 * For internal serdes, we just assume a signal is present, then poll.
1229 if(hw->media_type == e1000_media_type_internal_serdes ||
1230 (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
1231 DEBUGOUT("Looking for Link\n");
1232 for(i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
1234 status = E1000_READ_REG(hw, STATUS);
1235 if(status & E1000_STATUS_LU) break;
1237 if(i == (LINK_UP_TIMEOUT / 10)) {
1238 DEBUGOUT("Never got a valid link from auto-neg!!!\n");
1239 hw->autoneg_failed = 1;
1240 /* AutoNeg failed to achieve a link, so we'll call
1241 * e1000_check_for_link. This routine will force the link up if
1242 * we detect a signal. This will allow us to communicate with
1243 * non-autonegotiating link partners.
1245 ret_val = e1000_check_for_link(hw);
1247 DEBUGOUT("Error while checking for link\n");
1250 hw->autoneg_failed = 0;
1252 hw->autoneg_failed = 0;
1253 DEBUGOUT("Valid Link Found\n");
1256 DEBUGOUT("No Signal Detected\n");
1258 return E1000_SUCCESS;
1261 /******************************************************************************
1262 * Make sure we have a valid PHY and change PHY mode before link setup.
1264 * hw - Struct containing variables accessed by shared code
1265 ******************************************************************************/
1267 e1000_copper_link_preconfig(struct e1000_hw *hw)
1273 DEBUGFUNC("e1000_copper_link_preconfig");
1275 ctrl = E1000_READ_REG(hw, CTRL);
1276 /* With 82543, we need to force speed and duplex on the MAC equal to what
1277 * the PHY speed and duplex configuration is. In addition, we need to
1278 * perform a hardware reset on the PHY to take it out of reset.
1280 if(hw->mac_type > e1000_82543) {
1281 ctrl |= E1000_CTRL_SLU;
1282 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1283 E1000_WRITE_REG(hw, CTRL, ctrl);
1285 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
1286 E1000_WRITE_REG(hw, CTRL, ctrl);
1287 ret_val = e1000_phy_hw_reset(hw);
1292 /* Make sure we have a valid PHY */
1293 ret_val = e1000_detect_gig_phy(hw);
1295 DEBUGOUT("Error, did not detect valid phy.\n");
1298 DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
1300 /* Set PHY to class A mode (if necessary) */
1301 ret_val = e1000_set_phy_mode(hw);
1305 if((hw->mac_type == e1000_82545_rev_3) ||
1306 (hw->mac_type == e1000_82546_rev_3)) {
1307 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
1308 phy_data |= 0x00000008;
1309 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
1312 if(hw->mac_type <= e1000_82543 ||
1313 hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
1314 hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
1315 hw->phy_reset_disable = FALSE;
1317 return E1000_SUCCESS;
1321 /********************************************************************
1322 * Copper link setup for e1000_phy_igp series.
1324 * hw - Struct containing variables accessed by shared code
1325 *********************************************************************/
1327 e1000_copper_link_igp_setup(struct e1000_hw *hw)
1333 DEBUGFUNC("e1000_copper_link_igp_setup");
1335 if (hw->phy_reset_disable)
1336 return E1000_SUCCESS;
1338 ret_val = e1000_phy_reset(hw);
1340 DEBUGOUT("Error Resetting the PHY\n");
1344 /* Wait 10ms for MAC to configure PHY from eeprom settings */
1346 if (hw->mac_type != e1000_ich8lan) {
1347 /* Configure activity LED after PHY reset */
1348 led_ctrl = E1000_READ_REG(hw, LEDCTL);
1349 led_ctrl &= IGP_ACTIVITY_LED_MASK;
1350 led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
1351 E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
1354 /* disable lplu d3 during driver init */
1355 ret_val = e1000_set_d3_lplu_state(hw, FALSE);
1357 DEBUGOUT("Error Disabling LPLU D3\n");
1361 /* disable lplu d0 during driver init */
1362 ret_val = e1000_set_d0_lplu_state(hw, FALSE);
1364 DEBUGOUT("Error Disabling LPLU D0\n");
1367 /* Configure mdi-mdix settings */
1368 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
1372 if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
1373 hw->dsp_config_state = e1000_dsp_config_disabled;
1374 /* Force MDI for earlier revs of the IGP PHY */
1375 phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | IGP01E1000_PSCR_FORCE_MDI_MDIX);
1379 hw->dsp_config_state = e1000_dsp_config_enabled;
1380 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
1384 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
1387 phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
1391 phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
1395 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
1399 /* set auto-master slave resolution settings */
1401 e1000_ms_type phy_ms_setting = hw->master_slave;
1403 if(hw->ffe_config_state == e1000_ffe_config_active)
1404 hw->ffe_config_state = e1000_ffe_config_enabled;
1406 if(hw->dsp_config_state == e1000_dsp_config_activated)
1407 hw->dsp_config_state = e1000_dsp_config_enabled;
1409 /* when autonegotiation advertisment is only 1000Mbps then we
1410 * should disable SmartSpeed and enable Auto MasterSlave
1411 * resolution as hardware default. */
1412 if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
1413 /* Disable SmartSpeed */
1414 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
1417 phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
1418 ret_val = e1000_write_phy_reg(hw,
1419 IGP01E1000_PHY_PORT_CONFIG,
1423 /* Set auto Master/Slave resolution process */
1424 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1427 phy_data &= ~CR_1000T_MS_ENABLE;
1428 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1433 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
1437 /* load defaults for future use */
1438 hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
1439 ((phy_data & CR_1000T_MS_VALUE) ?
1440 e1000_ms_force_master :
1441 e1000_ms_force_slave) :
1444 switch (phy_ms_setting) {
1445 case e1000_ms_force_master:
1446 phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
1448 case e1000_ms_force_slave:
1449 phy_data |= CR_1000T_MS_ENABLE;
1450 phy_data &= ~(CR_1000T_MS_VALUE);
1453 phy_data &= ~CR_1000T_MS_ENABLE;
1457 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
1462 return E1000_SUCCESS;
1465 /********************************************************************
1466 * Copper link setup for e1000_phy_gg82563 series.
1468 * hw - Struct containing variables accessed by shared code
1469 *********************************************************************/
1471 e1000_copper_link_ggp_setup(struct e1000_hw *hw)
1477 DEBUGFUNC("e1000_copper_link_ggp_setup");
1479 if(!hw->phy_reset_disable) {
1481 /* Enable CRS on TX for half-duplex operation. */
1482 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
1487 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
1488 /* Use 25MHz for both link down and 1000BASE-T for Tx clock */
1489 phy_data |= GG82563_MSCR_TX_CLK_1000MBPS_25MHZ;
1491 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
1497 * MDI/MDI-X = 0 (default)
1498 * 0 - Auto for all speeds
1501 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1503 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL, &phy_data);
1507 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
1511 phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
1514 phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
1518 phy_data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
1523 * disable_polarity_correction = 0 (default)
1524 * Automatic Correction for Reversed Cable Polarity
1528 phy_data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1529 if(hw->disable_polarity_correction == 1)
1530 phy_data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1531 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL, phy_data);
1536 /* SW Reset the PHY so all changes take effect */
1537 ret_val = e1000_phy_reset(hw);
1539 DEBUGOUT("Error Resetting the PHY\n");
1542 } /* phy_reset_disable */
1544 if (hw->mac_type == e1000_80003es2lan) {
1545 /* Bypass RX and TX FIFO's */
1546 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_FIFO_CTRL,
1547 E1000_KUMCTRLSTA_FIFO_CTRL_RX_BYPASS |
1548 E1000_KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
1552 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, &phy_data);
1556 phy_data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
1557 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, phy_data);
1562 reg_data = E1000_READ_REG(hw, CTRL_EXT);
1563 reg_data &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
1564 E1000_WRITE_REG(hw, CTRL_EXT, reg_data);
1566 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
1571 /* Do not init these registers when the HW is in IAMT mode, since the
1572 * firmware will have already initialized them. We only initialize
1573 * them if the HW is not in IAMT mode.
1575 if (e1000_check_mng_mode(hw) == FALSE) {
1576 /* Enable Electrical Idle on the PHY */
1577 phy_data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
1578 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
1583 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
1588 phy_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1590 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
1596 /* Workaround: Disable padding in Kumeran interface in the MAC
1597 * and in the PHY to avoid CRC errors.
1599 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
1603 phy_data |= GG82563_ICR_DIS_PADDING;
1604 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
1610 return E1000_SUCCESS;
1613 /********************************************************************
1614 * Copper link setup for e1000_phy_m88 series.
1616 * hw - Struct containing variables accessed by shared code
1617 *********************************************************************/
1619 e1000_copper_link_mgp_setup(struct e1000_hw *hw)
1624 DEBUGFUNC("e1000_copper_link_mgp_setup");
1626 if(hw->phy_reset_disable)
1627 return E1000_SUCCESS;
1629 /* Enable CRS on TX. This must be set for half-duplex operation. */
1630 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
1634 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1637 * MDI/MDI-X = 0 (default)
1638 * 0 - Auto for all speeds
1641 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
1643 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
1647 phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
1650 phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
1653 phy_data |= M88E1000_PSCR_AUTO_X_1000T;
1657 phy_data |= M88E1000_PSCR_AUTO_X_MODE;
1662 * disable_polarity_correction = 0 (default)
1663 * Automatic Correction for Reversed Cable Polarity
1667 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
1668 if(hw->disable_polarity_correction == 1)
1669 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
1670 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
1674 if (hw->phy_revision < M88E1011_I_REV_4) {
1675 /* Force TX_CLK in the Extended PHY Specific Control Register
1678 ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
1682 phy_data |= M88E1000_EPSCR_TX_CLK_25;
1684 if ((hw->phy_revision == E1000_REVISION_2) &&
1685 (hw->phy_id == M88E1111_I_PHY_ID)) {
1686 /* Vidalia Phy, set the downshift counter to 5x */
1687 phy_data &= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK);
1688 phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X;
1689 ret_val = e1000_write_phy_reg(hw,
1690 M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
1694 /* Configure Master and Slave downshift values */
1695 phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
1696 M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
1697 phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
1698 M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
1699 ret_val = e1000_write_phy_reg(hw,
1700 M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
1706 /* SW Reset the PHY so all changes take effect */
1707 ret_val = e1000_phy_reset(hw);
1709 DEBUGOUT("Error Resetting the PHY\n");
1713 return E1000_SUCCESS;
1716 /********************************************************************
1717 * Setup auto-negotiation and flow control advertisements,
1718 * and then perform auto-negotiation.
1720 * hw - Struct containing variables accessed by shared code
1721 *********************************************************************/
1723 e1000_copper_link_autoneg(struct e1000_hw *hw)
1728 DEBUGFUNC("e1000_copper_link_autoneg");
1730 /* Perform some bounds checking on the hw->autoneg_advertised
1731 * parameter. If this variable is zero, then set it to the default.
1733 hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
1735 /* If autoneg_advertised is zero, we assume it was not defaulted
1736 * by the calling code so we set to advertise full capability.
1738 if(hw->autoneg_advertised == 0)
1739 hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
1741 /* IFE phy only supports 10/100 */
1742 if (hw->phy_type == e1000_phy_ife)
1743 hw->autoneg_advertised &= AUTONEG_ADVERTISE_10_100_ALL;
1745 DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
1746 ret_val = e1000_phy_setup_autoneg(hw);
1748 DEBUGOUT("Error Setting up Auto-Negotiation\n");
1751 DEBUGOUT("Restarting Auto-Neg\n");
1753 /* Restart auto-negotiation by setting the Auto Neg Enable bit and
1754 * the Auto Neg Restart bit in the PHY control register.
1756 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
1760 phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
1761 ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
1765 /* Does the user want to wait for Auto-Neg to complete here, or
1766 * check at a later time (for example, callback routine).
1768 if(hw->wait_autoneg_complete) {
1769 ret_val = e1000_wait_autoneg(hw);
1771 DEBUGOUT("Error while waiting for autoneg to complete\n");
1776 hw->get_link_status = TRUE;
1778 return E1000_SUCCESS;
1782 /******************************************************************************
1783 * Config the MAC and the PHY after link is up.
1784 * 1) Set up the MAC to the current PHY speed/duplex
1785 * if we are on 82543. If we
1786 * are on newer silicon, we only need to configure
1787 * collision distance in the Transmit Control Register.
1788 * 2) Set up flow control on the MAC to that established with
1790 * 3) Config DSP to improve Gigabit link quality for some PHY revisions.
1792 * hw - Struct containing variables accessed by shared code
1793 ******************************************************************************/
1795 e1000_copper_link_postconfig(struct e1000_hw *hw)
1798 DEBUGFUNC("e1000_copper_link_postconfig");
1800 if(hw->mac_type >= e1000_82544) {
1801 e1000_config_collision_dist(hw);
1803 ret_val = e1000_config_mac_to_phy(hw);
1805 DEBUGOUT("Error configuring MAC to PHY settings\n");
1809 ret_val = e1000_config_fc_after_link_up(hw);
1811 DEBUGOUT("Error Configuring Flow Control\n");
1815 /* Config DSP to improve Giga link quality */
1816 if(hw->phy_type == e1000_phy_igp) {
1817 ret_val = e1000_config_dsp_after_link_change(hw, TRUE);
1819 DEBUGOUT("Error Configuring DSP after link up\n");
1824 return E1000_SUCCESS;
1827 /******************************************************************************
1828 * Detects which PHY is present and setup the speed and duplex
1830 * hw - Struct containing variables accessed by shared code
1831 ******************************************************************************/
1833 e1000_setup_copper_link(struct e1000_hw *hw)
1840 DEBUGFUNC("e1000_setup_copper_link");
1842 switch (hw->mac_type) {
1843 case e1000_80003es2lan:
1845 /* Set the mac to wait the maximum time between each
1846 * iteration and increase the max iterations when
1847 * polling the phy; this fixes erroneous timeouts at 10Mbps. */
1848 ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF);
1851 ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data);
1855 ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data);
1862 /* Check if it is a valid PHY and set PHY mode if necessary. */
1863 ret_val = e1000_copper_link_preconfig(hw);
1867 switch (hw->mac_type) {
1868 case e1000_80003es2lan:
1869 /* Kumeran registers are written-only */
1870 reg_data = E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT;
1871 reg_data |= E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING;
1872 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_INB_CTRL,
1881 if (hw->phy_type == e1000_phy_igp ||
1882 hw->phy_type == e1000_phy_igp_3 ||
1883 hw->phy_type == e1000_phy_igp_2) {
1884 ret_val = e1000_copper_link_igp_setup(hw);
1887 } else if (hw->phy_type == e1000_phy_m88) {
1888 ret_val = e1000_copper_link_mgp_setup(hw);
1891 } else if (hw->phy_type == e1000_phy_gg82563) {
1892 ret_val = e1000_copper_link_ggp_setup(hw);
1898 /* Setup autoneg and flow control advertisement
1899 * and perform autonegotiation */
1900 ret_val = e1000_copper_link_autoneg(hw);
1904 /* PHY will be set to 10H, 10F, 100H,or 100F
1905 * depending on value from forced_speed_duplex. */
1906 DEBUGOUT("Forcing speed and duplex\n");
1907 ret_val = e1000_phy_force_speed_duplex(hw);
1909 DEBUGOUT("Error Forcing Speed and Duplex\n");
1914 /* Check link status. Wait up to 100 microseconds for link to become
1917 for(i = 0; i < 10; i++) {
1918 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
1921 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
1925 if(phy_data & MII_SR_LINK_STATUS) {
1926 /* Config the MAC and PHY after link is up */
1927 ret_val = e1000_copper_link_postconfig(hw);
1931 DEBUGOUT("Valid link established!!!\n");
1932 return E1000_SUCCESS;
1937 DEBUGOUT("Unable to establish link!!!\n");
1938 return E1000_SUCCESS;
1941 /******************************************************************************
1942 * Configure the MAC-to-PHY interface for 10/100Mbps
1944 * hw - Struct containing variables accessed by shared code
1945 ******************************************************************************/
1947 e1000_configure_kmrn_for_10_100(struct e1000_hw *hw, uint16_t duplex)
1949 int32_t ret_val = E1000_SUCCESS;
1953 DEBUGFUNC("e1000_configure_kmrn_for_10_100");
1955 reg_data = E1000_KUMCTRLSTA_HD_CTRL_10_100_DEFAULT;
1956 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
1961 /* Configure Transmit Inter-Packet Gap */
1962 tipg = E1000_READ_REG(hw, TIPG);
1963 tipg &= ~E1000_TIPG_IPGT_MASK;
1964 tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_10_100;
1965 E1000_WRITE_REG(hw, TIPG, tipg);
1967 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
1972 if (duplex == HALF_DUPLEX)
1973 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1975 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1977 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1983 e1000_configure_kmrn_for_1000(struct e1000_hw *hw)
1985 int32_t ret_val = E1000_SUCCESS;
1989 DEBUGFUNC("e1000_configure_kmrn_for_1000");
1991 reg_data = E1000_KUMCTRLSTA_HD_CTRL_1000_DEFAULT;
1992 ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
1997 /* Configure Transmit Inter-Packet Gap */
1998 tipg = E1000_READ_REG(hw, TIPG);
1999 tipg &= ~E1000_TIPG_IPGT_MASK;
2000 tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
2001 E1000_WRITE_REG(hw, TIPG, tipg);
2003 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, ®_data);
2008 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
2009 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
2014 /******************************************************************************
2015 * Configures PHY autoneg and flow control advertisement settings
2017 * hw - Struct containing variables accessed by shared code
2018 ******************************************************************************/
2020 e1000_phy_setup_autoneg(struct e1000_hw *hw)
2023 uint16_t mii_autoneg_adv_reg;
2024 uint16_t mii_1000t_ctrl_reg;
2026 DEBUGFUNC("e1000_phy_setup_autoneg");
2028 /* Read the MII Auto-Neg Advertisement Register (Address 4). */
2029 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
2033 if (hw->phy_type != e1000_phy_ife) {
2034 /* Read the MII 1000Base-T Control Register (Address 9). */
2035 ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
2039 mii_1000t_ctrl_reg=0;
2041 /* Need to parse both autoneg_advertised and fc and set up
2042 * the appropriate PHY registers. First we will parse for
2043 * autoneg_advertised software override. Since we can advertise
2044 * a plethora of combinations, we need to check each bit
2048 /* First we clear all the 10/100 mb speed bits in the Auto-Neg
2049 * Advertisement Register (Address 4) and the 1000 mb speed bits in
2050 * the 1000Base-T Control Register (Address 9).
2052 mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
2053 mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
2055 DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
2057 /* Do we want to advertise 10 Mb Half Duplex? */
2058 if(hw->autoneg_advertised & ADVERTISE_10_HALF) {
2059 DEBUGOUT("Advertise 10mb Half duplex\n");
2060 mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
2063 /* Do we want to advertise 10 Mb Full Duplex? */
2064 if(hw->autoneg_advertised & ADVERTISE_10_FULL) {
2065 DEBUGOUT("Advertise 10mb Full duplex\n");
2066 mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
2069 /* Do we want to advertise 100 Mb Half Duplex? */
2070 if(hw->autoneg_advertised & ADVERTISE_100_HALF) {
2071 DEBUGOUT("Advertise 100mb Half duplex\n");
2072 mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
2075 /* Do we want to advertise 100 Mb Full Duplex? */
2076 if(hw->autoneg_advertised & ADVERTISE_100_FULL) {
2077 DEBUGOUT("Advertise 100mb Full duplex\n");
2078 mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
2081 /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
2082 if(hw->autoneg_advertised & ADVERTISE_1000_HALF) {
2083 DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
2086 /* Do we want to advertise 1000 Mb Full Duplex? */
2087 if(hw->autoneg_advertised & ADVERTISE_1000_FULL) {
2088 DEBUGOUT("Advertise 1000mb Full duplex\n");
2089 mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
2090 if (hw->phy_type == e1000_phy_ife) {
2091 DEBUGOUT("e1000_phy_ife is a 10/100 PHY. Gigabit speed is not supported.\n");
2095 /* Check for a software override of the flow control settings, and
2096 * setup the PHY advertisement registers accordingly. If
2097 * auto-negotiation is enabled, then software will have to set the
2098 * "PAUSE" bits to the correct value in the Auto-Negotiation
2099 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
2101 * The possible values of the "fc" parameter are:
2102 * 0: Flow control is completely disabled
2103 * 1: Rx flow control is enabled (we can receive pause frames
2104 * but not send pause frames).
2105 * 2: Tx flow control is enabled (we can send pause frames
2106 * but we do not support receiving pause frames).
2107 * 3: Both Rx and TX flow control (symmetric) are enabled.
2108 * other: No software override. The flow control configuration
2109 * in the EEPROM is used.
2112 case e1000_fc_none: /* 0 */
2113 /* Flow control (RX & TX) is completely disabled by a
2114 * software over-ride.
2116 mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
2118 case e1000_fc_rx_pause: /* 1 */
2119 /* RX Flow control is enabled, and TX Flow control is
2120 * disabled, by a software over-ride.
2122 /* Since there really isn't a way to advertise that we are
2123 * capable of RX Pause ONLY, we will advertise that we
2124 * support both symmetric and asymmetric RX PAUSE. Later
2125 * (in e1000_config_fc_after_link_up) we will disable the
2126 *hw's ability to send PAUSE frames.
2128 mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
2130 case e1000_fc_tx_pause: /* 2 */
2131 /* TX Flow control is enabled, and RX Flow control is
2132 * disabled, by a software over-ride.
2134 mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
2135 mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
2137 case e1000_fc_full: /* 3 */
2138 /* Flow control (both RX and TX) is enabled by a software
2141 mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
2144 DEBUGOUT("Flow control param set incorrectly\n");
2145 return -E1000_ERR_CONFIG;
2148 ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
2152 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
2154 if (hw->phy_type != e1000_phy_ife) {
2155 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
2160 return E1000_SUCCESS;
2163 /******************************************************************************
2164 * Force PHY speed and duplex settings to hw->forced_speed_duplex
2166 * hw - Struct containing variables accessed by shared code
2167 ******************************************************************************/
2169 e1000_phy_force_speed_duplex(struct e1000_hw *hw)
2173 uint16_t mii_ctrl_reg;
2174 uint16_t mii_status_reg;
2178 DEBUGFUNC("e1000_phy_force_speed_duplex");
2180 /* Turn off Flow control if we are forcing speed and duplex. */
2181 hw->fc = e1000_fc_none;
2183 DEBUGOUT1("hw->fc = %d\n", hw->fc);
2185 /* Read the Device Control Register. */
2186 ctrl = E1000_READ_REG(hw, CTRL);
2188 /* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
2189 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
2190 ctrl &= ~(DEVICE_SPEED_MASK);
2192 /* Clear the Auto Speed Detect Enable bit. */
2193 ctrl &= ~E1000_CTRL_ASDE;
2195 /* Read the MII Control Register. */
2196 ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &mii_ctrl_reg);
2200 /* We need to disable autoneg in order to force link and duplex. */
2202 mii_ctrl_reg &= ~MII_CR_AUTO_NEG_EN;
2204 /* Are we forcing Full or Half Duplex? */
2205 if(hw->forced_speed_duplex == e1000_100_full ||
2206 hw->forced_speed_duplex == e1000_10_full) {
2207 /* We want to force full duplex so we SET the full duplex bits in the
2208 * Device and MII Control Registers.
2210 ctrl |= E1000_CTRL_FD;
2211 mii_ctrl_reg |= MII_CR_FULL_DUPLEX;
2212 DEBUGOUT("Full Duplex\n");
2214 /* We want to force half duplex so we CLEAR the full duplex bits in
2215 * the Device and MII Control Registers.
2217 ctrl &= ~E1000_CTRL_FD;
2218 mii_ctrl_reg &= ~MII_CR_FULL_DUPLEX;
2219 DEBUGOUT("Half Duplex\n");
2222 /* Are we forcing 100Mbps??? */
2223 if(hw->forced_speed_duplex == e1000_100_full ||
2224 hw->forced_speed_duplex == e1000_100_half) {
2225 /* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
2226 ctrl |= E1000_CTRL_SPD_100;
2227 mii_ctrl_reg |= MII_CR_SPEED_100;
2228 mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
2229 DEBUGOUT("Forcing 100mb ");
2231 /* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
2232 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
2233 mii_ctrl_reg |= MII_CR_SPEED_10;
2234 mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
2235 DEBUGOUT("Forcing 10mb ");
2238 e1000_config_collision_dist(hw);
2240 /* Write the configured values back to the Device Control Reg. */
2241 E1000_WRITE_REG(hw, CTRL, ctrl);
2243 if ((hw->phy_type == e1000_phy_m88) ||
2244 (hw->phy_type == e1000_phy_gg82563)) {
2245 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
2249 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
2250 * forced whenever speed are duplex are forced.
2252 phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
2253 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
2257 DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data);
2259 /* Need to reset the PHY or these changes will be ignored */
2260 mii_ctrl_reg |= MII_CR_RESET;
2261 /* Disable MDI-X support for 10/100 */
2262 } else if (hw->phy_type == e1000_phy_ife) {
2263 ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
2267 phy_data &= ~IFE_PMC_AUTO_MDIX;
2268 phy_data &= ~IFE_PMC_FORCE_MDIX;
2270 ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data);
2274 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
2275 * forced whenever speed or duplex are forced.
2277 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
2281 phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
2282 phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
2284 ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
2289 /* Write back the modified PHY MII control register. */
2290 ret_val = e1000_write_phy_reg(hw, PHY_CTRL, mii_ctrl_reg);
2296 /* The wait_autoneg_complete flag may be a little misleading here.
2297 * Since we are forcing speed and duplex, Auto-Neg is not enabled.
2298 * But we do want to delay for a period while forcing only so we
2299 * don't generate false No Link messages. So we will wait here
2300 * only if the user has set wait_autoneg_complete to 1, which is
2303 if(hw->wait_autoneg_complete) {
2304 /* We will wait for autoneg to complete. */
2305 DEBUGOUT("Waiting for forced speed/duplex link.\n");
2308 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
2309 for(i = PHY_FORCE_TIME; i > 0; i--) {
2310 /* Read the MII Status Register and wait for Auto-Neg Complete bit
2313 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2317 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2321 if(mii_status_reg & MII_SR_LINK_STATUS) break;
2325 ((hw->phy_type == e1000_phy_m88) ||
2326 (hw->phy_type == e1000_phy_gg82563))) {
2327 /* We didn't get link. Reset the DSP and wait again for link. */
2328 ret_val = e1000_phy_reset_dsp(hw);
2330 DEBUGOUT("Error Resetting PHY DSP\n");
2334 /* This loop will early-out if the link condition has been met. */
2335 for(i = PHY_FORCE_TIME; i > 0; i--) {
2336 if(mii_status_reg & MII_SR_LINK_STATUS) break;
2338 /* Read the MII Status Register and wait for Auto-Neg Complete bit
2341 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2345 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2351 if (hw->phy_type == e1000_phy_m88) {
2352 /* Because we reset the PHY above, we need to re-force TX_CLK in the
2353 * Extended PHY Specific Control Register to 25MHz clock. This value
2354 * defaults back to a 2.5MHz clock when the PHY is reset.
2356 ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
2360 phy_data |= M88E1000_EPSCR_TX_CLK_25;
2361 ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
2365 /* In addition, because of the s/w reset above, we need to enable CRS on
2366 * TX. This must be set for both full and half duplex operation.
2368 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
2372 phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
2373 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
2377 if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
2379 (hw->forced_speed_duplex == e1000_10_full ||
2380 hw->forced_speed_duplex == e1000_10_half)) {
2381 ret_val = e1000_polarity_reversal_workaround(hw);
2385 } else if (hw->phy_type == e1000_phy_gg82563) {
2386 /* The TX_CLK of the Extended PHY Specific Control Register defaults
2387 * to 2.5MHz on a reset. We need to re-force it back to 25MHz, if
2388 * we're not in a forced 10/duplex configuration. */
2389 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
2393 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
2394 if ((hw->forced_speed_duplex == e1000_10_full) ||
2395 (hw->forced_speed_duplex == e1000_10_half))
2396 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5MHZ;
2398 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25MHZ;
2400 /* Also due to the reset, we need to enable CRS on Tx. */
2401 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
2403 ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
2407 return E1000_SUCCESS;
2410 /******************************************************************************
2411 * Sets the collision distance in the Transmit Control register
2413 * hw - Struct containing variables accessed by shared code
2415 * Link should have been established previously. Reads the speed and duplex
2416 * information from the Device Status register.
2417 ******************************************************************************/
2419 e1000_config_collision_dist(struct e1000_hw *hw)
2421 uint32_t tctl, coll_dist;
2423 DEBUGFUNC("e1000_config_collision_dist");
2425 if (hw->mac_type < e1000_82543)
2426 coll_dist = E1000_COLLISION_DISTANCE_82542;
2428 coll_dist = E1000_COLLISION_DISTANCE;
2430 tctl = E1000_READ_REG(hw, TCTL);
2432 tctl &= ~E1000_TCTL_COLD;
2433 tctl |= coll_dist << E1000_COLD_SHIFT;
2435 E1000_WRITE_REG(hw, TCTL, tctl);
2436 E1000_WRITE_FLUSH(hw);
2439 /******************************************************************************
2440 * Sets MAC speed and duplex settings to reflect the those in the PHY
2442 * hw - Struct containing variables accessed by shared code
2443 * mii_reg - data to write to the MII control register
2445 * The contents of the PHY register containing the needed information need to
2447 ******************************************************************************/
2449 e1000_config_mac_to_phy(struct e1000_hw *hw)
2455 DEBUGFUNC("e1000_config_mac_to_phy");
2457 /* 82544 or newer MAC, Auto Speed Detection takes care of
2458 * MAC speed/duplex configuration.*/
2459 if (hw->mac_type >= e1000_82544)
2460 return E1000_SUCCESS;
2462 /* Read the Device Control Register and set the bits to Force Speed
2465 ctrl = E1000_READ_REG(hw, CTRL);
2466 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
2467 ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
2469 /* Set up duplex in the Device Control and Transmit Control
2470 * registers depending on negotiated values.
2472 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
2476 if(phy_data & M88E1000_PSSR_DPLX)
2477 ctrl |= E1000_CTRL_FD;
2479 ctrl &= ~E1000_CTRL_FD;
2481 e1000_config_collision_dist(hw);
2483 /* Set up speed in the Device Control register depending on
2484 * negotiated values.
2486 if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
2487 ctrl |= E1000_CTRL_SPD_1000;
2488 else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
2489 ctrl |= E1000_CTRL_SPD_100;
2491 /* Write the configured values back to the Device Control Reg. */
2492 E1000_WRITE_REG(hw, CTRL, ctrl);
2493 return E1000_SUCCESS;
2496 /******************************************************************************
2497 * Forces the MAC's flow control settings.
2499 * hw - Struct containing variables accessed by shared code
2501 * Sets the TFCE and RFCE bits in the device control register to reflect
2502 * the adapter settings. TFCE and RFCE need to be explicitly set by
2503 * software when a Copper PHY is used because autonegotiation is managed
2504 * by the PHY rather than the MAC. Software must also configure these
2505 * bits when link is forced on a fiber connection.
2506 *****************************************************************************/
2508 e1000_force_mac_fc(struct e1000_hw *hw)
2512 DEBUGFUNC("e1000_force_mac_fc");
2514 /* Get the current configuration of the Device Control Register */
2515 ctrl = E1000_READ_REG(hw, CTRL);
2517 /* Because we didn't get link via the internal auto-negotiation
2518 * mechanism (we either forced link or we got link via PHY
2519 * auto-neg), we have to manually enable/disable transmit an
2520 * receive flow control.
2522 * The "Case" statement below enables/disable flow control
2523 * according to the "hw->fc" parameter.
2525 * The possible values of the "fc" parameter are:
2526 * 0: Flow control is completely disabled
2527 * 1: Rx flow control is enabled (we can receive pause
2528 * frames but not send pause frames).
2529 * 2: Tx flow control is enabled (we can send pause frames
2530 * frames but we do not receive pause frames).
2531 * 3: Both Rx and TX flow control (symmetric) is enabled.
2532 * other: No other values should be possible at this point.
2537 ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
2539 case e1000_fc_rx_pause:
2540 ctrl &= (~E1000_CTRL_TFCE);
2541 ctrl |= E1000_CTRL_RFCE;
2543 case e1000_fc_tx_pause:
2544 ctrl &= (~E1000_CTRL_RFCE);
2545 ctrl |= E1000_CTRL_TFCE;
2548 ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
2551 DEBUGOUT("Flow control param set incorrectly\n");
2552 return -E1000_ERR_CONFIG;
2555 /* Disable TX Flow Control for 82542 (rev 2.0) */
2556 if(hw->mac_type == e1000_82542_rev2_0)
2557 ctrl &= (~E1000_CTRL_TFCE);
2559 E1000_WRITE_REG(hw, CTRL, ctrl);
2560 return E1000_SUCCESS;
2563 /******************************************************************************
2564 * Configures flow control settings after link is established
2566 * hw - Struct containing variables accessed by shared code
2568 * Should be called immediately after a valid link has been established.
2569 * Forces MAC flow control settings if link was forced. When in MII/GMII mode
2570 * and autonegotiation is enabled, the MAC flow control settings will be set
2571 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
2572 * and RFCE bits will be automaticaly set to the negotiated flow control mode.
2573 *****************************************************************************/
2575 e1000_config_fc_after_link_up(struct e1000_hw *hw)
2578 uint16_t mii_status_reg;
2579 uint16_t mii_nway_adv_reg;
2580 uint16_t mii_nway_lp_ability_reg;
2584 DEBUGFUNC("e1000_config_fc_after_link_up");
2586 /* Check for the case where we have fiber media and auto-neg failed
2587 * so we had to force link. In this case, we need to force the
2588 * configuration of the MAC to match the "fc" parameter.
2590 if(((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
2591 ((hw->media_type == e1000_media_type_internal_serdes) && (hw->autoneg_failed)) ||
2592 ((hw->media_type == e1000_media_type_copper) && (!hw->autoneg))) {
2593 ret_val = e1000_force_mac_fc(hw);
2595 DEBUGOUT("Error forcing flow control settings\n");
2600 /* Check for the case where we have copper media and auto-neg is
2601 * enabled. In this case, we need to check and see if Auto-Neg
2602 * has completed, and if so, how the PHY and link partner has
2603 * flow control configured.
2605 if((hw->media_type == e1000_media_type_copper) && hw->autoneg) {
2606 /* Read the MII Status Register and check to see if AutoNeg
2607 * has completed. We read this twice because this reg has
2608 * some "sticky" (latched) bits.
2610 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2613 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
2617 if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
2618 /* The AutoNeg process has completed, so we now need to
2619 * read both the Auto Negotiation Advertisement Register
2620 * (Address 4) and the Auto_Negotiation Base Page Ability
2621 * Register (Address 5) to determine how flow control was
2624 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
2628 ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
2629 &mii_nway_lp_ability_reg);
2633 /* Two bits in the Auto Negotiation Advertisement Register
2634 * (Address 4) and two bits in the Auto Negotiation Base
2635 * Page Ability Register (Address 5) determine flow control
2636 * for both the PHY and the link partner. The following
2637 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
2638 * 1999, describes these PAUSE resolution bits and how flow
2639 * control is determined based upon these settings.
2640 * NOTE: DC = Don't Care
2642 * LOCAL DEVICE | LINK PARTNER
2643 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
2644 *-------|---------|-------|---------|--------------------
2645 * 0 | 0 | DC | DC | e1000_fc_none
2646 * 0 | 1 | 0 | DC | e1000_fc_none
2647 * 0 | 1 | 1 | 0 | e1000_fc_none
2648 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
2649 * 1 | 0 | 0 | DC | e1000_fc_none
2650 * 1 | DC | 1 | DC | e1000_fc_full
2651 * 1 | 1 | 0 | 0 | e1000_fc_none
2652 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
2655 /* Are both PAUSE bits set to 1? If so, this implies
2656 * Symmetric Flow Control is enabled at both ends. The
2657 * ASM_DIR bits are irrelevant per the spec.
2659 * For Symmetric Flow Control:
2661 * LOCAL DEVICE | LINK PARTNER
2662 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2663 *-------|---------|-------|---------|--------------------
2664 * 1 | DC | 1 | DC | e1000_fc_full
2667 if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
2668 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
2669 /* Now we need to check if the user selected RX ONLY
2670 * of pause frames. In this case, we had to advertise
2671 * FULL flow control because we could not advertise RX
2672 * ONLY. Hence, we must now check to see if we need to
2673 * turn OFF the TRANSMISSION of PAUSE frames.
2675 if(hw->original_fc == e1000_fc_full) {
2676 hw->fc = e1000_fc_full;
2677 DEBUGOUT("Flow Control = FULL.\n");
2679 hw->fc = e1000_fc_rx_pause;
2680 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2683 /* For receiving PAUSE frames ONLY.
2685 * LOCAL DEVICE | LINK PARTNER
2686 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2687 *-------|---------|-------|---------|--------------------
2688 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
2691 else if(!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
2692 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
2693 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
2694 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
2695 hw->fc = e1000_fc_tx_pause;
2696 DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
2698 /* For transmitting PAUSE frames ONLY.
2700 * LOCAL DEVICE | LINK PARTNER
2701 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
2702 *-------|---------|-------|---------|--------------------
2703 * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
2706 else if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
2707 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
2708 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
2709 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
2710 hw->fc = e1000_fc_rx_pause;
2711 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2713 /* Per the IEEE spec, at this point flow control should be
2714 * disabled. However, we want to consider that we could
2715 * be connected to a legacy switch that doesn't advertise
2716 * desired flow control, but can be forced on the link
2717 * partner. So if we advertised no flow control, that is
2718 * what we will resolve to. If we advertised some kind of
2719 * receive capability (Rx Pause Only or Full Flow Control)
2720 * and the link partner advertised none, we will configure
2721 * ourselves to enable Rx Flow Control only. We can do
2722 * this safely for two reasons: If the link partner really
2723 * didn't want flow control enabled, and we enable Rx, no
2724 * harm done since we won't be receiving any PAUSE frames
2725 * anyway. If the intent on the link partner was to have
2726 * flow control enabled, then by us enabling RX only, we
2727 * can at least receive pause frames and process them.
2728 * This is a good idea because in most cases, since we are
2729 * predominantly a server NIC, more times than not we will
2730 * be asked to delay transmission of packets than asking
2731 * our link partner to pause transmission of frames.
2733 else if((hw->original_fc == e1000_fc_none ||
2734 hw->original_fc == e1000_fc_tx_pause) ||
2735 hw->fc_strict_ieee) {
2736 hw->fc = e1000_fc_none;
2737 DEBUGOUT("Flow Control = NONE.\n");
2739 hw->fc = e1000_fc_rx_pause;
2740 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2743 /* Now we need to do one last check... If we auto-
2744 * negotiated to HALF DUPLEX, flow control should not be
2745 * enabled per IEEE 802.3 spec.
2747 ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
2749 DEBUGOUT("Error getting link speed and duplex\n");
2753 if(duplex == HALF_DUPLEX)
2754 hw->fc = e1000_fc_none;
2756 /* Now we call a subroutine to actually force the MAC
2757 * controller to use the correct flow control settings.
2759 ret_val = e1000_force_mac_fc(hw);
2761 DEBUGOUT("Error forcing flow control settings\n");
2765 DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
2768 return E1000_SUCCESS;
2771 /******************************************************************************
2772 * Checks to see if the link status of the hardware has changed.
2774 * hw - Struct containing variables accessed by shared code
2776 * Called by any function that needs to check the link status of the adapter.
2777 *****************************************************************************/
2779 e1000_check_for_link(struct e1000_hw *hw)
2786 uint32_t signal = 0;
2790 DEBUGFUNC("e1000_check_for_link");
2792 ctrl = E1000_READ_REG(hw, CTRL);
2793 status = E1000_READ_REG(hw, STATUS);
2795 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
2796 * set when the optics detect a signal. On older adapters, it will be
2797 * cleared when there is a signal. This applies to fiber media only.
2799 if((hw->media_type == e1000_media_type_fiber) ||
2800 (hw->media_type == e1000_media_type_internal_serdes)) {
2801 rxcw = E1000_READ_REG(hw, RXCW);
2803 if(hw->media_type == e1000_media_type_fiber) {
2804 signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
2805 if(status & E1000_STATUS_LU)
2806 hw->get_link_status = FALSE;
2810 /* If we have a copper PHY then we only want to go out to the PHY
2811 * registers to see if Auto-Neg has completed and/or if our link
2812 * status has changed. The get_link_status flag will be set if we
2813 * receive a Link Status Change interrupt or we have Rx Sequence
2816 if((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
2817 /* First we want to see if the MII Status Register reports
2818 * link. If so, then we want to get the current speed/duplex
2820 * Read the register twice since the link bit is sticky.
2822 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
2825 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
2829 if(phy_data & MII_SR_LINK_STATUS) {
2830 hw->get_link_status = FALSE;
2831 /* Check if there was DownShift, must be checked immediately after
2833 e1000_check_downshift(hw);
2835 /* If we are on 82544 or 82543 silicon and speed/duplex
2836 * are forced to 10H or 10F, then we will implement the polarity
2837 * reversal workaround. We disable interrupts first, and upon
2838 * returning, place the devices interrupt state to its previous
2839 * value except for the link status change interrupt which will
2840 * happen due to the execution of this workaround.
2843 if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
2845 (hw->forced_speed_duplex == e1000_10_full ||
2846 hw->forced_speed_duplex == e1000_10_half)) {
2847 E1000_WRITE_REG(hw, IMC, 0xffffffff);
2848 ret_val = e1000_polarity_reversal_workaround(hw);
2849 icr = E1000_READ_REG(hw, ICR);
2850 E1000_WRITE_REG(hw, ICS, (icr & ~E1000_ICS_LSC));
2851 E1000_WRITE_REG(hw, IMS, IMS_ENABLE_MASK);
2855 /* No link detected */
2856 e1000_config_dsp_after_link_change(hw, FALSE);
2860 /* If we are forcing speed/duplex, then we simply return since
2861 * we have already determined whether we have link or not.
2863 if(!hw->autoneg) return -E1000_ERR_CONFIG;
2865 /* optimize the dsp settings for the igp phy */
2866 e1000_config_dsp_after_link_change(hw, TRUE);
2868 /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
2869 * have Si on board that is 82544 or newer, Auto
2870 * Speed Detection takes care of MAC speed/duplex
2871 * configuration. So we only need to configure Collision
2872 * Distance in the MAC. Otherwise, we need to force
2873 * speed/duplex on the MAC to the current PHY speed/duplex
2876 if(hw->mac_type >= e1000_82544)
2877 e1000_config_collision_dist(hw);
2879 ret_val = e1000_config_mac_to_phy(hw);
2881 DEBUGOUT("Error configuring MAC to PHY settings\n");
2886 /* Configure Flow Control now that Auto-Neg has completed. First, we
2887 * need to restore the desired flow control settings because we may
2888 * have had to re-autoneg with a different link partner.
2890 ret_val = e1000_config_fc_after_link_up(hw);
2892 DEBUGOUT("Error configuring flow control\n");
2896 /* At this point we know that we are on copper and we have
2897 * auto-negotiated link. These are conditions for checking the link
2898 * partner capability register. We use the link speed to determine if
2899 * TBI compatibility needs to be turned on or off. If the link is not
2900 * at gigabit speed, then TBI compatibility is not needed. If we are
2901 * at gigabit speed, we turn on TBI compatibility.
2903 if(hw->tbi_compatibility_en) {
2904 uint16_t speed, duplex;
2905 ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
2907 DEBUGOUT("Error getting link speed and duplex\n");
2910 if (speed != SPEED_1000) {
2911 /* If link speed is not set to gigabit speed, we do not need
2912 * to enable TBI compatibility.
2914 if(hw->tbi_compatibility_on) {
2915 /* If we previously were in the mode, turn it off. */
2916 rctl = E1000_READ_REG(hw, RCTL);
2917 rctl &= ~E1000_RCTL_SBP;
2918 E1000_WRITE_REG(hw, RCTL, rctl);
2919 hw->tbi_compatibility_on = FALSE;
2922 /* If TBI compatibility is was previously off, turn it on. For
2923 * compatibility with a TBI link partner, we will store bad
2924 * packets. Some frames have an additional byte on the end and
2925 * will look like CRC errors to to the hardware.
2927 if(!hw->tbi_compatibility_on) {
2928 hw->tbi_compatibility_on = TRUE;
2929 rctl = E1000_READ_REG(hw, RCTL);
2930 rctl |= E1000_RCTL_SBP;
2931 E1000_WRITE_REG(hw, RCTL, rctl);
2936 /* If we don't have link (auto-negotiation failed or link partner cannot
2937 * auto-negotiate), the cable is plugged in (we have signal), and our
2938 * link partner is not trying to auto-negotiate with us (we are receiving
2939 * idles or data), we need to force link up. We also need to give
2940 * auto-negotiation time to complete, in case the cable was just plugged
2941 * in. The autoneg_failed flag does this.
2943 else if((((hw->media_type == e1000_media_type_fiber) &&
2944 ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
2945 (hw->media_type == e1000_media_type_internal_serdes)) &&
2946 (!(status & E1000_STATUS_LU)) &&
2947 (!(rxcw & E1000_RXCW_C))) {
2948 if(hw->autoneg_failed == 0) {
2949 hw->autoneg_failed = 1;
2952 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
2954 /* Disable auto-negotiation in the TXCW register */
2955 E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
2957 /* Force link-up and also force full-duplex. */
2958 ctrl = E1000_READ_REG(hw, CTRL);
2959 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
2960 E1000_WRITE_REG(hw, CTRL, ctrl);
2962 /* Configure Flow Control after forcing link up. */
2963 ret_val = e1000_config_fc_after_link_up(hw);
2965 DEBUGOUT("Error configuring flow control\n");
2969 /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
2970 * auto-negotiation in the TXCW register and disable forced link in the
2971 * Device Control register in an attempt to auto-negotiate with our link
2974 else if(((hw->media_type == e1000_media_type_fiber) ||
2975 (hw->media_type == e1000_media_type_internal_serdes)) &&
2976 (ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
2977 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
2978 E1000_WRITE_REG(hw, TXCW, hw->txcw);
2979 E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
2981 hw->serdes_link_down = FALSE;
2983 /* If we force link for non-auto-negotiation switch, check link status
2984 * based on MAC synchronization for internal serdes media type.
2986 else if((hw->media_type == e1000_media_type_internal_serdes) &&
2987 !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
2988 /* SYNCH bit and IV bit are sticky. */
2990 if(E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
2991 if(!(rxcw & E1000_RXCW_IV)) {
2992 hw->serdes_link_down = FALSE;
2993 DEBUGOUT("SERDES: Link is up.\n");
2996 hw->serdes_link_down = TRUE;
2997 DEBUGOUT("SERDES: Link is down.\n");
3000 if((hw->media_type == e1000_media_type_internal_serdes) &&
3001 (E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
3002 hw->serdes_link_down = !(E1000_STATUS_LU & E1000_READ_REG(hw, STATUS));
3004 return E1000_SUCCESS;
3007 /******************************************************************************
3008 * Detects the current speed and duplex settings of the hardware.
3010 * hw - Struct containing variables accessed by shared code
3011 * speed - Speed of the connection
3012 * duplex - Duplex setting of the connection
3013 *****************************************************************************/
3015 e1000_get_speed_and_duplex(struct e1000_hw *hw,
3023 DEBUGFUNC("e1000_get_speed_and_duplex");
3025 if(hw->mac_type >= e1000_82543) {
3026 status = E1000_READ_REG(hw, STATUS);
3027 if(status & E1000_STATUS_SPEED_1000) {
3028 *speed = SPEED_1000;
3029 DEBUGOUT("1000 Mbs, ");
3030 } else if(status & E1000_STATUS_SPEED_100) {
3032 DEBUGOUT("100 Mbs, ");
3035 DEBUGOUT("10 Mbs, ");
3038 if(status & E1000_STATUS_FD) {
3039 *duplex = FULL_DUPLEX;
3040 DEBUGOUT("Full Duplex\n");
3042 *duplex = HALF_DUPLEX;
3043 DEBUGOUT(" Half Duplex\n");
3046 DEBUGOUT("1000 Mbs, Full Duplex\n");
3047 *speed = SPEED_1000;
3048 *duplex = FULL_DUPLEX;
3051 /* IGP01 PHY may advertise full duplex operation after speed downgrade even
3052 * if it is operating at half duplex. Here we set the duplex settings to
3053 * match the duplex in the link partner's capabilities.
3055 if(hw->phy_type == e1000_phy_igp && hw->speed_downgraded) {
3056 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_EXP, &phy_data);
3060 if(!(phy_data & NWAY_ER_LP_NWAY_CAPS))
3061 *duplex = HALF_DUPLEX;
3063 ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY, &phy_data);
3066 if((*speed == SPEED_100 && !(phy_data & NWAY_LPAR_100TX_FD_CAPS)) ||
3067 (*speed == SPEED_10 && !(phy_data & NWAY_LPAR_10T_FD_CAPS)))
3068 *duplex = HALF_DUPLEX;
3072 if ((hw->mac_type == e1000_80003es2lan) &&
3073 (hw->media_type == e1000_media_type_copper)) {
3074 if (*speed == SPEED_1000)
3075 ret_val = e1000_configure_kmrn_for_1000(hw);
3077 ret_val = e1000_configure_kmrn_for_10_100(hw, *duplex);
3082 if ((hw->phy_type == e1000_phy_igp_3) && (*speed == SPEED_1000)) {
3083 ret_val = e1000_kumeran_lock_loss_workaround(hw);
3088 return E1000_SUCCESS;
3091 /******************************************************************************
3092 * Blocks until autoneg completes or times out (~4.5 seconds)
3094 * hw - Struct containing variables accessed by shared code
3095 ******************************************************************************/
3097 e1000_wait_autoneg(struct e1000_hw *hw)
3103 DEBUGFUNC("e1000_wait_autoneg");
3104 DEBUGOUT("Waiting for Auto-Neg to complete.\n");
3106 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
3107 for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
3108 /* Read the MII Status Register and wait for Auto-Neg
3109 * Complete bit to be set.
3111 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
3114 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
3117 if(phy_data & MII_SR_AUTONEG_COMPLETE) {
3118 return E1000_SUCCESS;
3122 return E1000_SUCCESS;
3125 /******************************************************************************
3126 * Raises the Management Data Clock
3128 * hw - Struct containing variables accessed by shared code
3129 * ctrl - Device control register's current value
3130 ******************************************************************************/
3132 e1000_raise_mdi_clk(struct e1000_hw *hw,
3135 /* Raise the clock input to the Management Data Clock (by setting the MDC
3136 * bit), and then delay 10 microseconds.
3138 E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
3139 E1000_WRITE_FLUSH(hw);
3143 /******************************************************************************
3144 * Lowers the Management Data Clock
3146 * hw - Struct containing variables accessed by shared code
3147 * ctrl - Device control register's current value
3148 ******************************************************************************/
3150 e1000_lower_mdi_clk(struct e1000_hw *hw,
3153 /* Lower the clock input to the Management Data Clock (by clearing the MDC
3154 * bit), and then delay 10 microseconds.
3156 E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
3157 E1000_WRITE_FLUSH(hw);
3161 /******************************************************************************
3162 * Shifts data bits out to the PHY
3164 * hw - Struct containing variables accessed by shared code
3165 * data - Data to send out to the PHY
3166 * count - Number of bits to shift out
3168 * Bits are shifted out in MSB to LSB order.
3169 ******************************************************************************/
3171 e1000_shift_out_mdi_bits(struct e1000_hw *hw,
3178 /* We need to shift "count" number of bits out to the PHY. So, the value
3179 * in the "data" parameter will be shifted out to the PHY one bit at a
3180 * time. In order to do this, "data" must be broken down into bits.
3183 mask <<= (count - 1);
3185 ctrl = E1000_READ_REG(hw, CTRL);
3187 /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
3188 ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
3191 /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
3192 * then raising and lowering the Management Data Clock. A "0" is
3193 * shifted out to the PHY by setting the MDIO bit to "0" and then
3194 * raising and lowering the clock.
3196 if(data & mask) ctrl |= E1000_CTRL_MDIO;
3197 else ctrl &= ~E1000_CTRL_MDIO;
3199 E1000_WRITE_REG(hw, CTRL, ctrl);
3200 E1000_WRITE_FLUSH(hw);
3204 e1000_raise_mdi_clk(hw, &ctrl);
3205 e1000_lower_mdi_clk(hw, &ctrl);
3211 /******************************************************************************
3212 * Shifts data bits in from the PHY
3214 * hw - Struct containing variables accessed by shared code
3216 * Bits are shifted in in MSB to LSB order.
3217 ******************************************************************************/
3219 e1000_shift_in_mdi_bits(struct e1000_hw *hw)
3225 /* In order to read a register from the PHY, we need to shift in a total
3226 * of 18 bits from the PHY. The first two bit (turnaround) times are used
3227 * to avoid contention on the MDIO pin when a read operation is performed.
3228 * These two bits are ignored by us and thrown away. Bits are "shifted in"
3229 * by raising the input to the Management Data Clock (setting the MDC bit),
3230 * and then reading the value of the MDIO bit.
3232 ctrl = E1000_READ_REG(hw, CTRL);
3234 /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
3235 ctrl &= ~E1000_CTRL_MDIO_DIR;
3236 ctrl &= ~E1000_CTRL_MDIO;
3238 E1000_WRITE_REG(hw, CTRL, ctrl);
3239 E1000_WRITE_FLUSH(hw);
3241 /* Raise and Lower the clock before reading in the data. This accounts for
3242 * the turnaround bits. The first clock occurred when we clocked out the
3243 * last bit of the Register Address.
3245 e1000_raise_mdi_clk(hw, &ctrl);
3246 e1000_lower_mdi_clk(hw, &ctrl);
3248 for(data = 0, i = 0; i < 16; i++) {
3250 e1000_raise_mdi_clk(hw, &ctrl);
3251 ctrl = E1000_READ_REG(hw, CTRL);
3252 /* Check to see if we shifted in a "1". */
3253 if(ctrl & E1000_CTRL_MDIO) data |= 1;
3254 e1000_lower_mdi_clk(hw, &ctrl);
3257 e1000_raise_mdi_clk(hw, &ctrl);
3258 e1000_lower_mdi_clk(hw, &ctrl);
3264 e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask)
3266 uint32_t swfw_sync = 0;
3267 uint32_t swmask = mask;
3268 uint32_t fwmask = mask << 16;
3269 int32_t timeout = 200;
3271 DEBUGFUNC("e1000_swfw_sync_acquire");
3273 if (hw->swfwhw_semaphore_present)
3274 return e1000_get_software_flag(hw);
3276 if (!hw->swfw_sync_present)
3277 return e1000_get_hw_eeprom_semaphore(hw);
3280 if (e1000_get_hw_eeprom_semaphore(hw))
3281 return -E1000_ERR_SWFW_SYNC;
3283 swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
3284 if (!(swfw_sync & (fwmask | swmask))) {
3288 /* firmware currently using resource (fwmask) */
3289 /* or other software thread currently using resource (swmask) */
3290 e1000_put_hw_eeprom_semaphore(hw);
3296 DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
3297 return -E1000_ERR_SWFW_SYNC;
3300 swfw_sync |= swmask;
3301 E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
3303 e1000_put_hw_eeprom_semaphore(hw);
3304 return E1000_SUCCESS;
3308 e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask)
3311 uint32_t swmask = mask;
3313 DEBUGFUNC("e1000_swfw_sync_release");
3315 if (hw->swfwhw_semaphore_present) {
3316 e1000_release_software_flag(hw);
3320 if (!hw->swfw_sync_present) {
3321 e1000_put_hw_eeprom_semaphore(hw);
3325 /* if (e1000_get_hw_eeprom_semaphore(hw))
3326 * return -E1000_ERR_SWFW_SYNC; */
3327 while (e1000_get_hw_eeprom_semaphore(hw) != E1000_SUCCESS);
3330 swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
3331 swfw_sync &= ~swmask;
3332 E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
3334 e1000_put_hw_eeprom_semaphore(hw);
3337 /*****************************************************************************
3338 * Reads the value from a PHY register, if the value is on a specific non zero
3339 * page, sets the page first.
3340 * hw - Struct containing variables accessed by shared code
3341 * reg_addr - address of the PHY register to read
3342 ******************************************************************************/
3344 e1000_read_phy_reg(struct e1000_hw *hw,
3351 DEBUGFUNC("e1000_read_phy_reg");
3353 if ((hw->mac_type == e1000_80003es2lan) &&
3354 (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
3355 swfw = E1000_SWFW_PHY1_SM;
3357 swfw = E1000_SWFW_PHY0_SM;
3359 if (e1000_swfw_sync_acquire(hw, swfw))
3360 return -E1000_ERR_SWFW_SYNC;
3362 if ((hw->phy_type == e1000_phy_igp ||
3363 hw->phy_type == e1000_phy_igp_3 ||
3364 hw->phy_type == e1000_phy_igp_2) &&
3365 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
3366 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
3367 (uint16_t)reg_addr);
3369 e1000_swfw_sync_release(hw, swfw);
3372 } else if (hw->phy_type == e1000_phy_gg82563) {
3373 if (((reg_addr & MAX_PHY_REG_ADDRESS) > MAX_PHY_MULTI_PAGE_REG) ||
3374 (hw->mac_type == e1000_80003es2lan)) {
3375 /* Select Configuration Page */
3376 if ((reg_addr & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
3377 ret_val = e1000_write_phy_reg_ex(hw, GG82563_PHY_PAGE_SELECT,
3378 (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
3380 /* Use Alternative Page Select register to access