idle.c 918 B

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