barriers.h 1.4 KB

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