Skip to content

Commit

Permalink
net: bcmgenet: power up and down integrated GPHY when unused
Browse files Browse the repository at this point in the history
Power up the GPHY while we are bringing-up the network interface, and
conversely, upon bring down, power the GPHY down. In order to avoid
creating hardware hazards, make sure that the GPHY gets powered on
during bcmgenet_open() prior to the UniMAC being reset as the UniMAC may
start creating activity towards the GPHY if we reverse the steps.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Mar 24, 2015
1 parent a9d608c commit a642c4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions drivers/net/ethernet/broadcom/genet/bcmgenet.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ static int bcmgenet_power_down(struct bcmgenet_priv *priv,
reg |= (EXT_PWR_DOWN_PHY |
EXT_PWR_DOWN_DLL | EXT_PWR_DOWN_BIAS);
bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);

bcmgenet_phy_power_set(priv->dev, false);
}
break;
default:
Expand Down Expand Up @@ -2465,9 +2467,6 @@ static void bcmgenet_netif_start(struct net_device *dev)

umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true);

if (phy_is_internal(priv->phydev))
bcmgenet_power_up(priv, GENET_POWER_PASSIVE);

netif_tx_start_all_queues(dev);

phy_start(priv->phydev);
Expand All @@ -2486,6 +2485,12 @@ static int bcmgenet_open(struct net_device *dev)
if (!IS_ERR(priv->clk))
clk_prepare_enable(priv->clk);

/* If this is an internal GPHY, power it back on now, before UniMAC is
* brought out of reset as absolutely no UniMAC activity is allowed
*/
if (phy_is_internal(priv->phydev))
bcmgenet_power_up(priv, GENET_POWER_PASSIVE);

/* take MAC out of reset */
bcmgenet_umac_reset(priv);

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/genet/bcmgenet.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ int bcmgenet_mii_init(struct net_device *dev);
int bcmgenet_mii_config(struct net_device *dev, bool init);
void bcmgenet_mii_exit(struct net_device *dev);
void bcmgenet_mii_reset(struct net_device *dev);
void bcmgenet_phy_power_set(struct net_device *dev, bool enable);
void bcmgenet_mii_setup(struct net_device *dev);

/* Wake-on-LAN routines */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/genet/bcmmii.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void bcmgenet_mii_reset(struct net_device *dev)
}
}

static void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
u32 reg = 0;
Expand Down

0 comments on commit a642c4f

Please sign in to comment.