1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 * Generic idle routine for Book3E processors
8 #include <linux/threads.h>
10 #include <asm/ppc_asm.h>
11 #include <asm/asm-offsets.h>
12 #include <asm/ppc-opcode.h>
13 #include <asm/processor.h>
14 #include <asm/thread_info.h>
15 #include <asm/epapr_hcalls.h>
16 #include <asm/hw_irq.h>
18 /* 64-bit version only for now */
21 .macro BOOK3E_IDLE name loop
23 /* Save LR for later */
27 /* Hard disable interrupts */
30 /* Now check if an interrupt came in while we were soft disabled
31 * since we may otherwise lose it (doorbells etc...).
33 lbz r3,PACAIRQHAPPENED(r13)
37 /* Now we are going to mark ourselves as soft and hard enabled in
38 * order to be able to take interrupts while asleep. We inform lockdep
39 * of that. We don't actually turn interrupts on just yet tho.
41 #ifdef CONFIG_TRACE_IRQFLAGS
47 stb r0,PACAIRQSOFTMASK(r13)
49 /* Interrupts will make use return to LR, so get something we want
54 /* And return (interrupts are on) */
59 1: /* Let's set the _TLF_NAPPING flag so interrupts make us return
62 ld r11, PACACURRENT(r13)
63 ld r10,TI_LOCAL_FLAGS(r11)
64 ori r10,r10,_TLF_NAPPING
65 std r10,TI_LOCAL_FLAGS(r11)
67 /* We can now re-enable hard interrupts and go to sleep */
72 lbz r10,PACAIRQHAPPENED(r13)
73 ori r10,r10,PACA_IRQ_HARD_DIS
74 stb r10,PACAIRQHAPPENED(r13)
78 .macro BOOK3E_IDLE_LOOP
84 /* epapr_ev_idle_start below is patched with the proper hcall
85 opcodes during kernel initialization */
86 .macro EPAPR_EV_IDLE_LOOP
88 LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
90 .global epapr_ev_idle_start
99 BOOK3E_IDLE epapr_ev_idle EPAPR_EV_IDLE_LOOP
101 BOOK3E_IDLE book3e_idle BOOK3E_IDLE_LOOP
103 #endif /* CONFIG_PPC64 */