Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 268538
b: refs/heads/master
c: 268420a
h: refs/heads/master
v: v3
  • Loading branch information
Mark Einon authored and Greg Kroah-Hartman committed Sep 27, 2011
1 parent b32540c commit 9aa25e7
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 185 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 66a0cc1a02054a53ae8e6d1af0870d4ab799416d
refs/heads/master: 268420aa840ce6d5c18035ce6d7ebc4244b2cb1f
167 changes: 0 additions & 167 deletions trunk/drivers/staging/et131x/et1310_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,68 +298,6 @@ void et1310_phy_power_down(struct et131x_adapter *adapter, bool down)
et131x_mii_write(adapter, MII_BMCR, data);
}

/**
* et1310_phy_link_status - read link state
* @adapter: device to read
* @link_status: reported link state
* @autoneg: reported autonegotiation state (complete/incomplete/disabled)
* @linkspeed: returnedlink speed in use
* @duplex_mode: reported half/full duplex state
* @mdi_mdix: not yet working
* @masterslave: report whether we are master or slave
* @polarity: link polarity
*
* I can read your lan like a magazine
* I see if your up
* I know your link speed
* I see all the setting that you'd rather keep
*/
static void et1310_phy_link_status(struct et131x_adapter *adapter,
u8 *link_status,
u32 *autoneg,
u32 *linkspeed,
u32 *duplex_mode,
u32 *mdi_mdix,
u32 *masterslave, u32 *polarity)
{
u16 mistatus = 0;
u16 is1000BaseT = 0;
u16 vmi_phystatus = 0;
u16 control = 0;

et131x_mii_read(adapter, MII_BMSR, &mistatus);
et131x_mii_read(adapter, MII_STAT1000, &is1000BaseT);
et131x_mii_read(adapter, PHY_PHY_STATUS, &vmi_phystatus);
et131x_mii_read(adapter, MII_BMCR, &control);

*link_status = (vmi_phystatus & ET_PHY_LSTATUS) ? 1 : 0;
*autoneg = (control & ET_PHY_AUTONEG_STATUS) ?
((vmi_phystatus & ET_PHY_AUTONEG_ENABLE) ?
TRUEPHY_ANEG_COMPLETE :
TRUEPHY_ANEG_NOT_COMPLETE) :
TRUEPHY_ANEG_DISABLED;
*linkspeed = (vmi_phystatus & ET_PHY_SPEED_STATUS) >> 8;
*duplex_mode = (vmi_phystatus & ET_PHY_DUPLEX_STATUS) >> 7;
/* NOTE: Need to complete this */
*mdi_mdix = 0;

*masterslave = (is1000BaseT & ET_1000BT_MSTR_SLV) ?
TRUEPHY_CFG_MASTER : TRUEPHY_CFG_SLAVE;
*polarity = (vmi_phystatus & ET_PHY_POLARITY_STATUS) ?
TRUEPHY_POLARITY_INVERTED : TRUEPHY_POLARITY_NORMAL;
}

static void et1310_phy_and_or_reg(struct et131x_adapter *adapter,
u16 regnum, u16 and_mask, u16 or_mask)
{
u16 reg;

et131x_mii_read(adapter, regnum, &reg);
reg &= and_mask;
reg |= or_mask;
et131x_mii_write(adapter, regnum, reg);
}

/* Still used from _mac for BIT_READ */
void et1310_phy_access_mii_bit(struct et131x_adapter *adapter, u16 action,
u16 regnum, u16 bitnum, u8 *value)
Expand Down Expand Up @@ -437,108 +375,3 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)
}
}

void et131x_mii_check(struct et131x_adapter *adapter,
u16 bmsr, u16 bmsr_ints)
{
struct phy_device *phydev = adapter->phydev;
u8 link_status;
u32 autoneg_status;
u32 speed;
u32 duplex;
u32 mdi_mdix;
u32 masterslave;
u32 polarity;

if (bmsr_ints & BMSR_LSTATUS) {
if (bmsr & BMSR_LSTATUS) {
adapter->boot_coma = 20;
} else {
dev_warn(&adapter->pdev->dev,
"Link down - cable problem ?\n");

if (phydev && phydev->speed == SPEED_10) {
/* NOTE - Is there a way to query this without
* TruePHY?
* && TRU_QueryCoreType(adapter->hTruePhy, 0) ==
* EMI_TRUEPHY_A13O) {
*/
u16 register18;

et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
&register18);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18 | 0x4);
et131x_mii_write(adapter, PHY_INDEX_REG,
register18 | 0x8402);
et131x_mii_write(adapter, PHY_DATA_REG,
register18 | 511);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18);
}

/* Free the packets being actively sent & stopped */
et131x_free_busy_send_packets(adapter);

/* Re-initialize the send structures */
et131x_init_send(adapter);

/* Reset the RFD list and re-start RU */
et131x_reset_recv(adapter);

/*
* Bring the device back to the state it was during
* init prior to autonegotiation being complete. This
* way, when we get the auto-neg complete interrupt,
* we can complete init by calling config_mac_regs2.
*/
et131x_soft_reset(adapter);

/* Setup ET1310 as per the documentation */
et131x_adapter_setup(adapter);
}
}

