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>
16 /* linux/smp.h <- linux/irqflags.h needs asm/smp.h first */
21 * - "disabled": run in IM1/2
22 * - level 0 - kernel debugger
23 * - level 1 - virtual serial DMA (if present)
24 * - level 5 - normal interrupt priority
25 * - level 6 - timer interrupt
26 * - "enabled": run in IM7
28 #define MN10300_CLI_LEVEL (CONFIG_LINUX_CLI_LEVEL << EPSW_IM_SHIFT)
32 static inline unsigned long arch_local_save_flags(void)
36 asm volatile("mov epsw,%0" : "=d"(flags
));
40 static inline void arch_local_irq_disable(void)
49 : "i"(~EPSW_IM
), "i"(EPSW_IE
| MN10300_CLI_LEVEL
)
53 static inline unsigned long arch_local_irq_save(void)
57 flags
= arch_local_save_flags();
58 arch_local_irq_disable();
63 * we make sure arch_irq_enable() doesn't cause priority inversion
65 extern unsigned long __mn10300_irq_enabled_epsw
[];
67 static inline void arch_local_irq_enable(void)
70 int cpu
= raw_smp_processor_id();
78 : "i"(~EPSW_IM
), "r"(__mn10300_irq_enabled_epsw
[cpu
])
82 static inline void arch_local_irq_restore(unsigned long flags
)
94 static inline bool arch_irqs_disabled_flags(unsigned long flags
)
96 return (flags
& (EPSW_IE
| EPSW_IM
)) != (EPSW_IE
| EPSW_IM_7
);
99 static inline bool arch_irqs_disabled(void)
101 return arch_irqs_disabled_flags(arch_local_save_flags());
105 * Hook to save power by halting the CPU
106 * - called from the idle loop
107 * - must reenable interrupts (which takes three instruction cycles to complete)
109 static inline void arch_safe_halt(void)
112 arch_local_irq_enable();
120 : "i"(EPSW_IE
|EPSW_IM
), "n"(&CPUM
), "i"(CPUM_SLEEP
)
125 #define __sleep_cpu() \
129 "1: btst %1,(%0)\n" \
132 : "i"(&CPUM), "i"(CPUM_SLEEP) \
137 static inline void arch_local_cli(void)
150 static inline unsigned long arch_local_cli_save(void)
152 unsigned long flags
= arch_local_save_flags();
157 static inline void arch_local_sti(void)
166 static inline void arch_local_change_intr_mask_level(unsigned long level
)
172 : "i"(~EPSW_IM
), "i"(EPSW_IE
| level
)
176 #else /* !__ASSEMBLY__ */
178 #define LOCAL_SAVE_FLAGS(reg) \
181 #define LOCAL_IRQ_DISABLE \
183 or EPSW_IE|MN10300_CLI_LEVEL,epsw; \
188 #define LOCAL_IRQ_ENABLE \
189 or EPSW_IE|EPSW_IM_7,epsw
191 #define LOCAL_IRQ_RESTORE(reg) \
194 #define LOCAL_CLI_SAVE(reg) \
210 #define LOCAL_CHANGE_INTR_MASK_LEVEL(level) \
212 or EPSW_IE|(level),epsw
214 #endif /* __ASSEMBLY__ */
215 #endif /* _ASM_IRQFLAGS_H */