diff options
author | Bryan Wu <bryan.wu@analog.com> | 2007-05-06 17:50:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:58 -0400 |
commit | 1394f03221790a988afc3e4b3cb79f2e477246a9 (patch) | |
tree | 2c1963c9a4f2d84a5e021307fde240c5d567cf70 /include/asm-blackfin/semaphore.h | |
parent | 73243284463a761e04d69d22c7516b2be7de096c (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/semaphore.h')
-rw-r--r-- | include/asm-blackfin/semaphore.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/include/asm-blackfin/semaphore.h b/include/asm-blackfin/semaphore.h new file mode 100644 index 000000000000..94c04d7ab23e --- /dev/null +++ b/include/asm-blackfin/semaphore.h | |||
@@ -0,0 +1,106 @@ | |||
1 | #ifndef _BFIN_SEMAPHORE_H | ||
2 | #define _BFIN_SEMAPHORE_H | ||
3 | |||
4 | #ifndef __ASSEMBLY__ | ||
5 | |||
6 | #include <linux/linkage.h> | ||
7 | #include <linux/wait.h> | ||
8 | #include <linux/spinlock.h> | ||
9 | #include <linux/rwsem.h> | ||
10 | #include <asm/atomic.h> | ||
11 | |||
12 | /* | ||
13 | * Interrupt-safe semaphores.. | ||
14 | * | ||
15 | * (C) Copyright 1996 Linus Torvalds | ||
16 | * | ||
17 | * BFIN version by akbar hussain Lineo Inc April 2001 | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | struct semaphore { | ||
22 | atomic_t count; | ||
23 | int sleepers; | ||
24 | wait_queue_head_t wait; | ||
25 | }; | ||
26 | |||
27 | #define __SEMAPHORE_INITIALIZER(name, n) \ | ||
28 | { \ | ||
29 | .count = ATOMIC_INIT(n), \ | ||
30 | .sleepers = 0, \ | ||
31 | .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ | ||
32 | } | ||
33 | |||
34 | #define __DECLARE_SEMAPHORE_GENERIC(name,count) \ | ||
35 | struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) | ||
36 | |||
37 | #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) | ||
38 | #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) | ||
39 | |||
40 | static inline void sema_init(struct semaphore *sem, int val) | ||
41 | { | ||
42 | *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val); | ||
43 | } | ||
44 | |||
45 | static inline void init_MUTEX(struct semaphore *sem) | ||
46 | { | ||
47 | sema_init(sem, 1); | ||
48 | } | ||
49 | |||
50 | static inline void init_MUTEX_LOCKED(struct semaphore *sem) | ||
51 | { | ||
52 | sema_init(sem, 0); | ||
53 | } | ||
54 | |||
55 | asmlinkage void __down(struct semaphore *sem); | ||
56 | asmlinkage int __down_interruptible(struct semaphore *sem); | ||
57 | asmlinkage int __down_trylock(struct semaphore *sem); | ||
58 | asmlinkage void __up(struct semaphore *sem); | ||
59 | |||
60 | extern spinlock_t semaphore_wake_lock; | ||
61 | |||
62 | /* | ||
63 | * This is ugly, but we want the default case to fall through. | ||
64 | * "down_failed" is a special asm handler that calls the C | ||
65 | * routine that actually waits. | ||
66 | */ | ||
67 | static inline void down(struct semaphore *sem) | ||
68 | { | ||
69 | might_sleep(); | ||
70 | if (atomic_dec_return(&sem->count) < 0) | ||
71 | __down(sem); | ||
72 | } | ||
73 | |||
74 | static inline int down_interruptible(struct semaphore *sem) | ||
75 | { | ||
76 | int ret = 0; | ||
77 | |||
78 | might_sleep(); | ||
79 | if (atomic_dec_return(&sem->count) < 0) | ||
80 | ret = __down_interruptible(sem); | ||
81 | return (ret); | ||
82 | } | ||
83 | |||
84 | static inline int down_trylock(struct semaphore *sem) | ||
85 | { | ||
86 | int ret = 0; | ||
87 | |||
88 | if (atomic_dec_return(&sem->count) < 0) | ||
89 | ret = __down_trylock(sem); | ||
90 | return ret; | ||
91 | } | ||
92 | |||
93 | /* | ||
94 | * Note! This is subtle. We jump to wake people up only if | ||
95 | * the semaphore was negative (== somebody was waiting on it). | ||
96 | * The default case (no contention) will result in NO | ||
97 | * jumps for both down() and up(). | ||
98 | */ | ||
99 | static inline void up(struct semaphore *sem) | ||
100 | { | ||
101 | if (atomic_inc_return(&sem->count) <= 0) | ||
102 | __up(sem); | ||
103 | } | ||
104 | |||
105 | #endif /* __ASSEMBLY__ */ | ||
106 | #endif /* _BFIN_SEMAPHORE_H */ | ||