drivers/ipmi: Add Supermicro OEM commands

Add a new driver for OEM commands and select it from x11-lga1151-series.

The driver communicates the BIOS version and date to the BMC using OEM
commands. The command should be supported on all X11 series mainboards,
but might work with older BMC, too.

Tested on X11SSH-TF:
The BIOS version strings are updated on boot and are visible in the
BMC web UI.

Change-Id: I51c22f83383affb70abb0efbcdc33ea925b5ff9f
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Christian Walter <christian.walter@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38002
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
This commit is contained in:
Patrick Rudolph 2019-12-30 14:40:04 +01:00 committed by Hung-Te Lin
parent 1c18f8679f
commit 09cdeba606
6 changed files with 103 additions and 0 deletions

View File

@ -42,3 +42,14 @@ config IPMI_KCS_TIMEOUT_MS
The time unit is millisecond for each IPMI KCS transfer. The time unit is millisecond for each IPMI KCS transfer.
IPMI spec v2.0 rev 1.1 Sec. 9.15, a five-second timeout or IPMI spec v2.0 rev 1.1 Sec. 9.15, a five-second timeout or
greater is recommended. greater is recommended.
config DRIVERS_IPMI_SUPERMICRO_OEM
bool "Supermicro IPMI OEM BMC support"
depends on IPMI_KCS
default n
help
Tested on X11SSH only. Different BMCs might not support these OEM
commands.
The following features are implemented:
* Communicates the BIOS version to the BMC
* Communicates the BIOS date to the BMC

View File

@ -2,6 +2,7 @@ ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs.c
ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs_ops.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs_ops.c
ramstage-$(CONFIG_IPMI_KCS) += ipmi_ops.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_ops.c
ramstage-$(CONFIG_IPMI_KCS) += ipmi_fru.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_fru.c
ramstage-$(CONFIG_DRIVERS_IPMI_SUPERMICRO_OEM) += supermicro_oem.c
romstage-$(CONFIG_IPMI_KCS_ROMSTAGE) += ipmi_kcs_ops_premem.c romstage-$(CONFIG_IPMI_KCS_ROMSTAGE) += ipmi_kcs_ops_premem.c
romstage-$(CONFIG_IPMI_KCS_ROMSTAGE) += ipmi_kcs.c romstage-$(CONFIG_IPMI_KCS_ROMSTAGE) += ipmi_kcs.c
romstage-$(CONFIG_IPMI_KCS_ROMSTAGE) += ipmi_ops.c romstage-$(CONFIG_IPMI_KCS_ROMSTAGE) += ipmi_ops.c

View File

@ -23,6 +23,7 @@
#include <delay.h> #include <delay.h>
#include <timer.h> #include <timer.h>
#include "ipmi_kcs.h" #include "ipmi_kcs.h"
#include "ipmi_supermicro_oem.h"
#include "chip.h" #include "chip.h"
/* 4 bit encoding */ /* 4 bit encoding */
@ -167,6 +168,12 @@ static void ipmi_kcs_init(struct device *dev)
/* Don't write tables if communication failed */ /* Don't write tables if communication failed */
dev->enabled = 0; dev->enabled = 0;
} }
if (!dev->enabled)
return;
if (CONFIG(DRIVERS_IPMI_SUPERMICRO_OEM))
supermicro_ipmi_oem(dev->path.pnp.port);
} }
#if CONFIG(HAVE_ACPI_TABLES) #if CONFIG(HAVE_ACPI_TABLES)

View File

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __IPMI_SUPERMICRO_OEM_H
#define __IPMI_SUPERMICRO_OEM_H
#include <stdint.h>
void supermicro_ipmi_oem(const uint16_t kcs_port);
#endif /* __IPMI_SUPERMICRO_OEM_H */

View File

@ -0,0 +1,70 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <types.h>
#include <console/console.h>
#include <drivers/ipmi/ipmi_kcs.h>
#include <string.h>
#include <build.h>
#include "ipmi_supermicro_oem.h"
#define IPMI_NETFN_OEM 0x30
#define IPMI_LUN0_AC_SET_BIOS_VER 0x100
#define IPMI_LUN0_AC_SET_BIOS_DATE 0x101
#define IPMI_LUN0_SET_BIOS_STRING 0xac
struct ipmi_oem_set_bios_str {
uint16_t ver;
char str[16]; // NULL terminated string
} __packed;
static void set_coreboot_ver(const uint16_t kcs_port)
{
const char *coreboot_ver = COREBOOT_VERSION;
struct ipmi_oem_set_bios_str bios_ver;
struct ipmi_rsp rsp;
int ret;
size_t i;
/* Only 8 charactars are visible in UI. Cut of on first dash */
for (i = 0; i < 15; i++) {
if (coreboot_ver[i] == '-')
break;
bios_ver.str[i] = coreboot_ver[i];
}
bios_ver.str[i] = 0;
bios_ver.ver = IPMI_LUN0_AC_SET_BIOS_VER;
ret = ipmi_kcs_message(kcs_port, IPMI_NETFN_OEM, 0, IPMI_LUN0_SET_BIOS_STRING,
(const unsigned char *) &bios_ver, sizeof(bios_ver),
(unsigned char *) &rsp, sizeof(rsp));
if (ret < sizeof(rsp) || rsp.completion_code) {
printk(BIOS_ERR, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
__func__, ret, rsp.completion_code);
}
}
static void set_coreboot_date(const uint16_t kcs_port)
{
struct ipmi_oem_set_bios_str bios_ver;
struct ipmi_rsp rsp;
int ret;
strncpy(bios_ver.str, COREBOOT_DMI_DATE, 15);
bios_ver.str[15] = 0;
bios_ver.ver = IPMI_LUN0_AC_SET_BIOS_DATE;
ret = ipmi_kcs_message(kcs_port, IPMI_NETFN_OEM, 0, IPMI_LUN0_SET_BIOS_STRING,
(const unsigned char *) &bios_ver, sizeof(bios_ver),
(unsigned char *) &rsp, sizeof(rsp));
if (ret < sizeof(rsp) || rsp.completion_code) {
printk(BIOS_ERR, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
__func__, ret, rsp.completion_code);
}
}
void supermicro_ipmi_oem(const uint16_t kcs_port)
{
set_coreboot_ver(kcs_port);
set_coreboot_date(kcs_port);
}

View File

@ -63,6 +63,10 @@ config FMDFILE
string string
default "src/mainboard/\$(CONFIG_MAINBOARD_DIR)/vboot-ro-rwab.fmd" if VBOOT_SLOTS_RW_AB default "src/mainboard/\$(CONFIG_MAINBOARD_DIR)/vboot-ro-rwab.fmd" if VBOOT_SLOTS_RW_AB
config DRIVERS_IPMI_SUPERMICRO_OEM
bool
default y
config CBFS_SIZE config CBFS_SIZE
hex hex
default 0xb00000 default 0xb00000