From: Alexander Sverdlin <[email protected]>

Make TI K3 get_reset_reason() a model for other SoCs/platforms by providing
a weak global function. It will be used to populate /chosen/reset-reason
property in the FDT.

No change in behaviour expected.

Signed-off-by: Alexander Sverdlin <[email protected]>
---
 arch/arm/mach-k3/am62x/boot.c            |  1 +
 arch/arm/mach-k3/am64x/boot.c            |  1 +
 arch/arm/mach-k3/common.c                |  5 -----
 arch/arm/mach-k3/include/mach/hardware.h |  1 -
 common/board_info.c                      |  5 +++++
 include/init.h                           | 11 +++++++++++
 6 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-k3/am62x/boot.c b/arch/arm/mach-k3/am62x/boot.c
index bae53f1e459..8c46532113a 100644
--- a/arch/arm/mach-k3/am62x/boot.c
+++ b/arch/arm/mach-k3/am62x/boot.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include <init.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
diff --git a/arch/arm/mach-k3/am64x/boot.c b/arch/arm/mach-k3/am64x/boot.c
index a5a6fe2659c..e9677d63471 100644
--- a/arch/arm/mach-k3/am64x/boot.c
+++ b/arch/arm/mach-k3/am64x/boot.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include <init.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index b0a75988714..87ed134fcb9 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -212,11 +212,6 @@ static const char *get_device_type_name(void)
        }
 }
 
-__weak const char *get_reset_reason(void)
-{
-       return NULL;
-}
-
 int print_cpuinfo(void)
 {
        struct udevice *soc;
diff --git a/arch/arm/mach-k3/include/mach/hardware.h 
b/arch/arm/mach-k3/include/mach/hardware.h
index 81b5f1fa45e..fc7bee4d00b 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -125,5 +125,4 @@ struct rom_extended_boot_data {
 };
 
 u32 get_boot_device(void);
-const char *get_reset_reason(void);
 #endif /* _ASM_ARCH_HARDWARE_H_ */
diff --git a/common/board_info.c b/common/board_info.c
index dc26e1a33dd..e76d4cbbc2f 100644
--- a/common/board_info.c
+++ b/common/board_info.c
@@ -14,6 +14,11 @@ int __weak checkboard(void)
        return 0;
 }
 
+__weak const char *get_reset_reason(void)
+{
+       return NULL;
+}
+
 static const struct to_show {
        const char *name;
        enum sysinfo_id id;
diff --git a/include/init.h b/include/init.h
index c31ebd83b85..3ee35130268 100644
--- a/include/init.h
+++ b/include/init.h
@@ -238,6 +238,17 @@ int init_cache_f_r(void);
  */
 int print_cpuinfo(void);
 #endif
+
+/**
+ * get_reset_reason() - return a string describing the reset cause
+ *
+ * Platforms can override this weak function to provide the actual
+ * reset reason.
+ *
+ * Return: reason string, or NULL if unknown/unsupported
+ */
+const char *get_reset_reason(void);
+
 int timer_init(void);
 
 #if defined(CONFIG_DTB_RESELECT)
-- 
2.52.0

Reply via email to