[PATCH 0/9] sysinfo: Expand sysinfo with some more banner information

The show_board_info() function was adjusted to weak so that it could be entirely replaced with a board-specific implementation.
The intended way for boards to provide their own information is via a sysinfo driver. But currently there is no way to show anything other than the model name.
This series adds support for showing a few more items, in a way that is easy for boards to extend.
Since there is already a weak checkboard() function, we don't need to have two levels of weak function here. So this series drops the weak attribute from show_board_info()
Existing boards will see a slight change in output, in that the model name will appear first, before any custom output. If that is a problem, then the solution is to implement a sysinfo driver for the board.
Simon Glass (9): board: Move show_board_info() comment to header file meson: Use checkboard() instead of show_board_info() turris: Use checkboard() instead of show_board_info() solidrun: Use checkboard() instead of show_board_info() toradex: Use checkboard() instead of show_board_info() udoo: Use checkboard() instead of show_board_info() Revert "generic-board: make show_board_info a weak function" sysinfo: Allow displaying more info on startup x86: coreboot: Add a sysinfo driver
arch/arm/mach-meson/board-info.c | 2 +- arch/x86/cpu/coreboot/Kconfig | 2 + arch/x86/dts/coreboot.dts | 4 + board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- board/coreboot/coreboot/Makefile | 1 + board/coreboot/coreboot/coreboot.c | 44 --------- board/coreboot/coreboot/sysinfo.c | 89 +++++++++++++++++++ board/solidrun/mx6cuboxi/mx6cuboxi.c | 7 +- board/toradex/apalis-imx8/apalis-imx8.c | 2 +- board/toradex/apalis-tk1/apalis-tk1.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 3 +- board/toradex/apalis_t30/apalis_t30.c | 2 +- .../toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri-imx8x/colibri-imx8x.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 3 +- board/toradex/colibri_imx7/colibri_imx7.c | 2 +- board/toradex/colibri_t20/colibri_t20.c | 2 +- board/toradex/colibri_t30/colibri_t30.c | 2 +- board/toradex/colibri_vf/colibri_vf.c | 2 +- board/toradex/common/tdx-common.c | 2 +- board/toradex/common/tdx-common.h | 1 + board/udoo/neo/neo.c | 2 +- common/board_info.c | 80 +++++++++++------ drivers/sysinfo/Kconfig | 7 ++ include/init.h | 11 +++ include/sysinfo.h | 3 + 27 files changed, 189 insertions(+), 94 deletions(-) create mode 100644 board/coreboot/coreboot/sysinfo.c

