ARM: OMAP2+: pm33xx-core: Add cpu_suspend to platform_data ops for pm33xx
authorDave Gerlach <d-gerlach@ti.com>
Fri, 2 Nov 2018 10:29:47 +0000 (15:59 +0530)
committerTero Kristo <t-kristo@ti.com>
Tue, 6 Nov 2018 13:25:29 +0000 (15:25 +0200)
Currently an soc_suspend function is exposed by the pm33xx platform code
but this contains additional operations needed for full SoC suspend
beyond what is needed for a relatively simple CPU suspend needed during
cpuidle. To get around this introduce cpu_suspend ops to be used by the
am335x and am437x PM driver for the last stage of cpuidle path.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
arch/arm/mach-omap2/pm33xx-core.c
include/linux/platform_data/pm33xx.h

index b16fed8911be696ef4609183c5e7512a4b12620b..a99b46f17d36854185033f7a08599b3d890cfd58 100644 (file)
@@ -185,6 +185,32 @@ static int am43xx_suspend(unsigned int state, int (*fn)(unsigned long),
        return ret;
 }
 
+static int am33xx_cpu_suspend(int (*fn)(unsigned long), unsigned long args)
+{
+       int ret = 0;
+
+       if (omap_irq_pending() || need_resched())
+               return ret;
+
+       ret = cpu_suspend(args, fn);
+
+       return ret;
+}
+
+static int am43xx_cpu_suspend(int (*fn)(unsigned long), unsigned long args)
+{
+       int ret = 0;
+
+       if (!scu_base)
+               return 0;
+
+       scu_power_mode(scu_base, SCU_PM_DORMANT);
+       ret = cpu_suspend(args, fn);
+       scu_power_mode(scu_base, SCU_PM_NORMAL);
+
+       return ret;
+}
+
 static struct am33xx_pm_sram_addr *amx3_get_sram_addrs(void)
 {
        if (soc_is_am33xx())
@@ -238,6 +264,7 @@ static void am43xx_prepare_rtc_resume(void)
 static struct am33xx_pm_platform_data am33xx_ops = {
        .init = am33xx_suspend_init,
        .soc_suspend = am33xx_suspend,
+       .cpu_suspend = am33xx_cpu_suspend,
        .get_sram_addrs = amx3_get_sram_addrs,
        .save_context = am33xx_save_context,
        .restore_context = am33xx_restore_context,
@@ -250,6 +277,7 @@ static struct am33xx_pm_platform_data am33xx_ops = {
 static struct am33xx_pm_platform_data am43xx_ops = {
        .init = am43xx_suspend_init,
        .soc_suspend = am43xx_suspend,
+       .cpu_suspend = am43xx_cpu_suspend,
        .get_sram_addrs = amx3_get_sram_addrs,
        .save_context = am43xx_save_context,
        .restore_context = am43xx_restore_context,
index dd5971937a643c0703563a6ba4fa353237b6696c..c595e0109fa1449298bc52cead8ffc10b0eeadd0 100644 (file)
@@ -49,6 +49,7 @@ struct am33xx_pm_platform_data {
        int     (*init)(void);
        int     (*soc_suspend)(unsigned int state, int (*fn)(unsigned long),
                               unsigned long args);
+       int     (*cpu_suspend)(int (*fn)(unsigned long), unsigned long args);
        struct  am33xx_pm_sram_addr *(*get_sram_addrs)(void);
        void __iomem *(*get_rtc_base_addr)(void);
        void (*save_context)(void);