aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-blackfin/bitops.h
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@analog.com>2007-05-06 17:50:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:58 -0400
commit1394f03221790a988afc3e4b3cb79f2e477246a9 (patch)
tree2c1963c9a4f2d84a5e021307fde240c5d567cf70 /include/asm-blackfin/bitops.h
parent73243284463a761e04d69d22c7516b2be7de096c (diff)
blackfin architecture
This adds support for the Analog Devices Blackfin processor architecture, and currently supports the BF533, BF532, BF531, BF537, BF536, BF534, and BF561 (Dual Core) devices, with a variety of development platforms including those avaliable from Analog Devices (BF533-EZKit, BF533-STAMP, BF537-STAMP, BF561-EZKIT), and Bluetechnix! Tinyboards. The Blackfin architecture was jointly developed by Intel and Analog Devices Inc. (ADI) as the Micro Signal Architecture (MSA) core and introduced it in December of 2000. Since then ADI has put this core into its Blackfin processor family of devices. The Blackfin core has the advantages of a clean, orthogonal,RISC-like microprocessor instruction set. It combines a dual-MAC (Multiply/Accumulate), state-of-the-art signal processing engine and single-instruction, multiple-data (SIMD) multimedia capabilities into a single instruction-set architecture. The Blackfin architecture, including the instruction set, is described by the ADSP-BF53x/BF56x Blackfin Processor Programming Reference http://blackfin.uclinux.org/gf/download/frsrelease/29/2549/Blackfin_PRM.pdf The Blackfin processor is already supported by major releases of gcc, and there are binary and source rpms/tarballs for many architectures at: http://blackfin.uclinux.org/gf/project/toolchain/frs There is complete documentation, including "getting started" guides available at: http://docs.blackfin.uclinux.org/ which provides links to the sources and patches you will need in order to set up a cross-compiling environment for bfin-linux-uclibc This patch, as well as the other patches (toolchain, distribution, uClibc) are actively supported by Analog Devices Inc, at: http://blackfin.uclinux.org/ We have tested this on LTP, and our test plan (including pass/fails) can be found at: http://docs.blackfin.uclinux.org/doku.php?id=testing_the_linux_kernel [m.kozlowski@tuxland.pl: balance parenthesis in blackfin header files] Signed-off-by: Bryan Wu <bryan.wu@analog.com> Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl> Signed-off-by: Aubrey Li <aubrey.li@analog.com> Signed-off-by: Jie Zhang <jie.zhang@analog.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-blackfin/bitops.h')
-rw-r--r--include/asm-blackfin/bitops.h213
1 files changed, 213 insertions, 0 deletions
diff --git a/include/asm-blackfin/bitops.h b/include/asm-blackfin/bitops.h
new file mode 100644
index 000000000000..27c2d0e48e1b
--- /dev/null
+++ b/include/asm-blackfin/bitops.h
@@ -0,0 +1,213 @@
1#ifndef _BLACKFIN_BITOPS_H
2#define _BLACKFIN_BITOPS_H
3
4/*
5 * Copyright 1992, Linus Torvalds.
6 */
7
8#include <linux/compiler.h>
9#include <asm/byteorder.h> /* swab32 */
10#include <asm/system.h> /* save_flags */
11
12#ifdef __KERNEL__
13
14#include <asm-generic/bitops/ffs.h>
15#include <asm-generic/bitops/__ffs.h>
16#include <asm-generic/bitops/sched.h>
17#include <asm-generic/bitops/ffz.h>
18
19static __inline__ void set_bit(int nr, volatile unsigned long *addr)
20{
21 int *a = (int *)addr;
22 int mask;
23 unsigned long flags;
24
25 a += nr >> 5;
26 mask = 1 << (nr & 0x1f);
27 local_irq_save(flags);
28 *a |= mask;
29 local_irq_restore(flags);
30}
31
32static __inline__ void __set_bit(int nr, volatile unsigned long *addr)
33{
34 int *a = (int *)addr;
35 int mask;
36
37 a += nr >> 5;
38 mask = 1 << (nr & 0x1f);
39 *a |= mask;
40}
41
42/*
43 * clear_bit() doesn't provide any barrier for the compiler.
44 */
45#define smp_mb__before_clear_bit() barrier()
46#define smp_mb__after_clear_bit() barrier()
47
48static __inline__ void clear_bit(int nr, volatile unsigned long *addr)
49{
50 int *a = (int *)addr;
51 int mask;
52 unsigned long flags;
53 a += nr >> 5;
54 mask = 1 << (nr & 0x1f);
55 local_irq_save(flags);
56 *a &= ~mask;
57 local_irq_restore(flags);
58}
59
60static __inline__ void __clear_bit(int nr, volatile unsigned long *addr)
61{
62 int *a = (int *)addr;
63 int mask;
64
65 a += nr >> 5;
66 mask = 1 << (nr & 0x1f);
67 *a &= ~mask;
68}
69
70static __inline__ void change_bit(int nr, volatile unsigned long *addr)
71{
72 int mask, flags;
73 unsigned long *ADDR = (unsigned long *)addr;
74
75 ADDR += nr >> 5;
76 mask = 1 << (nr & 31);
77 local_irq_save(flags);
78 *ADDR ^= mask;
79 local_irq_restore(flags);
80}
81
82static __inline__ void __change_bit(int nr, volatile unsigned long *addr)
83{
84 int mask;
85 unsigned long *ADDR = (unsigned long *)addr;
86
87 ADDR += nr >> 5;
88 mask = 1 << (nr & 31);
89 *ADDR ^= mask;
90}
91
92static __inline__ int test_and_set_bit(int nr, void *addr)
93{
94 int mask, retval;
95 volatile unsigned int *a = (volatile unsigned int *)addr;
96 unsigned long flags;
97
98 a += nr >> 5;
99 mask = 1 << (nr & 0x1f);
100 local_irq_save(flags);
101 retval = (mask & *a) != 0;
102 *a |= mask;
103 local_irq_restore(flags);
104
105 return retval;
106}
107
108static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr)
109{
110 int mask, retval;
111 volatile unsigned int *a = (volatile unsigned int *)addr;
112
113 a += nr >> 5;
114 mask = 1 << (nr & 0x1f);
115 retval = (mask & *a) != 0;
116 *a |= mask;
117 return retval;
118}
119
120static __inline__ int test_and_clear_bit(int nr, volatile unsigned long *addr)
121{
122 int mask, retval;
123 volatile unsigned int *a = (volatile unsigned int *)addr;
124 unsigned long flags;
125
126 a += nr >> 5;
127 mask = 1 << (nr & 0x1f);
128 local_irq_save(flags);
129 retval = (mask & *a) != 0;
130 *a &= ~mask;
131 local_irq_restore(flags);
132
133 return retval;
134}
135
136static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr)
137{
138 int mask, retval;
139 volatile unsigned int *a = (volatile unsigned int *)addr;
140
141 a += nr >> 5;
142 mask = 1 << (nr & 0x1f);
143 retval = (mask & *a) != 0;
144 *a &= ~mask;
145 return retval;
146}
147
148static __inline__ int test_and_change_bit(int nr, volatile unsigned long *addr)
149{
150 int mask, retval;
151 volatile unsigned int *a = (volatile unsigned int *)addr;
152 unsigned long flags;
153
154 a += nr >> 5;
155 mask = 1 << (nr & 0x1f);
156 local_irq_save(flags);
157 retval = (mask & *a) != 0;
158 *a ^= mask;
159 local_irq_restore(flags);
160 return retval;
161}
162
163static __inline__ int __test_and_change_bit(int nr,
164 volatile unsigned long *addr)
165{
166 int mask, retval;
167 volatile unsigned int *a = (volatile unsigned int *)addr;
168
169 a += nr >> 5;
170 mask = 1 << (nr & 0x1f);
171 retval = (mask & *a) != 0;
172 *a ^= mask;
173 return retval;
174}
175
176/*
177 * This routine doesn't need to be atomic.
178 */
179static __inline__ int __constant_test_bit(int nr, const void *addr)
180{
181 return ((1UL << (nr & 31)) &
182 (((const volatile unsigned int *)addr)[nr >> 5])) != 0;
183}
184
185static __inline__ int __test_bit(int nr, const void *addr)
186{
187 int *a = (int *)addr;
188 int mask;
189
190 a += nr >> 5;
191 mask = 1 << (nr & 0x1f);
192 return ((mask & *a) != 0);
193}
194
195#define test_bit(nr,addr) \
196(__builtin_constant_p(nr) ? \
197 __constant_test_bit((nr),(addr)) : \
198 __test_bit((nr),(addr)))
199
200#include <asm-generic/bitops/find.h>
201#include <asm-generic/bitops/hweight.h>
202
203#include <asm-generic/bitops/ext2-atomic.h>
204#include <asm-generic/bitops/ext2-non-atomic.h>
205
206#include <asm-generic/bitops/minix.h>
207
208#endif /* __KERNEL__ */
209
210#include <asm-generic/bitops/fls.h>
211#include <asm-generic/bitops/fls64.h>
212
213#endif /* _BLACKFIN_BITOPS_H */