1 /* MN10300 IRQ flag handling
3 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #ifndef _ASM_IRQFLAGS_H
13 #define _ASM_IRQFLAGS_H
15 #include <asm/cpu-regs.h>
19 * - "disabled": run in IM1/2
20 * - level 0 - GDB stub
21 * - level 1 - virtual serial DMA (if present)
22 * - level 5 - normal interrupt priority
23 * - level 6 - timer interrupt
24 * - "enabled": run in IM7
26 #ifdef CONFIG_MN10300_TTYSM
27 #define MN10300_CLI_LEVEL EPSW_IM_2
29 #define MN10300_CLI_LEVEL EPSW_IM_1
34 static inline unsigned long arch_local_save_flags(void)
38 asm volatile("mov epsw,%0" : "=d"(flags
));
42 static inline void arch_local_irq_disable(void)
51 : "i"(~EPSW_IM
), "i"(EPSW_IE
| MN10300_CLI_LEVEL
)
55 static inline unsigned long arch_local_irq_save(void)
59 flags
= arch_local_save_flags();
60 arch_local_irq_disable();
65 * we make sure arch_irq_enable() doesn't cause priority inversion
67 extern unsigned long __mn10300_irq_enabled_epsw
;
69 static inline void arch_local_irq_enable(void)
79 : "i"(~EPSW_IM
), "r"(__mn10300_irq_enabled_epsw
)
83 static inline void arch_local_irq_restore(unsigned long flags
)
95 static inline bool arch_irqs_disabled_flags(unsigned long flags
)
97 return (flags
& EPSW_IM
) <= MN10300_CLI_LEVEL
;
100 static inline bool arch_irqs_disabled(void)
102 return arch_irqs_disabled_flags(arch_local_save_flags());
106 * Hook to save power by halting the CPU
107 * - called from the idle loop
108 * - must reenable interrupts (which takes three instruction cycles to complete)
110 static inline void arch_safe_halt(void)
118 : "i"(EPSW_IE
|EPSW_IM
), "n"(&CPUM
), "i"(CPUM_SLEEP
)
122 #endif /* __ASSEMBLY__ */
123 #endif /* _ASM_IRQFLAGS_H */