18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef __ASM_CSKY_BARRIER_H
58c2ecf20Sopenharmony_ci#define __ASM_CSKY_BARRIER_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define nop()	asm volatile ("nop\n":::"memory")
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * sync:        completion barrier, all sync.xx instructions
138c2ecf20Sopenharmony_ci *              guarantee the last response recieved by bus transaction
148c2ecf20Sopenharmony_ci *              made by ld/st instructions before sync.s
158c2ecf20Sopenharmony_ci * sync.s:      inherit from sync, but also shareable to other cores
168c2ecf20Sopenharmony_ci * sync.i:      inherit from sync, but also flush cpu pipeline
178c2ecf20Sopenharmony_ci * sync.is:     the same with sync.i + sync.s
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * bar.brwarw:  ordering barrier for all load/store instructions before it
208c2ecf20Sopenharmony_ci * bar.brwarws: ordering barrier for all load/store instructions before it
218c2ecf20Sopenharmony_ci *						and shareable to other cores
228c2ecf20Sopenharmony_ci * bar.brar:    ordering barrier for all load       instructions before it
238c2ecf20Sopenharmony_ci * bar.brars:   ordering barrier for all load       instructions before it
248c2ecf20Sopenharmony_ci *						and shareable to other cores
258c2ecf20Sopenharmony_ci * bar.bwaw:    ordering barrier for all store      instructions before it
268c2ecf20Sopenharmony_ci * bar.bwaws:   ordering barrier for all store      instructions before it
278c2ecf20Sopenharmony_ci *						and shareable to other cores
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_CACHEV2
318c2ecf20Sopenharmony_ci#define mb()		asm volatile ("sync.s\n":::"memory")
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP
348c2ecf20Sopenharmony_ci#define __smp_mb()	asm volatile ("bar.brwarws\n":::"memory")
358c2ecf20Sopenharmony_ci#define __smp_rmb()	asm volatile ("bar.brars\n":::"memory")
368c2ecf20Sopenharmony_ci#define __smp_wmb()	asm volatile ("bar.bwaws\n":::"memory")
378c2ecf20Sopenharmony_ci#endif /* CONFIG_SMP */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define sync_is()	asm volatile ("sync.is\n":::"memory")
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#else /* !CONFIG_CPU_HAS_CACHEV2 */
428c2ecf20Sopenharmony_ci#define mb()		asm volatile ("sync\n":::"memory")
438c2ecf20Sopenharmony_ci#endif
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#include <asm-generic/barrier.h>
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
488c2ecf20Sopenharmony_ci#endif /* __ASM_CSKY_BARRIER_H */
49