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 #define MN10300_CLI_LEVEL (CONFIG_LINUX_CLI_LEVEL << EPSW_IM_SHIFT)
30 static inline unsigned long arch_local_save_flags(void)
34 asm volatile("mov epsw,%0" : "=d"(flags));
38 static inline void arch_local_irq_disable(void)
47 : "i"(~EPSW_IM), "i"(EPSW_IE | MN10300_CLI_LEVEL)
51 static inline unsigned long arch_local_irq_save(void)
55 flags = arch_local_save_flags();
56 arch_local_irq_disable();
61 * we make sure arch_irq_enable() doesn't cause priority inversion
63 extern unsigned long __mn10300_irq_enabled_epsw;
65 static inline void arch_local_irq_enable(void)
75 : "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw)
79 static inline void arch_local_irq_restore(unsigned long flags)
91 static inline bool arch_irqs_disabled_flags(unsigned long flags)
93 return (flags & (EPSW_IE | EPSW_IM)) != (EPSW_IE | EPSW_IM_7);
96 static inline bool arch_irqs_disabled(void)
98 return arch_irqs_disabled_flags(arch_local_save_flags());
102 * Hook to save power by halting the CPU
103 * - called from the idle loop
104 * - must reenable interrupts (which takes three instruction cycles to complete)
106 static inline void arch_safe_halt(void)
114 : "i"(EPSW_IE|EPSW_IM), "n"(&CPUM), "i"(CPUM_SLEEP)
118 static inline void arch_local_cli(void)
131 static inline unsigned long arch_local_cli_save(void)
133 unsigned long flags = arch_local_save_flags();
138 static inline void arch_local_sti(void)
147 static inline void arch_local_change_intr_mask_level(unsigned long level)
153 : "i"(~EPSW_IM), "i"(EPSW_IE | level)
157 #else /* !__ASSEMBLY__ */
159 #define LOCAL_SAVE_FLAGS(reg) \
162 #define LOCAL_IRQ_DISABLE \
164 or EPSW_IE|MN10300_CLI_LEVEL,epsw; \
169 #define LOCAL_IRQ_ENABLE \
170 or EPSW_IE|EPSW_IM_7,epsw
172 #define LOCAL_IRQ_RESTORE(reg) \
175 #define LOCAL_CLI_SAVE(reg) \
191 #define LOCAL_CHANGE_INTR_MASK_LEVEL(level) \
193 or EPSW_IE|(level),epsw
195 #endif /* __ASSEMBLY__ */
196 #endif /* _ASM_IRQFLAGS_H */