]> Git Repo - J-u-boot.git/blame - arch/riscv/lib/cache.c
riscv: cache: Implement i/dcache [status, enable, disable]
[J-u-boot.git] / arch / riscv / lib / cache.c
CommitLineData
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
9void invalidate_icache_all(void)
10{
11 asm volatile ("fence.i" ::: "memory");
12}
13
14void flush_dcache_all(void)
15{
16 asm volatile ("fence" :::"memory");
17}
8bbb2909
RC
18void flush_dcache_range(unsigned long start, unsigned long end)
19{
52923c6d 20 flush_dcache_all();
8bbb2909
RC
21}
22
23void 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 32void invalidate_dcache_range(unsigned long start, unsigned long end)
62a09ad5 33{
52923c6d 34 flush_dcache_all();
8bbb2909
RC
35}
36
52923c6d 37void cache_flush(void)
8bbb2909 38{
52923c6d
RC
39 invalidate_icache_all();
40 flush_dcache_all();
8bbb2909
RC
41}
42
43void 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}
This page took 0.105358 seconds and 4 git commands to generate.