Tim Chu has uploaded this change for review.

View Change

drivers/ocp/ipmi: Implement set POST start/end command

Implemented to send POST start and POST end command to BMC in ramstage.

Tested=Read POST command in OpenBMC,
if success message may show as below,

root@bmc:~# cat /var/log/messages |grep -i "POST"
Aug 10 00:11:24 bmc user.info ipmid: POST Start Event for Payload#1
Aug 10 00:11:28 bmc user.info ipmid: POST End Event for Payload#1
root@bmc:~#

Signed-off-by: TimChu <Tim.Chu@quantatw.com>
Change-Id: I25fe435eeeef06ca9378ca9a0b3654806a3222ad
---
A src/drivers/ocp/ipmi/Kconfig
A src/drivers/ocp/ipmi/Makefile.inc
A src/drivers/ocp/ipmi/ipmi_ocp.c
A src/drivers/ocp/ipmi/ipmi_ocp.h
M src/mainboard/ocp/tiogapass/Kconfig
M src/mainboard/ocp/tiogapass/devicetree.cb
6 files changed, 138 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/29/41229/1
diff --git a/src/drivers/ocp/ipmi/Kconfig b/src/drivers/ocp/ipmi/Kconfig
new file mode 100644
index 0000000..74a886e
--- /dev/null
+++ b/src/drivers/ocp/ipmi/Kconfig
@@ -0,0 +1,3 @@
+config IPMI_OCP
+ bool
+ default n
\ No newline at end of file
diff --git a/src/drivers/ocp/ipmi/Makefile.inc b/src/drivers/ocp/ipmi/Makefile.inc
new file mode 100644
index 0000000..f8be839
--- /dev/null
+++ b/src/drivers/ocp/ipmi/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_IPMI_OCP) += ipmi_ocp.c
\ No newline at end of file
diff --git a/src/drivers/ocp/ipmi/ipmi_ocp.c b/src/drivers/ocp/ipmi/ipmi_ocp.c
new file mode 100644
index 0000000..08bca43
--- /dev/null
+++ b/src/drivers/ocp/ipmi/ipmi_ocp.c
@@ -0,0 +1,120 @@
+/* This file is part of the coreboot project. */
+/*
+ * Place in devicetree.cb:
+ *
+ * chip drivers/ocp/ipmi # OCP specific IPMI porting
+ device pnp ca2.1 on end
+ * end
+ */
+
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include "chip.h"
+#include "drivers/ipmi/ipmi_kcs.h"
+#include "ipmi_ocp.h"
+
+static int ipmi_set_post_start(struct device *dev, struct ipmi_rsp *rsp)
+{
+ int ret;
+
+ ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_OEM, 0,
+ IPMI_BMC_SET_POST_START, NULL, 0, (u8 *)rsp,
+ sizeof(*rsp));
+
+ if (ret < sizeof(struct ipmi_rsp) || rsp->completion_code) {
+ printk(BIOS_ERR, "IPMI: %s command failed (ret=%d rsp=0x%x)\n",
+ __func__, ret, rsp->completion_code);
+ return 1;
+ }
+ if (ret != sizeof(*rsp)) {
+ printk(BIOS_ERR, "IPMI: %s response truncated\n", __func__);
+ return 1;
+ }
+ return 0;
+}
+
+static int ipmi_set_post_end(struct device *dev, struct ipmi_rsp *rsp)
+{
+ int ret;
+
+ ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_OEM, 0,
+ IPMI_BMC_SET_POST_END, NULL, 0, (u8 *)rsp,
+ sizeof(*rsp));
+
+ if (ret < sizeof(struct ipmi_rsp) || rsp->completion_code) {
+ printk(BIOS_ERR, "IPMI: %s command failed (ret=%d rsp=0x%x)\n",
+ __func__, ret, rsp->completion_code);
+ return 1;
+ }
+ if (ret != sizeof(*rsp)) {
+ printk(BIOS_ERR, "IPMI: %s response truncated\n", __func__);
+ return 1;
+ }
+ return 0;
+}
+
+static void ipmi_ocp_init(struct device *dev)
+{
+ struct ipmi_rsp postrsp;
+
+ /* Send POST start to BMC. */
+ if(!ipmi_set_post_start(dev, &postrsp)){
+ printk(BIOS_DEBUG, "IPMI BMC POST is started\n");
+ }
+}
+
+static void ipmi_ocp_final(struct device *dev)
+{
+ struct ipmi_rsp postrsp;
+
+ /* Send POST end to BMC. */
+ if(!ipmi_set_post_end(dev, &postrsp)){
+ printk(BIOS_DEBUG, "IPMI BMC POST is ended\n");
+ }
+}
+
+static void ipmi_set_resources(struct device *dev)
+{
+ struct resource *res;
+
+ for (res = dev->resource_list; res; res = res->next) {
+ if (!(res->flags & IORESOURCE_ASSIGNED))
+ continue;
+
+ res->flags |= IORESOURCE_STORED;
+ report_resource_stored(dev, res, "");
+ }
+}
+
+static void ipmi_read_resources(struct device *dev)
+{
+ struct resource *res = new_resource(dev, 0);
+ res->base = dev->path.pnp.port;
+ res->size = 2;
+ res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
+}
+
+static struct device_operations ops = {
+ .read_resources = ipmi_read_resources,
+ .set_resources = ipmi_set_resources,
+ .init = ipmi_ocp_init,
+ .final = ipmi_ocp_final,
+};
+
+static void enable_dev(struct device *dev)
+{
+ if (dev->path.type != DEVICE_PATH_PNP)
+ printk(BIOS_ERR, "%s: Unsupported device type\n",
+ dev_path(dev));
+ else if (dev->path.pnp.port & 1)
+ printk(BIOS_ERR, "%s: Base address needs to be aligned to 2\n",
+ dev_path(dev));
+ else
+ dev->ops = &ops;
+}
+
+struct chip_operations drivers_ocp_ipmi_ops = {
+ CHIP_NAME("IPMI OCP")
+ .enable_dev = enable_dev,
+};
\ No newline at end of file
diff --git a/src/drivers/ocp/ipmi/ipmi_ocp.h b/src/drivers/ocp/ipmi/ipmi_ocp.h
new file mode 100644
index 0000000..6747e0a
--- /dev/null
+++ b/src/drivers/ocp/ipmi/ipmi_ocp.h
@@ -0,0 +1,10 @@
+/* This file is part of the coreboot project. */
+
+#ifndef __IPMI_OCP_H
+#define __IPMI_OCP_H
+
+#define IPMI_NETFN_OEM 0x30
+#define IPMI_BMC_SET_POST_START 0x73
+#define IPMI_BMC_SET_POST_END 0x74
+
+#endif
\ No newline at end of file
diff --git a/src/mainboard/ocp/tiogapass/Kconfig b/src/mainboard/ocp/tiogapass/Kconfig
index f9b5e7f..73eeca1 100644
--- a/src/mainboard/ocp/tiogapass/Kconfig
+++ b/src/mainboard/ocp/tiogapass/Kconfig
@@ -21,6 +21,7 @@
select HAVE_ACPI_TABLES
select MAINBOARD_USES_FSP2_0
select IPMI_KCS
+ select IPMI_OCP
select SOC_INTEL_SKYLAKE_SP
select SUPERIO_ASPEED_AST2400

diff --git a/src/mainboard/ocp/tiogapass/devicetree.cb b/src/mainboard/ocp/tiogapass/devicetree.cb
index 51e6a62..8b0caab 100644
--- a/src/mainboard/ocp/tiogapass/devicetree.cb
+++ b/src/mainboard/ocp/tiogapass/devicetree.cb
@@ -89,6 +89,9 @@
register "bmc_i2c_address" = "0x20"
register "bmc_boot_timeout" = "60"
end
+ chip drivers/ocp/ipmi # OCP specific IPMI porting
+ device pnp ca2.1 on end
+ end
end # Intel Corporation C621 Series Chipset LPC/eSPI Controller
device pci 1f.2 on end # Intel Corporation C620 Series Chipset Family Power Management Controller
device pci 1f.4 on end # Intel Corporation C620 Series Chipset Family SMBus

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

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I25fe435eeeef06ca9378ca9a0b3654806a3222ad
Gerrit-Change-Number: 41229
Gerrit-PatchSet: 1
Gerrit-Owner: Tim Chu <Tim.Chu@quantatw.com>
Gerrit-MessageType: newchange