2008-04-02 22:00:36 +00:00
|
|
|
/******************************************************************************
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2010-01-26 22:32:22 +00:00
|
|
|
Copyright (c) 2001-2010, Intel Corporation
|
2007-05-04 00:00:12 +00:00
|
|
|
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
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
******************************************************************************/
|
|
|
|
/*$FreeBSD$*/
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
/*
|
|
|
|
* 82542 Gigabit Ethernet Controller
|
2007-05-04 00:00:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "e1000_api.h"
|
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_init_phy_params_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_init_nvm_params_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_init_mac_params_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_get_bus_info_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_reset_hw_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_init_hw_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_setup_link_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_led_on_82542(struct e1000_hw *hw);
|
|
|
|
static s32 e1000_led_off_82542(struct e1000_hw *hw);
|
|
|
|
static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index);
|
|
|
|
static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw);
|
2009-07-06 17:23:48 +00:00
|
|
|
static s32 e1000_read_mac_addr_82542(struct e1000_hw *hw);
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/**
|
|
|
|
* e1000_init_phy_params_82542 - Init PHY func ptrs.
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_init_phy_params_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
struct e1000_phy_info *phy = &hw->phy;
|
|
|
|
s32 ret_val = E1000_SUCCESS;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_init_phy_params_82542");
|
|
|
|
|
|
|
|
phy->type = e1000_phy_none;
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_init_nvm_params_82542 - Init NVM func ptrs.
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_init_nvm_params_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
struct e1000_nvm_info *nvm = &hw->nvm;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_init_nvm_params_82542");
|
|
|
|
|
|
|
|
nvm->address_bits = 6;
|
|
|
|
nvm->delay_usec = 50;
|
|
|
|
nvm->opcode_bits = 3;
|
|
|
|
nvm->type = e1000_nvm_eeprom_microwire;
|
|
|
|
nvm->word_size = 64;
|
|
|
|
|
|
|
|
/* Function Pointers */
|
2008-04-02 22:00:36 +00:00
|
|
|
nvm->ops.read = e1000_read_nvm_microwire;
|
|
|
|
nvm->ops.release = e1000_stop_nvm;
|
|
|
|
nvm->ops.write = e1000_write_nvm_microwire;
|
|
|
|
nvm->ops.update = e1000_update_nvm_checksum_generic;
|
|
|
|
nvm->ops.validate = e1000_validate_nvm_checksum_generic;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
return E1000_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_init_mac_params_82542 - Init MAC func ptrs.
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_init_mac_params_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
struct e1000_mac_info *mac = &hw->mac;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_init_mac_params_82542");
|
|
|
|
|
|
|
|
/* Set media type */
|
2007-11-20 21:41:22 +00:00
|
|
|
hw->phy.media_type = e1000_media_type_fiber;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/* Set mta register count */
|
|
|
|
mac->mta_reg_count = 128;
|
|
|
|
/* Set rar entry count */
|
|
|
|
mac->rar_entry_count = E1000_RAR_ENTRIES;
|
|
|
|
|
|
|
|
/* Function pointers */
|
|
|
|
|
|
|
|
/* bus type/speed/width */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.get_bus_info = e1000_get_bus_info_82542;
|
2008-11-26 23:57:23 +00:00
|
|
|
/* function id */
|
|
|
|
mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* reset */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.reset_hw = e1000_reset_hw_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* hw initialization */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.init_hw = e1000_init_hw_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* link setup */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.setup_link = e1000_setup_link_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* phy/fiber/serdes setup */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.setup_physical_interface = e1000_setup_fiber_serdes_link_generic;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* check for link */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* multicast address update */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* writing VFTA */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.write_vfta = e1000_write_vfta_generic;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* clearing VFTA */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.clear_vfta = e1000_clear_vfta_generic;
|
2009-07-06 17:23:48 +00:00
|
|
|
/* read mac address */
|
|
|
|
mac->ops.read_mac_addr = e1000_read_mac_addr_82542;
|
2008-04-02 22:00:36 +00:00
|
|
|
/* set RAR */
|
|
|
|
mac->ops.rar_set = e1000_rar_set_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* turn on/off LED */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.led_on = e1000_led_on_82542;
|
|
|
|
mac->ops.led_off = e1000_led_off_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* clear hardware counters */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
/* link info */
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes_generic;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
return E1000_SUCCESS;
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_init_function_pointers_82542 - Init func ptrs.
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
2008-11-26 23:57:23 +00:00
|
|
|
* Called to initialize all function pointers and parameters.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2007-11-20 21:41:22 +00:00
|
|
|
void e1000_init_function_pointers_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
DEBUGFUNC("e1000_init_function_pointers_82542");
|
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
hw->mac.ops.init_params = e1000_init_mac_params_82542;
|
|
|
|
hw->nvm.ops.init_params = e1000_init_nvm_params_82542;
|
|
|
|
hw->phy.ops.init_params = e1000_init_phy_params_82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_get_bus_info_82542 - Obtain bus information for adapter
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
|
|
|
* This will obtain information about the HW bus for which the
|
2008-11-26 23:57:23 +00:00
|
|
|
* adapter is attached and stores it in the hw structure.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_get_bus_info_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
DEBUGFUNC("e1000_get_bus_info_82542");
|
|
|
|
|
|
|
|
hw->bus.type = e1000_bus_type_pci;
|
|
|
|
hw->bus.speed = e1000_bus_speed_unknown;
|
|
|
|
hw->bus.width = e1000_bus_width_unknown;
|
|
|
|
|
|
|
|
return E1000_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_reset_hw_82542 - Reset hardware
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
2008-11-26 23:57:23 +00:00
|
|
|
* This resets the hardware into a known state.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_reset_hw_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
struct e1000_bus_info *bus = &hw->bus;
|
|
|
|
s32 ret_val = E1000_SUCCESS;
|
2011-02-11 17:18:42 +00:00
|
|
|
u32 ctrl;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
DEBUGFUNC("e1000_reset_hw_82542");
|
|
|
|
|
|
|
|
if (hw->revision_id == E1000_REVISION_2) {
|
|
|
|
DEBUGOUT("Disabling MWI on 82542 rev 2\n");
|
|
|
|
e1000_pci_clear_mwi(hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUGOUT("Masking off all interrupts\n");
|
|
|
|
E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
|
|
|
|
|
|
|
|
E1000_WRITE_REG(hw, E1000_RCTL, 0);
|
|
|
|
E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
|
|
|
|
E1000_WRITE_FLUSH(hw);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* Delay to allow any outstanding PCI transactions to complete before
|
2007-05-04 00:00:12 +00:00
|
|
|
* resetting the device
|
|
|
|
*/
|
|
|
|
msec_delay(10);
|
|
|
|
|
|
|
|
ctrl = E1000_READ_REG(hw, E1000_CTRL);
|
|
|
|
|
|
|
|
DEBUGOUT("Issuing a global reset to 82542/82543 MAC\n");
|
|
|
|
E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
|
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
hw->nvm.ops.reload(hw);
|
2007-05-04 00:00:12 +00:00
|
|
|
msec_delay(2);
|
|
|
|
|
|
|
|
E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
|
2011-02-11 17:18:42 +00:00
|
|
|
E1000_READ_REG(hw, E1000_ICR);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
if (hw->revision_id == E1000_REVISION_2) {
|
|
|
|
if (bus->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
|
|
|
|
e1000_pci_set_mwi(hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_init_hw_82542 - Initialize hardware
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
2008-11-26 23:57:23 +00:00
|
|
|
* This inits the hardware readying it for operation.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_init_hw_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
struct e1000_mac_info *mac = &hw->mac;
|
2008-11-26 23:57:23 +00:00
|
|
|
struct e1000_dev_spec_82542 *dev_spec = &hw->dev_spec._82542;
|
2007-05-04 00:00:12 +00:00
|
|
|
s32 ret_val = E1000_SUCCESS;
|
|
|
|
u32 ctrl;
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_init_hw_82542");
|
|
|
|
|
|
|
|
/* Disabling VLAN filtering */
|
|
|
|
E1000_WRITE_REG(hw, E1000_VET, 0);
|
2008-04-02 22:00:36 +00:00
|
|
|
mac->ops.clear_vfta(hw);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
|
|
|
|
if (hw->revision_id == E1000_REVISION_2) {
|
|
|
|
DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
|
|
|
|
e1000_pci_clear_mwi(hw);
|
|
|
|
E1000_WRITE_REG(hw, E1000_RCTL, E1000_RCTL_RST);
|
|
|
|
E1000_WRITE_FLUSH(hw);
|
|
|
|
msec_delay(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the receive address. */
|
|
|
|
e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
|
|
|
|
|
|
|
|
/* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
|
|
|
|
if (hw->revision_id == E1000_REVISION_2) {
|
|
|
|
E1000_WRITE_REG(hw, E1000_RCTL, 0);
|
|
|
|
E1000_WRITE_FLUSH(hw);
|
|
|
|
msec_delay(1);
|
|
|
|
if (hw->bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
|
|
|
|
e1000_pci_set_mwi(hw);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Zero out the Multicast HASH table */
|
|
|
|
DEBUGOUT("Zeroing the MTA\n");
|
|
|
|
for (i = 0; i < mac->mta_reg_count; i++)
|
|
|
|
E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* Set the PCI priority bit correctly in the CTRL register. This
|
2007-05-04 00:00:12 +00:00
|
|
|
* determines if the adapter gives priority to receives, or if it
|
|
|
|
* gives equal priority to transmits and receives.
|
|
|
|
*/
|
|
|
|
if (dev_spec->dma_fairness) {
|
|
|
|
ctrl = E1000_READ_REG(hw, E1000_CTRL);
|
|
|
|
E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PRIOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup link and flow control */
|
|
|
|
ret_val = e1000_setup_link_82542(hw);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* Clear all of the statistics registers (clear on read). It is
|
2007-05-04 00:00:12 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
e1000_clear_hw_cntrs_82542(hw);
|
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_setup_link_82542 - Setup flow control and link settings
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-11-26 23:57:23 +00:00
|
|
|
* and the transmitter and receiver are not enabled.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_setup_link_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
struct e1000_mac_info *mac = &hw->mac;
|
|
|
|
s32 ret_val = E1000_SUCCESS;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_setup_link_82542");
|
|
|
|
|
|
|
|
ret_val = e1000_set_default_fc_generic(hw);
|
|
|
|
if (ret_val)
|
|
|
|
goto out;
|
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
hw->fc.requested_mode &= ~e1000_fc_tx_pause;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
if (mac->report_tx_early == 1)
|
2008-11-26 23:57:23 +00:00
|
|
|
hw->fc.requested_mode &= ~e1000_fc_rx_pause;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
2008-11-26 23:57:23 +00:00
|
|
|
* Save off the requested flow control mode for use later. Depending
|
|
|
|
* on the link partner's capabilities, we may or may not use this mode.
|
2007-05-04 00:00:12 +00:00
|
|
|
*/
|
2008-11-26 23:57:23 +00:00
|
|
|
hw->fc.current_mode = hw->fc.requested_mode;
|
2007-05-04 00:00:12 +00:00
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
|
|
|
|
hw->fc.current_mode);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
/* Call the necessary subroutine to configure the link. */
|
2008-04-02 22:00:36 +00:00
|
|
|
ret_val = mac->ops.setup_physical_interface(hw);
|
2007-05-04 00:00:12 +00:00
|
|
|
if (ret_val)
|
|
|
|
goto out;
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* Initialize the flow control address, type, and PAUSE timer
|
2007-05-04 00:00:12 +00:00
|
|
|
* registers to their default values. This is done even if flow
|
|
|
|
* control is disabled, because it does not hurt anything to
|
|
|
|
* initialize these registers.
|
|
|
|
*/
|
|
|
|
DEBUGOUT("Initializing Flow Control address, type and timer regs\n");
|
|
|
|
|
|
|
|
E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
|
|
|
|
E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
|
|
|
|
E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
|
|
|
|
|
2007-11-20 21:41:22 +00:00
|
|
|
E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
|
2007-05-04 00:00:12 +00:00
|
|
|
|
|
|
|
ret_val = e1000_set_fc_watermarks_generic(hw);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_led_on_82542 - Turn on SW controllable LED
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
2008-11-26 23:57:23 +00:00
|
|
|
* Turns the SW defined LED on.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_led_on_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_led_on_82542");
|
|
|
|
|
|
|
|
ctrl |= E1000_CTRL_SWDPIN0;
|
|
|
|
ctrl |= E1000_CTRL_SWDPIO0;
|
|
|
|
E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
|
|
|
|
|
|
|
|
return E1000_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_led_off_82542 - Turn off SW controllable LED
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
2008-11-26 23:57:23 +00:00
|
|
|
* Turns the SW defined LED off.
|
2007-05-04 00:00:12 +00:00
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static s32 e1000_led_off_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_led_off_82542");
|
|
|
|
|
|
|
|
ctrl &= ~E1000_CTRL_SWDPIN0;
|
|
|
|
ctrl |= E1000_CTRL_SWDPIO0;
|
|
|
|
E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
|
|
|
|
|
|
|
|
return E1000_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-04-02 22:00:36 +00:00
|
|
|
/**
|
|
|
|
* e1000_rar_set_82542 - Set receive address register
|
|
|
|
* @hw: pointer to the HW structure
|
|
|
|
* @addr: pointer to the receive address
|
|
|
|
* @index: receive address array register
|
|
|
|
*
|
|
|
|
* Sets the receive address array register at index to the address passed
|
|
|
|
* in by addr.
|
|
|
|
**/
|
|
|
|
static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index)
|
|
|
|
{
|
|
|
|
u32 rar_low, rar_high;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_rar_set_82542");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HW expects these in little endian so we reverse the byte order
|
|
|
|
* from network order (big endian) to little endian
|
|
|
|
*/
|
|
|
|
rar_low = ((u32) addr[0] |
|
|
|
|
((u32) addr[1] << 8) |
|
|
|
|
((u32) addr[2] << 16) | ((u32) addr[3] << 24));
|
|
|
|
|
|
|
|
rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
|
|
|
|
|
|
|
|
/* If MAC address zero, no need to set the AV bit */
|
2008-11-26 23:57:23 +00:00
|
|
|
if (rar_low || rar_high)
|
|
|
|
rar_high |= E1000_RAH_AV;
|
2008-04-02 22:00:36 +00:00
|
|
|
|
|
|
|
E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low);
|
|
|
|
E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
|
|
|
|
}
|
|
|
|
|
2007-05-04 00:00:12 +00:00
|
|
|
/**
|
2008-02-29 21:50:11 +00:00
|
|
|
* e1000_translate_register_82542 - Translate the proper register offset
|
2007-05-16 00:14:23 +00:00
|
|
|
* @reg: e1000 register to be read
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
|
|
|
* Registers in 82542 are located in different offsets than other adapters
|
|
|
|
* even though they function in the same manner. This function takes in
|
|
|
|
* the name of the register to read and returns the correct offset for
|
|
|
|
* 82542 silicon.
|
|
|
|
**/
|
2007-11-20 21:41:22 +00:00
|
|
|
u32 e1000_translate_register_82542(u32 reg)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
2007-11-20 21:41:22 +00:00
|
|
|
/*
|
|
|
|
* Some of the 82542 registers are located at different
|
2007-05-04 00:00:12 +00:00
|
|
|
* offsets than they are in newer adapters.
|
|
|
|
* Despite the difference in location, the registers
|
|
|
|
* function in the same manner.
|
|
|
|
*/
|
|
|
|
switch (reg) {
|
|
|
|
case E1000_RA:
|
|
|
|
reg = 0x00040;
|
|
|
|
break;
|
|
|
|
case E1000_RDTR:
|
|
|
|
reg = 0x00108;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDBAL(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00110;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDBAH(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00114;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDLEN(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00118;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDH(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00120;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDT(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00128;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDBAL(1):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00138;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDBAH(1):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x0013C;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDLEN(1):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00140;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDH(1):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00148;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_RDT(1):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00150;
|
|
|
|
break;
|
|
|
|
case E1000_FCRTH:
|
|
|
|
reg = 0x00160;
|
|
|
|
break;
|
|
|
|
case E1000_FCRTL:
|
|
|
|
reg = 0x00168;
|
|
|
|
break;
|
|
|
|
case E1000_MTA:
|
|
|
|
reg = 0x00200;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_TDBAL(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00420;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_TDBAH(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00424;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_TDLEN(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00428;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_TDH(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00430;
|
|
|
|
break;
|
2007-11-20 21:41:22 +00:00
|
|
|
case E1000_TDT(0):
|
2007-05-04 00:00:12 +00:00
|
|
|
reg = 0x00438;
|
|
|
|
break;
|
|
|
|
case E1000_TIDV:
|
|
|
|
reg = 0x00440;
|
|
|
|
break;
|
|
|
|
case E1000_VFTA:
|
|
|
|
reg = 0x00600;
|
|
|
|
break;
|
|
|
|
case E1000_TDFH:
|
|
|
|
reg = 0x08010;
|
|
|
|
break;
|
|
|
|
case E1000_TDFT:
|
|
|
|
reg = 0x08018;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_clear_hw_cntrs_82542 - Clear device specific hardware counters
|
2007-05-16 00:14:23 +00:00
|
|
|
* @hw: pointer to the HW structure
|
2007-05-04 00:00:12 +00:00
|
|
|
*
|
|
|
|
* Clears the hardware counters by reading the counter registers.
|
|
|
|
**/
|
2008-04-02 22:00:36 +00:00
|
|
|
static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw)
|
2007-05-04 00:00:12 +00:00
|
|
|
{
|
|
|
|
DEBUGFUNC("e1000_clear_hw_cntrs_82542");
|
|
|
|
|
|
|
|
e1000_clear_hw_cntrs_base_generic(hw);
|
|
|
|
|
2008-11-26 23:57:23 +00:00
|
|
|
E1000_READ_REG(hw, E1000_PRC64);
|
|
|
|
E1000_READ_REG(hw, E1000_PRC127);
|
|
|
|
E1000_READ_REG(hw, E1000_PRC255);
|
|
|
|
E1000_READ_REG(hw, E1000_PRC511);
|
|
|
|
E1000_READ_REG(hw, E1000_PRC1023);
|
|
|
|
E1000_READ_REG(hw, E1000_PRC1522);
|
|
|
|
E1000_READ_REG(hw, E1000_PTC64);
|
|
|
|
E1000_READ_REG(hw, E1000_PTC127);
|
|
|
|
E1000_READ_REG(hw, E1000_PTC255);
|
|
|
|
E1000_READ_REG(hw, E1000_PTC511);
|
|
|
|
E1000_READ_REG(hw, E1000_PTC1023);
|
|
|
|
E1000_READ_REG(hw, E1000_PTC1522);
|
2007-05-04 00:00:12 +00:00
|
|
|
}
|
2009-07-06 17:23:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* e1000_read_mac_addr_82542 - Read device MAC address
|
|
|
|
* @hw: pointer to the HW structure
|
|
|
|
*
|
|
|
|
* Reads the device MAC address from the EEPROM and stores the value.
|
|
|
|
**/
|
|
|
|
static s32 e1000_read_mac_addr_82542(struct e1000_hw *hw)
|
|
|
|
{
|
|
|
|
s32 ret_val = E1000_SUCCESS;
|
|
|
|
u16 offset, nvm_data, i;
|
|
|
|
|
|
|
|
DEBUGFUNC("e1000_read_mac_addr");
|
|
|
|
|
|
|
|
for (i = 0; i < ETH_ADDR_LEN; i += 2) {
|
|
|
|
offset = i >> 1;
|
|
|
|
ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
|
|
|
|
if (ret_val) {
|
|
|
|
DEBUGOUT("NVM Read Error\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
|
|
|
|
hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ETH_ADDR_LEN; i++)
|
|
|
|
hw->mac.addr[i] = hw->mac.perm_addr[i];
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret_val;
|
|
|
|
}
|