xref: /linux/arch/csky/include/asm/barrier.h (revision 00a9730e1007c6cc87a7c78af2f24a4105d616ee)
1*00a9730eSGuo Ren /* SPDX-License-Identifier: GPL-2.0 */
2*00a9730eSGuo Ren // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3*00a9730eSGuo Ren 
4*00a9730eSGuo Ren #ifndef __ASM_CSKY_BARRIER_H
5*00a9730eSGuo Ren #define __ASM_CSKY_BARRIER_H
6*00a9730eSGuo Ren 
7*00a9730eSGuo Ren #ifndef __ASSEMBLY__
8*00a9730eSGuo Ren 
9*00a9730eSGuo Ren #define nop()	asm volatile ("nop\n":::"memory")
10*00a9730eSGuo Ren 
11*00a9730eSGuo Ren /*
12*00a9730eSGuo Ren  * sync:        completion barrier
13*00a9730eSGuo Ren  * sync.s:      completion barrier and shareable to other cores
14*00a9730eSGuo Ren  * sync.i:      completion barrier with flush cpu pipeline
15*00a9730eSGuo Ren  * sync.is:     completion barrier with flush cpu pipeline and shareable to
16*00a9730eSGuo Ren  *		other cores
17*00a9730eSGuo Ren  *
18*00a9730eSGuo Ren  * bar.brwarw:  ordering barrier for all load/store instructions before it
19*00a9730eSGuo Ren  * bar.brwarws: ordering barrier for all load/store instructions before it
20*00a9730eSGuo Ren  *						and shareable to other cores
21*00a9730eSGuo Ren  * bar.brar:    ordering barrier for all load       instructions before it
22*00a9730eSGuo Ren  * bar.brars:   ordering barrier for all load       instructions before it
23*00a9730eSGuo Ren  *						and shareable to other cores
24*00a9730eSGuo Ren  * bar.bwaw:    ordering barrier for all store      instructions before it
25*00a9730eSGuo Ren  * bar.bwaws:   ordering barrier for all store      instructions before it
26*00a9730eSGuo Ren  *						and shareable to other cores
27*00a9730eSGuo Ren  */
28*00a9730eSGuo Ren 
29*00a9730eSGuo Ren #ifdef CONFIG_CPU_HAS_CACHEV2
30*00a9730eSGuo Ren #define mb()		asm volatile ("bar.brwarw\n":::"memory")
31*00a9730eSGuo Ren #define rmb()		asm volatile ("bar.brar\n":::"memory")
32*00a9730eSGuo Ren #define wmb()		asm volatile ("bar.bwaw\n":::"memory")
33*00a9730eSGuo Ren 
34*00a9730eSGuo Ren #ifdef CONFIG_SMP
35*00a9730eSGuo Ren #define __smp_mb()	asm volatile ("bar.brwarws\n":::"memory")
36*00a9730eSGuo Ren #define __smp_rmb()	asm volatile ("bar.brars\n":::"memory")
37*00a9730eSGuo Ren #define __smp_wmb()	asm volatile ("bar.bwaws\n":::"memory")
38*00a9730eSGuo Ren #endif /* CONFIG_SMP */
39*00a9730eSGuo Ren 
40*00a9730eSGuo Ren #define sync_is()	asm volatile ("sync.is\n":::"memory")
41*00a9730eSGuo Ren 
42*00a9730eSGuo Ren #else /* !CONFIG_CPU_HAS_CACHEV2 */
43*00a9730eSGuo Ren #define mb()		asm volatile ("sync\n":::"memory")
44*00a9730eSGuo Ren #endif
45*00a9730eSGuo Ren 
46*00a9730eSGuo Ren #include <asm-generic/barrier.h>
47*00a9730eSGuo Ren 
48*00a9730eSGuo Ren #endif /* __ASSEMBLY__ */
49*00a9730eSGuo Ren #endif /* __ASM_CSKY_BARRIER_H */
50