2 * (C) Copyright 2016 Vasily Khoruzhick <anarsoul@gmail.com>
4 * 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 /* Flush/Invalidate I cache */
19 asm volatile("mcr p15, 0, %0, c7, c5, 0\n" : : "r"(0));
20 /* Flush/Invalidate D cache */
21 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
24 void flush_dcache_all(void)
26 return invalidate_dcache_all();
29 void invalidate_dcache_range(unsigned long start, unsigned long stop)
31 start &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
32 stop &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
34 while (start <= stop) {
35 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
36 start += CONFIG_SYS_CACHELINE_SIZE;
40 void flush_dcache_range(unsigned long start, unsigned long stop)
42 return invalidate_dcache_range(start, stop);
44 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
45 void invalidate_dcache_all(void)
49 void flush_dcache_all(void)
52 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
55 * Stub implementations for l2 cache operations
58 __weak void l2_cache_disable(void) {}
60 #if defined CONFIG_SYS_THUMB_BUILD
61 __weak void invalidate_l2_cache(void) {}