2 * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 * Generic idle routine for Book3E processors
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/threads.h>
14 #include <asm/ppc_asm.h>
15 #include <asm/asm-offsets.h>
16 #include <asm/ppc-opcode.h>
17 #include <asm/processor.h>
18 #include <asm/thread_info.h>
19 #include <asm/epapr_hcalls.h>
20 #include <asm/hw_irq.h>
22 /* 64-bit version only for now */
25 .macro BOOK3E_IDLE name loop
27 /* Save LR for later */
31 /* Hard disable interrupts */
34 /* Now check if an interrupt came in while we were soft disabled
35 * since we may otherwise lose it (doorbells etc...).
37 lbz r3,PACAIRQHAPPENED(r13)
41 /* Now we are going to mark ourselves as soft and hard enabled in
42 * order to be able to take interrupts while asleep. We inform lockdep
43 * of that. We don't actually turn interrupts on just yet tho.
45 #ifdef CONFIG_TRACE_IRQFLAGS
51 stb r0,PACAIRQSOFTMASK(r13)
53 /* Interrupts will make use return to LR, so get something we want
58 /* And return (interrupts are on) */
63 1: /* Let's set the _TLF_NAPPING flag so interrupts make us return
66 CURRENT_THREAD_INFO(r11, r1)
67 ld r10,TI_LOCAL_FLAGS(r11)
68 ori r10,r10,_TLF_NAPPING
69 std r10,TI_LOCAL_FLAGS(r11)
71 /* We can now re-enable hard interrupts and go to sleep */
77 .macro BOOK3E_IDLE_LOOP
83 /* epapr_ev_idle_start below is patched with the proper hcall
84 opcodes during kernel initialization */
85 .macro EPAPR_EV_IDLE_LOOP
87 LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
89 .global epapr_ev_idle_start
98 BOOK3E_IDLE epapr_ev_idle EPAPR_EV_IDLE_LOOP
100 BOOK3E_IDLE book3e_idle BOOK3E_IDLE_LOOP
102 #endif /* CONFIG_PPC64 */