diff mbox series

[U-Boot,v2,03/10] board_f: Add reset status printing

Message ID 20180427125227.1026-3-mario.six@gdsys.cc
State Changes Requested
Delegated to: Simon Glass
Headers show
Series [U-Boot,v2,01/10] ram: Add driver for MPC83xx | expand

Commit Message

Mario Six April 27, 2018, 12:52 p.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.

Signed-off-by: Mario Six <mario.six@gdsys.cc>

---

v1 -> v2:
New in v2

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

--
2.16.1

Comments

Simon Glass May 3, 2018, 7:01 p.m. UTC | #1
Hi Mario,

On 27 April 2018 at 06:52, 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.
>
> Signed-off-by: Mario Six <mario.six@gdsys.cc>
>
> ---
>
> v1 -> v2:
> New in v2
>
> ---
>  common/board_f.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

nit below

>
> diff --git a/common/board_f.c b/common/board_f.c
> index ae8bdb7c5c..2df30cd250 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -25,6 +25,7 @@
>  #include <relocate.h>
>  #include <spi.h>
>  #include <status_led.h>
> +#include <sysreset.h>
>  #include <timer.h>
>  #include <trace.h>
>  #include <video.h>
> @@ -141,6 +142,21 @@ static int display_text_info(void)
>         return 0;
>  }
>
> +#ifdef CONFIG_SYSRESET
> +static int print_resetinfo(void)
> +{
> +       struct udevice *dev;
> +       char status[256];
> +
> +       uclass_first_device_err(UCLASS_SYSRESET, &dev);

Should check the result and only call the function below if it is 0.

> +
> +       if (!sysreset_get_status(dev, status, sizeof(status)))
> +               printf("%s", status);
> +
> +       return 0;
> +}
> +#endif
> +

Regards,
Simon
Mario Six May 4, 2018, 8:10 a.m. UTC | #2
Hi Simon,

On Thu, May 3, 2018 at 9:01 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi Mario,
>
> On 27 April 2018 at 06:52, 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.
>>
>> Signed-off-by: Mario Six <mario.six@gdsys.cc>
>>
>> ---
>>
>> v1 -> v2:
>> New in v2
>>
>> ---
>>  common/board_f.c | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> nit below
>
>>
>> diff --git a/common/board_f.c b/common/board_f.c
>> index ae8bdb7c5c..2df30cd250 100644
>> --- a/common/board_f.c
>> +++ b/common/board_f.c
>> @@ -25,6 +25,7 @@
>>  #include <relocate.h>
>>  #include <spi.h>
>>  #include <status_led.h>
>> +#include <sysreset.h>
>>  #include <timer.h>
>>  #include <trace.h>
>>  #include <video.h>
>> @@ -141,6 +142,21 @@ static int display_text_info(void)
>>         return 0;
>>  }
>>
>> +#ifdef CONFIG_SYSRESET
>> +static int print_resetinfo(void)
>> +{
>> +       struct udevice *dev;
>> +       char status[256];
>> +
>> +       uclass_first_device_err(UCLASS_SYSRESET, &dev);
>
> Should check the result and only call the function below if it is 0.
>

Yes, I found that one myself when I tried to run the sandbox tests again.

Will be fixed in v3.

>> +
>> +       if (!sysreset_get_status(dev, status, sizeof(status)))
>> +               printf("%s", status);
>> +
>> +       return 0;
>> +}
>> +#endif
>> +
>
> Regards,
> Simon

Best regards,
Mario
diff mbox series

Patch

diff --git a/common/board_f.c b/common/board_f.c
index ae8bdb7c5c..2df30cd250 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -25,6 +25,7 @@ 
 #include <relocate.h>
 #include <spi.h>
 #include <status_led.h>
+#include <sysreset.h>
 #include <timer.h>
 #include <trace.h>
 #include <video.h>
@@ -141,6 +142,21 @@  static int display_text_info(void)
 	return 0;
 }

+#ifdef CONFIG_SYSRESET
+static int print_resetinfo(void)
+{
+	struct udevice *dev;
+	char status[256];
+
+	uclass_first_device_err(UCLASS_SYSRESET, &dev);
+
+	if (!sysreset_get_status(dev, status, sizeof(status)))
+		printf("%s", status);
+
+	return 0;
+}
+#endif
+
 static int announce_dram_init(void)
 {
 	puts("DRAM:  ");
@@ -789,6 +805,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