Commit 1416408d authored by Paul Walmsley's avatar Paul Walmsley Committed by Kevin Hilman

ARM: OMAP2+: PM: share some suspend-related functions across OMAP2, 3, 4

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: default avatarPaul Walmsley <paul@pwsan.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
[khilman@ti.com: minor rework needed due to rebase/merge with conflicting changes]
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent b7c39a3f
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/opp.h> #include <linux/opp.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/suspend.h>
#include <plat/omap-pm.h> #include <plat/omap-pm.h>
#include <plat/omap_device.h> #include <plat/omap_device.h>
#include "common.h" #include "common.h"
#include "prcm-common.h"
#include "voltage.h" #include "voltage.h"
#include "powerdomain.h" #include "powerdomain.h"
#include "clockdomain.h" #include "clockdomain.h"
...@@ -28,6 +30,12 @@ ...@@ -28,6 +30,12 @@
static struct omap_device_pm_latency *pm_lats; 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) static int __init _init_omap_device(char *name)
{ {
struct omap_hwmod *oh; struct omap_hwmod *oh;
...@@ -134,6 +142,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst) ...@@ -134,6 +142,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
return ret; return ret;
} }
/* /*
* This API is to be called during init to set the various voltage * 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 * domains to the voltage as per the opp table. Typically we boot up
...@@ -201,6 +211,56 @@ static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name, ...@@ -201,6 +211,56 @@ static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
return -EINVAL; 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) static void __init omap3_init_voltages(void)
{ {
if (!cpu_is_omap34xx()) if (!cpu_is_omap34xx())
...@@ -243,6 +303,10 @@ static int __init omap2_common_pm_late_init(void) ...@@ -243,6 +303,10 @@ static int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */ /* Smartreflex device init */
omap_devinit_smartreflex(); omap_devinit_smartreflex();
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
#endif
return 0; return 0;
} }
late_initcall(omap2_common_pm_late_init); late_initcall(omap2_common_pm_late_init);
...@@ -23,6 +23,7 @@ extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state); ...@@ -23,6 +23,7 @@ extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
extern int omap3_idle_init(void); extern int omap3_idle_init(void);
extern int omap4_idle_init(void); extern int omap4_idle_init(void);
extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused); extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
extern int (*omap_pm_suspend)(void);
#if defined(CONFIG_PM_OPP) #if defined(CONFIG_PM_OPP)
extern int omap3_opp_init(void); extern int omap3_opp_init(void);
......
...@@ -52,19 +52,6 @@ ...@@ -52,19 +52,6 @@
#include "powerdomain.h" #include "powerdomain.h"
#include "clockdomain.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_idle)(void);
static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl, static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl,
void __iomem *sdrc_power); void __iomem *sdrc_power);
...@@ -84,7 +71,7 @@ static int omap2_fclks_active(void) ...@@ -84,7 +71,7 @@ static int omap2_fclks_active(void)
return (f1 | f2) ? 1 : 0; return (f1 | f2) ? 1 : 0;
} }
static void omap2_enter_full_retention(void) static int omap2_enter_full_retention(void)
{ {
u32 l; u32 l;
...@@ -147,6 +134,8 @@ static void omap2_enter_full_retention(void) ...@@ -147,6 +134,8 @@ static void omap2_enter_full_retention(void)
/* Mask future PRCM-to-MPU interrupts */ /* Mask future PRCM-to-MPU interrupts */
omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET); omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
return 0;
} }
static int omap2_i2c_active(void) static int omap2_i2c_active(void)
...@@ -243,46 +232,6 @@ static void omap2_pm_idle(void) ...@@ -243,46 +232,6 @@ static void omap2_pm_idle(void)
local_fiq_enable(); 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) static void __init prcm_setup_regs(void)
{ {
int i, num_mem_banks; int i, num_mem_banks;
...@@ -327,6 +276,10 @@ static void __init prcm_setup_regs(void) ...@@ -327,6 +276,10 @@ static void __init prcm_setup_regs(void)
clkdm_for_each(omap_pm_clkdms_setup, NULL); clkdm_for_each(omap_pm_clkdms_setup, NULL);
clkdm_add_wkdep(mpu_clkdm, wkup_clkdm); 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 /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk
* stabilisation */ * stabilisation */
omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD, omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD,
...@@ -427,7 +380,6 @@ static int __init omap2_pm_init(void) ...@@ -427,7 +380,6 @@ static int __init omap2_pm_init(void)
omap24xx_cpu_suspend_sz); omap24xx_cpu_suspend_sz);
} }
suspend_set_ops(&omap_pm_ops);
arm_pm_idle = omap2_pm_idle; arm_pm_idle = omap2_pm_idle;
return 0; return 0;
......
...@@ -50,10 +50,6 @@ ...@@ -50,10 +50,6 @@
#include "sdrc.h" #include "sdrc.h"
#include "control.h" #include "control.h"
#ifdef CONFIG_SUSPEND
static suspend_state_t suspend_state = PM_SUSPEND_ON;
#endif
/* pm34xx errata defined in pm.h */ /* pm34xx errata defined in pm.h */
u16 pm34xx_errata; u16 pm34xx_errata;
...@@ -472,50 +468,6 @@ static int omap3_pm_suspend(void) ...@@ -472,50 +468,6 @@ static int omap3_pm_suspend(void)
return ret; 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 */ #endif /* CONFIG_SUSPEND */
...@@ -823,8 +775,8 @@ static int __init omap3_pm_init(void) ...@@ -823,8 +775,8 @@ static int __init omap3_pm_init(void)
core_clkdm = clkdm_lookup("core_clkdm"); core_clkdm = clkdm_lookup("core_clkdm");
#ifdef CONFIG_SUSPEND #ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops); omap_pm_suspend = omap3_pm_suspend;
#endif /* CONFIG_SUSPEND */ #endif
arm_pm_idle = omap3_pm_idle; arm_pm_idle = omap3_pm_idle;
omap3_idle_init(); omap3_idle_init();
......
...@@ -83,41 +83,6 @@ static int omap4_pm_suspend(void) ...@@ -83,41 +83,6 @@ static int omap4_pm_suspend(void)
return 0; 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 */ #endif /* CONFIG_SUSPEND */
static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
...@@ -234,8 +199,8 @@ static int __init omap4_pm_init(void) ...@@ -234,8 +199,8 @@ static int __init omap4_pm_init(void)
(void) clkdm_for_each(omap_pm_clkdms_setup, NULL); (void) clkdm_for_each(omap_pm_clkdms_setup, NULL);
#ifdef CONFIG_SUSPEND #ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops); omap_pm_suspend = omap4_pm_suspend;
#endif /* CONFIG_SUSPEND */ #endif
/* Overwrite the default cpu_do_idle() */ /* Overwrite the default cpu_do_idle() */
arm_pm_idle = omap_default_idle; arm_pm_idle = omap_default_idle;
......
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