Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / powerpc / kernel / idle_power4.S
blob08faa93755f9f912bd9673be5bfa9ea363880aa4
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  */
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 #include <asm/irqflags.h>
18 #include <asm/hw_irq.h>
20 #undef DEBUG
22         .text
24 _GLOBAL(power4_idle)
25 BEGIN_FTR_SECTION
26         blr
27 END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
28         /* Now check if user or arch enabled NAP mode */
29         LOAD_REG_ADDRBASE(r3,powersave_nap)
30         lwz     r4,ADDROFF(powersave_nap)(r3)
31         cmpwi   0,r4,0
32         beqlr
34         /* Hard disable interrupts */
35         mfmsr   r7
36         rldicl  r0,r7,48,1
37         rotldi  r0,r0,16
38         mtmsrd  r0,1
40         /* Check if something happened while soft-disabled */
41         lbz     r0,PACAIRQHAPPENED(r13)
42         cmpwi   cr0,r0,0
43         bnelr
45         /* Soft-enable interrupts */
46 #ifdef CONFIG_TRACE_IRQFLAGS
47         mflr    r0
48         std     r0,16(r1)
49         stdu    r1,-128(r1)
50         bl      trace_hardirqs_on
51         addi    r1,r1,128
52         ld      r0,16(r1)
53         mtlr    r0
54         mfmsr   r7
55 #endif /* CONFIG_TRACE_IRQFLAGS */
57         li      r0,IRQS_ENABLED
58         stb     r0,PACAIRQSOFTMASK(r13) /* we'll hard-enable shortly */
59 BEGIN_FTR_SECTION
60         DSSALL
61         sync
62 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
63         CURRENT_THREAD_INFO(r9, r1)
64         ld      r8,TI_LOCAL_FLAGS(r9)   /* set napping bit */
65         ori     r8,r8,_TLF_NAPPING      /* so when we take an exception */
66         std     r8,TI_LOCAL_FLAGS(r9)   /* it will return to our caller */
67         ori     r7,r7,MSR_EE
68         oris    r7,r7,MSR_POW@h
69 1:      sync
70         isync
71         mtmsrd  r7
72         isync
73         b       1b