blob: 30de81da7b40fe163693ca4400edd643c36e3943 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Paul Mackerrasff2e6d72006-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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033BEGIN_FTR_SECTION
34 DSSALL
35 sync
36END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
Paul Mackerrasf39224a2006-04-18 21:49:11 +100037 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 */
Paul Mackerrasff2e6d72006-03-28 09:28:14 +110041 mfmsr r7
42 ori r7,r7,MSR_EE
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 oris r7,r7,MSR_POW@h
Paul Mackerrasf39224a2006-04-18 21:49:11 +1000441: sync
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 isync
46 mtmsrd r7
47 isync
Paul Mackerrasf39224a2006-04-18 21:49:11 +100048 b 1b
49