1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * This file contains the power_save function for 970-family CPUs.
6 #include <linux/threads.h>
7 #include <asm/processor.h>
9 #include <asm/cputable.h>
10 #include <asm/thread_info.h>
11 #include <asm/ppc_asm.h>
12 #include <asm/asm-offsets.h>
13 #include <asm/irqflags.h>
14 #include <asm/hw_irq.h>
15 #include <asm/feature-fixups.h>
24 END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
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 /* This sequence is similar to prep_irq_for_idle() */
33 /* Hard disable interrupts */
39 /* Check if something happened while soft-disabled */
40 lbz r0,PACAIRQHAPPENED(r13)
45 * Soft-enable interrupts. This will make power4_fixup_nap return
46 * to our caller with interrupts enabled (soft and hard). The caller
47 * can cope with either interrupts disabled or enabled upon return.
49 #ifdef CONFIG_TRACE_IRQFLAGS
50 /* Tell the tracer interrupts are on, because idle responds to them. */
59 #endif /* CONFIG_TRACE_IRQFLAGS */
62 stb r0,PACAIRQSOFTMASK(r13) /* we'll hard-enable shortly */
66 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
67 ld r9, PACA_THREAD_INFO(r13)
68 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
69 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
70 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
79 2: /* Return if an interrupt had happened while soft disabled */
80 /* Set the HARD_DIS flag because interrupts are now hard disabled */
81 ori r0,r0,PACA_IRQ_HARD_DIS
82 stb r0,PACAIRQHAPPENED(r13)