3 * Ilya Yanok, EmCraft Systems
5 * SPDX-License-Identifier: GPL-2.0+
7 #include <linux/types.h>
10 #ifndef CONFIG_SYS_DCACHE_OFF
12 #ifndef CONFIG_SYS_CACHELINE_SIZE
13 #define CONFIG_SYS_CACHELINE_SIZE 32
16 void invalidate_dcache_all(void)
18 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
21 void flush_dcache_all(void)
25 "mrc p15, 0, r15, c7, c14, 3\n"
27 "mcr p15, 0, %0, c7, c10, 4\n"
32 void invalidate_dcache_range(unsigned long start, unsigned long stop)
34 if (!check_cache_range(start, stop))
37 while (start < stop) {
38 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
39 start += CONFIG_SYS_CACHELINE_SIZE;
43 void flush_dcache_range(unsigned long start, unsigned long stop)
45 if (!check_cache_range(start, stop))
48 while (start < stop) {
49 asm volatile("mcr p15, 0, %0, c7, c14, 1\n" : : "r"(start));
50 start += CONFIG_SYS_CACHELINE_SIZE;
53 asm volatile("mcr p15, 0, %0, c7, c10, 4\n" : : "r"(0));
55 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
56 void invalidate_dcache_all(void)
60 void flush_dcache_all(void)
63 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
66 * Stub implementations for l2 cache operations
69 __weak void l2_cache_disable(void) {}
71 #if defined CONFIG_SYS_THUMB_BUILD
72 __weak void invalidate_l2_cache(void) {}