3 * Ilya Yanok, EmCraft Systems
5 * SPDX-License-Identifier: GPL-2.0+
7 #include <linux/types.h>
10 #ifndef CONFIG_SYS_DCACHE_OFF
11 void invalidate_dcache_all(void)
13 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
16 void flush_dcache_all(void)
20 "mrc p15, 0, r15, c7, c14, 3\n"
22 "mcr p15, 0, %0, c7, c10, 4\n"
27 void invalidate_dcache_range(unsigned long start, unsigned long stop)
29 if (!check_cache_range(start, stop))
32 while (start < stop) {
33 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
34 start += CONFIG_SYS_CACHELINE_SIZE;
38 void flush_dcache_range(unsigned long start, unsigned long stop)
40 if (!check_cache_range(start, stop))
43 while (start < stop) {
44 asm volatile("mcr p15, 0, %0, c7, c14, 1\n" : : "r"(start));
45 start += CONFIG_SYS_CACHELINE_SIZE;
48 asm volatile("mcr p15, 0, %0, c7, c10, 4\n" : : "r"(0));
50 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
51 void invalidate_dcache_all(void)
55 void flush_dcache_all(void)
58 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
61 * Stub implementations for l2 cache operations
64 __weak void l2_cache_disable(void) {}
66 #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
67 __weak void invalidate_l2_cache(void) {}