Move this comment to its prototype and tidy it up a bit.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/board_info.c | 6 ------ include/init.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/common/board_info.c b/common/board_info.c index e0f2d9392204..3185793da4a7 100644 --- a/common/board_info.c +++ b/common/board_info.c @@ -15,12 +15,6 @@ int __weak checkboard(void) return 0; }
-/* - * Check sysinfo for board information. Failing that if the root node of the DTB - * has a "model" property, show it. - * - * Then call checkboard(). - */ int __weak show_board_info(void) { if (IS_ENABLED(CONFIG_OF_CONTROL)) { diff --git a/include/init.h b/include/init.h index d57a24fd00dd..9a1951d10a01 100644 --- a/include/init.h +++ b/include/init.h @@ -292,6 +292,17 @@ int misc_init_r(void);
/* common/board_info.c */ int checkboard(void); + +/** + * show_board_info() - Show board information + * + * Check sysinfo for board information. Failing that if the root node of the DTB + * has a "model" property, show it. + * + * Then call checkboard(). + * + * Return 0 if OK, -ve on error + */ int show_board_info(void);
/**

On Sun, Nov 12, 2023 at 07:58:21PM -0700, Simon Glass wrote:
Move this comment to its prototype and tidy it up a bit.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Tom Rini trini@konsulko.com

Boards can use a sysinfo driver if a particular model name is needed. Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/mach-meson/board-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c index 2421acd817e4..95a29da07229 100644 --- a/arch/arm/mach-meson/board-info.c +++ b/arch/arm/mach-meson/board-info.c @@ -168,7 +168,7 @@ static unsigned int get_socinfo(void) return socinfo; }
-int show_board_info(void) +int checkboard(void) { unsigned int socinfo;

On 13/11/2023 03:58, Simon Glass wrote:
Boards can use a sysinfo driver if a particular model name is needed. Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/mach-meson/board-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c index 2421acd817e4..95a29da07229 100644 --- a/arch/arm/mach-meson/board-info.c +++ b/arch/arm/mach-meson/board-info.c @@ -168,7 +168,7 @@ static unsigned int get_socinfo(void) return socinfo; }
-int show_board_info(void) +int checkboard(void) { unsigned int socinfo;
Reviewed-by: Neil Armstrong neil.armstrong@linaro.org

Boards can use a sysinfo driver if a particular model name is needed. Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Signed-off-by: Simon Glass sjg@chromium.org ---
board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/CZ.NIC/turris_omnia/turris_omnia.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 63b869921943..3489bdd74bda 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -562,7 +562,7 @@ static void handle_reset_button(void) } }
-int show_board_info(void) +int checkboard(void) { int i, ret, board_version, ram_size, is_sd; const char *pub_key, *model; diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index 19c5043fcbaa..adeb69a205be 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -962,7 +962,7 @@ int board_late_init(void) return 0; }
-int show_board_info(void) +int checkboard(void) { char serial[17]; int err;

Boards can use a sysinfo driver if a particular model name is needed. Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Signed-off-by: Simon Glass sjg@chromium.org ---
board/solidrun/mx6cuboxi/mx6cuboxi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c index e119330bc0c1..8edabf4404c2 100644 --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c @@ -381,6 +381,7 @@ static bool has_emmc(void) return (mmc_get_op_cond(mmc, true) < 0) ? 0 : 1; }
+/* Override the default implementation, DT model is not accurate */ int checkboard(void) { request_detect_gpios(); @@ -496,12 +497,6 @@ int ft_board_setup(void *fdt, struct bd_info *bd) } #endif
-/* Override the default implementation, DT model is not accurate */ -int show_board_info(void) -{ - return checkboard(); -} - int board_late_init(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG

Boards can use a sysinfo driver if a particular model name is needed. Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Make all the checkboard() functions call the new tdx_checkboard() so that the same information is displayed.
Signed-off-by: Simon Glass sjg@chromium.org ---
board/toradex/apalis-imx8/apalis-imx8.c | 2 +- board/toradex/apalis-tk1/apalis-tk1.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 3 ++- board/toradex/apalis_t30/apalis_t30.c | 2 +- board/toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri-imx8x/colibri-imx8x.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 3 ++- board/toradex/colibri_imx7/colibri_imx7.c | 2 +- board/toradex/colibri_t20/colibri_t20.c | 2 +- board/toradex/colibri_t30/colibri_t30.c | 2 +- board/toradex/colibri_vf/colibri_vf.c | 2 +- board/toradex/common/tdx-common.c | 2 +- board/toradex/common/tdx-common.h | 1 + 13 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/board/toradex/apalis-imx8/apalis-imx8.c b/board/toradex/apalis-imx8/apalis-imx8.c index e2bbaba8b8c1..b351ce64abfc 100644 --- a/board/toradex/apalis-imx8/apalis-imx8.c +++ b/board/toradex/apalis-imx8/apalis-imx8.c @@ -215,7 +215,7 @@ int checkboard(void) build_info(); print_bootinfo();
- return 0; + return tdx_checkboard(); }
static enum pcb_rev_t get_pcb_revision(void) diff --git a/board/toradex/apalis-tk1/apalis-tk1.c b/board/toradex/apalis-tk1/apalis-tk1.c index 851343159186..79a1c92da0a0 100644 --- a/board/toradex/apalis-tk1/apalis-tk1.c +++ b/board/toradex/apalis-tk1/apalis-tk1.c @@ -95,7 +95,7 @@ int checkboard(void) { puts("Model: Toradex Apalis TK1 2GB\n");
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/apalis_imx6/apalis_imx6.c b/board/toradex/apalis_imx6/apalis_imx6.c index fa6b7226fedf..dc0e09991dde 100644 --- a/board/toradex/apalis_imx6/apalis_imx6.c +++ b/board/toradex/apalis_imx6/apalis_imx6.c @@ -730,7 +730,8 @@ int checkboard(void) is_cpu_type(MXC_CPU_MX6D) ? "Dual" : "Quad", (gd->ram_size == 0x80000000) ? "2GB" : (gd->ram_size == 0x40000000) ? "1GB" : "512MB", it); - return 0; + + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/apalis_t30/apalis_t30.c b/board/toradex/apalis_t30/apalis_t30.c index ef71270d9f2d..b9a2af33f19f 100644 --- a/board/toradex/apalis_t30/apalis_t30.c +++ b/board/toradex/apalis_t30/apalis_t30.c @@ -50,7 +50,7 @@ int checkboard(void) printf("Model: Toradex Apalis T30 %dGB\n", (gd->ram_size == 0x40000000) ? 1 : 2);
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/colibri-imx6ull/colibri-imx6ull.c b/board/toradex/colibri-imx6ull/colibri-imx6ull.c index 48fdb1e09712..6c8eeff38fa5 100644 --- a/board/toradex/colibri-imx6ull/colibri-imx6ull.c +++ b/board/toradex/colibri-imx6ull/colibri-imx6ull.c @@ -206,7 +206,7 @@ int checkboard(void) { printf("Model: Toradex Colibri iMX6ULL\n");
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c b/board/toradex/colibri-imx8x/colibri-imx8x.c index 6c0b09787c8b..d8cc72f323c5 100644 --- a/board/toradex/colibri-imx8x/colibri-imx8x.c +++ b/board/toradex/colibri-imx8x/colibri-imx8x.c @@ -121,7 +121,7 @@ int checkboard(void) build_info(); print_bootinfo();
- return 0; + return tdx_checkboard(); }
static void select_dt_from_module_version(void) diff --git a/board/toradex/colibri_imx6/colibri_imx6.c b/board/toradex/colibri_imx6/colibri_imx6.c index e6c9b10570d1..7635c5811d26 100644 --- a/board/toradex/colibri_imx6/colibri_imx6.c +++ b/board/toradex/colibri_imx6/colibri_imx6.c @@ -649,7 +649,8 @@ int checkboard(void) printf("Model: Toradex Colibri iMX6 %s %sMB%s\n", is_cpu_type(MXC_CPU_MX6DL) ? "DualLite" : "Solo", (gd->ram_size == 0x20000000) ? "512" : "256", it); - return 0; + + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c index f0356af0082b..c3478b15111b 100644 --- a/board/toradex/colibri_imx7/colibri_imx7.c +++ b/board/toradex/colibri_imx7/colibri_imx7.c @@ -279,7 +279,7 @@ int checkboard(void) printf("Model: Toradex Colibri iMX7%c\n", is_cpu_type(MXC_CPU_MX7D) ? 'D' : 'S');
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index 1df9697b97ce..5861cf7dc93e 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -77,7 +77,7 @@ int checkboard(void) (get_nand_dev_by_index(0)->erasesize >> 10 == 512) ? ((gd->ram_size == 0x10000000) ? "1.1B" : "1.1C") : "1.2A");
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/colibri_t30/colibri_t30.c b/board/toradex/colibri_t30/colibri_t30.c index b6b004669c26..8cef098c8e59 100644 --- a/board/toradex/colibri_t30/colibri_t30.c +++ b/board/toradex/colibri_t30/colibri_t30.c @@ -32,7 +32,7 @@ int checkboard(void) { puts("Model: Toradex Colibri T30 1GB\n");
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c index dcef2db360a3..af9f2d379cf4 100644 --- a/board/toradex/colibri_vf/colibri_vf.c +++ b/board/toradex/colibri_vf/colibri_vf.c @@ -373,7 +373,7 @@ int checkboard(void) else puts("Model: Toradex Colibri VF50\n");
- return 0; + return tdx_checkboard(); }
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c index d1449143977b..ed8f0a6a4756 100644 --- a/board/toradex/common/tdx-common.c +++ b/board/toradex/common/tdx-common.c @@ -96,7 +96,7 @@ static const char *get_board_assembly(u16 ver_assembly) return ver_name; }
-int show_board_info(void) +int tdx_checkboard(void) { unsigned char ethaddr[6];
diff --git a/board/toradex/common/tdx-common.h b/board/toradex/common/tdx-common.h index d446e9f1d5ca..44234dc49cd7 100644 --- a/board/toradex/common/tdx-common.h +++ b/board/toradex/common/tdx-common.h @@ -11,5 +11,6 @@
int ft_common_board_setup(void *blob, struct bd_info *bd); u32 get_board_revision(void); +int tdx_checkboard(void);
#endif /* _TDX_COMMON_H */

Hi Simon
Sorry, I missed this one, also due to a longer Xmas/New Year and later skiing vacation.
On Sun, 2023-11-12 at 19:58 -0700, Simon Glass wrote:
Boards can use a sysinfo driver if a particular model name is needed.
Okay, but so far we did print more than just a model name:
On Apalis/Colibri:
Model: Toradex 0028 Apalis iMX6Q 2GB IT V1.1D Serial#: 10867499
On Verdin:
Model: Toradex 0058 Verdin iMX8M Plus Quad 4GB WB IT V1.1A Serial#: 14772913 Carrier: Toradex Dahlia V1.1A, Serial# 10870316
Optionally there would even be display adapters with potentially more model (serial) information.
Now with your change we get the following:
On Apalis/Colibri:
Model: Toradex Apalis iMX6Q/D Module on Apalis Evaluation Board Model: Toradex Apalis iMX6 Quad 2GB IT Model: Toradex 0028 Apalis iMX6Q 2GB IT V1.1D Serial#: 11211073
The first line gets printed from the information in the device tree, the second Line from the fall-back in our board file (which so far was only used for the case when we failed reading the ConfigBlock) and the third and fourth lines are the previous information. Ugly, but so far so good.
On Verdin:
Model: Toradex Verdin iMX8M Plus WB on Verdin Development Board
Here only the device tree information gets printed and the ConfigBlock is not even read at all which subsequently fails detecting the variant (e.g. Wi-Fi vs. non-Wi-Fi) and later Ethernet fails due to an invalid MAC address. This does not look good...
Anyway, I don't propose to just revert your work but instead looked into converting our previous show_board_info (now tdx_checkboard) to a proper sysinfo driver. The basics actually worked quite smoothly but we would need more than just SYSINFO_ID_BOARD_MODEL, just like you do with CONFIG_SYSINFO_EXTRA. Of course, I could just do a CONFIG_SYSINFO_TORADEX, with e.g. SYSINFO_ID_BOARD_SERIAL and optionally SYSINFO_ID_BOARD_CARRIER or something but maybe a more generic way of extending sysinfo would make more sense.
What do you think?
Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Unfortunately, as mentioned above, this does not quite lead to any desired behaviour.
Make all the checkboard() functions call the new tdx_checkboard() so that the same information is displayed.
Not quite.
Signed-off-by: Simon Glass sjg@chromium.org
board/toradex/apalis-imx8/apalis-imx8.c | 2 +- board/toradex/apalis-tk1/apalis-tk1.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 3 ++- board/toradex/apalis_t30/apalis_t30.c | 2 +- board/toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri-imx8x/colibri-imx8x.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 3 ++- board/toradex/colibri_imx7/colibri_imx7.c | 2 +- board/toradex/colibri_t20/colibri_t20.c | 2 +- board/toradex/colibri_t30/colibri_t30.c | 2 +- board/toradex/colibri_vf/colibri_vf.c | 2 +- board/toradex/common/tdx-common.c | 2 +- board/toradex/common/tdx-common.h | 1 + 13 files changed, 15 insertions(+), 12 deletions(-)
[snip]
Cheers
Marcel

Gentle ping on this. Any opinion on that matter much appreciated. Thanks!
On Wed, 2024-01-24 at 18:16 +0100, Marcel Ziswiler wrote:
Hi Simon
Sorry, I missed this one, also due to a longer Xmas/New Year and later skiing vacation.
On Sun, 2023-11-12 at 19:58 -0700, Simon Glass wrote:
Boards can use a sysinfo driver if a particular model name is needed.
Okay, but so far we did print more than just a model name:
On Apalis/Colibri:
Model: Toradex 0028 Apalis iMX6Q 2GB IT V1.1D Serial#: 10867499
On Verdin:
Model: Toradex 0058 Verdin iMX8M Plus Quad 4GB WB IT V1.1A Serial#: 14772913 Carrier: Toradex Dahlia V1.1A, Serial# 10870316
Optionally there would even be display adapters with potentially more model (serial) information.
Now with your change we get the following:
On Apalis/Colibri:
Model: Toradex Apalis iMX6Q/D Module on Apalis Evaluation Board Model: Toradex Apalis iMX6 Quad 2GB IT Model: Toradex 0028 Apalis iMX6Q 2GB IT V1.1D Serial#: 11211073
The first line gets printed from the information in the device tree, the second Line from the fall-back in our board file (which so far was only used for the case when we failed reading the ConfigBlock) and the third and fourth lines are the previous information. Ugly, but so far so good.
On Verdin:
Model: Toradex Verdin iMX8M Plus WB on Verdin Development Board
Here only the device tree information gets printed and the ConfigBlock is not even read at all which subsequently fails detecting the variant (e.g. Wi-Fi vs. non-Wi-Fi) and later Ethernet fails due to an invalid MAC address. This does not look good...
Anyway, I don't propose to just revert your work but instead looked into converting our previous show_board_info (now tdx_checkboard) to a proper sysinfo driver. The basics actually worked quite smoothly but we would need more than just SYSINFO_ID_BOARD_MODEL, just like you do with CONFIG_SYSINFO_EXTRA. Of course, I could just do a CONFIG_SYSINFO_TORADEX, with e.g. SYSINFO_ID_BOARD_SERIAL and optionally SYSINFO_ID_BOARD_CARRIER or something but maybe a more generic way of extending sysinfo would make more sense.
What do you think?
Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Unfortunately, as mentioned above, this does not quite lead to any desired behaviour.
Make all the checkboard() functions call the new tdx_checkboard() so that the same information is displayed.
Not quite.
Signed-off-by: Simon Glass sjg@chromium.org
board/toradex/apalis-imx8/apalis-imx8.c | 2 +- board/toradex/apalis-tk1/apalis-tk1.c | 2 +- board/toradex/apalis_imx6/apalis_imx6.c | 3 ++- board/toradex/apalis_t30/apalis_t30.c | 2 +- board/toradex/colibri-imx6ull/colibri-imx6ull.c | 2 +- board/toradex/colibri-imx8x/colibri-imx8x.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 3 ++- board/toradex/colibri_imx7/colibri_imx7.c | 2 +- board/toradex/colibri_t20/colibri_t20.c | 2 +- board/toradex/colibri_t30/colibri_t30.c | 2 +- board/toradex/colibri_vf/colibri_vf.c | 2 +- board/toradex/common/tdx-common.c | 2 +- board/toradex/common/tdx-common.h | 1 + 13 files changed, 15 insertions(+), 12 deletions(-)
[snip]
Cheers
Marcel

On Wed, Feb 07, 2024 at 03:23:10PM +0000, Marcel Ziswiler wrote:
Gentle ping on this. Any opinion on that matter much appreciated. Thanks!
Perhaps you need to RFC some sysinfo driver that ends up providing what you expect?

Boards can use a sysinfo driver if a particular model name is needed. Update this board to use checkboard() directly, rather than having a weak function laid on top of a weak function.
Signed-off-by: Simon Glass sjg@chromium.org ---
board/udoo/neo/neo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/udoo/neo/neo.c b/board/udoo/neo/neo.c index 730e266469b2..d99d93b44ae5 100644 --- a/board/udoo/neo/neo.c +++ b/board/udoo/neo/neo.c @@ -212,7 +212,7 @@ static char *board_string(int type) }
/* Override the default implementation, DT model is not accurate */ -int show_board_info(void) +int checkboard(void) { int *board_type = (int *)OCRAM_START;

We already have:
- a sysinfo driver-interface which can obtain the model - a weak function called checkboard() for showing board info
The current implementation has a weak function on top of a weak function. Now that all boards have been updated to use checkboard() instead, drop the __weak on show_board_info()
This reverts commit f7637cc01414b9c87b6b0f861f34d83c19bfaaaf.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/board_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/board_info.c b/common/board_info.c index 3185793da4a7..a62c04794b90 100644 --- a/common/board_info.c +++ b/common/board_info.c @@ -15,7 +15,7 @@ int __weak checkboard(void) return 0; }
-int __weak show_board_info(void) +int show_board_info(void) { if (IS_ENABLED(CONFIG_OF_CONTROL)) { struct udevice *dev;

On Sun, Nov 12, 2023 at 07:58:27PM -0700, Simon Glass wrote:
We already have:
- a sysinfo driver-interface which can obtain the model
- a weak function called checkboard() for showing board info
The current implementation has a weak function on top of a weak function. Now that all boards have been updated to use checkboard() instead, drop the __weak on show_board_info()
This reverts commit f7637cc01414b9c87b6b0f861f34d83c19bfaaaf.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Tom Rini trini@konsulko.com

At present only the model name is shown on start. Some boards want to display more information. Add some more options to allow display of the manufacturer as well as the version and date of any prior-stage firmware.
This is useful for coreboot, at least. If other boards have more information to display, it is easy to add it, now.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/board_info.c | 72 +++++++++++++++++++++++++++++------------ drivers/sysinfo/Kconfig | 7 ++++ include/sysinfo.h | 3 ++ 3 files changed, 61 insertions(+), 21 deletions(-)
diff --git a/common/board_info.c b/common/board_info.c index a62c04794b90..f4c385add90c 100644 --- a/common/board_info.c +++ b/common/board_info.c @@ -15,35 +15,65 @@ int __weak checkboard(void) return 0; }
+static const struct to_show { + const char *name; + enum sysinfo_id id; +} to_show[] = { + { "Manufacturer", SYSINFO_ID_BOARD_MANUFACTURER}, + { "Prior-stage version", SYSINFO_ID_PRIOR_STAGE_VERSION }, + { "Prior-stage date", SYSINFO_ID_PRIOR_STAGE_DATE }, + { /* sentinel */ } +}; + +static int try_sysinfo(void) +{ + struct udevice *dev; + char str[80]; + int ret; + + /* This might provide more detail */ + ret = sysinfo_get(&dev); + if (ret) + return ret; + + ret = sysinfo_detect(dev); + if (ret) + return ret; + + ret = sysinfo_get_str(dev, SYSINFO_ID_BOARD_MODEL, sizeof(str), str); + if (ret) + return ret; + printf("Model: %s\n", str); + + if (IS_ENABLED(CONFIG_SYSINFO_EXTRA)) { + const struct to_show *item; + + for (item = to_show; item->id; item++) { + ret = sysinfo_get_str(dev, item->id, sizeof(str), str); + if (!ret) + printf("%s: %s\n", item->name, str); + } + } + + return 0; +} + int show_board_info(void) { if (IS_ENABLED(CONFIG_OF_CONTROL)) { - struct udevice *dev; - const char *model; - char str[80]; int ret = -ENOSYS;
- if (IS_ENABLED(CONFIG_SYSINFO)) { - /* This might provide more detail */ - ret = sysinfo_get(&dev); - if (!ret) { - ret = sysinfo_detect(dev); - if (!ret) { - ret = sysinfo_get_str(dev, - SYSINFO_ID_BOARD_MODEL, - sizeof(str), str); - } - } - } + if (IS_ENABLED(CONFIG_SYSINFO)) + ret = try_sysinfo();
/* Fail back to the main 'model' if available */ - if (ret) - model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); - else - model = str; + if (ret) { + const char *model;
- if (model) - printf("Model: %s\n", model); + model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); + if (model) + printf("Model: %s\n", model); + } }
return checkboard(); diff --git a/drivers/sysinfo/Kconfig b/drivers/sysinfo/Kconfig index e35f7cb17914..2030e4babc9f 100644 --- a/drivers/sysinfo/Kconfig +++ b/drivers/sysinfo/Kconfig @@ -8,6 +8,13 @@ menuconfig SYSINFO
if SYSINFO
+config SYSINFO_EXTRA + bool "Show extra information on startup" + help + Enable this to see extra information on startup. Normally only the + model is shown, but with this option the vendor and any prior-stage + firmware's version and date are shown as well. + config SPL_SYSINFO depends on SPL_DM bool "Enable board driver support in SPL" diff --git a/include/sysinfo.h b/include/sysinfo.h index b140d742e93d..f2c1aa29d18e 100644 --- a/include/sysinfo.h +++ b/include/sysinfo.h @@ -46,6 +46,9 @@ enum sysinfo_id {
/* For show_board_info() */ SYSINFO_ID_BOARD_MODEL, + SYSINFO_ID_BOARD_MANUFACTURER, + SYSINFO_ID_PRIOR_STAGE_VERSION, + SYSINFO_ID_PRIOR_STAGE_DATE,
/* First value available for downstream/board used */ SYSINFO_ID_USER = 0x1000,

