From 23471aed5c33e104d6fa64575932577618543bec Mon Sep 17 00:00:00 2001 From: Mario Six Date: Mon, 6 Aug 2018 10:23:34 +0200 Subject: board_f: Add reset status printing 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 Signed-off-by: Mario Six --- common/board_f.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'common') 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 #include #include +#include #include #include #include @@ -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 -- cgit v1.3.1 From 138181a550651efc28f25ddef9cc293792259c45 Mon Sep 17 00:00:00 2001 From: Mario Six Date: Mon, 6 Aug 2018 10:23:39 +0200 Subject: common: board_f: Sort includes Includes should be sorted. Reviewed-by: Simon Glass Signed-off-by: Mario Six --- common/board_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/board_f.c b/common/board_f.c index 3871839a2db..afafec5e4d0 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -11,8 +11,8 @@ #include #include -#include #include +#include #include #include #include -- cgit v1.3.1 From c0434407b595f785fc7401237896c48c791b45fd Mon Sep 17 00:00:00 2001 From: Mario Six Date: Mon, 6 Aug 2018 10:23:41 +0200 Subject: board_f: Use static print_cpuinfo if CONFIG_CPU is active When the DM CPU drivers are active, printing information about a CPU should be delegated to a matching driver. Hence, add a static print_cpuinfo that implements this delegation when DM CPU drivers are active. Reviewed-by: Simon Glass Signed-off-by: Mario Six Changed condition to CONFIG_IS_ENABLED(CPU): Signed-off-by: Simon Glass --- common/board_f.c | 28 ++++++++++++++++++++++++++++ include/init.h | 7 +++++++ 2 files changed, 35 insertions(+) (limited to 'common') diff --git a/common/board_f.c b/common/board_f.c index afafec5e4d0..213d0440667 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -165,6 +166,33 @@ static int print_resetinfo(void) } #endif +#if defined(CONFIG_DISPLAY_CPUINFO) && CONFIG_IS_ENABLED(CPU) +static int print_cpuinfo(void) +{ + struct udevice *dev; + char desc[512]; + int ret; + + ret = uclass_first_device_err(UCLASS_CPU, &dev); + if (ret) { + debug("%s: Could not get CPU device (err = %d)\n", + __func__, ret); + return ret; + } + + ret = cpu_get_desc(dev, desc, sizeof(desc)); + if (ret) { + debug("%s: Could not get CPU description (err = %d)\n", + dev->name, ret); + return ret; + } + + printf("%s", desc); + + return 0; +} +#endif + static int announce_dram_init(void) { puts("DRAM: "); diff --git a/include/init.h b/include/init.h index a58d7a6917f..afc953d51e2 100644 --- a/include/init.h +++ b/include/init.h @@ -109,7 +109,14 @@ int arch_reserve_stacks(void); */ int init_cache_f_r(void); +#if !CONFIG_IS_ENABLED(CPU) +/** + * print_cpuinfo() - Display information about the CPU + * + * Return: 0 if OK, -ve on error + */ int print_cpuinfo(void); +#endif int timer_init(void); int reserve_mmu(void); int misc_init_f(void); -- cgit v1.3.1