Support SiFive Composable cache driver
Subsystems (3)
v5 cover Support SiFive Composable cache driver
This patch set contains the SiFive composable cache support, and uses this driver to enable the ways of ccache by overwriting the enable_caches.
Changed in v5:
- Fix build error on ae350 platform
Changed in v4:
- Use generic enable_caches(), rather than cache_init().
- Rebase code base to v2021.10-rc3
Changed in v3:
- Combine some patches
- Drop the subdirectories of vendor in lib/
- Rebase codebase
Changed in v2:
- Refine the ccache driver by Sean's suggestions
- Introduce a common interface for cache initialization
Zong Li (5):
cache: add sifive composable cache driver
common: board_r: support enable_caches for RISC-V
riscv: lib: implement enable_caches for sifive cache
board: sifive: use ccache driver instead of helper function
riscv: lib: modify the indent
arch/riscv/Kconfig | 5 ++ arch/riscv/cpu/fu540/Kconfig | 2 + arch/riscv/cpu/fu540/Makefile | 1 - arch/riscv/cpu/fu540/cache.c | 55 ----------------- arch/riscv/cpu/fu740/Kconfig | 2 + arch/riscv/cpu/fu740/Makefile | 1 - arch/riscv/cpu/fu740/cache.c | 55 ----------------- arch/riscv/include/asm/arch-fu540/cache.h | 14 ----- arch/riscv/include/asm/arch-fu740/cache.h | 14 ----- arch/riscv/include/asm/cache.h | 2 +- arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 4 ++ arch/riscv/lib/sifive_cache.c | 27 ++++++++ board/sifive/unleashed/unleashed.c | 10 +-- board/sifive/unmatched/unmatched.c | 11 +--- common/board_r.c | 4 +- drivers/cache/Kconfig | 7 +++ drivers/cache/Makefile | 1 + drivers/cache/cache-sifive-ccache.c | 75 +++++++++++++++++++++++ 19 files changed, 132 insertions(+), 159 deletions(-) delete mode 100644 arch/riscv/cpu/fu540/cache.c delete mode 100644 arch/riscv/cpu/fu740/cache.c delete mode 100644 arch/riscv/include/asm/arch-fu540/cache.h delete mode 100644 arch/riscv/include/asm/arch-fu740/cache.h create mode 100644 arch/riscv/lib/sifive_cache.c create mode 100644 drivers/cache/cache-sifive-ccache.c
Signature · 1 line
2.32.0
PATCH v5 1/5 cache: add sifive composable cache driver
This driver is currently responsible for enabling all ccache ways. Composable cache could be configure as RAM or cache, we will use it as RAM at the beginning to put the u-boot SPL there. In u-boot proper phrase, we will use the composable cache as cache, and try to enable the cache ways.
--- drivers/cache/Kconfig | 7 +++ drivers/cache/Makefile | 1 + drivers/cache/cache-sifive-ccache.c | 75 +++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 drivers/cache/cache-sifive-ccache.c
drivers/cache/Kconfig +7 -0
@@ -39,4 +39,11 @@ config NCORE_CACHE controller. The driver initializes cache directories and coherent agent interfaces. +config SIFIVE_CCACHE + bool "SiFive composable cache" + select CACHE + help + This driver is for SiFive Composable L2/L3 cache. It enables cache + ways of composable cache. + endmenu
drivers/cache/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_SANDBOX) += sandbox_cache.o obj-$(CONFIG_L2X0_CACHE) += cache-l2x0.o obj-$(CONFIG_NCORE_CACHE) += cache-ncore.o obj-$(CONFIG_V5L2_CACHE) += cache-v5l2.o +obj-$(CONFIG_SIFIVE_CCACHE) += cache-sifive-ccache.o
drivers/cache/cache-sifive-ccache.c new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.32.0
PATCH v5 2/5 common: board_r: support enable_caches for RISC-V
In reply to Zong LiThe enable_caches is a generic hook for architecture-implemented, we leverage this function to enable caches for RISC-V
--- arch/riscv/lib/cache.c | 4 ++++ common/board_r.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
arch/riscv/lib/cache.c +4 -0
@@ -70,3 +70,7 @@ __weak int dcache_status(void) {return 0 ; } + +__weak void enable_caches (void ) +{ +}
common/board_r.c +2 -2
@@ -114,7 +114,7 @@ static int initr_reloc(void)return 0 ; } -#ifdef CONFIG_ARM +#if defined(CONFIG_ARM ) || defined(CONFIG_RISCV )/* * Some of these functions are needed purely because the functions they * call return void. If we change them to return 0, these stubs can go away.
@@ -607,7 +607,7 @@ static init_fnc_t init_sequence_r[] = { initr_trace, initr_reloc,/* TODO: could x86/PPC have this also perhaps? */ -#ifdef CONFIG_ARM +#if defined(CONFIG_ARM ) || defined(CONFIG_RISCV ) initr_caches,/* Note: For Freescale LS2 SoCs, new MMU table is created in DDR. * A temporary mapping of IFC high region is since removed,
Signature · 1 line
2.32.0
A message that is not in the archive (sent off-list or not yet received): HK0PR03MB29943C6262D940DFD705EABFC1CE9@HK0PR03MB2994.apcprd03.prod.outlook.com
Rick Chen
Reviewed-byRe: [PATCH v5 2/5] common: board_r: support enable_caches for RISC-V
Quoted 6 lines
From: Zong Li <[email protected]>
Sent: Wednesday, September 01, 2021 3:02 PM
To: Rick Jian-Zhi Chen(陳建志) <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zong Li <[email protected]>
Subject: [PATCH v5 2/5] common:board_r: supportenable_cachesfor RISC-V
Quoted 7 lines
The
enable_cachesis a generic hook for architecture-implemented, we leverage this function to enable caches for RISC-VSigned-off-by Zong Li <[email protected]>--- arch/riscv/lib/cache.c | 4 ++++ common/board_r.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
PATCH v5 3/5 riscv: lib: implement enable_caches for sifive cache
In reply to Zong LiThe enable_caches is a generic hook for architecture-implemented, we define this function to enable composable cache of sifive platforms.
In sifive_cache, it invokes the generic cache_enable interface of cache uclass to execute the relative implementation in SiFive ccache driver.
--- arch/riscv/Kconfig | 5 +++++ arch/riscv/lib/Makefile | 1 + arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 arch/riscv/lib/sifive_cache.c
arch/riscv/Kconfig +5 -0
@@ -179,6 +179,11 @@ config SPL_SIFIVE_CLINT The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. +config SIFIVE_CACHE + bool + help + This enables the operations to configure SiFive cache + config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE
arch/riscv/lib/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o obj-$(CONFIG_CMD_GO) += boot.o obj-y += cache.o +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
arch/riscv/lib/sifive_cache.c new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 SiFive, Inc +*/ + +#include <common.h> +#include <cache.h> +#include <cpu_func.h> +#include <dm.h> + +void enable_caches (void ) +{ +struct udevice *dev; +int ret; + +/* Enable ways of ccache */ + ret =uclass_get_device_by_driver (UCLASS_CACHE , +DM_DRIVER_GET (sifive_ccache), + &dev); +if (ret) { +log_debug ("Cannot enable cache ways" ); + }else { + ret =cache_enable (dev); +if (ret) +log_debug ("ccache enable failed" ); + } +}
Signature · 1 line
2.32.0
A message that is not in the archive (sent off-list or not yet received): HK0PR03MB29944781CFEA4FC7E46914D3C1CD9@HK0PR03MB2994.apcprd03.prod.outlook.com
Rick Chen
Reviewed-byRe: [PATCH v5 3/5] riscv: lib: implement enable_caches for sifive cache
Quoted 8 lines
From: Zong Li <[email protected]>
Sent: Wednesday, September 01, 2021 3:02 PM
To: Rick Jian-Zhi Chen(陳建志) <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zong Li <[email protected]>
Subject: [PATCH v5 3/5] riscv: lib: implementenable_cachesfor sifive cacheThe
enable_cachesis a generic hook for architecture-implemented, we define this function to enable composable cache of sifive platforms.
Quoted 8 lines
In
sifive_cache, it invokes the genericcache_enableinterface of cache uclass to execute the relative implementation in SiFive ccache driver.Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/lib/Makefile | 1 + arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+)
PATCH v5 4/5 board: sifive: use ccache driver instead of helper function
In reply to Zong LiInvokes the common cache_init function to initialize ccache.
--- arch/riscv/cpu/fu540/Kconfig | 2 + arch/riscv/cpu/fu540/Makefile | 1 - arch/riscv/cpu/fu540/cache.c | 55 ----------------------- arch/riscv/cpu/fu740/Kconfig | 2 + arch/riscv/cpu/fu740/Makefile | 1 - arch/riscv/cpu/fu740/cache.c | 55 ----------------------- arch/riscv/include/asm/arch-fu540/cache.h | 14 ------ arch/riscv/include/asm/arch-fu740/cache.h | 14 ------ board/sifive/unleashed/unleashed.c | 10 +---- board/sifive/unmatched/unmatched.c | 11 ++--- 10 files changed, 9 insertions(+), 156 deletions(-) delete mode 100644 arch/riscv/cpu/fu540/cache.c delete mode 100644 arch/riscv/cpu/fu740/cache.c delete mode 100644 arch/riscv/include/asm/arch-fu540/cache.h delete mode 100644 arch/riscv/include/asm/arch-fu740/cache.h
arch/riscv/cpu/fu540/Kconfig +2 -0
@@ -19,6 +19,8 @@ config SIFIVE_FU540 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CACHE + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MII
arch/riscv/cpu/fu540/Makefile +0 -1
@@ -8,5 +8,4 @@ obj-y += spl.o else obj-y += dram.o obj-y += cpu.o -obj-y += cache.o endif
arch/riscv/cpu/fu540/cache.c deleted +0 -55
55 lines not on this page · raw message
arch/riscv/cpu/fu740/Kconfig +2 -0
@@ -19,6 +19,8 @@ config SIFIVE_FU740 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CACHE + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MII
arch/riscv/cpu/fu740/Makefile +0 -1
@@ -8,5 +8,4 @@ obj-y += spl.o else obj-y += dram.o obj-y += cpu.o -obj-y += cache.o endif
arch/riscv/cpu/fu740/cache.c deleted +0 -55
55 lines not on this page · raw message
arch/riscv/include/asm/arch-fu540/cache.h deleted +0 -14
@@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* -* Copyright (C) 2020 SiFive, Inc. -* -* Authors: -* Pragnesh Patel <[email protected]> -*/ - -#ifndef _CACHE_SIFIVE_H -#define _CACHE_SIFIVE_H - -int cache_enable_ways (void ); - -#endif /* _CACHE_SIFIVE_H */
arch/riscv/include/asm/arch-fu740/cache.h deleted +0 -14
@@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* -* Copyright (C) 2020-2021 SiFive, Inc. -* -* Authors: -* Pragnesh Patel <[email protected]> -*/ - -#ifndef _CACHE_SIFIVE_H -#define _CACHE_SIFIVE_H - -int cache_enable_ways (void ); - -#endif /* _CACHE_SIFIVE_H */
board/sifive/unleashed/unleashed.c +2 -8
@@ -6,6 +6,7 @@* Anup Patel <[email protected]> */ +#include <cpu_func.h> #include <dm.h> #include <env.h> #include <init.h>
@@ -15,7 +16,6 @@#include <linux/delay.h> #include <misc.h> #include <spl.h> -#include <asm/arch/cache.h> #include <asm/sections.h> /*
@@ -126,14 +126,8 @@ void *board_fdt_blob_setup(void)int board_init (void ) { -int ret; -/* enable all cache ways */ - ret =cache_enable_ways (); -if (ret) { -debug ("%s: could not enable cache ways\n" , __func__); -return ret; - } +enable_caches ();return 0 ; }
board/sifive/unmatched/unmatched.c +3 -8
@@ -7,8 +7,8 @@*/ #include <common.h> +#include <cpu_func.h> #include <dm.h> -#include <asm/arch/cache.h> #include <asm/sections.h> void *board_fdt_blob_setup (void )
@@ -23,13 +23,8 @@ void *board_fdt_blob_setup(void)int board_init (void ) { -int ret; -/* enable all cache ways */ - ret =cache_enable_ways (); -if (ret) { -debug ("%s: could not enable cache ways\n" , __func__); -return ret; - } +enable_caches (); +return 0 ; }
Signature · 1 line
2.32.0
A message that is not in the archive (sent off-list or not yet received): HK0PR03MB29944C2C7C41C265EC071630C1CD9@HK0PR03MB2994.apcprd03.prod.outlook.com
Rick Chen
Reviewed-byRe: [PATCH v5 4/5] board: sifive: use ccache driver instead of helper function
Quoted 10 lines
From: Zong Li <[email protected]>
Sent: Wednesday, September 01, 2021 3:02 PM
To: Rick Jian-Zhi Chen(陳建志) <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zong Li <[email protected]>
Subject: [PATCH v5 4/5] board: sifive: use ccache driver instead of helper functionInvokes the common
cache_initfunction to initialize ccache.Signed-off-by Zong Li <[email protected]>Reviewed-by Sean Anderson <[email protected]>
Quoted 10 lines
--- arch/riscv/cpu/fu540/Kconfig | 2 + arch/riscv/cpu/fu540/Makefile | 1 - arch/riscv/cpu/fu540/cache.c | 55 ----------------------- arch/riscv/cpu/fu740/Kconfig | 2 + arch/riscv/cpu/fu740/Makefile | 1 - arch/riscv/cpu/fu740/cache.c | 55 ----------------------- arch/riscv/include/asm/arch-fu540/cache.h | 14 ------ arch/riscv/include/asm/arch-fu740/cache.h | 14 ------ board/sifive/unleashed/unleashed.c | 10 +---- board/sifive/unmatched/unmatched.c | 11 ++---
PATCH v5 5/5 riscv: lib: modify the indent
In reply to Zong LiWe usually use a space in function declaration, rather than a tab.
--- arch/riscv/include/asm/cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/cache.h +1 -1
@@ -8,7 +8,7 @@#define _ASM_RISCV_CACHE_H/* cache */ -void cache_flush (void ); +void cache_flush (void );/* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes.
Signature · 1 line
2.32.0
A message that is not in the archive (sent off-list or not yet received): HK0PR03MB299421CB94E426FE08B8B772C1CD9@HK0PR03MB2994.apcprd03.prod.outlook.com
Rick Chen
Reviewed-byRe: [PATCH v5 5/5] riscv: lib: modify the indent
Quoted 6 lines
From: Zong Li <[email protected]>
Sent: Wednesday, September 01, 2021 3:02 PM
To: Rick Jian-Zhi Chen(陳建志) <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Zong Li <[email protected]>
Subject: [PATCH v5 5/5] riscv: lib: modify the indent
Quoted 7 lines
We usually use a space in function declaration, rather than a tab.
Signed-off-by Zong Li <[email protected]>Reviewed-by Sean Anderson <[email protected]>--- arch/riscv/include/asm/cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)