2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-12-26 05:55:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Andes Technology Corporation
|
|
|
|
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2017-12-26 05:55:49 +00:00
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
void invalidate_icache_all(void)
|
|
|
|
{
|
|
|
|
asm volatile ("fence.i" ::: "memory");
|
|
|
|
}
|
|
|
|
|
2019-01-04 00:37:29 +00:00
|
|
|
__weak void flush_dcache_all(void)
|
2018-11-07 01:34:06 +00:00
|
|
|
{
|
|
|
|
}
|
2019-01-04 00:37:29 +00:00
|
|
|
|
|
|
|
__weak void flush_dcache_range(unsigned long start, unsigned long end)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void invalidate_icache_range(unsigned long start, unsigned long end)
|
|
|
|
{
|
2018-11-22 10:26:23 +00:00
|
|
|
/*
|
|
|
|
* RISC-V does not have an instruction for invalidating parts of the
|
|
|
|
* instruction cache. Invalidate all of it instead.
|
|
|
|
*/
|
|
|
|
invalidate_icache_all();
|
|
|
|
}
|
|
|
|
|
2019-01-04 00:37:29 +00:00
|
|
|
__weak void invalidate_dcache_range(unsigned long start, unsigned long end)
|
2018-11-22 10:26:23 +00:00
|
|
|
{
|
2017-12-26 05:55:49 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
void cache_flush(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
2018-11-07 01:34:06 +00:00
|
|
|
invalidate_icache_all();
|
|
|
|
flush_dcache_all();
|
2017-12-26 05:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_cache(unsigned long addr, unsigned long size)
|
|
|
|
{
|
2019-01-04 00:37:30 +00:00
|
|
|
invalidate_icache_range(addr, addr + size);
|
|
|
|
flush_dcache_range(addr, addr + size);
|
2017-12-26 05:55:49 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
__weak void icache_enable(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
__weak void icache_disable(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
__weak int icache_status(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
__weak void dcache_enable(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
__weak void dcache_disable(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
__weak int dcache_status(void)
|
2017-12-26 05:55:49 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-09-01 07:01:40 +00:00
|
|
|
|
|
|
|
__weak void enable_caches(void)
|
|
|
|
{
|
|
|
|
}
|