Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Andre Przywara | e996bc6 | 2016-05-12 12:14:41 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 ARM Ltd. |
| 4 | * |
| 5 | * ARM and ARM64 barrier instructions |
| 6 | * split from armv7.h to allow sharing between ARM and ARM64 |
| 7 | * |
| 8 | * Original copyright in armv7.h was: |
| 9 | * (C) Copyright 2010 Texas Instruments, <www.ti.com> Aneesh V <aneesh@ti.com> |
| 10 | * |
| 11 | * Much of the original barrier code was contributed by: |
| 12 | * Valentine Barshak <valentine.barshak@cogentembedded.com> |
Andre Przywara | e996bc6 | 2016-05-12 12:14:41 +0100 | [diff] [blame] | 13 | */ |
| 14 | #ifndef __BARRIERS_H__ |
| 15 | #define __BARRIERS_H__ |
| 16 | |
| 17 | #ifndef __ASSEMBLY__ |
| 18 | |
| 19 | #ifndef CONFIG_ARM64 |
| 20 | /* |
| 21 | * CP15 Barrier instructions |
| 22 | * Please note that we have separate barrier instructions in ARMv7 |
| 23 | * However, we use the CP15 based instructtions because we use |
| 24 | * -march=armv5 in U-Boot |
| 25 | */ |
| 26 | #define CP15ISB asm volatile ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0)) |
| 27 | #define CP15DSB asm volatile ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0)) |
| 28 | #define CP15DMB asm volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0)) |
| 29 | |
| 30 | #endif /* !CONFIG_ARM64 */ |
| 31 | |
Tom Rini | 3b787ef | 2016-08-01 18:54:53 -0400 | [diff] [blame] | 32 | #if __LINUX_ARM_ARCH__ >= 7 |
Andre Przywara | e996bc6 | 2016-05-12 12:14:41 +0100 | [diff] [blame] | 33 | #define ISB asm volatile ("isb sy" : : : "memory") |
| 34 | #define DSB asm volatile ("dsb sy" : : : "memory") |
| 35 | #define DMB asm volatile ("dmb sy" : : : "memory") |
Tom Rini | 3b787ef | 2016-08-01 18:54:53 -0400 | [diff] [blame] | 36 | #elif __LINUX_ARM_ARCH__ == 6 |
Andre Przywara | e996bc6 | 2016-05-12 12:14:41 +0100 | [diff] [blame] | 37 | #define ISB CP15ISB |
| 38 | #define DSB CP15DSB |
| 39 | #define DMB CP15DMB |
Tom Rini | 3b787ef | 2016-08-01 18:54:53 -0400 | [diff] [blame] | 40 | #else |
| 41 | #define ISB asm volatile ("" : : : "memory") |
| 42 | #define DSB CP15DSB |
| 43 | #define DMB asm volatile ("" : : : "memory") |
Andre Przywara | e996bc6 | 2016-05-12 12:14:41 +0100 | [diff] [blame] | 44 | #endif |
| 45 | |
Tom Rini | 3b787ef | 2016-08-01 18:54:53 -0400 | [diff] [blame] | 46 | #define isb() ISB |
| 47 | #define dsb() DSB |
| 48 | #define dmb() DMB |
Andre Przywara | e996bc6 | 2016-05-12 12:14:41 +0100 | [diff] [blame] | 49 | #endif /* __ASSEMBLY__ */ |
| 50 | #endif /* __BARRIERS_H__ */ |