2006-04-02 20:46:25 +04:00
/ *
* linux/ a r c h / a r m / m a c h - o m a p2 / s l e e p . S
*
* ( C) C o p y r i g h t 2 0 0 4
* Texas I n s t r u m e n t s , < w w w . t i . c o m >
* Richard W o o d r u f f < r - w o o d r u f f2 @ti.com>
*
2008-10-06 16:49:15 +04:00
* ( C) C o p y r i g h t 2 0 0 6 N o k i a C o r p o r a t i o n
* Fixed i d l e l o o p s l e e p
* Igor S t o p p a < i g o r . s t o p p a @nokia.com>
*
2006-04-02 20:46:25 +04:00
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version 2 of
* the L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R / P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e , S u i t e 3 3 0 , B o s t o n ,
* MA 0 2 1 1 1 - 1 3 0 7 U S A
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
2012-09-01 03:08:07 +04:00
# include " o m a p24 x x . h "
2008-03-18 11:04:51 +03:00
# include " s d r c . h "
2006-04-02 20:46:25 +04:00
2008-03-18 11:04:51 +03:00
/* First address of reserved address space? apparently valid for OMAP2 & 3 */
2006-04-02 20:46:25 +04:00
# define A _ S D R C 0 _ V ( 0 x C 0 0 0 0 0 0 0 )
.text
/ *
2008-10-06 16:49:15 +04:00
* omap2 4 x x _ c p u _ s u s p e n d ( ) - F o r c e s O M A P i n t o d e e p s l e e p s t a t e b y c o m p l e t i n g
2006-04-02 20:46:25 +04:00
* SDRC s h u t d o w n t h e n A R M s h u t d o w n . U p o n w a k e M P U i s b a c k o n s o j u s t r e s t o r e
* SDRC.
*
* Input :
* R0 : D L L c t r l v a l u e p r e - S l e e p
2008-10-06 16:49:15 +04:00
* R1 : S D R C _ D L L A _ C T R L
* R2 : S D R C _ P O W E R
2006-04-02 20:46:25 +04:00
*
* The i f t h e D P L L i s g o i n g t o A u t o I d l e . I t s e e m s l i k e t h e D P L L m a y b e b a c k o n
* when w e g e t c a l l e d , b u t t h e D L L p r o b a b l y i s n ' t . W e w i l l w a i t a b i t m o r e i n
* case t h e D P L L i s n ' t q u i t e t h e r e y e t . T h e c o d e w i l l w a i t o n D L L f o r D D R e v e n
* if i n u n l o c k e d m o d e .
*
* For l e s s t h a n 2 4 2 x - E S 2 . 2 u p o n w a k e f r o m a s l e e p m o d e w h e r e t h e e x t e r n a l
* oscillator w a s s t o p p e d , a t i m i n g b u g e x i s t s w h e r e a n o n - s t a b i l i z e d 1 2 M H z
* clock c a n p a s s i n t o t h e P R C M c a n c a u s e p r o b l e m s a t D S P a n d I V A .
* To w o r k a r o u n d t h i s t h e c o d e w i l l s w i t c h t o t h e 3 2 k H z s o u r c e p r i o r t o s l e e p .
* Post s l e e p w e w i l l s h i f t b a c k t o u s i n g t h e D P L L . A p p a r e n t l y ,
* CM_ I D L E S T _ C L K G E N d o e s n o t r e f l e c t t h e f u l l c l o c k c h a n g e s o y o u n e e d t o w a i t
* 3 x1 2 M H z + 3 x32 k H z c l o c k s f o r a f u l l s w i t c h .
*
* The D L L l o a d v a l u e i s n o t k e p t i n R E T E N T I O N o r O F F . I t n e e d s t o b e r e s t o r e d
* at w a k e
* /
2011-02-02 18:38:06 +03:00
.align 3
2006-04-02 20:46:25 +04:00
ENTRY( o m a p24 x x _ c p u _ s u s p e n d )
stmfd s p ! , { r0 - r12 , l r } @ save registers on stack
2008-10-06 16:49:15 +04:00
mov r3 , #0x0 @ clear for mcr call
2006-04-02 20:46:25 +04:00
mcr p15 , 0 , r3 , c7 , c10 , 4 @ memory barrier, hope SDR/DDR finished
nop
nop
2008-10-06 16:49:15 +04:00
ldr r4 , [ r2 ] @ read SDRC_POWER
2006-04-02 20:46:25 +04:00
orr r4 , r4 , #0x40 @ enable self refresh on idle req
mov r5 , #0x2000 @ set delay (DPLL relock + DLL relock)
2008-10-06 16:49:15 +04:00
str r4 , [ r2 ] @ make it so
2006-04-02 20:46:25 +04:00
nop
2009-01-29 19:57:18 +03:00
mcr p15 , 0 , r3 , c7 , c0 , 4 @ wait for interrupt
2006-04-02 20:46:25 +04:00
nop
loop :
subs r5 , r5 , #0x1 @ awake, wait just a bit
bne l o o p
2008-10-06 16:49:15 +04:00
/* The DPLL has to be on before we take the DDR out of self refresh */
2006-04-02 20:46:25 +04:00
bic r4 , r4 , #0x40 @ now clear self refresh bit.
2008-10-06 16:49:15 +04:00
str r4 , [ r2 ] @ write to SDRC_POWER
2006-04-02 20:46:25 +04:00
ldr r4 , A _ S D R C 0 @ make a clock happen
2008-10-06 16:49:15 +04:00
ldr r4 , [ r4 ] @ read A_SDRC0
2006-04-02 20:46:25 +04: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 l o o p2
/* resume*/
ldmfd s p ! , { r0 - r12 , p c } @ restore regs and return
A_SDRC0 :
.word A_SDRC0_V
ENTRY( o m a p24 x x _ c p u _ s u s p e n d _ s z )
.word . - omap2 4 x x _ c p u _ s u s p e n d