24 #include <linux/module.h>
25 #include <linux/list.h>
30 #include <linux/slab.h>
35 #include <asm/suspend.h>
36 #include <asm/system_misc.h>
70 static int (*_omap_save_secure_sram)(
u32 *
addr);
76 static void omap3_core_save_context(
void)
78 omap3_ctrl_save_padconf();
88 omap_intc_save_context();
92 omap3_control_save_context();
96 static void omap3_core_restore_context(
void)
99 omap3_control_restore_context();
103 omap_intc_restore_context();
113 static void omap3_save_secure_ram_context(
void)
125 ret = _omap_save_secure_sram((
u32 *)
126 __pa(omap3_secure_ram_storage));
130 pr_err(
"save_secure_sram() returns %08x\n", ret);
153 u16 grpsel_off = (regs == 3) ?
159 wkst &= ~ignore_bits;
175 wkst &= ~ignore_bits;
189 c = prcm_clear_mod_irqs(
WKUP_MOD, 1,
195 static irqreturn_t _prcm_int_handle_wakeup(
int irq,
void *unused)
204 c = prcm_clear_mod_irqs(
WKUP_MOD, 1,
206 c += prcm_clear_mod_irqs(
CORE_MOD, 1, 0);
209 c += prcm_clear_mod_irqs(
CORE_MOD, 3, 0);
216 static void omap34xx_save_context(
u32 *save)
221 asm(
"mrc p15, 0, %0, c1, c0, 1" :
"=r" (
val));
226 asm(
"mrc p15, 1, %0, c9, c0, 2" :
"=r" (
val));
231 static int omap34xx_do_sram_idle(
unsigned long save_state)
254 switch (mpu_next_state) {
265 pr_err(
"Invalid mpu state in sram_idle\n");
288 omap3_core_save_context();
293 omap3_intc_prepare_idle();
313 omap34xx_save_context(omap3_arm_context);
314 if (save_state == 1 || save_state == 3)
317 omap34xx_do_sram_idle(save_state);
330 omap3_core_restore_context();
340 omap3_intc_resume_idle();
349 static void omap3_pm_idle(
void)
368 #ifdef CONFIG_SUSPEND
369 static int omap3_pm_suspend(
void)
385 omap3_intc_suspend();
393 if (state > pwrst->next_state) {
394 pr_info(
"Powerdomain (%s) didn't enter target state %d\n",
395 pwrst->pwrdm->name, pwrst->next_state);
401 pr_err(
"Could not enter target state in pm_suspend\n");
403 pr_info(
"Successfully put all powerdomains to target state\n");
421 static void __init omap3_iva_idle(
void)
458 static void __init omap3_d2d_idle(
void)
466 mask = (1 << 4) | (1 << 3);
482 static void __init prcm_setup_regs(
void)
538 if (omap3_has_iva()) {
576 pwrst->
pwrdm == core_pwrdm &&
579 pr_warn(
"%s: Core OFF disabled due to errata i583\n",
593 if (pwrst->
pwrdm == pwrdm)
604 if (pwrst->
pwrdm == pwrdm) {
624 list_add(&pwrst->
node, &pwrst_list);
648 static void __init pm_errata_configure(
void)
653 enable_omap3630_toggle_l2_on_restore();
665 struct clockdomain *neon_clkdm, *mpu_clkdm, *per_clkdm, *wkup_clkdm;
668 if (!omap3_has_io_chain_ctrl())
669 pr_warning(
"PM: no software I/O chain control; some wakeups may be lost\n");
671 pm_errata_configure();
681 pr_err(
"pm: Failed to request pm_wkup irq\n");
692 pr_err(
"pm: Failed to request pm_io irq\n");
698 pr_err(
"Failed to setup powerdomains\n");
705 if (mpu_pwrdm ==
NULL) {
706 pr_err(
"Failed to get mpu_pwrdm\n");
720 #ifdef CONFIG_SUSPEND
733 omap3630_ctrl_disable_rta();
761 pr_err(
"Memory allocation failed when allocating for secure sram context\n");
767 omap3_save_secure_ram_context();