blob: 5437a122a100480881b3c66f8e1c24cf12eb3a58 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rick Chen8bbb2902017-12-26 13:55:49 +08002/*
3 * Copyright (C) 2017 Andes Technology Corporation
4 * Rick Chen, Andes Technology Corporation <rick@andestech.com>
Rick Chen8bbb2902017-12-26 13:55:49 +08005 */
6
7#include <common.h>
8
Rick Chen52923c62018-11-07 09:34:06 +08009void invalidate_icache_all(void)
10{
11 asm volatile ("fence.i" ::: "memory");
12}
13
Lukas Auerc9056652019-01-04 01:37:29 +010014__weak void flush_dcache_all(void)
Rick Chen52923c62018-11-07 09:34:06 +080015{
Rick Chen52923c62018-11-07 09:34:06 +080016}
Lukas Auerc9056652019-01-04 01:37:29 +010017
18__weak void flush_dcache_range(unsigned long start, unsigned long end)
Rick Chen8bbb2902017-12-26 13:55:49 +080019{
20}
21
22void invalidate_icache_range(unsigned long start, unsigned long end)
23{
Lukas Auer62a09ad2018-11-22 11:26:23 +010024 /*
25 * RISC-V does not have an instruction for invalidating parts of the
26 * instruction cache. Invalidate all of it instead.
27 */
28 invalidate_icache_all();
29}
30
Lukas Auerc9056652019-01-04 01:37:29 +010031__weak void invalidate_dcache_range(unsigned long start, unsigned long end)
Rick Chen8bbb2902017-12-26 13:55:49 +080032{
Rick Chen52923c62018-11-07 09:34:06 +080033}
34
35void cache_flush(void)
36{
37 invalidate_icache_all();
38 flush_dcache_all();
Rick Chen8bbb2902017-12-26 13:55:49 +080039}
40
41void flush_cache(unsigned long addr, unsigned long size)
42{
Lukas Auerf74c4162019-01-04 01:37:30 +010043 invalidate_icache_range(addr, addr + size);
44 flush_dcache_range(addr, addr + size);
Rick Chen8bbb2902017-12-26 13:55:49 +080045}
46
Rick Chen52923c62018-11-07 09:34:06 +080047__weak void icache_enable(void)
Rick Chen8bbb2902017-12-26 13:55:49 +080048{
49}
50
Rick Chen52923c62018-11-07 09:34:06 +080051__weak void icache_disable(void)
Rick Chen8bbb2902017-12-26 13:55:49 +080052{
53}
54
Rick Chen52923c62018-11-07 09:34:06 +080055__weak int icache_status(void)
Rick Chen8bbb2902017-12-26 13:55:49 +080056{
57 return 0;
58}
59
Rick Chen52923c62018-11-07 09:34:06 +080060__weak void dcache_enable(void)
Rick Chen8bbb2902017-12-26 13:55:49 +080061{
62}
63
Rick Chen52923c62018-11-07 09:34:06 +080064__weak void dcache_disable(void)
Rick Chen8bbb2902017-12-26 13:55:49 +080065{
66}
67
Rick Chen52923c62018-11-07 09:34:06 +080068__weak int dcache_status(void)
Rick Chen8bbb2902017-12-26 13:55:49 +080069{
70 return 0;
71}