2006-04-02 16:46:25 +00:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-omap2/sleep.S
|
|
|
|
*
|
|
|
|
* (C) Copyright 2004
|
|
|
|
* Texas Instruments, <www.ti.com>
|
|
|
|
* Richard Woodruff <r-woodruff2@ti.com>
|
|
|
|
*
|
2008-10-06 12:49:15 +00:00
|
|
|
* (C) Copyright 2006 Nokia Corporation
|
|
|
|
* Fixed idle loop sleep
|
|
|
|
* Igor Stoppa <igor.stoppa@nokia.com>
|
|
|
|
*
|
2006-04-02 16:46:25 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <asm/assembler.h>
|
|
|
|
|
2012-08-31 23:08:07 +00:00
|
|
|
#include "omap24xx.h"
|
2008-03-18 08:04:51 +00:00
|
|
|
#include "sdrc.h"
|
2006-04-02 16:46:25 +00:00
|
|
|
|
2008-03-18 08:04:51 +00:00
|
|
|
/* First address of reserved address space? apparently valid for OMAP2 & 3 */
|
2006-04-02 16:46:25 +00:00
|
|
|
#define A_SDRC0_V (0xC0000000)
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Forces OMAP into idle state
|
|
|
|
*
|
|
|
|
* omap24xx_idle_loop_suspend() - This bit of code just executes the WFI
|
|
|
|
* for normal idles.
|
|
|
|
*
|
|
|
|
* Note: This code get's copied to internal SRAM at boot. When the OMAP
|
|
|
|
* wakes up it continues execution at the point it went to sleep.
|
|
|
|
*/
|
2011-02-02 15:38:06 +00:00
|
|
|
.align 3
|
2006-04-02 16:46:25 +00:00
|
|
|
ENTRY(omap24xx_idle_loop_suspend)
|
|
|
|
stmfd sp!, {r0, lr} @ save registers on stack
|
|
|
|
mov r0, #0 @ clear for mcr setup
|
|
|
|
mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
|
|
|
|
ldmfd sp!, {r0, pc} @ restore regs and return
|
|
|
|
|
|
|
|
ENTRY(omap24xx_idle_loop_suspend_sz)
|
|
|
|
.word . - omap24xx_idle_loop_suspend
|
|
|
|
|
|
|
|
/*
|
2008-10-06 12:49:15 +00:00
|
|
|
* omap24xx_cpu_suspend() - Forces OMAP into deep sleep state by completing
|
2006-04-02 16:46:25 +00:00
|
|
|
* SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore
|
|
|
|
* SDRC.
|
|
|
|
*
|
|
|
|
* Input:
|
|
|
|
* R0 : DLL ctrl value pre-Sleep
|
2008-10-06 12:49:15 +00:00
|
|
|
* R1 : SDRC_DLLA_CTRL
|
|
|
|
* R2 : SDRC_POWER
|
2006-04-02 16:46:25 +00:00
|
|
|
*
|
|
|
|
* The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on
|
|
|
|
* when we get called, but the DLL probably isn't. We will wait a bit more in
|
|
|
|
* case the DPLL isn't quite there yet. The code will wait on DLL for DDR even
|
|
|
|
* if in unlocked mode.
|
|
|
|
*
|
|
|
|
* For less than 242x-ES2.2 upon wake from a sleep mode where the external
|
|
|
|
* oscillator was stopped, a timing bug exists where a non-stabilized 12MHz
|
|
|
|
* clock can pass into the PRCM can cause problems at DSP and IVA.
|
|
|
|
* To work around this the code will switch to the 32kHz source prior to sleep.
|
|
|
|
* Post sleep we will shift back to using the DPLL. Apparently,
|
|
|
|
* CM_IDLEST_CLKGEN does not reflect the full clock change so you need to wait
|
|
|
|
* 3x12MHz + 3x32kHz clocks for a full switch.
|
|
|
|
*
|
|
|
|
* The DLL load value is not kept in RETENTION or OFF. It needs to be restored
|
|
|
|
* at wake
|
|
|
|
*/
|
2011-02-02 15:38:06 +00:00
|
|
|
.align 3
|
2006-04-02 16:46:25 +00:00
|
|
|
ENTRY(omap24xx_cpu_suspend)
|
|
|
|
stmfd sp!, {r0 - r12, lr} @ save registers on stack
|
2008-10-06 12:49:15 +00:00
|
|
|
mov r3, #0x0 @ clear for mcr call
|
2006-04-02 16:46:25 +00:00
|
|
|
mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished
|
|
|
|
nop
|
|
|
|
nop
|
2008-10-06 12:49:15 +00:00
|
|
|
ldr r4, [r2] @ read SDRC_POWER
|
2006-04-02 16:46:25 +00:00
|
|
|
orr r4, r4, #0x40 @ enable self refresh on idle req
|
|
|
|
mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
|
2008-10-06 12:49:15 +00:00
|
|
|
str r4, [r2] @ make it so
|
2006-04-02 16:46:25 +00:00
|
|
|
nop
|
2009-01-29 16:57:18 +00:00
|
|
|
mcr p15, 0, r3, c7, c0, 4 @ wait for interrupt
|
2006-04-02 16:46:25 +00:00
|
|
|
nop
|
|
|
|
loop:
|
|
|
|
subs r5, r5, #0x1 @ awake, wait just a bit
|
|
|
|
bne loop
|
|
|
|
|
2008-10-06 12:49:15 +00:00
|
|
|
/* The DPLL has to be on before we take the DDR out of self refresh */
|
2006-04-02 16:46:25 +00:00
|
|
|
bic r4, r4, #0x40 @ now clear self refresh bit.
|
2008-10-06 12:49:15 +00:00
|
|
|
str r4, [r2] @ write to SDRC_POWER
|
2006-04-02 16:46:25 +00:00
|
|
|
ldr r4, A_SDRC0 @ make a clock happen
|
2008-10-06 12:49:15 +00:00
|
|
|
ldr r4, [r4] @ read A_SDRC0
|
2006-04-02 16:46:25 +00:00
|
|
|
nop @ start auto refresh only after clk ok
|
|
|
|
movs r0, r0 @ see if DDR or SDR
|
|
|
|
strne r0, [r1] @ rewrite DLLA to force DLL reload
|
|
|
|
addne r1, r1, #0x8 @ move to DLLB
|
|
|
|
strne r0, [r1] @ rewrite DLLB to force DLL reload
|
|
|
|
|
|
|
|
mov r5, #0x1000
|
|
|
|
loop2:
|
|
|
|
subs r5, r5, #0x1
|
|
|
|
bne loop2
|
|
|
|
/* resume*/
|
|
|
|
ldmfd sp!, {r0 - r12, pc} @ restore regs and return
|
|
|
|
|
|
|
|
A_SDRC0:
|
|
|
|
.word A_SDRC0_V
|
|
|
|
|
|
|
|
ENTRY(omap24xx_cpu_suspend_sz)
|
|
|
|
.word . - omap24xx_cpu_suspend
|