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
11 void invalidate_dcache_all(void)
13 /* Flush/Invalidate I cache */
14 asm volatile("mcr p15, 0, %0, c7, c5, 0\n" : : "r"(0));
15 /* Flush/Invalidate D cache */
16 asm volatile("mcr p15, 0, %0, c7, c6, 0\n" : : "r"(0));
19 void flush_dcache_all(void)
21 return invalidate_dcache_all();
24 void invalidate_dcache_range(unsigned long start
, unsigned long stop
)
26 start
&= ~(CONFIG_SYS_CACHELINE_SIZE
- 1);
27 stop
&= ~(CONFIG_SYS_CACHELINE_SIZE
- 1);
29 while (start
<= stop
) {
30 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start
));
31 start
+= CONFIG_SYS_CACHELINE_SIZE
;
35 void flush_dcache_range(unsigned long start
, unsigned long stop
)
37 return invalidate_dcache_range(start
, stop
);
39 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
40 void invalidate_dcache_all(void)
44 void flush_dcache_all(void)
47 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
50 * Stub implementations for l2 cache operations
53 __weak
void l2_cache_disable(void) {}
55 #if defined CONFIG_SYS_THUMB_BUILD
56 __weak
void invalidate_l2_cache(void) {}