From fe95c932a31e7f12bcb6a4e07434462da2ac6e1d Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Thu, 22 May 2014 20:00:04 +0200 Subject: [PATCH 1/4] drivers: sh: pm_runtime does not need idle callback In the runtime_pm idle callback the code assumes that a NULL .runtime_idle entry is the same as a .runtime_idle entry that returns 0 as a result. This means the entry in drivers/sh/pm_runtime can be removed in favour of just leaving the entry NULL. Signed-off-by: Ben Dooks Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Tested-by: Laurent Pinchart [r8a7779 legacy] Signed-off-by: Simon Horman --- drivers/sh/pm_runtime.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c index 10c65eb51f85..00b82ec94442 100644 --- a/drivers/sh/pm_runtime.c +++ b/drivers/sh/pm_runtime.c @@ -21,18 +21,10 @@ #include #ifdef CONFIG_PM_RUNTIME - -static int default_platform_runtime_idle(struct device *dev) -{ - /* suspend synchronously to disable clocks immediately */ - return 0; -} - static struct dev_pm_domain default_pm_domain = { .ops = { .runtime_suspend = pm_clk_suspend, .runtime_resume = pm_clk_resume, - .runtime_idle = default_platform_runtime_idle, USE_PLATFORM_PM_SLEEP_OPS }, }; From 39c5abbc54179998bf04368a11c561e19220d7d4 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 22 May 2014 20:00:06 +0200 Subject: [PATCH 2/4] drivers: sh: Restrict INTC_USERIMASK to SH4A register_intc_userimask() is called from sh4a code only. Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Tested-by: Laurent Pinchart [r8a7779 legacy] Signed-off-by: Simon Horman --- drivers/sh/intc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/sh/intc/Kconfig b/drivers/sh/intc/Kconfig index f7d90617c9d9..60228fae943f 100644 --- a/drivers/sh/intc/Kconfig +++ b/drivers/sh/intc/Kconfig @@ -6,7 +6,7 @@ comment "Interrupt controller options" config INTC_USERIMASK bool "Userspace interrupt masking support" - depends on ARCH_SHMOBILE || (SUPERH && CPU_SH4A) || COMPILE_TEST + depends on (SUPERH && CPU_SH4A) || COMPILE_TEST help This enables support for hardware-assisted userspace hardirq masking. From 8255fe169232364e5a01bd062e8037b8c1a9adec Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Thu, 22 May 2014 20:00:05 +0200 Subject: [PATCH 3/4] drivers: sh: pm_runtime implementation needs to suspend and resume devices If we override the platform bus calls for pm_runtime then we end up with the calls to the devices' suspend and resume methods ignored in favour of the bus ones. Change to calling the pm_runtime calls to suspend and resume the devices specifically in the drivers/sh/pm_runtime.c implementation to allow any device that may want to run power management to do so. Note, all the current sh driver implementations do not use their own power management code so this is not a major implementation issues. This also brings the implementation into line with the versions used by the Davinci and Keystone PM domain code, so once fully tested these implementations could be merged together. Signed-off-by: Ben Dooks Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Signed-off-by: Simon Horman --- drivers/sh/pm_runtime.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c index 00b82ec94442..25eafbe4da33 100644 --- a/drivers/sh/pm_runtime.c +++ b/drivers/sh/pm_runtime.c @@ -21,10 +21,43 @@ #include #ifdef CONFIG_PM_RUNTIME +static int sh_pm_runtime_suspend(struct device *dev) +{ + int ret; + + ret = pm_generic_runtime_suspend(dev); + if (ret) { + dev_err(dev, "failed to suspend device\n"); + return ret; + } + + ret = pm_clk_suspend(dev); + if (ret) { + dev_err(dev, "failed to suspend clock\n"); + pm_generic_runtime_resume(dev); + return ret; + } + + return 0; +} + +static int sh_pm_runtime_resume(struct device *dev) +{ + int ret; + + ret = pm_clk_resume(dev); + if (ret) { + dev_err(dev, "failed to resume clock\n"); + return ret; + } + + return pm_generic_runtime_resume(dev); +} + static struct dev_pm_domain default_pm_domain = { .ops = { - .runtime_suspend = pm_clk_suspend, - .runtime_resume = pm_clk_resume, + .runtime_suspend = sh_pm_runtime_suspend, + .runtime_resume = sh_pm_runtime_resume, USE_PLATFORM_PM_SLEEP_OPS }, }; From 2f35fb3c8a6018a0a5fe4a7fb0948b853c157256 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 27 May 2014 15:45:09 +0200 Subject: [PATCH 4/4] drivers: sh: Enable PM runtime for new R-Car Gen2 SoCs The PM runtime code should also be enabled for: - r8a7792 (R-Car V2H) - r8a7793 (R-Car M2-N) - r8a7794 (R-Car E2) Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- drivers/sh/pm_runtime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c index 25eafbe4da33..72f63817a1a0 100644 --- a/drivers/sh/pm_runtime.c +++ b/drivers/sh/pm_runtime.c @@ -88,6 +88,9 @@ static int __init sh_pm_runtime_init(void) !of_machine_is_compatible("renesas,r8a7779") && !of_machine_is_compatible("renesas,r8a7790") && !of_machine_is_compatible("renesas,r8a7791") && + !of_machine_is_compatible("renesas,r8a7792") && + !of_machine_is_compatible("renesas,r8a7793") && + !of_machine_is_compatible("renesas,r8a7794") && !of_machine_is_compatible("renesas,sh7372") && !of_machine_is_compatible("renesas,sh73a0")) return 0;