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>
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
void invalidate_icache_all(void)
|
|
|
|
{
|
|
|
|
asm volatile ("fence.i" ::: "memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
void flush_dcache_all(void)
|
|
|
|
{
|
|
|
|
asm volatile ("fence" :::"memory");
|
|
|
|
}
|
2017-12-26 05:55:49 +00:00
|
|
|
void flush_dcache_range(unsigned long start, unsigned long end)
|
|
|
|
{
|
2018-11-07 01:34:06 +00:00
|
|
|
flush_dcache_all();
|
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();
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
void invalidate_dcache_range(unsigned long start, unsigned long end)
|
2018-11-22 10:26:23 +00:00
|
|
|
{
|
2018-11-07 01:34:06 +00:00
|
|
|
flush_dcache_all();
|
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)
|
|
|
|
{
|
2018-11-07 01:34:06 +00:00
|
|
|
invalidate_icache_all();
|
|
|
|
flush_dcache_all();
|
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;
|
|
|
|
}
|