1 // SPDX-License-Identifier: GPL-2.0+
8 #include <linux/types.h>
11 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
12 void invalidate_dcache_all(void)
14 /* Flush/Invalidate I cache */
15 asm volatile("mcr p15, 0, %0, c7, c5, 0\n" : : "r"(0));
16 /* Flush/Invalidate D cache */
17 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
20 void flush_dcache_all(void)
22 return invalidate_dcache_all();
25 void invalidate_dcache_range(unsigned long start, unsigned long stop)
27 start &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
28 stop &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
30 while (start <= stop) {
31 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
32 start += CONFIG_SYS_CACHELINE_SIZE;
36 void flush_dcache_range(unsigned long start, unsigned long stop)
38 return invalidate_dcache_range(start, stop);
40 #else /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
41 void invalidate_dcache_all(void)
45 void flush_dcache_all(void)
48 #endif /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
51 * Stub implementations for l2 cache operations
54 __weak void l2_cache_disable(void) {}
56 #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
57 __weak void invalidate_l2_cache(void) {}