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

driver: net: ethernet: davinci_mdio: runtime PM support

Enabling runtime PM support for davinci mdio driver
Signed-off-by: default avatarMugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ed36d7b2
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/davinci_emac.h> #include <linux/davinci_emac.h>
/* /*
...@@ -321,7 +322,9 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev) ...@@ -321,7 +322,9 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x", snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",
pdev->name, pdev->id); pdev->name, pdev->id);
data->clk = clk_get(dev, NULL); pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);
data->clk = clk_get(&pdev->dev, "fck");
if (IS_ERR(data->clk)) { if (IS_ERR(data->clk)) {
dev_err(dev, "failed to get device clock\n"); dev_err(dev, "failed to get device clock\n");
ret = PTR_ERR(data->clk); ret = PTR_ERR(data->clk);
...@@ -329,8 +332,6 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev) ...@@ -329,8 +332,6 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
goto bail_out; goto bail_out;
} }
clk_enable(data->clk);
dev_set_drvdata(dev, data); dev_set_drvdata(dev, data);
data->dev = dev; data->dev = dev;
spin_lock_init(&data->lock); spin_lock_init(&data->lock);
...@@ -378,10 +379,10 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev) ...@@ -378,10 +379,10 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
if (data->bus) if (data->bus)
mdiobus_free(data->bus); mdiobus_free(data->bus);
if (data->clk) { if (data->clk)
clk_disable(data->clk);
clk_put(data->clk); clk_put(data->clk);
} pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
kfree(data); kfree(data);
...@@ -396,10 +397,10 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev) ...@@ -396,10 +397,10 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev)
if (data->bus) if (data->bus)
mdiobus_free(data->bus); mdiobus_free(data->bus);
if (data->clk) { if (data->clk)
clk_disable(data->clk);
clk_put(data->clk); clk_put(data->clk);
} pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
...@@ -421,8 +422,7 @@ static int davinci_mdio_suspend(struct device *dev) ...@@ -421,8 +422,7 @@ static int davinci_mdio_suspend(struct device *dev)
__raw_writel(ctrl, &data->regs->control); __raw_writel(ctrl, &data->regs->control);
wait_for_idle(data); wait_for_idle(data);
if (data->clk) pm_runtime_put_sync(data->dev);
clk_disable(data->clk);
data->suspended = true; data->suspended = true;
spin_unlock(&data->lock); spin_unlock(&data->lock);
...@@ -436,8 +436,7 @@ static int davinci_mdio_resume(struct device *dev) ...@@ -436,8 +436,7 @@ static int davinci_mdio_resume(struct device *dev)
u32 ctrl; u32 ctrl;
spin_lock(&data->lock); spin_lock(&data->lock);
if (data->clk) pm_runtime_put_sync(data->dev);
clk_enable(data->clk);
/* restart the scan state machine */ /* restart the scan state machine */
ctrl = __raw_readl(&data->regs->control); ctrl = __raw_readl(&data->regs->control);
......
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