Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Paul Mackerras | ff2e6d7e | 2006-03-28 09:28:14 +1100 | [diff] [blame] | 2 | * This file contains the power_save function for 970-family CPUs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Sam Ravnborg | 0013a85 | 2005-09-09 20:57:26 +0200 | [diff] [blame] | 16 | #include <asm/asm-offsets.h> |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 17 | #include <asm/irqflags.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | #undef DEBUG |
| 20 | |
| 21 | .text |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | _GLOBAL(power4_idle) |
| 24 | BEGIN_FTR_SECTION |
| 25 | blr |
| 26 | END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | /* Now check if user or arch enabled NAP mode */ |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 28 | LOAD_REG_ADDRBASE(r3,powersave_nap) |
| 29 | lwz r4,ADDROFF(powersave_nap)(r3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | cmpwi 0,r4,0 |
| 31 | beqlr |
| 32 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 33 | /* Hard disable interrupts */ |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 34 | mfmsr r7 |
| 35 | rldicl r0,r7,48,1 |
| 36 | rotldi r0,r0,16 |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 37 | mtmsrd r0,1 |
| 38 | |
| 39 | /* Check if something happened while soft-disabled */ |
| 40 | lbz r0,PACAIRQHAPPENED(r13) |
| 41 | cmpwi cr0,r0,0 |
| 42 | bnelr |
| 43 | |
| 44 | /* Soft-enable interrupts */ |
| 45 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 46 | mflr r0 |
| 47 | std r0,16(r1) |
| 48 | stdu r1,-128(r1) |
| 49 | bl .trace_hardirqs_on |
| 50 | addi r1,r1,128 |
| 51 | ld r0,16(r1) |
| 52 | mtlr r0 |
Benjamin Herrenschmidt | 01e8ec4 | 2012-03-16 09:26:59 +1100 | [diff] [blame] | 53 | mfmsr r7 |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 54 | #endif /* CONFIG_TRACE_IRQFLAGS */ |
| 55 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 56 | li r0,1 |
| 57 | stb r0,PACASOFTIRQEN(r13) /* we'll hard-enable shortly */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | BEGIN_FTR_SECTION |
| 59 | DSSALL |
| 60 | sync |
| 61 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) |
Stuart Yoder | 9778b69 | 2012-07-05 04:41:35 +0000 | [diff] [blame] | 62 | CURRENT_THREAD_INFO(r9, r1) |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 63 | ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */ |
| 64 | ori r8,r8,_TLF_NAPPING /* so when we take an exception */ |
| 65 | std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */ |
Paul Mackerras | ff2e6d7e | 2006-03-28 09:28:14 +1100 | [diff] [blame] | 66 | ori r7,r7,MSR_EE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | oris r7,r7,MSR_POW@h |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 68 | 1: sync |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | isync |
| 70 | mtmsrd r7 |
| 71 | isync |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 72 | b 1b |
| 73 | |