fec: Handle the regulator in suspend/resume
authorFabio Estevam <fabio.estevam@freescale.com>
Mon, 27 May 2013 03:48:33 +0000 (03:48 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 May 2013 05:29:54 +0000 (22:29 -0700)
In order to save power, let's disable the regulator in the suspend function and
enable it in resume.

Tested on a mx28evk board.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/fec_main.c

index cac667db61becb77ee30e8a11ca4f564f0ac7aae..866b92220c151ccbe7a9f681ab8bef93fa4a8136 100644 (file)
@@ -2044,6 +2044,9 @@ fec_suspend(struct device *dev)
        clk_disable_unprepare(fep->clk_ahb);
        clk_disable_unprepare(fep->clk_ipg);
 
+       if (fep->reg_phy)
+               regulator_disable(fep->reg_phy);
+
        return 0;
 }
 
@@ -2052,6 +2055,13 @@ fec_resume(struct device *dev)
 {
        struct net_device *ndev = dev_get_drvdata(dev);
        struct fec_enet_private *fep = netdev_priv(ndev);
+       int ret;
+
+       if (fep->reg_phy) {
+               ret = regulator_enable(fep->reg_phy);
+               if (ret)
+                       return ret;
+       }
 
        clk_prepare_enable(fep->clk_enet_out);
        clk_prepare_enable(fep->clk_ahb);