1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
35 #include "e1000_api.h"
36 #include "e1000_82541.h"
38 static s32
e1000_init_phy_params_82541(struct e1000_hw
*hw
);
39 static s32
e1000_init_nvm_params_82541(struct e1000_hw
*hw
);
40 static s32
e1000_init_mac_params_82541(struct e1000_hw
*hw
);
41 static s32
e1000_reset_hw_82541(struct e1000_hw
*hw
);
42 static s32
e1000_init_hw_82541(struct e1000_hw
*hw
);
43 static s32
e1000_get_link_up_info_82541(struct e1000_hw
*hw
, u16
*speed
,
45 static s32
e1000_phy_hw_reset_82541(struct e1000_hw
*hw
);
46 static s32
e1000_setup_copper_link_82541(struct e1000_hw
*hw
);
47 static s32
e1000_check_for_link_82541(struct e1000_hw
*hw
);
48 static s32
e1000_get_cable_length_igp_82541(struct e1000_hw
*hw
);
49 static s32
e1000_set_d3_lplu_state_82541(struct e1000_hw
*hw
,
51 static s32
e1000_setup_led_82541(struct e1000_hw
*hw
);
52 static s32
e1000_cleanup_led_82541(struct e1000_hw
*hw
);
53 static void e1000_clear_hw_cntrs_82541(struct e1000_hw
*hw
);
54 static s32
e1000_config_dsp_after_link_change_82541(struct e1000_hw
*hw
,
56 static s32
e1000_phy_init_script_82541(struct e1000_hw
*hw
);
57 static void e1000_power_down_phy_copper_82541(struct e1000_hw
*hw
);
59 static const u16 e1000_igp_cable_length_table
[] =
60 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
61 5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
62 25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
63 40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
64 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
65 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
66 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
67 110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
68 #define IGP01E1000_AGC_LENGTH_TABLE_SIZE \
69 (sizeof(e1000_igp_cable_length_table) / \
70 sizeof(e1000_igp_cable_length_table[0]))
72 struct e1000_dev_spec_82541
{
73 e1000_dsp_config dsp_config
;
74 e1000_ffe_config ffe_config
;
80 * e1000_init_phy_params_82541 - Init PHY func ptrs.
81 * @hw: pointer to the HW structure
83 * This is a function pointer entry point called by the api module.
85 static s32
e1000_init_phy_params_82541(struct e1000_hw
*hw
)
87 struct e1000_phy_info
*phy
= &hw
->phy
;
88 s32 ret_val
= E1000_SUCCESS
;
90 DEBUGFUNC("e1000_init_phy_params_82541");
93 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
94 phy
->reset_delay_us
= 10000;
95 phy
->type
= e1000_phy_igp
;
97 /* Function Pointers */
98 phy
->ops
.check_polarity
= e1000_check_polarity_igp
;
99 phy
->ops
.force_speed_duplex
= e1000_phy_force_speed_duplex_igp
;
100 phy
->ops
.get_cable_length
= e1000_get_cable_length_igp_82541
;
101 phy
->ops
.get_cfg_done
= e1000_get_cfg_done_generic
;
102 phy
->ops
.get_info
= e1000_get_phy_info_igp
;
103 phy
->ops
.read_reg
= e1000_read_phy_reg_igp
;
104 phy
->ops
.reset
= e1000_phy_hw_reset_82541
;
105 phy
->ops
.set_d3_lplu_state
= e1000_set_d3_lplu_state_82541
;
106 phy
->ops
.write_reg
= e1000_write_phy_reg_igp
;
107 phy
->ops
.power_up
= e1000_power_up_phy_copper
;
108 phy
->ops
.power_down
= e1000_power_down_phy_copper_82541
;
110 ret_val
= e1000_get_phy_id(hw
);
115 if (phy
->id
!= IGP01E1000_I_PHY_ID
) {
116 ret_val
= -E1000_ERR_PHY
;
125 * e1000_init_nvm_params_82541 - Init NVM func ptrs.
126 * @hw: pointer to the HW structure
128 * This is a function pointer entry point called by the api module.
130 static s32
e1000_init_nvm_params_82541(struct e1000_hw
*hw
)
132 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
133 s32 ret_val
= E1000_SUCCESS
;
134 u32 eecd
= E1000_READ_REG(hw
, E1000_EECD
);
137 DEBUGFUNC("e1000_init_nvm_params_82541");
139 switch (nvm
->override
) {
140 case e1000_nvm_override_spi_large
:
141 nvm
->type
= e1000_nvm_eeprom_spi
;
142 eecd
|= E1000_EECD_ADDR_BITS
;
144 case e1000_nvm_override_spi_small
:
145 nvm
->type
= e1000_nvm_eeprom_spi
;
146 eecd
&= ~E1000_EECD_ADDR_BITS
;
148 case e1000_nvm_override_microwire_large
:
149 nvm
->type
= e1000_nvm_eeprom_microwire
;
150 eecd
|= E1000_EECD_SIZE
;
152 case e1000_nvm_override_microwire_small
:
153 nvm
->type
= e1000_nvm_eeprom_microwire
;
154 eecd
&= ~E1000_EECD_SIZE
;
157 nvm
->type
= eecd
& E1000_EECD_TYPE
158 ? e1000_nvm_eeprom_spi
159 : e1000_nvm_eeprom_microwire
;
163 if (nvm
->type
== e1000_nvm_eeprom_spi
) {
164 nvm
->address_bits
= (eecd
& E1000_EECD_ADDR_BITS
)
167 nvm
->opcode_bits
= 8;
168 nvm
->page_size
= (eecd
& E1000_EECD_ADDR_BITS
)
171 /* Function Pointers */
172 nvm
->ops
.acquire
= e1000_acquire_nvm_generic
;
173 nvm
->ops
.read
= e1000_read_nvm_spi
;
174 nvm
->ops
.release
= e1000_release_nvm_generic
;
175 nvm
->ops
.update
= e1000_update_nvm_checksum_generic
;
176 nvm
->ops
.valid_led_default
= e1000_valid_led_default_generic
;
177 nvm
->ops
.validate
= e1000_validate_nvm_checksum_generic
;
178 nvm
->ops
.write
= e1000_write_nvm_spi
;
181 * nvm->word_size must be discovered after the pointers
182 * are set so we can verify the size from the nvm image
183 * itself. Temporarily set it to a dummy value so the
187 ret_val
= nvm
->ops
.read(hw
, NVM_CFG
, 1, &size
);
190 size
= (size
& NVM_SIZE_MASK
) >> NVM_SIZE_SHIFT
;
192 * if size != 0, it can be added to a constant and become
193 * the left-shift value to set the word_size. Otherwise,
194 * word_size stays at 64.
197 size
+= NVM_WORD_SIZE_BASE_SHIFT_82541
;
198 nvm
->word_size
= 1 << size
;
201 nvm
->address_bits
= (eecd
& E1000_EECD_ADDR_BITS
)
203 nvm
->delay_usec
= 50;
204 nvm
->opcode_bits
= 3;
205 nvm
->word_size
= (eecd
& E1000_EECD_ADDR_BITS
)
208 /* Function Pointers */
209 nvm
->ops
.acquire
= e1000_acquire_nvm_generic
;
210 nvm
->ops
.read
= e1000_read_nvm_microwire
;
211 nvm
->ops
.release
= e1000_release_nvm_generic
;
212 nvm
->ops
.update
= e1000_update_nvm_checksum_generic
;
213 nvm
->ops
.valid_led_default
= e1000_valid_led_default_generic
;
214 nvm
->ops
.validate
= e1000_validate_nvm_checksum_generic
;
215 nvm
->ops
.write
= e1000_write_nvm_microwire
;
223 * e1000_init_mac_params_82541 - Init MAC func ptrs.
224 * @hw: pointer to the HW structure
226 * This is a function pointer entry point called by the api module.
228 static s32
e1000_init_mac_params_82541(struct e1000_hw
*hw
)
230 struct e1000_mac_info
*mac
= &hw
->mac
;
233 DEBUGFUNC("e1000_init_mac_params_82541");
236 hw
->phy
.media_type
= e1000_media_type_copper
;
237 /* Set mta register count */
238 mac
->mta_reg_count
= 128;
239 /* Set rar entry count */
240 mac
->rar_entry_count
= E1000_RAR_ENTRIES
;
241 /* Set if part includes ASF firmware */
242 mac
->asf_firmware_present
= TRUE
;
244 /* Function Pointers */
246 /* bus type/speed/width */
247 mac
->ops
.get_bus_info
= e1000_get_bus_info_pci_generic
;
249 mac
->ops
.reset_hw
= e1000_reset_hw_82541
;
250 /* hw initialization */
251 mac
->ops
.init_hw
= e1000_init_hw_82541
;
253 mac
->ops
.setup_link
= e1000_setup_link_generic
;
254 /* physical interface link setup */
255 mac
->ops
.setup_physical_interface
= e1000_setup_copper_link_82541
;
257 mac
->ops
.check_for_link
= e1000_check_for_link_82541
;
259 mac
->ops
.get_link_up_info
= e1000_get_link_up_info_82541
;
260 /* multicast address update */
261 mac
->ops
.update_mc_addr_list
= e1000_update_mc_addr_list_generic
;
263 mac
->ops
.write_vfta
= e1000_write_vfta_generic
;
265 mac
->ops
.clear_vfta
= e1000_clear_vfta_generic
;
267 mac
->ops
.mta_set
= e1000_mta_set_generic
;
269 mac
->ops
.setup_led
= e1000_setup_led_82541
;
271 mac
->ops
.cleanup_led
= e1000_cleanup_led_82541
;
272 /* turn on/off LED */
273 mac
->ops
.led_on
= e1000_led_on_generic
;
274 mac
->ops
.led_off
= e1000_led_off_generic
;
276 mac
->ops
.remove_device
= e1000_remove_device_generic
;
277 /* clear hardware counters */
278 mac
->ops
.clear_hw_cntrs
= e1000_clear_hw_cntrs_82541
;
280 hw
->dev_spec_size
= sizeof(struct e1000_dev_spec_82541
);
282 /* Device-specific structure allocation */
283 ret_val
= e1000_alloc_zeroed_dev_spec_struct(hw
, hw
->dev_spec_size
);
289 * e1000_init_function_pointers_82541 - Init func ptrs.
290 * @hw: pointer to the HW structure
292 * The only function explicitly called by the api module to initialize
293 * all function pointers and parameters.
295 void e1000_init_function_pointers_82541(struct e1000_hw
*hw
)
297 DEBUGFUNC("e1000_init_function_pointers_82541");
299 hw
->mac
.ops
.init_params
= e1000_init_mac_params_82541
;
300 hw
->nvm
.ops
.init_params
= e1000_init_nvm_params_82541
;
301 hw
->phy
.ops
.init_params
= e1000_init_phy_params_82541
;
305 * e1000_reset_hw_82541 - Reset hardware
306 * @hw: pointer to the HW structure
308 * This resets the hardware into a known state. This is a
309 * function pointer entry point called by the api module.
311 static s32
e1000_reset_hw_82541(struct e1000_hw
*hw
)
313 u32 ledctl
, ctrl
, icr
, manc
;
315 DEBUGFUNC("e1000_reset_hw_82541");
317 DEBUGOUT("Masking off all interrupts\n");
318 E1000_WRITE_REG(hw
, E1000_IMC
, 0xFFFFFFFF);
320 E1000_WRITE_REG(hw
, E1000_RCTL
, 0);
321 E1000_WRITE_REG(hw
, E1000_TCTL
, E1000_TCTL_PSP
);
322 E1000_WRITE_FLUSH(hw
);
325 * Delay to allow any outstanding PCI transactions to complete
326 * before resetting the device.
330 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
332 /* Must reset the Phy before resetting the MAC */
333 if ((hw
->mac
.type
== e1000_82541
) || (hw
->mac
.type
== e1000_82547
)) {
334 E1000_WRITE_REG(hw
, E1000_CTRL
, (ctrl
| E1000_CTRL_PHY_RST
));
338 DEBUGOUT("Issuing a global reset to 82541/82547 MAC\n");
339 switch (hw
->mac
.type
) {
341 case e1000_82541_rev_2
:
343 * These controllers can't ack the 64-bit write when
344 * issuing the reset, so we use IO-mapping as a
345 * workaround to issue the reset.
347 E1000_WRITE_REG_IO(hw
, E1000_CTRL
, ctrl
| E1000_CTRL_RST
);
350 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
| E1000_CTRL_RST
);
354 /* Wait for NVM reload */
357 /* Disable HW ARPs on ASF enabled adapters */
358 manc
= E1000_READ_REG(hw
, E1000_MANC
);
359 manc
&= ~E1000_MANC_ARP_EN
;
360 E1000_WRITE_REG(hw
, E1000_MANC
, manc
);
362 if ((hw
->mac
.type
== e1000_82541
) || (hw
->mac
.type
== e1000_82547
)) {
363 e1000_phy_init_script_82541(hw
);
365 /* Configure activity LED after Phy reset */
366 ledctl
= E1000_READ_REG(hw
, E1000_LEDCTL
);
367 ledctl
&= IGP_ACTIVITY_LED_MASK
;
368 ledctl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
369 E1000_WRITE_REG(hw
, E1000_LEDCTL
, ledctl
);
372 /* Once again, mask the interrupts */
373 DEBUGOUT("Masking off all interrupts\n");
374 E1000_WRITE_REG(hw
, E1000_IMC
, 0xFFFFFFFF);
376 /* Clear any pending interrupt events. */
377 icr
= E1000_READ_REG(hw
, E1000_ICR
);
379 return E1000_SUCCESS
;
383 * e1000_init_hw_82541 - Initialize hardware
384 * @hw: pointer to the HW structure
386 * This inits the hardware readying it for operation. This is a
387 * function pointer entry point called by the api module.
389 static s32
e1000_init_hw_82541(struct e1000_hw
*hw
)
391 struct e1000_mac_info
*mac
= &hw
->mac
;
395 DEBUGFUNC("e1000_init_hw_82541");
397 /* Initialize identification LED */
398 ret_val
= e1000_id_led_init_generic(hw
);
400 DEBUGOUT("Error initializing identification LED\n");
401 /* This is not fatal and we should not stop init due to this */
404 /* Disabling VLAN filtering */
405 DEBUGOUT("Initializing the IEEE VLAN\n");
406 mac
->ops
.clear_vfta(hw
);
408 /* Setup the receive address. */
409 e1000_init_rx_addrs_generic(hw
, mac
->rar_entry_count
);
411 /* Zero out the Multicast HASH table */
412 DEBUGOUT("Zeroing the MTA\n");
413 for (i
= 0; i
< mac
->mta_reg_count
; i
++) {
414 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
416 * Avoid back to back register writes by adding the register
417 * read (flush). This is to protect against some strange
418 * bridge configurations that may issue Memory Write Block
419 * (MWB) to our register space.
421 E1000_WRITE_FLUSH(hw
);
424 /* Setup link and flow control */
425 ret_val
= mac
->ops
.setup_link(hw
);
427 txdctl
= E1000_READ_REG(hw
, E1000_TXDCTL(0));
428 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
429 E1000_TXDCTL_FULL_TX_DESC_WB
;
430 E1000_WRITE_REG(hw
, E1000_TXDCTL(0), txdctl
);
433 * Clear all of the statistics registers (clear on read). It is
434 * important that we do this after we have tried to establish link
435 * because the symbol error count will increment wildly if there
438 e1000_clear_hw_cntrs_82541(hw
);
444 * e1000_get_link_up_info_82541 - Report speed and duplex
445 * @hw: pointer to the HW structure
446 * @speed: pointer to speed buffer
447 * @duplex: pointer to duplex buffer
449 * Retrieve the current speed and duplex configuration.
450 * This is a function pointer entry point called by the api module.
452 static s32
e1000_get_link_up_info_82541(struct e1000_hw
*hw
, u16
*speed
,
455 struct e1000_phy_info
*phy
= &hw
->phy
;
459 DEBUGFUNC("e1000_get_link_up_info_82541");
461 ret_val
= e1000_get_speed_and_duplex_copper_generic(hw
, speed
, duplex
);
465 if (!phy
->speed_downgraded
)
469 * IGP01 PHY may advertise full duplex operation after speed
470 * downgrade even if it is operating at half duplex.
471 * Here we set the duplex settings to match the duplex in the
472 * link partner's capabilities.
474 ret_val
= phy
->ops
.read_reg(hw
, PHY_AUTONEG_EXP
, &data
);
478 if (!(data
& NWAY_ER_LP_NWAY_CAPS
)) {
479 *duplex
= HALF_DUPLEX
;
481 ret_val
= phy
->ops
.read_reg(hw
, PHY_LP_ABILITY
, &data
);
485 if (*speed
== SPEED_100
) {
486 if (!(data
& NWAY_LPAR_100TX_FD_CAPS
))
487 *duplex
= HALF_DUPLEX
;
488 } else if (*speed
== SPEED_10
) {
489 if (!(data
& NWAY_LPAR_10T_FD_CAPS
))
490 *duplex
= HALF_DUPLEX
;
499 * e1000_phy_hw_reset_82541 - PHY hardware reset
500 * @hw: pointer to the HW structure
502 * Verify the reset block is not blocking us from resetting. Acquire
503 * semaphore (if necessary) and read/set/write the device control reset
504 * bit in the PHY. Wait the appropriate delay time for the device to
505 * reset and release the semaphore (if necessary).
506 * This is a function pointer entry point called by the api module.
508 static s32
e1000_phy_hw_reset_82541(struct e1000_hw
*hw
)
513 DEBUGFUNC("e1000_phy_hw_reset_82541");
515 ret_val
= e1000_phy_hw_reset_generic(hw
);
519 e1000_phy_init_script_82541(hw
);
521 if ((hw
->mac
.type
== e1000_82541
) || (hw
->mac
.type
== e1000_82547
)) {
522 /* Configure activity LED after PHY reset */
523 ledctl
= E1000_READ_REG(hw
, E1000_LEDCTL
);
524 ledctl
&= IGP_ACTIVITY_LED_MASK
;
525 ledctl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
526 E1000_WRITE_REG(hw
, E1000_LEDCTL
, ledctl
);
534 * e1000_setup_copper_link_82541 - Configure copper link settings
535 * @hw: pointer to the HW structure
537 * Calls the appropriate function to configure the link for auto-neg or forced
538 * speed and duplex. Then we check for link, once link is established calls
539 * to configure collision distance and flow control are called. If link is
540 * not established, we return -E1000_ERR_PHY (-2). This is a function
541 * pointer entry point called by the api module.
543 static s32
e1000_setup_copper_link_82541(struct e1000_hw
*hw
)
545 struct e1000_phy_info
*phy
= &hw
->phy
;
546 struct e1000_dev_spec_82541
*dev_spec
;
550 DEBUGFUNC("e1000_setup_copper_link_82541");
552 ctrl
= E1000_READ_REG(hw
, E1000_CTRL
);
553 ctrl
|= E1000_CTRL_SLU
;
554 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
555 E1000_WRITE_REG(hw
, E1000_CTRL
, ctrl
);
557 hw
->phy
.reset_disable
= FALSE
;
559 dev_spec
= (struct e1000_dev_spec_82541
*)hw
->dev_spec
;
561 /* Earlier revs of the IGP phy require us to force MDI. */
562 if (hw
->mac
.type
== e1000_82541
|| hw
->mac
.type
== e1000_82547
) {
563 dev_spec
->dsp_config
= e1000_dsp_config_disabled
;
566 dev_spec
->dsp_config
= e1000_dsp_config_enabled
;
569 ret_val
= e1000_copper_link_setup_igp(hw
);
573 if (hw
->mac
.autoneg
) {
574 if (dev_spec
->ffe_config
== e1000_ffe_config_active
)
575 dev_spec
->ffe_config
= e1000_ffe_config_enabled
;
578 /* Configure activity LED after Phy reset */
579 ledctl
= E1000_READ_REG(hw
, E1000_LEDCTL
);
580 ledctl
&= IGP_ACTIVITY_LED_MASK
;
581 ledctl
|= (IGP_ACTIVITY_LED_ENABLE
| IGP_LED3_MODE
);
582 E1000_WRITE_REG(hw
, E1000_LEDCTL
, ledctl
);
584 ret_val
= e1000_setup_copper_link_generic(hw
);
591 * e1000_check_for_link_82541 - Check/Store link connection
592 * @hw: pointer to the HW structure
594 * This checks the link condition of the adapter and stores the
595 * results in the hw->mac structure. This is a function pointer entry
596 * point called by the api module.
598 static s32
e1000_check_for_link_82541(struct e1000_hw
*hw
)
600 struct e1000_mac_info
*mac
= &hw
->mac
;
604 DEBUGFUNC("e1000_check_for_link_82541");
607 * We only want to go out to the PHY registers to see if Auto-Neg
608 * has completed and/or if our link status has changed. The
609 * get_link_status flag is set upon receiving a Link Status
610 * Change or Rx Sequence Error interrupt.
612 if (!mac
->get_link_status
) {
613 ret_val
= E1000_SUCCESS
;
618 * First we want to see if the MII Status Register reports
619 * link. If so, then we want to get the current speed/duplex
622 ret_val
= e1000_phy_has_link_generic(hw
, 1, 0, &link
);
627 ret_val
= e1000_config_dsp_after_link_change_82541(hw
, FALSE
);
628 goto out
; /* No link detected */
631 mac
->get_link_status
= FALSE
;
634 * Check if there was DownShift, must be checked
635 * immediately after link-up
637 e1000_check_downshift_generic(hw
);
640 * If we are forcing speed/duplex, then we simply return since
641 * we have already determined whether we have link or not.
644 ret_val
= -E1000_ERR_CONFIG
;
648 ret_val
= e1000_config_dsp_after_link_change_82541(hw
, TRUE
);
651 * Auto-Neg is enabled. Auto Speed Detection takes care
652 * of MAC speed/duplex configuration. So we only need to
653 * configure Collision Distance in the MAC.
655 e1000_config_collision_dist_generic(hw
);
658 * Configure Flow Control now that Auto-Neg has completed.
659 * First, we need to restore the desired flow control
660 * settings because we may have had to re-autoneg with a
661 * different link partner.
663 ret_val
= e1000_config_fc_after_link_up_generic(hw
);
665 DEBUGOUT("Error configuring flow control\n");
673 * e1000_config_dsp_after_link_change_82541 - Config DSP after link
674 * @hw: pointer to the HW structure
675 * @link_up: boolean flag for link up status
677 * Return E1000_ERR_PHY when failing to read/write the PHY, else E1000_SUCCESS
680 * 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
681 * gigabit link is achieved to improve link quality.
682 * This is a function pointer entry point called by the api module.
684 static s32
e1000_config_dsp_after_link_change_82541(struct e1000_hw
*hw
,
687 struct e1000_phy_info
*phy
= &hw
->phy
;
688 struct e1000_dev_spec_82541
*dev_spec
;
691 u16 phy_data
, phy_saved_data
, speed
, duplex
, i
;
692 u16 ffe_idle_err_timeout
= FFE_IDLE_ERR_COUNT_TIMEOUT_20
;
693 u16 dsp_reg_array
[IGP01E1000_PHY_CHANNEL_NUM
] =
694 {IGP01E1000_PHY_AGC_PARAM_A
,
695 IGP01E1000_PHY_AGC_PARAM_B
,
696 IGP01E1000_PHY_AGC_PARAM_C
,
697 IGP01E1000_PHY_AGC_PARAM_D
};
699 DEBUGFUNC("e1000_config_dsp_after_link_change_82541");
701 dev_spec
= (struct e1000_dev_spec_82541
*)hw
->dev_spec
;
704 ret_val
= hw
->mac
.ops
.get_link_up_info(hw
, &speed
, &duplex
);
706 DEBUGOUT("Error getting link speed and duplex\n");
710 if (speed
!= SPEED_1000
) {
711 ret_val
= E1000_SUCCESS
;
715 ret_val
= phy
->ops
.get_cable_length(hw
);
719 if ((dev_spec
->dsp_config
== e1000_dsp_config_enabled
) &&
720 phy
->min_cable_length
>= 50) {
722 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
723 ret_val
= phy
->ops
.read_reg(hw
,
729 phy_data
&= ~IGP01E1000_PHY_EDAC_MU_INDEX
;
731 ret_val
= phy
->ops
.write_reg(hw
,
737 dev_spec
->dsp_config
= e1000_dsp_config_activated
;
740 if ((dev_spec
->ffe_config
!= e1000_ffe_config_enabled
) ||
741 (phy
->min_cable_length
>= 50)) {
742 ret_val
= E1000_SUCCESS
;
746 /* clear previous idle error counts */
747 ret_val
= phy
->ops
.read_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
751 for (i
= 0; i
< ffe_idle_err_timeout
; i
++) {
753 ret_val
= phy
->ops
.read_reg(hw
,
759 idle_errs
+= (phy_data
& SR_1000T_IDLE_ERROR_CNT
);
760 if (idle_errs
> SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT
) {
761 dev_spec
->ffe_config
= e1000_ffe_config_active
;
763 ret_val
= phy
->ops
.write_reg(hw
,
764 IGP01E1000_PHY_DSP_FFE
,
765 IGP01E1000_PHY_DSP_FFE_CM_CP
);
772 ffe_idle_err_timeout
=
773 FFE_IDLE_ERR_COUNT_TIMEOUT_100
;
776 if (dev_spec
->dsp_config
== e1000_dsp_config_activated
) {
778 * Save off the current value of register 0x2F5B
779 * to be restored at the end of the routines.
781 ret_val
= phy
->ops
.read_reg(hw
,
787 /* Disable the PHY transmitter */
788 ret_val
= phy
->ops
.write_reg(hw
, 0x2F5B, 0x0003);
794 ret_val
= phy
->ops
.write_reg(hw
,
796 IGP01E1000_IEEE_FORCE_GIG
);
799 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
800 ret_val
= phy
->ops
.read_reg(hw
,
806 phy_data
&= ~IGP01E1000_PHY_EDAC_MU_INDEX
;
807 phy_data
|= IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS
;
809 ret_val
= phy
->ops
.write_reg(hw
,
816 ret_val
= phy
->ops
.write_reg(hw
,
818 IGP01E1000_IEEE_RESTART_AUTONEG
);
824 /* Now enable the transmitter */
825 ret_val
= phy
->ops
.write_reg(hw
,
831 dev_spec
->dsp_config
= e1000_dsp_config_enabled
;
834 if (dev_spec
->ffe_config
!= e1000_ffe_config_active
) {
835 ret_val
= E1000_SUCCESS
;
840 * Save off the current value of register 0x2F5B
841 * to be restored at the end of the routines.
843 ret_val
= phy
->ops
.read_reg(hw
, 0x2F5B, &phy_saved_data
);
847 /* Disable the PHY transmitter */
848 ret_val
= phy
->ops
.write_reg(hw
, 0x2F5B, 0x0003);
854 ret_val
= phy
->ops
.write_reg(hw
,
856 IGP01E1000_IEEE_FORCE_GIG
);
860 ret_val
= phy
->ops
.write_reg(hw
,
861 IGP01E1000_PHY_DSP_FFE
,
862 IGP01E1000_PHY_DSP_FFE_DEFAULT
);
866 ret_val
= phy
->ops
.write_reg(hw
,
868 IGP01E1000_IEEE_RESTART_AUTONEG
);
874 /* Now enable the transmitter */
875 ret_val
= phy
->ops
.write_reg(hw
, 0x2F5B, phy_saved_data
);
880 dev_spec
->ffe_config
= e1000_ffe_config_enabled
;
888 * e1000_get_cable_length_igp_82541 - Determine cable length for igp PHY
889 * @hw: pointer to the HW structure
891 * The automatic gain control (agc) normalizes the amplitude of the
892 * received signal, adjusting for the attenuation produced by the
893 * cable. By reading the AGC registers, which represent the
894 * combination of coarse and fine gain value, the value can be put
895 * into a lookup table to obtain the approximate cable length
896 * for each channel. This is a function pointer entry point called by the
899 static s32
e1000_get_cable_length_igp_82541(struct e1000_hw
*hw
)
901 struct e1000_phy_info
*phy
= &hw
->phy
;
902 s32 ret_val
= E1000_SUCCESS
;
904 u16 cur_agc_value
, agc_value
= 0;
905 u16 min_agc_value
= IGP01E1000_AGC_LENGTH_TABLE_SIZE
;
906 u16 agc_reg_array
[IGP01E1000_PHY_CHANNEL_NUM
] =
907 {IGP01E1000_PHY_AGC_A
,
908 IGP01E1000_PHY_AGC_B
,
909 IGP01E1000_PHY_AGC_C
,
910 IGP01E1000_PHY_AGC_D
};
912 DEBUGFUNC("e1000_get_cable_length_igp_82541");
914 /* Read the AGC registers for all channels */
915 for (i
= 0; i
< IGP01E1000_PHY_CHANNEL_NUM
; i
++) {
916 ret_val
= phy
->ops
.read_reg(hw
, agc_reg_array
[i
], &data
);
920 cur_agc_value
= data
>> IGP01E1000_AGC_LENGTH_SHIFT
;
922 /* Bounds checking */
923 if ((cur_agc_value
>= IGP01E1000_AGC_LENGTH_TABLE_SIZE
- 1) ||
924 (cur_agc_value
== 0)) {
925 ret_val
= -E1000_ERR_PHY
;
929 agc_value
+= cur_agc_value
;
931 if (min_agc_value
> cur_agc_value
)
932 min_agc_value
= cur_agc_value
;
935 /* Remove the minimal AGC result for length < 50m */
936 if (agc_value
< IGP01E1000_PHY_CHANNEL_NUM
* 50) {
937 agc_value
-= min_agc_value
;
938 /* Average the three remaining channels for the length. */
939 agc_value
/= (IGP01E1000_PHY_CHANNEL_NUM
- 1);
941 /* Average the channels for the length. */
942 agc_value
/= IGP01E1000_PHY_CHANNEL_NUM
;
945 phy
->min_cable_length
= (e1000_igp_cable_length_table
[agc_value
] >
946 IGP01E1000_AGC_RANGE
)
947 ? (e1000_igp_cable_length_table
[agc_value
] -
948 IGP01E1000_AGC_RANGE
)
950 phy
->max_cable_length
= e1000_igp_cable_length_table
[agc_value
] +
951 IGP01E1000_AGC_RANGE
;
953 phy
->cable_length
= (phy
->min_cable_length
+ phy
->max_cable_length
) / 2;
960 * e1000_set_d3_lplu_state_82541 - Sets low power link up state for D3
961 * @hw: pointer to the HW structure
962 * @active: boolean used to enable/disable lplu
964 * Success returns 0, Failure returns 1
966 * The low power link up (lplu) state is set to the power management level D3
967 * and SmartSpeed is disabled when active is true, else clear lplu for D3
968 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
969 * is used during Dx states where the power conservation is most important.
970 * During driver activity, SmartSpeed should be enabled so performance is
971 * maintained. This is a function pointer entry point called by the
974 static s32
e1000_set_d3_lplu_state_82541(struct e1000_hw
*hw
, bool active
)
976 struct e1000_phy_info
*phy
= &hw
->phy
;
980 DEBUGFUNC("e1000_set_d3_lplu_state_82541");
982 switch (hw
->mac
.type
) {
983 case e1000_82541_rev_2
:
984 case e1000_82547_rev_2
:
987 ret_val
= e1000_set_d3_lplu_state_generic(hw
, active
);
992 ret_val
= phy
->ops
.read_reg(hw
, IGP01E1000_GMII_FIFO
, &data
);
997 data
&= ~IGP01E1000_GMII_FLEX_SPD
;
998 ret_val
= phy
->ops
.write_reg(hw
, IGP01E1000_GMII_FIFO
, data
);
1003 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
1004 * during Dx states where the power conservation is most
1005 * important. During driver activity we should enable
1006 * SmartSpeed, so performance is maintained.
1008 if (phy
->smart_speed
== e1000_smart_speed_on
) {
1009 ret_val
= phy
->ops
.read_reg(hw
,
1010 IGP01E1000_PHY_PORT_CONFIG
,
1015 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
1016 ret_val
= phy
->ops
.write_reg(hw
,
1017 IGP01E1000_PHY_PORT_CONFIG
,
1021 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
1022 ret_val
= phy
->ops
.read_reg(hw
,
1023 IGP01E1000_PHY_PORT_CONFIG
,
1028 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1029 ret_val
= phy
->ops
.write_reg(hw
,
1030 IGP01E1000_PHY_PORT_CONFIG
,
1035 } else if ((phy
->autoneg_advertised
== E1000_ALL_SPEED_DUPLEX
) ||
1036 (phy
->autoneg_advertised
== E1000_ALL_NOT_GIG
) ||
1037 (phy
->autoneg_advertised
== E1000_ALL_10_SPEED
)) {
1038 data
|= IGP01E1000_GMII_FLEX_SPD
;
1039 ret_val
= phy
->ops
.write_reg(hw
, IGP01E1000_GMII_FIFO
, data
);
1043 /* When LPLU is enabled, we should disable SmartSpeed */
1044 ret_val
= phy
->ops
.read_reg(hw
,
1045 IGP01E1000_PHY_PORT_CONFIG
,
1050 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1051 ret_val
= phy
->ops
.write_reg(hw
,
1052 IGP01E1000_PHY_PORT_CONFIG
,
1061 * e1000_setup_led_82541 - Configures SW controllable LED
1062 * @hw: pointer to the HW structure
1064 * This prepares the SW controllable LED for use and saves the current state
1065 * of the LED so it can be later restored. This is a function pointer entry
1066 * point called by the api module.
1068 static s32
e1000_setup_led_82541(struct e1000_hw
*hw
)
1070 struct e1000_dev_spec_82541
*dev_spec
;
1073 DEBUGFUNC("e1000_setup_led_82541");
1075 dev_spec
= (struct e1000_dev_spec_82541
*)hw
->dev_spec
;
1077 ret_val
= hw
->phy
.ops
.read_reg(hw
,
1078 IGP01E1000_GMII_FIFO
,
1079 &dev_spec
->spd_default
);
1083 ret_val
= hw
->phy
.ops
.write_reg(hw
,
1084 IGP01E1000_GMII_FIFO
,
1085 (u16
)(dev_spec
->spd_default
&
1086 ~IGP01E1000_GMII_SPD
));
1090 E1000_WRITE_REG(hw
, E1000_LEDCTL
, hw
->mac
.ledctl_mode1
);
1097 * e1000_cleanup_led_82541 - Set LED config to default operation
1098 * @hw: pointer to the HW structure
1100 * Remove the current LED configuration and set the LED configuration
1101 * to the default value, saved from the EEPROM. This is a function pointer
1102 * entry point called by the api module.
1104 static s32
e1000_cleanup_led_82541(struct e1000_hw
*hw
)
1106 struct e1000_dev_spec_82541
*dev_spec
;
1109 DEBUGFUNC("e1000_cleanup_led_82541");
1111 dev_spec
= (struct e1000_dev_spec_82541
*)hw
->dev_spec
;
1113 ret_val
= hw
->phy
.ops
.write_reg(hw
,
1114 IGP01E1000_GMII_FIFO
,
1115 dev_spec
->spd_default
);
1119 E1000_WRITE_REG(hw
, E1000_LEDCTL
, hw
->mac
.ledctl_default
);
1126 * e1000_phy_init_script_82541 - Initialize GbE PHY
1127 * @hw: pointer to the HW structure
1129 * Initializes the IGP PHY.
1131 static s32
e1000_phy_init_script_82541(struct e1000_hw
*hw
)
1133 struct e1000_dev_spec_82541
*dev_spec
;
1137 DEBUGFUNC("e1000_phy_init_script_82541");
1139 dev_spec
= (struct e1000_dev_spec_82541
*)hw
->dev_spec
;
1141 if (!dev_spec
->phy_init_script
) {
1142 ret_val
= E1000_SUCCESS
;
1146 /* Delay after phy reset to enable NVM configuration to load */
1150 * Save off the current value of register 0x2F5B to be restored at
1151 * the end of this routine.
1153 ret_val
= hw
->phy
.ops
.read_reg(hw
, 0x2F5B, &phy_saved_data
);
1155 /* Disabled the PHY transmitter */
1156 hw
->phy
.ops
.write_reg(hw
, 0x2F5B, 0x0003);
1160 hw
->phy
.ops
.write_reg(hw
, 0x0000, 0x0140);
1164 switch (hw
->mac
.type
) {
1167 hw
->phy
.ops
.write_reg(hw
, 0x1F95, 0x0001);
1169 hw
->phy
.ops
.write_reg(hw
, 0x1F71, 0xBD21);
1171 hw
->phy
.ops
.write_reg(hw
, 0x1F79, 0x0018);
1173 hw
->phy
.ops
.write_reg(hw
, 0x1F30, 0x1600);
1175 hw
->phy
.ops
.write_reg(hw
, 0x1F31, 0x0014);
1177 hw
->phy
.ops
.write_reg(hw
, 0x1F32, 0x161C);
1179 hw
->phy
.ops
.write_reg(hw
, 0x1F94, 0x0003);
1181 hw
->phy
.ops
.write_reg(hw
, 0x1F96, 0x003F);
1183 hw
->phy
.ops
.write_reg(hw
, 0x2010, 0x0008);
1185 case e1000_82541_rev_2
:
1186 case e1000_82547_rev_2
:
1187 hw
->phy
.ops
.write_reg(hw
, 0x1F73, 0x0099);
1193 hw
->phy
.ops
.write_reg(hw
, 0x0000, 0x3300);
1197 /* Now enable the transmitter */
1198 hw
->phy
.ops
.write_reg(hw
, 0x2F5B, phy_saved_data
);
1200 if (hw
->mac
.type
== e1000_82547
) {
1201 u16 fused
, fine
, coarse
;
1203 /* Move to analog registers page */
1204 hw
->phy
.ops
.read_reg(hw
,
1205 IGP01E1000_ANALOG_SPARE_FUSE_STATUS
,
1208 if (!(fused
& IGP01E1000_ANALOG_SPARE_FUSE_ENABLED
)) {
1209 hw
->phy
.ops
.read_reg(hw
,
1210 IGP01E1000_ANALOG_FUSE_STATUS
,
1213 fine
= fused
& IGP01E1000_ANALOG_FUSE_FINE_MASK
;
1214 coarse
= fused
& IGP01E1000_ANALOG_FUSE_COARSE_MASK
;
1216 if (coarse
> IGP01E1000_ANALOG_FUSE_COARSE_THRESH
) {
1217 coarse
-= IGP01E1000_ANALOG_FUSE_COARSE_10
;
1218 fine
-= IGP01E1000_ANALOG_FUSE_FINE_1
;
1219 } else if (coarse
==
1220 IGP01E1000_ANALOG_FUSE_COARSE_THRESH
)
1221 fine
-= IGP01E1000_ANALOG_FUSE_FINE_10
;
1223 fused
= (fused
& IGP01E1000_ANALOG_FUSE_POLY_MASK
) |
1224 (fine
& IGP01E1000_ANALOG_FUSE_FINE_MASK
) |
1225 (coarse
& IGP01E1000_ANALOG_FUSE_COARSE_MASK
);
1227 hw
->phy
.ops
.write_reg(hw
,
1228 IGP01E1000_ANALOG_FUSE_CONTROL
,
1230 hw
->phy
.ops
.write_reg(hw
,
1231 IGP01E1000_ANALOG_FUSE_BYPASS
,
1232 IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL
);
1241 * e1000_init_script_state_82541 - Enable/Disable PHY init script
1242 * @hw: pointer to the HW structure
1243 * @state: boolean value used to enable/disable PHY init script
1245 * Allows the driver to enable/disable the PHY init script, if the PHY is an
1246 * IGP PHY. This is a function pointer entry point called by the api module.
1248 void e1000_init_script_state_82541(struct e1000_hw
*hw
, bool state
)
1250 struct e1000_dev_spec_82541
*dev_spec
;
1252 DEBUGFUNC("e1000_init_script_state_82541");
1254 if (hw
->phy
.type
!= e1000_phy_igp
) {
1255 DEBUGOUT("Initialization script not necessary.\n");
1259 dev_spec
= (struct e1000_dev_spec_82541
*)hw
->dev_spec
;
1262 DEBUGOUT("dev_spec pointer is set to NULL.\n");
1266 dev_spec
->phy_init_script
= state
;
1273 * e1000_power_down_phy_copper_82541 - Remove link in case of PHY power down
1274 * @hw: pointer to the HW structure
1276 * In the case of a PHY power down to save power, or to turn off link during a
1277 * driver unload, or wake on lan is not enabled, remove the link.
1279 static void e1000_power_down_phy_copper_82541(struct e1000_hw
*hw
)
1281 /* If the management interface is not enabled, then power down */
1282 if (!(E1000_READ_REG(hw
, E1000_MANC
) & E1000_MANC_SMBUS_EN
))
1283 e1000_power_down_phy_copper(hw
);
1289 * e1000_clear_hw_cntrs_82541 - Clear device specific hardware counters
1290 * @hw: pointer to the HW structure
1292 * Clears the hardware counters by reading the counter registers.
1294 static void e1000_clear_hw_cntrs_82541(struct e1000_hw
*hw
)
1298 DEBUGFUNC("e1000_clear_hw_cntrs_82541");
1300 e1000_clear_hw_cntrs_base_generic(hw
);
1302 temp
= E1000_READ_REG(hw
, E1000_PRC64
);
1303 temp
= E1000_READ_REG(hw
, E1000_PRC127
);
1304 temp
= E1000_READ_REG(hw
, E1000_PRC255
);
1305 temp
= E1000_READ_REG(hw
, E1000_PRC511
);
1306 temp
= E1000_READ_REG(hw
, E1000_PRC1023
);
1307 temp
= E1000_READ_REG(hw
, E1000_PRC1522
);
1308 temp
= E1000_READ_REG(hw
, E1000_PTC64
);
1309 temp
= E1000_READ_REG(hw
, E1000_PTC127
);
1310 temp
= E1000_READ_REG(hw
, E1000_PTC255
);
1311 temp
= E1000_READ_REG(hw
, E1000_PTC511
);
1312 temp
= E1000_READ_REG(hw
, E1000_PTC1023
);
1313 temp
= E1000_READ_REG(hw
, E1000_PTC1522
);
1315 temp
= E1000_READ_REG(hw
, E1000_ALGNERRC
);
1316 temp
= E1000_READ_REG(hw
, E1000_RXERRC
);
1317 temp
= E1000_READ_REG(hw
, E1000_TNCRS
);
1318 temp
= E1000_READ_REG(hw
, E1000_CEXTERR
);
1319 temp
= E1000_READ_REG(hw
, E1000_TSCTC
);
1320 temp
= E1000_READ_REG(hw
, E1000_TSCTFC
);
1322 temp
= E1000_READ_REG(hw
, E1000_MGTPRC
);
1323 temp
= E1000_READ_REG(hw
, E1000_MGTPDC
);
1324 temp
= E1000_READ_REG(hw
, E1000_MGTPTC
);