Merge tag 'kbuild-v4.21-3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[linux-2.6-block.git] / arch / powerpc / kernel / idle_power4.S
CommitLineData
1da177e4 1/*
ff2e6d7e 2 * This file contains the power_save function for 970-family CPUs.
1da177e4
LT
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
1da177e4
LT
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>
0013a854 16#include <asm/asm-offsets.h>
7230c564 17#include <asm/irqflags.h>
c2e480ba 18#include <asm/hw_irq.h>
2c86cd18 19#include <asm/feature-fixups.h>
1da177e4
LT
20
21#undef DEBUG
22
23 .text
24
1da177e4
LT
25_GLOBAL(power4_idle)
26BEGIN_FTR_SECTION
27 blr
28END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
1da177e4 29 /* Now check if user or arch enabled NAP mode */
e58c3495
DG
30 LOAD_REG_ADDRBASE(r3,powersave_nap)
31 lwz r4,ADDROFF(powersave_nap)(r3)
1da177e4
LT
32 cmpwi 0,r4,0
33 beqlr
34
993ff6d9
NP
35 /* This sequence is similar to prep_irq_for_idle() */
36
7230c564 37 /* Hard disable interrupts */
d04c56f7
PM
38 mfmsr r7
39 rldicl r0,r7,48,1
40 rotldi r0,r0,16
7230c564
BH
41 mtmsrd r0,1
42
43 /* Check if something happened while soft-disabled */
44 lbz r0,PACAIRQHAPPENED(r13)
45 cmpwi cr0,r0,0
993ff6d9 46 bne- 2f
7230c564 47
993ff6d9
NP
48 /*
49 * Soft-enable interrupts. This will make power4_fixup_nap return
50 * to our caller with interrupts enabled (soft and hard). The caller
51 * can cope with either interrupts disabled or enabled upon return.
52 */
7230c564 53#ifdef CONFIG_TRACE_IRQFLAGS
993ff6d9 54 /* Tell the tracer interrupts are on, because idle responds to them. */
7230c564
BH
55 mflr r0
56 std r0,16(r1)
57 stdu r1,-128(r1)
b1576fec 58 bl trace_hardirqs_on
7230c564
BH
59 addi r1,r1,128
60 ld r0,16(r1)
61 mtlr r0
01e8ec44 62 mfmsr r7
7230c564
BH
63#endif /* CONFIG_TRACE_IRQFLAGS */
64
c2e480ba 65 li r0,IRQS_ENABLED
4e26bc4a 66 stb r0,PACAIRQSOFTMASK(r13) /* we'll hard-enable shortly */
1da177e4
LT
67BEGIN_FTR_SECTION
68 DSSALL
69 sync
70END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
9778b696 71 CURRENT_THREAD_INFO(r9, r1)
f39224a8
PM
72 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
73 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
74 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
ff2e6d7e 75 ori r7,r7,MSR_EE
1da177e4 76 oris r7,r7,MSR_POW@h
f39224a8 771: sync
1da177e4
LT
78 isync
79 mtmsrd r7
80 isync
f39224a8
PM
81 b 1b
82
993ff6d9
NP
832: /* Return if an interrupt had happened while soft disabled */
84 /* Set the HARD_DIS flag because interrupts are now hard disabled */
85 ori r0,r0,PACA_IRQ_HARD_DIS
86 stb r0,PACAIRQHAPPENED(r13)
87 blr