Commit 3cb6f10a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

sh: MTU2: Basic runtime PM support

Modify the SH MTU2 clock event device driver to support runtime PM at
a basic level (i.e. device clocks can be disabled and enabled, but
domain power must be on, because the device has to be marked as
"irq safe").
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarMagnus Damm <damm@opensource.se>
parent bad81383
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_domain.h> #include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
struct sh_mtu2_priv { struct sh_mtu2_priv {
void __iomem *mapbase; void __iomem *mapbase;
...@@ -123,6 +124,9 @@ static int sh_mtu2_enable(struct sh_mtu2_priv *p) ...@@ -123,6 +124,9 @@ static int sh_mtu2_enable(struct sh_mtu2_priv *p)
{ {
int ret; int ret;
pm_runtime_get_sync(&p->pdev->dev);
dev_pm_syscore_device(&p->pdev->dev, true);
/* enable clock */ /* enable clock */
ret = clk_enable(p->clk); ret = clk_enable(p->clk);
if (ret) { if (ret) {
...@@ -157,6 +161,9 @@ static void sh_mtu2_disable(struct sh_mtu2_priv *p) ...@@ -157,6 +161,9 @@ static void sh_mtu2_disable(struct sh_mtu2_priv *p)
/* stop clock */ /* stop clock */
clk_disable(p->clk); clk_disable(p->clk);
dev_pm_syscore_device(&p->pdev->dev, false);
pm_runtime_put(&p->pdev->dev);
} }
static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id) static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id)
...@@ -317,18 +324,17 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) ...@@ -317,18 +324,17 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
static int __devinit sh_mtu2_probe(struct platform_device *pdev) static int __devinit sh_mtu2_probe(struct platform_device *pdev)
{ {
struct sh_mtu2_priv *p = platform_get_drvdata(pdev); struct sh_mtu2_priv *p = platform_get_drvdata(pdev);
struct sh_timer_config *cfg = pdev->dev.platform_data;
int ret; int ret;
if (!is_early_platform_device(pdev)) { if (!is_early_platform_device(pdev)) {
struct sh_timer_config *cfg = pdev->dev.platform_data; pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
if (cfg->clockevent_rating)
dev_pm_syscore_device(&pdev->dev, true);
} }
if (p) { if (p) {
dev_info(&pdev->dev, "kept as earlytimer\n"); dev_info(&pdev->dev, "kept as earlytimer\n");
return 0; goto out;
} }
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kmalloc(sizeof(*p), GFP_KERNEL);
...@@ -341,8 +347,19 @@ static int __devinit sh_mtu2_probe(struct platform_device *pdev) ...@@ -341,8 +347,19 @@ static int __devinit sh_mtu2_probe(struct platform_device *pdev)
if (ret) { if (ret) {
kfree(p); kfree(p);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
pm_runtime_idle(&pdev->dev);
return ret;
} }
return ret; if (is_early_platform_device(pdev))
return 0;
out:
if (cfg->clockevent_rating)
pm_runtime_irq_safe(&pdev->dev);
else
pm_runtime_idle(&pdev->dev);
return 0;
} }
static int __devexit sh_mtu2_remove(struct platform_device *pdev) static int __devexit sh_mtu2_remove(struct platform_device *pdev)
......
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