0001
0002 #ifndef __ASM_CPUIDLE_H
0003 #define __ASM_CPUIDLE_H
0004
0005 #include <asm/proc-fns.h>
0006
0007 #ifdef CONFIG_ARM64_PSEUDO_NMI
0008 #include <asm/arch_gicv3.h>
0009
0010 struct arm_cpuidle_irq_context {
0011 unsigned long pmr;
0012 unsigned long daif_bits;
0013 };
0014
0015 #define arm_cpuidle_save_irq_context(__c) \
0016 do { \
0017 struct arm_cpuidle_irq_context *c = __c; \
0018 if (system_uses_irq_prio_masking()) { \
0019 c->daif_bits = read_sysreg(daif); \
0020 write_sysreg(c->daif_bits | PSR_I_BIT | PSR_F_BIT, \
0021 daif); \
0022 c->pmr = gic_read_pmr(); \
0023 gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET); \
0024 } \
0025 } while (0)
0026
0027 #define arm_cpuidle_restore_irq_context(__c) \
0028 do { \
0029 struct arm_cpuidle_irq_context *c = __c; \
0030 if (system_uses_irq_prio_masking()) { \
0031 gic_write_pmr(c->pmr); \
0032 write_sysreg(c->daif_bits, daif); \
0033 } \
0034 } while (0)
0035 #else
0036 struct arm_cpuidle_irq_context { };
0037
0038 #define arm_cpuidle_save_irq_context(c) (void)c
0039 #define arm_cpuidle_restore_irq_context(c) (void)c
0040 #endif
0041 #endif