Patrick Rudolph has uploaded this change for review.

View Change

drivers/ipmi: Add Supermicro OEM commands

Add a new driver for OEM commands an select if 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, 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>
---
M src/drivers/ipmi/Kconfig
M src/drivers/ipmi/Makefile.inc
M src/drivers/ipmi/ipmi_kcs_ops.c
A src/drivers/ipmi/ipmi_supermicro_oem.h
A src/drivers/ipmi/supermicro_oem.c
M src/mainboard/supermicro/x11-lga1151-series/Kconfig
6 files changed, 121 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/38002/1
diff --git a/src/drivers/ipmi/Kconfig b/src/drivers/ipmi/Kconfig
index 0f7152d..e098bc8 100644
--- a/src/drivers/ipmi/Kconfig
+++ b/src/drivers/ipmi/Kconfig
@@ -8,3 +8,14 @@
depends on IPMI_KCS
help
KCS status and command register IO port address spacing
+
+config DRIVER_SUPERMICRO_IPMI_OEM
+ bool "Supermicro IPMI OEM BMC support"
+ depends on IPMI_KCS
+ default n
+ help
+ Tested on X11SSH only. Different BMCs might have different OEM
+ commands.
+ The following features are implemented:
+ * Communicates the BIOS version to the BMC
+ * Communicates the BIOS date to the BMC
diff --git a/src/drivers/ipmi/Makefile.inc b/src/drivers/ipmi/Makefile.inc
index 9d5b3d4..9fccccf 100644
--- a/src/drivers/ipmi/Makefile.inc
+++ b/src/drivers/ipmi/Makefile.inc
@@ -1,3 +1,4 @@
ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs.c
ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs_ops.c
ramstage-$(CONFIG_IPMI_KCS) += ipmi_ops.c
+ramstage-$(CONFIG_DRIVER_SUPERMICRO_IPMI_OEM) += supermicro_oem.c
diff --git a/src/drivers/ipmi/ipmi_kcs_ops.c b/src/drivers/ipmi/ipmi_kcs_ops.c
index 5cb8995..ba8487f 100644
--- a/src/drivers/ipmi/ipmi_kcs_ops.c
+++ b/src/drivers/ipmi/ipmi_kcs_ops.c
@@ -34,6 +34,7 @@
#include <delay.h>
#include <timer.h>
#include "ipmi_kcs.h"
+#include "ipmi_supermicro_oem.h"
#include "chip.h"

/* 4 bit encoding */
@@ -170,6 +171,12 @@
/* Don't write tables if communication failed */
dev->enabled = 0;
}
+
+ if (!dev->enabled)
+ return;
+
+ if (CONFIG(DRIVER_SUPERMICRO_IPMI_OEM))
+ supermicro_ipmi_oem(dev->path.pnp.port);
}

#if CONFIG(HAVE_ACPI_TABLES)
diff --git a/src/drivers/ipmi/ipmi_supermicro_oem.h b/src/drivers/ipmi/ipmi_supermicro_oem.h
new file mode 100644
index 0000000..742b97d
--- /dev/null
+++ b/src/drivers/ipmi/ipmi_supermicro_oem.h
@@ -0,0 +1,20 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __IPMI_SUPERMICRO_OEM_H
+#define __IPMI_SUPERMICRO_OEM_H
+
+void supermicro_ipmi_oem(const uint16_t kcs_port);
+
+#endif /* __IPMI_SUPERMICRO_OEM_H */
diff --git a/src/drivers/ipmi/supermicro_oem.c b/src/drivers/ipmi/supermicro_oem.c
new file mode 100644
index 0000000..ea01fef
--- /dev/null
+++ b/src/drivers/ipmi/supermicro_oem.c
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#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);
+}
diff --git a/src/mainboard/supermicro/x11-lga1151-series/Kconfig b/src/mainboard/supermicro/x11-lga1151-series/Kconfig
index 5a99f7a..53ae398 100644
--- a/src/mainboard/supermicro/x11-lga1151-series/Kconfig
+++ b/src/mainboard/supermicro/x11-lga1151-series/Kconfig
@@ -12,6 +12,7 @@
select SUPERIO_ASPEED_AST2400
select GENERATE_SMBIOS_TABLES
select IPMI_KCS
+ select DRIVER_SUPERMICRO_IPMI_OEM
select MAINBOARD_NO_FSP_GOP
select SUPERIO_ASPEED_HAS_UART_DELAY_WORKAROUND
select NO_FADT_8042

To view, visit change 38002. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I51c22f83383affb70abb0efbcdc33ea925b5ff9f
Gerrit-Change-Number: 38002
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph@9elements.com>
Gerrit-MessageType: newchange