if (bmsr_ints & BMSR_ANEGCOMPLETE) {
if (bmsr & BMSR_ANEGCOMPLETE) {
et1310_phy_link_status(adapter,
&link_status, &autoneg_status,
&speed, &duplex, &mdi_mdix,
&masterslave, &polarity);

adapter->boot_coma = 20;

if (phydev && phydev->speed == SPEED_10) {
/*
* NOTE - Is there a way to query this without
* TruePHY?
* && TRU_QueryCoreType(adapter->hTruePhy, 0)==
* EMI_TRUEPHY_A13O) {
*/
u16 register18;

et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
&register18);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18 | 0x4);
et131x_mii_write(adapter, PHY_INDEX_REG,
register18 | 0x8402);
et131x_mii_write(adapter, PHY_DATA_REG,
register18 | 511);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18);
}

et1310_config_flow_control(adapter);

if (phydev && phydev->speed == SPEED_1000 &&
adapter->registry_jumbo_packet > 2048)
et1310_phy_and_or_reg(adapter, PHY_CONFIG,
~ET_PHY_CONFIG_TX_FIFO_DEPTH,
ET_PHY_CONFIG_FIFO_DEPTH_32);

et131x_set_rx_dma_timer(adapter);
et1310_config_mac_regs2(adapter);
}
}
}

115 changes: 98 additions & 17 deletions trunk/drivers/staging/et131x/et131x_initpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,29 +446,110 @@ static void et131x_adjust_link(struct net_device *netdev)
struct address_map __iomem *iomem = adapter->regs;

u32 pm_csr;
u16 bmsr_ints;
u16 bmsr_data;

/* If we are in coma mode, we need to disable it. */
pm_csr = readl(&iomem->global.pm_csr);
if (pm_csr & ET_PM_PHY_SW_COMA) {
/*
* Check to see if we are in coma mode and if
* so, disable it because we will not be able
* to read PHY values until we are out.
*/
et1310_disable_phy_coma(adapter);
if (netif_carrier_ok(netdev)) {
adapter->boot_coma = 20;

if (phydev && phydev->speed == SPEED_10) {
/*
* NOTE - Is there a way to query this without
* TruePHY?
* && TRU_QueryCoreType(adapter->hTruePhy, 0)==
* EMI_TRUEPHY_A13O) {
*/
u16 register18;

et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
&register18);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18 | 0x4);
et131x_mii_write(adapter, PHY_INDEX_REG,
register18 | 0x8402);
et131x_mii_write(adapter, PHY_DATA_REG,
register18 | 511);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18);
}

et1310_config_flow_control(adapter);

if (phydev && phydev->speed == SPEED_1000 &&
adapter->registry_jumbo_packet > 2048) {
u16 reg;

et131x_mii_read(adapter, PHY_CONFIG, &reg);
reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
et131x_mii_write(adapter, PHY_CONFIG, reg);
}

et131x_set_rx_dma_timer(adapter);
et1310_config_mac_regs2(adapter);
}

et131x_phy_mii_read(adapter, phydev->addr, MII_BMSR, &bmsr_data);
if (phydev->link != adapter->link) {
/* If we are in coma mode, we need to disable it. */
pm_csr = readl(&iomem->global.pm_csr);
if (pm_csr & ET_PM_PHY_SW_COMA) {
/*
* Check to see if we are in coma mode and if
* so, disable it because we will not be able
* to read PHY values until we are out.
*/
et1310_disable_phy_coma(adapter);
}

if (phydev->link) {
adapter->boot_coma = 20;
} else {
dev_warn(&adapter->pdev->dev,
"Link down - cable problem ?\n");

if (phydev && phydev->speed == SPEED_10) {
/* NOTE - Is there a way to query this without
* TruePHY?
* && TRU_QueryCoreType(adapter->hTruePhy, 0) ==
* EMI_TRUEPHY_A13O)
*/
u16 register18;

et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
&register18);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18 | 0x4);
et131x_mii_write(adapter, PHY_INDEX_REG,
register18 | 0x8402);
et131x_mii_write(adapter, PHY_DATA_REG,
register18 | 511);
et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
register18);
}

/* Free the packets being actively sent & stopped */
et131x_free_busy_send_packets(adapter);

/* Re-initialize the send structures */
et131x_init_send(adapter);

bmsr_ints = adapter->bmsr ^ bmsr_data;
adapter->bmsr = bmsr_data;
/* Reset the RFD list and re-start RU */
et131x_reset_recv(adapter);

/* Do all the cable in / cable out stuff */
et131x_mii_check(adapter, bmsr_data, bmsr_ints);
/*
* Bring the device back to the state it was during
* init prior to autonegotiation being complete. This
* way, when we get the auto-neg complete interrupt,
* we can complete init by calling config_mac_regs2.
*/
et131x_soft_reset(adapter);

phy_print_status(phydev);
/* Setup ET1310 as per the documentation */
et131x_adapter_setup(adapter);
}

adapter->link = phydev->link;

phy_print_status(phydev);
}
}

int et131x_mii_probe(struct net_device *netdev)
Expand Down

0 comments on commit 9aa25e7

Please sign in to comment.