net: bcmgenet: power up and down integrated GPHY when unused
authorFlorian Fainelli <f.fainelli@gmail.com>
Mon, 23 Mar 2015 22:09:56 +0000 (15:09 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Mar 2015 02:10:43 +0000 (22:10 -0400)
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>
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/genet/bcmgenet.h
drivers/net/ethernet/broadcom/genet/bcmmii.c

index f86837f..c6b15c3 100644 (file)
@@ -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:
@@ -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);
@@ -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);
 
index a27ef77..7a59879 100644 (file)
@@ -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 */
index 3320219..6d3b66a 100644 (file)
@@ -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;