]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ARM: OMAP2+: PM: share some suspend-related functions across OMAP2, 3, 4
authorPaul Walmsley <paul@pwsan.com>
Thu, 2 Feb 2012 09:30:50 +0000 (02:30 -0700)
committerKevin Hilman <khilman@ti.com>
Tue, 6 Mar 2012 00:01:19 +0000 (16:01 -0800)
The platform_suspend_ops can be shared across OMAP2, 3, and 4, along
with all of the functions referenced in that structure.  This patch
shares them.  It also removes the suspend_state file-scoped variable
in the OMAP2 and 3 PM code; it does not appear to be actually needed
by anything.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
[khilman@ti.com: minor rework needed due to rebase/merge with conflicting changes]
Signed-off-by: Kevin Hilman <khilman@ti.com>
arch/arm/mach-omap2/pm.c
arch/arm/mach-omap2/pm.h
arch/arm/mach-omap2/pm24xx.c
arch/arm/mach-omap2/pm34xx.c
arch/arm/mach-omap2/pm44xx.c

index f9e807958f3e9940e71c4a7620a583a883e354b2..28706696a341e0502b8c19d368a70bf099e74484 100644 (file)
 #include <linux/err.h>
 #include <linux/opp.h>
 #include <linux/export.h>
+#include <linux/suspend.h>
 
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
 #include "common.h"
 
+#include "prcm-common.h"
 #include "voltage.h"
 #include "powerdomain.h"
 #include "clockdomain.h"
 
 static struct omap_device_pm_latency *pm_lats;
 
+/*
+ * omap_pm_suspend: points to a function that does the SoC-specific
+ * suspend work
+ */
+int (*omap_pm_suspend)(void);
+
 static int __init _init_omap_device(char *name)
 {
        struct omap_hwmod *oh;
@@ -134,6 +142,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
        return ret;
 }
 
+
+
 /*
  * This API is to be called during init to set the various voltage
  * domains to the voltage as per the opp table. Typically we boot up
@@ -201,6 +211,56 @@ exit:
        return -EINVAL;
 }
 
+#ifdef CONFIG_SUSPEND
+static int omap_pm_enter(suspend_state_t suspend_state)
+{
+       int ret = 0;
+
+       if (!omap_pm_suspend)
+               return -ENOENT; /* XXX doublecheck */
+
+       switch (suspend_state) {
+       case PM_SUSPEND_STANDBY:
+       case PM_SUSPEND_MEM:
+               ret = omap_pm_suspend();
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       return ret;
+}
+
+static int omap_pm_begin(suspend_state_t state)
+{
+       disable_hlt();
+       if (cpu_is_omap34xx())
+               omap_prcm_irq_prepare();
+       return 0;
+}
+
+static void omap_pm_end(void)
+{
+       enable_hlt();
+       return;
+}
+
+static void omap_pm_finish(void)
+{
+       if (cpu_is_omap34xx())
+               omap_prcm_irq_complete();
+}
+
+static const struct platform_suspend_ops omap_pm_ops = {
+       .begin          = omap_pm_begin,
+       .end            = omap_pm_end,
+       .enter          = omap_pm_enter,
+       .finish         = omap_pm_finish,
+       .valid          = suspend_valid_only_mem,
+};
+
+#endif /* CONFIG_SUSPEND */
+
 static void __init omap3_init_voltages(void)
 {
        if (!cpu_is_omap34xx())
@@ -243,6 +303,10 @@ static int __init omap2_common_pm_late_init(void)
        /* Smartreflex device init */
        omap_devinit_smartreflex();
 
+#ifdef CONFIG_SUSPEND
+       suspend_set_ops(&omap_pm_ops);
+#endif
+
        return 0;
 }
 late_initcall(omap2_common_pm_late_init);
index eef67f67872e517d45c6aa0c9478af46f9d152d9..a0514310d15fa5af4029b74eb8056f22c1a5e89a 100644 (file)
@@ -23,6 +23,7 @@ extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
 extern int omap3_idle_init(void);
 extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
+extern int (*omap_pm_suspend)(void);
 
 #if defined(CONFIG_PM_OPP)
 extern int omap3_opp_init(void);
index c4fdde47742128fb34f0f873fd3adbe9863032b0..5ca45ca76946fa777a046e45443b74395d4e0238 100644 (file)
 #include "powerdomain.h"
 #include "clockdomain.h"
 
-#ifdef CONFIG_SUSPEND
-static suspend_state_t suspend_state = PM_SUSPEND_ON;
-static inline bool is_suspending(void)
-{
-       return (suspend_state != PM_SUSPEND_ON);
-}
-#else
-static inline bool is_suspending(void)
-{
-       return false;
-}
-#endif
-
 static void (*omap2_sram_idle)(void);
 static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl,
                                  void __iomem *sdrc_power);
@@ -84,7 +71,7 @@ static int omap2_fclks_active(void)
        return (f1 | f2) ? 1 : 0;
 }
 
-static void omap2_enter_full_retention(void)
+static int omap2_enter_full_retention(void)
 {
        u32 l;
 
@@ -147,6 +134,8 @@ no_sleep:
 
        /* Mask future PRCM-to-MPU interrupts */
        omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
+
+       return 0;
 }
 
 static int omap2_i2c_active(void)
@@ -243,46 +232,6 @@ out:
        local_fiq_enable();
 }
 
