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 */ |
| 34 | ret = uclass_first_device_err(UCLASS_SYSINFO, &dev); |
| 35 | if (!ret) |
| 36 | ret = sysinfo_get_str(dev, |
| 37 | SYSINFO_ID_BOARD_MODEL, |
| 38 | sizeof(str), str); |
| 39 | } |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 40 | |
Simon Glass | 96dedb0 | 2021-03-21 16:50:06 +1300 | [diff] [blame] | 41 | /* Fail back to the main 'model' if available */ |
| 42 | if (ret) |
| 43 | model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); |
| 44 | else |
| 45 | model = str; |
| 46 | |
| 47 | if (model) |
| 48 | printf("Model: %s\n", model); |
| 49 | } |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 50 | |
| 51 | return checkboard(); |
| 52 | } |