aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include
diff options
context:
space:
mode:
authorPhilippe Gerum <rpm@xenomai.org>2009-06-15 23:25:37 -0400
committerMike Frysinger <vapier@gentoo.org>2009-06-22 21:15:53 -0400
commit06ecc190f3928850cb77c498f745fc8e9a7e2fd7 (patch)
tree41d705a007dcc0472bf1555e5163f50d52da9f80 /arch/blackfin/include
parent3d15f302d089d0583463745cbece077c1e8294b1 (diff)
Blackfin: convert interrupt pipeline to irqflags
Signed-off-by: Philippe Gerum <rpm@xenomai.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/include')
-rw-r--r--arch/blackfin/include/asm/ipipe_base.h30
-rw-r--r--arch/blackfin/include/asm/irq.h7
-rw-r--r--arch/blackfin/include/asm/irqflags.h164
-rw-r--r--arch/blackfin/include/asm/system.h4
4 files changed, 176 insertions, 29 deletions
diff --git a/arch/blackfin/include/asm/ipipe_base.h b/arch/blackfin/include/asm/ipipe_base.h
index 3e8acbd1a3be..490098f532a7 100644
--- a/arch/blackfin/include/asm/ipipe_base.h
+++ b/arch/blackfin/include/asm/ipipe_base.h
@@ -51,23 +51,23 @@
51 51
52extern unsigned long __ipipe_root_status; /* Alias to ipipe_root_cpudom_var(status) */ 52extern unsigned long __ipipe_root_status; /* Alias to ipipe_root_cpudom_var(status) */
53 53
54static inline void __ipipe_stall_root(void) 54#define __ipipe_stall_root() \
55{ 55 do { \
56 volatile unsigned long *p = &__ipipe_root_status; 56 volatile unsigned long *p = &__ipipe_root_status; \
57 set_bit(0, p); 57 set_bit(0, p); \
58} 58 } while (0)
59 59
60static inline unsigned long __ipipe_test_and_stall_root(void) 60#define __ipipe_test_and_stall_root() \
61{ 61 ({ \
62 volatile unsigned long *p = &__ipipe_root_status; 62 volatile unsigned long *p = &__ipipe_root_status; \
63 return test_and_set_bit(0, p); 63 test_and_set_bit(0, p); \
64} 64 })
65 65
66static inline unsigned long __ipipe_test_root(void) 66#define __ipipe_test_root() \
67{ 67 ({ \
68 const unsigned long *p = &__ipipe_root_status; 68 const unsigned long *p = &__ipipe_root_status; \
69 return test_bit(0, p); 69 test_bit(0, p); \
70} 70 })
71 71
72#endif /* !__ASSEMBLY__ */ 72#endif /* !__ASSEMBLY__ */
73 73
diff --git a/arch/blackfin/include/asm/irq.h b/arch/blackfin/include/asm/irq.h
index 9a7f63a83c47..42a15f5ce0d0 100644
--- a/arch/blackfin/include/asm/irq.h
+++ b/arch/blackfin/include/asm/irq.h
@@ -22,13 +22,6 @@
22/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h> */ 22/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h> */
23#include <mach/irq.h> 23#include <mach/irq.h>
24 24
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)
31
32#if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE) 25#if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE)
33# define NOP_PAD_ANOMALY_05000244 "nop; nop;" 26# define NOP_PAD_ANOMALY_05000244 "nop; nop;"
34#else 27#else
diff --git a/arch/blackfin/include/asm/irqflags.h b/arch/blackfin/include/asm/irqflags.h
index 139cba4651b1..9b19a19d9ae9 100644
--- a/arch/blackfin/include/asm/irqflags.h
+++ b/arch/blackfin/include/asm/irqflags.h
@@ -31,6 +31,150 @@ static inline unsigned long bfin_cli(void)
31 return flags; 31 return flags;
32} 32}
33 33
34#ifdef CONFIG_IPIPE
35
36#include <linux/ipipe_base.h>
37#include <linux/ipipe_trace.h>
38
39#ifdef CONFIG_DEBUG_HWERR
40# define bfin_no_irqs 0x3f
41#else
42# define bfin_no_irqs 0x1f
43#endif
44
45#define raw_local_irq_disable() \
46 do { \
47 ipipe_check_context(ipipe_root_domain); \
48 __ipipe_stall_root(); \
49 barrier(); \
50 } while (0)
51
52static inline void raw_local_irq_enable(void)
53{
54 barrier();
55 ipipe_check_context(ipipe_root_domain);
56 __ipipe_unstall_root();
57}
58
59#define raw_local_save_flags_ptr(x) \
60 do { \
61 *(x) = __ipipe_test_root() ? bfin_no_irqs : bfin_irq_flags; \
62 } while (0)
63
64#define raw_local_save_flags(x) raw_local_save_flags_ptr(&(x))
65
66#define raw_irqs_disabled_flags(x) ((x) == bfin_no_irqs)
67
68#define raw_local_irq_save_ptr(x) \
69 do { \
70 *(x) = __ipipe_test_and_stall_root() ? bfin_no_irqs : bfin_irq_flags; \
71 barrier(); \
72 } while (0)
73
74#define raw_local_irq_save(x) \
75 do { \
76 ipipe_check_context(ipipe_root_domain); \
77 raw_local_irq_save_ptr(&(x)); \
78 } while (0)
79
80static inline unsigned long raw_mangle_irq_bits(int virt, unsigned long real)
81{
82 /*
83 * Merge virtual and real interrupt mask bits into a single
84 * 32bit word.
85 */
86 return (real & ~(1 << 31)) | ((virt != 0) << 31);
87}
88
89static inline int raw_demangle_irq_bits(unsigned long *x)
90{
91 int virt = (*x & (1 << 31)) != 0;
92 *x &= ~(1L << 31);
93 return virt;
94}
95
96static inline void local_irq_disable_hw_notrace(void)
97{
98 bfin_cli();
99}
100
101static inline void local_irq_enable_hw_notrace(void)
102{
103 bfin_sti(bfin_irq_flags);
104}
105
106#define local_save_flags_hw(flags) \
107 do { \
108 (flags) = bfin_read_IMASK(); \
109 } while (0)
110
111#define irqs_disabled_flags_hw(flags) (((flags) & ~0x3f) == 0)
112
113#define irqs_disabled_hw() \
114 ({ \
115 unsigned long flags; \
116 local_save_flags_hw(flags); \
117 irqs_disabled_flags_hw(flags); \
118 })
119
120static inline void local_irq_save_ptr_hw(unsigned long *flags)
121{
122 *flags = bfin_cli();
123#ifdef CONFIG_DEBUG_HWERR
124 bfin_sti(0x3f);
125#endif
126}
127
128#define local_irq_save_hw_notrace(flags) \
129 do { \
130 local_irq_save_ptr_hw(&(flags)); \
131 } while (0)
132
133static inline void local_irq_restore_hw_notrace(unsigned long flags)
134{
135 if (!irqs_disabled_flags_hw(flags))
136 local_irq_enable_hw_notrace();
137}
138
139#ifdef CONFIG_IPIPE_TRACE_IRQSOFF
140# define local_irq_disable_hw() \
141 do { \
142 if (!irqs_disabled_hw()) { \
143 local_irq_disable_hw_notrace(); \
144 ipipe_trace_begin(0x80000000); \
145 } \
146 } while (0)
147# define local_irq_enable_hw() \
148 do { \
149 if (irqs_disabled_hw()) { \
150 ipipe_trace_end(0x80000000); \
151 local_irq_enable_hw_notrace(); \
152 } \
153 } while (0)
154# define local_irq_save_hw(flags) \
155 do { \
156 local_save_flags_hw(flags); \
157 if (!irqs_disabled_flags_hw(flags)) { \
158 local_irq_disable_hw_notrace(); \
159 ipipe_trace_begin(0x80000001); \
160 } \
161 } while (0)
162# define local_irq_restore_hw(flags) \
163 do { \
164 if (!irqs_disabled_flags_hw(flags)) { \
165 ipipe_trace_end(0x80000001); \
166 local_irq_enable_hw_notrace(); \
167 } \
168 } while (0)
169#else /* !CONFIG_IPIPE_TRACE_IRQSOFF */
170# define local_irq_disable_hw() local_irq_disable_hw_notrace()
171# define local_irq_enable_hw() local_irq_enable_hw_notrace()
172# define local_irq_save_hw(flags) local_irq_save_hw_notrace(flags)
173# define local_irq_restore_hw(flags) local_irq_restore_hw_notrace(flags)
174#endif /* !CONFIG_IPIPE_TRACE_IRQSOFF */
175
176#else /* CONFIG_IPIPE */
177
34static inline void raw_local_irq_disable(void) 178static inline void raw_local_irq_disable(void)
35{ 179{
36 bfin_cli(); 180 bfin_cli();
@@ -44,12 +188,6 @@ static inline void raw_local_irq_enable(void)
44 188
45#define raw_irqs_disabled_flags(flags) (((flags) & ~0x3f) == 0) 189#define raw_irqs_disabled_flags(flags) (((flags) & ~0x3f) == 0)
46 190
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) 191static inline unsigned long __raw_local_irq_save(void)
54{ 192{
55 unsigned long flags = bfin_cli(); 193 unsigned long flags = bfin_cli();
@@ -60,4 +198,18 @@ static inline unsigned long __raw_local_irq_save(void)
60} 198}
61#define raw_local_irq_save(flags) do { (flags) = __raw_local_irq_save(); } while (0) 199#define raw_local_irq_save(flags) do { (flags) = __raw_local_irq_save(); } while (0)
62 200
201#define local_irq_save_hw(flags) raw_local_irq_save(flags)
202#define local_irq_restore_hw(flags) raw_local_irq_restore(flags)
203#define local_irq_enable_hw() raw_local_irq_enable()
204#define local_irq_disable_hw() raw_local_irq_disable()
205#define irqs_disabled_hw() irqs_disabled()
206
207#endif /* !CONFIG_IPIPE */
208
209static inline void raw_local_irq_restore(unsigned long flags)
210{
211 if (!raw_irqs_disabled_flags(flags))
212 raw_local_irq_enable();
213}
214
63#endif 215#endif
diff --git a/arch/blackfin/include/asm/system.h b/arch/blackfin/include/asm/system.h
index 294dbda24164..85e8f16cf8c2 100644
--- a/arch/blackfin/include/asm/system.h
+++ b/arch/blackfin/include/asm/system.h
@@ -135,11 +135,13 @@ struct __xchg_dummy {
135}; 135};
136#define __xg(x) ((volatile struct __xchg_dummy *)(x)) 136#define __xg(x) ((volatile struct __xchg_dummy *)(x))
137 137
138#include <mach/blackfin.h>
139
138static inline unsigned long __xchg(unsigned long x, volatile void *ptr, 140static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
139 int size) 141 int size)
140{ 142{
141 unsigned long tmp = 0; 143 unsigned long tmp = 0;
142 unsigned long flags = 0; 144 unsigned long flags;
143 145
144 local_irq_save_hw(flags); 146 local_irq_save_hw(flags);
145 147