1 // SPDX-License-Identifier: GPL-2.0+
4 * Ilya Yanok, EmCraft Systems
6 #include <linux/types.h>
9 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
10 void invalidate_dcache_all(void)
12 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
15 void flush_dcache_all(void)
19 "mrc p15, 0, r15, c7, c14, 3\n"
21 "mcr p15, 0, %0, c7, c10, 4\n"
26 void invalidate_dcache_range(unsigned long start, unsigned long stop)
28 if (!check_cache_range(start, stop))
31 while (start < stop) {
32 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
33 start += CONFIG_SYS_CACHELINE_SIZE;
37 void flush_dcache_range(unsigned long start, unsigned long stop)
39 if (!check_cache_range(start, stop))
42 while (start < stop) {
43 asm volatile("mcr p15, 0, %0, c7, c14, 1\n" : : "r"(start));
44 start += CONFIG_SYS_CACHELINE_SIZE;
47 asm volatile("mcr p15, 0, %0, c7, c10, 4\n" : : "r"(0));
49 #else /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
50 void invalidate_dcache_all(void)
54 void flush_dcache_all(void)
57 #endif /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
60 * Stub implementations for l2 cache operations
63 __weak void l2_cache_disable(void) {}
65 #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
66 __weak void invalidate_l2_cache(void) {}
69 #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
70 /* Invalidate entire I-cache and branch predictor array */
71 void invalidate_icache_all(void)
75 asm ("mcr p15, 0, %0, c7, c5, 0" : : "r" (i));
78 void invalidate_icache_all(void) {}
81 void enable_caches(void)
83 #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
86 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)