Johnny Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42029 )
Change subject: drivers/vpd: Add a config option that would override coreboot version with VPD variable ......................................................................
drivers/vpd: Add a config option that would override coreboot version with VPD variable
If VPD_COREBOOT_VERSION is selected, it would read VPD_RO variable to override SMBIOS type 0 version, if the VPD variable is not found it would fallback to use VERSION_VPD_DEFAULT_IF_MISSING, if it's still not set it would use COREBOOT_VERSION. VPD_COREBOOT_VERSION default is n.
Tested on OCP Delta Lake, dmidecode -t 0 can see version being updated from VPD.
Change-Id: Iee62ed900095001ffac225fc629b3f2f52045e30 Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/vpd/Kconfig M src/drivers/vpd/Makefile.inc A src/drivers/vpd/smbios.c 3 files changed, 49 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/29/42029/1
diff --git a/src/drivers/vpd/Kconfig b/src/drivers/vpd/Kconfig index eda9130..566bec5 100644 --- a/src/drivers/vpd/Kconfig +++ b/src/drivers/vpd/Kconfig @@ -5,3 +5,27 @@ default n help Enable support for flash based vital product data. + +config VPD_COREBOOT_VERSION + bool "Read CONFIG_VERSION_VPD from VPD_RO for SMBIOS type 0 version" + default n + depends on VPD + help + After selecting this option, it would read CONFIG_VERSION_VPD from + VPD_RO and override SMBIOS type 0 version. + +config VERSION_VPD + string + default "version" + depends on VPD_COREBOOT_VERSION + help + The VPD variable name resides in VPD_RO for coreboot version, default + is "version". The value of the variable is limited to 20 characters for now. + +config VERSION_VPD_DEFAULT_IF_MISSING + string + default "" + depends on VPD_COREBOOT_VERSION + help + The fallback version value if VERSION_VPD cannot be read from VPD_RO, + if it's not set COREBOOT_VERSION would be used. diff --git a/src/drivers/vpd/Makefile.inc b/src/drivers/vpd/Makefile.inc index cc276e4..2237340 100644 --- a/src/drivers/vpd/Makefile.inc +++ b/src/drivers/vpd/Makefile.inc @@ -1,2 +1,3 @@ romstage-$(CONFIG_VPD) += vpd_decode.c vpd_premem.c vpd.c ramstage-$(CONFIG_VPD) += vpd_decode.c vpd_cbmem.c vpd.c +ramstage-$(CONFIG_VPD_COREBOOT_VERSION) += smbios.c diff --git a/src/drivers/vpd/smbios.c b/src/drivers/vpd/smbios.c new file mode 100644 index 0000000..682a4ce --- /dev/null +++ b/src/drivers/vpd/smbios.c @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#include <console/console.h> +#include <string.h> +#include <smbios.h> +#include <version.h> + +#include "vpd.h" + +#define VER_LEN 20 +static char version[VER_LEN] = {0}; + +const char *smbios_mainboard_bios_version(void) +{ + if (vpd_gets(CONFIG_VERSION_VPD, version, VER_LEN, VPD_RO)) { + printk(BIOS_DEBUG, "Get version from VPD: %s\n", version); + return version; + } + printk(BIOS_ERR, "Get version from VPD failed\n"); + if (strlen(CONFIG_VERSION_VPD_DEFAULT_IF_MISSING)) + return CONFIG_VERSION_VPD_DEFAULT_IF_MISSING; + else + return coreboot_version; +}