blob: a2cfbacec2bbe0add6dc13f88822719efb193720 [file] [log] [blame]
Mark Rutlandb5df5b82021-06-07 10:46:24 +01001// 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
Mark Rutlandb5df5b82021-06-07 10:46:24 +01009#include <asm/barrier.h>
Will Deacon6cf61e02021-06-24 14:01:55 +010010#include <asm/cpuidle.h>
Mark Rutlandb5df5b82021-06-07 10:46:24 +010011#include <asm/cpufeature.h>
12#include <asm/sysreg.h>
13
Mark Rutlandb5df5b82021-06-07 10:46:24 +010014/*
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 */
23void noinstr cpu_do_idle(void)
24{
Will Deacon6cf61e02021-06-24 14:01:55 +010025 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);
Mark Rutlandb5df5b82021-06-07 10:46:24 +010033}
34
35/*
36 * This is our default idle handler.
37 */
38void 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 raw_local_irq_enable();
46}