e1000_phy.c revision bd9f6899328e19cbb74e3ad02f5c32002285887e
/*
* 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 - 2009 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms of the CDDLv1.
*/
/*
* IntelVersion: 1.151 v3-1-10-1_2009-9-18_Release14-6
*/
#include "e1000_api.h"
/* Cable length tables */
static const u16 e1000_m88_cable_length_table[] =
#define M88E1000_CABLE_LENGTH_TABLE_SIZE \
(sizeof (e1000_m88_cable_length_table) / \
sizeof (e1000_m88_cable_length_table[0]))
static const u16 e1000_igp_2_cable_length_table[] =
{0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
0, 0, 0, 3, 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41,
6, 10, 14, 18, 22, 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61,
21, 26, 31, 35, 40, 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82,
40, 45, 51, 56, 61, 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104,
60, 66, 72, 77, 82, 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121,
83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
104, 109, 114, 118, 121, 124};
#define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \
(sizeof (e1000_igp_2_cable_length_table) / \
sizeof (e1000_igp_2_cable_length_table[0]))
/*
* e1000_init_phy_ops_generic - Initialize PHY function pointers
* @hw: pointer to the HW structure
*
* Setups up the function pointers to no-op functions
*/
void
{
DEBUGFUNC("e1000_init_phy_ops_generic");
/* Initialize function pointers */
}
/*
* e1000_null_read_reg - No-op function, return 0
* @hw: pointer to the HW structure
*/
{
DEBUGFUNC("e1000_null_read_reg");
return (E1000_SUCCESS);
}
/*
* e1000_null_phy_generic - No-op function, return void
* @hw: pointer to the HW structure
*/
void
{
DEBUGFUNC("e1000_null_phy_generic");
}
/*
* e1000_null_lplu_state - No-op function, return 0
* @hw: pointer to the HW structure
*/
{
DEBUGFUNC("e1000_null_lplu_state");
return (E1000_SUCCESS);
}
/*
* e1000_null_write_reg - No-op function, return 0
* @hw: pointer to the HW structure
*/
{
DEBUGFUNC("e1000_null_write_reg");
return (E1000_SUCCESS);
}
/*
* e1000_check_reset_block_generic - Check if PHY reset is blocked
* @hw: pointer to the HW structure
*
* Read the PHY management control register and check whether a PHY reset
* is blocked. If a reset is not blocked return E1000_SUCCESS, otherwise
* return E1000_BLK_PHY_RESET (12).
*/
{
DEBUGFUNC("e1000_check_reset_block");
return ((manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
}
/*
* e1000_get_phy_id - 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.
*/
{
u16 retry_count = 0;
DEBUGFUNC("e1000_get_phy_id");
goto out;
while (retry_count < 2) {
if (ret_val)
goto out;
usec_delay(20);
if (ret_val)
goto out;
goto out;
/*
* If the PHY ID is still unknown, we may have an 82577
* without link. We will try again after setting Slow MDIC
* mode. No harm in trying again in this case since the PHY
* ID is unknown at this point anyway.
*/
if (ret_val)
goto out;
if (ret_val)
goto out;
retry_count++;
}
out:
/* Revert to MDIO fast mode, if applicable */
if (retry_count) {
if (ret_val)
return (ret_val);
}
return (ret_val);
}
/*
* e1000_phy_reset_dsp_generic - Reset PHY DSP
* @hw: pointer to the HW structure
*
* Reset the digital signal processor.
*/
{
DEBUGFUNC("e1000_phy_reset_dsp_generic");
goto out;
if (ret_val)
goto out;
out:
return (ret_val);
}
/*
* e1000_read_phy_reg_mdic - Read MDI control register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Reads the MDI control register in the PHY at offset and stores the
* information read to data.
*/
{
DEBUGFUNC("e1000_read_phy_reg_mdic");
/*
* Set up Op-code, Phy Address, and register offset in the MDI Control
* register. The MAC will take care of interfacing with the PHY to
* retrieve the desired data.
*/
/*
* Poll the ready bit to see if the MDI read completed
* Increasing the time out as testing showed failures with
* the lower time out
*/
for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
usec_delay(50);
if (mdic & E1000_MDIC_READY)
break;
}
if (!(mdic & E1000_MDIC_READY)) {
DEBUGOUT("MDI Read did not complete\n");
ret_val = -E1000_ERR_PHY;
goto out;
}
if (mdic & E1000_MDIC_ERROR) {
DEBUGOUT("MDI Error\n");
ret_val = -E1000_ERR_PHY;
goto out;
}
out:
return (ret_val);
}
/*
* e1000_write_phy_reg_mdic - Write MDI control register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write to register at offset
*
* Writes data to MDI control register in the PHY at offset.
*/
{
DEBUGFUNC("e1000_write_phy_reg_mdic");
/*
* Set up Op-code, Phy Address, and register offset in the MDI Control
* register. The MAC will take care of interfacing with the PHY to
* retrieve the desired data.
*/
(offset << E1000_MDIC_REG_SHIFT) |
/*
* Poll the ready bit to see if the MDI read completed
* Increasing the time out as testing showed failures with
* the lower time out
*/
for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
usec_delay(50);
if (mdic & E1000_MDIC_READY)
break;
}
if (!(mdic & E1000_MDIC_READY)) {
DEBUGOUT("MDI Write did not complete\n");
ret_val = -E1000_ERR_PHY;
goto out;
}
if (mdic & E1000_MDIC_ERROR) {
DEBUGOUT("MDI Error\n");
ret_val = -E1000_ERR_PHY;
goto out;
}
out:
return (ret_val);
}
/*
* e1000_read_phy_reg_m88 - Read m88 PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquires semaphore, if necessary, then reads the PHY register at offset
* and storing the retrieved information in data. Release any acquired
* semaphores before exiting.
*/
{
DEBUGFUNC("e1000_read_phy_reg_m88");
goto out;
if (ret_val)
goto out;
data);
out:
return (ret_val);
}
/*
* e1000_write_phy_reg_m88 - Write m88 PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquires semaphore, if necessary, then writes the data to PHY register
* at the offset. Release any acquired semaphores before exiting.
*/
{
DEBUGFUNC("e1000_write_phy_reg_m88");
goto out;
if (ret_val)
goto out;
data);
out:
return (ret_val);
}
/*
* e1000_read_phy_reg_igp - Read igp PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
* @locked: semaphore has already been acquired or not
*
* Acquires semaphore, if necessary, then reads the PHY register at offset
* and stores the retrieved information in data. Release any acquired
* semaphores before exiting.
*/
static s32
bool locked)
{
DEBUGFUNC("__e1000_read_phy_reg_igp");
if (!locked) {
goto out;
if (ret_val)
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
if (ret_val)
goto release;
}
data);
if (!locked)
out:
return (ret_val);
}
/*
* e1000_read_phy_reg_igp - Read igp PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquires semaphore then reads the PHY register at offset and stores the
* retrieved information in data.
* Release the acquired semaphore before exiting.
*/
{
}
/*
* e1000_read_phy_reg_igp_locked - Read igp PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Reads the PHY register at offset and stores the retrieved information
* in data. Assumes semaphore already acquired.
*/
{
}
/*
* e1000_write_phy_reg_igp - Write igp PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
* @locked: semaphore has already been acquired or not
*
* Acquires semaphore, if necessary, then writes the data to PHY register
* at the offset. Release any acquired semaphores before exiting.
*/
static s32
bool locked)
{
DEBUGFUNC("e1000_write_phy_reg_igp");
if (!locked) {
goto out;
if (ret_val)
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
if (ret_val)
goto release;
}
data);
if (!locked)
out:
return (ret_val);
}
/*
* e1000_write_phy_reg_igp - Write igp PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquires semaphore then writes the data to PHY register
* at the offset. Release any acquired semaphores before exiting.
*/
{
}
/*
* e1000_write_phy_reg_igp_locked - Write igp PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Writes the data to PHY register at the offset.
* Assumes semaphore already acquired.
*/
{
}
/*
* __e1000_read_kmrn_reg - Read kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
* @locked: semaphore has already been acquired or not
*
* Acquires semaphore, if necessary. Then reads the PHY register at offset
* using the kumeran interface. The information retrieved is stored in data.
* Release any acquired semaphores before exiting.
*/
static s32
{
DEBUGFUNC("__e1000_read_kmrn_reg");
if (!locked) {
goto out;
if (ret_val)
goto out;
}
usec_delay(2);
if (!locked)
out:
return (ret_val);
}
/*
* e1000_read_kmrn_reg_generic - Read kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquires semaphore then reads the PHY register at offset using the
* kumeran interface. The information retrieved is stored in data.
* Release the acquired semaphore before exiting.
*/
{
}
/*
* e1000_read_kmrn_reg_locked - Read kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Reads the PHY register at offset using the kumeran interface. The
* information retrieved is stored in data.
* Assumes semaphore already acquired.
*/
{
}
/*
* __e1000_write_kmrn_reg - Write kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
* @locked: semaphore has already been acquired or not
*
* Acquires semaphore, if necessary. Then write the data to PHY register
* at the offset using the kumeran interface. Release any acquired semaphores
* before exiting.
*/
static s32
{
DEBUGFUNC("e1000_write_kmrn_reg_generic");
if (!locked) {
goto out;
if (ret_val)
goto out;
}
usec_delay(2);
if (!locked)
out:
return (ret_val);
}
/*
* e1000_write_kmrn_reg_generic - Write kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquires semaphore then writes the data to the PHY register at the offset
* using the kumeran interface. Release the acquired semaphore before exiting.
*/
{
}
/*
* e1000_write_kmrn_reg_locked - Write kumeran register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Write the data to PHY register at the offset using the kumeran interface.
* Assumes semaphore already acquired.
*/
{
}
/*
* e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
* @hw: pointer to the HW structure
*
* Sets up Carrier-sense on Transmit and downshift values.
*/
{
DEBUGFUNC("e1000_copper_link_setup_82577");
if (phy->reset_disable) {
goto out;
}
/* Enable CRS on TX. This must be set for half-duplex operation. */
if (ret_val)
goto out;
/* Enable downshift */
if (ret_val)
goto out;
/* Set number of link attempts before downshift */
if (ret_val)
goto out;
out:
return (ret_val);
}
/*
* e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link
* @hw: pointer to the HW structure
*
* and downshift values are set also.
*/
{
DEBUGFUNC("e1000_copper_link_setup_m88");
if (phy->reset_disable) {
goto out;
}
/* Enable CRS on TX. This must be set for half-duplex operation. */
if (ret_val)
goto out;
/* For BM PHY this bit is downshift enable */
/*
* 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)
*/
case 1:
break;
case 2:
break;
case 3:
break;
case 0:
default:
break;
}
/*
* Options:
* disable_polarity_correction = 0 (default)
* Automatic Correction for Reversed Cable Polarity
* 0 - Disabled
* 1 - Enabled
*/
/* Enable downshift on BM (disabled by default) */
if (ret_val)
goto out;
/*
* Force TX_CLK in the Extended PHY Specific Control Register
* to 25MHz clock.
*/
&phy_data);
if (ret_val)
goto out;
/* 82573L PHY - set the downshift counter to 5x. */
} else {
/* Configure Master and Slave downshift values */
}
phy_data);
if (ret_val)
goto out;
}
/* Set PHY page 0, register 29 to 0x0003 */
if (ret_val)
goto out;
/* Set PHY page 0, register 30 to 0x0000 */
if (ret_val)
goto out;
}
/* Commit the changes. */
if (ret_val) {
DEBUGOUT("Error committing the PHY changes\n");
goto out;
}
&phy_data);
if (ret_val)
goto out;
/* 82578 PHY - set the downshift count to 1x. */
phy_data);
if (ret_val)
goto out;
}
out:
return (ret_val);
}
/*
* e1000_copper_link_setup_igp - Setup igp PHY's for copper link
* @hw: pointer to the HW structure
*
* igp PHY's.
*/
{
DEBUGFUNC("e1000_copper_link_setup_igp");
if (phy->reset_disable) {
goto out;
}
if (ret_val) {
DEBUGOUT("Error resetting the PHY.\n");
goto out;
}
/*
* Wait 100ms for MAC to configure PHY from NVM settings, to avoid
* timeout issues when LFS is enabled.
*/
msec_delay(100);
/*
* The NVM settings will configure LPLU in D3 for non-IGP1 PHYs.
*/
/* disable lplu d3 during driver init */
if (ret_val) {
DEBUGOUT("Error Disabling LPLU D3\n");
goto out;
}
}
/* disable lplu d0 during driver init */
if (ret_val) {
DEBUGOUT("Error Disabling LPLU D0\n");
goto out;
}
}
/* Configure mdi-mdix settings */
if (ret_val)
goto out;
case 1:
break;
case 2:
break;
case 0:
default:
break;
}
if (ret_val)
goto out;
/* set auto-master slave resolution settings */
/*
* when autonegotiation advertisement is only 1000Mbps then we
* should disable SmartSpeed and enable Auto MasterSlave
* resolution as hardware default.
*/
/* Disable SmartSpeed */
&data);
if (ret_val)
goto out;
data);
if (ret_val)
goto out;
if (ret_val)
goto out;
data &= ~CR_1000T_MS_ENABLE;
if (ret_val)
goto out;
}
if (ret_val)
goto out;
/* load defaults for future use */
((data & CR_1000T_MS_VALUE) ?
case e1000_ms_force_master:
break;
case e1000_ms_force_slave:
data &= ~(CR_1000T_MS_VALUE);
break;
case e1000_ms_auto:
data &= ~CR_1000T_MS_ENABLE;
default:
break;
}
if (ret_val)
goto out;
}
out:
return (ret_val);
}
/*
* @hw: pointer to the HW structure
*
* Performs initial bounds checking on autoneg advertisement parameter, then
* configure to advertise the full capability. Setup the PHY to autoneg
* and restart the negotiation process between the link partner. If
* autoneg_wait_to_complete, then wait for autoneg to complete before exiting.
*/
{
DEBUGFUNC("e1000_copper_link_autoneg");
/*
* Perform some bounds checking on the autoneg advertisement
* parameter.
*/
/*
* If autoneg_advertised is zero, we assume it was not defaulted by
* the calling code so we set to advertise full capability.
*/
if (phy->autoneg_advertised == 0)
DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
if (ret_val) {
DEBUGOUT("Error Setting up Auto-Negotiation\n");
goto out;
}
DEBUGOUT("Restarting Auto-Neg\n");
/*
* Restart auto-negotiation by setting the Auto Neg Enable bit and the
* Auto Neg Restart bit in the PHY control register.
*/
if (ret_val)
goto out;
if (ret_val)
goto out;
/*
* Does the user want to wait for Auto-Neg to complete here, or check
* at a later time (for example, callback routine).
*/
if (phy->autoneg_wait_to_complete) {
if (ret_val) {
DEBUGOUT("Error while waiting for "
"autoneg to complete\n");
goto out;
}
}
out:
return (ret_val);
}
/*
* e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
* @hw: pointer to the HW structure
*
* register and if the PHY is already setup for auto-negotiation, then
* return successful. Otherwise, setup advertisement and flow control to
* the appropriate values for the wanted auto-negotiation.
*/
{
u16 mii_1000t_ctrl_reg = 0;
DEBUGFUNC("e1000_phy_setup_autoneg");
/* Read the MII Auto-Neg Advertisement Register (Address 4). */
if (ret_val)
goto out;
/* Read the MII 1000Base-T Control Register (Address 9). */
if (ret_val)
goto out;
}
/*
* Need to parse both autoneg_advertised and fc and set up the
* appropriate PHY registers. First we will parse for
* autoneg_advertised software override. Since we can advertise a
* plethora of combinations, we need to check each bit individually.
*/
/*
* First we clear all the 10/100 mb speed bits in the Auto-Neg
* Advertisement Register (Address 4) and the 1000 mb speed bits in
* the 1000Base-T Control Register (Address 9).
*/
/* Do we want to advertise 10 Mb Half Duplex? */
DEBUGOUT("Advertise 10mb Half duplex\n");
}
/* Do we want to advertise 10 Mb Full Duplex? */
DEBUGOUT("Advertise 10mb Full duplex\n");
}
/* Do we want to advertise 100 Mb Half Duplex? */
DEBUGOUT("Advertise 100mb Half duplex\n");
}
/* Do we want to advertise 100 Mb Full Duplex? */
DEBUGOUT("Advertise 100mb Full duplex\n");
}
/* We do not allow the Phy to advertise 1000 Mb Half Duplex */
DEBUGOUT("Advertise 1000mb Half duplex request denied!\n");
/* Do we want to advertise 1000 Mb Full Duplex? */
DEBUGOUT("Advertise 1000mb Full duplex\n");
}
/*
* Check for a software override of the flow control settings, and
* setup the PHY advertisement registers accordingly. If
* auto-negotiation is enabled, then software will have to set the
* "PAUSE" bits to the correct value in the Auto-Negotiation
* Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-
* negotiation.
*
* The possible values of the "fc" parameter are:
* 0: Flow control is completely disabled
* 1: Rx flow control is enabled (we can receive pause frames
* but not send pause frames).
* 2: Tx flow control is enabled (we can send pause frames
* but we do not support receiving pause frames).
* 3: Both Rx and Tx flow control (symmetric) are enabled.
* other: No software override. The flow control configuration
* in the EEPROM is used.
*/
case e1000_fc_none:
/*
* Flow control (Rx & Tx) is completely disabled by a software
* over-ride.
*/
break;
case e1000_fc_rx_pause:
/*
* Rx Flow control is enabled, and Tx Flow control is
* disabled, by a software over-ride.
*
* Since there really isn't a way to advertise that we are
* capable of Rx Pause ONLY, we will advertise that we support
* both symmetric and asymmetric Rx PAUSE. Later (in
* e1000_config_fc_after_link_up) we will disable the hw's
* ability to send PAUSE frames.
*/
break;
case e1000_fc_tx_pause:
/*
* Tx Flow control is enabled, and Rx Flow control is
* disabled, by a software over-ride.
*/
break;
case e1000_fc_full:
/*
* Flow control (both Rx and Tx) is enabled by a software
* over-ride.
*/
break;
default:
DEBUGOUT("Flow control param set incorrectly\n");
goto out;
}
if (ret_val)
goto out;
if (ret_val)
goto out;
}
out:
return (ret_val);
}
/*
* e1000_setup_copper_link_generic - 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).
*/
{
bool link;
DEBUGFUNC("e1000_setup_copper_link_generic");
/*
* Setup autoneg and flow control advertisement and perform
* autonegotiation.
*/
if (ret_val)
goto out;
} else {
/*
* PHY will be set to 10H, 10F, 100H or 100F depending on user
* settings.
*/
DEBUGOUT("Forcing Speed and Duplex\n");
if (ret_val) {
DEBUGOUT("Error Forcing Speed and Duplex\n");
goto out;
}
}
/*
* Check link status. Wait up to 100 microseconds for link to become
* valid.
*/
10,
&link);
if (ret_val)
goto out;
if (link) {
DEBUGOUT("Valid link established!!!\n");
} else {
DEBUGOUT("Unable to establish link!!!\n");
}
out:
return (ret_val);
}
/*
* @hw: pointer to the HW structure
*
* Calls the PHY setup function to force speed and duplex. Clears the
* auto-crossover to force MDI manually. Waits for link and returns
* successful if link up is successful, else -E1000_ERR_PHY (-2).
*/
{
bool link;
DEBUGFUNC("e1000_phy_force_speed_duplex_igp");
if (ret_val)
goto out;
if (ret_val)
goto out;
/*
* Clear Auto-Crossover to force MDI manually. IGP requires MDI
* forced whenever speed and duplex are forced.
*/
if (ret_val)
goto out;
if (ret_val)
goto out;
usec_delay(1);
if (phy->autoneg_wait_to_complete) {
100000,
&link);
if (ret_val)
goto out;
if (!link)
DEBUGOUT("Link taking longer than expected.\n");
/* Try once more */
100000,
&link);
if (ret_val)
goto out;
}
out:
return (ret_val);
}
/*
* @hw: pointer to the HW structure
*
* Calls the PHY setup function to force speed and duplex. Clears the
* auto-crossover to force MDI manually. Resets the PHY to commit the
* changes. If time expires while waiting for link up, we reset the DSP.
* After reset, TX_CLK and CRS on Tx must be set. Return successful upon
* successful completion, else return corresponding error code.
*/
{
bool link;
DEBUGFUNC("e1000_phy_force_speed_duplex_m88");
/*
* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
* forced whenever speed and duplex are forced.
*/
if (ret_val)
goto out;
if (ret_val)
goto out;
if (ret_val)
goto out;
if (ret_val)
goto out;
/* Reset the phy to commit changes. */
if (ret_val)
goto out;
if (phy->autoneg_wait_to_complete) {
100000,
&link);
if (ret_val)
goto out;
if (!link) {
/*
* We didn't get link. Reset the DSP and cross our
* fingers.
*/
0x001d);
if (ret_val)
goto out;
if (ret_val)
goto out;
}
/* Try once more */
100000,
&link);
if (ret_val)
goto out;
}
if (ret_val)
goto out;
/*
* Resetting the phy means we need to re-force TX_CLK in the Extended
* PHY Specific Control Register to 25MHz clock from the reset value
* of 2.5MHz.
*/
if (ret_val)
goto out;
/*
* In addition, we must re-enable CRS on Tx for both half and full
* duplex.
*/
if (ret_val)
goto out;
out:
return (ret_val);
}
/*
* e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex
* @hw: pointer to the HW structure
*
* Forces the speed and duplex settings of the PHY.
* This is a function pointer entry point only called by
* PHY setup routines.
*/
{
bool link;
DEBUGFUNC("e1000_phy_force_speed_duplex_ife");
goto out;
}
if (ret_val)
goto out;
if (ret_val)
goto out;
/* Disable MDI-X support for 10/100 */
if (ret_val)
goto out;
data &= ~IFE_PMC_AUTO_MDIX;
data &= ~IFE_PMC_FORCE_MDIX;
if (ret_val)
goto out;
usec_delay(1);
if (phy->autoneg_wait_to_complete) {
if (ret_val)
goto out;
if (!link)
DEBUGOUT("Link taking longer than expected.\n");
/* Try once more */
if (ret_val)
goto out;
}
out:
return (ret_val);
}
/*
* @hw: pointer to the HW structure
* @phy_ctrl: pointer to current value of PHY_CONTROL
*
* Forces speed and duplex on the PHY by doing the following: disable flow
* disable auto-negotiation, configure duplex, configure speed, configure
* the collision distance, write configuration to CTRL register. The
* caller must write to the PHY_CONTROL register for these settings to
* take affect.
*/
void
{
DEBUGFUNC("e1000_phy_force_speed_duplex_setup");
ctrl &= ~E1000_CTRL_SPD_SEL;
/* Disable Auto Speed Detection */
ctrl &= ~E1000_CTRL_ASDE;
/* Disable autoneg on the phy */
*phy_ctrl &= ~MII_CR_AUTO_NEG_EN;
/* Forcing Full or Half Duplex? */
ctrl &= ~E1000_CTRL_FD;
*phy_ctrl &= ~MII_CR_FULL_DUPLEX;
DEBUGOUT("Half Duplex\n");
} else {
ctrl |= E1000_CTRL_FD;
DEBUGOUT("Full Duplex\n");
}
/* Forcing 10mb or 100mb? */
*phy_ctrl |= MII_CR_SPEED_100;
DEBUGOUT("Forcing 100mb\n");
} else {
/* LINTED */
*phy_ctrl |= MII_CR_SPEED_10;
DEBUGOUT("Forcing 10mb\n");
}
}
/*
* e1000_set_d3_lplu_state_generic - 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_generic");
goto out;
if (ret_val)
goto out;
if (!active) {
data);
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;
}
data);
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_check_downshift_generic - Checks whether a downshift in speed occurred
* @hw: pointer to the HW structure
*
* Success returns 0, Failure returns 1
*
* A downshift is detected by querying the PHY link health.
*/
{
DEBUGFUNC("e1000_check_downshift_generic");
case e1000_phy_m88:
case e1000_phy_gg82563:
case e1000_phy_bm:
case e1000_phy_82578:
break;
case e1000_phy_igp_2:
case e1000_phy_igp:
case e1000_phy_igp_3:
break;
default:
/* speed downshift not supported */
phy->speed_downgraded = false;
goto out;
}
if (!ret_val)
out:
return (ret_val);
}
/*
* e1000_check_polarity_m88 - Checks the polarity.
* @hw: pointer to the HW structure
*
* Success returns 0, Failure returns -E1000_ERR_PHY (-2)
*
* Polarity is determined based on the PHY specific status register.
*/
{
DEBUGFUNC("e1000_check_polarity_m88");
if (!ret_val)
return (ret_val);
}
/*
* e1000_check_polarity_igp - Checks the polarity.
* @hw: pointer to the HW structure
*
* Success returns 0, Failure returns -E1000_ERR_PHY (-2)
*
* Polarity is determined based on the PHY port status register, and the
* current speed (since there is no polarity at 100Mbps).
*/
{
DEBUGFUNC("e1000_check_polarity_igp");
/*
* Polarity is determined based on the speed of our connection.
*/
if (ret_val)
goto out;
if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
} else {
/*
* This really only applies to 10Mbps since there is no
* polarity for 100Mbps (always 0).
*/
}
if (!ret_val)
out:
return (ret_val);
}
/*
* e1000_check_polarity_ife - Check cable polarity for IFE PHY
* @hw: pointer to the HW structure
*
* Polarity is determined on the polarity reversal feature being enabled.
*/
{
DEBUGFUNC("e1000_check_polarity_ife");
/*
* Polarity is determined based on the reversal feature being enabled.
*/
if (phy->polarity_correction) {
} else {
}
if (!ret_val)
return (ret_val);
}
/*
* e1000_wait_autoneg_generic - Wait for auto-neg completion
* @hw: pointer to the HW structure
*
* Waits for auto-negotiation to complete or for the auto-negotiation time
* limit to expire, which ever happens first.
*/
{
u16 i, phy_status;
DEBUGFUNC("e1000_wait_autoneg_generic");
return (E1000_SUCCESS);
/* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */
for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) {
if (ret_val)
break;
if (ret_val)
break;
break;
msec_delay(100);
}
/*
* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation has
* completed.
*/
return (ret_val);
}
/*
* e1000_phy_has_link_generic - Polls PHY for link
* @hw: pointer to the HW structure
* @iterations: number of times to poll for link
* @usec_interval: delay between polling attempts
* @success: pointer to whether polling was successful or not
*
* Polls the PHY status register for link, 'iterations' number of times.
*/
{
u16 i, phy_status;
DEBUGFUNC("e1000_phy_has_link_generic");
return (E1000_SUCCESS);
for (i = 0; i < iterations; i++) {
/*
* Some PHYs require the PHY_STATUS register to be read twice
* due to the link bit being sticky. No harm doing it across
* the board.
*/
if (ret_val) {
/*
* If the first read fails, another entity may have
* ownership of the resources, wait and try again to
* see if they have relinquished the resources yet.
*/
}
if (ret_val)
break;
if (phy_status & MII_SR_LINK_STATUS)
break;
if (usec_interval >= 1000)
else
}
*success = (i < iterations) ? true : false;
return (ret_val);
}
/*
* e1000_get_cable_length_m88 - Determine cable length for m88 PHY
* @hw: pointer to the HW structure
*
* Reads the PHY specific status register to retrieve the cable length
* information. The cable length is determined by averaging the minimum and
* maximum values to get the "average" cable length. The m88 PHY has four
* possible cable length values, which are:
* Register Value Cable Length
* 0 < 50 meters
* 1 50 - 80 meters
* 2 80 - 110 meters
* 3 110 - 140 meters
* 4 > 140 meters
*/
{
DEBUGFUNC("e1000_get_cable_length_m88");
if (ret_val)
goto out;
goto out;
}
out:
return (ret_val);
}
/*
* e1000_get_cable_length_igp_2 - Determine cable length for igp2 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_2");
/* Read the AGC registers for all channels */
for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
if (ret_val)
goto out;
/*
* Getting bits 15:9, which represent the combination of
* coarse and fine gain values. The result is a number that
* can be put into the lookup table to obtain the approximate
* cable length.
*/
/* Array index bound check. */
if ((cur_agc_index >= IGP02E1000_CABLE_LENGTH_TABLE_SIZE) ||
(cur_agc_index == 0)) {
ret_val = -E1000_ERR_PHY;
goto out;
}
/* Remove min & max AGC values from calculation. */
}
/* Calculate cable length with the error range of +/- 10 meters. */
(agc_value - IGP02E1000_AGC_RANGE) : 0;
out:
return (ret_val);
}
/*
* e1000_get_phy_info_m88 - Retrieve PHY information
* @hw: pointer to the HW structure
*
* Valid for only copper links. Read the PHY status register (sticky read)
* to verify that link is up. Read the PHY special control register to
* determine the polarity and 10base-T extended distance. Read the PHY
* speed is 1000, then determine cable length, local and remote receiver.
*/
{
bool link;
DEBUGFUNC("e1000_get_phy_info_m88");
DEBUGOUT("Phy info is only valid for copper media\n");
goto out;
}
if (ret_val)
goto out;
if (!link) {
DEBUGOUT("Phy info is only valid if link is up\n");
goto out;
}
if (ret_val)
goto out;
? true
: false;
if (ret_val)
goto out;
if (ret_val)
goto out;
if (ret_val)
goto out;
if (ret_val)
goto out;
} else {
/* Set values to "undefined" */
}
out:
return (ret_val);
}
/*
* e1000_get_phy_info_igp - Retrieve igp PHY information
* @hw: pointer to the HW structure
*
* Read PHY status to determine if link is up. If link is up, then
* determine on the cable length, local and remote receiver.
*/
{
bool link;
DEBUGFUNC("e1000_get_phy_info_igp");
if (ret_val)
goto out;
if (!link) {
DEBUGOUT("Phy info is only valid if link is up\n");
goto out;
}
phy->polarity_correction = true;
if (ret_val)
goto out;
if (ret_val)
goto out;
if ((data & IGP01E1000_PSSR_SPEED_MASK) ==
if (ret_val)
goto out;
if (ret_val)
goto out;
} else {
}
out:
return (ret_val);
}
/*
* e1000_phy_sw_reset_generic - PHY software reset
* @hw: pointer to the HW structure
*
* Does a software reset of the PHY by reading the PHY control register and
*/
{
DEBUGFUNC("e1000_phy_sw_reset_generic");
goto out;
if (ret_val)
goto out;
phy_ctrl |= MII_CR_RESET;
if (ret_val)
goto out;
usec_delay(1);
out:
return (ret_val);
}
/*
* e1000_phy_hw_reset_generic - 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_generic");
if (ret_val) {
goto out;
}
if (ret_val)
goto out;
usec_delay(150);
out:
return (ret_val);
}
/*
* e1000_get_cfg_done_generic - Generic configuration done
* @hw: pointer to the HW structure
*
* Generic function to wait 10 milli-seconds for configuration to complete
* and return success.
*/
{
DEBUGFUNC("e1000_get_cfg_done_generic");
msec_delay_irq(10);
return (E1000_SUCCESS);
}
/*
* e1000_phy_init_script_igp3 - Inits the IGP3 PHY
* @hw: pointer to the HW structure
*
* Initializes a Intel Gigabit PHY3 when an EEPROM is not present.
*/
{
DEBUGOUT("Running IGP 3 PHY init script\n");
/* PHY init IGP 3 */
/* Remove all caps from Replica path filter */
/* Bias trimming for ADC, AFE and Driver (Default) */
/* Increase Hybrid poly bias */
/* Add 4% to TX amplitude in Giga mode */
/* Disable trimming (TTT) */
/* Poly DC correction to 94.6% + 2% for all channels */
/* ABS DC correction to 95.9% */
/* BG temp curve trim */
/* Increasing ADC OPAMP stage 1 currents to max */
/* Force 1000 ( required for enabling PHY regs configuration) */
/* Set upd_freq to 6 */
/* Disable NPDFE */
/* Disable adaptive fixed FFE (Default) */
/* Enable FFE hysteresis */
/* Fixed FFE for short cable lengths */
/* Fixed FFE for medium cable lengths */
/* Fixed FFE for long cable lengths */
/* Enable Adaptive Clip Threshold */
/* AHT reset limit to 1 */
/* Set AHT master delay to 127 msec */
/* Set scan bits for AHT */
/* Set AHT Preset bits */
/* Change integ_factor of channel A to 3 */
/* Change prop_factor of channels BCD to 8 */
/* Change cg_icount + enable integbp for channels BCD */
/*
* Change cg_icount + enable integbp + change prop_factor_master to 8
* for channel A
*/
/* Disable AHT in Slave mode on channel A */
/*
* Enable LPLU and disable AN to 1000 in non-D0a states, Enable
* SPD+B2B
*/
/* Enable restart AN on an1000_dis change */
/* Enable wh_fifo read clock in 10/100 modes */
/* Restart AN, Speed selection is 1000 */
return (E1000_SUCCESS);
}
/*
* e1000_get_phy_type_from_id - Get PHY type from id
* @phy_id: phy_id read from the phy
*
* Returns the phy type from the id.
*/
enum e1000_phy_type
{
switch (phy_id) {
case M88E1000_I_PHY_ID:
case M88E1000_E_PHY_ID:
case M88E1111_I_PHY_ID:
case M88E1011_I_PHY_ID:
break;
case IGP01E1000_I_PHY_ID: /* IGP 1 & 2 share this */
break;
case GG82563_E_PHY_ID:
break;
case IGP03E1000_E_PHY_ID:
break;
case IFE_E_PHY_ID:
case IFE_PLUS_E_PHY_ID:
case IFE_C_E_PHY_ID:
break;
case BME1000_E_PHY_ID:
case BME1000_E_PHY_ID_R2:
break;
case I82578_E_PHY_ID:
break;
case I82577_E_PHY_ID:
break;
default:
break;
}
return (phy_type);
}
/*
* e1000_determine_phy_address - Determines PHY address.
* @hw: pointer to the HW structure
*
* This uses a trial and error method to loop through possible PHY
* addresses. It tests each by reading the PHY ID registers and
* checking for a match.
*/
{
u32 i;
i = 0;
do {
(void) e1000_get_phy_id(hw);
/*
* If phy_type is valid, break - we found our
* PHY address
*/
if (phy_type != e1000_phy_unknown) {
goto out;
}
msec_delay(1);
i++;
} while (i < 10);
}
out:
return (ret_val);
}
/*
* e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
* @page: page to access
*
* Returns the phy address for the page requested.
*/
static u32
{
phy_addr = 1;
return (phy_addr);
}
/*
* e1000_write_phy_reg_bm - Write BM PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquires semaphore, if necessary, then writes the data to PHY register
* at the offset. Release any acquired semaphores before exiting.
*/
{
u32 page_select = 0;
u32 page_shift = 0;
DEBUGFUNC("e1000_write_phy_reg_bm");
if (ret_val)
goto out;
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
/*
* Page select is register 31 for phy address 1 and 22 for phy
* address 2 and 3. Page select is shifted only for phy
* address 1.
*/
} else {
page_shift = 0;
}
/* Page is shifted left, PHY expects (page x 32) */
(page << page_shift));
if (ret_val)
goto out;
}
data);
out:
return (ret_val);
}
/*
* e1000_read_phy_reg_bm - Read BM PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquires semaphore, if necessary, then reads the PHY register at offset
* and storing the retrieved information in data. Release any acquired
* semaphores before exiting.
*/
{
u32 page_select = 0;
u32 page_shift = 0;
DEBUGFUNC("e1000_read_phy_reg_bm");
if (ret_val)
goto out;
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
/*
* Page select is register 31 for phy address 1 and 22 for phy
* address 2 and 3. Page select is shifted only for phy
* address 1.
*/
} else {
page_shift = 0;
}
/* Page is shifted left, PHY expects (page x 32) */
(page << page_shift));
if (ret_val)
goto out;
}
data);
out:
return (ret_val);
}
/*
* e1000_read_phy_reg_bm2 - Read BM PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquires semaphore, if necessary, then reads the PHY register at offset
* and storing the retrieved information in data. Release any acquired
* semaphores before exiting.
*/
{
DEBUGFUNC("e1000_write_phy_reg_bm2");
if (ret_val)
goto out;
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
true);
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
/* Page is shifted left, PHY expects (page x 32) */
page);
if (ret_val)
goto out;
}
data);
out:
return (ret_val);
}
/*
* e1000_write_phy_reg_bm2 - Write BM PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquires semaphore, if necessary, then writes the data to PHY register
* at the offset. Release any acquired semaphores before exiting.
*/
{
DEBUGFUNC("e1000_write_phy_reg_bm2");
if (ret_val)
goto out;
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
false);
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
/* Page is shifted left, PHY expects (page x 32) */
page);
if (ret_val)
goto out;
}
data);
out:
return (ret_val);
}
/*
* e1000_access_phy_wakeup_reg_bm - Read BM PHY wakeup register
* @hw: pointer to the HW structure
* @offset: register offset to be read or written
* @data: pointer to the data to read or write
* @read: determines if operation is read or write
*
* Acquires semaphore, if necessary, then reads the PHY register at offset
* and storing the retrieved information in data. Release any acquired
* semaphores before exiting. Note that procedure to read the wakeup
* registers are different. It works as such:
* 1) Set page 769, register 17, bit 2 = 1
* 2) Set page to 800 for host (801 if we were manageability)
* 3) Write the address using the address opcode (0x11)
* 4) Read or write the data using the data opcode (0x12)
* 5) Restore 769_17.2 to its original value
*
* Assumes semaphore already acquired.
*/
static s32
{
DEBUGFUNC("e1000_access_phy_wakeup_reg_bm");
/* Gig must be disabled for MDIO accesses to page 800 */
DEBUGOUT("Attempting to access page 800 while gig enabled.\n");
/* All operations in this function are phy address 1 */
/* Set page 769 */
(BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
if (ret_val) {
DEBUGOUT("Could not read PHY page 769\n");
goto out;
}
/* First clear bit 4 to avoid a power state change */
phy_reg &= ~(BM_WUC_HOST_WU_BIT);
if (ret_val) {
DEBUGOUT("Could not clear PHY page 769 bit 4\n");
goto out;
}
/* Write bit 2 = 1, and clear bit 4 to 769_17 */
if (ret_val) {
DEBUGOUT("Could not write PHY page 769 bit 2\n");
goto out;
}
/* Select page 800 */
(BM_WUC_PAGE << IGP_PAGE_SHIFT));
/* Write the page 800 offset value using opcode 0x11 */
if (ret_val) {
DEBUGOUT("Could not write address opcode to page 800\n");
goto out;
}
if (read) {
/* Read the page 800 value using opcode 0x12 */
data);
} else {
/* Write the page 800 value using opcode 0x12 */
*data);
}
if (ret_val) {
DEBUGOUT("Could not access data value from page 800\n");
goto out;
}
/*
* Restore 769_17.2 to its original value Set page 769
*/
(BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
/* Clear 769_17.2 */
if (ret_val) {
DEBUGOUT("Could not clear PHY page 769 bit 2\n");
goto out;
}
out:
return (ret_val);
}
/*
* e1000_power_up_phy_copper - Restore copper 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, restore the link to previous
* settings.
*/
void
{
mii_reg &= ~MII_CR_POWER_DOWN;
}
/*
* e1000_power_down_phy_copper - Restore copper 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, restore the link to previous
* settings.
*/
void
{
msec_delay(1);
}
/*
* e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
* @hw: pointer to the HW structure
* @slow: true for slow mode, false for normal mode
*
* Assumes semaphore already acquired.
*/
{
/* Set MDIO mode - page 769, register 16: 0x2580==slow, 0x2180==fast */
(BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT));
if (ret_val)
goto out;
if (ret_val)
goto out;
/* dummy read when reverting to fast mode - throw away result */
if (!slow)
out:
return (ret_val);
}
/*
* __e1000_read_phy_reg_hv - Read HV PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
* @locked: semaphore has already been acquired or not
*
* Acquires semaphore, if necessary, then reads the PHY register at offset
* and stores the retrieved information in data. Release any acquired
* semaphore before exiting.
*/
static s32
bool locked)
{
bool in_slow_mode = false;
DEBUGFUNC("e1000_read_phy_reg_hv");
if (!locked) {
if (ret_val)
return (ret_val);
}
/* Workaround failure in MDIO access while cable is disconnected */
if (ret_val)
goto out;
in_slow_mode = true;
}
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
data, true);
goto out;
}
data, true);
goto out;
}
if (page == HV_INTC_FC_PAGE_START)
page = 0;
if (reg > MAX_PHY_MULTI_PAGE_REG) {
/* Page is shifted left, PHY expects (page x 32) */
}
out:
/* Revert to MDIO fast mode, if applicable */
if (!locked)
return (ret_val);
}
/*
* e1000_read_phy_reg_hv - Read HV PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Acquires semaphore then reads the PHY register at offset and stores
* the retrieved information in data. Release the acquired semaphore
* before exiting.
*/
{
}
/*
* e1000_read_phy_reg_hv_locked - Read HV PHY register
* @hw: pointer to the HW structure
* @offset: register offset to be read
* @data: pointer to the read data
*
* Reads the PHY register at offset and stores the retrieved information
* in data. Assumes semaphore already acquired.
*/
{
}
/*
* __e1000_write_phy_reg_hv - Write HV PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
* @locked: semaphore has already been acquired or not
*
* Acquires semaphore, if necessary, then writes the data to PHY register
* at the offset. Release any acquired semaphores before exiting.
*/
static s32
bool locked)
{
bool in_slow_mode = false;
DEBUGFUNC("e1000_write_phy_reg_hv");
if (!locked) {
if (ret_val)
return (ret_val);
}
/* Workaround failure in MDIO access while cable is disconnected */
if (ret_val)
goto out;
in_slow_mode = true;
}
/* Page 800 works differently than the rest so it has its own func */
if (page == BM_WUC_PAGE) {
&data, false);
goto out;
}
&data, false);
goto out;
}
/* The LCD Config workaround provides the phy address to use */
if (dev_spec->nvm_lcd_config_enabled == false)
if (page == HV_INTC_FC_PAGE_START)
page = 0;
/*
* Workaround MDIO accesses being disabled after entering IEEE Power
* Down (whenever bit 11 of the PHY Control register is set)
*/
((MAX_PHY_REG_ADDRESS & reg) == 0) &&
&data2, false);
if (ret_val)
goto out;
}
if (reg > MAX_PHY_MULTI_PAGE_REG) {
/* Page is shifted left, PHY expects (page x 32) */
}
data);
out:
/* Revert to MDIO fast mode, if applicable */
if (!locked)
return (ret_val);
}
/*
* e1000_write_phy_reg_hv - Write HV PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Acquires semaphore then writes the data to PHY register at the offset.
* Release the acquired semaphores before exiting.
*/
{
}
/*
* e1000_write_phy_reg_hv_locked - Write HV PHY register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write at register offset
*
* Writes the data to PHY register at the offset. Assumes semaphore
* already acquired.
*/
{
}
/*
* e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page
* @page: page to be accessed
*/
static u32
{
if (page >= HV_INTC_FC_PAGE_START)
phy_addr = 1;
return (phy_addr);
}
/*
* e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
* @hw: pointer to the HW structure
* @offset: register offset to be read or written
* @data: pointer to the data to be read or written
* @read: determines if operation is read or written
*
* Reads the PHY register at offset and stores the retreived information
* in data. Assumes semaphore already acquired. Note that the procedure
*/
static s32
{
DEBUGFUNC("e1000_access_phy_debug_regs_hv");
/* This takes care of the difference with desktop vs mobile phy */
/* All operations in this function are phy address 2 */
/* masking with 0x3F to remove the page from offset */
if (ret_val) {
DEBUGOUT("Could not write PHY the HV address register\n");
goto out;
}
/* Read or write the data value next */
if (read)
else
if (ret_val) {
DEBUGOUT("Could not read data value from HV data register\n");
goto out;
}
out:
return (ret_val);
}
/*
* e1000_link_stall_workaround_hv - Si workaround
* @hw: pointer to the HW structure
*
* This function works around a Si bug where the link partner can get
* a link up indication before the PHY does. If small packets are sent
* by the link partner they can be placed in the packet buffer without
* being properly accounted for by the PHY and will stall preventing
* further packets from being received. The workaround is to clear the
* packet buffer after the PHY detects link up.
*/
{
DEBUGFUNC("e1000_link_stall_workaround_hv");
goto out;
/* Do not apply workaround if in PHY loopback bit 14 set */
if (data & PHY_CONTROL_LB)
goto out;
/* check if link is up and at 1Gbps */
if (ret_val)
goto out;
data &= BM_CS_STATUS_LINK_UP |
if (data != (BM_CS_STATUS_LINK_UP |
goto out;
msec_delay(200);
/* flush the packets in the fifo buffer */
if (ret_val)
goto out;
out:
return (ret_val);
}
/*
* e1000_check_polarity_82577 - Checks the polarity.
* @hw: pointer to the HW structure
*
* Success returns 0, Failure returns -E1000_ERR_PHY (-2)
*
* Polarity is determined based on the PHY specific status register.
*/
{
DEBUGFUNC("e1000_check_polarity_82577");
if (!ret_val)
return (ret_val);
}
/*
* @hw: pointer to the HW structure
*
* Calls the PHY setup function to force speed and duplex. Clears the
* auto-crossover to force MDI manually. Waits for link and returns
* successful if link up is successful, else -E1000_ERR_PHY (-2).
*/
{
bool link;
DEBUGFUNC("e1000_phy_force_speed_duplex_82577");
if (ret_val)
goto out;
if (ret_val)
goto out;
/*
* Clear Auto-Crossover to force MDI manually. 82577 requires MDI
* forced whenever speed and duplex are forced.
*/
if (ret_val)
goto out;
if (ret_val)
goto out;
usec_delay(1);
if (phy->autoneg_wait_to_complete) {
if (ret_val)
goto out;
if (!link)
DEBUGOUT("Link taking longer than expected.\n");
/* Try once more */
if (ret_val)
goto out;
}
out:
return (ret_val);
}
/*
* e1000_get_phy_info_82577 - Retrieve I82577 PHY information
* @hw: pointer to the HW structure
*
* Read PHY status to determine if link is up. If link is up, then
* determine on the cable length, local and remote receiver.
*/
{
bool link;
DEBUGFUNC("e1000_get_phy_info_82577");
if (ret_val)
goto out;
if (!link) {
DEBUGOUT("Phy info is only valid if link is up\n");
goto out;
}
phy->polarity_correction = true;
if (ret_val)
goto out;
if (ret_val)
goto out;
if ((data & I82577_PHY_STATUS2_SPEED_MASK) ==
if (ret_val)
goto out;
if (ret_val)
goto out;
} else {
}
out:
return (ret_val);
}
/*
* e1000_get_cable_length_82577 - Determine cable length for 82577 PHY
* @hw: pointer to the HW structure
*
* Reads the diagnostic status register and verifies result is valid before
* placing it in the phy_cable_length field.
*/
{
DEBUGFUNC("e1000_get_cable_length_82577");
if (ret_val)
goto out;
if (length == E1000_CABLE_LENGTH_UNDEFINED)
out:
return (ret_val);
}