blob: e0f2d9392204435558f464e93e897916ae84406b [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 */
Marek Vasut00937692021-07-04 21:32:04 +020034 ret = sysinfo_get(&dev);
Marek Vasut2227c822021-07-04 21:32:05 +020035 if (!ret) {
36 ret = sysinfo_detect(dev);
37 if (!ret) {
38 ret = sysinfo_get_str(dev,
Simon Glass43bc5432021-03-21 16:50:06 +130039 SYSINFO_ID_BOARD_MODEL,
40 sizeof(str), str);
Marek Vasut2227c822021-07-04 21:32:05 +020041 }
42 }
Simon Glass43bc5432021-03-21 16:50:06 +130043 }
44
45 /* 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;
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090050
Simon Glass43bc5432021-03-21 16:50:06 +130051 if (model)
52 printf("Model: %s\n", model);
53 }
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090054
55 return checkboard();
56}