Commit f150bd7f authored by Mugunthan V N's avatar Mugunthan V N Committed by David S. Miller

driver: net: ethernet: cpsw: runtime PM support

Enabling runtime PM support for cpsw driver
Signed-off-by: default avatarMugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8e476d9d
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <linux/platform_data/cpsw.h> #include <linux/platform_data/cpsw.h>
...@@ -494,11 +495,7 @@ static int cpsw_ndo_open(struct net_device *ndev) ...@@ -494,11 +495,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
cpsw_intr_disable(priv); cpsw_intr_disable(priv);
netif_carrier_off(ndev); netif_carrier_off(ndev);
ret = clk_enable(priv->clk); pm_runtime_get_sync(&priv->pdev->dev);
if (ret < 0) {
dev_err(priv->dev, "unable to turn on device clock\n");
return ret;
}
reg = __raw_readl(&priv->regs->id_ver); reg = __raw_readl(&priv->regs->id_ver);
...@@ -569,7 +566,7 @@ static int cpsw_ndo_stop(struct net_device *ndev) ...@@ -569,7 +566,7 @@ static int cpsw_ndo_stop(struct net_device *ndev)
netif_carrier_off(priv->ndev); netif_carrier_off(priv->ndev);
cpsw_ale_stop(priv->ale); cpsw_ale_stop(priv->ale);
for_each_slave(priv, cpsw_slave_stop, priv); for_each_slave(priv, cpsw_slave_stop, priv);
clk_disable(priv->clk); pm_runtime_put_sync(&priv->pdev->dev);
return 0; return 0;
} }
...@@ -763,10 +760,12 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ...@@ -763,10 +760,12 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
for (i = 0; i < data->slaves; i++) for (i = 0; i < data->slaves; i++)
priv->slaves[i].slave_num = i; priv->slaves[i].slave_num = i;
priv->clk = clk_get(&pdev->dev, NULL); pm_runtime_enable(&pdev->dev);
priv->clk = clk_get(&pdev->dev, "fck");
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
dev_err(priv->dev, "failed to get device clock)\n"); dev_err(&pdev->dev, "fck is not found\n");
ret = -EBUSY; ret = -ENODEV;
goto clean_slave_ret;
} }
priv->cpsw_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->cpsw_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -935,6 +934,8 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ...@@ -935,6 +934,8 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
resource_size(priv->cpsw_res)); resource_size(priv->cpsw_res));
clean_clk_ret: clean_clk_ret:
clk_put(priv->clk); clk_put(priv->clk);
clean_slave_ret:
pm_runtime_disable(&pdev->dev);
kfree(priv->slaves); kfree(priv->slaves);
clean_ndev_ret: clean_ndev_ret:
free_netdev(ndev); free_netdev(ndev);
...@@ -959,6 +960,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev) ...@@ -959,6 +960,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
resource_size(priv->cpsw_res)); resource_size(priv->cpsw_res));
release_mem_region(priv->cpsw_ss_res->start, release_mem_region(priv->cpsw_ss_res->start,
resource_size(priv->cpsw_ss_res)); resource_size(priv->cpsw_ss_res));
pm_runtime_disable(&pdev->dev);
clk_put(priv->clk); clk_put(priv->clk);
kfree(priv->slaves); kfree(priv->slaves);
free_netdev(ndev); free_netdev(ndev);
...@@ -973,6 +975,8 @@ static int cpsw_suspend(struct device *dev) ...@@ -973,6 +975,8 @@ static int cpsw_suspend(struct device *dev)
if (netif_running(ndev)) if (netif_running(ndev))
cpsw_ndo_stop(ndev); cpsw_ndo_stop(ndev);
pm_runtime_put_sync(&pdev->dev);
return 0; return 0;
} }
...@@ -981,6 +985,7 @@ static int cpsw_resume(struct device *dev) ...@@ -981,6 +985,7 @@ static int cpsw_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
pm_runtime_get_sync(&pdev->dev);
if (netif_running(ndev)) if (netif_running(ndev))
cpsw_ndo_open(ndev); cpsw_ndo_open(ndev);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment