David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 1 | #ifndef __ASM_BARRIER_H |
| 2 | #define __ASM_BARRIER_H |
| 3 | |
| 4 | #ifndef __ASSEMBLY__ |
R Sricharan | b7782d3 | 2012-03-30 14:27:43 +0530 | [diff] [blame] | 5 | #include <asm/outercache.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 6 | |
| 7 | #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t"); |
| 8 | |
| 9 | #if __LINUX_ARM_ARCH__ >= 7 || \ |
| 10 | (__LINUX_ARM_ARCH__ == 6 && defined(CONFIG_CPU_32v6K)) |
| 11 | #define sev() __asm__ __volatile__ ("sev" : : : "memory") |
| 12 | #define wfe() __asm__ __volatile__ ("wfe" : : : "memory") |
| 13 | #define wfi() __asm__ __volatile__ ("wfi" : : : "memory") |
| 14 | #endif |
| 15 | |
| 16 | #if __LINUX_ARM_ARCH__ >= 7 |
| 17 | #define isb() __asm__ __volatile__ ("isb" : : : "memory") |
| 18 | #define dsb() __asm__ __volatile__ ("dsb" : : : "memory") |
| 19 | #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") |
| 20 | #elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6 |
| 21 | #define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \ |
| 22 | : : "r" (0) : "memory") |
| 23 | #define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \ |
| 24 | : : "r" (0) : "memory") |
| 25 | #define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \ |
| 26 | : : "r" (0) : "memory") |
| 27 | #elif defined(CONFIG_CPU_FA526) |
| 28 | #define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \ |
| 29 | : : "r" (0) : "memory") |
| 30 | #define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \ |
| 31 | : : "r" (0) : "memory") |
| 32 | #define dmb() __asm__ __volatile__ ("" : : : "memory") |
| 33 | #else |
| 34 | #define isb() __asm__ __volatile__ ("" : : : "memory") |
| 35 | #define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \ |
| 36 | : : "r" (0) : "memory") |
| 37 | #define dmb() __asm__ __volatile__ ("" : : : "memory") |
| 38 | #endif |
| 39 | |
| 40 | #ifdef CONFIG_ARCH_HAS_BARRIERS |
| 41 | #include <mach/barriers.h> |
| 42 | #elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP) |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 43 | #define mb() do { dsb(); outer_sync(); } while (0) |
| 44 | #define rmb() dsb() |
| 45 | #define wmb() mb() |
| 46 | #else |
| 47 | #include <asm/memory.h> |
| 48 | #define mb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0) |
| 49 | #define rmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0) |
| 50 | #define wmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0) |
| 51 | #endif |
| 52 | |
| 53 | #ifndef CONFIG_SMP |
| 54 | #define smp_mb() barrier() |
| 55 | #define smp_rmb() barrier() |
| 56 | #define smp_wmb() barrier() |
| 57 | #else |
| 58 | #define smp_mb() dmb() |
| 59 | #define smp_rmb() dmb() |
| 60 | #define smp_wmb() dmb() |
| 61 | #endif |
| 62 | |
| 63 | #define read_barrier_depends() do { } while(0) |
| 64 | #define smp_read_barrier_depends() do { } while(0) |
| 65 | |
| 66 | #define set_mb(var, value) do { var = value; smp_mb(); } while (0) |
| 67 | |
| 68 | #endif /* !__ASSEMBLY__ */ |
| 69 | #endif /* __ASM_BARRIER_H */ |