diff mbox series

[U-Boot,v4,05/17] board_f: Add reset status printing

Message ID 20180806082346.21211-5-mario.six@gdsys.cc
State Accepted
Commit 23471aed5c33e104d6fa64575932577618543bec
Delegated to: Simon Glass
Headers show
Series [U-Boot,v4,01/17] ram: Add driver for MPC83xx | expand

Commit Message

Mario Six Aug. 6, 2018, 8:23 a.m. UTC
To print the reset status during boot, add a method print_resetinfo to
board_f, which is called in init_sequence_f[], that gets the reset
information from the sysreset driver (assuming there is only one seems
reasonable), and prints it.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mario Six <mario.six@gdsys.cc>
---

Notes:
    v3 -> v4:
    No changes
    
    v2 -> v3:
    * Improved behavior and error handling
    
    v1 -> v2:
    New in v2

 common/board_f.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Simon Glass Sept. 28, 2018, 3:55 p.m. UTC | #1
On 6 August 2018 at 01:23, Mario Six <mario.six@gdsys.cc> wrote:
> To print the reset status during boot, add a method print_resetinfo to
> board_f, which is called in init_sequence_f[], that gets the reset
> information from the sysreset driver (assuming there is only one seems
> reasonable), and prints it.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Mario Six <mario.six@gdsys.cc>
> ---
>
> Notes:
>     v3 -> v4:
>     No changes
>
>     v2 -> v3:
>     * Improved behavior and error handling
>
>     v1 -> v2:
>     New in v2
>
>  common/board_f.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

Applied to u-boot-dm, and now in mainline, thanks!
diff mbox series

Patch

diff --git a/common/board_f.c b/common/board_f.c
index 88d770071c3..3871839a2db 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -24,6 +24,7 @@ 
 #include <relocate.h>
 #include <spi.h>
 #include <status_led.h>
+#include <sysreset.h>
 #include <timer.h>
 #include <trace.h>
 #include <video.h>
@@ -140,6 +141,30 @@  static int display_text_info(void)
 	return 0;
 }
 
+#ifdef CONFIG_SYSRESET
+static int print_resetinfo(void)
+{
+	struct udevice *dev;
+	char status[256];
+	int ret;
+
+	ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
+	if (ret) {
+		debug("%s: No sysreset device found (error: %d)\n",
+		      __func__, ret);
+		/* Not all boards have sysreset drivers available during early
+		 * boot, so don't fail if one can't be found.
+		 */
+		return 0;
+	}
+
+	if (!sysreset_get_status(dev, status, sizeof(status)))
+		printf("%s", status);
+
+	return 0;
+}
+#endif
+
 static int announce_dram_init(void)
 {
 	puts("DRAM:  ");
@@ -790,6 +815,9 @@  static const init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_PPC) || defined(CONFIG_SH) || defined(CONFIG_X86)
 	checkcpu,
 #endif
+#if defined(CONFIG_SYSRESET)
+	print_resetinfo,
+#endif
 #if defined(CONFIG_DISPLAY_CPUINFO)
 	print_cpuinfo,		/* display cpu info (and speed) */
 #endif