cpuidle.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_CPUIDLE_H
  3. #define __ASM_CPUIDLE_H
  4. #include <asm/proc-fns.h>
  5. #ifdef CONFIG_ARM64_PSEUDO_NMI
  6. #include <asm/arch_gicv3.h>
  7. struct arm_cpuidle_irq_context {
  8. unsigned long pmr;
  9. unsigned long daif_bits;
  10. };
  11. #define arm_cpuidle_save_irq_context(__c) \
  12. do { \
  13. struct arm_cpuidle_irq_context *c = __c; \
  14. if (system_uses_irq_prio_masking()) { \
  15. c->daif_bits = read_sysreg(daif); \
  16. write_sysreg(c->daif_bits | PSR_I_BIT | PSR_F_BIT, \
  17. daif); \
  18. c->pmr = gic_read_pmr(); \
  19. gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET); \
  20. } \
  21. } while (0)
  22. #define arm_cpuidle_restore_irq_context(__c) \
  23. do { \
  24. struct arm_cpuidle_irq_context *c = __c; \
  25. if (system_uses_irq_prio_masking()) { \
  26. gic_write_pmr(c->pmr); \
  27. write_sysreg(c->daif_bits, daif); \
  28. } \
  29. } while (0)
  30. #else
  31. struct arm_cpuidle_irq_context { };
  32. #define arm_cpuidle_save_irq_context(c) (void)c
  33. #define arm_cpuidle_restore_irq_context(c) (void)c
  34. #endif
  35. #endif