spl: fit: Move FPGA loading code to separate functions
[platform/kernel/u-boot.git] / common / board_info.c
1 // SPDX-License-Identifier: GPL-2.0+
2
3 #include <common.h>
4 #include <dm.h>
5 #include <init.h>
6 #include <sysinfo.h>
7 #include <asm/global_data.h>
8 #include <linux/libfdt.h>
9 #include <linux/compiler.h>
10
11 DECLARE_GLOBAL_DATA_PTR;
12
13 int __weak checkboard(void)
14 {
15         return 0;
16 }
17
18 /*
19  * Check sysinfo for board information. Failing that if the root node of the DTB
20  * has a "model" property, show it.
21  *
22  * Then call checkboard().
23  */
24 int __weak show_board_info(void)
25 {
26         if (IS_ENABLED(CONFIG_OF_CONTROL)) {
27                 struct udevice *dev;
28                 const char *model;
29                 char str[80];
30                 int ret = -ENOSYS;
31
32                 if (IS_ENABLED(CONFIG_SYSINFO)) {
33                         /* This might provide more detail */
34                         ret = uclass_first_device_err(UCLASS_SYSINFO, &dev);
35                         if (!ret)
36                                 ret = sysinfo_get_str(dev,
37                                                       SYSINFO_ID_BOARD_MODEL,
38                                                       sizeof(str), str);
39                 }
40
41                 /* Fail back to the main 'model' if available */
42                 if (ret)
43                         model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
44                 else
45                         model = str;
46
47                 if (model)
48                         printf("Model: %s\n", model);
49         }
50
51         return checkboard();
52 }