[PATCH 2/2] e100: power off PHY after reset when interface is down

From: Jiang Wang
Date: Thu Dec 15 2011 - 20:44:20 EST


PHYs supported by e100 re-starts auto-negotiation after writing to
BMCR_RESET bit. This patch powers down PHY when the interface is down
and reset is issued.

Signed-off-by: Jiang Wang <Jiang.Wang@xxxxxxxxxxxx>
---
drivers/net/ethernet/intel/e100.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index ca994da..2764cdd 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -589,6 +589,7 @@ struct nic {
multicast_all = (1 << 2),
wol_magic = (1 << 3),
ich_10h_workaround = (1 << 4),
+ powered_off = (1 << 5),
} flags ____cacheline_aligned;

enum mac mac;
@@ -1454,6 +1455,8 @@ static int e100_phy_init(struct nic *nic)
phy_data &= ~BMCR_PDOWN;
mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);

+ nic->flags &= ~powered_off;
+
/* Get phy ID */
id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);
id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2);
@@ -2273,6 +2276,7 @@ static void e100_down(struct nic *nic)
phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
phy_data |= BMCR_PDOWN;
mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
+ nic->flags |= powered_off;
}

free_irq(nic->pdev->irq, nic->netdev);
@@ -2383,6 +2387,13 @@ static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
err = mii_ethtool_sset(&nic->mii, cmd);
e100_exec_cb(nic, NULL, e100_configure);

+ if (nic->flags & powered_off) {
+ uint16_t phy_data;
+ phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
+ phy_data |= BMCR_PDOWN;
+ mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
+ }
+
return err;
}

--
1.7.1


-------------------------------------
Jiang Wang
Member of Technical Staff
Riverbed Technology
Tel: (408) 522-5109
Email: Jiang.Wang@xxxxxxxxxxxx
www.riverbed.com


-----Original Message-----
From: Jiang Wang [mailto:Jiang.Wang@xxxxxxxxxxxx]
Sent: Tuesday, December 13, 2011 6:50 PM
To: Jeff Kirsher; Jesse Brandeburg; Bruce Allan; Carolyn Wyborny; Don Skidmore; Greg Rose; Peter P Waskiewicz Jr; Alex Duyck; John Ronciak; e1000-devel@xxxxxxxxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
Cc: Prasanna Panchamukhi; Chaitanya Lala; Francis St. Amant; miles.ito@xxxxxxxxx; Jiang Wang
Subject: [PATCH 2/2] e100: power off PHY after reset when interface is down

PHYs supported by e100 re-starts auto-negotiation after writing to BMCR_RESET bit. This patch powers down PHY when the interface is down and reset is issued.

Signed-off-by: Jiang Wang <Jiang.Wang@xxxxxxxxxxxx>
---
drivers/net/ethernet/intel/e100.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 9824e0a..b8e4910 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -2386,6 +2386,13 @@ static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
err = mii_ethtool_sset(&nic->mii, cmd);
e100_exec_cb(nic, NULL, e100_configure);

+ if (!netif_running(netdev) && !(nic->flags & wol_magic)) {
+ uint16_t phy_data;
+ phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
+ phy_data |= BMCR_PDOWN;
+ mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
+ }
+
return err;
}

--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/