aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-06-08 12:49:48 -0400
committerMike Frysinger <vapier@gentoo.org>2009-06-13 07:20:13 -0400
commit8f86001f76609f70bfcce34e7e2a11860e012ace (patch)
tree714bb31a2e54ceabfc750a1a1e556cc1ff60abff /arch/blackfin/include/asm
parent538067c822e2512d9a165c71c0c5722168470304 (diff)
Blackfin: add support for irqflags
This converts the irq handling in the Blackfin arch from the old irq.h / system.h method to the new irqflags.h. A stepping stone on the way to other tracing functionality. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/include/asm')
-rw-r--r--arch/blackfin/include/asm/irq.h271
-rw-r--r--arch/blackfin/include/asm/irqflags.h63
-rw-r--r--arch/blackfin/include/asm/system.h4
3 files changed, 74 insertions, 264 deletions
diff --git a/arch/blackfin/include/asm/irq.h b/arch/blackfin/include/asm/irq.h
index 7645e85a5f6f..400bdd52ce87 100644
--- a/arch/blackfin/include/asm/irq.h
+++ b/arch/blackfin/include/asm/irq.h
@@ -17,270 +17,17 @@
17#ifndef _BFIN_IRQ_H_ 17#ifndef _BFIN_IRQ_H_
18#define _BFIN_IRQ_H_ 18#define _BFIN_IRQ_H_
19 19
20/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h>*/ 20#include <linux/irqflags.h>
21#include <mach/irq.h>
22#include <asm/pda.h>
23#include <asm/processor.h>
24
25#ifdef CONFIG_SMP
26/* Forward decl needed due to cdef inter dependencies */
27static inline uint32_t __pure bfin_dspid(void);
28# define blackfin_core_id() (bfin_dspid() & 0xff)
29# define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
30#else
31extern unsigned long bfin_irq_flags;
32#endif
33
34#ifdef CONFIG_IPIPE
35
36#include <linux/ipipe_trace.h>
37 21
38void __ipipe_unstall_root(void); 22/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h> */
39 23#include <mach/irq.h>
40void __ipipe_restore_root(unsigned long flags);
41
42#ifdef CONFIG_DEBUG_HWERR
43# define __all_masked_irq_flags 0x3f
44# define __save_and_cli_hw(x) \
45 __asm__ __volatile__( \
46 "cli %0;" \
47 "sti %1;" \
48 : "=&d"(x) \
49 : "d" (0x3F) \
50 )
51#else
52# define __all_masked_irq_flags 0x1f
53# define __save_and_cli_hw(x) \
54 __asm__ __volatile__( \
55 "cli %0;" \
56 : "=&d"(x) \
57 )
58#endif
59
60#define irqs_enabled_from_flags_hw(x) ((x) != __all_masked_irq_flags)
61#define raw_irqs_disabled_flags(flags) (!irqs_enabled_from_flags_hw(flags))
62#define local_test_iflag_hw(x) irqs_enabled_from_flags_hw(x)
63
64#define local_save_flags(x) \
65 do { \
66 (x) = __ipipe_test_root() ? \
67 __all_masked_irq_flags : bfin_irq_flags; \
68 barrier(); \
69 } while (0)
70
71#define local_irq_save(x) \
72 do { \
73 (x) = __ipipe_test_and_stall_root() ? \
74 __all_masked_irq_flags : bfin_irq_flags; \
75 barrier(); \
76 } while (0)
77
78static inline void local_irq_restore(unsigned long x)
79{
80 barrier();
81 __ipipe_restore_root(x == __all_masked_irq_flags);
82}
83
84#define local_irq_disable() \
85 do { \
86 __ipipe_stall_root(); \
87 barrier(); \
88 } while (0)
89
90static inline void local_irq_enable(void)
91{
92 barrier();
93 __ipipe_unstall_root();
94}
95
96#define irqs_disabled() __ipipe_test_root()
97
98#define local_save_flags_hw(x) \
99 __asm__ __volatile__( \
100 "cli %0;" \
101 "sti %0;" \
102 : "=d"(x) \
103 )
104
105#define irqs_disabled_hw() \
106 ({ \
107 unsigned long flags; \
108 local_save_flags_hw(flags); \
109 !irqs_enabled_from_flags_hw(flags); \
110 })
111
112static inline unsigned long raw_mangle_irq_bits(int virt, unsigned long real)
113{
114 /* Merge virtual and real interrupt mask bits into a single
115 32bit word. */
116 return (real & ~(1 << 31)) | ((virt != 0) << 31);
117}
118
119static inline int raw_demangle_irq_bits(unsigned long *x)
120{
121 int virt = (*x & (1 << 31)) != 0;
122 *x &= ~(1L << 31);
123 return virt;
124}
125
126#ifdef CONFIG_IPIPE_TRACE_IRQSOFF
127
128#define local_irq_disable_hw() \
129 do { \
130 int _tmp_dummy; \
131 if (!irqs_disabled_hw()) \
132 ipipe_trace_begin(0x80000000); \
133 __asm__ __volatile__ ("cli %0;" : "=d" (_tmp_dummy) : ); \
134 } while (0)
135
136#define local_irq_enable_hw() \
137 do { \
138 if (irqs_disabled_hw()) \
139 ipipe_trace_end(0x80000000); \
140 __asm__ __volatile__ ("sti %0;" : : "d"(bfin_irq_flags)); \
141 } while (0)
142
143#define local_irq_save_hw(x) \
144 do { \
145 __save_and_cli_hw(x); \
146 if (local_test_iflag_hw(x)) \
147 ipipe_trace_begin(0x80000001); \
148 } while (0)
149
150#define local_irq_restore_hw(x) \
151 do { \
152 if (local_test_iflag_hw(x)) { \
153 ipipe_trace_end(0x80000001); \
154 local_irq_enable_hw_notrace(); \
155 } \
156 } while (0)
157
158#define local_irq_disable_hw_notrace() \
159 do { \
160 int _tmp_dummy; \
161 __asm__ __volatile__ ("cli %0;" : "=d" (_tmp_dummy) : ); \
162 } while (0)
163
164#define local_irq_enable_hw_notrace() \
165 __asm__ __volatile__( \
166 "sti %0;" \
167 : \
168 : "d"(bfin_irq_flags) \
169 )
170
171#define local_irq_save_hw_notrace(x) __save_and_cli_hw(x)
172
173#define local_irq_restore_hw_notrace(x) \
174 do { \
175 if (local_test_iflag_hw(x)) \
176 local_irq_enable_hw_notrace(); \
177 } while (0)
178
179#else /* CONFIG_IPIPE_TRACE_IRQSOFF */
180
181#define local_irq_enable_hw() \
182 __asm__ __volatile__( \
183 "sti %0;" \
184 : \
185 : "d"(bfin_irq_flags) \
186 )
187
188#define local_irq_disable_hw() \
189 do { \
190 int _tmp_dummy; \
191 __asm__ __volatile__ ( \
192 "cli %0;" \
193 : "=d" (_tmp_dummy)); \
194 } while (0)
195
196#define local_irq_restore_hw(x) \
197 do { \
198 if (irqs_enabled_from_flags_hw(x)) \
199 local_irq_enable_hw(); \
200 } while (0)
201
202#define local_irq_save_hw(x) __save_and_cli_hw(x)
203
204#define local_irq_disable_hw_notrace() local_irq_disable_hw()
205#define local_irq_enable_hw_notrace() local_irq_enable_hw()
206#define local_irq_save_hw_notrace(x) local_irq_save_hw(x)
207#define local_irq_restore_hw_notrace(x) local_irq_restore_hw(x)
208
209#endif /* CONFIG_IPIPE_TRACE_IRQSOFF */
210
211#else /* !CONFIG_IPIPE */
212
213/*
214 * Interrupt configuring macros.
215 */
216#define local_irq_disable() \
217 do { \
218 int __tmp_dummy; \
219 __asm__ __volatile__( \
220 "cli %0;" \
221 : "=d" (__tmp_dummy) \
222 ); \
223 } while (0)
224
225#define local_irq_enable() \
226 __asm__ __volatile__( \
227 "sti %0;" \
228 : \
229 : "d" (bfin_irq_flags) \
230 )
231
232#ifdef CONFIG_DEBUG_HWERR
233# define __save_and_cli(x) \
234 __asm__ __volatile__( \
235 "cli %0;" \
236 "sti %1;" \
237 : "=&d" (x) \
238 : "d" (0x3F) \
239 )
240#else
241# define __save_and_cli(x) \
242 __asm__ __volatile__( \
243 "cli %0;" \
244 : "=&d" (x) \
245 )
246#endif
247
248#define local_save_flags(x) \
249 __asm__ __volatile__( \
250 "cli %0;" \
251 "sti %0;" \
252 : "=d" (x) \
253 )
254
255#ifdef CONFIG_DEBUG_HWERR
256#define irqs_enabled_from_flags(x) (((x) & ~0x3f) != 0)
257#else
258#define irqs_enabled_from_flags(x) ((x) != 0x1f)
259#endif
260
261#define local_irq_restore(x) \
262 do { \
263 if (irqs_enabled_from_flags(x)) \
264 local_irq_enable(); \
265 } while (0)
266
267/* For spinlocks etc */
268#define local_irq_save(x) __save_and_cli(x)
269
270#define irqs_disabled() \
271({ \
272 unsigned long flags; \
273 local_save_flags(flags); \
274 !irqs_enabled_from_flags(flags); \
275})
276
277#define local_irq_save_hw(x) local_irq_save(x)
278#define local_irq_restore_hw(x) local_irq_restore(x)
279#define local_irq_enable_hw() local_irq_enable()
280#define local_irq_disable_hw() local_irq_disable()
281#define irqs_disabled_hw() irqs_disabled()
282 24
283#endif /* !CONFIG_IPIPE */ 25/* Xenomai IPIPE helpers */
26#define local_irq_restore_hw(x) local_irq_restore(x)
27#define local_irq_save_hw(x) local_irq_save(x)
28#define local_irq_enable_hw(x) local_irq_enable(x)
29#define local_irq_disable_hw(x) local_irq_disable(x)
30#define irqs_disabled_hw(x) irqs_disabled(x)
284 31
285#if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE) 32#if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE)
286# define NOP_PAD_ANOMALY_05000244 "nop; nop;" 33# define NOP_PAD_ANOMALY_05000244 "nop; nop;"
diff --git a/arch/blackfin/include/asm/irqflags.h b/arch/blackfin/include/asm/irqflags.h
new file mode 100644
index 000000000000..139cba4651b1
--- /dev/null
+++ b/arch/blackfin/include/asm/irqflags.h
@@ -0,0 +1,63 @@
1/*
2 * interface to Blackfin CEC
3 *
4 * Copyright 2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
6 */
7
8#ifndef __ASM_BFIN_IRQFLAGS_H__
9#define __ASM_BFIN_IRQFLAGS_H__
10
11#ifdef CONFIG_SMP
12# include <asm/pda.h>
13# include <asm/processor.h>
14/* Forward decl needed due to cdef inter dependencies */
15static inline uint32_t __pure bfin_dspid(void);
16# define blackfin_core_id() (bfin_dspid() & 0xff)
17# define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
18#else
19extern unsigned long bfin_irq_flags;
20#endif
21
22static inline void bfin_sti(unsigned long flags)
23{
24 asm volatile("sti %0;" : : "d" (flags));
25}
26
27static inline unsigned long bfin_cli(void)
28{
29 unsigned long flags;
30 asm volatile("cli %0;" : "=d" (flags));
31 return flags;
32}
33
34static inline void raw_local_irq_disable(void)
35{
36 bfin_cli();
37}
38static inline void raw_local_irq_enable(void)
39{
40 bfin_sti(bfin_irq_flags);
41}
42
43#define raw_local_save_flags(flags) do { (flags) = bfin_read_IMASK(); } while (0)
44
45#define raw_irqs_disabled_flags(flags) (((flags) & ~0x3f) == 0)
46
47static inline void raw_local_irq_restore(unsigned long flags)
48{
49 if (!raw_irqs_disabled_flags(flags))
50 raw_local_irq_enable();
51}
52
53static inline unsigned long __raw_local_irq_save(void)
54{
55 unsigned long flags = bfin_cli();
56#ifdef CONFIG_DEBUG_HWERR
57 bfin_sti(0x3f);
58#endif
59 return flags;
60}
61#define raw_local_irq_save(flags) do { (flags) = __raw_local_irq_save(); } while (0)
62
63#endif
diff --git a/arch/blackfin/include/asm/system.h b/arch/blackfin/include/asm/system.h
index a4c8254bec55..294dbda24164 100644
--- a/arch/blackfin/include/asm/system.h
+++ b/arch/blackfin/include/asm/system.h
@@ -35,10 +35,10 @@
35#define _BLACKFIN_SYSTEM_H 35#define _BLACKFIN_SYSTEM_H
36 36
37#include <linux/linkage.h> 37#include <linux/linkage.h>
38#include <linux/compiler.h> 38#include <linux/irqflags.h>
39#include <mach/anomaly.h> 39#include <mach/anomaly.h>
40#include <asm/cache.h>
40#include <asm/pda.h> 41#include <asm/pda.h>
41#include <asm/processor.h>
42#include <asm/irq.h> 42#include <asm/irq.h>
43 43
44/* 44/*