blob: e0f2d9392204435558f464e93e897916ae84406b [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 */
Marek Vasut10f3e152021-07-04 21:32:04 +020034 ret = sysinfo_get(&dev);
Marek Vasut93e310c2021-07-04 21:32:05 +020035 if (!ret) {
36 ret = sysinfo_detect(dev);
37 if (!ret) {
38 ret = sysinfo_get_str(dev,
Simon Glass96dedb02021-03-21 16:50:06 +130039 SYSINFO_ID_BOARD_MODEL,
40 sizeof(str), str);
Marek Vasut93e310c2021-07-04 21:32:05 +020041 }
42 }
Simon Glass96dedb02021-03-21 16:50:06 +130043 }
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090044
Simon Glass96dedb02021-03-21 16:50:06 +130045 /* Fail back to the main 'model' if available */
46 if (ret)
47 model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
48 else
49 model = str;
50
51 if (model)
52 printf("Model: %s\n", model);
53 }
Masahiro Yamada0365ffc2015-01-14 17:07:05 +090054
55 return checkboard();
56}