From 93ac30d1891b0f365c42892beb4b189221e44e78 Mon Sep 17 00:00:00 2001 From: Johnny Lin Date: Tue, 3 Dec 2019 18:46:54 +0800 Subject: [PATCH] mb/ocp/monolake: Override SMBIOS data with IPMI read FRU data SMBIOS type 1 data fields are overwritten by FRU product info area data, SMBIOS type 2 fields are overwritten by FRU board info area data. Tested on OCP Mono Lake. Change-Id: I58cbe95055dea053b115e99f354f40d5902c6a35 Signed-off-by: Johnny Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/37445 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- src/mainboard/ocp/monolake/Kconfig | 2 + src/mainboard/ocp/monolake/mainboard.c | 87 ++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/src/mainboard/ocp/monolake/Kconfig b/src/mainboard/ocp/monolake/Kconfig index 7d85bbba70..bbc29a334f 100644 --- a/src/mainboard/ocp/monolake/Kconfig +++ b/src/mainboard/ocp/monolake/Kconfig @@ -60,4 +60,6 @@ config FMDFILE config IPMI_KCS_REGISTER_SPACING default 4 +config IPMI_FRU_SINGLE_RW_SZ + default 16 endif # BOARD_OCP_MONOLAKE diff --git a/src/mainboard/ocp/monolake/mainboard.c b/src/mainboard/ocp/monolake/mainboard.c index a75aae7051..9a1c9953ab 100644 --- a/src/mainboard/ocp/monolake/mainboard.c +++ b/src/mainboard/ocp/monolake/mainboard.c @@ -30,6 +30,9 @@ #define VPD_LEN 10 /* Default countdown is 15 minutes. */ #define DEFAULT_COUNTDOWN 9000 +#define FRU_DEVICE_ID 0 + +static struct fru_info_str fru_strings; static void init_frb2_wdt(void) { @@ -76,6 +79,7 @@ static void mainboard_enable(struct device *dev) clear_ipmi_flags(&rsp); system_reset(); } + read_fru_areas(BMC_KCS_BASE, FRU_DEVICE_ID, 0, &fru_strings); } struct chip_operations mainboard_ops = { @@ -101,3 +105,86 @@ void smbios_system_set_uuid(u8 *uuid) { ipmi_get_system_guid(BMC_KCS_BASE, uuid); } +/* Override SMBIOS type 1 data. */ +const char *smbios_system_manufacturer(void) +{ + if (fru_strings.prod_info.manufacturer != NULL) + return (const char *)fru_strings.prod_info.manufacturer; + else + return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; +} + +const char *smbios_system_product_name(void) +{ + char *prod_name_partnumber; + /* Concatenates IPMI FRU Product Info product name + * and product part number. */ + if (fru_strings.prod_info.product_name != NULL) { + if (fru_strings.prod_info.product_partnumber != NULL) { + /* Append a space after product_name. */ + prod_name_partnumber = strconcat(fru_strings.prod_info.product_name, + " "); + if (!prod_name_partnumber) + return (const char *)fru_strings.prod_info.product_name; + + prod_name_partnumber = strconcat(prod_name_partnumber, + fru_strings.prod_info.product_partnumber); + if (!prod_name_partnumber) + return (const char *)fru_strings.prod_info.product_name; + + return (const char *)prod_name_partnumber; + } else { + return (const char *)fru_strings.prod_info.product_name; + } + } else { + return CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME; + } +} + +const char *smbios_system_serial_number(void) +{ + if (fru_strings.prod_info.serial_number != NULL) + return (const char *)fru_strings.prod_info.serial_number; + else + return CONFIG_MAINBOARD_SERIAL_NUMBER; +} + +const char *smbios_system_version(void) +{ + if (fru_strings.prod_info.product_version != NULL) + return (const char *)fru_strings.prod_info.product_version; + else + return CONFIG_MAINBOARD_SERIAL_NUMBER; +} +/* Override SMBIOS type 2 data. */ +const char *smbios_mainboard_version(void) +{ + if (fru_strings.board_info.part_number != NULL) + return (const char *)fru_strings.board_info.part_number; + else + return CONFIG_MAINBOARD_VERSION; +} + +const char *smbios_mainboard_manufacturer(void) +{ + if (fru_strings.board_info.manufacturer != NULL) + return (const char *)fru_strings.board_info.manufacturer; + else + return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; +} + +const char *smbios_mainboard_product_name(void) +{ + if (fru_strings.board_info.product_name != NULL) + return (const char *)fru_strings.board_info.product_name; + else + return CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME; +} + +const char *smbios_mainboard_serial_number(void) +{ + if (fru_strings.board_info.serial_number != NULL) + return (const char *)fru_strings.board_info.serial_number; + else + return CONFIG_MAINBOARD_SERIAL_NUMBER; +}