Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 2 | |
3 | #include <common.h> | ||||
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 4 | #include <dm.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 5 | #include <init.h> |
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 6 | #include <sysinfo.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 7 | #include <asm/global_data.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 8 | #include <linux/libfdt.h> |
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 9 | #include <linux/compiler.h> |
10 | |||||
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 11 | DECLARE_GLOBAL_DATA_PTR; |
12 | |||||
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 13 | int __weak checkboard(void) |
14 | { | ||||
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 15 | return 0; |
16 | } | ||||
17 | |||||
Simon Glass | cda520e | 2023-11-12 19:58:27 -0700 | [diff] [blame^] | 18 | int show_board_info(void) |
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 19 | { |
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 20 | if (IS_ENABLED(CONFIG_OF_CONTROL)) { |
21 | struct udevice *dev; | ||||
22 | const char *model; | ||||
23 | char str[80]; | ||||
24 | int ret = -ENOSYS; | ||||
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 25 | |
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 26 | if (IS_ENABLED(CONFIG_SYSINFO)) { |
27 | /* This might provide more detail */ | ||||
Marek Vasut | 0093769 | 2021-07-04 21:32:04 +0200 | [diff] [blame] | 28 | ret = sysinfo_get(&dev); |
Marek Vasut | 2227c82 | 2021-07-04 21:32:05 +0200 | [diff] [blame] | 29 | if (!ret) { |
30 | ret = sysinfo_detect(dev); | ||||
31 | if (!ret) { | ||||
32 | ret = sysinfo_get_str(dev, | ||||
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 33 | SYSINFO_ID_BOARD_MODEL, |
34 | sizeof(str), str); | ||||
Marek Vasut | 2227c82 | 2021-07-04 21:32:05 +0200 | [diff] [blame] | 35 | } |
36 | } | ||||
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 37 | } |
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 Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 44 | |
Simon Glass | 43bc543 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 45 | if (model) |
46 | printf("Model: %s\n", model); | ||||
47 | } | ||||
Masahiro Yamada | 9607f7a | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 48 | |
49 | return checkboard(); | ||||
50 | } |