aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/include')
-rw-r--r--arch/blackfin/include/asm/atomic.h16
-rw-r--r--arch/blackfin/include/asm/bfin-global.h11
-rw-r--r--arch/blackfin/include/asm/bitops.h3
-rw-r--r--arch/blackfin/include/asm/bug.h57
-rw-r--r--arch/blackfin/include/asm/cache.h11
-rw-r--r--arch/blackfin/include/asm/cacheflush.h3
-rw-r--r--arch/blackfin/include/asm/cpu.h1
-rw-r--r--arch/blackfin/include/asm/ftrace.h14
-rw-r--r--arch/blackfin/include/asm/ipipe.h28
-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/mutex-dec.h112
-rw-r--r--arch/blackfin/include/asm/sections.h11
-rw-r--r--arch/blackfin/include/asm/system.h4
-rw-r--r--arch/blackfin/include/asm/unistd.h3
15 files changed, 188 insertions, 420 deletions
diff --git a/arch/blackfin/include/asm/atomic.h b/arch/blackfin/include/asm/atomic.h
index 7bbf44e4ddf..b1d92f13ef9 100644
--- a/arch/blackfin/include/asm/atomic.h
+++ b/arch/blackfin/include/asm/atomic.h
@@ -90,7 +90,7 @@ static inline int atomic_test_mask(int mask, atomic_t *v)
90 90
91static inline void atomic_add(int i, atomic_t *v) 91static inline void atomic_add(int i, atomic_t *v)
92{ 92{
93 long flags; 93 unsigned long flags;
94 94
95 local_irq_save_hw(flags); 95 local_irq_save_hw(flags);
96 v->counter += i; 96 v->counter += i;
@@ -99,7 +99,7 @@ static inline void atomic_add(int i, atomic_t *v)
99 99
100static inline void atomic_sub(int i, atomic_t *v) 100static inline void atomic_sub(int i, atomic_t *v)
101{ 101{
102 long flags; 102 unsigned long flags;
103 103
104 local_irq_save_hw(flags); 104 local_irq_save_hw(flags);
105 v->counter -= i; 105 v->counter -= i;
@@ -110,7 +110,7 @@ static inline void atomic_sub(int i, atomic_t *v)
110static inline int atomic_add_return(int i, atomic_t *v) 110static inline int atomic_add_return(int i, atomic_t *v)
111{ 111{
112 int __temp = 0; 112 int __temp = 0;
113 long flags; 113 unsigned long flags;
114 114
115 local_irq_save_hw(flags); 115 local_irq_save_hw(flags);
116 v->counter += i; 116 v->counter += i;
@@ -124,7 +124,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
124static inline int atomic_sub_return(int i, atomic_t *v) 124static inline int atomic_sub_return(int i, atomic_t *v)
125{ 125{
126 int __temp = 0; 126 int __temp = 0;
127 long flags; 127 unsigned long flags;
128 128
129 local_irq_save_hw(flags); 129 local_irq_save_hw(flags);
130 v->counter -= i; 130 v->counter -= i;
@@ -136,7 +136,7 @@ static inline int atomic_sub_return(int i, atomic_t *v)
136 136
137static inline void atomic_inc(volatile atomic_t *v) 137static inline void atomic_inc(volatile atomic_t *v)
138{ 138{
139 long flags; 139 unsigned long flags;
140 140
141 local_irq_save_hw(flags); 141 local_irq_save_hw(flags);
142 v->counter++; 142 v->counter++;
@@ -145,7 +145,7 @@ static inline void atomic_inc(volatile atomic_t *v)
145 145
146static inline void atomic_dec(volatile atomic_t *v) 146static inline void atomic_dec(volatile atomic_t *v)
147{ 147{
148 long flags; 148 unsigned long flags;
149 149
150 local_irq_save_hw(flags); 150 local_irq_save_hw(flags);
151 v->counter--; 151 v->counter--;
@@ -154,7 +154,7 @@ static inline void atomic_dec(volatile atomic_t *v)
154 154
155static inline void atomic_clear_mask(unsigned int mask, atomic_t *v) 155static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
156{ 156{
157 long flags; 157 unsigned long flags;
158 158
159 local_irq_save_hw(flags); 159 local_irq_save_hw(flags);
160 v->counter &= ~mask; 160 v->counter &= ~mask;
@@ -163,7 +163,7 @@ static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
163 163
164static inline void atomic_set_mask(unsigned int mask, atomic_t *v) 164static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
165{ 165{
166 long flags; 166 unsigned long flags;
167 167
168 local_irq_save_hw(flags); 168 local_irq_save_hw(flags);
169 v->counter |= mask; 169 v->counter |= mask;
diff --git a/arch/blackfin/include/asm/bfin-global.h b/arch/blackfin/include/asm/bfin-global.h
index daffc0684e7..e39277ea43e 100644
--- a/arch/blackfin/include/asm/bfin-global.h
+++ b/arch/blackfin/include/asm/bfin-global.h
@@ -31,7 +31,7 @@
31 31
32#ifndef __ASSEMBLY__ 32#ifndef __ASSEMBLY__
33 33
34#include <asm-generic/sections.h> 34#include <asm/sections.h>
35#include <asm/ptrace.h> 35#include <asm/ptrace.h>
36#include <asm/user.h> 36#include <asm/user.h>
37#include <linux/linkage.h> 37#include <linux/linkage.h>
@@ -99,15 +99,6 @@ extern const char bfin_board_name[];
99extern unsigned long bfin_sic_iwr[]; 99extern unsigned long bfin_sic_iwr[];
100extern unsigned vr_wakeup; 100extern unsigned vr_wakeup;
101extern u16 _bfin_swrst; /* shadow for Software Reset Register (SWRST) */ 101extern u16 _bfin_swrst; /* shadow for Software Reset Register (SWRST) */
102extern unsigned long _ramstart, _ramend, _rambase;
103extern unsigned long memory_start, memory_end, physical_mem_end;
104extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
105 _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _sbss_b_l1[], _ebss_b_l1[],
106 _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[],
107 _ebss_l2[], _l2_lma_start[];
108
109/* only used when MTD_UCLINUX */
110extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size;
111 102
112#ifdef CONFIG_BFIN_ICACHE_LOCK 103#ifdef CONFIG_BFIN_ICACHE_LOCK
113extern void cache_grab_lock(int way); 104extern void cache_grab_lock(int way);
diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h
index 21b036eadab..75fee2f7d9f 100644
--- a/arch/blackfin/include/asm/bitops.h
+++ b/arch/blackfin/include/asm/bitops.h
@@ -109,7 +109,8 @@ static inline void clear_bit(int nr, volatile unsigned long *addr)
109 109
110static inline void change_bit(int nr, volatile unsigned long *addr) 110static inline void change_bit(int nr, volatile unsigned long *addr)
111{ 111{
112 int mask, flags; 112 int mask;
113 unsigned long flags;
113 unsigned long *ADDR = (unsigned long *)addr; 114 unsigned long *ADDR = (unsigned long *)addr;
114 115
115 ADDR += nr >> 5; 116 ADDR += nr >> 5;
diff --git a/arch/blackfin/include/asm/bug.h b/arch/blackfin/include/asm/bug.h
index 6d3e11b1fc5..655e49540e4 100644
--- a/arch/blackfin/include/asm/bug.h
+++ b/arch/blackfin/include/asm/bug.h
@@ -2,13 +2,58 @@
2#define _BLACKFIN_BUG_H 2#define _BLACKFIN_BUG_H
3 3
4#ifdef CONFIG_BUG 4#ifdef CONFIG_BUG
5#define HAVE_ARCH_BUG
6 5
7#define BUG() do { \ 6#define BFIN_BUG_OPCODE 0xefcd
8 dump_bfin_trace_buffer(); \ 7
9 printk(KERN_EMERG "BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ 8#ifdef CONFIG_DEBUG_BUGVERBOSE
10 panic("BUG!"); \ 9
11} while (0) 10#define _BUG_OR_WARN(flags) \
11 asm volatile( \
12 "1: .hword %0\n" \
13 " .section __bug_table,\"a\",@progbits\n" \
14 "2: .long 1b\n" \
15 " .long %1\n" \
16 " .short %2\n" \
17 " .short %3\n" \
18 " .org 2b + %4\n" \
19 " .previous" \
20 : \
21 : "i"(BFIN_BUG_OPCODE), "i"(__FILE__), \
22 "i"(__LINE__), "i"(flags), \
23 "i"(sizeof(struct bug_entry)))
24
25#else
26
27#define _BUG_OR_WARN(flags) \
28 asm volatile( \
29 "1: .hword %0\n" \
30 " .section __bug_table,\"a\",@progbits\n" \
31 "2: .long 1b\n" \
32 " .short %1\n" \
33 " .org 2b + %2\n" \
34 " .previous" \
35 : \
36 : "i"(BFIN_BUG_OPCODE), "i"(flags), \
37 "i"(sizeof(struct bug_entry)))
38
39#endif /* CONFIG_DEBUG_BUGVERBOSE */
40
41#define BUG() \
42 do { \
43 _BUG_OR_WARN(0); \
44 for (;;); \
45 } while (0)
46
47#define WARN_ON(condition) \
48 ({ \
49 int __ret_warn_on = !!(condition); \
50 if (unlikely(__ret_warn_on)) \
51 _BUG_OR_WARN(BUGFLAG_WARNING); \
52 unlikely(__ret_warn_on); \
53 })
54
55#define HAVE_ARCH_BUG
56#define HAVE_ARCH_WARN_ON
12 57
13#endif 58#endif
14 59
diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
index 86637814cf2..2ef669ed922 100644
--- a/arch/blackfin/include/asm/cache.h
+++ b/arch/blackfin/include/asm/cache.h
@@ -34,9 +34,13 @@
34#define L1_CACHE_SHIFT_MAX 5 34#define L1_CACHE_SHIFT_MAX 5
35 35
36#if defined(CONFIG_SMP) && \ 36#if defined(CONFIG_SMP) && \
37 !defined(CONFIG_BFIN_CACHE_COHERENT) && \ 37 !defined(CONFIG_BFIN_CACHE_COHERENT)
38 defined(CONFIG_BFIN_DCACHE) 38# if defined(CONFIG_BFIN_ICACHE)
39#define __ARCH_SYNC_CORE_DCACHE 39# define __ARCH_SYNC_CORE_ICACHE
40# endif
41# if defined(CONFIG_BFIN_DCACHE)
42# define __ARCH_SYNC_CORE_DCACHE
43# endif
40#ifndef __ASSEMBLY__ 44#ifndef __ASSEMBLY__
41asmlinkage void __raw_smp_mark_barrier_asm(void); 45asmlinkage void __raw_smp_mark_barrier_asm(void);
42asmlinkage void __raw_smp_check_barrier_asm(void); 46asmlinkage void __raw_smp_check_barrier_asm(void);
@@ -51,6 +55,7 @@ static inline void smp_check_barrier(void)
51} 55}
52 56
53void resync_core_dcache(void); 57void resync_core_dcache(void);
58void resync_core_icache(void);
54#endif 59#endif
55#endif 60#endif
56 61
diff --git a/arch/blackfin/include/asm/cacheflush.h b/arch/blackfin/include/asm/cacheflush.h
index 94697f0f6f4..5c17dee53b5 100644
--- a/arch/blackfin/include/asm/cacheflush.h
+++ b/arch/blackfin/include/asm/cacheflush.h
@@ -37,6 +37,7 @@ extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned lo
37extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address); 37extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address);
38extern void blackfin_dflush_page(void *page); 38extern void blackfin_dflush_page(void *page);
39extern void blackfin_invalidate_entire_dcache(void); 39extern void blackfin_invalidate_entire_dcache(void);
40extern void blackfin_invalidate_entire_icache(void);
40 41
41#define flush_dcache_mmap_lock(mapping) do { } while (0) 42#define flush_dcache_mmap_lock(mapping) do { } while (0)
42#define flush_dcache_mmap_unlock(mapping) do { } while (0) 43#define flush_dcache_mmap_unlock(mapping) do { } while (0)
@@ -97,7 +98,7 @@ do { memcpy(dst, src, len); \
97extern unsigned long reserved_mem_dcache_on; 98extern unsigned long reserved_mem_dcache_on;
98extern unsigned long reserved_mem_icache_on; 99extern unsigned long reserved_mem_icache_on;
99 100
100static inline int bfin_addr_dcachable(unsigned long addr) 101static inline int bfin_addr_dcacheable(unsigned long addr)
101{ 102{
102#ifdef CONFIG_BFIN_DCACHE 103#ifdef CONFIG_BFIN_DCACHE
103 if (addr < (_ramend - DMA_UNCACHED_REGION)) 104 if (addr < (_ramend - DMA_UNCACHED_REGION))
diff --git a/arch/blackfin/include/asm/cpu.h b/arch/blackfin/include/asm/cpu.h
index c2594ef877f..565b8136855 100644
--- a/arch/blackfin/include/asm/cpu.h
+++ b/arch/blackfin/include/asm/cpu.h
@@ -34,6 +34,7 @@ struct blackfin_cpudata {
34 unsigned int dmemctl; 34 unsigned int dmemctl;
35 unsigned long loops_per_jiffy; 35 unsigned long loops_per_jiffy;
36 unsigned long dcache_invld_count; 36 unsigned long dcache_invld_count;
37 unsigned long icache_invld_count;
37}; 38};
38 39
39DECLARE_PER_CPU(struct blackfin_cpudata, cpu_data); 40DECLARE_PER_CPU(struct blackfin_cpudata, cpu_data);
diff --git a/arch/blackfin/include/asm/ftrace.h b/arch/blackfin/include/asm/ftrace.h
index 40a8c178f10..8643680f0f7 100644
--- a/arch/blackfin/include/asm/ftrace.h
+++ b/arch/blackfin/include/asm/ftrace.h
@@ -1 +1,13 @@
1/* empty */ 1/*
2 * Blackfin ftrace code
3 *
4 * Copyright 2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
6 */
7
8#ifndef __ASM_BFIN_FTRACE_H__
9#define __ASM_BFIN_FTRACE_H__
10
11#define MCOUNT_INSN_SIZE 8 /* sizeof mcount call: LINK + CALL */
12
13#endif
diff --git a/arch/blackfin/include/asm/ipipe.h b/arch/blackfin/include/asm/ipipe.h
index 51d0bf5e289..bbe1c3726b6 100644
--- a/arch/blackfin/include/asm/ipipe.h
+++ b/arch/blackfin/include/asm/ipipe.h
@@ -35,10 +35,10 @@
35#include <asm/atomic.h> 35#include <asm/atomic.h>
36#include <asm/traps.h> 36#include <asm/traps.h>
37 37
38#define IPIPE_ARCH_STRING "1.9-01" 38#define IPIPE_ARCH_STRING "1.10-00"
39#define IPIPE_MAJOR_NUMBER 1 39#define IPIPE_MAJOR_NUMBER 1
40#define IPIPE_MINOR_NUMBER 9 40#define IPIPE_MINOR_NUMBER 10
41#define IPIPE_PATCH_NUMBER 1 41#define IPIPE_PATCH_NUMBER 0
42 42
43#ifdef CONFIG_SMP 43#ifdef CONFIG_SMP
44#error "I-pipe/blackfin: SMP not implemented" 44#error "I-pipe/blackfin: SMP not implemented"
@@ -54,10 +54,11 @@ do { \
54 54
55#define task_hijacked(p) \ 55#define task_hijacked(p) \
56 ({ \ 56 ({ \
57 int __x__ = ipipe_current_domain != ipipe_root_domain; \ 57 int __x__ = __ipipe_root_domain_p; \
58 /* We would need to clear the SYNC flag for the root domain */ \ 58 __clear_bit(IPIPE_SYNC_FLAG, &ipipe_root_cpudom_var(status)); \
59 /* over the current processor in SMP mode. */ \ 59 if (__x__) \
60 local_irq_enable_hw(); __x__; \ 60 local_irq_enable_hw(); \
61 !__x__; \
61 }) 62 })
62 63
63struct ipipe_domain; 64struct ipipe_domain;
@@ -179,23 +180,24 @@ static inline unsigned long __ipipe_ffnz(unsigned long ul)
179 180
180#define __ipipe_run_isr(ipd, irq) \ 181#define __ipipe_run_isr(ipd, irq) \
181 do { \ 182 do { \
182 if (ipd == ipipe_root_domain) { \ 183 if (!__ipipe_pipeline_head_p(ipd)) \
183 local_irq_enable_hw(); \ 184 local_irq_enable_hw(); \
184 if (ipipe_virtual_irq_p(irq)) \ 185 if (ipd == ipipe_root_domain) { \
186 if (unlikely(ipipe_virtual_irq_p(irq))) { \
187 irq_enter(); \
185 ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \ 188 ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \
186 else \ 189 irq_exit(); \
190 } else \
187 ipd->irqs[irq].handler(irq, &__raw_get_cpu_var(__ipipe_tick_regs)); \ 191 ipd->irqs[irq].handler(irq, &__raw_get_cpu_var(__ipipe_tick_regs)); \
188 local_irq_disable_hw(); \
189 } else { \ 192 } else { \
190 __clear_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \ 193 __clear_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
191 local_irq_enable_nohead(ipd); \
192 ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \ 194 ipd->irqs[irq].handler(irq, ipd->irqs[irq].cookie); \
193 /* Attempt to exit the outer interrupt level before \ 195 /* Attempt to exit the outer interrupt level before \
194 * starting the deferred IRQ processing. */ \ 196 * starting the deferred IRQ processing. */ \
195 local_irq_disable_nohead(ipd); \
196 __ipipe_run_irqtail(); \ 197 __ipipe_run_irqtail(); \
197 __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \ 198 __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
198 } \ 199 } \
200 local_irq_disable_hw(); \
199 } while (0) 201 } while (0)
200 202
201#define __ipipe_syscall_watched_p(p, sc) \ 203#define __ipipe_syscall_watched_p(p, sc) \
diff --git a/arch/blackfin/include/asm/irq.h b/arch/blackfin/include/asm/irq.h
index 7645e85a5f6..400bdd52ce8 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 00000000000..139cba4651b
--- /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/mutex-dec.h b/arch/blackfin/include/asm/mutex-dec.h
deleted file mode 100644
index 0134151656a..00000000000
--- a/arch/blackfin/include/asm/mutex-dec.h
+++ /dev/null
@@ -1,112 +0,0 @@
1/*
2 * include/asm-generic/mutex-dec.h
3 *
4 * Generic implementation of the mutex fastpath, based on atomic
5 * decrement/increment.
6 */
7#ifndef _ASM_GENERIC_MUTEX_DEC_H
8#define _ASM_GENERIC_MUTEX_DEC_H
9
10/**
11 * __mutex_fastpath_lock - try to take the lock by moving the count
12 * from 1 to a 0 value
13 * @count: pointer of type atomic_t
14 * @fail_fn: function to call if the original value was not 1
15 *
16 * Change the count from 1 to a value lower than 1, and call <fail_fn> if
17 * it wasn't 1 originally. This function MUST leave the value lower than
18 * 1 even when the "1" assertion wasn't true.
19 */
20static inline void
21__mutex_fastpath_lock(atomic_t *count, fastcall void (*fail_fn)(atomic_t *))
22{
23 if (unlikely(atomic_dec_return(count) < 0))
24 fail_fn(count);
25 else
26 smp_mb();
27}
28
29/**
30 * __mutex_fastpath_lock_retval - try to take the lock by moving the count
31 * from 1 to a 0 value
32 * @count: pointer of type atomic_t
33 * @fail_fn: function to call if the original value was not 1
34 *
35 * Change the count from 1 to a value lower than 1, and call <fail_fn> if
36 * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
37 * or anything the slow path function returns.
38 */
39static inline int
40__mutex_fastpath_lock_retval(atomic_t *count, fastcall int (*fail_fn)(atomic_t *))
41{
42 if (unlikely(atomic_dec_return(count) < 0))
43 return fail_fn(count);
44 else {
45 smp_mb();
46 return 0;
47 }
48}
49
50/**
51 * __mutex_fastpath_unlock - try to promote the count from 0 to 1
52 * @count: pointer of type atomic_t
53 * @fail_fn: function to call if the original value was not 0
54 *
55 * Try to promote the count from 0 to 1. If it wasn't 0, call <fail_fn>.
56 * In the failure case, this function is allowed to either set the value to
57 * 1, or to set it to a value lower than 1.
58 *
59 * If the implementation sets it to a value of lower than 1, then the
60 * __mutex_slowpath_needs_to_unlock() macro needs to return 1, it needs
61 * to return 0 otherwise.
62 */
63static inline void
64__mutex_fastpath_unlock(atomic_t *count, fastcall void (*fail_fn)(atomic_t *))
65{
66 smp_mb();
67 if (unlikely(atomic_inc_return(count) <= 0))
68 fail_fn(count);
69}
70
71#define __mutex_slowpath_needs_to_unlock() 1
72
73/**
74 * __mutex_fastpath_trylock - try to acquire the mutex, without waiting
75 *
76 * @count: pointer of type atomic_t
77 * @fail_fn: fallback function
78 *
79 * Change the count from 1 to a value lower than 1, and return 0 (failure)
80 * if it wasn't 1 originally, or return 1 (success) otherwise. This function
81 * MUST leave the value lower than 1 even when the "1" assertion wasn't true.
82 * Additionally, if the value was < 0 originally, this function must not leave
83 * it to 0 on failure.
84 *
85 * If the architecture has no effective trylock variant, it should call the
86 * <fail_fn> spinlock-based trylock variant unconditionally.
87 */
88static inline int
89__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
90{
91 /*
92 * We have two variants here. The cmpxchg based one is the best one
93 * because it never induce a false contention state. It is included
94 * here because architectures using the inc/dec algorithms over the
95 * xchg ones are much more likely to support cmpxchg natively.
96 *
97 * If not we fall back to the spinlock based variant - that is
98 * just as efficient (and simpler) as a 'destructive' probing of
99 * the mutex state would be.
100 */
101#ifdef __HAVE_ARCH_CMPXCHG
102 if (likely(atomic_cmpxchg(count, 1, 0) == 1)) {
103 smp_mb();
104 return 1;
105 }
106 return 0;
107#else
108 return fail_fn(count);
109#endif
110}
111
112#endif
diff --git a/arch/blackfin/include/asm/sections.h b/arch/blackfin/include/asm/sections.h
index 1443c3353a8..e7fd0ecd73f 100644
--- a/arch/blackfin/include/asm/sections.h
+++ b/arch/blackfin/include/asm/sections.h
@@ -4,4 +4,15 @@
4/* nothing to see, move along */ 4/* nothing to see, move along */
5#include <asm-generic/sections.h> 5#include <asm-generic/sections.h>
6 6
7/* only used when MTD_UCLINUX */
8extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size;
9
10extern unsigned long _ramstart, _ramend, _rambase;
11extern unsigned long memory_start, memory_end, physical_mem_end;
12
13extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
14 _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _sbss_b_l1[], _ebss_b_l1[],
15 _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[],
16 _ebss_l2[], _l2_lma_start[];
17
7#endif 18#endif
diff --git a/arch/blackfin/include/asm/system.h b/arch/blackfin/include/asm/system.h
index a4c8254bec5..294dbda2416 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/*
diff --git a/arch/blackfin/include/asm/unistd.h b/arch/blackfin/include/asm/unistd.h
index cf5066d3efd..da35133c171 100644
--- a/arch/blackfin/include/asm/unistd.h
+++ b/arch/blackfin/include/asm/unistd.h
@@ -380,8 +380,9 @@
380#define __NR_inotify_init1 365 380#define __NR_inotify_init1 365
381#define __NR_preadv 366 381#define __NR_preadv 366
382#define __NR_pwritev 367 382#define __NR_pwritev 367
383#define __NR_rt_tgsigqueueinfo 368
383 384
384#define __NR_syscall 368 385#define __NR_syscall 369
385#define NR_syscalls __NR_syscall 386#define NR_syscalls __NR_syscall
386 387
387/* Old optional stuff no one actually uses */ 388/* Old optional stuff no one actually uses */