2 * This file contains the power_save function for Power7 CPUs.
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.
10 #include <linux/threads.h>
11 #include <asm/processor.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/ppc-opcode.h>
18 #include <asm/hw_irq.h>
25 /* Now check if user or arch enabled NAP mode */
26 LOAD_REG_ADDRBASE(r3,powersave_nap)
27 lwz r4,ADDROFF(powersave_nap)(r3)
31 /* NAP is a state loss, we create a regs frame on the
32 * stack, fill it up with the state we care about and
33 * stick a pointer to it in PACAR1. We really only
34 * need to save PC, some CR bits and the NV GPRs,
35 * but for now an interrupt frame will do.
39 stdu r1,-INT_FRAME_SIZE(r1)
44 /* Make sure FPU, VSX etc... are flushed as we may lose
45 * state when going to nap mode
47 bl .discard_lazy_cpu_state
48 #endif /* CONFIG_SMP */
50 /* Hard disable interrupts */
54 mtmsrd r9,1 /* hard-disable interrupts */
56 /* Check if something happened while soft-disabled */
57 lbz r0,PACAIRQHAPPENED(r13)
60 addi r1,r1,INT_FRAME_SIZE
65 1: /* We mark irqs hard disabled as this is the state we'll
66 * be in when returning and we need to tell arch_local_irq_restore()
69 li r0,PACA_IRQ_HARD_DIS
70 stb r0,PACAIRQHAPPENED(r13)
72 /* We haven't lost state ... yet */
74 stb r0,PACA_NAPSTATELOST(r13)
76 /* Continue saving state */
84 /* Magic NAP mode enter sequence */
93 _GLOBAL(power7_wakeup_loss)
100 addi r1,r1,INT_FRAME_SIZE
106 _GLOBAL(power7_wakeup_noloss)
107 lbz r0,PACA_NAPSTATELOST(r13)
109 bne .power7_wakeup_loss
113 addi r1,r1,INT_FRAME_SIZE