1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2016 Vasily Khoruzhick <anarsoul@gmail.com>
6 #include <linux/types.h>
9 #ifndef CONFIG_SYS_DCACHE_OFF
10 void invalidate_dcache_all(void)
12 /* Flush/Invalidate I cache */
13 asm volatile("mcr p15, 0, %0, c7, c5, 0\n" : : "r"(0));
14 /* Flush/Invalidate D cache */
15 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
18 void flush_dcache_all(void)
20 return invalidate_dcache_all();
23 void invalidate_dcache_range(unsigned long start, unsigned long stop)
25 start &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
26 stop &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
28 while (start <= stop) {
29 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
30 start += CONFIG_SYS_CACHELINE_SIZE;
34 void flush_dcache_range(unsigned long start, unsigned long stop)
36 return invalidate_dcache_range(start, stop);
38 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
39 void invalidate_dcache_all(void)
43 void flush_dcache_all(void)
46 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
49 * Stub implementations for l2 cache operations
52 __weak void l2_cache_disable(void) {}
54 #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
55 __weak void invalidate_l2_cache(void) {}