Mark Rutland | b5df5b8 | 2021-06-07 10:46:24 +0100 | [diff] [blame] | 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 | |
Mark Rutland | b5df5b8 | 2021-06-07 10:46:24 +0100 | [diff] [blame] | 9 | #include <asm/barrier.h> |
Will Deacon | 6cf61e0 | 2021-06-24 14:01:55 +0100 | [diff] [blame] | 10 | #include <asm/cpuidle.h> |
Mark Rutland | b5df5b8 | 2021-06-07 10:46:24 +0100 | [diff] [blame] | 11 | #include <asm/cpufeature.h> |
| 12 | #include <asm/sysreg.h> |
| 13 | |
Mark Rutland | b5df5b8 | 2021-06-07 10:46:24 +0100 | [diff] [blame] | 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 | */ |
| 23 | void noinstr cpu_do_idle(void) |
| 24 | { |
Will Deacon | 6cf61e0 | 2021-06-24 14:01:55 +0100 | [diff] [blame] | 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); |
Mark Rutland | b5df5b8 | 2021-06-07 10:46:24 +0100 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | /* |
| 36 | * This is our default idle handler. |
| 37 | */ |
| 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 | raw_local_irq_enable(); |
| 46 | } |