2018-11-07 01:34:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* 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>
|
2019-08-28 10:46:09 +00:00
|
|
|
#include <dm.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <asm/cache.h>
|
2019-08-28 10:46:09 +00:00
|
|
|
#include <dm/uclass-internal.h>
|
|
|
|
#include <cache.h>
|
2019-08-28 10:46:11 +00:00
|
|
|
#include <asm/csr.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_RISCV_NDS_CACHE
|
2020-03-14 13:42:28 +00:00
|
|
|
#if CONFIG_IS_ENABLED(RISCV_MMODE)
|
2019-08-28 10:46:11 +00:00
|
|
|
/* mcctlcommand */
|
|
|
|
#define CCTL_REG_MCCTLCOMMAND_NUM 0x7cc
|
|
|
|
|
|
|
|
/* D-cache operation */
|
|
|
|
#define CCTL_L1D_WBINVAL_ALL 6
|
|
|
|
#endif
|
2019-11-14 05:52:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_V5L2_CACHE
|
|
|
|
static void _cache_enable(void)
|
|
|
|
{
|
|
|
|
struct udevice *dev = NULL;
|
|
|
|
|
|
|
|
uclass_find_first_device(UCLASS_CACHE, &dev);
|
|
|
|
|
|
|
|
if (dev)
|
|
|
|
cache_enable(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _cache_disable(void)
|
|
|
|
{
|
|
|
|
struct udevice *dev = NULL;
|
|
|
|
|
|
|
|
uclass_find_first_device(UCLASS_CACHE, &dev);
|
|
|
|
|
|
|
|
if (dev)
|
|
|
|
cache_disable(dev);
|
|
|
|
}
|
|
|
|
#endif
|
2018-11-07 01:34:06 +00:00
|
|
|
|
2019-01-04 00:37:29 +00:00
|
|
|
void flush_dcache_all(void)
|
|
|
|
{
|
2019-11-14 05:52:25 +00:00
|
|
|
#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
|
2019-08-28 10:46:11 +00:00
|
|
|
#ifdef CONFIG_RISCV_NDS_CACHE
|
2020-03-14 13:42:28 +00:00
|
|
|
#if CONFIG_IS_ENABLED(RISCV_MMODE)
|
2019-08-28 10:46:11 +00:00
|
|
|
csr_write(CCTL_REG_MCCTLCOMMAND_NUM, CCTL_L1D_WBINVAL_ALL);
|
|
|
|
#endif
|
2019-11-14 05:52:25 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-01-04 00:37:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_dcache_range(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
flush_dcache_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
void invalidate_dcache_range(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
flush_dcache_all();
|
|
|
|
}
|
|
|
|
|
2018-11-07 01:34:06 +00:00
|
|
|
void icache_enable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void icache_disable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void dcache_enable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void dcache_disable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int icache_status(void)
|
|
|
|
{
|
2023-02-06 08:10:44 +00:00
|
|
|
return 0;
|
2018-11-07 01:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int dcache_status(void)
|
|
|
|
{
|
2023-02-06 08:10:44 +00:00
|
|
|
return 0;
|
2018-11-07 01:34:06 +00:00
|
|
|
}
|