[PATCH 34/50] ARM: Rockchip: Make safe for multi-arch

Sascha Hauer s.hauer at pengutronix.de
Fri Mar 3 01:21:15 PST 2023


Make sure Rockchip initcalls are only executed when running on
a Rockchip SoC.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-rockchip/bootm.c    |  4 ++++
 arch/arm/mach-rockchip/rockchip.c | 29 +++++++++++++++++++++++------
 include/mach/rockchip/rockchip.h  |  2 ++
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-rockchip/bootm.c b/arch/arm/mach-rockchip/bootm.c
index 036a3696ad..4317fdefd6 100644
--- a/arch/arm/mach-rockchip/bootm.c
+++ b/arch/arm/mach-rockchip/bootm.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <init.h>
 #include <memory.h>
+#include <mach/rockchip/rockchip.h>
 
 struct newidb_entry {
 	uint32_t sector;
@@ -113,6 +114,9 @@ static struct image_handler image_handler_rkns_barebox_image = {
 
 static int rockchip_register_barebox_image_handler(void)
 {
+	if (rockchip_soc() < 0)
+		return 0;
+
 	return register_image_handler(&image_handler_rkns_barebox_image);
 }
 late_initcall(rockchip_register_barebox_image_handler);
diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c
index 0a89ab1841..e75238481c 100644
--- a/arch/arm/mach-rockchip/rockchip.c
+++ b/arch/arm/mach-rockchip/rockchip.c
@@ -3,18 +3,35 @@
 #include <init.h>
 #include <mach/rockchip/rockchip.h>
 
+static int __rockchip_soc = -1;
+
+int rockchip_soc(void)
+{
+	return __rockchip_soc;
+}
+
 static int rockchip_init(void)
 {
-	if (of_machine_is_compatible("rockchip,rk3188"))
+	if (of_machine_is_compatible("rockchip,rk3188")) {
+		__rockchip_soc = 3188;
 		return rk3188_init();
-	if (of_machine_is_compatible("rockchip,rk3288"))
+	}
+
+	if (of_machine_is_compatible("rockchip,rk3288")) {
+		__rockchip_soc = 3288;
 		return rk3288_init();
-	if (of_machine_is_compatible("rockchip,rk3566"))
+	}
+
+	if (of_machine_is_compatible("rockchip,rk3566")) {
+		__rockchip_soc = 3566;
 		return rk3568_init();
-	if (of_machine_is_compatible("rockchip,rk3568"))
+	}
+
+	if (of_machine_is_compatible("rockchip,rk3568")) {
+		__rockchip_soc = 3568;
 		return rk3568_init();
+	}
 
-	pr_err("Unknown rockchip SoC\n");
-	return -ENODEV;
+	return 0;
 }
 postcore_initcall(rockchip_init);
diff --git a/include/mach/rockchip/rockchip.h b/include/mach/rockchip/rockchip.h
index 16a691ee8c..485526ef53 100644
--- a/include/mach/rockchip/rockchip.h
+++ b/include/mach/rockchip/rockchip.h
@@ -37,4 +37,6 @@ static inline int rk3568_init(void)
 
 void rk3568_lowlevel_init(void);
 
+int rockchip_soc(void);
+
 #endif /* __MACH_ROCKCHIP_H */
-- 
2.30.2




More information about the barebox mailing list