-#ifdef CONFIG_SUSPEND
-static int omap2_pm_begin(suspend_state_t state)
-{
-       disable_hlt();
-       suspend_state = state;
-       return 0;
-}
-
-static int omap2_pm_enter(suspend_state_t state)
-{
-       int ret = 0;
-
-       switch (state) {
-       case PM_SUSPEND_STANDBY:
-       case PM_SUSPEND_MEM:
-               omap2_enter_full_retention();
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-static void omap2_pm_end(void)
-{
-       suspend_state = PM_SUSPEND_ON;
-       enable_hlt();
-}
-
-static const struct platform_suspend_ops omap_pm_ops = {
-       .begin          = omap2_pm_begin,
-       .enter          = omap2_pm_enter,
-       .end            = omap2_pm_end,
-       .valid          = suspend_valid_only_mem,
-};
-#else
-static const struct platform_suspend_ops __initdata omap_pm_ops;
-#endif /* CONFIG_SUSPEND */
-
 static void __init prcm_setup_regs(void)
 {
        int i, num_mem_banks;
@@ -327,6 +276,10 @@ static void __init prcm_setup_regs(void)
        clkdm_for_each(omap_pm_clkdms_setup, NULL);
        clkdm_add_wkdep(mpu_clkdm, wkup_clkdm);
 
+#ifdef CONFIG_SUSPEND
+       omap_pm_suspend = omap2_enter_full_retention;
+#endif
+
        /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk
         * stabilisation */
        omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD,
@@ -427,7 +380,6 @@ static int __init omap2_pm_init(void)
                                                    omap24xx_cpu_suspend_sz);
        }
 
-       suspend_set_ops(&omap_pm_ops);
        arm_pm_idle = omap2_pm_idle;
 
        return 0;
index 5fc1a987fccc9ec0756d0628eb3e682a5882098e..da054370f83750600df3cfb0961d501336c83de3 100644 (file)
 #include "sdrc.h"
 #include "control.h"
 
-#ifdef CONFIG_SUSPEND
-static suspend_state_t suspend_state = PM_SUSPEND_ON;
-#endif
-
 /* pm34xx errata defined in pm.h */
 u16 pm34xx_errata;
 
@@ -472,50 +468,6 @@ restore:
        return ret;
 }
 
-static int omap3_pm_enter(suspend_state_t unused)
-{
-       int ret = 0;
-
-       switch (suspend_state) {
-       case PM_SUSPEND_STANDBY:
-       case PM_SUSPEND_MEM:
-               ret = omap3_pm_suspend();
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-/* Hooks to enable / disable UART interrupts during suspend */
-static int omap3_pm_begin(suspend_state_t state)
-{
-       disable_hlt();
-       suspend_state = state;
-       omap_prcm_irq_prepare();
-       return 0;
-}
-
-static void omap3_pm_end(void)
-{
-       suspend_state = PM_SUSPEND_ON;
-       enable_hlt();
-       return;
-}
-
-static void omap3_pm_finish(void)
-{
-       omap_prcm_irq_complete();
-}
-
-static const struct platform_suspend_ops omap_pm_ops = {
-       .begin          = omap3_pm_begin,
-       .end            = omap3_pm_end,
-       .enter          = omap3_pm_enter,
-       .finish         = omap3_pm_finish,
-       .valid          = suspend_valid_only_mem,
-};
 #endif /* CONFIG_SUSPEND */
 
 
@@ -823,8 +775,8 @@ static int __init omap3_pm_init(void)
        core_clkdm = clkdm_lookup("core_clkdm");
 
 #ifdef CONFIG_SUSPEND
-       suspend_set_ops(&omap_pm_ops);
-#endif /* CONFIG_SUSPEND */
+       omap_pm_suspend = omap3_pm_suspend;
+#endif
 
        arm_pm_idle = omap3_pm_idle;
        omap3_idle_init();
index 84d52f729af41ffb25782d5eae177796b77b9a84..91e0b1c9b76c6c594f4e4d3a200d090f32f5401a 100644 (file)
@@ -83,41 +83,6 @@ static int omap4_pm_suspend(void)
 
        return 0;
 }
-
-static int omap4_pm_enter(suspend_state_t suspend_state)
-{
-       int ret = 0;
-
-       switch (suspend_state) {
-       case PM_SUSPEND_STANDBY:
-       case PM_SUSPEND_MEM:
-               ret = omap4_pm_suspend();
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       return ret;
-}
-
-static int omap4_pm_begin(suspend_state_t state)
-{
-       disable_hlt();
-       return 0;
-}
-
-static void omap4_pm_end(void)
-{
-       enable_hlt();
-       return;
-}
-
-static const struct platform_suspend_ops omap_pm_ops = {
-       .begin          = omap4_pm_begin,
-       .end            = omap4_pm_end,
-       .enter          = omap4_pm_enter,
-       .valid          = suspend_valid_only_mem,
-};
 #endif /* CONFIG_SUSPEND */
 
 static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
@@ -234,8 +199,8 @@ static int __init omap4_pm_init(void)
        (void) clkdm_for_each(omap_pm_clkdms_setup, NULL);
 
 #ifdef CONFIG_SUSPEND
-       suspend_set_ops(&omap_pm_ops);
-#endif /* CONFIG_SUSPEND */
+       omap_pm_suspend = omap4_pm_suspend;
+#endif
 
        /* Overwrite the default cpu_do_idle() */
        arm_pm_idle = omap_default_idle;