1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Low-level idle sequences
4  */
5 
6 #include <linux/cpu.h>
7 #include <linux/irqflags.h>
8 
9 #include <asm/barrier.h>
10 #include <asm/cpuidle.h>
11 #include <asm/cpufeature.h>
12 #include <asm/sysreg.h>
13 
14 /*
15  *	cpu_do_idle()
16  *
17  *	Idle the processor (wait for interrupt).
18  *
19  *	If the CPU supports priority masking we must do additional work to
20  *	ensure that interrupts are not masked at the PMR (because the core will
21  *	not wake up if we block the wake up signal in the interrupt controller).
22  */
cpu_do_idle(void)23 void noinstr cpu_do_idle(void)
24 {
25 	struct arm_cpuidle_irq_context context;
26 
27 	arm_cpuidle_save_irq_context(&context);
28 
29 	dsb(sy);
30 	wfi();
31 
32 	arm_cpuidle_restore_irq_context(&context);
33 }
34 
35 /*
36  * This is our default idle handler.
37  */
arch_cpu_idle(void)38 void noinstr arch_cpu_idle(void)
39 {
40 	/*
41 	 * This should do all the clock switching and wait for interrupt
42 	 * tricks
43 	 */
44 	cpu_do_idle();
45 }
46