net: stmmac: dwmac-rk: add pd_gmac support for rk3399
authorDavid Wu <david.wu@rock-chips.com>
Thu, 1 Sep 2016 17:50:01 +0000 (01:50 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Sep 2016 00:08:57 +0000 (17:08 -0700)
Add the gmac power domain support for rk3399, in order to save more
power consumption.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

index e2ba6c4619fdef9e8a5fb8e882fff3402c9e013e..3740a4417fa0297c2631a08785dd9345e7cb0371 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/pm_runtime.h>
 
 #include "stmmac_platform.h"
 
@@ -883,11 +884,19 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv)
        if (ret)
                return ret;
 
+       pm_runtime_enable(dev);
+       pm_runtime_get_sync(dev);
+
        return 0;
 }
 
 static void rk_gmac_powerdown(struct rk_priv_data *gmac)
 {
+       struct device *dev = &gmac->pdev->dev;
+
+       pm_runtime_put_sync(dev);
+       pm_runtime_disable(dev);
+
        phy_power_on(gmac, false);
        gmac_clk_enable(gmac, false);
 }