Fix IRQ flag handling naming
[linux-2.6/cjktty.git] / arch / blackfin / include / asm / irqflags.h
blob41c4d70544ef4811cd23c85f03c68122221f7aae
1 /*
2 * interface to Blackfin CEC
4 * Copyright 2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
6 */
8 #ifndef __ASM_BFIN_IRQFLAGS_H__
9 #define __ASM_BFIN_IRQFLAGS_H__
11 #include <mach/blackfin.h>
13 #ifdef CONFIG_SMP
14 # include <asm/pda.h>
15 # include <asm/processor.h>
16 /* Forward decl needed due to cdef inter dependencies */
17 static inline uint32_t __pure bfin_dspid(void);
18 # define blackfin_core_id() (bfin_dspid() & 0xff)
19 # define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
20 #else
21 extern unsigned long bfin_irq_flags;
22 #endif
24 static inline void bfin_sti(unsigned long flags)
26 asm volatile("sti %0;" : : "d" (flags));
29 static inline unsigned long bfin_cli(void)
31 unsigned long flags;
32 asm volatile("cli %0;" : "=d" (flags));
33 return flags;
36 #ifdef CONFIG_DEBUG_HWERR
37 # define bfin_no_irqs 0x3f
38 #else
39 # define bfin_no_irqs 0x1f
40 #endif
42 /*****************************************************************************/
44 * Hard, untraced CPU interrupt flag manipulation and access.
46 static inline void __hard_local_irq_disable(void)
48 bfin_cli();
51 static inline void __hard_local_irq_enable(void)
53 bfin_sti(bfin_irq_flags);
56 static inline unsigned long hard_local_save_flags(void)
58 return bfin_read_IMASK();
61 static inline unsigned long __hard_local_irq_save(void)
63 unsigned long flags;
64 flags = bfin_cli();
65 #ifdef CONFIG_DEBUG_HWERR
66 bfin_sti(0x3f);
67 #endif
68 return flags;
71 static inline int hard_irqs_disabled_flags(unsigned long flags)
73 return (flags & ~0x3f) == 0;
76 static inline int hard_irqs_disabled(void)
78 unsigned long flags = hard_local_save_flags();
79 return hard_irqs_disabled_flags(flags);
82 static inline void __hard_local_irq_restore(unsigned long flags)
84 if (!hard_irqs_disabled_flags(flags))
85 __hard_local_irq_enable();
88 /*****************************************************************************/
90 * Interrupt pipe handling.
92 #ifdef CONFIG_IPIPE
94 #include <linux/compiler.h>
95 #include <linux/ipipe_base.h>
96 #include <linux/ipipe_trace.h>
99 * Interrupt pipe interface to linux/irqflags.h.
101 static inline void arch_local_irq_disable(void)
103 ipipe_check_context(ipipe_root_domain);
104 __ipipe_stall_root();
105 barrier();
108 static inline void arch_local_irq_enable(void)
110 barrier();
111 ipipe_check_context(ipipe_root_domain);
112 __ipipe_unstall_root();
115 static inline unsigned long arch_local_save_flags(void)
117 return __ipipe_test_root() ? bfin_no_irqs : bfin_irq_flags;
120 static inline int arch_irqs_disabled_flags(unsigned long flags)
122 return flags == bfin_no_irqs;
125 static inline void arch_local_irq_save_ptr(unsigned long *_flags)
127 x = __ipipe_test_and_stall_root() ? bfin_no_irqs : bfin_irq_flags;
128 barrier();
131 static inline unsigned long arch_local_irq_save(void)
133 ipipe_check_context(ipipe_root_domain);
134 return __hard_local_irq_save();
137 static inline unsigned long arch_mangle_irq_bits(int virt, unsigned long real)
140 * Merge virtual and real interrupt mask bits into a single
141 * 32bit word.
143 return (real & ~(1 << 31)) | ((virt != 0) << 31);
146 static inline int arch_demangle_irq_bits(unsigned long *x)
148 int virt = (*x & (1 << 31)) != 0;
149 *x &= ~(1L << 31);
150 return virt;
154 * Interface to various arch routines that may be traced.
156 #ifdef CONFIG_IPIPE_TRACE_IRQSOFF
157 static inline void hard_local_irq_disable(void)
159 if (!hard_irqs_disabled()) {
160 __hard_local_irq_disable();
161 ipipe_trace_begin(0x80000000);
165 static inline void hard_local_irq_enable(void)
167 if (hard_irqs_disabled()) {
168 ipipe_trace_end(0x80000000);
169 __hard_local_irq_enable();
173 static inline unsigned long hard_local_irq_save(void)
175 unsigned long flags = hard_local_save_flags();
176 if (!hard_irqs_disabled_flags(flags)) {
177 __hard_local_irq_disable();
178 ipipe_trace_begin(0x80000001);
180 return flags;
183 static inline void hard_local_irq_restore(unsigned long flags)
185 if (!hard_irqs_disabled_flags(flags)) {
186 ipipe_trace_end(0x80000001);
187 __hard_local_irq_enable();
191 #else /* !CONFIG_IPIPE_TRACE_IRQSOFF */
192 # define hard_local_irq_disable() __hard_local_irq_disable()
193 # define hard_local_irq_enable() __hard_local_irq_enable()
194 # define hard_local_irq_save() __hard_local_irq_save()
195 # define hard_local_irq_restore(flags) __hard_local_irq_restore(flags)
196 #endif /* !CONFIG_IPIPE_TRACE_IRQSOFF */
198 #else /* CONFIG_IPIPE */
201 * Direct interface to linux/irqflags.h.
203 #define arch_local_save_flags() hard_local_save_flags()
204 #define arch_local_irq_save(flags) __hard_local_irq_save()
205 #define arch_local_irq_restore(flags) __hard_local_irq_restore(flags)
206 #define arch_local_irq_enable() __hard_local_irq_enable()
207 #define arch_local_irq_disable() __hard_local_irq_disable()
208 #define arch_irqs_disabled_flags(flags) hard_irqs_disabled_flags(flags)
209 #define arch_irqs_disabled() hard_irqs_disabled()
212 * Interface to various arch routines that may be traced.
214 #define hard_local_irq_save() __hard_local_irq_save()
215 #define hard_local_irq_restore(flags) __hard_local_irq_restore(flags)
216 #define hard_local_irq_enable() __hard_local_irq_enable()
217 #define hard_local_irq_disable() __hard_local_irq_disable()
220 #endif /* !CONFIG_IPIPE */
221 #endif