2008-06-19 01:26:52 +04:00
/ *
* Copyright ( C ) 2 0 0 8 F r e e s c a l e S e m i c o n d u c t o r , I n c . A l l r i g h t s r e s e r v e d .
* Dave L i u < d a v e l i u @freescale.com>
* copy f r o m i d l e _ 6 x x . S a n d m o d i f y f o r e 5 0 0 b a s e d p r o c e s s o r ,
* implement t h e p o w e r _ s a v e f u n c t i o n i n i d l e .
*
* 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
* as p u b l i s h e d 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 t h e 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 .
* /
# include < l i n u x / t h r e a d s . h >
# include < a s m / r e g . h >
# include < a s m / p a g e . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / a s m - o f f s e t s . h >
.text
_ GLOBAL( e 5 0 0 _ i d l e )
2012-07-05 08:41:35 +04:00
CURRENT_ T H R E A D _ I N F O ( r3 , r1 )
2008-06-19 01:26:52 +04:00
lwz r4 ,T I _ L O C A L _ F L A G S ( r3 ) / * s e t n a p p i n g b i t * /
ori r4 ,r4 ,_ T L F _ N A P P I N G / * s o w h e n w e t a k e a n e x c e p t i o n * /
stw r4 ,T I _ L O C A L _ F L A G S ( r3 ) / * i t w i l l r e t u r n t o o u r c a l l e r * /
2011-10-11 09:56:08 +04:00
# ifdef C O N F I G _ P P C _ E 5 0 0 M C
2011-06-23 03:10:30 +04:00
wrteei 1
1 : wait
/ *
* Guard a g a i n s t s p u r i o u s w a k e u p s ( e . g . f r o m a h y p e r v i s o r ) - -
* any r e a l i n t e r r u p t w i l l c a u s e u s t o r e t u r n t o L R d u e t o
* _ TLF_ N A P P I N G .
* /
b 1 b
# else
2008-06-19 01:26:52 +04:00
/* Check if we can nap or doze, put HID0 mask in r3 */
lis r3 ,0
BEGIN_ F T R _ S E C T I O N
lis r3 ,H I D 0 _ D O Z E @h
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ C A N _ D O Z E )
BEGIN_ F T R _ S E C T I O N
/* Now check if user enabled NAP mode */
lis r4 ,p o w e r s a v e _ n a p @ha
lwz r4 ,p o w e r s a v e _ n a p @l(r4)
cmpwi 0 ,r4 ,0
beq 1 f
stwu r1 ,- 1 6 ( r1 )
mflr r0
stw r0 ,2 0 ( r1 )
bl f l u s h _ d c a c h e _ L 1
lwz r0 ,2 0 ( r1 )
addi r1 ,r1 ,1 6
mtlr r0
lis r3 ,H I D 0 _ N A P @h
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ C A N _ N A P )
2008-06-19 18:40:31 +04:00
BEGIN_ F T R _ S E C T I O N
msync
li r7 ,L 2 C S R 0 _ L 2 F L @l
mtspr S P R N _ L 2 C S R 0 ,r7
2 :
mfspr r7 ,S P R N _ L 2 C S R 0
andi. r4 ,r7 ,L 2 C S R 0 _ L 2 F L @l
bne 2 b
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ L 2 C S R | C P U _ F T R _ C A N _ N A P )
2008-06-19 01:26:52 +04:00
1 :
/* Go to NAP or DOZE now */
mfspr r4 ,S P R N _ H I D 0
rlwinm r4 ,r4 ,0 ,~ ( H I D 0 _ D O Z E | H I D 0 _ N A P | H I D 0 _ S L E E P )
or r4 ,r4 ,r3
isync
mtspr S P R N _ H I D 0 ,r4
isync
mfmsr r7
oris r7 ,r7 ,M S R _ W E @h
ori r7 ,r7 ,M S R _ E E
msync
mtmsr r7
isync
2 : b 2 b
2011-06-23 03:10:30 +04:00
# endif / * ! E 5 0 0 M C * /
2008-06-19 01:26:52 +04:00
/ *
* Return f r o m N A P / D O Z E m o d e , r e s t o r e s o m e C P U s p e c i f i c r e g i s t e r s ,
* r2 c o n t a i n i n g p h y s i c a l a d d r e s s o f c u r r e n t .
* r1 1 p o i n t s t o t h e e x c e p t i o n f r a m e ( p h y s i c a l a d d r e s s ) .
* We h a v e t o p r e s e r v e r10 .
* /
_ GLOBAL( p o w e r _ s a v e _ p p c32 _ r e s t o r e )
lwz r9 ,_ L I N K ( r11 ) / * i n t e r r u p t e d i n e 5 0 0 _ i d l e * /
stw r9 ,_ N I P ( r11 ) / * m a k e i t d o a b l r * /
# ifdef C O N F I G _ S M P
2012-07-05 08:41:35 +04:00
CURRENT_ T H R E A D _ I N F O ( r12 , r1 )
2008-06-19 01:26:52 +04:00
lwz r11 ,T I _ C P U ( r12 ) / * g e t c p u n u m b e r * 4 * /
slwi r11 ,r11 ,2
# else
li r11 ,0
# endif
2008-08-26 06:08:56 +04:00
2008-06-19 01:26:52 +04:00
b t r a n s f e r _ t o _ h a n d l e r _ c o n t