1b2dd5a3fe7a258c03283e423a898e64da17649c
[cascardo/linux.git] / include / asm-blackfin / blackfin.h
1 /*
2  * Common header file for blackfin family of processors.
3  *
4  */
5
6 #ifndef _BLACKFIN_H_
7 #define _BLACKFIN_H_
8
9 #define LO(con32) ((con32) & 0xFFFF)
10 #define lo(con32) ((con32) & 0xFFFF)
11 #define HI(con32) (((con32) >> 16) & 0xFFFF)
12 #define hi(con32) (((con32) >> 16) & 0xFFFF)
13
14 #include <asm/mach/blackfin.h>
15 #include <asm/bfin-global.h>
16
17 #ifndef __ASSEMBLY__
18
19 /* SSYNC implementation for C file */
20 static inline void SSYNC(void)
21 {
22         int _tmp;
23         if (ANOMALY_05000312 && ANOMALY_05000244)
24                 __asm__ __volatile__(
25                         "cli %0;"
26                         "nop;"
27                         "nop;"
28                         "ssync;"
29                         "sti %0;"
30                         : "=d" (_tmp)
31                 );
32         else if (ANOMALY_05000312 && !ANOMALY_05000244)
33                 __asm__ __volatile__(
34                         "cli %0;"
35                         "ssync;"
36                         "sti %0;"
37                         : "=d" (_tmp)
38                 );
39         else if (!ANOMALY_05000312 && ANOMALY_05000244)
40                 __asm__ __volatile__(
41                         "nop;"
42                         "nop;"
43                         "nop;"
44                         "ssync;"
45                 );
46         else
47                 __asm__ __volatile__("ssync;");
48 }
49
50 /* CSYNC implementation for C file */
51 static inline void CSYNC(void)
52 {
53         int _tmp;
54         if (ANOMALY_05000312 && ANOMALY_05000244)
55                 __asm__ __volatile__(
56                         "cli %0;"
57                         "nop;"
58                         "nop;"
59                         "csync;"
60                         "sti %0;"
61                         : "=d" (_tmp)
62                 );
63         else if (ANOMALY_05000312 && !ANOMALY_05000244)
64                 __asm__ __volatile__(
65                         "cli %0;"
66                         "csync;"
67                         "sti %0;"
68                         : "=d" (_tmp)
69                 );
70         else if (!ANOMALY_05000312 && ANOMALY_05000244)
71                 __asm__ __volatile__(
72                         "nop;"
73                         "nop;"
74                         "nop;"
75                         "ssync;"
76                 );
77         else
78                 __asm__ __volatile__("csync;");
79 }
80
81 #else  /* __ASSEMBLY__ */
82
83 /* SSYNC & CSYNC implementations for assembly files */
84
85 #define ssync(x) SSYNC(x)
86 #define csync(x) CSYNC(x)
87
88 #if ANOMALY_05000312 && ANOMALY_05000244
89 #define SSYNC(scratch) cli scratch; nop; nop; SSYNC; sti scratch;
90 #define CSYNC(scratch) cli scratch; nop; nop; CSYNC; sti scratch;
91
92 #elif ANOMALY_05000312 && !ANOMALY_05000244
93 #define SSYNC(scratch) cli scratch; nop; nop; SSYNC; sti scratch;
94 #define CSYNC(scratch) cli scratch; nop; nop; CSYNC; sti scratch;
95
96 #elif !ANOMALY_05000312 && ANOMALY_05000244
97 #define SSYNC(scratch) nop; nop; nop; SSYNC;
98 #define CSYNC(scratch) nop; nop; nop; CSYNC;
99
100 #elif !ANOMALY_05000312 && !ANOMALY_05000244
101 #define SSYNC(scratch) SSYNC;
102 #define CSYNC(scratch) CSYNC;
103
104 #endif /* ANOMALY_05000312 & ANOMALY_05000244 handling */
105
106 #endif /* __ASSEMBLY__ */
107
108 #endif                          /* _BLACKFIN_H_ */