Support SiFive Composable cache driver
Subsystems (3)
v2 cover Support SiFive Composable cache driver
This patch set contains the SiFive composable cache support, and indroduce an interface to do cache initialization, each platform can overwrite it by their own implementation.
Changed in v2:
- Refine the ccache driver by Sean's suggestions
- Introduce a common interface for cache initialization
Zong Li (6):
cache: add sifive composable cache driver
board: sifive: use ccache driver instead of helper function
riscv: lib: introduce cache_init interface
riscv: sifive: use common cache_init instead of duplicated
implementation
riscv: lib: move platform-related libraries to sperate folder
riscv: lib: modify the indent
arch/riscv/Kconfig | 12 ++++
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 | 3 +-
arch/riscv/lib/Makefile | 8 +--
arch/riscv/lib/andestech/Kconfig | 8 +++
arch/riscv/lib/andestech/Makefile | 7 ++
arch/riscv/lib/{ => andestech}/andes_plic.c | 0
arch/riscv/lib/cache.c | 5 ++
arch/riscv/lib/sifive/Kconfig | 8 +++
arch/riscv/lib/sifive/Makefile | 9 +++
arch/riscv/lib/sifive/sifive_cache.c | 27 ++++++++
arch/riscv/lib/{ => sifive}/sifive_clint.c | 0
board/sifive/unleashed/unleashed.c | 12 +---
board/sifive/unmatched/unmatched.c | 11 +--
drivers/cache/Kconfig | 7 ++
drivers/cache/Makefile | 1 +
drivers/cache/cache-sifive-ccache.c | 75 +++++++++++++++++++++
24 files changed, 173 insertions(+), 164 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/andestech/Kconfig
create mode 100644 arch/riscv/lib/andestech/Makefile
rename arch/riscv/lib/{ => andestech}/andes_plic.c (100%)
create mode 100644 arch/riscv/lib/sifive/Kconfig
create mode 100644 arch/riscv/lib/sifive/Makefile
create mode 100644 arch/riscv/lib/sifive/sifive_cache.c
rename arch/riscv/lib/{ => sifive}/sifive_clint.c (100%)
create mode 100644 drivers/cache/cache-sifive-ccache.cSignature · 1 line
2.32.0
PATCH v2 1/6 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
Re: [PATCH v2 1/6] cache: add sifive composable cache driver
Quoted 111 lines · Zong Li
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.
Signed-off-by Zong Li <[email protected]>--- 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.cdrivers/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. + endmenudrivers/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.odrivers/cache/cache-sifive-ccache.c new file +65
-0@@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2021 SiFive +*/ + +#include <common.h> +#include <cache.h> +#include <dm.h> +#include <asm/io.h> +#include <dm/device.h> +#include <linux/bitfield.h> + +#define SIFIVE_CCACHE_CONFIG 0x000 +#define SIFIVE_CCACHE_CONFIG_WAYS GENMASK(15, 8) + +#define SIFIVE_CCACHE_WAY_ENABLE 0x008 + +struct sifive_ccache { +void __iomem *base; +}; + +static int sifive_ccache_enable (struct udevice *dev) +{ +struct sifive_ccache *priv =dev_get_priv (dev); +u32 config; +u32 ways; + +/* Enable all ways of composable cache */ + config =readl (priv->base +SIFIVE_CCACHE_CONFIG ); + ways =FIELD_GET (SIFIVE_CCACHE_CONFIG_WAYS , config); + +writel (ways -1 , priv->base +SIFIVE_CCACHE_WAY_ENABLE ); + +return 0 ; +} + +static int sifive_ccache_get_info (struct udevice *dev,struct cache_info *info) +{ +struct sifive_ccache *priv =dev_get_priv (dev); + + info->base = (phys_addr_t )priv->base; + +return 0 ; +} + +static const struct cache_ops sifive_ccache_ops = { + .enable = sifive_ccache_enable, + .get_info = sifive_ccache_get_info, +}; + +static int sifive_ccache_probe (struct udevice *dev) +{ +struct sifive_ccache *priv =dev_get_priv (dev); + + priv->base =dev_read_addr_ptr (dev); +if (!priv->base) +return -EINVAL ; + +return 0 ; +} + +static const struct udevice_id sifive_ccache_ids[] = { + { .compatible ="sifive,fu540-c000-ccache" }, + { .compatible ="sifive,fu740-c000-ccache" }, + {}
drivers/cache/cache-sifive-ccache.c line 75
Quoted 10 lines
drivers/cache/cache-sifive-ccache.c new file +10
-0+}; + +U_BOOT_DRIVER (sifive_ccache) = { + .name ="sifive_ccache" , + .id =UCLASS_CACHE , + .of_match = sifive_ccache_ids, + .probe = sifive_ccache_probe, + .priv_auto =sizeof (struct sifive_ccache ), + .ops = &sifive_ccache_ops, +};
PATCH v2 2/6 board: sifive: use ccache driver instead of helper function
In reply to Zong LiInvokes the generic cache_enable interface to execute the relative implementation in SiFive ccache driver.
--- arch/riscv/cpu/fu540/Kconfig | 1 + arch/riscv/cpu/fu540/cache.c | 54 ++++++----------------- arch/riscv/cpu/fu740/Kconfig | 1 + arch/riscv/cpu/fu740/cache.c | 52 ++++++---------------- arch/riscv/include/asm/arch-fu540/cache.h | 2 +- arch/riscv/include/asm/arch-fu740/cache.h | 2 +- board/sifive/unleashed/unleashed.c | 10 +---- board/sifive/unmatched/unmatched.c | 9 +--- 8 files changed, 33 insertions(+), 98 deletions(-)
arch/riscv/cpu/fu540/Kconfig +1 -0
@@ -19,6 +19,7 @@ config SIFIVE_FU540 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MII
arch/riscv/cpu/fu540/cache.c +14 -40
69 lines not on this page · raw message
arch/riscv/cpu/fu740/Kconfig +1 -0
@@ -19,6 +19,7 @@ config SIFIVE_FU740 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MII
arch/riscv/cpu/fu740/cache.c +13 -39
62 lines not on this page · raw message
arch/riscv/include/asm/arch-fu540/cache.h +1 -1
@@ -9,6 +9,6 @@#ifndef _CACHE_SIFIVE_H#define _CACHE_SIFIVE_H -int cache_enable_ways (void ); +int sifive_ccache_enable_ways (void );#endif /* _CACHE_SIFIVE_H */
arch/riscv/include/asm/arch-fu740/cache.h +1 -1
@@ -9,6 +9,6 @@#ifndef _CACHE_SIFIVE_H#define _CACHE_SIFIVE_H -int cache_enable_ways (void ); +int sifive_ccache_enable_ways (void );#endif /* _CACHE_SIFIVE_H */
board/sifive/unleashed/unleashed.c +1 -9
@@ -126,14 +126,6 @@ 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; - } - -return 0 ; +return sifive_ccache_enable_ways (); }
board/sifive/unmatched/unmatched.c +1 -8
@@ -23,13 +23,6 @@ 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; - } -return 0 ; +return sifive_ccache_enable_ways (); }
Signature · 1 line
2.32.0
Re: [PATCH v2 2/6] board: sifive: use ccache driver instead of helper function
Quoted 234 lines · Zong Li
Invokes the generic
cache_enableinterface to execute the relative implementation in SiFive ccache driver.Signed-off-by Zong Li <[email protected]>--- arch/riscv/cpu/fu540/Kconfig | 1 + arch/riscv/cpu/fu540/cache.c | 54 ++++++----------------- arch/riscv/cpu/fu740/Kconfig | 1 + arch/riscv/cpu/fu740/cache.c | 52 ++++++---------------- arch/riscv/include/asm/arch-fu540/cache.h | 2 +- arch/riscv/include/asm/arch-fu740/cache.h | 2 +- board/sifive/unleashed/unleashed.c | 10 +---- board/sifive/unmatched/unmatched.c | 9 +--- 8 files changed, 33 insertions(+), 98 deletions(-)arch/riscv/cpu/fu540/Kconfig +1
-0@@ -19,6 +19,7 @@ config SIFIVE_FU540 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MIIarch/riscv/cpu/fu540/cache.c +14
-40@@ -1,55 +1,29 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Copyright (C) 2020 SiFive, Inc +* Copyright (C) 2020 - 2021 SiFive, Inc * * Authors: * Pragnesh Patel <[email protected]> */ #include <common.h> -#include <asm/global_data.h> -#include <asm/io.h> -#include <linux/bitops.h> +#include <cache.h> +#include <dm.h> -/* Register offsets */ -#define L2_CACHE_CONFIG 0x000 -#define L2_CACHE_ENABLE 0x008 - -#define MASK_NUM_WAYS GENMASK(15, 8) -#define NUM_WAYS_SHIFT 8 - -DECLARE_GLOBAL_DATA_PTR ; - -int cache_enable_ways (void ) +int sifive_ccache_enable_ways (void ) { -const void *blob = gd->fdt_blob; -int node; -fdt_addr_t base; -u32 config; -u32 ways; - -volatile u32 *enable; - - node =fdt_node_offset_by_compatible (blob,-1 , -"sifive,fu540-c000-ccache" ); - -if (node <0 ) -return node; - - base =fdtdec_get_addr_size_auto_parent (blob,0 , node,"reg" ,0 , -NULL , false); -if (base ==FDT_ADDR_T_NONE ) -return FDT_ADDR_T_NONE ; +struct udevice *dev; +int ret; - config =readl ((volatile u32 *)base +L2_CACHE_CONFIG ); - ways = (config &MASK_NUM_WAYS ) >>NUM_WAYS_SHIFT ; + ret =uclass_get_device_by_driver (UCLASS_CACHE , +DM_DRIVER_GET (sifive_ccache), + &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); - enable = (volatile u32 *)(base +L2_CACHE_ENABLE ); + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); -/* memory barrier */ -mb (); - (*enable) = ways -1 ; -/* memory barrier */ -mb ();return 0 ; }arch/riscv/cpu/fu740/Kconfig +1
-0@@ -19,6 +19,7 @@ config SIFIVE_FU740 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MIIarch/riscv/cpu/fu740/cache.c +13
-39@@ -7,49 +7,23 @@*/ #include <common.h> -#include <asm/io.h> -#include <linux/bitops.h> -#include <asm/global_data.h> +#include <cache.h> +#include <dm.h> -/* Register offsets */ -#define L2_CACHE_CONFIG 0x000 -#define L2_CACHE_ENABLE 0x008 - -#define MASK_NUM_WAYS GENMASK(15, 8) -#define NUM_WAYS_SHIFT 8 - -DECLARE_GLOBAL_DATA_PTR ; - -int cache_enable_ways (void ) +int sifive_ccache_enable_ways (void ) { -const void *blob = gd->fdt_blob; -int node; -fdt_addr_t base; -u32 config; -u32 ways; - -volatile u32 *enable; - - node =fdt_node_offset_by_compatible (blob,-1 , -"sifive,fu740-c000-ccache" ); - -if (node <0 ) -return node; - - base =fdtdec_get_addr_size_auto_parent (blob,0 , node,"reg" ,0 , -NULL , false); -if (base ==FDT_ADDR_T_NONE ) -return FDT_ADDR_T_NONE ; +struct udevice *dev; +int ret; - config =readl ((volatile u32 *)base +L2_CACHE_CONFIG ); - ways = (config &MASK_NUM_WAYS ) >>NUM_WAYS_SHIFT ; + ret =uclass_get_device_by_driver (UCLASS_CACHE , +DM_DRIVER_GET (sifive_ccache), + &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); - enable = (volatile u32 *)(base +L2_CACHE_ENABLE ); + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); -/* memory barrier */ -mb (); - (*enable) = ways -1 ; -/* memory barrier */ -mb ();return 0 ; }arch/riscv/include/asm/arch-fu540/cache.h +1
-1@@ -9,6 +9,6 @@#ifndef _CACHE_SIFIVE_H#define _CACHE_SIFIVE_H -int cache_enable_ways (void ); +int sifive_ccache_enable_ways (void );#endif /* _CACHE_SIFIVE_H */ arch/riscv/include/asm/arch-fu740/cache.h +1
-1@@ -9,6 +9,6 @@#ifndef _CACHE_SIFIVE_H#define _CACHE_SIFIVE_H -int cache_enable_ways (void ); +int sifive_ccache_enable_ways (void );#endif /* _CACHE_SIFIVE_H */ board/sifive/unleashed/unleashed.c +1
-9@@ -126,14 +126,6 @@ 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; - } - -return 0 ; +return sifive_ccache_enable_ways (); }board/sifive/unmatched/unmatched.c +0
-1@@ -23,13 +23,6 @@ void *board_fdt_blob_setup(void)int board_init (void ) { -int ret;
board/sifive/unmatched/unmatched.c void *board_fdt_blob_setup(void) · line 28
Quoted 10 lines
board/sifive/unmatched/unmatched.c +1
-7-/* enable all cache ways */ - ret =cache_enable_ways (); -if (ret) { -debug ("%s: could not enable cache ways\n" , __func__); -return ret; - } -return 0 ; +return sifive_ccache_enable_ways (); }
Can you combine patches 2-4 in some way? It seems like you add some code only to immediately refactor it.
--Sean
Re: [PATCH v2 2/6] board: sifive: use ccache driver instead of helper function
Quoted 232 lines · Sean Anderson
Quoted 230 lines · Zong Li
Invokes the generic
cache_enableinterface to execute the relative implementation in SiFive ccache driver.Signed-off-by Zong Li <[email protected]>--- arch/riscv/cpu/fu540/Kconfig | 1 + arch/riscv/cpu/fu540/cache.c | 54 ++++++----------------- arch/riscv/cpu/fu740/Kconfig | 1 + arch/riscv/cpu/fu740/cache.c | 52 ++++++---------------- arch/riscv/include/asm/arch-fu540/cache.h | 2 +- arch/riscv/include/asm/arch-fu740/cache.h | 2 +- board/sifive/unleashed/unleashed.c | 10 +---- board/sifive/unmatched/unmatched.c | 9 +--- 8 files changed, 33 insertions(+), 98 deletions(-)arch/riscv/cpu/fu540/Kconfig +1
-0@@ -19,6 +19,7 @@ config SIFIVE_FU540 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MIIarch/riscv/cpu/fu540/cache.c +14
-40@@ -1,55 +1,29 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Copyright (C) 2020 SiFive, Inc +* Copyright (C) 2020 - 2021 SiFive, Inc * * Authors: * Pragnesh Patel <[email protected]> */ #include <common.h> -#include <asm/global_data.h> -#include <asm/io.h> -#include <linux/bitops.h> +#include <cache.h> +#include <dm.h> -/* Register offsets */ -#define L2_CACHE_CONFIG 0x000 -#define L2_CACHE_ENABLE 0x008 - -#define MASK_NUM_WAYS GENMASK(15, 8) -#define NUM_WAYS_SHIFT 8 - -DECLARE_GLOBAL_DATA_PTR ; - -int cache_enable_ways (void ) +int sifive_ccache_enable_ways (void ) { -const void *blob = gd->fdt_blob; -int node; -fdt_addr_t base; -u32 config; -u32 ways; - -volatile u32 *enable; - - node =fdt_node_offset_by_compatible (blob,-1 , -"sifive,fu540-c000-ccache" ); - -if (node <0 ) -return node; - - base =fdtdec_get_addr_size_auto_parent (blob,0 , node,"reg" ,0 , -NULL , false); -if (base ==FDT_ADDR_T_NONE ) -return FDT_ADDR_T_NONE ; +struct udevice *dev; +int ret; - config =readl ((volatile u32 *)base +L2_CACHE_CONFIG ); - ways = (config &MASK_NUM_WAYS ) >>NUM_WAYS_SHIFT ; + ret =uclass_get_device_by_driver (UCLASS_CACHE , +DM_DRIVER_GET (sifive_ccache), + &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); - enable = (volatile u32 *)(base +L2_CACHE_ENABLE ); + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); -/* memory barrier */ -mb (); - (*enable) = ways -1 ; -/* memory barrier */ -mb ();return 0 ; }arch/riscv/cpu/fu740/Kconfig +1
-0@@ -19,6 +19,7 @@ config SIFIVE_FU740 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB imply MIIarch/riscv/cpu/fu740/cache.c +13
-39@@ -7,49 +7,23 @@*/ #include <common.h> -#include <asm/io.h> -#include <linux/bitops.h> -#include <asm/global_data.h> +#include <cache.h> +#include <dm.h> -/* Register offsets */ -#define L2_CACHE_CONFIG 0x000 -#define L2_CACHE_ENABLE 0x008 - -#define MASK_NUM_WAYS GENMASK(15, 8) -#define NUM_WAYS_SHIFT 8 - -DECLARE_GLOBAL_DATA_PTR ; - -int cache_enable_ways (void ) +int sifive_ccache_enable_ways (void ) { -const void *blob = gd->fdt_blob; -int node; -fdt_addr_t base; -u32 config; -u32 ways; - -volatile u32 *enable; - - node =fdt_node_offset_by_compatible (blob,-1 , -"sifive,fu740-c000-ccache" ); - -if (node <0 ) -return node; - - base =fdtdec_get_addr_size_auto_parent (blob,0 , node,"reg" ,0 , -NULL , false); -if (base ==FDT_ADDR_T_NONE ) -return FDT_ADDR_T_NONE ; +struct udevice *dev; +int ret; - config =readl ((volatile u32 *)base +L2_CACHE_CONFIG ); - ways = (config &MASK_NUM_WAYS ) >>NUM_WAYS_SHIFT ; + ret =uclass_get_device_by_driver (UCLASS_CACHE , +DM_DRIVER_GET (sifive_ccache), + &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); - enable = (volatile u32 *)(base +L2_CACHE_ENABLE ); + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); -/* memory barrier */ -mb (); - (*enable) = ways -1 ; -/* memory barrier */ -mb ();return 0 ; }arch/riscv/include/asm/arch-fu540/cache.h +1
-1@@ -9,6 +9,6 @@#ifndef _CACHE_SIFIVE_H#define _CACHE_SIFIVE_H -int cache_enable_ways (void ); +int sifive_ccache_enable_ways (void );#endif /* _CACHE_SIFIVE_H */ arch/riscv/include/asm/arch-fu740/cache.h +1
-1@@ -9,6 +9,6 @@#ifndef _CACHE_SIFIVE_H#define _CACHE_SIFIVE_H -int cache_enable_ways (void ); +int sifive_ccache_enable_ways (void );#endif /* _CACHE_SIFIVE_H */ board/sifive/unleashed/unleashed.c +1
-9@@ -126,14 +126,6 @@ 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; - } - -return 0 ; +return sifive_ccache_enable_ways (); }board/sifive/unmatched/unmatched.c +0
-0@@ -23,13 +23,6 @@ void *board_fdt_blob_setup(void)
Quoted 17 lines
Quoted 4 lines
board/sifive/unmatched/unmatched.c +0
-1int board_init (void ) { -int ret;board/sifive/unmatched/unmatched.c void *board_fdt_blob_setup(void) · line 28
Quoted 10 lines
board/sifive/unmatched/unmatched.c +1
-7-/* enable all cache ways */ - ret =cache_enable_ways (); -if (ret) { -debug ("%s: could not enable cache ways\n" , __func__); -return ret; - } -return 0 ; +return sifive_ccache_enable_ways (); }Can you combine patches 2-4 in some way? It seems like you add some code only to immediately refactor it.
Okay, let me tidy up these patches. I separated them because I'd like to separate the histories of using ccache driver and using common interfaces, so people could easily know the process of evolution. But yes, I might as well re-split the patches and combine them.
Quoted 1 line
--Sean
PATCH v2 3/6 riscv: lib: introduce cache_init interface
In reply to Zong LiAdd an interface for cache initialization. Each platform can overwrite this weak function by their own implementation, such as sifive_cache in this patch.
--- arch/riscv/Kconfig | 5 +++++ arch/riscv/include/asm/cache.h | 1 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 5 +++++ arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 5 files changed, 39 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/include/asm/cache.h +1 -0
@@ -9,6 +9,7 @@/* cache */ void cache_flush (void ); +int cache_init (void );/* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes.
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/cache.c +5 -0
@@ -70,3 +70,8 @@ __weak int dcache_status(void) {return 0 ; } + +__weak int cache_init (void ) +{ +return 0 ; +}
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 <dm.h> + +int cache_init (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) +return log_msg_ret ("Cannot enable cache ways" , ret); + + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); + +return 0 ; +}
Signature · 1 line
2.32.0
Re: [PATCH v2 3/6] riscv: lib: introduce cache_init interface
Quoted 3 lines · Zong Li
Add an interface for cache initialization. Each platform can overwrite this weak function by their own implementation, such as
sifive_cachein this patch.
Can we call this enable_caches instead of cache_init? This function is called by initr_caches in board_r.c for ARM. There's even an eight-year-old TODO on the subject.
Quoted 88 lines
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/include/asm/cache.h | 1 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 5 +++++ arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+)create mode 100644
arch/riscv/lib/sifive_cache.carch/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_MMODEarch/riscv/include/asm/cache.h +1
-0@@ -9,6 +9,7 @@/* cache */ void cache_flush (void ); +int cache_init (void );/* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes. 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.oarch/riscv/lib/cache.c +5
-0@@ -70,3 +70,8 @@ __weak int dcache_status(void) {return 0 ; } + +__weak int cache_init (void ) +{ +return 0 ; +}arch/riscv/lib/sifive_cache.c new file +17
-0@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 SiFive, Inc +*/ + +#include <common.h> +#include <cache.h> +#include <dm.h> + +int cache_init (void ) +{ +struct udevice *dev; +int ret; + +/* Enable ways of ccache */ + ret = uclass_get_device_by_driver(UCLASS_CACHE, + DM_DRIVER_GET(sifive_ccache),
arch/riscv/lib/sifive_cache.c line 27
Quoted 10 lines
arch/riscv/lib/sifive_cache.c new file +10
-0+ &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); + + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); + +return 0 ; +}
Otherwise LGTM
Re: [PATCH v2 3/6] riscv: lib: introduce cache_init interface
Quoted 10 lines · Sean Anderson
Quoted 3 lines · Zong Li
Add an interface for cache initialization. Each platform can overwrite this weak function by their own implementation, such as
sifive_cachein this patch.Can we call this
enable_cachesinstead ofcache_init? This function is called byinitr_cachesinboard_r.cfor ARM. There's even an eight-year-old TODO on the subject.
I had considered use it, The reason I finally used cache_init here is that it seems to me that cache_init would be more flexible for risc-v platforms to do not only cache enable, but also various platform-specific initialization of cache, even they could decide the time to invoke cache_init if there is particular initialization sequence. If you think that cache_init is OK to you, I would prefer to retain cache_init. I can still use enable_caches instead of cache_init if you think that it is a better way. Please let me know your thoughts and thanks for your review.
Quoted 100 lines
Quoted 88 lines
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/include/asm/cache.h | 1 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 5 +++++ arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+)create mode 100644
arch/riscv/lib/sifive_cache.carch/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_MMODEarch/riscv/include/asm/cache.h +1
-0@@ -9,6 +9,7 @@/* cache */ void cache_flush (void ); +int cache_init (void );/* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes. 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.oarch/riscv/lib/cache.c +5
-0@@ -70,3 +70,8 @@ __weak int dcache_status(void) {return 0 ; } + +__weak int cache_init (void ) +{ +return 0 ; +}arch/riscv/lib/sifive_cache.c new file +17
-0@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 SiFive, Inc +*/ + +#include <common.h> +#include <cache.h> +#include <dm.h> + +int cache_init (void ) +{ +struct udevice *dev; +int ret; + +/* Enable ways of ccache */ + ret = uclass_get_device_by_driver(UCLASS_CACHE, + DM_DRIVER_GET(sifive_ccache),arch/riscv/lib/sifive_cache.c line 27
Quoted 10 lines
arch/riscv/lib/sifive_cache.c new file +10
-0+ &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); + + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); + +return 0 ; +}Otherwise LGTM
Re: [PATCH v2 3/6] riscv: lib: introduce cache_init interface
Quoted 12 lines · Zong Li
Quoted 10 lines · Sean Anderson
Quoted 3 lines · Zong Li
Add an interface for cache initialization. Each platform can overwrite this weak function by their own implementation, such as
sifive_cachein this patch.Can we call this
enable_cachesinstead ofcache_init? This function is called byinitr_cachesinboard_r.cfor ARM. There's even an eight-year-old TODO on the subject.
Quoted 6 lines
I had considered use it, The reason I finally used
cache_inithere is that it seems to me thatcache_initwould be more flexible for risc-v platforms to do not only cache enable, but also various platform-specific initialization of cache, even they could decide the time to invokecache_initif there is particular initialization sequence.
Do you have some example in mind?
Quoted 4 lines
If you think that
cache_initis OK to you, I would prefer to retaincache_init. I can still useenable_cachesinstead ofcache_initif you think that it is a better way. Please let me know your thoughts and thanks for your review.
I would like to reduce the proliferation of different cache enable functions. Right now we have (i|d)cache_enable which are RISC-V-specific and called very early during boot; cache_enable, which must be called manually; enable_caches, which is implemented only for ARM; and your proposed cache_init. I don't think there is need for yet another way to accomplish the same thing.
--Sean
Quoted 100 lines
Quoted 100 lines
Quoted 88 lines
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/include/asm/cache.h | 1 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 5 +++++ arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+)create mode 100644
arch/riscv/lib/sifive_cache.carch/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_MMODEarch/riscv/include/asm/cache.h +1
-0@@ -9,6 +9,7 @@/* cache */ void cache_flush (void ); +int cache_init (void );/* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes. 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.oarch/riscv/lib/cache.c +5
-0@@ -70,3 +70,8 @@ __weak int dcache_status(void) {return 0 ; } + +__weak int cache_init (void ) +{ +return 0 ; +}arch/riscv/lib/sifive_cache.c new file +17
-0@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 SiFive, Inc +*/ + +#include <common.h> +#include <cache.h> +#include <dm.h> + +int cache_init (void ) +{ +struct udevice *dev; +int ret; + +/* Enable ways of ccache */ + ret = uclass_get_device_by_driver(UCLASS_CACHE, + DM_DRIVER_GET(sifive_ccache),arch/riscv/lib/sifive_cache.c line 27
Quoted 10 lines
arch/riscv/lib/sifive_cache.c new file +10
-0+ &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); + + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); + +return 0 ; +}Otherwise LGTM
Re: [PATCH v2 3/6] riscv: lib: introduce cache_init interface
Quoted 14 lines · Sean Anderson
Quoted 12 lines · Zong Li
Quoted 10 lines · Sean Anderson
Quoted 3 lines · Zong Li
Add an interface for cache initialization. Each platform can overwrite this weak function by their own implementation, such as
sifive_cachein this patch.Can we call this
enable_cachesinstead ofcache_init? This function is called byinitr_cachesinboard_r.cfor ARM. There's even an eight-year-old TODO on the subject.
Quoted 8 lines
Quoted 6 lines
I had considered use it, The reason I finally used
cache_inithere is that it seems to me thatcache_initwould be more flexible for risc-v platforms to do not only cache enable, but also various platform-specific initialization of cache, even they could decide the time to invokecache_initif there is particular initialization sequence.Do you have some example in mind?
It seems to me that not all cache devices are only configured for operations related to enable/disable. It might refer to the status of the cache itself or different functionalities, then it might be a bit weird if we associate them with the "enable" term, It is a platform-specific implementation.
Quoted 116 lines
Quoted 5 lines
If you think that
cache_initis OK to you, I would prefer to retaincache_init. I can still useenable_cachesinstead ofcache_initif you think that it is a better way. Please let me know your thoughts and thanks for your review.I would like to reduce the proliferation of different cache enable functions. Right now we have (i|d)cache_enable which are RISC-V-specific and called very early during boot;
cache_enable, which must be called manually;enable_caches, which is implemented only for ARM; and your proposedcache_init. I don't think there is need for yet another way to accomplish the same thing.--Sean
Quoted 100 lines
Quoted 100 lines
Quoted 88 lines
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 5 +++++ arch/riscv/include/asm/cache.h | 1 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 5 +++++ arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+)create mode 100644
arch/riscv/lib/sifive_cache.carch/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_MMODEarch/riscv/include/asm/cache.h +1
-0@@ -9,6 +9,7 @@/* cache */ void cache_flush (void ); +int cache_init (void );/* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes. 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.oarch/riscv/lib/cache.c +5
-0@@ -70,3 +70,8 @@ __weak int dcache_status(void) {return 0 ; } + +__weak int cache_init (void ) +{ +return 0 ; +}arch/riscv/lib/sifive_cache.c new file +17
-0@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 SiFive, Inc +*/ + +#include <common.h> +#include <cache.h> +#include <dm.h> + +int cache_init (void ) +{ +struct udevice *dev; +int ret; + +/* Enable ways of ccache */ + ret = uclass_get_device_by_driver(UCLASS_CACHE, + DM_DRIVER_GET(sifive_ccache),arch/riscv/lib/sifive_cache.c line 27
Quoted 10 lines
arch/riscv/lib/sifive_cache.c new file +10
-0+ &dev); +if (ret) +return log_msg_ret ("Cannot enable cache ways" , ret); + + ret =cache_enable (dev); +if (ret) +return log_msg_ret ("ccache enable failed" , ret); + +return 0 ; +}Otherwise LGTM
PATCH v2 4/6 riscv: sifive: use common cache_init instead of duplicated implementation
In reply to Zong LiWe already extracted the duplicated implementation to common code, so change to use that and drop the original implementation.
--- arch/riscv/cpu/fu540/Kconfig | 1 + arch/riscv/cpu/fu540/Makefile | 1 - arch/riscv/cpu/fu540/cache.c | 29 ----------------------- arch/riscv/cpu/fu740/Kconfig | 1 + arch/riscv/cpu/fu740/Makefile | 1 - arch/riscv/cpu/fu740/cache.c | 29 ----------------------- arch/riscv/include/asm/arch-fu540/cache.h | 14 ----------- arch/riscv/include/asm/arch-fu740/cache.h | 14 ----------- board/sifive/unleashed/unleashed.c | 4 ++-- board/sifive/unmatched/unmatched.c | 4 ++-- 10 files changed, 6 insertions(+), 92 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 +1 -0
@@ -19,6 +19,7 @@ config SIFIVE_FU540 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CACHE imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB
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 -29
@@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* Copyright (C) 2020 - 2021 SiFive, Inc -* -* Authors: -* Pragnesh Patel <[email protected]> -*/ - -#include <common.h> -#include <cache.h> -#include <dm.h> - -int sifive_ccache_enable_ways (void ) -{ -struct udevice *dev; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CACHE , -DM_DRIVER_GET (sifive_ccache), - &dev); -if (ret) -return log_msg_ret ("Cannot enable cache ways" , ret); - - ret =cache_enable (dev); -if (ret) -return log_msg_ret ("ccache enable failed" , ret); - -return 0 ; -}
arch/riscv/cpu/fu740/Kconfig +1 -0
@@ -19,6 +19,7 @@ config SIFIVE_FU740 imply SMP imply CLK_SIFIVE imply CLK_SIFIVE_PRCI + imply SIFIVE_CACHE imply SIFIVE_CCACHE imply SIFIVE_SERIAL imply MACB
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 -29
@@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* Copyright (C) 2020-2021 SiFive, Inc -* -* Authors: -* Pragnesh Patel <[email protected]> -*/ - -#include <common.h> -#include <cache.h> -#include <dm.h> - -int sifive_ccache_enable_ways (void ) -{ -struct udevice *dev; -int ret; - - ret =uclass_get_device_by_driver (UCLASS_CACHE , -DM_DRIVER_GET (sifive_ccache), - &dev); -if (ret) -return log_msg_ret ("Cannot enable cache ways" , ret); - - ret =cache_enable (dev); -if (ret) -return log_msg_ret ("ccache enable failed" , ret); - -return 0 ; -}
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 sifive_ccache_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 sifive_ccache_enable_ways (void ); - -#endif /* _CACHE_SIFIVE_H */
board/sifive/unleashed/unleashed.c +2 -2
@@ -15,7 +15,7 @@#include <linux/delay.h> #include <misc.h> #include <spl.h> -#include <asm/arch/cache.h> +#include <asm/cache.h> #include <asm/sections.h> /*
@@ -127,5 +127,5 @@ void *board_fdt_blob_setup(void)int board_init (void ) {/* enable all cache ways */ -return sifive_ccache_enable_ways (); +return cache_init (); }
board/sifive/unmatched/unmatched.c +2 -2
@@ -8,7 +8,7 @@#include <common.h> #include <dm.h> -#include <asm/arch/cache.h> +#include <asm/cache.h> #include <asm/sections.h> #if defined(CONFIG_OF_SEPARATE )
@@ -24,5 +24,5 @@ void *board_fdt_blob_setup(void)int board_init (void ) {/* enable all cache ways */ -return sifive_ccache_enable_ways (); +return cache_init (); }
Signature · 1 line
2.32.0
PATCH v2 5/6 riscv: lib: move platform-related libraries to sperate folder
In reply to Zong LiPut the platform-related implementation into their own folder respectively. Just leave the common library in the top of lib folder.
---
arch/riscv/Kconfig | 7 +++++++
arch/riscv/lib/Makefile | 9 ++++-----
arch/riscv/lib/andestech/Kconfig | 8 ++++++++
arch/riscv/lib/andestech/Makefile | 7 +++++++
arch/riscv/lib/{ => andestech}/andes_plic.c | 0
arch/riscv/lib/sifive/Kconfig | 8 ++++++++
arch/riscv/lib/sifive/Makefile | 9 +++++++++
arch/riscv/lib/{ => sifive}/sifive_cache.c | 0
arch/riscv/lib/{ => sifive}/sifive_clint.c | 0
9 files changed, 43 insertions(+), 5 deletions(-)
create mode 100644 arch/riscv/lib/andestech/Kconfig
create mode 100644 arch/riscv/lib/andestech/Makefile
rename arch/riscv/lib/{ => andestech}/andes_plic.c (100%)
create mode 100644 arch/riscv/lib/sifive/Kconfig
create mode 100644 arch/riscv/lib/sifive/Makefile
rename arch/riscv/lib/{ => sifive}/sifive_cache.c (100%)
rename arch/riscv/lib/{ => sifive}/sifive_clint.c (100%)arch/riscv/Kconfig +7 -0
@@ -72,6 +72,10 @@ source "arch/riscv/cpu/fu540/Kconfig" source "arch/riscv/cpu/fu740/Kconfig" source "arch/riscv/cpu/generic/Kconfig" +# library-specific options below +source "arch/riscv/lib/sifive/Kconfig" +source "arch/riscv/lib/andestech/Kconfig" + # architecture-specific options below choice
@@ -175,18 +179,21 @@ config SIFIVE_CLINT config SPL_SIFIVE_CLINT bool depends on SPL_RISCV_MMODE + select SIFIVE_LIB help The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. config SIFIVE_CACHE bool + select SIFIVE_LIB help This enables the operations to configure SiFive cache config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE + select ANDESTECH_LIB select REGMAP select SYSCON select SPL_REGMAP if SPL
arch/riscv/lib/Makefile +4 -5
@@ -10,11 +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 -else +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),) obj-$(CONFIG_SBI) += sbi.o obj-$(CONFIG_SBI_IPI) += sbi_ipi.o endif
@@ -42,3 +38,6 @@ extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o + +obj-$(CONFIG_SIFIVE_LIB) += sifive/ +obj-$(CONFIG_ANDESTECH_LIB) += andestech/
arch/riscv/lib/andestech/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config ANDESTECH_LIB + bool + help + This supports the specific libraries for AndesTech platforms
arch/riscv/lib/andestech/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_ANDES_PLIC) += andes_plic.o +endif
arch/riscv/lib/andestech/andes_plic.c renamed from arch/riscv/lib/andes_plic.c +0 -0
arch/riscv/lib/sifive/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config SIFIVE_LIB + bool + help + This supports the specific libraries for SiFive platforms
arch/riscv/lib/sifive/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o +endif
arch/riscv/lib/sifive/sifive_cache.c renamed from arch/riscv/lib/sifive_cache.c +0 -0
arch/riscv/lib/sifive/sifive_clint.c renamed from arch/riscv/lib/sifive_clint.c +0 -0
Signature · 1 line
2.32.0
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
Quoted 1 line
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
nit: separate
Quoted 16 lines · Zong Li
Put the platform-related implementation into their own folder respectively. Just leave the common library in the top of lib folder.
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 7 +++++++ arch/riscv/lib/Makefile | 9 ++++----- arch/riscv/lib/andestech/Kconfig | 8 ++++++++ arch/riscv/lib/andestech/Makefile | 7 +++++++ arch/riscv/lib/{ => andestech}/andes_plic.c | 0 arch/riscv/lib/sifive/Kconfig | 8 ++++++++ arch/riscv/lib/sifive/Makefile | 9 +++++++++ arch/riscv/lib/{ => sifive}/sifive_cache.c | 0 arch/riscv/lib/{ => sifive}/sifive_clint.c | 0 9 files changed, 43 insertions(+), 5 deletions(-)
Quoted 7 lines
create mode 100644
arch/riscv/lib/andestech/Kconfigcreate mode 100644arch/riscv/lib/andestech/Makefilerenamearch/riscv/lib/{=>andestech}/andes_plic.c(100%) create mode 100644arch/riscv/lib/sifive/Kconfigcreate mode 100644arch/riscv/lib/sifive/Makefilerenamearch/riscv/lib/{=>sifive}/sifive_cache.c(100%) renamearch/riscv/lib/{=>sifive}/sifive_clint.c(100%)
NAK from me. I'd much rather see organization by function (e.g. clint/sbi/plic together) than by vendor. Plus, the clint/plic are not really specific to one vendor like ccache.
--Sean
Quoted 130 lines
arch/riscv/Kconfig +7
-0@@ -72,6 +72,10 @@ source "arch/riscv/cpu/fu540/Kconfig" source "arch/riscv/cpu/fu740/Kconfig" source "arch/riscv/cpu/generic/Kconfig" +# library-specific options below +source "arch/riscv/lib/sifive/Kconfig" +source "arch/riscv/lib/andestech/Kconfig" + # architecture-specific options below choice@@ -175,18 +179,21 @@ config SIFIVE_CLINT config SPL_SIFIVE_CLINT bool depends on SPL_RISCV_MMODE + select SIFIVE_LIB help The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. config SIFIVE_CACHE bool + select SIFIVE_LIB help This enables the operations to configure SiFive cache config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE + select ANDESTECH_LIB select REGMAP select SYSCON select SPL_REGMAP if SPLarch/riscv/lib/Makefile +4
-5@@ -10,11 +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 -else +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),) obj-$(CONFIG_SBI) += sbi.o obj-$(CONFIG_SBI_IPI) += sbi_ipi.o endif@@ -42,3 +38,6 @@ extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o + +obj-$(CONFIG_SIFIVE_LIB) += sifive/ +obj-$(CONFIG_ANDESTECH_LIB) += andestech/arch/riscv/lib/andestech/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config ANDESTECH_LIB + bool + help + This supports the specific libraries for AndesTech platformsarch/riscv/lib/andestech/Makefile new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_ANDES_PLIC) += andes_plic.o +endifarch/riscv/lib/andestech/andes_plic.c renamed from arch/riscv/lib/andes_plic.c +0
-0arch/riscv/lib/sifive/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config SIFIVE_LIB + bool + help + This supports the specific libraries for SiFive platformsarch/riscv/lib/sifive/Makefile new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o +endifarch/riscv/lib/sifive/sifive_cache.c renamed from arch/riscv/lib/sifive_cache.c +0
-0arch/riscv/lib/sifive/sifive_clint.c renamed from arch/riscv/lib/sifive_clint.c +0
-0
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
Quoted 5 lines · Sean Anderson
Quoted 2 lines
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
nit: separate
Thanks for catching it. Fix it in the next version.
Quoted 25 lines · Zong Li
Quoted 16 lines
Put the platform-related implementation into their own folder respectively. Just leave the common library in the top of lib folder.
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 7 +++++++ arch/riscv/lib/Makefile | 9 ++++----- arch/riscv/lib/andestech/Kconfig | 8 ++++++++ arch/riscv/lib/andestech/Makefile | 7 +++++++ arch/riscv/lib/{ => andestech}/andes_plic.c | 0 arch/riscv/lib/sifive/Kconfig | 8 ++++++++ arch/riscv/lib/sifive/Makefile | 9 +++++++++ arch/riscv/lib/{ => sifive}/sifive_cache.c | 0 arch/riscv/lib/{ => sifive}/sifive_clint.c | 0 9 files changed, 43 insertions(+), 5 deletions(-)Quoted 7 lines
create mode 100644
arch/riscv/lib/andestech/Kconfigcreate mode 100644arch/riscv/lib/andestech/Makefilerenamearch/riscv/lib/{=>andestech}/andes_plic.c(100%) create mode 100644arch/riscv/lib/sifive/Kconfigcreate mode 100644arch/riscv/lib/sifive/Makefilerenamearch/riscv/lib/{=>sifive}/sifive_cache.c(100%) renamearch/riscv/lib/{=>sifive}/sifive_clint.c(100%)
Quoted 4 lines
NAK from me. I'd much rather see organization by function (e.g. clint/sbi/plic together) than by vendor. Plus, the clint/plic are not really specific to one vendor like ccache.
Yes, it makes more sense to me. In this case, there are three functionalities, so I'd like to separate clint, plic and cache at this time, does it make sense to you?
Quoted 133 lines
--Sean
Quoted 130 lines
arch/riscv/Kconfig +7
-0@@ -72,6 +72,10 @@ source "arch/riscv/cpu/fu540/Kconfig" source "arch/riscv/cpu/fu740/Kconfig" source "arch/riscv/cpu/generic/Kconfig" +# library-specific options below +source "arch/riscv/lib/sifive/Kconfig" +source "arch/riscv/lib/andestech/Kconfig" + # architecture-specific options below choice@@ -175,18 +179,21 @@ config SIFIVE_CLINT config SPL_SIFIVE_CLINT bool depends on SPL_RISCV_MMODE + select SIFIVE_LIB help The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. config SIFIVE_CACHE bool + select SIFIVE_LIB help This enables the operations to configure SiFive cache config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE + select ANDESTECH_LIB select REGMAP select SYSCON select SPL_REGMAP if SPLarch/riscv/lib/Makefile +4
-5@@ -10,11 +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 -else +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),) obj-$(CONFIG_SBI) += sbi.o obj-$(CONFIG_SBI_IPI) += sbi_ipi.o endif@@ -42,3 +38,6 @@ extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o + +obj-$(CONFIG_SIFIVE_LIB) += sifive/ +obj-$(CONFIG_ANDESTECH_LIB) += andestech/arch/riscv/lib/andestech/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config ANDESTECH_LIB + bool + help + This supports the specific libraries for AndesTech platformsarch/riscv/lib/andestech/Makefile new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_ANDES_PLIC) += andes_plic.o +endifarch/riscv/lib/andestech/andes_plic.c renamed from arch/riscv/lib/andes_plic.c +0
-0arch/riscv/lib/sifive/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config SIFIVE_LIB + bool + help + This supports the specific libraries for SiFive platformsarch/riscv/lib/sifive/Makefile new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o +endifarch/riscv/lib/sifive/sifive_cache.c renamed from arch/riscv/lib/sifive_cache.c +0
-0arch/riscv/lib/sifive/sifive_clint.c renamed from arch/riscv/lib/sifive_clint.c +0
-0
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
Quoted 34 lines · Zong Li
Quoted 5 lines · Sean Anderson
Quoted 2 lines
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
nit: separate
Thanks for catching it. Fix it in the next version.
Quoted 25 lines · Zong Li
Quoted 23 lines
Put the platform-related implementation into their own folder respectively. Just leave the common library in the top of lib folder.
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 7 +++++++ arch/riscv/lib/Makefile | 9 ++++----- arch/riscv/lib/andestech/Kconfig | 8 ++++++++ arch/riscv/lib/andestech/Makefile | 7 +++++++ arch/riscv/lib/{ => andestech}/andes_plic.c | 0 arch/riscv/lib/sifive/Kconfig | 8 ++++++++ arch/riscv/lib/sifive/Makefile | 9 +++++++++ arch/riscv/lib/{ => sifive}/sifive_cache.c | 0 arch/riscv/lib/{ => sifive}/sifive_clint.c | 0 9 files changed, 43 insertions(+), 5 deletions(-)create mode 100644
arch/riscv/lib/andestech/Kconfigcreate mode 100644arch/riscv/lib/andestech/Makefilerenamearch/riscv/lib/{=>andestech}/andes_plic.c(100%) create mode 100644arch/riscv/lib/sifive/Kconfigcreate mode 100644arch/riscv/lib/sifive/Makefilerenamearch/riscv/lib/{=>sifive}/sifive_cache.c(100%) renamearch/riscv/lib/{=>sifive}/sifive_clint.c(100%)
Quoted 8 lines
Quoted 4 lines
NAK from me. I'd much rather see organization by function (e.g. clint/sbi/plic together) than by vendor. Plus, the clint/plic are not really specific to one vendor like ccache.
Yes, it makes more sense to me. In this case, there are three functionalities, so I'd like to separate clint, plic and cache at this time, does it make sense to you?
No, it does not. clint and plic should be grouped with SBI because in U-Boot they are all used for IPIs. But frankly, I don't really see the need to place them in subdirectories yet...
--Sean
Quoted 134 lines
Quoted 134 lines
--Sean
Quoted 130 lines
arch/riscv/Kconfig +7
-0@@ -72,6 +72,10 @@ source "arch/riscv/cpu/fu540/Kconfig" source "arch/riscv/cpu/fu740/Kconfig" source "arch/riscv/cpu/generic/Kconfig" +# library-specific options below +source "arch/riscv/lib/sifive/Kconfig" +source "arch/riscv/lib/andestech/Kconfig" + # architecture-specific options below choice@@ -175,18 +179,21 @@ config SIFIVE_CLINT config SPL_SIFIVE_CLINT bool depends on SPL_RISCV_MMODE + select SIFIVE_LIB help The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. config SIFIVE_CACHE bool + select SIFIVE_LIB help This enables the operations to configure SiFive cache config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE + select ANDESTECH_LIB select REGMAP select SYSCON select SPL_REGMAP if SPLarch/riscv/lib/Makefile +4
-5@@ -10,11 +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 -else +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),) obj-$(CONFIG_SBI) += sbi.o obj-$(CONFIG_SBI_IPI) += sbi_ipi.o endif@@ -42,3 +38,6 @@ extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o + +obj-$(CONFIG_SIFIVE_LIB) += sifive/ +obj-$(CONFIG_ANDESTECH_LIB) += andestech/arch/riscv/lib/andestech/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config ANDESTECH_LIB + bool + help + This supports the specific libraries for AndesTech platformsarch/riscv/lib/andestech/Makefile new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_ANDES_PLIC) += andes_plic.o +endifarch/riscv/lib/andestech/andes_plic.c renamed from arch/riscv/lib/andes_plic.c +0
-0arch/riscv/lib/sifive/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config SIFIVE_LIB + bool + help + This supports the specific libraries for SiFive platformsarch/riscv/lib/sifive/Makefile new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o +endifarch/riscv/lib/sifive/sifive_cache.c renamed from arch/riscv/lib/sifive_cache.c +0
-0arch/riscv/lib/sifive/sifive_clint.c renamed from arch/riscv/lib/sifive_clint.c +0
-0
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
Quoted 41 lines · Sean Anderson
Quoted 39 lines · Zong Li
Quoted 5 lines · Sean Anderson
Quoted 2 lines
Re: [PATCH v2 5/6] riscv: lib: move platform-related libraries to sperate folder
nit: separate
Thanks for catching it. Fix it in the next version.
Quoted 29 lines · Zong Li
Quoted 16 lines
Put the platform-related implementation into their own folder respectively. Just leave the common library in the top of lib folder.
Signed-off-by Zong Li <[email protected]>--- arch/riscv/Kconfig | 7 +++++++ arch/riscv/lib/Makefile | 9 ++++----- arch/riscv/lib/andestech/Kconfig | 8 ++++++++ arch/riscv/lib/andestech/Makefile | 7 +++++++ arch/riscv/lib/{ => andestech}/andes_plic.c | 0 arch/riscv/lib/sifive/Kconfig | 8 ++++++++ arch/riscv/lib/sifive/Makefile | 9 +++++++++ arch/riscv/lib/{ => sifive}/sifive_cache.c | 0 arch/riscv/lib/{ => sifive}/sifive_clint.c | 0 9 files changed, 43 insertions(+), 5 deletions(-)Quoted 7 lines
create mode 100644
arch/riscv/lib/andestech/Kconfigcreate mode 100644arch/riscv/lib/andestech/Makefilerenamearch/riscv/lib/{=>andestech}/andes_plic.c(100%) create mode 100644arch/riscv/lib/sifive/Kconfigcreate mode 100644arch/riscv/lib/sifive/Makefilerenamearch/riscv/lib/{=>sifive}/sifive_cache.c(100%) renamearch/riscv/lib/{=>sifive}/sifive_clint.c(100%)NAK from me. I'd much rather see organization by function (e.g. clint/sbi/plic together) than by vendor. Plus, the clint/plic are not really specific to one vendor like ccache.
Quoted 8 lines
Quoted 3 lines
Yes, it makes more sense to me. In this case, there are three functionalities, so I'd like to separate clint, plic and cache at this time, does it make sense to you?
No, it does not. clint and plic should be grouped with SBI because in U-Boot they are all used for IPIs. But frankly, I don't really see the need to place them in subdirectories yet...
Okay, I got it, how about only separate cache into a subdirectory? Or you think that it might be OK to just put all of them in lib/ ?
Quoted 137 lines
--Sean
Quoted 134 lines
Quoted 134 lines
--Sean
Quoted 130 lines
arch/riscv/Kconfig +7
-0@@ -72,6 +72,10 @@ source "arch/riscv/cpu/fu540/Kconfig" source "arch/riscv/cpu/fu740/Kconfig" source "arch/riscv/cpu/generic/Kconfig" +# library-specific options below +source "arch/riscv/lib/sifive/Kconfig" +source "arch/riscv/lib/andestech/Kconfig" + # architecture-specific options below choice@@ -175,18 +179,21 @@ config SIFIVE_CLINT config SPL_SIFIVE_CLINT bool depends on SPL_RISCV_MMODE + select SIFIVE_LIB help The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. config SIFIVE_CACHE bool + select SIFIVE_LIB help This enables the operations to configure SiFive cache config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE + select ANDESTECH_LIB select REGMAP select SYSCON select SPL_REGMAP if SPLarch/riscv/lib/Makefile +4
-5@@ -10,11 +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 -else +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),) obj-$(CONFIG_SBI) += sbi.o obj-$(CONFIG_SBI_IPI) += sbi_ipi.o endif@@ -42,3 +38,6 @@ extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o + +obj-$(CONFIG_SIFIVE_LIB) += sifive/ +obj-$(CONFIG_ANDESTECH_LIB) += andestech/arch/riscv/lib/andestech/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config ANDESTECH_LIB + bool + help + This supports the specific libraries for AndesTech platformsarch/riscv/lib/andestech/Makefile new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_ANDES_PLIC) += andes_plic.o +endifarch/riscv/lib/andestech/andes_plic.c renamed from arch/riscv/lib/andes_plic.c +0
-0arch/riscv/lib/sifive/Kconfig new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +config SIFIVE_LIB + bool + help + This supports the specific libraries for SiFive platformsarch/riscv/lib/sifive/Makefile new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 SiFive, Inc + +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o + +ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) +obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o +endifarch/riscv/lib/sifive/sifive_cache.c renamed from arch/riscv/lib/sifive_cache.c +0
-0arch/riscv/lib/sifive/sifive_clint.c renamed from arch/riscv/lib/sifive_clint.c +0
-0
PATCH v2 6/6 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 );int cache_init (void );/*
Signature · 1 line
2.32.0
Re: [PATCH v2 6/6] riscv: lib: modify the indent
Quoted 13 lines · Zong Li
We usually use a space in function declaration, rather than a tab.
Signed-off-by Zong Li <[email protected]>--- arch/riscv/include/asm/cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/include/asm/cache.h +0
-0
arch/riscv/include/asm/cache.h line 14
Quoted 8 lines
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 );int cache_init (void );/*