2 * interface to Blackfin CEC
4 * Copyright 2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
8 #ifndef __ASM_BFIN_IRQFLAGS_H__
9 #define __ASM_BFIN_IRQFLAGS_H__
11 #include <mach/blackfin.h>
15 # include <asm/processor.h>
16 # define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
18 extern unsigned long bfin_irq_flags;
21 static inline void bfin_sti(unsigned long flags)
23 asm volatile("sti %0;" : : "d" (flags));
26 static inline unsigned long bfin_cli(void)
29 asm volatile("cli %0;" : "=d" (flags));
33 #ifdef CONFIG_DEBUG_HWERR
34 # define bfin_no_irqs 0x3f
36 # define bfin_no_irqs 0x1f
39 /*****************************************************************************/
41 * Hard, untraced CPU interrupt flag manipulation and access.
43 static inline void __hard_local_irq_disable(void)
48 static inline void __hard_local_irq_enable(void)
50 bfin_sti(bfin_irq_flags);
53 static inline unsigned long hard_local_save_flags(void)
55 return bfin_read_IMASK();
58 static inline unsigned long __hard_local_irq_save(void)
62 #ifdef CONFIG_DEBUG_HWERR
68 static inline int hard_irqs_disabled_flags(unsigned long flags)
70 return (flags & ~0x3f) == 0;
73 static inline int hard_irqs_disabled(void)
75 unsigned long flags = hard_local_save_flags();
76 return hard_irqs_disabled_flags(flags);
79 static inline void __hard_local_irq_restore(unsigned long flags)
81 if (!hard_irqs_disabled_flags(flags))
82 __hard_local_irq_enable();
85 /*****************************************************************************/
87 * Interrupt pipe handling.
91 #include <linux/compiler.h>
92 #include <linux/ipipe_base.h>
93 #include <linux/ipipe_trace.h>
96 * Interrupt pipe interface to linux/irqflags.h.
98 static inline void arch_local_irq_disable(void)
100 ipipe_check_context(ipipe_root_domain);
101 __ipipe_stall_root();
105 static inline void arch_local_irq_enable(void)
108 ipipe_check_context(ipipe_root_domain);
109 __ipipe_unstall_root();
112 static inline unsigned long arch_local_save_flags(void)
114 return __ipipe_test_root() ? bfin_no_irqs : bfin_irq_flags;
117 static inline int arch_irqs_disabled_flags(unsigned long flags)
119 return flags == bfin_no_irqs;
122 static inline void arch_local_irq_save_ptr(unsigned long *_flags)
124 x = __ipipe_test_and_stall_root() ? bfin_no_irqs : bfin_irq_flags;
128 static inline unsigned long arch_local_irq_save(void)
130 ipipe_check_context(ipipe_root_domain);
131 return __hard_local_irq_save();
134 static inline unsigned long arch_mangle_irq_bits(int virt, unsigned long real)
137 * Merge virtual and real interrupt mask bits into a single
140 return (real & ~(1 << 31)) | ((virt != 0) << 31);
143 static inline int arch_demangle_irq_bits(unsigned long *x)
145 int virt = (*x & (1 << 31)) != 0;
151 * Interface to various arch routines that may be traced.
153 #ifdef CONFIG_IPIPE_TRACE_IRQSOFF
154 static inline void hard_local_irq_disable(void)
156 if (!hard_irqs_disabled()) {
157 __hard_local_irq_disable();
158 ipipe_trace_begin(0x80000000);
162 static inline void hard_local_irq_enable(void)
164 if (hard_irqs_disabled()) {
165 ipipe_trace_end(0x80000000);
166 __hard_local_irq_enable();
170 static inline unsigned long hard_local_irq_save(void)
172 unsigned long flags = hard_local_save_flags();
173 if (!hard_irqs_disabled_flags(flags)) {
174 __hard_local_irq_disable();
175 ipipe_trace_begin(0x80000001);
180 static inline void hard_local_irq_restore(unsigned long flags)
182 if (!hard_irqs_disabled_flags(flags)) {
183 ipipe_trace_end(0x80000001);
184 __hard_local_irq_enable();
188 #else /* !CONFIG_IPIPE_TRACE_IRQSOFF */
189 # define hard_local_irq_disable() __hard_local_irq_disable()
190 # define hard_local_irq_enable() __hard_local_irq_enable()
191 # define hard_local_irq_save() __hard_local_irq_save()
192 # define hard_local_irq_restore(flags) __hard_local_irq_restore(flags)
193 #endif /* !CONFIG_IPIPE_TRACE_IRQSOFF */
195 #else /* CONFIG_IPIPE */
198 * Direct interface to linux/irqflags.h.
200 #define arch_local_save_flags() hard_local_save_flags()
201 #define arch_local_irq_save(flags) __hard_local_irq_save()
202 #define arch_local_irq_restore(flags) __hard_local_irq_restore(flags)
203 #define arch_local_irq_enable() __hard_local_irq_enable()
204 #define arch_local_irq_disable() __hard_local_irq_disable()
205 #define arch_irqs_disabled_flags(flags) hard_irqs_disabled_flags(flags)
206 #define arch_irqs_disabled() hard_irqs_disabled()
209 * Interface to various arch routines that may be traced.
211 #define hard_local_irq_save() __hard_local_irq_save()
212 #define hard_local_irq_restore(flags) __hard_local_irq_restore(flags)
213 #define hard_local_irq_enable() __hard_local_irq_enable()
214 #define hard_local_irq_disable() __hard_local_irq_disable()
217 #endif /* !CONFIG_IPIPE */