cpuidle.h (1330B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef __ASM_CPUIDLE_H 3#define __ASM_CPUIDLE_H 4 5#include <asm/proc-fns.h> 6 7#ifdef CONFIG_CPU_IDLE 8extern int arm_cpuidle_init(unsigned int cpu); 9extern int arm_cpuidle_suspend(int index); 10#else 11static inline int arm_cpuidle_init(unsigned int cpu) 12{ 13 return -EOPNOTSUPP; 14} 15 16static inline int arm_cpuidle_suspend(int index) 17{ 18 return -EOPNOTSUPP; 19} 20#endif 21 22#ifdef CONFIG_ARM64_PSEUDO_NMI 23#include <asm/arch_gicv3.h> 24 25struct arm_cpuidle_irq_context { 26 unsigned long pmr; 27 unsigned long daif_bits; 28}; 29 30#define arm_cpuidle_save_irq_context(__c) \ 31 do { \ 32 struct arm_cpuidle_irq_context *c = __c; \ 33 if (system_uses_irq_prio_masking()) { \ 34 c->daif_bits = read_sysreg(daif); \ 35 write_sysreg(c->daif_bits | PSR_I_BIT | PSR_F_BIT, \ 36 daif); \ 37 c->pmr = gic_read_pmr(); \ 38 gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET); \ 39 } \ 40 } while (0) 41 42#define arm_cpuidle_restore_irq_context(__c) \ 43 do { \ 44 struct arm_cpuidle_irq_context *c = __c; \ 45 if (system_uses_irq_prio_masking()) { \ 46 gic_write_pmr(c->pmr); \ 47 write_sysreg(c->daif_bits, daif); \ 48 } \ 49 } while (0) 50#else 51struct arm_cpuidle_irq_context { }; 52 53#define arm_cpuidle_save_irq_context(c) (void)c 54#define arm_cpuidle_restore_irq_context(c) (void)c 55#endif 56#endif