/******************************************************************************
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$*/
/* 80003ES2LAN Gigabit Ethernet Controller (Copper)
* 80003ES2LAN Gigabit Ethernet Controller (Serdes)
*/
#include "e1000_api.h"
/* A table for the GG82563 cable length where the range is defined
* with a lower bound at "index" and the upper bound at
* "index + 5".
*/
0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
#define GG82563_CABLE_LENGTH_TABLE_SIZE \
(sizeof(e1000_gg82563_cable_length_table) / \
sizeof(e1000_gg82563_cable_length_table[0]))
/**
* e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_phy_params_80003es2lan");
return E1000_SUCCESS;
} else {
}
/* This can only be done after all function pointers are setup. */
/* Verify phy id */
return -E1000_ERR_PHY;
return ret_val;
}
/**
* e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_nvm_params_80003es2lan");
break;
break;
default:
break;
}
/* Added to a constant, "size" becomes the left-shift value
* for setting word_size.
*/
/* EEPROM access above 16k is unsupported */
if (size > 14)
size = 14;
/* Function Pointers */
return E1000_SUCCESS;
}
/**
* e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_mac_params_80003es2lan");
/* Set media type and media-dependent function pointers */
break;
default:
break;
}
/* Set mta register count */
/* Set rar entry count */
/* Set if part includes ASF firmware */
/* FWSM register */
/* ARC supported; valid only if manageability features are enabled. */
/* Adaptive IFS not supported */
/* Function pointers */
/* reset */
/* hw initialization */
/* link setup */
/* check management mode */
/* multicast address update */
/* writing VFTA */
/* clearing VFTA */
/* read mac address */
/* ID LED init */
/* blink LED */
/* setup LED */
/* cleanup LED */
/* clear hardware counters */
/* link info */
/* set lan id for port to determine which phy lock to use */
return E1000_SUCCESS;
}
/**
* e1000_init_function_pointers_80003es2lan - Init ESB2 func ptrs.
* @hw: pointer to the HW structure
*
* Called to initialize all function pointers and parameters.
**/
{
DEBUGFUNC("e1000_init_function_pointers_80003es2lan");
}
/**
* e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
* @hw: pointer to the HW structure
*
* A wrapper to acquire access rights to the correct PHY.
**/
{
DEBUGFUNC("e1000_acquire_phy_80003es2lan");
}
/**
* e1000_release_phy_80003es2lan - Release rights to access PHY
* @hw: pointer to the HW structure
*
* A wrapper to release access rights to the correct PHY.
**/
{
DEBUGFUNC("e1000_release_phy_80003es2lan");
}
/**
* e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
* @hw: pointer to the HW structure
*
* Acquire the semaphore to access the Kumeran interface.
*
**/
{
DEBUGFUNC("e1000_acquire_mac_csr_80003es2lan");
}
/**
* e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
* @hw: pointer to the HW structure
*
* Release the semaphore used to access the Kumeran interface
**/
{
DEBUGFUNC("e1000_release_mac_csr_80003es2lan");
}
/**
* e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
* @hw: pointer to the HW structure
*
* Acquire the semaphore to access the EEPROM.
**/
{
DEBUGFUNC("e1000_acquire_nvm_80003es2lan");
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
}
/**
* e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
* @hw: pointer to the HW structure
*
* Release the semaphore used to access the EEPROM.
**/
{
DEBUGFUNC("e1000_release_nvm_80003es2lan");
}
/**
* @hw: pointer to the HW structure
* @mask: specifies which semaphore to acquire
*
* will also specify which port we're acquiring the lock for.
**/
{
s32 i = 0;
DEBUGFUNC("e1000_acquire_swfw_sync_80003es2lan");
while (i < timeout) {
return -E1000_ERR_SWFW_SYNC;
break;
/* Firmware currently using resource (fwmask)
* or other software thread using resource (swmask)
*/
msec_delay_irq(5);
i++;
}
if (i == timeout) {
DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
return -E1000_ERR_SWFW_SYNC;
}
return E1000_SUCCESS;
}
/**
* @hw: pointer to the HW structure
* @mask: specifies which semaphore to acquire
*
* will also specify which port we're releasing the lock for.
**/
{
DEBUGFUNC("e1000_release_swfw_sync_80003es2lan");
; /* Empty */
}
/**
* e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
* @hw: pointer to the HW structure
* @offset: offset of the register to read
* @data: pointer to the data returned from the operation
*
* Read the GG82563 PHY register.
**/
{
DEBUGFUNC("e1000_read_phy_reg_gg82563_80003es2lan");
if (ret_val)
return ret_val;
/* Select Configuration Page */
} else {
/* Use Alternative Page Select register to access
* registers 30 and 31
*/
}
if (ret_val) {
return ret_val;
}
/* The "ready" bit in the MDIC register may be incorrectly set
* before the device has completed the "Page Select" MDI
* transaction. So we wait 200us after each MDI command...
*/
usec_delay(200);
/* ...and verify the command was successful. */
return -E1000_ERR_PHY;
}
usec_delay(200);
data);
usec_delay(200);
} else {
data);
}
return ret_val;
}
/**
* e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
* @hw: pointer to the HW structure
* @offset: offset of the register to read
* @data: value to write to the register
*
* Write to the GG82563 PHY register.
**/
{
DEBUGFUNC("e1000_write_phy_reg_gg82563_80003es2lan");
if (ret_val)
return ret_val;
/* Select Configuration Page */
} else {
/* Use Alternative Page Select register to access
* registers 30 and 31
*/
}
if (ret_val) {
return ret_val;
}
/* The "ready" bit in the MDIC register may be incorrectly set
* before the device has completed the "Page Select" MDI
* transaction. So we wait 200us after each MDI command...
*/
usec_delay(200);
/* ...and verify the command was successful. */
return -E1000_ERR_PHY;
}
usec_delay(200);
data);
usec_delay(200);
} else {
data);
}
return ret_val;
}
/**
* e1000_write_nvm_80003es2lan - Write to ESB2 NVM
* @hw: pointer to the HW structure
* @offset: offset of the register to read
* @words: number of words to write
* @data: buffer of data to write to the NVM
*
* Write "words" of data to the ESB2 NVM.
**/
{
DEBUGFUNC("e1000_write_nvm_80003es2lan");
}
/**
* e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
* @hw: pointer to the HW structure
*
* Wait a specific amount of time for manageability processes to complete.
* This is a function pointer entry point called by the phy module.
**/
{
DEBUGFUNC("e1000_get_cfg_done_80003es2lan");
while (timeout) {
break;
msec_delay(1);
timeout--;
}
if (!timeout) {
DEBUGOUT("MNG configuration cycle has not completed.\n");
return -E1000_ERR_RESET;
}
return E1000_SUCCESS;
}
/**
* e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
* @hw: pointer to the HW structure
*
* Force the speed and duplex settings onto the PHY. This is a
* function pointer entry point called by the phy module.
**/
{
bool link;
DEBUGFUNC("e1000_phy_force_speed_duplex_80003es2lan");
return E1000_SUCCESS;
/* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
* forced whenever speed and duplex are forced.
*/
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
/* Reset the phy to commit changes. */
phy_data |= MII_CR_RESET;
if (ret_val)
return ret_val;
usec_delay(1);
100000, &link);
if (ret_val)
return ret_val;
if (!link) {
/* We didn't get link.
* Reset the DSP and cross our fingers.
*/
if (ret_val)
return ret_val;
}
/* Try once more */
100000, &link);
if (ret_val)
return ret_val;
}
&phy_data);
if (ret_val)
return ret_val;
/* Resetting the phy means we need to verify the TX_CLK corresponds
* to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
*/
else
/* In addition, we must re-enable CRS on Tx for both half and full
* duplex.
*/
phy_data);
return ret_val;
}
/**
* e1000_get_cable_length_80003es2lan - Set approximate cable length
* @hw: pointer to the HW structure
*
* Find the approximate cable length as measured by the GG82563 PHY.
* This is a function pointer entry point called by the phy module.
**/
{
DEBUGFUNC("e1000_get_cable_length_80003es2lan");
return E1000_SUCCESS;
if (ret_val)
return ret_val;
return -E1000_ERR_PHY;
return E1000_SUCCESS;
}
/**
* e1000_get_link_up_info_80003es2lan - 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_80003es2lan");
duplex);
} else {
duplex);
}
return ret_val;
}
/**
* e1000_reset_hw_80003es2lan - Reset the ESB2 controller
* @hw: pointer to the HW structure
*
* Perform a global reset to the ESB2 controller.
**/
{
DEBUGFUNC("e1000_reset_hw_80003es2lan");
/* Prevent the PCI-E bus from sticking if there is no TLP connection
*/
if (ret_val)
DEBUGOUT("PCI-E Master disable polling has failed.\n");
DEBUGOUT("Masking off all interrupts\n");
msec_delay(10);
if (ret_val)
return ret_val;
DEBUGOUT("Issuing a global reset to MAC\n");
/* Disable IBIST slave mode (far-end loopback) */
if (!ret_val) {
if (ret_val)
DEBUGOUT("Error disabling far-end loopback\n");
} else
DEBUGOUT("Error disabling far-end loopback\n");
if (ret_val)
/* We don't want to continue accessing MAC registers. */
return ret_val;
/* Clear any pending interrupt events. */
return e1000_check_alt_mac_addr_generic(hw);
}
/**
* e1000_init_hw_80003es2lan - Initialize the ESB2 controller
* @hw: pointer to the HW structure
*
* Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
**/
{
u16 i;
DEBUGFUNC("e1000_init_hw_80003es2lan");
/* Initialize identification LED */
/* An error is not fatal and we should not stop init due to this */
if (ret_val)
DEBUGOUT("Error initializing identification LED\n");
/* 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++)
/* Setup link and flow control */
if (ret_val)
return ret_val;
/* Disable IBIST slave mode (far-end loopback) */
ret_val =
&kum_reg_data);
if (!ret_val) {
if (ret_val)
DEBUGOUT("Error disabling far-end loopback\n");
} else
DEBUGOUT("Error disabling far-end loopback\n");
/* Set the transmit descriptor write-back policy */
/* ...for both queues. */
/* Enable retransmit on late collisions */
/* Configure Gigabit Carry Extend Padding */
/* Configure Transmit Inter-Packet Gap */
reg_data &= ~0x00100000;
/* default to TRUE to enable the MDIC W/A */
ret_val =
if (!ret_val) {
if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
}
/* 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.
*/
return ret_val;
}
/**
* e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
* @hw: pointer to the HW structure
*
* Initializes required hardware-dependent bits needed for normal operation.
**/
{
DEBUGFUNC("e1000_initialize_hw_bits_80003es2lan");
/* Transmit Descriptor Control 0 */
/* Transmit Descriptor Control 1 */
/* Transmit Arbitration Control 0 */
/* Transmit Arbitration Control 1 */
else
/* Disable IPv6 extension header parsing because some malformed
* IPv6 headers can hang the Rx.
*/
return;
}
/**
* e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
* @hw: pointer to the HW structure
*
* Setup some GG82563 PHY registers for obtaining link
**/
{
DEBUGFUNC("e1000_copper_link_setup_gg82563_80003es2lan");
if (ret_val)
return ret_val;
/* Use 25MHz for both link down and 1000Base-T for Tx clock. */
if (ret_val)
return ret_val;
/* Options:
* 0 - Auto for all speeds
* 1 - MDI mode
* 2 - MDI-X mode
* 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
*/
if (ret_val)
return ret_val;
case 1:
break;
case 2:
break;
case 0:
default:
break;
}
/* Options:
* disable_polarity_correction = 0 (default)
* Automatic Correction for Reversed Cable Polarity
* 0 - Disabled
* 1 - Enabled
*/
if (ret_val)
return ret_val;
/* SW Reset the PHY so all changes take effect */
if (ret_val) {
DEBUGOUT("Error Resetting the PHY\n");
return ret_val;
}
/* Bypass Rx and Tx FIFO's */
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
/* Do not init these registers when the HW is in IAMT mode, since the
* firmware will have already initialized them. We only initialize
* them if the HW is not in IAMT mode.
*/
/* Enable Electrical Idle on the PHY */
data);
if (ret_val)
return ret_val;
&data);
if (ret_val)
return ret_val;
data);
if (ret_val)
return ret_val;
}
/* Workaround: Disable padding in Kumeran interface in the MAC
* and in the PHY to avoid CRC errors.
*/
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
return E1000_SUCCESS;
}
/**
* e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
* @hw: pointer to the HW structure
*
* Essentially a wrapper for setting up all things "copper" related.
* This is a function pointer entry point called by the mac module.
**/
{
DEBUGFUNC("e1000_setup_copper_link_80003es2lan");
ctrl |= E1000_CTRL_SLU;
/* Set the mac to wait the maximum time between each
* iteration and increase the max iterations when
* polling the phy; this fixes erroneous timeouts at 10Mbps.
*/
0xFFFF);
if (ret_val)
return ret_val;
®_data);
if (ret_val)
return ret_val;
reg_data |= 0x3F;
reg_data);
if (ret_val)
return ret_val;
ret_val =
®_data);
if (ret_val)
return ret_val;
ret_val =
reg_data);
if (ret_val)
return ret_val;
if (ret_val)
return ret_val;
return e1000_setup_copper_link_generic(hw);
}
/**
* e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
* @hw: pointer to the HW structure
* @duplex: current duplex setting
*
* Configure the KMRN interface by applying last minute quirks for
* 10/100 operation.
**/
{
DEBUGFUNC("e1000_configure_on_link_up");
&duplex);
if (ret_val)
return ret_val;
if (speed == SPEED_1000)
else
}
return ret_val;
}
/**
* e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
* @hw: pointer to the HW structure
* @duplex: current duplex setting
*
* Configure the KMRN interface by applying last minute quirks for
* 10/100 operation.
**/
{
u32 i = 0;
DEBUGFUNC("e1000_configure_kmrn_for_10_100");
ret_val =
reg_data);
if (ret_val)
return ret_val;
/* Configure Transmit Inter-Packet Gap */
tipg &= ~E1000_TIPG_IPGT_MASK;
do {
®_data);
if (ret_val)
return ret_val;
®_data2);
if (ret_val)
return ret_val;
i++;
if (duplex == HALF_DUPLEX)
else
}
/**
* e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
* @hw: pointer to the HW structure
*
* Configure the KMRN interface by applying last minute quirks for
* gigabit operation.
**/
{
u32 i = 0;
DEBUGFUNC("e1000_configure_kmrn_for_1000");
ret_val =
reg_data);
if (ret_val)
return ret_val;
/* Configure Transmit Inter-Packet Gap */
tipg &= ~E1000_TIPG_IPGT_MASK;
do {
®_data);
if (ret_val)
return ret_val;
®_data2);
if (ret_val)
return ret_val;
i++;
}
/**
* e1000_read_kmrn_reg_80003es2lan - Read kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquire semaphore, then read the PHY register at offset
* using the kumeran interface. The information retrieved is stored in data.
* Release the semaphore before exiting.
**/
{
DEBUGFUNC("e1000_read_kmrn_reg_80003es2lan");
if (ret_val)
return ret_val;
usec_delay(2);
return ret_val;
}
/**
* e1000_write_kmrn_reg_80003es2lan - Write kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquire semaphore, then write the data to PHY register
* at the offset using the kumeran interface. Release semaphore
* before exiting.
**/
{
DEBUGFUNC("e1000_write_kmrn_reg_80003es2lan");
if (ret_val)
return ret_val;
usec_delay(2);
return ret_val;
}
/**
* e1000_read_mac_addr_80003es2lan - Read device MAC address
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_read_mac_addr_80003es2lan");
/* If there's an alternate MAC address place it in RAR0
* so that it will override the Si installed default perm
* address.
*/
if (ret_val)
return ret_val;
return e1000_read_mac_addr_generic(hw);
}
/**
* e1000_power_down_phy_copper_80003es2lan - Remove link during 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_80003es2lan - 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_80003es2lan");
}