e1000_82571.c revision ab0c14ae5d796bc0dbf61efb71188e04a595a42d
/*
* This file is provided under a CDDLv1 license. When using or
* redistributing this file, you may do so under this license.
* In redistributing this file this license must be included
* and no other modification of this header file is permitted.
*
* CDDL LICENSE SUMMARY
*
* Copyright(c) 1999 - 2007 Intel Corporation. All rights reserved.
*
* The contents of this file are subject to the terms of Version
* 1.0 of the Common Development and Distribution License (the "License").
*
* You should have received a copy of the License with this software.
* You can obtain a copy of the License at
* See the License for the specific language governing permissions
* and limitations under the License.
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms of the CDDLv1.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* IntelVersion: HSD_2343720b_DragonLake3 v2007-06-14_HSD_2343720b_DragonLake3
*/
/*
* e1000_82571
* e1000_82572
* e1000_82573
*/
#include "e1000_api.h"
#include "e1000_82571.h"
struct e1000_dev_spec_82571 {
};
/*
* e1000_init_phy_params_82571 - Init PHY func ptrs.
* @hw: pointer to the HW structure
*
* This is a function pointer entry point called by the api module.
*/
static s32
{
DEBUGFUNC("e1000_init_phy_params_82571");
goto out;
}
case e1000_82571:
case e1000_82572:
break;
case e1000_82573:
break;
default:
ret_val = -E1000_ERR_PHY;
goto out;
}
/* This can only be done after all function pointers are setup. */
/* Verify phy id */
case e1000_82571:
case e1000_82572:
ret_val = -E1000_ERR_PHY;
goto out;
}
break;
case e1000_82573:
ret_val = -E1000_ERR_PHY;
goto out;
}
break;
default:
ret_val = -E1000_ERR_PHY;
goto out;
}
out:
return (ret_val);
}
/*
* e1000_init_nvm_params_82571 - Init NVM func ptrs.
* @hw: pointer to the HW structure
*
* This is a function pointer entry point called by the api module.
*/
static s32
{
DEBUGFUNC("e1000_init_nvm_params_82571");
break;
break;
default:
break;
}
case e1000_82573:
/*
* Autonomous Flash update bit must be cleared due
* to Flash update issue.
*/
eecd &= ~E1000_EECD_AUPDEN;
break;
}
/* Fall Through */
default:
/*
* Added to a constant, "size" becomes the left-shift value
* for setting word_size.
*/
break;
}
/* Function Pointers */
return (E1000_SUCCESS);
}
/*
* e1000_init_mac_params_82571 - Init MAC func ptrs.
* @hw: pointer to the HW structure
*
* This is a function pointer entry point called by the api module.
*/
static s32
{
DEBUGFUNC("e1000_init_mac_params_82571");
/* Set media type */
break;
break;
default:
break;
}
/* Set mta register count */
/* Set rar entry count */
/* Set if part includes ASF firmware */
/* Set if manageability features are enabled. */
/* Function pointers */
/* reset */
/* hw initialization */
/* link setup */
/* physical interface link setup */
/* check for link */
switch (hw->media_type) {
case e1000_media_type_copper:
break;
case e1000_media_type_fiber:
break;
break;
default:
goto out;
}
/* check management mode */
/* multicast address update */
/* writing VFTA */
/* clearing VFTA */
/* setting MTA */
/* blink LED */
/* setup LED */
/* cleanup LED */
/* remove device */
/* clear hardware counters */
/* link info */
/* Device-specific structure allocation */
out:
return (ret_val);
}
/*
* e1000_init_function_pointers_82571 - Init func ptrs.
* @hw: pointer to the HW structure
*
* The only function explicitly called by the api module to initialize
* all function pointers and parameters.
*/
void
{
DEBUGFUNC("e1000_init_function_pointers_82571");
}
/*
* e1000_get_phy_id_82571 - Retrieve the PHY ID and revision
* @hw: pointer to the HW structure
*
* Reads the PHY registers and stores the PHY ID and possibly the PHY
* revision in the hardware structure.
*/
static s32
{
DEBUGFUNC("e1000_get_phy_id_82571");
case e1000_82571:
case e1000_82572:
/*
* The 82571 firmware may still be configuring the PHY.
* In this case, we cannot access the PHY until the
* configuration is done. So we explicitly set the
* PHY ID.
*/
break;
case e1000_82573:
break;
default:
ret_val = -E1000_ERR_PHY;
break;
}
return (ret_val);
}
/*
* e1000_get_hw_semaphore_82571 - Acquire hardware semaphore
* @hw: pointer to the HW structure
*
* Acquire the HW semaphore to access the PHY or NVM
*/
{
s32 i = 0;
DEBUGFUNC("e1000_get_hw_semaphore_82571");
/* Get the FW semaphore. */
for (i = 0; i < timeout; i++) {
/* Semaphore acquired if bit latched */
break;
usec_delay(50);
}
if (i == timeout) {
/* Release semaphores */
DEBUGOUT("Driver can't access the NVM\n");
ret_val = -E1000_ERR_NVM;
goto out;
}
out:
return (ret_val);
}
/*
* e1000_put_hw_semaphore_82571 - Release hardware semaphore
* @hw: pointer to the HW structure
*
* Release hardware semaphore used to access the PHY or NVM
*/
void
{
DEBUGFUNC("e1000_put_hw_semaphore_82571");
swsm &= ~E1000_SWSM_SWESMBI;
}
/*
* e1000_acquire_nvm_82571 - Request for access to the EEPROM
* @hw: pointer to the HW structure
*
* To gain access to the EEPROM, first we must obtain a hardware semaphore.
* Then for non-82573 hardware, set the EEPROM access request bit and wait
* for EEPROM access grant bit. If the access grant bit is not set, release
* hardware semaphore.
*/
static s32
{
DEBUGFUNC("e1000_acquire_nvm_82571");
if (ret_val)
goto out;
if (ret_val)
out:
return (ret_val);
}
/*
* e1000_release_nvm_82571 - Release exclusive access to EEPROM
* @hw: pointer to the HW structure
*
* Stop any current commands to the EEPROM and clear the EEPROM request bit.
*/
static void
{
DEBUGFUNC("e1000_release_nvm_82571");
}
/*
* e1000_write_nvm_82571 - Write to EEPROM using appropriate interface
* @hw: pointer to the HW structure
* @offset: offset within the EEPROM to be written to
* @words: number of words to write
* @data: 16 bit word(s) to be written to the EEPROM
*
* For non-82573 silicon, write data to EEPROM at offset using SPI interface.
*
* If e1000_update_nvm_checksum is not called after this function, the
* EEPROM will most likley contain an invalid checksum.
*/
static s32
{
DEBUGFUNC("e1000_write_nvm_82571");
case e1000_82573:
break;
case e1000_82571:
case e1000_82572:
break;
default:
ret_val = -E1000_ERR_NVM;
break;
}
return (ret_val);
}
/*
* e1000_update_nvm_checksum_82571 - Update EEPROM checksum
* @hw: pointer to the HW structure
*
* up to the checksum. Then calculates the EEPROM checksum and writes the
* value to the EEPROM.
*/
static s32
{
u16 i;
DEBUGFUNC("e1000_update_nvm_checksum_82571");
if (ret_val)
goto out;
/*
* If our nvm is an EEPROM, then we're done
* otherwise, commit the checksum to the flash NVM.
*/
goto out;
/* Check for pending operations. */
for (i = 0; i < E1000_FLASH_UPDATES; i++) {
msec_delay(1);
break;
}
if (i == E1000_FLASH_UPDATES) {
ret_val = -E1000_ERR_NVM;
goto out;
}
/* Reset the firmware if using STM opcode. */
/*
* The enabling of and the actual reset must be done
* in two write cycles.
*/
}
/* Commit the write to flash */
for (i = 0; i < E1000_FLASH_UPDATES; i++) {
msec_delay(1);
break;
}
if (i == E1000_FLASH_UPDATES) {
ret_val = -E1000_ERR_NVM;
goto out;
}
out:
return (ret_val);
}
/*
* e1000_validate_nvm_checksum_82571 - Validate EEPROM checksum
* @hw: pointer to the HW structure
*
* and then verifies that the sum of the EEPROM is equal to 0xBABA.
*/
static s32
{
DEBUGFUNC("e1000_validate_nvm_checksum_82571");
return (e1000_validate_nvm_checksum_generic(hw));
}
/*
* e1000_write_nvm_eewr_82571 - Write to EEPROM for 82573 silicon
* @hw: pointer to the HW structure
* @offset: offset within the EEPROM to be written to
* @words: number of words to write
* @data: 16 bit word(s) to be written to the EEPROM
*
* After checking for invalid values, poll the EEPROM to ensure the previous
* command has completed before trying to write the next word. After write
* poll for completion.
*
* If e1000_update_nvm_checksum is not called after this function, the
* EEPROM will most likley contain an invalid checksum.
*/
static s32
{
DEBUGFUNC("e1000_write_nvm_eewr_82571");
/*
* A check for invalid values: offset too large, too many words,
* and not enough words.
*/
(words == 0)) {
DEBUGOUT("nvm parameter(s) out of bounds\n");
ret_val = -E1000_ERR_NVM;
goto out;
}
for (i = 0; i < words; i++) {
((offset + i) << E1000_NVM_RW_ADDR_SHIFT) |
if (ret_val)
break;
if (ret_val)
break;
}
out:
return (ret_val);
}
/*
* e1000_get_cfg_done_82571 - Poll for configuration done
* @hw: pointer to the HW structure
*
* Reads the management control register for the config done bit to be set.
*/
static s32
{
DEBUGFUNC("e1000_get_cfg_done_82571");
while (timeout) {
break;
msec_delay(1);
timeout--;
}
if (!timeout) {
DEBUGOUT("MNG configuration cycle has not completed.\n");
goto out;
}
out:
return (ret_val);
}
/*
* e1000_set_d0_lplu_state_82571 - Set Low Power Linkup D0 state
* @hw: pointer to the HW structure
* @active: TRUE to enable LPLU, FALSE to disable
*
* Sets the LPLU D0 state according to the active flag. When activating LPLU
* this function also disables smart speed and vice versa. LPLU will not be
* activated unless the device autonegotiation advertisement meets standards
* of either 10 or 10/100 or 10/100/1000 at all duplexes. This is a function
* pointer entry point only called by PHY setup routines.
*/
static s32
{
DEBUGFUNC("e1000_set_d0_lplu_state_82571");
if (ret_val)
goto out;
if (active) {
data);
if (ret_val)
goto out;
/* When LPLU is enabled, we should disable SmartSpeed */
&data);
data);
if (ret_val)
goto out;
} else {
data);
/*
* 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;
}
}
out:
return (ret_val);
}
/*
* e1000_reset_hw_82571 - Reset hardware
* @hw: pointer to the HW structure
*
* This resets the hardware into a known state. This is a
* function pointer entry point called by the api module.
*/
static s32
{
u16 i = 0;
DEBUGFUNC("e1000_reset_hw_82571");
/*
* 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);
/*
* Must acquire the MDIO ownership before MAC reset.
* Ownership defaults to firmware after a reset.
*/
do {
break;
msec_delay(2);
i++;
} while (i < MDIO_OWNERSHIP_TIMEOUT);
}
DEBUGOUT("Issuing a global reset to MAC\n");
usec_delay(10);
}
if (ret_val)
/* We don't want to continue accessing MAC registers. */
goto out;
/*
* Phy configuration from NVM just starts after EECD_AUTO_RD is set.
* Need to wait for Phy configuration completion before accessing
* NVM and Phy.
*/
msec_delay(25);
/* Clear any pending interrupt events. */
out:
return (ret_val);
}
/*
* e1000_init_hw_82571 - Initialize hardware
* @hw: pointer to the HW structure
*
* This inits the hardware readying it for operation.
*/
static s32
{
DEBUGFUNC("e1000_init_hw_82571");
/* Initialize identification LED */
if (ret_val) {
DEBUGOUT("Error initializing identification LED\n");
goto out;
}
/* Disabling VLAN filtering */
DEBUGOUT("Initializing the IEEE VLAN\n");
/* Setup the receive address. */
/*
* If, however, a locally administered address was assigned to the
* 82571, we must reserve a RAR for it to work around an issue where
* resetting one port will reload the MAC on the other port.
*/
if (e1000_get_laa_state_82571(hw))
rar_count--;
/* 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 */
/* Set the transmit descriptor write-back policy */
/* ...for both queues. */
} else {
}
/*
* 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_initialize_hw_bits_82571 - Initialize hardware-dependent bits
* @hw: pointer to the HW structure
*
* Initializes required hardware-dependent bits needed for normal operation.
*/
static void
{
DEBUGFUNC("e1000_initialize_hw_bits_82571");
return;
/* Transmit Descriptor Control 0 */
/* Transmit Descriptor Control 1 */
/* Transmit Arbitration Control 0 */
case e1000_82571:
case e1000_82572:
break;
default:
break;
}
/* Transmit Arbitration Control 1 */
case e1000_82571:
case e1000_82572:
else
break;
default:
break;
}
/* Device Control */
}
/* Extended Device Control */
}
}
/*
* e1000_clear_vfta_82571 - Clear VLAN filter table
* @hw: pointer to the HW structure
*
* Clears the register array which contains the VLAN filter table by
* setting all the values to 0.
*/
static void
{
u32 vfta_value = 0;
u32 vfta_offset = 0;
u32 vfta_bit_in_reg = 0;
DEBUGFUNC("e1000_clear_vfta_82571");
/*
* The VFTA is a 4096b bit-field, each identifying
* a single VLAN ID. The following operations
* determine which 32b entry (i.e. offset) into the
* array we want to set the VLAN ID (i.e. bit) of
* the manageability unit.
*/
}
}
/*
* If the offset we want to clear is the same offset of the
* manageability VLAN ID, then clear all bits except that of
* the manageability unit.
*/
}
}
/*
* e1000_mc_addr_list_update_82571 - Update Multicast addresses
* @hw: pointer to the HW structure
* @mc_addr_list: array of multicast addresses to program
* @mc_addr_count: number of multicast addresses to program
* @rar_used_count: the first RAR register free to program
* @rar_count: total number of supported Receive Address Registers
*
* Updates the Receive Address Registers and Multicast Table Array.
* The caller must have a packed mc_addr_list of multicast addresses.
* The parameter rar_count will usually be hw->mac.rar_entry_count
* unless there are workarounds that change this.
*/
static void
{
DEBUGFUNC("e1000_mc_addr_list_update_82571");
if (e1000_get_laa_state_82571(hw))
rar_count--;
}
/*
* e1000_setup_link_82571 - Setup flow control and link settings
* @hw: pointer to the HW structure
*
* Determines which flow control settings to use, then configures flow
* control. Calls the appropriate media-specific link configuration
* function. Assuming the adapter has a valid link partner, a valid link
* should be established. Assumes the hardware has previously been reset
* and the transmitter and receiver are not enabled.
*/
static s32
{
DEBUGFUNC("e1000_setup_link_82571");
/*
* 82573 does not have a word in the NVM to determine
* the default flow control setting, so we explicitly
* set it to full.
*/
return (e1000_setup_link_generic(hw));
}
/*
* e1000_setup_copper_link_82571 - Configure copper link settings
* @hw: pointer to the HW structure
*
* Configures 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.
*/
static s32
{
DEBUGFUNC("e1000_setup_copper_link_82571");
ctrl |= E1000_CTRL_SLU;
case e1000_phy_m88:
break;
case e1000_phy_igp_2:
/* Setup activity LED */
break;
default:
ret_val = -E1000_ERR_PHY;
break;
}
if (ret_val)
goto out;
out:
return (ret_val);
}
/*
* @hw: pointer to the HW structure
*
* Configures collision distance and flow control for fiber and serdes links.
* Upon successful setup, poll for link.
*/
static s32
{
DEBUGFUNC("e1000_setup_fiber_serdes_link_82571");
case e1000_82571:
case e1000_82572:
/*
* If SerDes loopback mode is entered, there is no form
* of reset to take the adapter out of that mode. So we
* have to explicitly take the adapter out of loopback
* mode. This prevents drivers from twidling their thumbs
* if another tool failed to take it out of loopback mode.
*/
break;
default:
break;
}
return (e1000_setup_fiber_serdes_link_generic(hw));
}
/*
* e1000_valid_led_default_82571 - Verify a valid default LED config
* @hw: pointer to the HW structure
* @data: pointer to the NVM (EEPROM)
*
* Read the EEPROM for the current default LED configuration. If the
* LED configuration is not valid, set to a valid LED configuration.
*/
static s32
{
DEBUGFUNC("e1000_valid_led_default_82571");
if (ret_val) {
DEBUGOUT("NVM Read Error\n");
goto out;
}
*data == ID_LED_RESERVED_F746)
else if (*data == ID_LED_RESERVED_0000 ||
*data == ID_LED_RESERVED_FFFF)
*data = ID_LED_DEFAULT;
out:
return (ret_val);
}
/*
* e1000_get_laa_state_82571 - Get locally administered address state
* @hw: pointer to the HW structure
*
* Retrieve and return the current locally administed address state.
*/
{
struct e1000_dev_spec_82571 *dev_spec;
DEBUGFUNC("e1000_get_laa_state_82571");
goto out;
out:
return (state);
}
/*
* e1000_set_laa_state_82571 - Set locally administered address state
* @hw: pointer to the HW structure
*
*/
void
{
struct e1000_dev_spec_82571 *dev_spec;
DEBUGFUNC("e1000_set_laa_state_82571");
return;
/* If workaround is activated... */
if (state) {
/*
* Hold a copy of the LAA in RAR[14] This is done so that
* between the time RAR[0] gets clobbered and the time it
* gets fixed, the actual LAA is in one of the RARs and no
* incoming packets directed to this port are dropped.
* Eventually the LAA will be in RAR[0] and RAR[14].
*/
}
}
/*
* e1000_fix_nvm_checksum_82571 - Fix EEPROM checksum
* @hw: pointer to the HW structure
*
* Verifies that the EEPROM has completed the update. After updating the
* EEPROM, we need to check bit 15 in work 0x23 for the checksum fix. If
* the checksum fix is not implemented, we need to set the bit and update
* the checksum. Otherwise, if bit 15 is set and the checksum is incorrect,
* we need to return bad checksum.
*/
static s32
{
DEBUGFUNC("e1000_fix_nvm_checksum_82571");
goto out;
/*
* Check bit 4 of word 10h. If it is 0, firmware is done updating
* 10h-12h. Checksum may need to be fixed.
*/
if (ret_val)
goto out;
if (!(data & 0x10)) {
/*
* Read 0x23 and check bit 15. This bit is a 1
* when the checksum has already been fixed. If
* the checksum is still wrong and this bit is a
* 1, we need to return bad checksum. Otherwise,
* we need to set this bit to a 1 and update the
* checksum.
*/
if (ret_val)
goto out;
if (!(data & 0x8000)) {
data |= 0x8000;
if (ret_val)
goto out;
}
}
out:
return (ret_val);
}
/*
* e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
* @hw: pointer to the HW structure
*
* Clears the hardware counters by reading the counter registers.
*/
static void
{
DEBUGFUNC("e1000_clear_hw_cntrs_82571");
}