Commit 0365ffcc0bd6335afb0c866423f3fe401b28ffaa

Authored by Masahiro Yamada
Committed by Simon Glass
1 parent 5468461d1e

generic-board: show model name in board_init_f() too

The common/board_r.c has show_model_r() to display the model name
if the DTB has a "model" property.  It sounds useful to have a similar
function in common/board_f.c too because most of the boards show
their board name before relocation.

Instead of implementing the same function in both common/board_f.c
and common/board_r.c, let's split it up into common/show_board_info.c.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>

Showing 5 changed files with 46 additions and 24 deletions Side-by-side Diff

... ... @@ -27,6 +27,8 @@
27 27 # boards
28 28 obj-$(CONFIG_SYS_GENERIC_BOARD) += board_f.o
29 29 obj-$(CONFIG_SYS_GENERIC_BOARD) += board_r.o
  30 +obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
  31 +obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
30 32  
31 33 # core command
32 34 obj-y += cmd_boot.o
... ... @@ -894,7 +894,7 @@
894 894 prt_mpc5xxx_clks,
895 895 #endif /* CONFIG_MPC5xxx */
896 896 #if defined(CONFIG_DISPLAY_BOARDINFO)
897   - checkboard, /* display board info */
  897 + show_board_info,
898 898 #endif
899 899 INIT_FUNC_WATCHDOG_INIT
900 900 #if defined(CONFIG_MISC_INIT_F)
  1 +/*
  2 + * SPDX-License-Identifier: GPL-2.0+
  3 + */
  4 +
  5 +#include <common.h>
  6 +#include <libfdt.h>
  7 +#include <linux/compiler.h>
  8 +
  9 +int __weak checkboard(void)
  10 +{
  11 + printf("Board: Unknown\n");
  12 + return 0;
  13 +}
  14 +
  15 +/*
  16 + * If the root node of the DTB has a "model" property, show it.
  17 + * If CONFIG_OF_CONTROL is disabled or the "model" property is missing,
  18 + * fall back to checkboard().
  19 + */
  20 +int show_board_info(void)
  21 +{
  22 +#ifdef CONFIG_OF_CONTROL
  23 + DECLARE_GLOBAL_DATA_PTR;
  24 + const char *model;
  25 +
  26 + model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
  27 +
  28 + if (model) {
  29 + printf("Model: %s\n", model);
  30 + return 0;
  31 + }
  32 +#endif
  33 +
  34 + return checkboard();
  35 +}
... ... @@ -476,22 +476,6 @@
476 476 }
477 477 #endif
478 478  
479   -#ifdef CONFIG_DISPLAY_BOARDINFO_LATE
480   -static int show_model_r(void)
481   -{
482   - /* Put this here so it appears on the LCD, now it is ready */
483   -# ifdef CONFIG_OF_CONTROL
484   - const char *model;
485   -
486   - model = (char *)fdt_getprop(gd->fdt_blob, 0, "model", NULL);
487   - printf("Model: %s\n", model ? model : "<unknown>");
488   -# else
489   - checkboard();
490   -# endif
491   - return 0;
492   -}
493   -#endif
494   -
495 479 /* enable exceptions */
496 480 #ifdef CONFIG_ARM
497 481 static int initr_enable_interrupts(void)
... ... @@ -801,7 +785,7 @@
801 785 #endif
802 786 console_init_r, /* fully init console as a device */
803 787 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
804   - show_model_r,
  788 + show_board_info,
805 789 #endif
806 790 #ifdef CONFIG_ARCH_MISC_INIT
807 791 arch_misc_init, /* miscellaneous arch-dependent init */
... ... @@ -228,12 +228,13 @@
228 228 extern char console_buffer[];
229 229  
230 230 /* arch/$(ARCH)/lib/board.c */
231   -void board_init_f(ulong);
232   -void board_init_r (gd_t *, ulong) __attribute__ ((noreturn));
233   -int checkboard (void);
234   -int checkflash (void);
235   -int checkdram (void);
236   -int last_stage_init(void);
  231 +void board_init_f(ulong);
  232 +void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
  233 +int checkboard(void);
  234 +int show_board_info(void);
  235 +int checkflash(void);
  236 +int checkdram(void);
  237 +int last_stage_init(void);
237 238 extern ulong monitor_flash_len;
238 239 int mac_read_from_eeprom(void);
239 240 extern u8 __dtb_dt_begin[]; /* embedded device tree blob */