2005-04-17 02:20:36 +04:00
/ *
* SA1 1 x0 A s s e m b l e r S l e e p / W a k e U p M a n a g e m e n t R o u t i n e s
*
* Copyright ( c ) 2 0 0 1 C l i f f B r a k e < c b r a k e @accelent.com>
*
* 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 .
*
* History :
*
* 2 0 0 1 - 0 2 - 06 : Cliff B r a k e I n i t i a l c o d e
*
* 2 0 0 1 - 0 8 - 29 : Nicolas P i t r e S i m p l i f i e d .
*
* 2 0 0 2 - 0 5 - 27 : Nicolas P i t r e R e v i s i t e d , m o r e c l e a n u p a n d s i m p l i f i c a t i o n .
* Storage i s o n t h e s t a c k n o w .
* /
# 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 >
2008-08-05 19:14:15 +04:00
# include < m a c h / h a r d w a r e . h >
2005-04-17 02:20:36 +04:00
.text
/ *
2011-06-21 19:26:29 +04:00
* sa1 1 0 0 _ f i n i s h _ s u s p e n d ( )
2005-04-17 02:20:36 +04:00
*
* Causes s a11 x0 t o e n t e r s l e e p s t a t e
*
2012-01-23 22:39:21 +04:00
* Must b e a l i g n e d t o a c a c h e l i n e .
2005-04-17 02:20:36 +04:00
* /
2012-01-23 22:39:21 +04:00
.balign 32
2011-06-21 19:26:29 +04:00
ENTRY( s a11 0 0 _ f i n i s h _ s u s p e n d )
2005-04-17 02:20:36 +04:00
@ disable clock switching
mcr p15 , 0 , r1 , c15 , c2 , 2
2012-01-23 22:39:21 +04:00
ldr r6 , =MDREFR
ldr r4 , [ r6 ]
orr r4 , r4 , #M D R E F R _ K 1 D B 2
ldr r5 , =PPCR
2012-07-06 18:47:17 +04:00
@ Pre-load __loop_udelay into the I-cache
2012-01-23 22:39:21 +04:00
mov r0 , #1
2012-07-06 18:47:17 +04:00
bl _ _ l o o p _ u d e l a y
2012-01-23 22:39:21 +04:00
mov r0 , r0
@ The following must all exist in a single cache line to
@ avoid accessing memory until this sequence is complete,
@ otherwise we occasionally hang.
@ Adjust memory timing before lowering CPU clock
str r4 , [ r6 ]
2005-04-17 02:20:36 +04:00
@ delay 90us and set CPU PLL to lowest speed
@ fixes resume problem on high speed SA1110
mov r0 , #90
2012-07-06 18:47:17 +04:00
bl _ _ l o o p _ u d e l a y
2005-04-17 02:20:36 +04:00
mov r1 , #0
2012-01-23 22:39:21 +04:00
str r1 , [ r5 ]
2005-04-17 02:20:36 +04:00
mov r0 , #90
2012-07-06 18:47:17 +04:00
bl _ _ l o o p _ u d e l a y
2005-04-17 02:20:36 +04:00
/ *
* SA1 1 1 0 S D R A M c o n t r o l l e r w o r k a r o u n d . r e g i s t e r v a l u e s :
*
* r0 = & M S C 0
* r1 = & M S C 1
* r2 = & M S C 2
* r3 = M S C 0 v a l u e
* r4 = M S C 1 v a l u e
* r5 = M S C 2 v a l u e
* r6 = & M D R E F R
* r7 = f i r s t M D R E F R v a l u e
* r8 = s e c o n d M D R E F R v a l u e
* r9 = & M D C N F G
* r1 0 = M D C N F G v a l u e
* r1 1 = t h i r d M D R E F R v a l u e
* r1 2 = & P M C R
* r1 3 = P M C R v a l u e ( 1 )
* /
ldr r0 , =MSC0
ldr r1 , =MSC1
ldr r2 , =MSC2
2008-11-26 22:58:43 +03:00
ldr r3 , [ r0 ]
bic r3 , r3 , #F M s k ( M S C _ R T )
bic r3 , r3 , #F M s k ( M S C _ R T ) < < 16
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
ldr r4 , [ r1 ]
bic r4 , r4 , #F M s k ( M S C _ R T )
bic r4 , r4 , #F M s k ( M S C _ R T ) < < 16
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
ldr r5 , [ r2 ]
bic r5 , r5 , #F M s k ( M S C _ R T )
bic r5 , r5 , #F M s k ( M S C _ R T ) < < 16
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
ldr r7 , [ r6 ]
2012-01-23 22:39:21 +04:00
bic r7 , r7 , #0x0000FF00
bic r7 , r7 , #0x000000F0
orr r8 , r7 , #M D R E F R _ S L F R S H
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
ldr r9 , =MDCNFG
ldr r10 , [ r9 ]
bic r10 , r10 , #( M D C N F G _ D E 0 + M D C N F G _ D E 1 )
bic r10 , r10 , #( M D C N F G _ D E 2 + M D C N F G _ D E 3 )
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
bic r11 , r8 , #M D R E F R _ S L F R S H
bic r11 , r11 , #M D R E F R _ E 1 P I N
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
ldr r12 , =PMCR
2005-04-17 02:20:36 +04:00
2008-11-26 22:58:43 +03:00
mov r13 , #P M C R _ S F
2005-04-17 02:20:36 +04:00
b s a11 1 0 _ s d r a m _ c o n t r o l l e r _ f i x
.align 5
sa1110_sdram_controller_fix :
@ Step 1 clear RT field of all MSCx registers
str r3 , [ r0 ]
str r4 , [ r1 ]
str r5 , [ r2 ]
@ Step 2 clear DRI field in MDREFR
str r7 , [ r6 ]
@ Step 3 set SLFRSH bit in MDREFR
str r8 , [ r6 ]
@ Step 4 clear DE bis in MDCNFG
str r10 , [ r9 ]
@ Step 5 clear DRAM refresh control register
str r11 , [ r6 ]
@ Wow, now the hardware suspend request pins can be used, that makes them functional for
@ about 7 ns out of the entire time that the CPU is running!
@ Step 6 set force sleep bit in PMCR
str r13 , [ r12 ]
20 : b 2 0 b @ loop waiting for sleep