Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 2 | |
3 | #include <common.h> | ||||
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 4 | #include <dm.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 5 | #include <init.h> |
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 6 | #include <sysinfo.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 7 | #include <asm/global_data.h> |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 8 | #include <linux/libfdt.h> |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 9 | #include <linux/compiler.h> |
10 | |||||
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 11 | DECLARE_GLOBAL_DATA_PTR; |
12 | |||||
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 13 | int __weak checkboard(void) |
14 | { | ||||
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 15 | return 0; |
16 | } | ||||
17 | |||||
18 | /* | ||||
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 19 | * 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.com | dac326b | 2015-07-09 19:58:03 +0800 | [diff] [blame] | 22 | * Then call checkboard(). |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 23 | */ |
Marcel Ziswiler | f7637cc | 2016-11-16 17:49:20 +0100 | [diff] [blame] | 24 | int __weak show_board_info(void) |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 25 | { |
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 26 | if (IS_ENABLED(CONFIG_OF_CONTROL)) { |
27 | struct udevice *dev; | ||||
28 | const char *model; | ||||
29 | char str[80]; | ||||
30 | int ret = -ENOSYS; | ||||
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 31 | |
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 32 | if (IS_ENABLED(CONFIG_SYSINFO)) { |
33 | /* This might provide more detail */ | ||||
Marek Vasut | 10f3e15 | 2021-07-04 21:32:04 +0200 | [diff] [blame] | 34 | ret = sysinfo_get(&dev); |
Marek Vasut | 93e310c | 2021-07-04 21:32:05 +0200 | [diff] [blame^] | 35 | if (!ret) { |
36 | ret = sysinfo_detect(dev); | ||||
37 | if (!ret) { | ||||
38 | ret = sysinfo_get_str(dev, | ||||
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 39 | SYSINFO_ID_BOARD_MODEL, |
40 | sizeof(str), str); | ||||
Marek Vasut | 93e310c | 2021-07-04 21:32:05 +0200 | [diff] [blame^] | 41 | } |
42 | } | ||||
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 43 | } |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 44 | |
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 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; | ||||
50 | |||||
51 | if (model) | ||||
52 | printf("Model: %s\n", model); | ||||
53 | } | ||||
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 54 | |
55 | return checkboard(); | ||||
56 | } |