From 43a218b65366e225297a20442b49d07129765f73 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 3 Nov 2020 15:34:52 +0100 Subject: coreboot: make use of smbios parser If u-boot gets used as coreboot payload it might be nice to get vendor, model and bios version from smbios. I am not sure about the output of all the read information. With qemu target for coreboot this could look this: CBFS: Found @ offset 14f40 size 3b188 Checking segment from ROM address 0xffc15178 Checking segment from ROM address 0xffc15194 Loading segment from ROM address 0xffc15178 code (compression=1) New segment dstaddr 0x01110000 memsize 0x889ef srcaddr 0xffc151b0 filesize 0x3b150 Loading Segment: addr: 0x01110000 memsz: 0x00000000000889ef filesz: 0x000000000003b150 using LZMA Loading segment from ROM address 0xffc15194 Entry Point 0x01110000 BS: BS_PAYLOAD_LOAD run times (exec / console): 77 / 1 ms Jumping to boot code at 0x01110000(0x07fa7000) U-Boot 2020.10-00536-g5dcf7cc590-dirty (Oct 07 2020 - 14:21:51 +0200) CPU: x86_64, vendor AMD, device 663h DRAM: 127.1 MiB MMC: Video: No video mode configured in coreboot! Video: No video mode configured in coreboot! Vendor: QEMU Model: Standard PC (i440FX + PIIX, 1996) Bios Version: 4.12-3152-g326a499f6f-dirty Net: e1000: 52:54:00:12:34:56 eth0: e1000#0 No working controllers found Finalizing coreboot Hit any key to stop autoboot: 0 Signed-off-by: Christian Gmeiner Reviewed-by: Bin Meng --- board/coreboot/coreboot/coreboot.c | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'board') diff --git a/board/coreboot/coreboot/coreboot.c b/board/coreboot/coreboot/coreboot.c index b791b82..55aeced 100644 --- a/board/coreboot/coreboot/coreboot.c +++ b/board/coreboot/coreboot/coreboot.c @@ -4,7 +4,9 @@ */ #include +#include #include +#include int board_early_init_r(void) { @@ -16,3 +18,46 @@ int board_early_init_r(void) return 0; } + +#ifdef CONFIG_SMBIOS_PARSER +int show_board_info(void) +{ + const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size); + + if (!smbios) + goto fallback; + + const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION); + const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION); + const struct smbios_type0 *t0 = (struct smbios_type0 *)bios; + const struct smbios_type1 *t1 = (struct smbios_type1 *)system; + + if (!t0 || !t1) + goto fallback; + + const char *bios_ver = smbios_string(bios, t0->bios_ver); + const char *model = smbios_string(system, t1->product_name); + const char *manufacturer = smbios_string(system, t1->manufacturer); + + if (!model || !manufacturer || !bios_ver) + goto fallback; + + printf("Vendor: %s\n", manufacturer); + printf("Model: %s\n", model); + printf("BIOS Version: %s\n", bios_ver); + + return 0; + +fallback: +#ifdef CONFIG_OF_CONTROL + DECLARE_GLOBAL_DATA_PTR; + + model = fdt_getprop(gd->fdt_blob, 0, "model", NULL); + + if (model) + printf("Model: %s\n", model); +#endif + + return checkboard(); +} +#endif -- cgit v1.1 From 3a8ee3df836614b68881f5b84d3197305ee1b08e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 06:32:05 -0700 Subject: board: Rename uclass to sysinfo This uclass is intended to provide a way to obtain information about a U-Boot board. But the concept of a U-Boot 'board' is the whole system, not just one circuit board, meaning that 'board' is something of a misnomer for this uclass. In addition, the name 'board' is a bit overused in U-Boot and we want to use the same uclass to provide SMBIOS information. The obvious name is 'system' but that is so vague as to be meaningless. Use 'sysinfo' instead, since this uclass is aimed at providing information on the system. Rename everything accordingly. Note: Due to the patch delta caused by the symbol renames, this patch shows some renamed files as being deleted in one place and created in another. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- board/gdsys/common/cmd_ioloop.c | 12 +++++---- board/gdsys/mpc8308/gazerbeam.c | 47 +++++++++++++++++++---------------- board/google/chromebook_coral/coral.c | 2 +- 3 files changed, 33 insertions(+), 28 deletions(-) (limited to 'board') diff --git a/board/gdsys/common/cmd_ioloop.c b/board/gdsys/common/cmd_ioloop.c index 3ea2bec..658756d 100644 --- a/board/gdsys/common/cmd_ioloop.c +++ b/board/gdsys/common/cmd_ioloop.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "../../../drivers/misc/gdsys_soc.h" #include "../../../drivers/misc/gdsys_ioep.h" @@ -506,11 +506,11 @@ int do_ioloop(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *ioep = NULL; - struct udevice *board; + struct udevice *sysinfo; char name[8]; int ret; - if (board_get(&board)) + if (sysinfo_get(&sysinfo)) return CMD_RET_FAILURE; if (argc > 1) { @@ -518,7 +518,8 @@ int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) snprintf(name, sizeof(name), "ioep%d", i); - ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &ioep); + ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, name, + &ioep); if (ret || !ioep) { printf("Invalid IOEP %d\n", i); @@ -532,7 +533,8 @@ int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) while (1) { snprintf(name, sizeof(name), "ioep%d", i); - ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &ioep); + ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, + name, &ioep); if (ret || !ioep) break; diff --git a/board/gdsys/mpc8308/gazerbeam.c b/board/gdsys/mpc8308/gazerbeam.c index c317260..0e7fa1e 100644 --- a/board/gdsys/mpc8308/gazerbeam.c +++ b/board/gdsys/mpc8308/gazerbeam.c @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -15,11 +14,12 @@ #include #include #include +#include #include #include #include "../common/ihs_mdio.h" -#include "../../../drivers/board/gazerbeam.h" +#include "../../../drivers/sysinfo/gazerbeam.h" DECLARE_GLOBAL_DATA_PTR; @@ -43,22 +43,22 @@ static int get_tpm(struct udevice **devp) int board_early_init_r(void) { - struct udevice *board; + struct udevice *sysinfo; struct udevice *serdes; int mc = 0; int con = 0; - if (board_get(&board)) - puts("Could not find board information device.\n"); + if (sysinfo_get(&sysinfo)) + puts("Could not find sysinfo information device.\n"); /* Initialize serdes */ - uclass_get_device_by_phandle(UCLASS_MISC, board, "serdes", &serdes); + uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, "serdes", &serdes); - if (board_detect(board)) + if (sysinfo_detect(sysinfo)) puts("Device information detection failed.\n"); - board_get_int(board, BOARD_MULTICHANNEL, &mc); - board_get_int(board, BOARD_VARIANT, &con); + sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc); + sysinfo_get_int(sysinfo, BOARD_VARIANT, &con); if (mc == 2 || mc == 1) dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@22"); @@ -84,18 +84,18 @@ int board_early_init_r(void) return 0; } -int checkboard(void) +int checksysinfo(void) { - struct udevice *board; + struct udevice *sysinfo; char *s = env_get("serial#"); int mc = 0; int con = 0; - if (board_get(&board)) - puts("Could not find board information device.\n"); + if (sysinfo_get(&sysinfo)) + puts("Could not find sysinfo information device.\n"); - board_get_int(board, BOARD_MULTICHANNEL, &mc); - board_get_int(board, BOARD_VARIANT, &con); + sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc); + sysinfo_get_int(sysinfo, BOARD_VARIANT, &con); puts("Board: Gazerbeam "); printf("%s ", mc == 4 ? "MC4" : mc == 2 ? "MC2" : "SC"); @@ -123,20 +123,22 @@ int last_stage_init(void) { int fpga_hw_rev = 0; int i; - struct udevice *board; + struct udevice *sysinfo; struct udevice *osd; struct video_osd_info osd_info; struct udevice *tpm; int ret; - if (board_get(&board)) - puts("Could not find board information device.\n"); + if (sysinfo_get(&sysinfo)) + puts("Could not find sysinfo information device.\n"); - if (board) { - int res = board_get_int(board, BOARD_HWVERSION, &fpga_hw_rev); + if (sysinfo) { + int res = sysinfo_get_int(sysinfo, BOARD_HWVERSION, + &fpga_hw_rev); if (res) - printf("Could not determind FPGA HW revision (res = %d)\n", res); + printf("Could not determind FPGA HW revision (res = %d)\n", + res); } env_set_ulong("fpga_hw_rev", fpga_hw_rev); @@ -154,7 +156,8 @@ int last_stage_init(void) snprintf(name, sizeof(name), "rxaui%d", i); /* Disable RXAUI polarity inversion */ - ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &rxaui); + ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, + name, &rxaui); if (!ret) misc_set_enabled(rxaui, false); } diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c index f5ae482..b8b923c 100644 --- a/board/google/chromebook_coral/coral.c +++ b/board/google/chromebook_coral/coral.c @@ -150,7 +150,7 @@ static const struct udevice_id coral_ids[] = { U_BOOT_DRIVER(coral_drv) = { .name = "coral", - .id = UCLASS_BOARD, + .id = UCLASS_SYSINFO, .of_match = coral_ids, ACPI_OPS_PTR(&coral_acpi_ops) }; -- cgit v1.1 From 8f1f374f63076cdbb8f7106bd80fcae50ba62394 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 06:32:16 -0700 Subject: x86: galileo: Use devicetree for SMBIOS settings Add settings and enable the default sysinfo driver so that these can come from the device tree. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- board/intel/galileo/Kconfig | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'board') diff --git a/board/intel/galileo/Kconfig b/board/intel/galileo/Kconfig index 1416c89..fb8d94f 100644 --- a/board/intel/galileo/Kconfig +++ b/board/intel/galileo/Kconfig @@ -22,15 +22,4 @@ config BOARD_SPECIFIC_OPTIONS # dummy select BOARD_ROMSIZE_KB_1024 select SPI_FLASH_WINBOND -config SMBIOS_PRODUCT_NAME - default "GalileoGen2" - help - Override the default product name U-Boot reports in the SMBIOS - table, to be compatible with the Intel provided UEFI BIOS, as - Linux kernel drivers (drivers/mfd/intel_quark_i2c_gpio.c and - drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c) make use of - it to do different board level configuration. - - This can be "Galileo" for GEN1 Galileo board. - endif -- cgit v1.1