blob: a62c04794b90e303ee8a7a880b64b3c6fb397d68 [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
Simon Glasscda520e2023-11-12 19:58:27 -070018int show_board_info(void)
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090019{
Simon Glass43bc5432021-03-21 16:50:06 +130020 if (IS_ENABLED(CONFIG_OF_CONTROL)) {
21 struct udevice *dev;
22 const char *model;
23 char str[80];
24 int ret = -ENOSYS;
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090025
Simon Glass43bc5432021-03-21 16:50:06 +130026 if (IS_ENABLED(CONFIG_SYSINFO)) {
27 /* This might provide more detail */
Marek Vasut00937692021-07-04 21:32:04 +020028 ret = sysinfo_get(&dev);
Marek Vasut2227c822021-07-04 21:32:05 +020029 if (!ret) {
30 ret = sysinfo_detect(dev);
31 if (!ret) {
32 ret = sysinfo_get_str(dev,
Simon Glass43bc5432021-03-21 16:50:06 +130033 SYSINFO_ID_BOARD_MODEL,
34 sizeof(str), str);
Marek Vasut2227c822021-07-04 21:32:05 +020035 }
36 }
Simon Glass43bc5432021-03-21 16:50:06 +130037 }
38
39 /* Fail back to the main 'model' if available */
40 if (ret)
41 model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
42 else
43 model = str;
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090044
Simon Glass43bc5432021-03-21 16:50:06 +130045 if (model)
46 printf("Model: %s\n", model);
47 }
Masahiro Yamada9607f7a2015-01-14 17:07:05 +090048
49 return checkboard();
50}