blob: 1cfe34f7067852d4e2dd4e8b37266d9a40b04173 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada0365ffc2015-01-14 17:07:05 +09002
3#include <common.h>
Simon Glass96dedb02021-03-21 16:50:06 +13004#include <dm.h>
Simon Glass691d7192020-05-10 11:40:02 -06005#include <init.h>
Simon Glass96dedb02021-03-21 16:50:06 +13006#include <sysinfo.h>
Simon Glass401d1c42020-10-30 21:38:53 -06007#include <asm/global_data.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +09008#include <linux/libfdt.h>
Masahiro Yamada0365ffc2015-01-14 17:07:05 +09009#include <linux/compiler.h>
10
Simon Glass96dedb02021-03-21 16:50:06 +130011DECLARE_GLOBAL_DATA_PTR;
12
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090013int __weak checkboard(void)
14{
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090015 return 0;
16}
17
18/*
Simon Glass96dedb02021-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.comdac326b2015-07-09 19:58:03 +080022 * Then call checkboard().
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090023 */
Marcel Ziswilerf7637cc2016-11-16 17:49:20 +010024int __weak show_board_info(void)
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090025{
Simon Glass96dedb02021-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 Yamada0365ffc2015-01-14 17:07:05 +090031
Simon Glass96dedb02021-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 }
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090040
Simon Glass96dedb02021-03-21 16:50:06 +130041 /* 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 }
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090050
51 return checkboard();
52}