Create a sysinfo driver to avoid needing a custom checkboard() function. With this the following information is printed when booting from coreboot under QEMU:
Model: Standard PC (i440FX + PIIX, 1996) Manufacturer: QEMU Prior-stage version: 4.21-885-g2a87ef1eca56 Prior-stage date: 11/11/2023
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/cpu/coreboot/Kconfig | 2 + arch/x86/dts/coreboot.dts | 4 ++ board/coreboot/coreboot/Makefile | 1 + board/coreboot/coreboot/coreboot.c | 44 --------------- board/coreboot/coreboot/sysinfo.c | 89 ++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 44 deletions(-) create mode 100644 board/coreboot/coreboot/sysinfo.c
diff --git a/arch/x86/cpu/coreboot/Kconfig b/arch/x86/cpu/coreboot/Kconfig index 178f8ad18162..085302c04829 100644 --- a/arch/x86/cpu/coreboot/Kconfig +++ b/arch/x86/cpu/coreboot/Kconfig @@ -27,5 +27,7 @@ config SYS_COREBOOT imply X86_TSC_READ_BASE imply USE_PREBOOT select BINMAN if X86_64 + select SYSINFO + imply SYSINFO_EXTRA
endif diff --git a/arch/x86/dts/coreboot.dts b/arch/x86/dts/coreboot.dts index 0eb31cae42c1..dfce7c2d5919 100644 --- a/arch/x86/dts/coreboot.dts +++ b/arch/x86/dts/coreboot.dts @@ -45,4 +45,8 @@ bootph-some-ram; compatible = "coreboot-fb"; }; + + sysinfo { + compatible = "coreboot,sysinfo"; + }; }; diff --git a/board/coreboot/coreboot/Makefile b/board/coreboot/coreboot/Makefile index d292b7032c23..75bfbd189437 100644 --- a/board/coreboot/coreboot/Makefile +++ b/board/coreboot/coreboot/Makefile @@ -11,3 +11,4 @@ # Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
obj-y += coreboot.o +obj-$(CONFIG_$(SPL_TPL_)SMBIOS_PARSER) += sysinfo.o diff --git a/board/coreboot/coreboot/coreboot.c b/board/coreboot/coreboot/coreboot.c index db855c11ae65..e58dce37477f 100644 --- a/board/coreboot/coreboot/coreboot.c +++ b/board/coreboot/coreboot/coreboot.c @@ -23,50 +23,6 @@ int board_early_init_r(void) return 0; }
-#ifdef CONFIG_SMBIOS_PARSER -int show_board_info(void) -{ - const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size); - - if (!smbios) - goto fallback; - - const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION); - const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION); - const struct smbios_type0 *t0 = (struct smbios_type0 *)bios; - const struct smbios_type1 *t1 = (struct smbios_type1 *)system; - - if (!t0 || !t1) - goto fallback; - - const char *bios_ver = smbios_string(bios, t0->bios_ver); - const char *bios_date = smbios_string(bios, t0->bios_release_date); - const char *model = smbios_string(system, t1->product_name); - const char *manufacturer = smbios_string(system, t1->manufacturer); - - if (!model || !manufacturer || !bios_ver) - goto fallback; - - printf("Vendor: %s\n", manufacturer); - printf("Model: %s\n", model); - printf("BIOS Version: %s\n", bios_ver); - if (bios_date) - printf("BIOS date: %s\n", bios_date); - - return 0; - -fallback: - if (IS_ENABLED(CONFIG_OF_CONTROL)) { - model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); - - if (model) - printf("Model: %s\n", model); - } - - return checkboard(); -} -#endif - static struct splash_location coreboot_splash_locations[] = { { .name = "virtio_fs", diff --git a/board/coreboot/coreboot/sysinfo.c b/board/coreboot/coreboot/sysinfo.c new file mode 100644 index 000000000000..e0bdc7a5a88e --- /dev/null +++ b/board/coreboot/coreboot/sysinfo.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * coreboot sysinfo driver + * + * Copyright 2023 Google LLC + * Written by Simon Glass sjg@chromium.org + */ + +#include <dm.h> +#include <smbios.h> +#include <sysinfo.h> +#include <asm/cb_sysinfo.h> + +struct cb_sysinfo_priv { + const struct smbios_header *bios; + const struct smbios_header *system; + const struct smbios_type0 *t0; + const struct smbios_type1 *t1; +}; + +static int cb_get_str(struct udevice *dev, int id, size_t size, char *val) +{ + struct cb_sysinfo_priv *priv = dev_get_priv(dev); + const char *str = NULL; + + switch (id) { + case SYSINFO_ID_BOARD_MODEL: + if (priv->t1) + str = smbios_string(priv->system, + priv->t1->product_name); + break; + case SYSINFO_ID_BOARD_MANUFACTURER: + if (priv->t1) + str = smbios_string(priv->system, + priv->t1->manufacturer); + break; + case SYSINFO_ID_PRIOR_STAGE_VERSION: + if (priv->t0) + str = smbios_string(priv->bios, priv->t0->bios_ver); + break; + case SYSINFO_ID_PRIOR_STAGE_DATE: + if (priv->t0) + str = smbios_string(priv->bios, + priv->t0->bios_release_date); + break; + } + if (!str) + return -ENOTSUPP; + + strlcpy(val, str, size); + + return 0; +} + +static int cb_detect(struct udevice *dev) +{ + struct cb_sysinfo_priv *priv = dev_get_priv(dev); + const struct smbios_entry *smbios; + + smbios = smbios_entry(lib_sysinfo.smbios_start, + lib_sysinfo.smbios_size); + if (!smbios) + return 0; + + priv->bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION); + priv->system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION); + priv->t0 = (struct smbios_type0 *)priv->bios; + priv->t1 = (struct smbios_type1 *)priv->system; + + return 0; +} + +static const struct udevice_id sysinfo_coreboot_ids[] = { + { .compatible = "coreboot,sysinfo" }, + { /* sentinel */ } +}; + +static const struct sysinfo_ops sysinfo_coreboot_ops = { + .detect = cb_detect, + .get_str = cb_get_str, +}; + +U_BOOT_DRIVER(sysinfo_coreboot) = { + .name = "sysinfo_coreboot", + .id = UCLASS_SYSINFO, + .of_match = sysinfo_coreboot_ids, + .ops = &sysinfo_coreboot_ops, + .priv_auto = sizeof(struct cb_sysinfo_priv), +};

On Sun, 12 Nov 2023 19:58:20 -0700, Simon Glass wrote:
The show_board_info() function was adjusted to weak so that it could be entirely replaced with a board-specific implementation.
The intended way for boards to provide their own information is via a sysinfo driver. But currently there is no way to show anything other than the model name.
[...]
Applied to u-boot/next, thanks!
participants (4)
-
Marcel Ziswiler
-
Neil Armstrong
-
Simon Glass
-
Tom Rini