blob: 1cfe34f7067852d4e2dd4e8b37266d9a40b04173 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada9607f7a2015-01-14 17:07:05 +09002
3#include <common.h>
Simon Glass43bc5432021-03-21 16:50:06 +13004#include <dm.h>
Simon Glass97589732020-05-10 11:40:02 -06005#include <init.h>
Simon Glass43bc5432021-03-21 16:50:06 +13006#include <sysinfo.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06007#include <asm/global_data.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +09008#include <linux/libfdt.h>
Masahiro Yamada9607f7a2015-01-14 17:07:05 +09009#include <linux/compiler.h>
10
Simon Glass43bc5432021-03-21 16:50:06 +130011DECLARE_GLOBAL_DATA_PTR;
12
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090013int __weak checkboard(void)
14{
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090015 return 0;
16}
17
18/*
Simon Glass43bc5432021-03-21 16:50:06 +130019 * Check sysinfo for board information. Failing that if the root node of the DTB
20 * has a "model" property, show it.
21 *
Haikun.Wang@freescale.com7f7335e2015-07-09 19:58:03 +080022 * Then call checkboard().
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090023 */
Marcel Ziswiler6e8bc1a2016-11-16 17:49:20 +010024int __weak show_board_info(void)
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090025{
Simon Glass43bc5432021-03-21 16:50:06 +130026 if (IS_ENABLED(CONFIG_OF_CONTROL)) {
27 struct udevice *dev;
28 const char *model;
29 char str[80];
30 int ret = -ENOSYS;
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090031
Simon Glass43bc5432021-03-21 16:50:06 +130032 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;
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090046
Simon Glass43bc5432021-03-21 16:50:06 +130047 if (model)
48 printf("Model: %s\n", model);
49 }
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090050
51 return checkboard();
52}