blob: d4dfe7f6d85c062724b251d31977e91f0b690f55 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -07002/*
3 * (C) Copyright 2016 Vasily Khoruzhick <anarsoul@gmail.com>
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -07004 */
5
Simon Glass1eb69ae2019-11-14 12:57:39 -07006#include <cpu_func.h>
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -07007#include <linux/types.h>
8#include <common.h>
9
Trevor Woerner10015022019-05-03 09:41:00 -040010#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -070011void invalidate_dcache_all(void)
12{
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));
17}
18
19void flush_dcache_all(void)
20{
21 return invalidate_dcache_all();
22}
23
24void invalidate_dcache_range(unsigned long start, unsigned long stop)
25{
26 start &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
27 stop &= ~(CONFIG_SYS_CACHELINE_SIZE - 1);
28
29 while (start <= stop) {
30 asm volatile("mcr p15, 0, %0, c7, c6, 1\n" : : "r"(start));
31 start += CONFIG_SYS_CACHELINE_SIZE;
32 }
33}
34
35void flush_dcache_range(unsigned long start, unsigned long stop)
36{
37 return invalidate_dcache_range(start, stop);
38}
Trevor Woerner10015022019-05-03 09:41:00 -040039#else /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -070040void invalidate_dcache_all(void)
41{
42}
43
44void flush_dcache_all(void)
45{
46}
Trevor Woerner10015022019-05-03 09:41:00 -040047#endif /* #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) */
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -070048
49/*
50 * Stub implementations for l2 cache operations
51 */
52
53__weak void l2_cache_disable(void) {}
54
Tom Rini3a649402017-03-18 09:01:44 -040055#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
Vasily Khoruzhick9cfc0592016-03-20 18:37:07 -070056__weak void invalidate_l2_cache(void) {}
57#endif