Merge branch 'from-linus' into upstream
[linux-2.6] / arch / powerpc / kernel / idle_power4.S
1 /*
2  *  This file contains the power_save function for 970-family CPUs.
3  *
4  *  This program is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU General Public License
6  *  as published by the Free Software Foundation; either version
7  *  2 of the License, or (at your option) any later version.
8  */
9
10 #include <linux/threads.h>
11 #include <asm/processor.h>
12 #include <asm/page.h>
13 #include <asm/cputable.h>
14 #include <asm/thread_info.h>
15 #include <asm/ppc_asm.h>
16 #include <asm/asm-offsets.h>
17
18 #undef DEBUG
19
20         .text
21
22 _GLOBAL(power4_idle)
23 BEGIN_FTR_SECTION
24         blr
25 END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
26         /* Now check if user or arch enabled NAP mode */
27         LOAD_REG_ADDRBASE(r3,powersave_nap)
28         lwz     r4,ADDROFF(powersave_nap)(r3)
29         cmpwi   0,r4,0
30         beqlr
31
32         /* Go to NAP now */
33 BEGIN_FTR_SECTION
34         DSSALL
35         sync
36 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
37         clrrdi  r9,r1,THREAD_SHIFT      /* current thread_info */
38         ld      r8,TI_LOCAL_FLAGS(r9)   /* set napping bit */
39         ori     r8,r8,_TLF_NAPPING      /* so when we take an exception */
40         std     r8,TI_LOCAL_FLAGS(r9)   /* it will return to our caller */
41         mfmsr   r7
42         ori     r7,r7,MSR_EE
43         oris    r7,r7,MSR_POW@h
44 1:      sync
45         isync
46         mtmsrd  r7
47         isync
48         b       1b
49