]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
8bbb2909 RC |
2 | /* |
3 | * Copyright (C) 2017 Andes Technology Corporation | |
4 | * Rick Chen, Andes Technology Corporation <[email protected]> | |
8bbb2909 RC |
5 | */ |
6 | ||
7 | #include <common.h> | |
8 | ||
52923c6d RC |
9 | void invalidate_icache_all(void) |
10 | { | |
11 | asm volatile ("fence.i" ::: "memory"); | |
12 | } | |
13 | ||
14 | void flush_dcache_all(void) | |
15 | { | |
16 | asm volatile ("fence" :::"memory"); | |
17 | } | |
8bbb2909 RC |
18 | void flush_dcache_range(unsigned long start, unsigned long end) |
19 | { | |
52923c6d | 20 | flush_dcache_all(); |
8bbb2909 RC |
21 | } |
22 | ||
23 | void invalidate_icache_range(unsigned long start, unsigned long end) | |
24 | { | |
62a09ad5 LA |
25 | /* |
26 | * RISC-V does not have an instruction for invalidating parts of the | |
27 | * instruction cache. Invalidate all of it instead. | |
28 | */ | |
29 | invalidate_icache_all(); | |
30 | } | |
31 | ||
52923c6d | 32 | void invalidate_dcache_range(unsigned long start, unsigned long end) |
62a09ad5 | 33 | { |
52923c6d | 34 | flush_dcache_all(); |
8bbb2909 RC |
35 | } |
36 | ||
52923c6d | 37 | void cache_flush(void) |
8bbb2909 | 38 | { |
52923c6d RC |
39 | invalidate_icache_all(); |
40 | flush_dcache_all(); | |
8bbb2909 RC |
41 | } |
42 | ||
43 | void flush_cache(unsigned long addr, unsigned long size) | |
44 | { | |
52923c6d RC |
45 | invalidate_icache_all(); |
46 | flush_dcache_all(); | |
8bbb2909 RC |
47 | } |
48 | ||
52923c6d | 49 | __weak void icache_enable(void) |
8bbb2909 RC |
50 | { |
51 | } | |
52 | ||
52923c6d | 53 | __weak void icache_disable(void) |
8bbb2909 RC |
54 | { |
55 | } | |
56 | ||
52923c6d | 57 | __weak int icache_status(void) |
8bbb2909 RC |
58 | { |
59 | return 0; | |
60 | } | |
61 | ||
52923c6d | 62 | __weak void dcache_enable(void) |
8bbb2909 RC |
63 | { |
64 | } | |
65 | ||
52923c6d | 66 | __weak void dcache_disable(void) |
8bbb2909 RC |
67 | { |
68 | } | |
69 | ||
52923c6d | 70 | __weak int dcache_status(void) |
8bbb2909 RC |
71 | { |
72 | return 0; | |
73 | } |