]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/asm-blackfin/system.h
Replace "#include <asm-$ARCH/$FILE>" with "#include <asm/$FILE>"
[karo-tx-uboot.git] / include / asm-blackfin / system.h
1 /*
2  * U-boot - system.h
3  *
4  * Copyright (c) 2005-2007 Analog Devices Inc.
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22  * MA 02110-1301 USA
23  */
24
25 #ifndef _BLACKFIN_SYSTEM_H
26 #define _BLACKFIN_SYSTEM_H
27
28 /*
29  * Interrupt configuring macros.
30  */
31
32 extern int irq_flags;
33
34 #define local_irq_enable() \
35         __asm__ __volatile__ ( \
36                 "sti %0;" \
37                 : \
38                 : "d" (irq_flags) \
39         )
40
41 #define local_irq_disable() \
42         do { \
43                 int __tmp_dummy; \
44                 __asm__ __volatile__ ( \
45                         "cli %0;" \
46                         : "=d" (__tmp_dummy) \
47                 ); \
48         } while (0)
49
50 # define local_irq_save(x) \
51         __asm__ __volatile__ ( \
52                 "cli %0;" \
53                 : "=&d" (x) \
54         )
55
56 #define local_save_flags(x) \
57         __asm__ __volatile__ ( \
58                 "cli %0;" \
59                 "sti %0;" \
60                 : "=d" (x) \
61         )
62
63 #define irqs_enabled_from_flags(x) ((x) != 0x1f)
64
65 #define local_irq_restore(x) \
66         do { \
67                 if (irqs_enabled_from_flags(x)) \
68                         local_irq_enable(); \
69         } while (0)
70
71 /*
72  * Force strict CPU ordering.
73  */
74 #define nop()                   asm volatile ("nop;\n\t"::)
75 #define mb()                    asm volatile (""   : : :"memory")
76 #define rmb()                   asm volatile (""   : : :"memory")
77 #define wmb()                   asm volatile (""   : : :"memory")
78 #define set_rmb(var, value)     do { xchg(&var, value); } while (0)
79 #define set_mb(var, value)      set_rmb(var, value)
80 #define set_wmb(var, value)     do { var = value; wmb(); } while (0)
81
82 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
83
84 struct __xchg_dummy {
85         unsigned long a[100];
86 };
87 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
88
89 static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
90                                    int size)
91 {
92         unsigned long tmp = 0;
93         unsigned long flags = 0;
94
95         local_irq_save(flags);
96
97         switch (size) {
98         case 1:
99                 __asm__ __volatile__
100                         ("%0 = b%2 (z);\n\t"
101                          "b%2 = %1;\n\t"
102                          : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
103                 break;
104         case 2:
105                 __asm__ __volatile__
106                         ("%0 = w%2 (z);\n\t"
107                          "w%2 = %1;\n\t"
108                          : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
109                 break;
110         case 4:
111                 __asm__ __volatile__
112                         ("%0 = %2;\n\t"
113                          "%2 = %1;\n\t"
114                          : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
115                 break;
116         }
117         local_irq_restore(flags);
118         return tmp;
119 }
120
121 #endif  /* _BLACKFIN_SYSTEM_H */