/******************************************************************************
Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
3. Neither the name of the Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
/*$FreeBSD$*/
/*
* 82541EI Gigabit Ethernet Controller
* 82541ER Gigabit Ethernet Controller
* 82541GI Gigabit Ethernet Controller
* 82541PI Gigabit Ethernet Controller
* 82547EI Gigabit Ethernet Controller
* 82547GI Gigabit Ethernet Controller
*/
#include "e1000_api.h"
bool active);
bool link_up);
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10,
10, 10, 20, 20, 20, 20, 20, 25, 25, 25, 25, 25, 25, 25, 30, 30, 30, 30,
40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 60, 60,
60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80,
80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 120, 120,
120, 120, 120, 120, 120, 120, 120, 120};
#define IGP01E1000_AGC_LENGTH_TABLE_SIZE \
(sizeof(e1000_igp_cable_length_table) / \
sizeof(e1000_igp_cable_length_table[0]))
/**
* e1000_init_phy_params_82541 - Init PHY func ptrs.
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_phy_params_82541");
/* Function Pointers */
if (ret_val)
goto out;
/* Verify phy id */
ret_val = -E1000_ERR_PHY;
goto out;
}
out:
return ret_val;
}
/**
* e1000_init_nvm_params_82541 - Init NVM func ptrs.
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_nvm_params_82541");
break;
eecd &= ~E1000_EECD_ADDR_BITS;
break;
eecd |= E1000_EECD_SIZE;
break;
eecd &= ~E1000_EECD_SIZE;
break;
default:
break;
}
/* Function Pointers */
/*
* nvm->word_size must be discovered after the pointers
* are set so we can verify the size from the nvm image
* itself. Temporarily set it to a dummy value so the
* read will work.
*/
if (ret_val)
goto out;
/*
* if size != 0, it can be added to a constant and become
* the left-shift value to set the word_size. Otherwise,
* word_size stays at 64.
*/
if (size) {
}
} else {
/* Function Pointers */
}
out:
return ret_val;
}
/**
* e1000_init_mac_params_82541 - Init MAC func ptrs.
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_mac_params_82541");
/* Set media type */
/* Set mta register count */
/* Set rar entry count */
/* Set if part includes ASF firmware */
/* Function Pointers */
/* function id */
/* reset */
/* hw initialization */
/* link setup */
/* physical interface link setup */
/* check for link */
/* link info */
/* multicast address update */
/* writing VFTA */
/* clearing VFTA */
/* read mac address */
/* ID LED init */
/* setup LED */
/* cleanup LED */
/* clear hardware counters */
return E1000_SUCCESS;
}
/**
* e1000_init_function_pointers_82541 - Init func ptrs.
* @hw: pointer to the HW structure
*
* Called to initialize all function pointers and parameters.
**/
{
DEBUGFUNC("e1000_init_function_pointers_82541");
}
/**
* e1000_reset_hw_82541 - Reset hardware
* @hw: pointer to the HW structure
*
* This resets the hardware into a known state.
**/
{
DEBUGFUNC("e1000_reset_hw_82541");
DEBUGOUT("Masking off all interrupts\n");
/*
* Delay to allow any outstanding PCI transactions to complete
* before resetting the device.
*/
msec_delay(10);
/* Must reset the Phy before resetting the MAC */
msec_delay(5);
}
DEBUGOUT("Issuing a global reset to 82541/82547 MAC\n");
case e1000_82541:
case e1000_82541_rev_2:
/*
* These controllers can't ack the 64-bit write when
* issuing the reset, so we use IO-mapping as a
* workaround to issue the reset.
*/
break;
default:
break;
}
/* Wait for NVM reload */
msec_delay(20);
/* Disable HW ARPs on ASF enabled adapters */
manc &= ~E1000_MANC_ARP_EN;
/* Configure activity LED after Phy reset */
}
/* Once again, mask the interrupts */
DEBUGOUT("Masking off all interrupts\n");
/* Clear any pending interrupt events. */
return E1000_SUCCESS;
}
/**
* e1000_init_hw_82541 - Initialize hardware
* @hw: pointer to the HW structure
*
* This inits the hardware readying it for operation.
**/
{
DEBUGFUNC("e1000_init_hw_82541");
/* Initialize identification LED */
if (ret_val) {
DEBUGOUT("Error initializing identification LED\n");
/* This is not fatal and we should not stop init due to this */
}
/* Storing the Speed Power Down value for later use */
&dev_spec->spd_default);
if (ret_val)
goto out;
/* Disabling VLAN filtering */
DEBUGOUT("Initializing the IEEE VLAN\n");
/* Setup the receive address. */
/* Zero out the Multicast HASH table */
DEBUGOUT("Zeroing the MTA\n");
for (i = 0; i < mac->mta_reg_count; i++) {
/*
* Avoid back to back register writes by adding the register
* read (flush). This is to protect against some strange
* bridge configurations that may issue Memory Write Block
* (MWB) to our register space.
*/
}
/* Setup link and flow control */
/*
* Clear all of the statistics registers (clear on read). It is
* important that we do this after we have tried to establish link
* because the symbol error count will increment wildly if there
* is no link.
*/
out:
return ret_val;
}
/**
* e1000_get_link_up_info_82541 - Report speed and duplex
* @hw: pointer to the HW structure
* @speed: pointer to speed buffer
* @duplex: pointer to duplex buffer
*
* Retrieve the current speed and duplex configuration.
**/
{
DEBUGFUNC("e1000_get_link_up_info_82541");
if (ret_val)
goto out;
if (!phy->speed_downgraded)
goto out;
/*
* IGP01 PHY may advertise full duplex operation after speed
* downgrade even if it is operating at half duplex.
* Here we set the duplex settings to match the duplex in the
* link partner's capabilities.
*/
if (ret_val)
goto out;
if (!(data & NWAY_ER_LP_NWAY_CAPS)) {
*duplex = HALF_DUPLEX;
} else {
if (ret_val)
goto out;
if (!(data & NWAY_LPAR_100TX_FD_CAPS))
*duplex = HALF_DUPLEX;
if (!(data & NWAY_LPAR_10T_FD_CAPS))
*duplex = HALF_DUPLEX;
}
}
out:
return ret_val;
}
/**
* e1000_phy_hw_reset_82541 - PHY hardware reset
* @hw: pointer to the HW structure
*
* Verify the reset block is not blocking us from resetting. Acquire
* bit in the PHY. Wait the appropriate delay time for the device to
* reset and release the semaphore (if necessary).
**/
{
DEBUGFUNC("e1000_phy_hw_reset_82541");
if (ret_val)
goto out;
/* Configure activity LED after PHY reset */
}
out:
return ret_val;
}
/**
* e1000_setup_copper_link_82541 - Configure copper link settings
* @hw: pointer to the HW structure
*
* Calls the appropriate function to configure the link for auto-neg or forced
* speed and duplex. Then we check for link, once link is established calls
* to configure collision distance and flow control are called. If link is
* not established, we return -E1000_ERR_PHY (-2).
**/
{
DEBUGFUNC("e1000_setup_copper_link_82541");
ctrl |= E1000_CTRL_SLU;
/* Earlier revs of the IGP phy require us to force MDI. */
} else {
}
if (ret_val)
goto out;
}
/* Configure activity LED after Phy reset */
out:
return ret_val;
}
/**
* @hw: pointer to the HW structure
*
* This checks the link condition of the adapter and stores the
* results in the hw->mac structure.
**/
{
bool link;
DEBUGFUNC("e1000_check_for_link_82541");
/*
* We only want to go out to the PHY registers to see if Auto-Neg
* get_link_status flag is set upon receiving a Link Status
* Change or Rx Sequence Error interrupt.
*/
if (!mac->get_link_status) {
goto out;
}
/*
* First we want to see if the MII Status Register reports
* of the PHY.
*/
if (ret_val)
goto out;
if (!link) {
goto out; /* No link detected */
}
/*
* Check if there was DownShift, must be checked
* immediately after link-up
*/
/*
* we have already determined whether we have link or not.
*/
goto out;
}
/*
* Auto-Neg is enabled. Auto Speed Detection takes care
* configure Collision Distance in the MAC.
*/
/*
* Configure Flow Control now that Auto-Neg has completed.
* First, we need to restore the desired flow control
* settings because we may have had to re-autoneg with a
* different link partner.
*/
if (ret_val)
DEBUGOUT("Error configuring flow control\n");
out:
return ret_val;
}
/**
* e1000_config_dsp_after_link_change_82541 - Config DSP after link
* @hw: pointer to the HW structure
* @link_up: boolean flag for link up status
*
* at any other case.
*
* 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
* gigabit link is achieved to improve link quality.
**/
bool link_up)
{
DEBUGFUNC("e1000_config_dsp_after_link_change_82541");
if (link_up) {
if (ret_val) {
DEBUGOUT("Error getting link speed and duplex\n");
goto out;
}
if (speed != SPEED_1000) {
goto out;
}
if (ret_val)
goto out;
for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
dsp_reg_array[i],
&phy_data);
if (ret_val)
goto out;
dsp_reg_array[i],
phy_data);
if (ret_val)
goto out;
}
}
goto out;
}
/* clear previous idle error counts */
if (ret_val)
goto out;
for (i = 0; i < ffe_idle_err_timeout; i++) {
usec_delay(1000);
&phy_data);
if (ret_val)
goto out;
if (ret_val)
goto out;
break;
}
if (idle_errs)
}
} else {
/*
* Save off the current value of register 0x2F5B
* to be restored at the end of the routines.
*/
if (ret_val)
goto out;
/* Disable the PHY transmitter */
if (ret_val)
goto out;
msec_delay_irq(20);
if (ret_val)
goto out;
for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
dsp_reg_array[i],
&phy_data);
if (ret_val)
goto out;
dsp_reg_array[i],
phy_data);
if (ret_val)
goto out;
}
if (ret_val)
goto out;
msec_delay_irq(20);
/* Now enable the transmitter */
if (ret_val)
goto out;
}
goto out;
}
/*
* Save off the current value of register 0x2F5B
* to be restored at the end of the routines.
*/
if (ret_val)
goto out;
/* Disable the PHY transmitter */
if (ret_val)
goto out;
msec_delay_irq(20);
if (ret_val)
goto out;
if (ret_val)
goto out;
if (ret_val)
goto out;
msec_delay_irq(20);
/* Now enable the transmitter */
if (ret_val)
goto out;
}
out:
return ret_val;
}
/**
* e1000_get_cable_length_igp_82541 - Determine cable length for igp PHY
* @hw: pointer to the HW structure
*
* The automatic gain control (agc) normalizes the amplitude of the
* received signal, adjusting for the attenuation produced by the
* cable. By reading the AGC registers, which represent the
* combination of coarse and fine gain value, the value can be put
* into a lookup table to obtain the approximate cable length
* for each channel.
**/
{
DEBUGFUNC("e1000_get_cable_length_igp_82541");
/* Read the AGC registers for all channels */
for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
if (ret_val)
goto out;
/* Bounds checking */
(cur_agc_value == 0)) {
ret_val = -E1000_ERR_PHY;
goto out;
}
if (min_agc_value > cur_agc_value)
}
/* Remove the minimal AGC result for length < 50m */
/* Average the three remaining channels for the length. */
} else {
/* Average the channels for the length. */
}
: 0;
out:
return ret_val;
}
/**
* e1000_set_d3_lplu_state_82541 - Sets low power link up state for D3
* @hw: pointer to the HW structure
*
* Success returns 0, Failure returns 1
*
* The low power link up (lplu) state is set to the power management level D3
* and SmartSpeed is disabled when active is TRUE, else clear lplu for D3
* and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
* is used during Dx states where the power conservation is most important.
* During driver activity, SmartSpeed should be enabled so performance is
* maintained.
**/
{
DEBUGFUNC("e1000_set_d3_lplu_state_82541");
case e1000_82541_rev_2:
case e1000_82547_rev_2:
break;
default:
goto out;
break;
}
if (ret_val)
goto out;
if (!active) {
if (ret_val)
goto out;
/*
* LPLU and SmartSpeed are mutually exclusive. LPLU is used
* during Dx states where the power conservation is most
* important. During driver activity we should enable
* SmartSpeed, so performance is maintained.
*/
&data);
if (ret_val)
goto out;
data);
if (ret_val)
goto out;
&data);
if (ret_val)
goto out;
data);
if (ret_val)
goto out;
}
if (ret_val)
goto out;
/* When LPLU is enabled, we should disable SmartSpeed */
&data);
if (ret_val)
goto out;
data);
}
out:
return ret_val;
}
/**
* e1000_setup_led_82541 - Configures SW controllable LED
* @hw: pointer to the HW structure
*
* This prepares the SW controllable LED for use and saves the current state
* of the LED so it can be later restored.
**/
{
DEBUGFUNC("e1000_setup_led_82541");
&dev_spec->spd_default);
if (ret_val)
goto out;
if (ret_val)
goto out;
out:
return ret_val;
}
/**
* e1000_cleanup_led_82541 - Set LED config to default operation
* @hw: pointer to the HW structure
*
* Remove the current LED configuration and set the LED configuration
* to the default value, saved from the EEPROM.
**/
{
DEBUGFUNC("e1000_cleanup_led_82541");
if (ret_val)
goto out;
out:
return ret_val;
}
/**
* e1000_phy_init_script_82541 - Initialize GbE PHY
* @hw: pointer to the HW structure
*
* Initializes the IGP PHY.
**/
{
DEBUGFUNC("e1000_phy_init_script_82541");
if (!dev_spec->phy_init_script) {
goto out;
}
/* Delay after phy reset to enable NVM configuration to load */
msec_delay(20);
/*
* Save off the current value of register 0x2F5B to be restored at
* the end of this routine.
*/
/* Disabled the PHY transmitter */
msec_delay(20);
msec_delay(5);
case e1000_82541:
case e1000_82547:
break;
case e1000_82541_rev_2:
case e1000_82547_rev_2:
break;
default:
break;
}
msec_delay(20);
/* Now enable the transmitter */
/* Move to analog registers page */
&fused);
if (!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
&fused);
} else if (coarse ==
fused);
}
}
out:
return ret_val;
}
/**
* @hw: pointer to the HW structure
*
* IGP PHY.
**/
{
DEBUGFUNC("e1000_init_script_state_82541");
DEBUGOUT("Initialization script not necessary.\n");
goto out;
}
out:
return;
}
/**
* e1000_power_down_phy_copper_82541 - Remove link in case of PHY power down
* @hw: pointer to the HW structure
*
* In the case of a PHY power down to save power, or to turn off link during a
* driver unload, or wake on lan is not enabled, remove the link.
**/
{
/* If the management interface is not enabled, then power down */
return;
}
/**
* e1000_clear_hw_cntrs_82541 - Clear device specific hardware counters
* @hw: pointer to the HW structure
*
* Clears the hardware counters by reading the counter registers.
**/
{
DEBUGFUNC("e1000_clear_hw_cntrs_82541");
}
/**
* e1000_read_mac_addr_82541 - Read device MAC address
* @hw: pointer to the HW structure
*
* Reads the device MAC address from the EEPROM and stores the value.
**/
{
DEBUGFUNC("e1000_read_mac_addr");
for (i = 0; i < ETH_ADDR_LEN; i += 2) {
offset = i >> 1;
if (ret_val) {
DEBUGOUT("NVM Read Error\n");
goto out;
}
}
for (i = 0; i < ETH_ADDR_LEN; i++)
out:
return ret_val;
}