2007-02-04 16:36:51 -06:00
/ *
* Copyright ( C ) 2 0 0 6 - 2 0 0 7 P A S e m i , I n c
*
* Maintained b y : O l o f J o h a n s s o n < o l o f @lixom.net>
*
* 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
* it 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 v e r s i o n 2 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 .
*
* 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 , M A 0 2 1 1 1 - 1 3 0 7 U S A
*
* /
# include < a s m / p r o c e s s o r . h >
# include < a s m / p a g e . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / c a c h e . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / a s m - o f f s e t s . h >
/* Power savings opcodes since not all binutils have them at this time */
# define D O Z E . l o n g 0 x4 c00 0 3 2 4
# define N A P . l o n g 0 x4 c00 0 3 6 4
# define S L E E P . l o n g 0 x4 c00 0 3 a4
# define R V W . l o n g 0 x4 c00 0 3 e 4
/ * Common s e q u e n c e t o d o b e f o r e g o i n g t o a n y o f t h e
* powersavings m o d e s .
* /
# define P R E _ S L E E P _ S E Q U E N C E \
std r3 ,8 ( r1 ) ; \
ptesync ; \
ld r3 ,8 ( r1 ) ; \
1 : cmpd r3 ,r3 ; \
bne 1 b
_doze :
PRE_ S L E E P _ S E Q U E N C E
DOZE
b .
_ GLOBAL( i d l e _ s p i n )
blr
_ GLOBAL( i d l e _ d o z e )
LOAD_ R E G _ A D D R ( r3 , _ d o z e )
b s l e e p _ c o m m o n
/* Add more modes here later */
sleep_common :
mflr r0
std r0 , 1 6 ( r1 )
stdu r1 ,- 6 4 ( r1 )
2007-11-07 09:26:06 -06:00
# ifdef C O N F I G _ P P C _ P A S E M I _ C P U F R E Q
std r3 , 4 8 ( r1 )
2007-02-04 16:36:51 -06:00
2007-11-07 09:26:06 -06:00
/* Only do power savings when in astate 0 */
bl . c h e c k _ a s t a t e
cmpwi r3 ,0
bne 1 f
ld r3 , 4 8 ( r1 )
# endif
2007-02-04 16:36:51 -06:00
LOAD_ R E G _ I M M E D I A T E ( r6 ,M S R _ D R | M S R _ I R | M S R _ M E | M S R _ E E )
mfmsr r4
andc r5 ,r4 ,r6
mtmsrd r5 ,0
mtctr r3
bctrl
mtmsrd r4 ,0
2007-11-07 09:26:06 -06:00
1 : addi r1 ,r1 ,6 4
2007-02-04 16:36:51 -06:00
ld r0 ,1 6 ( r1 )
mtlr r0
blr