[PATCH v2 4/6] riscv: sifive: use common cache_init instead of duplicated implementation

Zong Li zong.li at sifive.com
Tue Aug 3 06:44:42 CEST 2021


We already extracted the duplicated implementation to common code, so
change to use that and drop the original implementation.

Signed-off-by: Zong Li <zong.li at sifive.com>
---
 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

diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig
index 8608741779..1604b412b4 100644
--- a/arch/riscv/cpu/fu540/Kconfig
+++ b/arch/riscv/cpu/fu540/Kconfig
@@ -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
diff --git a/arch/riscv/cpu/fu540/Makefile b/arch/riscv/cpu/fu540/Makefile
index 088205ef57..043fb961a5 100644
--- a/arch/riscv/cpu/fu540/Makefile
+++ b/arch/riscv/cpu/fu540/Makefile
@@ -8,5 +8,4 @@ obj-y += spl.o
 else
 obj-y += dram.o
 obj-y += cpu.o
-obj-y += cache.o
 endif
diff --git a/arch/riscv/cpu/fu540/cache.c b/arch/riscv/cpu/fu540/cache.c
deleted file mode 100644
index bc31f664b8..0000000000
--- a/arch/riscv/cpu/fu540/cache.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020 - 2021 SiFive, Inc
- *
- * Authors:
- *   Pragnesh Patel <pragnesh.patel at sifive.com>
- */
-
-#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;
-}
diff --git a/arch/riscv/cpu/fu740/Kconfig b/arch/riscv/cpu/fu740/Kconfig
index b4cada0ea9..049a0a0584 100644
--- a/arch/riscv/cpu/fu740/Kconfig
+++ b/arch/riscv/cpu/fu740/Kconfig
@@ -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
diff --git a/arch/riscv/cpu/fu740/Makefile b/arch/riscv/cpu/fu740/Makefile
index 5ef8ac18a7..1d1ad98ba7 100644
--- a/arch/riscv/cpu/fu740/Makefile
+++ b/arch/riscv/cpu/fu740/Makefile
@@ -8,5 +8,4 @@ obj-y += spl.o
 else
 obj-y += dram.o
 obj-y += cpu.o
-obj-y += cache.o
 endif
diff --git a/arch/riscv/cpu/fu740/cache.c b/arch/riscv/cpu/fu740/cache.c
deleted file mode 100644
index e2782d76c0..0000000000
--- a/arch/riscv/cpu/fu740/cache.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020-2021 SiFive, Inc
- *
- * Authors:
- *   Pragnesh Patel <pragnesh.patel at sifive.com>
- */
-
-#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;
-}
diff --git a/arch/riscv/include/asm/arch-fu540/cache.h b/arch/riscv/include/asm/arch-fu540/cache.h
deleted file mode 100644
index c252eb64d1..0000000000
--- a/arch/riscv/include/asm/arch-fu540/cache.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2020 SiFive, Inc.
- *
- * Authors:
- *   Pragnesh Patel <pragnesh.patel at sifve.com>
- */
-
-#ifndef _CACHE_SIFIVE_H
-#define _CACHE_SIFIVE_H
-
-int sifive_ccache_enable_ways(void);
-
-#endif /* _CACHE_SIFIVE_H */
diff --git a/arch/riscv/include/asm/arch-fu740/cache.h b/arch/riscv/include/asm/arch-fu740/cache.h
deleted file mode 100644
index 8c456e3658..0000000000
--- a/arch/riscv/include/asm/arch-fu740/cache.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2020-2021 SiFive, Inc.
- *
- * Authors:
- *   Pragnesh Patel <pragnesh.patel at sifve.com>
- */
-
-#ifndef _CACHE_SIFIVE_H
-#define _CACHE_SIFIVE_H
-
-int sifive_ccache_enable_ways(void);
-
-#endif /* _CACHE_SIFIVE_H */
diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c
index 12e61ec85f..6d697d797d 100644
--- a/board/sifive/unleashed/unleashed.c
+++ b/board/sifive/unleashed/unleashed.c
@@ -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();
 }
diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
index d27c4d3e88..f4fc2a793d 100644
--- a/board/sifive/unmatched/unmatched.c
+++ b/board/sifive/unmatched/unmatched.c
@@ -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();
 }
-- 
2.32.0



More information about the U-Boot mailing list