OMAP3: run the ASM sleep code from DDR
From: Jean Pihet <[email protected]>
Most of the ASM sleep code (in arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there.
However only a small part of the code really needs to run from internal SRAM.
This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.
SRAM usage:
- original code:
. 560 bytes for omap3_sram_configure_core_dpll (used by DVFS), . 1368 bytes for omap_sram_idle (used by suspend/resume in RETention), . 124 bytes for es3_sdrc_fix (used by suspend/resume in OFF mode on ES3.x), . 108 bytes for save_secure_ram_context (used on HS parts).
With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the gain in SRAM usage for suspend/resume is > 1KB.
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
--- arch/arm/mach-omap2/pm.h | 19 ++- arch/arm/mach-omap2/pm34xx.c | 19 ++- arch/arm/mach-omap2/sleep34xx.S | 299 +++++++++++++++++++++++---------------- 3 files changed, 200 insertions(+), 137 deletions(-)
arch/arm/mach-omap2/pm.h +15 -4
@@ -87,18 +87,29 @@ extern int pm_dbg_regset_init(int reg_set);#define pm_dbg_regset_init (reg_set) do {} while (0);#endif /* CONFIG_PM_DEBUG */ +/* 24xx */ extern void omap24xx_idle_loop_suspend (void ); +extern unsigned int omap24xx_idle_loop_suspend_sz;extern void omap24xx_cpu_suspend (u32 dll_ctrl,void __iomem *sdrc_dlla_ctrl,void __iomem *sdrc_power); +extern unsigned int omap24xx_cpu_suspend_sz; + +/* 3xxx */ extern void omap34xx_cpu_suspend (u32 *addr,int save_state); + +/* 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 void save_secure_ram_context (u32 *addr); -extern void omap3_save_scratchpad_contents (void ); -extern unsigned int omap24xx_idle_loop_suspend_sz;extern unsigned int save_secure_ram_context_sz; -extern unsigned int omap24xx_cpu_suspend_sz; -extern unsigned int omap34xx_cpu_suspend_sz; + +extern void omap3_save_scratchpad_contents (void );#define PM_RTA_ERRATUM_i608 (1 << 0)#define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)
arch/arm/mach-omap2/pm34xx.c +11 -8
@@ -82,9 +82,8 @@ struct power_state {static LIST_HEAD (pwrst_list); -static void (*_omap_sram_idle)(u32 *addr,int save_state); -static int (*_omap_save_secure_sram)(u32 *addr); +void (*omap3_do_wfi_sram)(void );static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;
@@ -355,9 +354,6 @@ void omap_sram_idle(void)int core_prev_state, per_prev_state;u32 sdrc_pwr =0 ; -if (!_omap_sram_idle) -return ; -pwrdm_clear_all_prev_pwrst (mpu_pwrdm);pwrdm_clear_all_prev_pwrst (neon_pwrdm);pwrdm_clear_all_prev_pwrst (core_pwrdm);
@@ -439,7 +435,7 @@ void omap_sram_idle(void)* get saved. The restore path then reads from this * location and restores them back. */ -_omap_sram_idle (omap3_arm_context, save_state); +omap34xx_cpu_suspend (omap3_arm_context, save_state);cpu_init ();/* Restore normal SDRC POWER settings */
@@ -996,10 +992,17 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)return 0 ; } +/* +* Push functions to SRAM +* +* The minimum set of functions is pushed to SRAM for execution: +* - omap3_do_wfi for erratum i581 WA, +* - save_secure_ram_context for security extensions. +*/ void omap_push_sram_idle (void ) { - _omap_sram_idle =omap_sram_push (omap34xx_cpu_suspend, - omap34xx_cpu_suspend_sz); + omap3_do_wfi_sram =omap_sram_push (omap3_do_wfi, omap3_do_wfi_sz); +if (omap_type () !=OMAP2_DEVICE_TYPE_GP ) _omap_save_secure_sram =omap_sram_push (save_secure_ram_context, save_secure_ram_context_sz);
arch/arm/mach-omap2/sleep34xx.S +174 -125
363 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Quoted 23 lines · On Thu, Jan 13, 2011 at 5:19 PM, <[email protected]> wrote:
From: Jean Pihet <[email protected]>
Most of the ASM sleep code (in
arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there.
However only a small part of the code really needs to run from internal SRAM.This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.SRAM usage:
- original code:
. 560 bytes foromap3_sram_configure_core_dpll(used by DVFS), . 1368 bytes foromap_sram_idle(used by suspend/resume in RETention), . 124 bytes fores3_sdrc_fix(used by suspend/resume in OFF mode on ES3.x), . 108 bytes forsave_secure_ram_context(used on HS parts).
Quoted 7 lines
With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the gain in SRAM usage for suspend/resume is > 1KB.
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
Signed-off-by Jean Pihet <[email protected]>
Is there any feedback on this code?
This change would need some more testing on all OMAP3 platforms, especially on the 36xx platforms that I do not have at hand.
Comments are welcome!
Regards,
Jean
Quoted 475 lines
---
arch/arm/mach-omap2/pm.h | 19 ++-arch/arm/mach-omap2/pm34xx.c| 19 ++-arch/arm/mach-omap2/sleep34xx.S| 299 +++++++++++++++++++++++----------------3 files changed, 200 insertions(+), 137 deletions(-)arch/arm/mach-omap2/pm.h +15
-4@@ -87,18 +87,29 @@ extern int pm_dbg_regset_init(int reg_set); #define pm_dbg_regset_init(reg_set) do {} while (0); #endif /* CONFIG_PM_DEBUG */ +/* 24xx */ extern void omap24xx_idle_loop_suspend(void); +extern unsigned int omap24xx_idle_loop_suspend_sz; extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl, void __iomem *sdrc_power); +extern unsigned int omap24xx_cpu_suspend_sz; + +/* 3xxx */ extern void omap34xx_cpu_suspend(u32 *addr, int save_state); + +/* 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 void save_secure_ram_context(u32 *addr); -extern void omap3_save_scratchpad_contents (void ); -extern unsigned int omap24xx_idle_loop_suspend_sz; extern unsigned int save_secure_ram_context_sz; -extern unsigned int omap24xx_cpu_suspend_sz; -extern unsigned int omap34xx_cpu_suspend_sz; + +extern void omap3_save_scratchpad_contents (void ); #define PM_RTA_ERRATUM_i608 (1 << 0) #define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)arch/arm/mach-omap2/pm34xx.c +11
-8@@ -82,9 +82,8 @@ struct power_state { static LIST_HEAD(pwrst_list); -static void (*_omap_sram_idle)(u32 *addr,int save_state); - static int (*_omap_save_secure_sram)(u32 *addr); +void (*omap3_do_wfi_sram)(void ); static struct powerdomain *mpu_pwrdm, *neon_pwrdm; static struct powerdomain *core_pwrdm, *per_pwrdm;@@ -355,9 +354,6 @@ void omap_sram_idle(void) int core_prev_state, per_prev_state; u32 sdrc_pwr = 0; - if (!_omap_sram_idle) - return; - pwrdm_clear_all_prev_pwrst(mpu_pwrdm); pwrdm_clear_all_prev_pwrst(neon_pwrdm); pwrdm_clear_all_prev_pwrst(core_pwrdm);@@ -439,7 +435,7 @@ void omap_sram_idle(void)* get saved. The restore path then reads from this * location and restores them back. */ - _omap_sram_idle(omap3_arm_context, save_state); + omap34xx_cpu_suspend(omap3_arm_context, save_state); cpu_init(); /* Restore normal SDRC POWER settings */@@ -996,10 +992,17 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused) return 0; } +/* +* Push functions to SRAM +* +* The minimum set of functions is pushed to SRAM for execution: +* - omap3_do_wfi for erratum i581 WA, +* - save_secure_ram_context for security extensions. +*/ void omap_push_sram_idle(void) { - _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend, - omap34xx_cpu_suspend_sz); + omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi, omap3_do_wfi_sz); + if (omap_type() != OMAP2_DEVICE_TYPE_GP) _omap_save_secure_sram = omap_sram_push(save_secure_ram_context, save_secure_ram_context_sz);arch/arm/mach-omap2/sleep34xx.S +13
-5@@ -163,8 +163,10 @@ ENTRY(save_secure_ram_context_sz) * * * Notes: - * - this code gets copied to internal SRAM at boot and after wake-up - * from OFF mode. The execution pointer in SRAM is _omap_sram_idle. + * - only the minimum set of functions gets copied to internal SRAM at boot + * and after wake-up from OFF mode, cf. omap_push_sram_idle. The function + * pointers in SDRAM or SRAM are called depending on the desired low power + * target state. * - when the OMAP wakes up it continues at different execution points * depending on the low power mode (non-OFF vs OFF modes), * cf. 'Resume path for xxx mode' comments.@@ -181,9 +183,15 @@ ENTRY(omap34xx_cpu_suspend) * 3 - Both L1 and L2 lost */ - /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 - beq omap3_do_wfi + /* + * For OFF mode: save context and jump to WFI in SDRAM (omap3_do_wfi) + * For non-OFF modes: jump to the WFI code in SRAM (omap3_do_wfi_sram) + */ + ldr r4, omap3_do_wfi_sram_addr + ldr r5, [r4] + cmp r1, #0x0 @ If no context save required, + bxeq r5 @ jump to the WFI code in SRAM + /* Otherwise fall through to the save context code */save_context_wfi:
arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -282,7 +290,31 @@ clean_l2:mov lr, pc
bx r1arch/arm/mach-omap2/sleep34xx.S +25
-1-omap3_do_wfi: + b omap3_do_wfi + +/* + * Local variables + */ +omap3_do_wfi_sram_addr: + .word omap3_do_wfi_sram +kernel_flush: + .word v7_flush_dcache_all + +/* =================================== + * == WFI instruction => Enter idle == + * =================================== + */ + +/* + * Do WFI instruction + * Includes the resume path for non-OFF modes + * + * This code gets copied to internal SRAM and is accessible + * from both SDRAM and SRAM: + * - executed from SRAM for non-off modes (omap3_do_wfi_sram), + * - executed from SDRAM for OFF mode (omap3_do_wfi). + */ +ENTRY(omap3_do_wfi)ldr r4,
sdrc_power@ read theSDRC_POWERregister ldr r5, [r4] @ read the contents ofSDRC_POWERorr r5, r5, #0x40 @ enable self refresh on idle reqarch/arm/mach-omap2/sleep34xx.S +0
-0@@ -315,15 +347,111 @@ omap3_do_wfi:nop
nop
nop
- blwait_sdrc_okarch/arm/mach-omap2/sleep34xx.S +71
-0+ +/* + * wait_sdrc_ok implements the erratum ID i581 WA: + * SDRC state restore before accessing the SDRAM + * + * Only used at return from non-OFF mode. For OFF + * mode the ROM code configures the SDRC and + * the DPLL before calling the restore code directly + * from SDRAM. + */ + +/* Make sure SDRC accesses are ok */ +wait_sdrc_ok: + +/* DPLL3 must be locked before accessing the SDRC. Maybe the HW ensures this */ + ldr r4, cm_idlest_ckgen +wait_dpll3_lock: + ldr r5, [r4] + tst r5, #1 + beq wait_dpll3_lock + + ldr r4, cm_idlest1_core +wait_sdrc_ready: + ldr r5, [r4] + tst r5, #0x2 + bne wait_sdrc_ready + /* allow DLL powerdown upon hw idle req */ + ldr r4, sdrc_power + ldr r5, [r4] + bic r5, r5, #0x40 + str r5, [r4] + +is_dll_in_lock_mode: + /* Is dll in lock mode? */ + ldr r4, sdrc_dlla_ctrl + ldr r5, [r4] + tst r5, #0x4 + bne exit_nonoff_modes @ Return if locked + + /* wait till dll locks */ +wait_dll_lock_timed: + ldr r4, wait_dll_lock_counter + add r4, r4, #1 + str r4, wait_dll_lock_counter + ldr r4, sdrc_dlla_status + /* Wait 20uS for lock */ + mov r6, #8 +wait_dll_lock: + subs r6, r6, #0x1 + beq kick_dll + ldr r5, [r4] + and r5, r5, #0x4 + cmp r5, #0x4 + bne wait_dll_lock + b exit_nonoff_modes @ Return when locked + + /* disable/reenable DLL if not locked */ +kick_dll: + ldr r4, sdrc_dlla_ctrl + ldr r5, [r4] + mov r6, r5 + bic r6, #(1<<3) @ disable dll + str r6, [r4] + dsb + orr r6, r6, #(1<<3) @ enable dll + str r6, [r4] + dsb + ldr r4, kick_counter + add r4, r4, #1 + str r4, kick_counter + b wait_dll_lock_timed/*
* ===================================
* == Exit point from non-OFF modes ==
* ===================================
*/
+exit_nonoff_modes:
ldmfd sp!, {r0-r12, pc} @ restore regs and returnarch/arm/mach-omap2/sleep34xx.S +25
-0+/* + * Local variables + */ +sdrc_power: + .word SDRC_POWER_V +cm_idlest1_core: + .word CM_IDLEST1_CORE_V +cm_idlest_ckgen: + .word CM_IDLEST_CKGEN_V +sdrc_dlla_status: + .word SDRC_DLLA_STATUS_V +sdrc_dlla_ctrl: + .word SDRC_DLLA_CTRL_V + /* + * When exporting to userspace while the counters are in SRAM, + * these 2 words need to be at the end to facilitate retrival! + */ +kick_counter: + .word 0 +wait_dll_lock_counter: + .word 0 + +ENTRY(omap3_do_wfi_sz) + .word . - omap3_do_wfi +/*
* ==============================arch/arm/mach-omap2/sleep34xx.S +4
-0@@ -339,6 +467,10 @@ omap3_do_wfi: * restore_es3: applies to 34xx >= ES3.0 * restore_3630: applies to 36xx * restore: common code for 3xxx + * + * Note: when back from CORE and MPU OFF mode we are running + * from SDRAM, without MMU, without the caches and prediction. + * Also the SRAM content has been cleared. */restore_es3:
ldr r5,pm_prepwstst_core_parch/arm/mach-omap2/sleep34xx.S +0
-0@@ -357,7 +489,8 @@ copy_to_sram:bne
copy_to_sram
ldr r1,sram_base
blx r1
- b restore
+
+ b restore @ Fall through to common coderestore_3630:
ldr r1,pm_prepwstst_core_parch/arm/mach-omap2/sleep34xx.S +0
-0@@ -600,12 +733,41 @@ usettbr0: */ldmfd sp!, {r0-r12, pc} @ restore regs and return
arch/arm/mach-omap2/sleep34xx.S +26
-0+/* + * Local variables + */ +pm_prepwstst_core_p: + .word PM_PREPWSTST_CORE_P +pm_pwstctrl_mpu: + .word PM_PWSTCTRL_MPU_P +scratchpad_base: + .word SCRATCHPAD_BASE_P +sram_base: + .word SRAM_BASE_P + 0x8000 +ttbrbit_mask: + .word 0xFFFFC000 +table_index_mask: + .word 0xFFF00000 +table_entry: + .word 0x00000C02 +cache_pred_disable_mask: + .word 0xFFFFE7FB +control_stat: + .word CONTROL_STAT +control_mem_rta: + .word CONTROL_MEM_RTA_CTRL +l2dis_3630: + .word 0 +/*
* Internal functions
*/arch/arm/mach-omap2/sleep34xx.S +4
-1-/* This function implements the erratum ID i443 WA, applies to 34xx >= ES3.0 */ +/* This function implements the erratum ID i443 WA, applies to 34xx >= ES3.0 + * + * Copied and run from SRAM in order to reconfigure the SDRC parameters. + */.text
ENTRY(es3_sdrc_fix)
ldr r4,sdrc_syscfg@ get config addrarch/arm/mach-omap2/sleep34xx.S +0
-0@@ -634,6 +796,9 @@ ENTRY(es3_sdrc_fix)str r5, [r4] @ kick off refreshes bx lr
+/*
+ * Local variables
+ */
sdrc_syscfg:
.wordSDRC_SYSCONFIG_P
sdrc_mr_0:arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -650,119 +815,3 @@ sdrc_manual_1:.word
SDRC_MANUAL_1_P
ENTRY(es3_sdrc_fix_sz)
.word . -es3_sdrc_fixarch/arm/mach-omap2/sleep34xx.S +0
-117- -/* - * This function implements the erratum ID i581 WA: - * SDRC state restore before accessing the SDRAM - * - * Only used at return from non-OFF mode. For OFF - * mode the ROM code configures the SDRC and - * the DPLL before calling the restore code directly - * from DDR. - */ - -/* Make sure SDRC accesses are ok */ -wait_sdrc_ok: - -/* DPLL3 must be locked before accessing the SDRC. Maybe the HW ensures this */ - ldr r4, cm_idlest_ckgen -wait_dpll3_lock: - ldr r5, [r4] - tst r5, #1 - beq wait_dpll3_lock - - ldr r4, cm_idlest1_core -wait_sdrc_ready: - ldr r5, [r4] - tst r5, #0x2 - bne wait_sdrc_ready - /* allow DLL powerdown upon hw idle req */ - ldr r4, sdrc_power - ldr r5, [r4] - bic r5, r5, #0x40 - str r5, [r4] - -is_dll_in_lock_mode: - /* Is dll in lock mode? */ - ldr r4, sdrc_dlla_ctrl - ldr r5, [r4] - tst r5, #0x4 - bxne lr @ Return if locked - /* wait till dll locks */ -wait_dll_lock_timed: - ldr r4, wait_dll_lock_counter - add r4, r4, #1 - str r4, wait_dll_lock_counter - ldr r4, sdrc_dlla_status - /* Wait 20uS for lock */ - mov r6, #8 -wait_dll_lock: - subs r6, r6, #0x1 - beq kick_dll - ldr r5, [r4] - and r5, r5, #0x4 - cmp r5, #0x4 - bne wait_dll_lock - bx lr @ Return when locked - - /* disable/reenable DLL if not locked */ -kick_dll: - ldr r4, sdrc_dlla_ctrl - ldr r5, [r4] - mov r6, r5 - bic r6, #(1<<3) @ disable dll - str r6, [r4] - dsb - orr r6, r6, #(1<<3) @ enable dll - str r6, [r4] - dsb - ldr r4, kick_counter - add r4, r4, #1 - str r4, kick_counter - b wait_dll_lock_timed - -cm_idlest1_core: - .word CM_IDLEST1_CORE_V -cm_idlest_ckgen: - .word CM_IDLEST_CKGEN_V -sdrc_dlla_status: - .word SDRC_DLLA_STATUS_V -sdrc_dlla_ctrl: - .word SDRC_DLLA_CTRL_V -pm_prepwstst_core_p: - .word PM_PREPWSTST_CORE_P -pm_pwstctrl_mpu: - .word PM_PWSTCTRL_MPU_P -scratchpad_base: - .word SCRATCHPAD_BASE_P -sram_base: - .word SRAM_BASE_P + 0x8000 -sdrc_power: - .word SDRC_POWER_V -ttbrbit_mask: - .word 0xFFFFC000 -table_index_mask: - .word 0xFFF00000 -table_entry: - .word 0x00000C02 -cache_pred_disable_mask: - .word 0xFFFFE7FB -control_stat: - .word CONTROL_STAT -control_mem_rta: - .word CONTROL_MEM_RTA_CTRL -kernel_flush: - .word v7_flush_dcache_all -l2dis_3630: - .word 0 - /* - * When exporting to userspace while the counters are in SRAM, - * these 2 words need to be at the end to facilitate retrival! - */ -kick_counter: - .word 0 -wait_dll_lock_counter: - .word 0 - -ENTRY(omap34xx_cpu_suspend_sz) - .word . - omap34xx_cpu_suspend --
Quoted 3 lines
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vishwanath Sripathy
Tested-byJean,
Quoted 8 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Jean Pihet
Sent: Monday, January 24, 2011 7:59 PM
To: [email protected]
Cc: Jean Pihet
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDR
Quoted 6 lines
Quoted 5 lines · On Thu, Jan 13, 2011 at 5:19 PM, <[email protected]> wrote:
From: Jean Pihet <[email protected]>
Most of the ASM sleep code (in
arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there. However only a small part of the code really needs to run from
internal
Quoted 25 lines
SRAM.
Quoted 11 lines
This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.Quoted 4 lines
SRAM usage:
- original code:
. 560 bytes foromap3_sram_configure_core_dpll(used by DVFS), . 1368 bytes foromap_sram_idle(used by suspend/resume inRETention),
Quoted 1 line
. 124 bytes for
es3_sdrc_fix(used by suspend/resume in OFF modeon ES3.x),
Quoted 3 lines
. 108 bytes for
save_secure_ram_context(used on HS parts).With this fix the usage for suspend/resume in RETention goes down
312 bytes, so the
Quoted 2 lines
gain in SRAM usage for suspend/resume is > 1KB.
Quoted 8 lines
Quoted 4 lines
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
Signed-off-by Jean Pihet <[email protected]>Is there any feedback on this code?
This change would need some more testing on all OMAP3 platforms, especially on the 36xx platforms that I do not have at hand.
I tested this patch on ZOOM3 (OMAP3630) using kevin's PM branch for both retention and off in CPUIdle and suspend path and it seems to work fine. You can add
Vishwa
Quoted 138 lines
Comments are welcome!
Regards,
JeanQuoted 4 lines
---
arch/arm/mach-omap2/pm.h | 19 ++-
arch/arm/mach-omap2/pm34xx.c | 19 ++-
arch/arm/mach-omap2/sleep34xx.S | 299+++++++++++++++++++++++----------------
arch/arm/mach-
Quoted 3 lines
3 files changed, 200 insertions(+), 137 deletions(-)arch/arm/mach- renamed from arch/arm/mach-omap2/pm.h +0
-0
omap2/pm.hQuoted 11 lines
index 1c1b0ab..ae9dec0 100644
arch/arm/mach-omap2/pm.h +2
-0@@ -87,18 +87,29 @@ extern int pm_dbg_regset_init(int reg_set); #define pm_dbg_regset_init(reg_set) do {} while (0); #endif /* CONFIG_PM_DEBUG */ +/* 24xx */ extern void omap24xx_idle_loop_suspend(void); +extern unsigned int omap24xx_idle_loop_suspend_sz;Quoted 1 line
extern void omap24xx_cpu_suspend(u32
dll_ctrl, void__iomem
*sdrc_dlla_ctrl,arch/arm/mach-omap2/pm.h extern int pm_dbg_regset_init(int reg_set);
Quoted 13 lines
void
__iomem*sdrc_power);arch/arm/mach-omap2/pm.h +3
-0+extern unsigned int omap24xx_cpu_suspend_sz; + +/* 3xxx */ extern void
omap34xx_cpu_suspend(u32 *addr, int save_state);arch/arm/mach-omap2/pm.h +8
-0+ +/* 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 */
arch/arm/mach-
Quoted 13 lines
extern void
save_secure_ram_context(u32 *addr);arch/arm/mach-omap2/pm.h +0
-2-extern void omap3_save_scratchpad_contents (void ); -extern unsigned int omap24xx_idle_loop_suspend_sz;extern unsigned int
save_secure_ram_context_sz;arch/arm/mach-omap2/pm.h +2
-2-extern unsigned int omap24xx_cpu_suspend_sz; -extern unsigned int omap34xx_cpu_suspend_sz; + +extern void omap3_save_scratchpad_contents (void );#define
PM_RTA_ERRATUM_i608(1 << 0)
#definePM_SDRC_WAKEUP_ERRATUM_i583(1 << 1)arch/arm/mach- renamed from arch/arm/mach-omap2/pm34xx.c +0
-0
omap2/pm34xx.carch/arm/mach-omap2/pm34xx.c static int __init clkdms_setup(struct
Quoted 34 lines
index 5b323f2..56ca3cb 100644
arch/arm/mach-omap2/pm34xx.c +2
-6@@ -82,9 +82,8 @@ struct power_state { static LIST_HEAD(pwrst_list); -static void (*_omap_sram_idle)(u32 *addr,int save_state); - static int (*_omap_save_secure_sram)(u32 *addr); +void (*omap3_do_wfi_sram)(void ); static struct powerdomain *mpu_pwrdm, *neon_pwrdm; static struct powerdomain *core_pwrdm, *per_pwrdm;@@ -355,9 +354,6 @@ void omap_sram_idle(void) int core_prev_state, per_prev_state; u32 sdrc_pwr = 0; - if (!_omap_sram_idle) - return; - pwrdm_clear_all_prev_pwrst(mpu_pwrdm); pwrdm_clear_all_prev_pwrst(neon_pwrdm); pwrdm_clear_all_prev_pwrst(core_pwrdm);@@ -439,7 +435,7 @@ void omap_sram_idle(void)* get saved. The restore path then reads from this * location and restores them back. */ - _omap_sram_idle(omap3_arm_context, save_state); + omap34xx_cpu_suspend(omap3_arm_context, save_state); cpu_init(); /* Restore normal SDRC POWER settings */@@ -996,10 +992,17 @@ static int __init clkdms_setup(structclockdomain *clkdm, void *unused)
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +2
-0return 0; } +/* +* Push functions to SRAM arch/arm/mach-omap2/pm34xx.c static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
Quoted 10 lines
arch/arm/mach-omap2/pm34xx.c +6
-2+* +* The minimum set of functions is pushed to SRAM for execution: +* - omap3_do_wfi for erratum i581 WA, +* - save_secure_ram_context for security extensions. +*/ void omap_push_sram_idle(void) { - _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend, - omap34xx_cpu_suspend_sz); + omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi,
omap3_do_wfi_sz);Quoted 3 lines
arch/arm/mach-omap2/pm34xx.c +1
-0+ if (omap_type() != OMAP2_DEVICE_TYPE_GP)_omap_save_secure_sram =
omap_sram_push(save_secure_ram_context,
arch/arm/mach-
Quoted 2 lines
save_secure_ram_context_sz);
arch/arm/mach- renamed from arch/arm/mach-omap2/sleep34xx.S +0
-0
omap2/sleep34xx.Sarch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 167
Quoted 9 lines
index 98d8232..ced85b5 100644
arch/arm/mach-omap2/sleep34xx.S +0
-2@@ -163,8 +163,10 @@ ENTRY(save_secure_ram_context_sz) * * * Notes: - * - this code gets copied to internal SRAM at boot and after wake-up - * from OFF mode. The execution pointer in SRAM is
_omap_sram_idle.arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 166
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * - only the minimum set of functions gets copied to internal SRAMat boot
arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 167
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * and after wake-up from OFF mode, cf. omap_push_sram_idle.The function
arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 168
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * pointers in SDRAM or SRAM are called depending on the desiredlow power
Quoted 8 lines
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * target state. * - when the OMAP wakes up it continues at different execution points * depending on the low power mode (non-OFF vs OFF modes), * cf. 'Resume path for xxx mode' comments.@@ -181,9 +183,15 @@ ENTRY(omap34xx_cpu_suspend) * 3 - Both L1 and L2 lost */
Quoted 13 lines
arch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend)
Quoted 5 lines
arch/arm/mach-omap2/sleep34xx.S +2
-3- /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 - beq omap3_do_wfi + /* + * For OFF mode: save context and jump to WFI in SDRAM(
omap3_do_wfi)arch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend) · line 188
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * For non-OFF modes: jump to the WFI code in SRAM(
omap3_do_wfi_sram)Quoted 5 lines
arch/arm/mach-omap2/sleep34xx.S +5
-0+ */ + ldr r4, omap3_do_wfi_sram_addr + ldr r5, [r4] + cmp r1, #0x0 @ If no context save required, + bxeq r5 @ jump to the WFI code in
SRAM
Quoted 28 lines
Quoted 28 lines
arch/arm/mach-omap2/sleep34xx.S +1
-0+ /* Otherwise fall through to the save context code */save_context_wfi:
arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -282,7 +290,31 @@ clean_l2:mov lr, pc
bx r1arch/arm/mach-omap2/sleep34xx.S +19
-1-omap3_do_wfi: + b omap3_do_wfi + +/* + * Local variables + */ +omap3_do_wfi_sram_addr: + .word omap3_do_wfi_sram +kernel_flush: + .word v7_flush_dcache_all + +/* =================================== + * == WFI instruction => Enter idle == + * =================================== + */ + +/* + * Do WFI instruction + * Includes the resume path for non-OFF modes + *
Quoted 8 lines
Quoted 8 lines
+ * This code gets copied to internal SRAM and is accessible
+ * from both SDRAM and SRAM:
+ * - executed from SRAM for non-off modes (omap3_do_wfi_sram),
+ * - executed from SDRAM for OFF mode (omap3_do_wfi).
+ */
+ENTRY(omap3_do_wfi)
ldr r4,sdrc_power@ read theSDRC_POWERregister ldr r5, [r4] @ read the contents of
SDRC_POWER
Quoted 1 line
Quoted 1 line
orr r5, r5, #0x40 @ enable self refresh on idle
req
Quoted 312 lines
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -315,15 +347,111 @@ omap3_do_wfi:nop
nop
nop
- blwait_sdrc_okarch/arm/mach-omap2/sleep34xx.S +5
-0+ +/* + * wait_sdrc_ok implements the erratum ID i581 WA: + * SDRC state restore before accessing the SDRAM + *arch/arm/mach-omap2/sleep34xx.S omap3_do_wfi:
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +10
-0+ * Only used at return from non-OFF mode. For OFF + * mode the ROM code configures the SDRC and + * the DPLL before calling the restore code directly + * from SDRAM. + */ + +/* Make sure SDRC accesses are ok */ +wait_sdrc_ok: + +/* DPLL3 must be locked before accessing the SDRC. Maybe the HWensures this */
Quoted 149 lines
+ ldr r4,
cm_idlest_ckgenarch/arm/mach-omap2/sleep34xx.S +55
-0+wait_dpll3_lock: + ldr r5, [r4] + tst r5, #1 + beq wait_dpll3_lock + + ldr r4, cm_idlest1_core +wait_sdrc_ready: + ldr r5, [r4] + tst r5, #0x2 + bne wait_sdrc_ready + /* allow DLL powerdown upon hw idle req */ + ldr r4, sdrc_power + ldr r5, [r4] + bic r5, r5, #0x40 + str r5, [r4] + +is_dll_in_lock_mode: + /* Is dll in lock mode? */ + ldr r4, sdrc_dlla_ctrl + ldr r5, [r4] + tst r5, #0x4 + bne exit_nonoff_modes @ Return if locked + + /* wait till dll locks */ +wait_dll_lock_timed: + ldr r4, wait_dll_lock_counter + add r4, r4, #1 + str r4, wait_dll_lock_counter + ldr r4, sdrc_dlla_status + /* Wait 20uS for lock */ + mov r6, #8 +wait_dll_lock: + subs r6, r6, #0x1 + beq kick_dll + ldr r5, [r4] + and r5, r5, #0x4 + cmp r5, #0x4 + bne wait_dll_lock + b exit_nonoff_modes @ Return when locked + + /* disable/reenable DLL if not locked */ +kick_dll: + ldr r4, sdrc_dlla_ctrl + ldr r5, [r4] + mov r6, r5 + bic r6, #(1<<3) @ disable dll + str r6, [r4] + dsb + orr r6, r6, #(1<<3) @ enable dll + str r6, [r4] + dsb + ldr r4, kick_counter + add r4, r4, #1 + str r4, kick_counter + b wait_dll_lock_timed/*
* ===================================
* == Exit point from non-OFF modes ==
* ===================================
*/
+exit_nonoff_modes:
ldmfd sp!, {r0-r12, pc} @ restore regs and returnarch/arm/mach-omap2/sleep34xx.S +25
-0+/* + * Local variables + */ +sdrc_power: + .word SDRC_POWER_V +cm_idlest1_core: + .word CM_IDLEST1_CORE_V +cm_idlest_ckgen: + .word CM_IDLEST_CKGEN_V +sdrc_dlla_status: + .word SDRC_DLLA_STATUS_V +sdrc_dlla_ctrl: + .word SDRC_DLLA_CTRL_V + /* + * When exporting to userspace while the counters are in SRAM, + * these 2 words need to be at the end to facilitate retrival! + */ +kick_counter: + .word 0 +wait_dll_lock_counter: + .word 0 + +ENTRY(omap3_do_wfi_sz) + .word . - omap3_do_wfi +/*
* ==============================arch/arm/mach-omap2/sleep34xx.S +4
-0@@ -339,6 +467,10 @@ omap3_do_wfi: * restore_es3: applies to 34xx >= ES3.0 * restore_3630: applies to 36xx * restore: common code for 3xxx + * + * Note: when back from CORE and MPU OFF mode we are running + * from SDRAM, without MMU, without the caches and prediction. + * Also the SRAM content has been cleared. */restore_es3:
ldr r5,pm_prepwstst_core_parch/arm/mach-omap2/sleep34xx.S +0
-0@@ -357,7 +489,8 @@ copy_to_sram:bne
copy_to_sram
ldr r1,sram_base
blx r1
- b restore
+
+ b restore @ Fall through to common coderestore_3630:
ldr r1,pm_prepwstst_core_parch/arm/mach-omap2/sleep34xx.S +0
-0@@ -600,12 +733,41 @@ usettbr0: */ldmfd sp!, {r0-r12, pc} @ restore regs and return
arch/arm/mach-omap2/sleep34xx.S +26
-0+/* + * Local variables + */ +pm_prepwstst_core_p: + .word PM_PREPWSTST_CORE_P +pm_pwstctrl_mpu: + .word PM_PWSTCTRL_MPU_P +scratchpad_base: + .word SCRATCHPAD_BASE_P +sram_base: + .word SRAM_BASE_P + 0x8000 +ttbrbit_mask: + .word 0xFFFFC000 +table_index_mask: + .word 0xFFF00000 +table_entry: + .word 0x00000C02 +cache_pred_disable_mask: + .word 0xFFFFE7FB +control_stat: + .word CONTROL_STAT +control_mem_rta: + .word CONTROL_MEM_RTA_CTRL +l2dis_3630: + .word 0 +/*
* Internal functions
*/Quoted 6 lines
-/* This function implements the erratum ID i443 WA, applies to 34xx = ES3.0 */
+/* This function implements the erratum ID i443 WA, applies to 34xx = ES3.0
+ *
+ * Copied and run from SRAM in order to reconfigure the SDRCparameters.
Quoted 23 lines
+ */
.text
ENTRY(es3_sdrc_fix)
ldr r4,sdrc_syscfg@ get config addrarch/arm/mach-omap2/sleep34xx.S +0
-0@@ -634,6 +796,9 @@ ENTRY(es3_sdrc_fix)str r5, [r4] @ kick off refreshes bx lr
+/*
+ * Local variables
+ */
sdrc_syscfg:
.wordSDRC_SYSCONFIG_P
sdrc_mr_0:arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -650,119 +815,3 @@ sdrc_manual_1:.word
SDRC_MANUAL_1_P
ENTRY(es3_sdrc_fix_sz)
.word . -es3_sdrc_fixarch/arm/mach-omap2/sleep34xx.S +0
-5- -/* - * This function implements the erratum ID i581 WA: - * SDRC state restore before accessing the SDRAM - *arch/arm/mach-omap2/sleep34xx.S sdrc_manual_1:
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +0
-10- * Only used at return from non-OFF mode. For OFF - * mode the ROM code configures the SDRC and - * the DPLL before calling the restore code directly - * from DDR. - */ - -/* Make sure SDRC accesses are ok */ -wait_sdrc_ok: - -/* DPLL3 must be locked before accessing the SDRC. Maybe the HWensures this */
Quoted 101 lines
- ldr r4,
cm_idlest_ckgenarch/arm/mach-omap2/sleep34xx.S +0
-100-wait_dpll3_lock: - ldr r5, [r4] - tst r5, #1 - beq wait_dpll3_lock - - ldr r4, cm_idlest1_core -wait_sdrc_ready: - ldr r5, [r4] - tst r5, #0x2 - bne wait_sdrc_ready - /* allow DLL powerdown upon hw idle req */ - ldr r4, sdrc_power - ldr r5, [r4] - bic r5, r5, #0x40 - str r5, [r4] - -is_dll_in_lock_mode: - /* Is dll in lock mode? */ - ldr r4, sdrc_dlla_ctrl - ldr r5, [r4] - tst r5, #0x4 - bxne lr @ Return if locked - /* wait till dll locks */ -wait_dll_lock_timed: - ldr r4, wait_dll_lock_counter - add r4, r4, #1 - str r4, wait_dll_lock_counter - ldr r4, sdrc_dlla_status - /* Wait 20uS for lock */ - mov r6, #8 -wait_dll_lock: - subs r6, r6, #0x1 - beq kick_dll - ldr r5, [r4] - and r5, r5, #0x4 - cmp r5, #0x4 - bne wait_dll_lock - bx lr @ Return when locked - - /* disable/reenable DLL if not locked */ -kick_dll: - ldr r4, sdrc_dlla_ctrl - ldr r5, [r4] - mov r6, r5 - bic r6, #(1<<3) @ disable dll - str r6, [r4] - dsb - orr r6, r6, #(1<<3) @ enable dll - str r6, [r4] - dsb - ldr r4, kick_counter - add r4, r4, #1 - str r4, kick_counter - b wait_dll_lock_timed - -cm_idlest1_core: - .word CM_IDLEST1_CORE_V -cm_idlest_ckgen: - .word CM_IDLEST_CKGEN_V -sdrc_dlla_status: - .word SDRC_DLLA_STATUS_V -sdrc_dlla_ctrl: - .word SDRC_DLLA_CTRL_V -pm_prepwstst_core_p: - .word PM_PREPWSTST_CORE_P -pm_pwstctrl_mpu: - .word PM_PWSTCTRL_MPU_P -scratchpad_base: - .word SCRATCHPAD_BASE_P -sram_base: - .word SRAM_BASE_P + 0x8000 -sdrc_power: - .word SDRC_POWER_V -ttbrbit_mask: - .word 0xFFFFC000 -table_index_mask: - .word 0xFFF00000 -table_entry: - .word 0x00000C02 -cache_pred_disable_mask: - .word 0xFFFFE7FB -control_stat: - .word CONTROL_STAT -control_mem_rta: - .word CONTROL_MEM_RTA_CTRL -kernel_flush: - .word v7_flush_dcache_all -l2dis_3630: - .word 0 - /* - * When exporting to userspace while the counters are in SRAM, - * these 2 words need to be at the end to facilitate retrival! - */ -kick_counter: - .word 0 -wait_dll_lock_counter: - .word 0 - -ENTRY(omap34xx_cpu_suspend_sz) - .word . - omap34xx_cpu_suspend
Quoted 8 lines
Quoted 4 lines
--
1.7.2.3--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 47 lines · Vishwanath Sripathy
Jean,
Quoted 8 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Jean Pihet
Sent: Monday, January 24, 2011 7:59 PM
To: [email protected]
Cc: Jean Pihet
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRQuoted 6 lines
Quoted 5 lines · On Thu, Jan 13, 2011 at 5:19 PM, <[email protected]> wrote:
From: Jean Pihet <[email protected]>
Most of the ASM sleep code (in
arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there. However only a small part of the code really needs to run frominternal
Quoted 30 lines
SRAM.
Quoted 11 lines
This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.Quoted 4 lines
SRAM usage:
- original code:
. 560 bytes foromap3_sram_configure_core_dpll(used by DVFS), . 1368 bytes foromap_sram_idle(used by suspend/resume inRETention),
Quoted 1 line
. 124 bytes for
es3_sdrc_fix(used by suspend/resume in OFF modeon ES3.x),
Quoted 3 lines
. 108 bytes for
save_secure_ram_context(used on HS parts).With this fix the usage for suspend/resume in RETention goes down
312 bytes, so the
Quoted 6 lines
gain in SRAM usage for suspend/resume is > 1KB.
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
Signed-off-by Jean Pihet <[email protected]>
Quoted 7 lines
Quoted 3 lines
Is there any feedback on this code?
This change would need some more testing on all OMAP3 platforms, especially on the 36xx platforms that I do not have at hand.I tested this patch on ZOOM3 (OMAP3630) using kevin's PM branch for both retention and off in CPUIdle and suspend path and it seems to work fine. You can add
Tested-by Vishwanath BS <[email protected]>
Thanks Vishwa!
Regards,
Jean
Quoted 191 lines
Vishwa
Quoted 138 lines
Comments are welcome!
Regards,
JeanQuoted 4 lines
---
arch/arm/mach-omap2/pm.h | 19 ++-
arch/arm/mach-omap2/pm34xx.c | 19 ++-
arch/arm/mach-omap2/sleep34xx.S | 299+++++++++++++++++++++++----------------
arch/arm/mach-
Quoted 3 lines
3 files changed, 200 insertions(+), 137 deletions(-)arch/arm/mach- renamed from arch/arm/mach-omap2/pm.h +0
-0
omap2/pm.hQuoted 11 lines
index 1c1b0ab..ae9dec0 100644
arch/arm/mach-omap2/pm.h +2
-0@@ -87,18 +87,29 @@ extern int pm_dbg_regset_init(int reg_set); #define pm_dbg_regset_init(reg_set) do {} while (0); #endif /* CONFIG_PM_DEBUG */ +/* 24xx */ extern void omap24xx_idle_loop_suspend(void); +extern unsigned int omap24xx_idle_loop_suspend_sz;Quoted 1 line
extern void omap24xx_cpu_suspend(u32
dll_ctrl, void__iomem
*sdrc_dlla_ctrl,arch/arm/mach-omap2/pm.h extern int pm_dbg_regset_init(int reg_set);
Quoted 13 lines
void
__iomem*sdrc_power);arch/arm/mach-omap2/pm.h +3
-0+extern unsigned int omap24xx_cpu_suspend_sz; + +/* 3xxx */ extern void
omap34xx_cpu_suspend(u32 *addr, int save_state);arch/arm/mach-omap2/pm.h +8
-0+ +/* 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 */
arch/arm/mach-
Quoted 13 lines
extern void
save_secure_ram_context(u32 *addr);arch/arm/mach-omap2/pm.h +0
-2-extern void omap3_save_scratchpad_contents (void ); -extern unsigned int omap24xx_idle_loop_suspend_sz;extern unsigned int
save_secure_ram_context_sz;arch/arm/mach-omap2/pm.h +2
-2-extern unsigned int omap24xx_cpu_suspend_sz; -extern unsigned int omap34xx_cpu_suspend_sz; + +extern void omap3_save_scratchpad_contents (void );#define
PM_RTA_ERRATUM_i608(1 << 0)
#definePM_SDRC_WAKEUP_ERRATUM_i583(1 << 1)arch/arm/mach- renamed from arch/arm/mach-omap2/pm34xx.c +0
-0
omap2/pm34xx.carch/arm/mach-omap2/pm34xx.c static int __init clkdms_setup(struct
Quoted 34 lines
index 5b323f2..56ca3cb 100644
arch/arm/mach-omap2/pm34xx.c +2
-6@@ -82,9 +82,8 @@ struct power_state { static LIST_HEAD(pwrst_list); -static void (*_omap_sram_idle)(u32 *addr,int save_state); - static int (*_omap_save_secure_sram)(u32 *addr); +void (*omap3_do_wfi_sram)(void ); static struct powerdomain *mpu_pwrdm, *neon_pwrdm; static struct powerdomain *core_pwrdm, *per_pwrdm;@@ -355,9 +354,6 @@ void omap_sram_idle(void) int core_prev_state, per_prev_state; u32 sdrc_pwr = 0; - if (!_omap_sram_idle) - return; - pwrdm_clear_all_prev_pwrst(mpu_pwrdm); pwrdm_clear_all_prev_pwrst(neon_pwrdm); pwrdm_clear_all_prev_pwrst(core_pwrdm);@@ -439,7 +435,7 @@ void omap_sram_idle(void)* get saved. The restore path then reads from this * location and restores them back. */ - _omap_sram_idle(omap3_arm_context, save_state); + omap34xx_cpu_suspend(omap3_arm_context, save_state); cpu_init(); /* Restore normal SDRC POWER settings */@@ -996,10 +992,17 @@ static int __init clkdms_setup(structclockdomain *clkdm, void *unused)
Quoted 5 lines
arch/arm/mach-omap2/pm34xx.c +2
-0return 0; } +/* +* Push functions to SRAM arch/arm/mach-omap2/pm34xx.c static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
Quoted 10 lines
arch/arm/mach-omap2/pm34xx.c +6
-2+* +* The minimum set of functions is pushed to SRAM for execution: +* - omap3_do_wfi for erratum i581 WA, +* - save_secure_ram_context for security extensions. +*/ void omap_push_sram_idle(void) { - _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend, - omap34xx_cpu_suspend_sz); + omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi,
omap3_do_wfi_sz);Quoted 3 lines
arch/arm/mach-omap2/pm34xx.c +1
-0+ if (omap_type() != OMAP2_DEVICE_TYPE_GP)_omap_save_secure_sram =
omap_sram_push(save_secure_ram_context,
arch/arm/mach-
Quoted 2 lines
save_secure_ram_context_sz);
arch/arm/mach- renamed from arch/arm/mach-omap2/sleep34xx.S +0
-0
omap2/sleep34xx.Sarch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 167
Quoted 9 lines
index 98d8232..ced85b5 100644
arch/arm/mach-omap2/sleep34xx.S +0
-2@@ -163,8 +163,10 @@ ENTRY(save_secure_ram_context_sz) * * * Notes: - * - this code gets copied to internal SRAM at boot and after wake-up - * from OFF mode. The execution pointer in SRAM is
_omap_sram_idle.arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 166
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * - only the minimum set of functions gets copied to internal SRAMat boot
arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 167
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * and after wake-up from OFF mode, cf. omap_push_sram_idle.The function
arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 168
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * pointers in SDRAM or SRAM are called depending on the desiredlow power
Quoted 8 lines
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * target state. * - when the OMAP wakes up it continues at different execution points * depending on the low power mode (non-OFF vs OFF modes), * cf. 'Resume path for xxx mode' comments.@@ -181,9 +183,15 @@ ENTRY(omap34xx_cpu_suspend) * 3 - Both L1 and L2 lost */Quoted 13 lines
arch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend)
Quoted 5 lines
arch/arm/mach-omap2/sleep34xx.S +2
-3- /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 - beq omap3_do_wfi + /* + * For OFF mode: save context and jump to WFI in SDRAM(
omap3_do_wfi)arch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend) · line 188
Quoted 1 line
arch/arm/mach-omap2/sleep34xx.S +1
-0+ * For non-OFF modes: jump to the WFI code in SRAM(
omap3_do_wfi_sram)Quoted 5 lines
arch/arm/mach-omap2/sleep34xx.S +5
-0+ */ + ldr r4, omap3_do_wfi_sram_addr + ldr r5, [r4] + cmp r1, #0x0 @ If no context save required, + bxeq r5 @ jump to the WFI code inSRAM
Quoted 28 lines
Quoted 28 lines
arch/arm/mach-omap2/sleep34xx.S +1
-0+ /* Otherwise fall through to the save context code */save_context_wfi:
arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -282,7 +290,31 @@ clean_l2:mov lr, pc
bx r1arch/arm/mach-omap2/sleep34xx.S +19
-1-omap3_do_wfi: + b omap3_do_wfi + +/* + * Local variables + */ +omap3_do_wfi_sram_addr: + .word omap3_do_wfi_sram +kernel_flush: + .word v7_flush_dcache_all + +/* =================================== + * == WFI instruction => Enter idle == + * =================================== + */ + +/* + * Do WFI instruction + * Includes the resume path for non-OFF modes + *Quoted 8 lines
Quoted 8 lines
+ * This code gets copied to internal SRAM and is accessible
+ * from both SDRAM and SRAM:
+ * - executed from SRAM for non-off modes (omap3_do_wfi_sram),
+ * - executed from SDRAM for OFF mode (omap3_do_wfi).
+ */
+ENTRY(omap3_do_wfi)
ldr r4,sdrc_power@ read theSDRC_POWERregister ldr r5, [r4] @ read the contents of
SDRC_POWER
Quoted 323 lines
Quoted 1 line
Quoted 1 line
orr r5, r5, #0x40 @ enable self refresh on idle
req
Quoted 320 lines
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -315,15 +347,111 @@ omap3_do_wfi:nop
nop
nop
- blwait_sdrc_okarch/arm/mach-omap2/sleep34xx.S +5
-0+ +/* + * wait_sdrc_ok implements the erratum ID i581 WA: + * SDRC state restore before accessing the SDRAM + *arch/arm/mach-omap2/sleep34xx.S omap3_do_wfi:
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +10
-0+ * Only used at return from non-OFF mode. For OFF + * mode the ROM code configures the SDRC and + * the DPLL before calling the restore code directly + * from SDRAM. + */ + +/* Make sure SDRC accesses are ok */ +wait_sdrc_ok: + +/* DPLL3 must be locked before accessing the SDRC. Maybe the HWensures this */
Quoted 149 lines
+ ldr r4,
cm_idlest_ckgenarch/arm/mach-omap2/sleep34xx.S +55
-0+wait_dpll3_lock: + ldr r5, [r4] + tst r5, #1 + beq wait_dpll3_lock + + ldr r4, cm_idlest1_core +wait_sdrc_ready: + ldr r5, [r4] + tst r5, #0x2 + bne wait_sdrc_ready + /* allow DLL powerdown upon hw idle req */ + ldr r4, sdrc_power + ldr r5, [r4] + bic r5, r5, #0x40 + str r5, [r4] + +is_dll_in_lock_mode: + /* Is dll in lock mode? */ + ldr r4, sdrc_dlla_ctrl + ldr r5, [r4] + tst r5, #0x4 + bne exit_nonoff_modes @ Return if locked + + /* wait till dll locks */ +wait_dll_lock_timed: + ldr r4, wait_dll_lock_counter + add r4, r4, #1 + str r4, wait_dll_lock_counter + ldr r4, sdrc_dlla_status + /* Wait 20uS for lock */ + mov r6, #8 +wait_dll_lock: + subs r6, r6, #0x1 + beq kick_dll + ldr r5, [r4] + and r5, r5, #0x4 + cmp r5, #0x4 + bne wait_dll_lock + b exit_nonoff_modes @ Return when locked + + /* disable/reenable DLL if not locked */ +kick_dll: + ldr r4, sdrc_dlla_ctrl + ldr r5, [r4] + mov r6, r5 + bic r6, #(1<<3) @ disable dll + str r6, [r4] + dsb + orr r6, r6, #(1<<3) @ enable dll + str r6, [r4] + dsb + ldr r4, kick_counter + add r4, r4, #1 + str r4, kick_counter + b wait_dll_lock_timed/*
* ===================================
* == Exit point from non-OFF modes ==
* ===================================
*/
+exit_nonoff_modes:
ldmfd sp!, {r0-r12, pc} @ restore regs and returnarch/arm/mach-omap2/sleep34xx.S +25
-0+/* + * Local variables + */ +sdrc_power: + .word SDRC_POWER_V +cm_idlest1_core: + .word CM_IDLEST1_CORE_V +cm_idlest_ckgen: + .word CM_IDLEST_CKGEN_V +sdrc_dlla_status: + .word SDRC_DLLA_STATUS_V +sdrc_dlla_ctrl: + .word SDRC_DLLA_CTRL_V + /* + * When exporting to userspace while the counters are in SRAM, + * these 2 words need to be at the end to facilitate retrival! + */ +kick_counter: + .word 0 +wait_dll_lock_counter: + .word 0 + +ENTRY(omap3_do_wfi_sz) + .word . - omap3_do_wfi +/*
* ==============================arch/arm/mach-omap2/sleep34xx.S +4
-0@@ -339,6 +467,10 @@ omap3_do_wfi: * restore_es3: applies to 34xx >= ES3.0 * restore_3630: applies to 36xx * restore: common code for 3xxx + * + * Note: when back from CORE and MPU OFF mode we are running + * from SDRAM, without MMU, without the caches and prediction. + * Also the SRAM content has been cleared. */restore_es3:
ldr r5,pm_prepwstst_core_parch/arm/mach-omap2/sleep34xx.S +0
-0@@ -357,7 +489,8 @@ copy_to_sram:bne
copy_to_sram
ldr r1,sram_base
blx r1
- b restore
+
+ b restore @ Fall through to common coderestore_3630:
ldr r1,pm_prepwstst_core_parch/arm/mach-omap2/sleep34xx.S +0
-0@@ -600,12 +733,41 @@ usettbr0: */ldmfd sp!, {r0-r12, pc} @ restore regs and return
arch/arm/mach-omap2/sleep34xx.S +26
-0+/* + * Local variables + */ +pm_prepwstst_core_p: + .word PM_PREPWSTST_CORE_P +pm_pwstctrl_mpu: + .word PM_PWSTCTRL_MPU_P +scratchpad_base: + .word SCRATCHPAD_BASE_P +sram_base: + .word SRAM_BASE_P + 0x8000 +ttbrbit_mask: + .word 0xFFFFC000 +table_index_mask: + .word 0xFFF00000 +table_entry: + .word 0x00000C02 +cache_pred_disable_mask: + .word 0xFFFFE7FB +control_stat: + .word CONTROL_STAT +control_mem_rta: + .word CONTROL_MEM_RTA_CTRL +l2dis_3630: + .word 0 +/*
* Internal functions
*/Quoted 6 lines
-/* This function implements the erratum ID i443 WA, applies to 34xx = ES3.0 */
+/* This function implements the erratum ID i443 WA, applies to 34xx = ES3.0
+ *
+ * Copied and run from SRAM in order to reconfigure the SDRCparameters.
Quoted 23 lines
+ */
.text
ENTRY(es3_sdrc_fix)
ldr r4,sdrc_syscfg@ get config addrarch/arm/mach-omap2/sleep34xx.S +0
-0@@ -634,6 +796,9 @@ ENTRY(es3_sdrc_fix)str r5, [r4] @ kick off refreshes bx lr
+/*
+ * Local variables
+ */
sdrc_syscfg:
.wordSDRC_SYSCONFIG_P
sdrc_mr_0:arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -650,119 +815,3 @@ sdrc_manual_1:.word
SDRC_MANUAL_1_P
ENTRY(es3_sdrc_fix_sz)
.word . -es3_sdrc_fixarch/arm/mach-omap2/sleep34xx.S +0
-5- -/* - * This function implements the erratum ID i581 WA: - * SDRC state restore before accessing the SDRAM - *arch/arm/mach-omap2/sleep34xx.S sdrc_manual_1:
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +0
-10- * Only used at return from non-OFF mode. For OFF - * mode the ROM code configures the SDRC and - * the DPLL before calling the restore code directly - * from DDR. - */ - -/* Make sure SDRC accesses are ok */ -wait_sdrc_ok: - -/* DPLL3 must be locked before accessing the SDRC. Maybe the HWensures this */
Quoted 102 lines
- ldr r4,
cm_idlest_ckgenarch/arm/mach-omap2/sleep34xx.S +0
-101-wait_dpll3_lock: - ldr r5, [r4] - tst r5, #1 - beq wait_dpll3_lock - - ldr r4, cm_idlest1_core -wait_sdrc_ready: - ldr r5, [r4] - tst r5, #0x2 - bne wait_sdrc_ready - /* allow DLL powerdown upon hw idle req */ - ldr r4, sdrc_power - ldr r5, [r4] - bic r5, r5, #0x40 - str r5, [r4] - -is_dll_in_lock_mode: - /* Is dll in lock mode? */ - ldr r4, sdrc_dlla_ctrl - ldr r5, [r4] - tst r5, #0x4 - bxne lr @ Return if locked - /* wait till dll locks */ -wait_dll_lock_timed: - ldr r4, wait_dll_lock_counter - add r4, r4, #1 - str r4, wait_dll_lock_counter - ldr r4, sdrc_dlla_status - /* Wait 20uS for lock */ - mov r6, #8 -wait_dll_lock: - subs r6, r6, #0x1 - beq kick_dll - ldr r5, [r4] - and r5, r5, #0x4 - cmp r5, #0x4 - bne wait_dll_lock - bx lr @ Return when locked - - /* disable/reenable DLL if not locked */ -kick_dll: - ldr r4, sdrc_dlla_ctrl - ldr r5, [r4] - mov r6, r5 - bic r6, #(1<<3) @ disable dll - str r6, [r4] - dsb - orr r6, r6, #(1<<3) @ enable dll - str r6, [r4] - dsb - ldr r4, kick_counter - add r4, r4, #1 - str r4, kick_counter - b wait_dll_lock_timed - -cm_idlest1_core: - .word CM_IDLEST1_CORE_V -cm_idlest_ckgen: - .word CM_IDLEST_CKGEN_V -sdrc_dlla_status: - .word SDRC_DLLA_STATUS_V -sdrc_dlla_ctrl: - .word SDRC_DLLA_CTRL_V -pm_prepwstst_core_p: - .word PM_PREPWSTST_CORE_P -pm_pwstctrl_mpu: - .word PM_PWSTCTRL_MPU_P -scratchpad_base: - .word SCRATCHPAD_BASE_P -sram_base: - .word SRAM_BASE_P + 0x8000 -sdrc_power: - .word SDRC_POWER_V -ttbrbit_mask: - .word 0xFFFFC000 -table_index_mask: - .word 0xFFF00000 -table_entry: - .word 0x00000C02 -cache_pred_disable_mask: - .word 0xFFFFE7FB -control_stat: - .word CONTROL_STAT -control_mem_rta: - .word CONTROL_MEM_RTA_CTRL -kernel_flush: - .word v7_flush_dcache_all -l2dis_3630: - .word 0 - /* - * When exporting to userspace while the counters are in SRAM, - * these 2 words need to be at the end to facilitate retrival! - */ -kick_counter: - .word 0 -wait_dll_lock_counter: - .word 0 - -ENTRY(omap34xx_cpu_suspend_sz) - .word . - omap34xx_cpu_suspend --Quoted 3 lines
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jean,
Quoted 49 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of [email protected]
Sent: Thursday, January 13, 2011 9:49 PM
To: [email protected]
Cc: Jean Pihet
Subject: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRFrom: Jean Pihet <[email protected]>
Most of the ASM sleep code (in
arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there. However only a small part of the code really needs to run from internal SRAM.This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.SRAM usage:
- original code:
. 560 bytes foromap3_sram_configure_core_dpll(used by DVFS), . 1368 bytes foromap_sram_idle(used by suspend/resume in
RETention),
. 124 bytes fores3_sdrc_fix(used by suspend/resume in OFF mode
on ES3.x),
. 108 bytes forsave_secure_ram_context(used on HS parts).With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the
gain in SRAM usage for suspend/resume is > 1KB.Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
Signed-off-by Jean Pihet <[email protected]>--- arch/arm/mach-omap2/pm.h | 19 ++- arch/arm/mach-omap2/pm34xx.c | 19 ++- arch/arm/mach-omap2/sleep34xx.S | 299 +++++++++++++++++++++++----- ----------- 3 files changed, 200 insertions(+), 137 deletions(-)
[...]
Quoted 26 lines
arch/arm/mach- renamed from arch/arm/mach-omap2/sleep34xx.S +0
-0
omap2/sleep34xx.S
index 98d8232..ced85b5 100644arch/arm/mach-omap2/sleep34xx.S +0
-1@@ -163,8 +163,10 @@ ENTRY(save_secure_ram_context_sz) * * * Notes: - * - this code gets copied to internal SRAM at boot and after wake-up
- * from OFF mode. The execution pointer in SRAM is_omap_sram_idle.
+ * - only the minimum set of functions gets copied to internal SRAM at boot
+ * and after wake-up from OFF mode, cf.omap_push_sram_idle. The
function
+ * pointers in SDRAM or SRAM are called depending on the desired
low power
+ * target state.
* - when the OMAP wakes up it continues at different execution
points
* depending on the low power mode (non-OFF vs OFF modes),
* cf. 'Resume path for xxx mode' comments.arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -181,9 +183,15 @@ ENTRY(omap34xx_cpu_suspend) * 3 - Both L1 and L2 lost
arch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend) · line 190
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +3
-3*/ - /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 - beq omap3_do_wfi + /* + * For OFF mode: save context and jump to WFI in SDRAM (omap3_do_wfi) + * For non-OFF modes: jump to the WFI code in SRAM (omap3_do_wfi_sram)
Why is this distinction? For non-low power modes it should be even safer to issue WFI from DDR itself.
Do I miss any errata here ?
Quoted 5 lines
arch/arm/mach-omap2/sleep34xx.S +5
-0+ */ + ldr r4, omap3_do_wfi_sram_addr + ldr r5, [r4] + cmp r1, #0x0 @ If no context save required, + bxeq r5 @ jump to the WFI code in SRAM
Quoted 104 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:[email protected]]
Sent: Saturday, January 29, 2011 10:45 PM
To: [email protected]; [email protected]
Cc: Jean Pihet-XID
Subject: RE: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRJean,
Quoted 38 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of [email protected]
Sent: Thursday, January 13, 2011 9:49 PM
To: [email protected]
Cc: Jean Pihet
Subject: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRFrom: Jean Pihet <[email protected]>
Most of the ASM sleep code (in
arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there. However only a small part of the code really needs to run from internal SRAM.This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.SRAM usage:
- original code:
. 560 bytes foromap3_sram_configure_core_dpll(used by DVFS), . 1368 bytes foromap_sram_idle(used by suspend/resume in
RETention),
. 124 bytes fores3_sdrc_fix(used by suspend/resume in OFF mode
on ES3.x),
. 108 bytes forsave_secure_ram_context(used on HS parts).With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the
gain in SRAM usage for suspend/resume is > 1KB.Quoted 8 lines
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
Signed-off-by Jean Pihet <[email protected]>--- arch/arm/mach-omap2/pm.h | 19 ++- arch/arm/mach-omap2/pm34xx.c | 19 ++- arch/arm/mach-omap2/sleep34xx.S | 299 +++++++++++++++++++++++-----
Quoted 3 lines
-----------
3 files changed, 200 insertions(+), 137 deletions(-)[...]
arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 166
Quoted 10 lines
arch/arm/mach- renamed from arch/arm/mach-omap2/sleep34xx.S +0
-0
omap2/sleep34xx.S
index 98d8232..ced85b5 100644arch/arm/mach-omap2/sleep34xx.S +0
-1@@ -163,8 +163,10 @@ ENTRY(save_secure_ram_context_sz) * * * Notes: - * - this code gets copied to internal SRAM at boot and afterwake-
Quoted 4 lines
up
- * from OFF mode. The execution pointer in SRAM is_omap_sram_idle.
+ * - only the minimum set of functions gets copied to internalSRAM
Quoted 2 lines
at boot
+ * and after wake-up from OFF mode, cf.omap_push_sram_idle.The
Quoted 2 lines
function
+ * pointers in SDRAM or SRAM are called depending on thedesired
Quoted 8 lines
low power
+ * target state.
* - when the OMAP wakes up it continues at different execution
points
* depending on the low power mode (non-OFF vs OFF modes),
* cf. 'Resume path for xxx mode' comments.arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -181,9 +183,15 @@ ENTRY(omap34xx_cpu_suspend) * 3 - Both L1 and L2 lostarch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend) · line 190
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +3
-3*/ - /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 - beq omap3_do_wfi + /* + * For OFF mode: save context and jump to WFI in SDRAM (omap3_do_wfi) + * For non-OFF modes: jump to the WFI code in SRAM (omap3_do_wfi_sram)Why is this distinction? For non-low power modes it should be even safer to issue WFI from DDR itself.
Quoted 2 lines
Do I miss any errata here ?
Looking further into code, I also noticed that the DDR self refresh is attempted for every WFI. This certainly isn't correct and should be attempted only if core OFF or RET is attempted. Putting DDR to self refresh comes with latency cost and you certainly don't want to incur that for lower C states where may be just MPU hits lower states.
Regards,
Santosh
Hi Santosh,
Quoted 104 lines · Santosh Shilimkar
Quoted 104 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:[email protected]]
Sent: Saturday, January 29, 2011 10:45 PM
To: [email protected]; [email protected]
Cc: Jean Pihet-XID
Subject: RE: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRJean,
Quoted 38 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of [email protected]
Sent: Thursday, January 13, 2011 9:49 PM
To: [email protected]
Cc: Jean Pihet
Subject: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRFrom: Jean Pihet <[email protected]>
Most of the ASM sleep code (in
arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there. However only a small part of the code really needs to run from internal SRAM.This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.SRAM usage:
- original code:
. 560 bytes foromap3_sram_configure_core_dpll(used by DVFS), . 1368 bytes foromap_sram_idle(used by suspend/resume in RETention),
. 124 bytes fores3_sdrc_fix(used by suspend/resume in OFF mode on ES3.x),
. 108 bytes forsave_secure_ram_context(used on HS parts).With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the
gain in SRAM usage for suspend/resume is > 1KB.Quoted 8 lines
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
Signed-off-by Jean Pihet <[email protected]>---
arch/arm/mach-omap2/pm.h | 19 ++-arch/arm/mach-omap2/pm34xx.c| 19 ++-arch/arm/mach-omap2/sleep34xx.S| 299 +++++++++++++++++++++++-----
Quoted 3 lines
-----------
3 files changed, 200 insertions(+), 137 deletions(-)[...]
arch/arm/mach-omap2/sleep34xx.S ENTRY(save_secure_ram_context_sz) · line 166
Quoted 10 lines
arch/arm/mach- renamed from arch/arm/mach-omap2/sleep34xx.S +0
-0
omap2/sleep34xx.S
index 98d8232..ced85b5 100644arch/arm/mach-omap2/sleep34xx.S +0
-1@@ -163,8 +163,10 @@ ENTRY(save_secure_ram_context_sz) * * * Notes: - * - this code gets copied to internal SRAM at boot and afterwake-
Quoted 4 lines
up
- * from OFF mode. The execution pointer in SRAM is_omap_sram_idle.
+ * - only the minimum set of functions gets copied to internalSRAM
Quoted 2 lines
at boot
+ * and after wake-up from OFF mode, cf.omap_push_sram_idle.The
Quoted 2 lines
function
+ * pointers in SDRAM or SRAM are called depending on thedesired
Quoted 8 lines
low power
+ * target state.
* - when the OMAP wakes up it continues at different execution points
* depending on the low power mode (non-OFF vs OFF modes),
* cf. 'Resume path for xxx mode' comments.arch/arm/mach-omap2/sleep34xx.S +0
-0@@ -181,9 +183,15 @@ ENTRY(omap34xx_cpu_suspend) * 3 - Both L1 and L2 lostarch/arm/mach-omap2/sleep34xx.S ENTRY(omap34xx_cpu_suspend) · line 190
Quoted 10 lines
arch/arm/mach-omap2/sleep34xx.S +3
-3*/ - /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 - beq omap3_do_wfi + /* + * For OFF mode: save context and jump to WFI in SDRAM (omap3_do_wfi) + * For non-OFF modes: jump to the WFI code in SRAM (omap3_do_wfi_sram)Why is this distinction? For non-low power modes it should be even safer to issue WFI from DDR itself.
Quoted 1 line
Quoted 1 line
Do I miss any errata here ?
For non-OFF modes the erratum ID i581 WA forces us to restore the SDRC state before accessing the SDRAM, cf. wait_sdrc_ok that implements that. Given that the non-OFF mode triggering WFI needs to be run from SRAM.
Quoted 7 lines
Looking further into code, I also noticed that the DDR self refresh is attempted for every WFI. This certainly isn't correct and should be attempted only if core OFF or RET is attempted. Putting DDR to self refresh comes with latency cost and you certainly don't want to incur that for lower C states where may be just MPU hits lower states.
The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.
Also the code in wait_sdrc_ok will exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since the actual CORE hit state is unknow after wake-up from WFI the wait_sdrc_ok code always run at wake-up from MPU RET.
Does that makes sense?
Quoted 4 lines
Regards,
Santosh
Thanks,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Monday, January 31, 2011 4:07 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRHi Santosh,
[.....]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
+ * For OFF mode: save context and jump to WFI in SDRAM (
omap3_do_wfi)
+ * For non-OFF modes: jump to the WFI code in SRAM (omap3_do_wfi_sram)Why is this distinction? For non-low power modes it should be even safer to issue WFI from DDR itself.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Do I miss any errata here ?
For non-OFF modes the erratum ID i581 WA forces us to restore the SDRC
state before accessing the SDRAM, cf.wait_sdrc_okthat implements that. Given that the non-OFF mode triggering WFI needs to be run from
SRAM.
The errata is applicable when CORE hits low power states and DPLL can autoidle. Not sure how are linking this with all non-OFF modes.
Quoted 14 lines
Quoted 7 lines
Looking further into code, I also noticed that the DDR self refresh is attempted for every WFI. This certainly isn't correct and should be attempted only if core OFF or RET is attempted. Putting DDR to self refresh comes with latency cost and you certainly don't want to incur that for lower C states where may be just MPU hits lower states.
The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the
settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.
Quoted 8 lines
Also the code in
wait_sdrc_okwill exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since
the actual CORE hit state is unknow after wake-up from WFI thewait_sdrc_okcode always run at wake-up from MPU RET.Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
Regards,
Santosh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Santosh,
Quoted 55 lines · Santosh Shilimkar
Quoted 8 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Monday, January 31, 2011 4:07 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRHi Santosh,
[.....]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
+ * For OFF mode: save context and jump to WFI in SDRAM (
omap3_do_wfi)
+ * For non-OFF modes: jump to the WFI code in SRAM (omap3_do_wfi_sram)Why is this distinction? For non-low power modes it should be even safer to issue WFI from DDR itself.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Do I miss any errata here ?
For non-OFF modes the erratum ID i581 WA forces us to restore the SDRC
state before accessing the SDRAM, cf.wait_sdrc_okthat implements that. Given that the non-OFF mode triggering WFI needs to be run from
SRAM.The errata is applicable when CORE hits low power states and DPLL can autoidle. Not sure how are linking this with all non-OFF modes.
Quoted 14 lines
Quoted 7 lines
Looking further into code, I also noticed that the DDR self refresh is attempted for every WFI. This certainly isn't correct and should be attempted only if core OFF or RET is attempted. Putting DDR to self refresh comes with latency cost and you certainly don't want to incur that for lower C states where may be just MPU hits lower states.
The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the
settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.Quoted 8 lines
Also the code in
wait_sdrc_okwill exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since
the actual CORE hit state is unknow after wake-up from WFI thewait_sdrc_okcode always run at wake-up from MPU RET.Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
Quoted 8 lines
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
No. Only the MPU attempted state is checked (this actually is the 'save_state' parameter passed to omap_cpu_suspend).
So it makes sense to check the CORE attempted state in order to decide to run the WFI from internal SRAM or DDR.
The MPU attempted state is used to decide whether to save the MPU/L1/L2 context.
Quoted 4 lines
Regards,
Santosh
Thanks,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 4:53 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDR
[...]
Quoted 14 lines
Quoted 6 lines
Quoted 2 lines
Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
Quoted 8 lines
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
Quoted 9 lines
No. Only the MPU attempted state is checked (this actually is the '
save_state' parameter passed toomap_cpu_suspend).
So it makes sense to check the CORE attempted state in order to decide
to run the WFI from internal SRAM or DDR.The MPU attempted state is used to decide whether to save the MPU/L1/L2 context.
Looks like you miss-understood my point. As I understand from errata, as long as core clock domain can idle with core dpll divider auto idle enabled, the errata is applicable.
So the only check needed is to see if the core clockdomain hw_auto or sw sleep is enabled.
If it is suppose to be not idle(we force few C-states where CORE inactive is avoided for faster response), we can execute WFI from DDR with not enabling self refresh.
Rest of the scenario can follow the SRAM path.
Hope this is clear to you.
Regards,
Santosh
Jean,
Quoted 46 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 5:01 PM
To: Jean Pihet
Cc: [email protected]; Jean Pihet-XID
Subject: RE: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRQuoted 7 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 4:53 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDR[...]
Quoted 14 lines
Quoted 6 lines
Quoted 2 lines
Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
Quoted 8 lines
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
Quoted 9 lines
No. Only the MPU attempted state is checked (this actually is the '
save_state' parameter passed toomap_cpu_suspend).
So it makes sense to check the CORE attempted state in order to decide
to run the WFI from internal SRAM or DDR.The MPU attempted state is used to decide whether to save the MPU/L1/L2 context.
Looks like you miss-understood my point. As I understand from errata, as long as core clock domain can idle with core dpll divider auto idle enabled, the errata is applicable.
So the only check needed is to see if the core clockdomain
hw_autoor sw sleep is enabled.
Quoted 8 lines
If it is suppose to be not idle(we force few C-states where CORE inactive is avoided for faster response), we can execute WFI from DDR with not enabling self refresh.
Rest of the scenario can follow the SRAM path.
Hope this is clear to you.
As per further discussion, I have updated your
patch to address above by using core clockdomain
state.
Have tested OFF and RET with this new update and they work as expected. Feel free to update further if needed.
------
Quoted 1 line
From
49fe8164a40431807495638ec23639cc9bc53cb9Mon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Sat, 29 Jan 2011 20:51:19 +0530
Subject: [PATCH] OMAP3: run the ASM sleep code from DDR
Most of the ASM sleep code (in arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there.
However only a small part of the code really needs to run from internal SRAM.
This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.
SRAM usage:
- original code:
. 560 bytes for omap3_sram_configure_core_dpll (used by DVFS), . 1368 bytes for omap_sram_idle (used by suspend/resume in RETention), . 124 bytes for es3_sdrc_fix (used by suspend/resume in OFF mode on
ES3.x),
. 108 bytes for save_secure_ram_context (used on HS parts).
With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the
gain in SRAM usage for suspend/resume is > 1KB.
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
--- arch/arm/mach-omap2/pm.h | 19 ++- arch/arm/mach-omap2/pm34xx.c | 19 ++- arch/arm/mach-omap2/sleep34xx.S | 321 +++++++++++++++++++++++---------------- 3 files changed, 219 insertions(+), 140 deletions(-)
arch/arm/mach-omap2/pm.h +2 -0
@@ -87,18 +87,29 @@ extern int pm_dbg_regset_init(int reg_set);#define pm_dbg_regset_init (reg_set) do {} while (0);#endif /* CONFIG_PM_DEBUG */ +/* 24xx */ extern void omap24xx_idle_loop_suspend (void ); +extern unsigned int omap24xx_idle_loop_suspend_sz; extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem
*sdrc_dlla_ctrl,
void __iomem *sdrc_power);
+extern unsigned int omap24xx_cpu_suspend_sz;
+
+/* 3xxx */
extern void omap34xx_cpu_suspend(u32 *addr, int save_state);
+
+/* 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 void save_secure_ram_context(u32 *addr);
-extern void omap3_save_scratchpad_contents(void);
-extern unsigned int omap24xx_idle_loop_suspend_sz;
extern unsigned int save_secure_ram_context_sz;
-extern unsigned int omap24xx_cpu_suspend_sz; -extern unsigned int omap34xx_cpu_suspend_sz; +
+extern void omap3_save_scratchpad_contents(void);
#define PM_RTA_ERRATUM_i608 (1 << 0)
#define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)
arch/arm/mach-omap2/pm34xx.c +2 -6
@@ -83,9 +83,8 @@ struct power_state {static LIST_HEAD (pwrst_list); -static void (*_omap_sram_idle)(u32 *addr,int save_state); -static int (*_omap_save_secure_sram)(u32 *addr); +void (*omap3_do_wfi_sram)(void );static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;
@@ -357,9 +356,6 @@ void omap_sram_idle(void)int core_prev_state, per_prev_state;u32 sdrc_pwr =0 ; -if (!_omap_sram_idle) -return ; -pwrdm_clear_all_prev_pwrst (mpu_pwrdm);pwrdm_clear_all_prev_pwrst (neon_pwrdm);pwrdm_clear_all_prev_pwrst (core_pwrdm);
@@ -444,7 +440,7 @@ void omap_sram_idle(void)* get saved. The restore path then reads from this * location and restores them back. */ -_omap_sram_idle (omap3_arm_context, save_state); +omap34xx_cpu_suspend (omap3_arm_context, save_state);cpu_init ();if (is_suspending ())
@@ -993,10 +989,17 @@ static int __init clkdms_setup(struct clockdomain
*clkdm, void *unused)
return 0;
}
+/*
+ * Push functions to SRAM
+ *
+ * The minimum set of functions is pushed to SRAM for execution:
+ * - omap3_do_wfi for erratum i581 WA,
+ * - save_secure_ram_context for security extensions.
+ */
void omap_push_sram_idle(void)
{
- _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
- omap34xx_cpu_suspend_sz);
+ omap3_do_wfi_sram = omap_sram_push(omap3_do_wfi, omap3_do_wfi_sz);
+
if (omap_type() != OMAP2_DEVICE_TYPE_GP)
_omap_save_secure_sram =
omap_sram_push(save_secure_ram_context,
save_secure_ram_context_sz);
(quoted diff) +0 -0
b/arch/arm/mach-omap2/sleep34xx.S
index 98d8232..8a987f7 100644
arch/arm/mach-omap2/sleep34xx.S +0 -0
@@ -42,6 +42,7 @@ OMAP3430_PM_PREPWSTST #define PM_PWSTCTRL_MPU_P OMAP3430_PRM_BASE + MPU_MOD +
OMAP2_PM_PWSTCTRL
#define CM_IDLEST1_CORE_V OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST1)
+#define CM_CLKSTCTRL_CORE_V OMAP34XX_CM_REGADDR(CORE_MOD,OMAP2_CM_CLKSTCTRL)
#define CM_IDLEST_CKGEN_V OMAP34XX_CM_REGADDR(PLL_MOD, CM_IDLEST)
#define SRAM_BASE_P OMAP3_SRAM_PA
#define CONTROL_STAT OMAP343X_CTRL_BASE +OMAP343X_CONTROL_STATUS
@@ -163,8 +164,10 @@ ENTRY(save_secure_ram_context_sz)
*
*
* Notes:
- * - this code gets copied to internal SRAM at boot and after wake-up
- * from OFF mode. The execution pointer in SRAM is _omap_sram_idle.
+ * - only the minimum set of functions gets copied to internal SRAM at boot
+ * and after wake-up from OFF mode, cf. omap_push_sram_idle. The
function
+ * pointers in SDRAM or SRAM are called depending on the desired low
power
+ * target state.
* - when the OMAP wakes up it continues at different execution points
* depending on the low power mode (non-OFF vs OFF modes),
* cf. 'Resume path for xxx mode' comments.
@@ -181,9 +184,15 @@ ENTRY(omap34xx_cpu_suspend)
* 3 - Both L1 and L2 lost
*/
- /* Directly jump to WFI is the context save is not required */
- cmp r1, #0x0
- beq omap3_do_wfi
+ /*
+ * For OFF mode: save context and jump to WFI in SDRAM
(omap3_do_wfi)
+ * For non-OFF modes: jump to the WFI code in SRAM
(omap3_do_wfi_sram)
+ */
+ ldr r4, omap3_do_wfi_sram_addr
+ ldr r5, [r4]
+ cmp r1, #0x0 @ If no context save required,
+ bxeq r5 @ jump to the WFI code in SRAM
+
/* Otherwise fall through to the save context code */
save_context_wfi:
@@ -268,7 +277,7 @@ clean_caches:
* mcr p15, 0, r11, c7, c11, 1
*/
cmp r1, #0x1 @ Check whether L2 inval is
required
- beq omap3_do_wfi
+ beq do_WFI
clean_l2:
/*
@@ -282,7 +291,44 @@ clean_l2:
mov lr, pc
bx r1
-omap3_do_wfi:
+do_WFI:
+ ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE
+ ldr r5, [r4] @ read the contents ofCLKSTCTRL_CORE
+ and r5, r5, #0x3
+ cmp r5, #0x3
+ beq omap3_do_wfi @ Jumpt to SRAM function
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4
+ mcr p15, 0, r1, c7, c10, 5
+
+ wfi @ wait for interrupt
+
+ ldmfd sp!, {r0-r12, pc} @ restore regs and return
+
+
+/*
+ * Local variables
+ */
+omap3_do_wfi_sram_addr:
+ .word omap3_do_wfi_sram
+kernel_flush:
+ .word v7_flush_dcache_all
+
+/* ===================================
+ * == WFI instruction => Enter idle ==
+ * ===================================
+ */
+
+/*
+ * Do WFI instruction
+ * Includes the resume path for non-OFF modes
+ *
+ * This code gets copied to internal SRAM and is accessible
+ * from both SDRAM and SRAM:
+ * - executed from SRAM for non-off modes (omap3_do_wfi_sram),
+ * - executed from SDRAM for OFF mode (omap3_do_wfi).
+ */
+ENTRY(omap3_do_wfi)
ldr r4, sdrc_power @ read the SDRC_POWER register
ldr r5, [r4] @ read the contents of SDRC_POWER
orr r5, r5, #0x40 @ enable self refresh on idle req
@@ -302,7 +348,7 @@ omap3_do_wfi:
/*
* ===================================
- * == Resume path for non-OFF modes ==
+ * == Resume path for OFF/RET modes ==
* ===================================
*/
nop
@@ -315,15 +361,113 @@ omap3_do_wfi:
nop
nop
nop
- bl wait_sdrc_ok
+
+/*
+ * wait_sdrc_ok implements the erratum ID i581 WA:
+ * SDRC state restore before accessing the SDRAM
+ *
+ * Only used at return from non-OFF mode. For OFF
+ * mode the ROM code configures the SDRC and
+ * the DPLL before calling the restore code directly
+ * from SDRAM.
+ */
+
+/* Make sure SDRC accesses are ok */
+wait_sdrc_ok:
+
+/* DPLL3 must be locked before accessing the SDRC. Maybe the HW ensures this */
+ ldr r4, cm_idlest_ckgen
+wait_dpll3_lock:
+ ldr r5, [r4]
+ tst r5, #1
+ beq wait_dpll3_lock
+
+ ldr r4, cm_idlest1_core
+wait_sdrc_ready:
+ ldr r5, [r4]
+ tst r5, #0x2
+ bne wait_sdrc_ready
+ /* allow DLL powerdown upon hw idle req */
+ ldr r4, sdrc_power
+ ldr r5, [r4]
+ bic r5, r5, #0x40
+ str r5, [r4]
+
+is_dll_in_lock_mode:
+ /* Is dll in lock mode? */
+ ldr r4, sdrc_dlla_ctrl
+ ldr r5, [r4]
+ tst r5, #0x4
+ bne exit_nonoff_modes @ Return if locked
+
+ /* wait till dll locks */
+wait_dll_lock_timed:
+ ldr r4, wait_dll_lock_counter
+ add r4, r4, #1
+ str r4, wait_dll_lock_counter
+ ldr r4, sdrc_dlla_status
+ /* Wait 20uS for lock */
+ mov r6, #8
+wait_dll_lock:
+ subs r6, r6, #0x1
+ beq kick_dll
+ ldr r5, [r4]
+ and r5, r5, #0x4
+ cmp r5, #0x4
+ bne wait_dll_lock
+ b exit_nonoff_modes @ Return when locked
+
+ /* disable/reenable DLL if not locked */
+kick_dll:
+ ldr r4, sdrc_dlla_ctrl
+ ldr r5, [r4]
+ mov r6, r5
+ bic r6, #(1<<3) @ disable dll
+ str r6, [r4]
+ dsb
+ orr r6, r6, #(1<<3) @ enable dll
+ str r6, [r4]
+ dsb
+ ldr r4, kick_counter
+ add r4, r4, #1
+ str r4, kick_counter
+ b wait_dll_lock_timed
/*
* ===================================
- * == Exit point from non-OFF modes ==
+ * == Exit point from OFF/RET modes ==
* ===================================
*/
+exit_nonoff_modes:
ldmfd sp!, {r0-r12, pc} @ restore regs and return
+/*
+ * Local variables
+ */
+sdrc_power:
+ .word SDRC_POWER_V
+cm_idlest1_core:
+ .word CM_IDLEST1_CORE_V
+cm_clkstctrl_core:
+ .word CM_CLKSTCTRL_CORE_V
+cm_idlest_ckgen:
+ .word CM_IDLEST_CKGEN_V
+sdrc_dlla_status:
+ .word SDRC_DLLA_STATUS_V
+sdrc_dlla_ctrl:
+ .word SDRC_DLLA_CTRL_V
+ /*
+ * When exporting to userspace while the counters are in SRAM,
+ * these 2 words need to be at the end to facilitate retrival!
+ */
+kick_counter:
+ .word 0
+wait_dll_lock_counter:
+ .word 0
+
+ENTRY(omap3_do_wfi_sz)
+ .word . - omap3_do_wfi
+
/*
* ==============================
@@ -339,6 +483,10 @@ omap3_do_wfi:
* restore_es3: applies to 34xx >= ES3.0 * restore_3630: applies to 36xx * restore: common code for 3xxx
+ *
+ * Note: when back from CORE and MPU OFF mode we are running
+ * from SDRAM, without MMU, without the caches and prediction.
+ * Also the SRAM content has been cleared.
*/
restore_es3:
ldr r5, pm_prepwstst_core_p
@@ -357,7 +505,8 @@ copy_to_sram:
bne copy_to_sram
ldr r1, sram_base
blx r1
- b restore
+
+ b restore @ Fall through to common code
restore_3630:
ldr r1, pm_prepwstst_core_p
@@ -600,12 +749,41 @@ usettbr0:
*/
ldmfd sp!, {r0-r12, pc} @ restore regs and return
+/*
+ * Local variables
+ */
+pm_prepwstst_core_p:
+ .word PM_PREPWSTST_CORE_P
+pm_pwstctrl_mpu:
+ .word PM_PWSTCTRL_MPU_P
+scratchpad_base:
+ .word SCRATCHPAD_BASE_P
+sram_base:
+ .word SRAM_BASE_P + 0x8000
+ttbrbit_mask:
+ .word 0xFFFFC000
+table_index_mask:
+ .word 0xFFF00000
+table_entry:
+ .word 0x00000C02
+cache_pred_disable_mask:
+ .word 0xFFFFE7FB
+control_stat:
+ .word CONTROL_STAT
+control_mem_rta:
+ .word CONTROL_MEM_RTA_CTRL
+l2dis_3630:
+ .word 0
+
/*
* Internal functions
*/
-/* This function implements the erratum ID i443 WA, applies to 34xx >= ES3.0 */
+/* This function implements the erratum ID i443 WA, applies to 34xx >= ES3.0
+ *
+ * Copied and run from SRAM in order to reconfigure the SDRC parameters.
+ */
.text
ENTRY(es3_sdrc_fix)
ldr r4, sdrc_syscfg @ get config addr
@@ -634,6 +812,9 @@ ENTRY(es3_sdrc_fix)
str r5, [r4] @ kick off refreshes
bx lr
+/*
+ * Local variables
+ */
sdrc_syscfg:
.word SDRC_SYSCONFIG_P
sdrc_mr_0:
@@ -650,119 +831,3 @@ sdrc_manual_1:
.word SDRC_MANUAL_1_P
ENTRY(es3_sdrc_fix_sz)
.word . - es3_sdrc_fix
-
-/*
- * This function implements the erratum ID i581 WA:
- * SDRC state restore before accessing the SDRAM
- *
- * Only used at return from non-OFF mode. For OFF
- * mode the ROM code configures the SDRC and
- * the DPLL before calling the restore code directly
- * from DDR.
- */
-
-/* Make sure SDRC accesses are ok */
-wait_sdrc_ok:
-
-/* DPLL3 must be locked before accessing the SDRC. Maybe the HW ensures this */
- ldr r4, cm_idlest_ckgen
-wait_dpll3_lock:
- ldr r5, [r4]
- tst r5, #1
- beq wait_dpll3_lock
-
- ldr r4, cm_idlest1_core
-wait_sdrc_ready:
- ldr r5, [r4]
- tst r5, #0x2
- bne wait_sdrc_ready
- /* allow DLL powerdown upon hw idle req */
- ldr r4, sdrc_power
- ldr r5, [r4]
- bic r5, r5, #0x40
- str r5, [r4]
-
-is_dll_in_lock_mode:
- /* Is dll in lock mode? */
- ldr r4, sdrc_dlla_ctrl
- ldr r5, [r4]
- tst r5, #0x4
- bxne lr @ Return if locked
- /* wait till dll locks */
-wait_dll_lock_timed:
- ldr r4, wait_dll_lock_counter
- add r4, r4, #1
- str r4, wait_dll_lock_counter
- ldr r4, sdrc_dlla_status
- /* Wait 20uS for lock */
- mov r6, #8
-wait_dll_lock:
- subs r6, r6, #0x1
- beq kick_dll
- ldr r5, [r4]
- and r5, r5, #0x4
- cmp r5, #0x4
- bne wait_dll_lock
- bx lr @ Return when locked
-
- /* disable/reenable DLL if not locked */
-kick_dll:
- ldr r4, sdrc_dlla_ctrl
- ldr r5, [r4]
- mov r6, r5
- bic r6, #(1<<3) @ disable dll
- str r6, [r4]
- dsb
- orr r6, r6, #(1<<3) @ enable dll
- str r6, [r4]
- dsb
- ldr r4, kick_counter
- add r4, r4, #1
- str r4, kick_counter
- b wait_dll_lock_timed
-
-cm_idlest1_core:
- .word CM_IDLEST1_CORE_V
-cm_idlest_ckgen:
- .word CM_IDLEST_CKGEN_V
-sdrc_dlla_status:
- .word SDRC_DLLA_STATUS_V
-sdrc_dlla_ctrl:
- .word SDRC_DLLA_CTRL_V
-pm_prepwstst_core_p:
- .word PM_PREPWSTST_CORE_P
-pm_pwstctrl_mpu:
- .word PM_PWSTCTRL_MPU_P
-scratchpad_base:
- .word SCRATCHPAD_BASE_P
-sram_base:
- .word SRAM_BASE_P + 0x8000
-sdrc_power:
- .word SDRC_POWER_V
-ttbrbit_mask:
- .word 0xFFFFC000
-table_index_mask:
- .word 0xFFF00000
-table_entry:
- .word 0x00000C02
-cache_pred_disable_mask:
- .word 0xFFFFE7FB
-control_stat:
- .word CONTROL_STAT
-control_mem_rta:
- .word CONTROL_MEM_RTA_CTRL
-kernel_flush:
- .word v7_flush_dcache_all
-l2dis_3630:
- .word 0
- /*
- * When exporting to userspace while the counters are in SRAM,
- * these 2 words need to be at the end to facilitate retrival!
- */
-kick_counter:
- .word 0
-wait_dll_lock_counter:
- .word 0
-
-ENTRY(omap34xx_cpu_suspend_sz)
- .word . - omap34xx_cpu_suspend
Signature · 1 line
1.6.0.4
From 49fe8164a40431807495638ec23639cc9bc53cb9 Mon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Sat, 29 Jan 2011 20:51:19 +0530
Subject: [PATCH] OMAP3: run the ASM sleep code from DDR
Most of the ASM sleep code (in arch/arm/mach-omap2/sleep34xx.S) is copied to internal SRAM and run from there.
However only a small part of the code really needs to run from internal SRAM.
This fix lets most of the ASM idle code run from the DDR in order to minimize the SRAM usage. No performance loss or gain can be measured with a 32KHz clock period.
The only pieces of code that are mandatory in SRAM are:
- the i443 erratum WA,
- the i581 erratum WA,
- the security extension code.
SRAM usage:
- original code:
. 560 bytes for omap3_sram_configure_core_dpll (used by DVFS), . 1368 bytes for omap_sram_idle (used by suspend/resume in RETention), . 124 bytes for es3_sdrc_fix (used by suspend/resume in OFF mode on ES3.x), . 108 bytes for save_secure_ram_context (used on HS parts).
With this fix the usage for suspend/resume in RETention goes down 312 bytes, so the gain in SRAM usage for suspend/resume is > 1KB.
Tested on OMAP3EVM, Beagleboard (ES2.x) and N900 (ES3.1) in idle with full RET and OFF modes.
--- arch/arm/mach-omap2/pm.h | 19 ++- arch/arm/mach-omap2/pm34xx.c | 19 ++- arch/arm/mach-omap2/sleep34xx.S | 321 +++++++++++++++++++++++---------------- 3 files changed, 219 insertions(+), 140 deletions(-)
arch/arm/mach-omap2/pm.h +15 -4
@@ -87,18 +87,29 @@ extern int pm_dbg_regset_init(int reg_set);#define pm_dbg_regset_init (reg_set) do {} while (0);#endif /* CONFIG_PM_DEBUG */ +/* 24xx */ extern void omap24xx_idle_loop_suspend (void ); +extern unsigned int omap24xx_idle_loop_suspend_sz;extern void omap24xx_cpu_suspend (u32 dll_ctrl,void __iomem *sdrc_dlla_ctrl,void __iomem *sdrc_power); +extern unsigned int omap24xx_cpu_suspend_sz; + +/* 3xxx */ extern void omap34xx_cpu_suspend (u32 *addr,int save_state); + +/* 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 void save_secure_ram_context (u32 *addr); -extern void omap3_save_scratchpad_contents (void ); -extern unsigned int omap24xx_idle_loop_suspend_sz;extern unsigned int save_secure_ram_context_sz; -extern unsigned int omap24xx_cpu_suspend_sz; -extern unsigned int omap34xx_cpu_suspend_sz; + +extern void omap3_save_scratchpad_contents (void );#define PM_RTA_ERRATUM_i608 (1 << 0)#define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)
arch/arm/mach-omap2/pm34xx.c +11 -8
@@ -83,9 +83,8 @@ struct power_state {static LIST_HEAD (pwrst_list); -static void (*_omap_sram_idle)(u32 *addr,int save_state); -static int (*_omap_save_secure_sram)(u32 *addr); +void (*omap3_do_wfi_sram)(void );static struct powerdomain *mpu_pwrdm, *neon_pwrdm;static struct powerdomain *core_pwrdm, *per_pwrdm;
@@ -357,9 +356,6 @@ void omap_sram_idle(void)int core_prev_state, per_prev_state;u32 sdrc_pwr =0 ; -if (!_omap_sram_idle) -return ; -pwrdm_clear_all_prev_pwrst (mpu_pwrdm);pwrdm_clear_all_prev_pwrst (neon_pwrdm);pwrdm_clear_all_prev_pwrst (core_pwrdm);
@@ -444,7 +440,7 @@ void omap_sram_idle(void)* get saved. The restore path then reads from this * location and restores them back. */ -_omap_sram_idle (omap3_arm_context, save_state); +omap34xx_cpu_suspend (omap3_arm_context, save_state);cpu_init ();if (is_suspending ())
@@ -993,10 +989,17 @@ static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)return 0 ; } +/* +* Push functions to SRAM +* +* The minimum set of functions is pushed to SRAM for execution: +* - omap3_do_wfi for erratum i581 WA, +* - save_secure_ram_context for security extensions. +*/ void omap_push_sram_idle (void ) { - _omap_sram_idle =omap_sram_push (omap34xx_cpu_suspend, - omap34xx_cpu_suspend_sz); + omap3_do_wfi_sram =omap_sram_push (omap3_do_wfi, omap3_do_wfi_sz); +if (omap_type () !=OMAP2_DEVICE_TYPE_GP ) _omap_save_secure_sram =omap_sram_push (save_secure_ram_context, save_secure_ram_context_sz);
arch/arm/mach-omap2/sleep34xx.S +193 -128
402 lines not on this page · raw message
Signature · 1 line
1.6.0.4
Hi Santosh, Benoit, Kevin,
I would like to revive this discussion. Can you give some feedback on the self-refresh problem that is proposed in the latest patch from Santosh? Cf. below for more details.
Quoted 51 lines · Santosh Shilimkar
Jean,
Quoted 50 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 5:01 PM
To: Jean Pihet
Cc: [email protected]; Jean Pihet-XID
Subject: RE: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRQuoted 7 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 4:53 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDR[...]
Quoted 14 lines
Quoted 6 lines
Quoted 2 lines
Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
Quoted 8 lines
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
Quoted 9 lines
No. Only the MPU attempted state is checked (this actually is the '
save_state' parameter passed toomap_cpu_suspend).
So it makes sense to check the CORE attempted state in order to decide
to run the WFI from internal SRAM or DDR.The MPU attempted state is used to decide whether to save the MPU/L1/L2 context.
Looks like you miss-understood my point. As I understand from errata, as long as core clock domain can idle with core dpll divider auto idle enabled, the errata is applicable.
So the only check needed is to see if the core clockdomain
hw_autoor sw sleep is enabled.If it is suppose to be not idle(we force few C-states where CORE inactive is avoided for faster response), we can execute WFI from DDR with not enabling self refresh.
Is this the way to go?
Quoted 17 lines
Quoted 4 lines
Rest of the scenario can follow the SRAM path.
Hope this is clear to you.
As per further discussion, I have updated your
patch to address above by using core clockdomain
state.Have tested OFF and RET with this new update and they work as expected. Feel free to update further if needed.
------
From49fe8164a40431807495638ec23639cc9bc53cb9Mon Sep 17 00:00:00 2001
From: Jean Pihet <[email protected]>
Date: Sat, 29 Jan 2011 20:51:19 +0530
Subject: [PATCH] OMAP3: run the ASM sleep code from DDR
...
Quoted 12 lines
arch/arm/mach-omap2/sleep34xx.S +3
-1-omap3_do_wfi: +do_WFI: + ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE + ldr r5, [r4] @ read the contents of
CLKSTCTRL_CORE
+ and r5, r5, #0x3
+ cmp r5, #0x3
+ beqomap3_do_wfi@ Jumpt to SRAM function
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4
+ mcr p15, 0, r1, c7, c10, 5
arch/arm/mach-omap2/sleep34xx.S clean_l2: · line 306
Quoted 4 lines
arch/arm/mach-omap2/sleep34xx.S +4
-0+ + wfi @ wait for interrupt + + ldmfd sp!, {r0-r12, pc} @ restore regs and return
This code has a few problems:
- there now are 2 wfi instructions, which I would like to avoid for readability and maintainability,
- are the mcr instructions needed here? From arch/arm/include/asm/system.h it seems those are not needed for __LINUX_ARM_ARCH__ >= 7
Furthermore the main point of discussion to me is: is it advised to go into wfi without self refresh requested? Can anyone confirm this?
Quoted 38 lines
arch/arm/mach-omap2/sleep34xx.S +25
-0+ + +/* + * Local variables + */ +omap3_do_wfi_sram_addr: + .word omap3_do_wfi_sram +kernel_flush: + .word v7_flush_dcache_all + +/* =================================== + * == WFI instruction => Enter idle == + * =================================== + */ + +/* + * Do WFI instruction + * Includes the resume path for non-OFF modes + * + * This code gets copied to internal SRAM and is accessible + * from both SDRAM and SRAM: + * - executed from SRAM for non-off modes (omap3_do_wfi_sram), + * - executed from SDRAM for OFF mode (omap3_do_wfi). + */ +ENTRY(omap3_do_wfi)ldr r4,
sdrc_power@ read theSDRC_POWERregister ldr r5, [r4] @ read the contents ofSDRC_POWERorr r5, r5, #0x40 @ enable self refresh on idle reqarch/arm/mach-omap2/sleep34xx.S +1
-1@@ -302,7 +348,7 @@ omap3_do_wfi: /* * =================================== - * == Resume path for non-OFF modes == + * == Resume path for OFF/RET modes == * =================================== */nop
(quoted diff) +0
-0@@ -315,15 +361,113 @@ omap3_do_wfi:
Quoted 4 lines
nop
nop
nop
- blwait_sdrc_ok
...
Regards,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Jean
Hi Santosh, Benoit, Kevin,
I would like to revive this discussion. Can you give some feedback on the self-refresh problem that is proposed in the latest patch from Santosh? Cf. below for more details.
Comments below.
Quoted 46 lines
Quoted 44 lines · Santosh Shilimkar
Jean,
Quoted 43 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 5:01 PM
To: Jean Pihet
Cc: [email protected]; Jean Pihet-XID
Subject: RE: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRQuoted 7 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 4:53 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDR[...]
Quoted 14 lines
Quoted 6 lines
Quoted 2 lines
Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
Quoted 8 lines
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
Quoted 9 lines
No. Only the MPU attempted state is checked (this actually is the '
save_state' parameter passed toomap_cpu_suspend).
So it makes sense to check the CORE attempted state in order to decide
to run the WFI from internal SRAM or DDR.The MPU attempted state is used to decide whether to save the MPU/L1/L2 context.
Looks like you miss-understood my point. As I understand from errata, as long as core clock domain can idle with core dpll divider auto idle enabled, the errata is applicable.
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
So the only check needed is to see if the core clockdomain
hw_autoor sw sleep is enabled.If it is suppose to be not idle(we force few C-states where CORE inactive is avoided for faster response), we can execute WFI from DDR with not enabling self refresh.
Is this the way to go?
I think so considering we need C-states for
faster responses as well.
Quoted 34 lines
Quoted 17 lines
Quoted 4 lines
Rest of the scenario can follow the SRAM path.
Hope this is clear to you.
As per further discussion, I have updated your patch to address above by using core clockdomain state.
Have tested OFF and RET with this new update and they work as expected. Feel free to update further if needed.
------
From49fe8164a40431807495638ec23639cc9bc53cb9Mon Sep 17 00:00:00 2001
From: Jean Pihet<[email protected]>
Date: Sat, 29 Jan 2011 20:51:19 +0530
Subject: [PATCH] OMAP3: run the ASM sleep code from DDR...
Quoted 15 lines
arch/arm/mach-omap2/sleep34xx.S +3
-1-omap3_do_wfi: +do_WFI: + ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE + ldr r5, [r4] @ read the contents of
CLKSTCTRL_COREarch/arm/mach-omap2/sleep34xx.S +9
-0+ and r5, r5, #0x3 + cmp r5, #0x3 + beq omap3_do_wfi @ Jumpt to SRAM function + mov r1, #0 + mcr p15, 0, r1, c7, c10, 4 + mcr p15, 0, r1, c7, c10, 5 + + wfi @ wait for interrupt +
Quoted 8 lines
Quoted 1 line
+ ldmfd sp!, {r0-r12, pc} @ restore regs and return
This code has a few problems:
- there now are 2 wfi instructions, which I would like to avoid for readability and maintainability,
- are the mcr instructions needed here? Fromarch/arm/include/asm/system.hit seems those are not needed for __LINUX_ARM_ARCH__>= 7
The are barriers and in my clean-up I have already fixed them. Your patch is bit old so has those things. Once you refresh your patch against mainline, this can be simply converted to DSB and DMB.
Quoted 4 lines
Furthermore the main point of discussion to me is: is it advised to go into wfi without self refresh requested? Can anyone confirm this?
You can provided you ensure that CORE and SDRC can't idle.
I suggest you to create a patch against mainline and then we take it from there.
Regards
Santosh
Hi Santosh,
Quoted 123 lines · Santosh Shilimkar
Quoted 7 lines · Jean
Hi Santosh, Benoit, Kevin,
I would like to revive this discussion. Can you give some feedback on the self-refresh problem that is proposed in the latest patch from Santosh? Cf. below for more details.
Comments below.
Quoted 53 lines
Quoted 51 lines · Santosh Shilimkar
Jean,
Quoted 49 lines
-----Original Message-----
From: Santosh Shilimkar [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 5:01 PM
To: Jean Pihet
Cc: [email protected]; Jean Pihet-XID
Subject: RE: [RFC/PATCH] OMAP3: run the ASM sleep code from DDRQuoted 7 lines
-----Original Message-----
From: Jean Pihet [mailto:[email protected]]
Sent: Tuesday, February 01, 2011 4:53 PM
To: Santosh Shilimkar
Cc: [email protected]; Jean Pihet-XID
Subject: Re: [RFC/PATCH] OMAP3: run the ASM sleep code from DDR[...]
Quoted 16 lines
Quoted 7 lines
Quoted 3 lines
Does that makes sense?
Actually not. Rather I will separate only the scenario's where CORE low power targets are attempted and only have that code run from SRAM.
Quoted 8 lines
There are scenario's where CORE can be active because MODEM, DSP and MPU can still hit RET, OFF. And here, the errata isn't applicable.
Unless I missed something here, I think in the code we check the the CORE attempted state and based on that we can do a normal WFI from DDR (no self rfersh) or WFI from SRAM with self refresh enabled.
Quoted 9 lines
No. Only the MPU attempted state is checked (this actually is the '
save_state' parameter passed toomap_cpu_suspend).
So it makes sense to check the CORE attempted state in order to decide
to run the WFI from internal SRAM or DDR.The MPU attempted state is used to decide whether to save the MPU/L1/L2 context.
Looks like you miss-understood my point. As I understand from errata, as long as core clock domain can idle with core dpll divider auto idle enabled, the errata is applicable.
So the only check needed is to see if the core clockdomain
hw_autoor sw sleep is enabled.Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
If it is suppose to be not idle(we force few C-states where CORE inactive is avoided for faster response), we can execute WFI from DDR with not enabling self refresh.
Is this the way to go?
I think so considering we need C-states for
faster responses as well.Quoted 35 lines
Quoted 17 lines
Quoted 4 lines
Rest of the scenario can follow the SRAM path.
Hope this is clear to you.
As per further discussion, I have updated your patch to address above by using core clockdomain state.
Have tested OFF and RET with this new update and they work as expected. Feel free to update further if needed.
------
From49fe8164a40431807495638ec23639cc9bc53cb9Mon Sep 17 00:00:00 2001
From: Jean Pihet<[email protected]>
Date: Sat, 29 Jan 2011 20:51:19 +0530
Subject: [PATCH] OMAP3: run the ASM sleep code from DDR...
Quoted 15 lines
arch/arm/mach-omap2/sleep34xx.S +3
-1-omap3_do_wfi: +do_WFI: + ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE + ldr r5, [r4] @ read the contents of
CLKSTCTRL_CORE
+ and r5, r5, #0x3
+ cmp r5, #0x3
+ beqomap3_do_wfi@ Jumpt to SRAM function
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4
+ mcr p15, 0, r1, c7, c10, 5arch/arm/mach-omap2/sleep34xx.S +3
-0+ + wfi @ wait for interrupt +Quoted 8 lines
Quoted 1 line
+ ldmfd sp!, {r0-r12, pc} @ restore regs and return
This code has a few problems:
- there now are 2 wfi instructions, which I would like to avoid for readability and maintainability,
- are the mcr instructions needed here? Fromarch/arm/include/asm/system.hit seems those are not needed for __LINUX_ARM_ARCH__>= 7The are barriers and in my clean-up I have already fixed them. Your patch is bit old so has those things. Once you refresh your patch against mainline, this can be simply converted to DSB and DMB.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Furthermore the main point of discussion to me is: is it advised to go into wfi without self refresh requested? Can anyone confirm this?
You can provided you ensure that CORE and SDRC can't idle.
I suggest you to create a patch against mainline and then we take it from there.
Re-pushed an updated patch on l-o ML: '[PATCH] OMAP3: run the ASM sleep code from DDR'.
I deliberately omitted the code for WFI transition without self-refresh because of the reasons mentioned here above and repeated here (quoting myself):
"The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.
Also the code in wait_sdrc_ok will exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since the actual CORE hit state is unknow after wake-up from WFI the wait_sdrc_ok code always run at wake-up from MPU RET.
"
Quoted 4 lines
Regards
Santosh
Regards,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Jean Pihet
Hi Santosh,
[....]
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
arch/arm/mach-omap2/sleep34xx.S +3
-1-omap3_do_wfi: +do_WFI: + ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE + ldr r5, [r4] @ read the contents of
CLKSTCTRL_COREarch/arm/mach-omap2/sleep34xx.S +10
-0+ and r5, r5, #0x3 + cmp r5, #0x3 + beq omap3_do_wfi @ Jumpt to SRAM function + mov r1, #0 + mcr p15, 0, r1, c7, c10, 4 + mcr p15, 0, r1, c7, c10, 5 + + wfi @ wait for interrupt + + ldmfd sp!, {r0-r12, pc} @ restore regs and return
[....]
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
Furthermore the main point of discussion to me is: is it advised to go into wfi without self refresh requested? Can anyone confirm this?
You can provided you ensure that CORE and SDRC can't idle.
I suggest you to create a patch against mainline and then we take it from there.
Re-pushed an updated patch on l-o ML: '[PATCH] OMAP3: run the ASM sleep code from DDR'.
Thanks. We needed this to be in mainline.
Quoted 9 lines
I deliberately omitted the code for WFI transition without self-refresh because of the reasons mentioned here above and repeated here (quoting myself):
"The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.
Quoted 6 lines
Also the code in
wait_sdrc_okwill exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since the actual CORE hit state is unknow after wake-up from WFI thewait_sdrc_okcode always run at wake-up from MPU RET.
"
What is written here is completely right and I never said anything against it. What I mentioned is if the CORE clock-domain is under HW supervision, SDRC can idle and hence the DDR can enter into self refresh.
Ofocurse on OMAP3 all clock-domain has static deps set and hence above assumption is ok. The update I mentioned in the code will make it complete even without auto-dep assumption.
Anyways if that is the only point we are contesting, I am OK to not have that change part of the patch because it would work becasuse of auto-deps.
Regards
Santosh
Hi Santosh,
Quoted 59 lines · Santosh Shilimkar
Quoted 2 lines · Jean Pihet
Hi Santosh,
[....]
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
arch/arm/mach-omap2/sleep34xx.S +3
-1-omap3_do_wfi: +do_WFI: + ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE + ldr r5, [r4] @ read the contents of
CLKSTCTRL_COREarch/arm/mach-omap2/sleep34xx.S +10
-0+ and r5, r5, #0x3 + cmp r5, #0x3 + beq omap3_do_wfi @ Jumpt to SRAM function + mov r1, #0 + mcr p15, 0, r1, c7, c10, 4 + mcr p15, 0, r1, c7, c10, 5 + + wfi @ wait for interrupt + + ldmfd sp!, {r0-r12, pc} @ restore regs and return[....]
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
Furthermore the main point of discussion to me is: is it advised to go into wfi without self refresh requested? Can anyone confirm this?
You can provided you ensure that CORE and SDRC can't idle.
I suggest you to create a patch against mainline and then we take it from there.
Re-pushed an updated patch on l-o ML: '[PATCH] OMAP3: run the ASM sleep code from DDR'.
Thanks. We needed this to be in mainline.
Quoted 9 lines
I deliberately omitted the code for WFI transition without self-refresh because of the reasons mentioned here above and repeated here (quoting myself):
"The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.Quoted 6 lines
Also the code in
wait_sdrc_okwill exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since the actual CORE hit state is unknow after wake-up from WFI thewait_sdrc_okcode always run at wake-up from MPU RET.
"What is written here is completely right and I never said anything against it. What I mentioned is if the CORE clock-domain is under HW supervision, SDRC can idle and hence the DDR can enter into self refresh.
Quoted 8 lines
Ofocurse on OMAP3 all clock-domain has static deps set and hence above assumption is ok. The update I mentioned in the code will make it complete even without auto-dep assumption.
Anyways if that is the only point we are contesting, I am OK to not have that change part of the patch because it would work becasuse of auto-deps.
Sorry I haven't followed the whole thread...
Can you please clarify what would need to be updated if auto-deps were removed? We are hoping to remove them when we have full hwmod conversion.
Kevin
Quoted 72 lines · Kevin Hilman
Hi Santosh,
Quoted 59 lines · Santosh Shilimkar
Quoted 2 lines · Jean Pihet
Hi Santosh,
[....]
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
arch/arm/mach-omap2/sleep34xx.S +3
-1-omap3_do_wfi: +do_WFI: + ldr r4, cm_clkstctrl_core @ read the CLKSTCTRL_CORE + ldr r5, [r4] @ read the contents of
CLKSTCTRL_COREarch/arm/mach-omap2/sleep34xx.S +10
-0+ and r5, r5, #0x3 + cmp r5, #0x3 + beq omap3_do_wfi @ Jumpt to SRAM function + mov r1, #0 + mcr p15, 0, r1, c7, c10, 4 + mcr p15, 0, r1, c7, c10, 5 + + wfi @ wait for interrupt + + ldmfd sp!, {r0-r12, pc} @ restore regs and return[....]
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
Furthermore the main point of discussion to me is: is it advised to go into wfi without self refresh requested? Can anyone confirm this?
You can provided you ensure that CORE and SDRC can't idle.
I suggest you to create a patch against mainline and then we take it from there.
Re-pushed an updated patch on l-o ML: '[PATCH] OMAP3: run the ASM sleep code from DDR'.
Thanks. We needed this to be in mainline.
Quoted 9 lines
I deliberately omitted the code for WFI transition without self-refresh because of the reasons mentioned here above and repeated here (quoting myself):
"The DDR self refresh is enabled at each WFI but not necessarily hit. It is actually triggered by the CORE idle request which depends on the settings, the dependencies, the HW states... For example the CORE state depends on the MPU state so if the MPU stays ON running instructions the CORE will stay ON as well.Quoted 6 lines
Also the code in
wait_sdrc_okwill exit quicker if the CORE DPLL is already locked, e.g. if the CORE did not hit a low power state. Since the actual CORE hit state is unknow after wake-up from WFI thewait_sdrc_okcode always run at wake-up from MPU RET.
"What is written here is completely right and I never said anything against it. What I mentioned is if the CORE clock-domain is under HW supervision, SDRC can idle and hence the DDR can enter into self refresh.
Quoted 8 lines
Ofocurse on OMAP3 all clock-domain has static deps set and hence above assumption is ok. The update I mentioned in the code will make it complete even without auto-dep assumption.
Anyways if that is the only point we are contesting, I am OK to not have that change part of the patch because it would work becasuse of auto-deps.
Quoted 6 lines
Sorry I haven't followed the whole thread...
Can you please clarify what would need to be updated if auto-deps were removed? We are hoping to remove them when we have full hwmod conversion.
Sure.
I sent an update on Jean's original patch to check the CORE clock domain state(HW_SUP or SW_WKUP). If we are in HW_SUP and the SDRC self refresh bit enabled, SDRC can idle along with CORE. So in that case and _only_ that case we need to execute WFI from SRAM. I thought that's a right way to go and not depend on auto-deps.
Jean in his refreshed patch dropped that update with above auto-dep reasoning. For sure, with autodep set, we won't need that additional logic because CORE CD can never IDLE without MPU CD being in idle.
Regards
Santosh