2009-05-28 17:56:16 +00:00
|
|
|
/*
|
|
|
|
* OMAP2/3 Power Management Routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Nokia Corporation
|
|
|
|
* Jouni Hogander
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
#ifndef __ARCH_ARM_MACH_OMAP2_PM_H
|
|
|
|
#define __ARCH_ARM_MACH_OMAP2_PM_H
|
|
|
|
|
2010-05-29 16:32:23 +00:00
|
|
|
#include <linux/err.h>
|
|
|
|
|
2010-12-22 04:05:16 +00:00
|
|
|
#include "powerdomain.h"
|
2008-10-15 15:13:48 +00:00
|
|
|
|
2012-05-10 10:02:57 +00:00
|
|
|
#ifdef CONFIG_CPU_IDLE
|
|
|
|
extern int __init omap3_idle_init(void);
|
|
|
|
extern int __init omap4_idle_init(void);
|
|
|
|
#else
|
|
|
|
static inline int omap3_idle_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int omap4_idle_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 10:15:00 +00:00
|
|
|
extern void *omap3_secure_ram_storage;
|
2009-10-06 21:25:09 +00:00
|
|
|
extern void omap3_pm_off_mode_enable(int);
|
2008-10-08 12:00:58 +00:00
|
|
|
extern void omap_sram_idle(void);
|
2012-02-02 09:38:50 +00:00
|
|
|
extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
|
2008-10-13 10:15:00 +00:00
|
|
|
|
2010-12-09 15:13:46 +00:00
|
|
|
#if defined(CONFIG_PM_OPP)
|
|
|
|
extern int omap3_opp_init(void);
|
2010-12-09 15:13:47 +00:00
|
|
|
extern int omap4_opp_init(void);
|
2010-12-09 15:13:46 +00:00
|
|
|
#else
|
|
|
|
static inline int omap3_opp_init(void)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-12-09 15:13:47 +00:00
|
|
|
static inline int omap4_opp_init(void)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-12-09 15:13:46 +00:00
|
|
|
#endif
|
|
|
|
|
2008-11-26 10:26:24 +00:00
|
|
|
extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
|
|
|
|
extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
|
|
|
|
|
2009-05-28 17:56:16 +00:00
|
|
|
#ifdef CONFIG_PM_DEBUG
|
2010-09-27 21:04:20 +00:00
|
|
|
extern u32 enable_off_mode;
|
2009-11-16 14:46:52 +00:00
|
|
|
#else
|
2010-09-27 21:04:20 +00:00
|
|
|
#define enable_off_mode 0
|
2009-11-16 14:46:52 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
|
2008-10-15 15:13:48 +00:00
|
|
|
extern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev);
|
2009-05-28 17:56:16 +00:00
|
|
|
#else
|
2008-10-15 15:13:48 +00:00
|
|
|
#define pm_dbg_update_time(pwrdm, prev) do {} while (0);
|
2009-05-28 17:56:16 +00:00
|
|
|
#endif /* CONFIG_PM_DEBUG */
|
|
|
|
|
2011-06-29 16:40:23 +00:00
|
|
|
/* 24xx */
|
2009-05-28 17:56:16 +00:00
|
|
|
extern void omap24xx_idle_loop_suspend(void);
|
2011-06-29 16:40:23 +00:00
|
|
|
extern unsigned int omap24xx_idle_loop_suspend_sz;
|
2009-05-28 17:56:16 +00:00
|
|
|
|
|
|
|
extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl,
|
|
|
|
void __iomem *sdrc_power);
|
2011-06-29 16:40:23 +00:00
|
|
|
extern unsigned int omap24xx_cpu_suspend_sz;
|
|
|
|
|
|
|
|
/* 3xxx */
|
2011-06-30 07:45:49 +00:00
|
|
|
extern void omap34xx_cpu_suspend(int save_state);
|
2009-05-28 17:56:16 +00:00
|
|
|
|
2011-06-29 16:40:23 +00:00
|
|
|
/* omap3_do_wfi function pointer and size, for copy to SRAM */
|
|
|
|
extern void omap3_do_wfi(void);
|
|
|
|
extern unsigned int omap3_do_wfi_sz;
|
|
|
|
/* ... and its pointer from SRAM after copy */
|
|
|
|
extern void (*omap3_do_wfi_sram)(void);
|
|
|
|
|
|
|
|
/* save_secure_ram_context function pointer and size, for copy to SRAM */
|
|
|
|
extern int save_secure_ram_context(u32 *addr);
|
2009-05-28 17:56:16 +00:00
|
|
|
extern unsigned int save_secure_ram_context_sz;
|
2011-06-29 16:40:23 +00:00
|
|
|
|
|
|
|
extern void omap3_save_scratchpad_contents(void);
|
2009-05-28 17:56:16 +00:00
|
|
|
|
2010-12-20 20:05:06 +00:00
|
|
|
#define PM_RTA_ERRATUM_i608 (1 << 0)
|
2010-12-20 20:05:09 +00:00
|
|
|
#define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)
|
2012-10-16 06:08:53 +00:00
|
|
|
#define PM_PER_MEMORIES_ERRATUM_i582 (1 << 2)
|
2010-12-20 20:05:06 +00:00
|
|
|
|
2010-12-20 20:05:05 +00:00
|
|
|
#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3)
|
|
|
|
extern u16 pm34xx_errata;
|
|
|
|
#define IS_PM34XX_ERRATUM(id) (pm34xx_errata & (id))
|
2010-12-20 20:05:07 +00:00
|
|
|
extern void enable_omap3630_toggle_l2_on_restore(void);
|
2010-12-20 20:05:05 +00:00
|
|
|
#else
|
|
|
|
#define IS_PM34XX_ERRATUM(id) 0
|
2010-12-20 20:05:07 +00:00
|
|
|
static inline void enable_omap3630_toggle_l2_on_restore(void) { }
|
2010-12-20 20:05:05 +00:00
|
|
|
#endif /* defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) */
|
|
|
|
|
ARM: OMAP4460: Workaround for ROM bug because of CA9 r2pX GIC control register change.
On OMAP4+ devices, GIC register context is lost when MPUSS hits
the OSWR(Open Switch Retention). On the CPU wakeup path, ROM code
gets executed and one of the steps in it is to restore the
saved context of the GIC. The ROM Code GIC distributor restoration
is split in two parts: CPU specific register done by each CPU and
common register done by only one CPU.
Below is the abstract flow.
...............................................................
- MPUSS in OSWR state.
- CPU0 wakes up on the event(interrupt) and start executing ROM code.
[..]
- CPU0 executes "GIC Restoration:"
[...]
- CPU0 swicthes to non-secure mode and jumps to OS resume code.
[...]
- CPU0 is online in OS
- CPU0 enables the GIC distributor. GICD.Enable Non-secure = 1
- CPU0 wakes up CPU1 with clock-domain force wakeup method.
- CPU0 continues it's execution.
[..]
- CPU1 wakes up and start executing ROM code.
[..]
- CPU1 executes "GIC Restoration:"
[..]
- CPU1 swicthes to non-secure mode and jumps to OS resume code.
[...]
- CPU1 is online in OS and start executing.
[...] -
GIC Restoration: /* Common routine for HS and GP devices */
{
if (GICD != 1) { /* This will be true in OSWR state */
if (GIC_SAR_BACKUP_STATE == SAVED)
- CPU restores GIC distributor
else
- reconfigure GIC distributor to boot values.
GICD.Enable secure = 1
}
if (GIC_SAR_BACKUP_STATE == SAVED)
- CPU restore its GIC CPU interface registers if saved.
else
- reconfigure its GIC CPU interface registers to boot
values.
}
...............................................................
So as mentioned in the flow, GICD != 1 condition decides how
the GIC registers are handled in ROM code wakeup path from
OSWR. As evident from the flow, ROM code relies on the entire
GICD register value and not specific register bits.
The assumption was valid till CortexA9 r1pX version since there
was only one banked bit to control secure and non-secure GICD.
Secure view which ROM code sees:
bit 0 == Enable Non-secure
Non-secure view which HLOS sees:
bit 0 == Enable secure
But GICD register has changed between CortexA9 r1pX and r2pX.
On r2pX GICD register is composed of 2 bits.
Secure view which ROM code sees:
bit 1 == Enable Non-secure
bit 0 == Enable secure
Non-secure view which HLOS sees:
bit 0 == Enable Non-secure
Hence on OMAP4460(r2pX) devices, if you go through the
above flow again during CPU1 wakeup, GICD == 3 and hence
ROM code fails to understand the real wakeup power state
and reconfigures GIC distributor to boot values. This is
nasty since you loose the entire interrupt controller
context in a live system.
The ROM code fix done on next OMAP4 device (OMAP4470 - r2px) is to
check "GICD.Enable secure != 1" for GIC restoration in OSWR wakeup path.
Since ROM code can't be fixed on OMAP4460 devices, a work around
needs to be implemented. As evident from the flow, as long as
CPU1 sees GICD == 1 in it's wakeup path from OSWR, the issue
won't happen. Below is the flow with the work-around.
...............................................................
- MPUSS in OSWR state.
- CPU0 wakes up on the event(interrupt) and start executing ROM code.
[..]
- CPU0 executes "GIC Restoration:"
[..]
- CPU0 swicthes to non-secure mode and jumps to OS resume code.
[..]
- CPU0 is online in OS.
- CPU0 does GICD.Enable Non-secure = 0
- CPU0 wakes up CPU1 with clock domain force wakeup method.
- CPU0 waits for GICD.Enable Non-secure = 1
- CPU0 coninues it's execution.
[..]
- CPU1 wakes up and start executing ROM code.
[..]
- CPU1 executes "GIC Restoration:"
[..]
- CPU1 swicthes to non-secure mode and jumps to OS resume code.
[..]
- CPU1 is online in OS
- CPU1 does GICD.Enable Non-secure = 1
- CPU1 start executing
[...]
...............................................................
With this procedure, the GIC configuration done between the
CPU0 wakeup and CPU1 wakeup will not be lost but during this
short windows, the CPU0 will not receive interrupts.
The BUG is applicable to only OMAP4460(r2pX) devices.
OMAP4470 (also r2pX) is not affected by this bug because
ROM code has been fixed.
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
2012-10-18 09:20:05 +00:00
|
|
|
#define PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD (1 << 0)
|
|
|
|
|
2014-03-12 21:43:20 +00:00
|
|
|
#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP4)
|
2012-10-18 09:20:04 +00:00
|
|
|
extern u16 pm44xx_errata;
|
|
|
|
#define IS_PM44XX_ERRATUM(id) (pm44xx_errata & (id))
|
|
|
|
#else
|
|
|
|
#define IS_PM44XX_ERRATUM(id) 0
|
|
|
|
#endif
|
|
|
|
|
2012-04-24 06:08:50 +00:00
|
|
|
#ifdef CONFIG_POWER_AVS_OMAP
|
2010-05-29 16:32:23 +00:00
|
|
|
extern int omap_devinit_smartreflex(void);
|
|
|
|
extern void omap_enable_smartreflex_on_init(void);
|
|
|
|
#else
|
|
|
|
static inline int omap_devinit_smartreflex(void)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void omap_enable_smartreflex_on_init(void) {}
|
|
|
|
#endif
|
|
|
|
|
2010-12-10 17:21:05 +00:00
|
|
|
#ifdef CONFIG_TWL4030_CORE
|
|
|
|
extern int omap3_twl_init(void);
|
2010-12-10 17:45:16 +00:00
|
|
|
extern int omap4_twl_init(void);
|
2011-02-15 07:58:58 +00:00
|
|
|
extern int omap3_twl_set_sr_bit(bool enable);
|
2010-12-10 17:21:05 +00:00
|
|
|
#else
|
|
|
|
static inline int omap3_twl_init(void)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-12-10 17:45:16 +00:00
|
|
|
static inline int omap4_twl_init(void)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-12-10 17:21:05 +00:00
|
|
|
#endif
|
|
|
|
|
2012-09-25 16:33:39 +00:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
extern void omap_pm_setup_oscillator(u32 tstart, u32 tshut);
|
|
|
|
extern void omap_pm_get_oscillator(u32 *tstart, u32 *tshut);
|
2012-09-25 16:33:48 +00:00
|
|
|
extern void omap_pm_setup_sr_i2c_pcb_length(u32 mm);
|
2012-09-25 16:33:39 +00:00
|
|
|
#else
|
|
|
|
static inline void omap_pm_setup_oscillator(u32 tstart, u32 tshut) { }
|
2012-11-15 01:13:04 +00:00
|
|
|
static inline void omap_pm_get_oscillator(u32 *tstart, u32 *tshut) { *tstart = *tshut = 0; }
|
2012-09-25 16:33:48 +00:00
|
|
|
static inline void omap_pm_setup_sr_i2c_pcb_length(u32 mm) { }
|
2012-09-25 16:33:39 +00:00
|
|
|
#endif
|
|
|
|
|
2014-05-12 18:33:21 +00:00
|
|
|
#ifdef CONFIG_SUSPEND
|
|
|
|
void omap_common_suspend_init(void *pm_suspend);
|
|
|
|
#else
|
|
|
|
static inline void omap_common_suspend_init(void *pm_suspend)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_SUSPEND */
|
2009-05-28 17:56:16 +00:00
|
|
|
#endif
|