blob: 5328709eeedcf952b3fa32445f8a6aea1c3e82cb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Paul Mackerrasff2e6d7e2006-03-28 09:28:14 +11002 * This file contains the power_save function for 970-family CPUs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#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>
Sam Ravnborg0013a852005-09-09 20:57:26 +020016#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#undef DEBUG
19
20 .text
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022_GLOBAL(power4_idle)
23BEGIN_FTR_SECTION
24 blr
25END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 /* Now check if user or arch enabled NAP mode */
David Gibsone58c3492006-01-13 14:56:25 +110027 LOAD_REG_ADDRBASE(r3,powersave_nap)
28 lwz r4,ADDROFF(powersave_nap)(r3)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 cmpwi 0,r4,0
30 beqlr
31
Stephen Rothwelldc1c1ca2005-10-01 18:43:42 +100032 /* Go to NAP now */
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100033 mfmsr r7
34 rldicl r0,r7,48,1
35 rotldi r0,r0,16
36 mtmsrd r0,1 /* hard-disable interrupts */
37 li r0,1
38 stb r0,PACASOFTIRQEN(r13) /* we'll hard-enable shortly */
39 stb r0,PACAHARDIRQEN(r13)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040BEGIN_FTR_SECTION
41 DSSALL
42 sync
43END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
Paul Mackerrasf39224a2006-04-18 21:49:11 +100044 clrrdi r9,r1,THREAD_SHIFT /* current thread_info */
45 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
46 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
47 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
Paul Mackerrasff2e6d7e2006-03-28 09:28:14 +110048 ori r7,r7,MSR_EE
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 oris r7,r7,MSR_POW@h
Paul Mackerrasf39224a2006-04-18 21:49:11 +1000501: sync
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 isync
52 mtmsrd r7
53 isync
Paul Mackerrasf39224a2006-04-18 21:49:11 +100054 b 1b
55
Johannes Bergd9333af2007-05-03 06:33:51 +100056_GLOBAL(power4_cpu_offline_powersave)
57 /* Go to NAP now */
58 mfmsr r7
59 rldicl r0,r7,48,1
60 rotldi r0,r0,16
61 mtmsrd r0,1 /* hard-disable interrupts */
62 li r0,1
63 li r6,0
64 stb r0,PACAHARDIRQEN(r13) /* we'll hard-enable shortly */
65 stb r6,PACASOFTIRQEN(r13) /* soft-disable irqs */
66BEGIN_FTR_SECTION
67 DSSALL
68 sync
69END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
70 ori r7,r7,MSR_EE
71 oris r7,r7,MSR_POW@h
72 sync
73 isync
74 mtmsrd r7
75 isync
76 blr