aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/ocp/deltalake/ipmi.c
diff options
context:
space:
mode:
authorJingle Hsu <jingle_hsu@wiwynn.com>2020-07-02 09:35:06 +0800
committerAngel Pons <th3fanbus@gmail.com>2020-07-24 09:48:34 +0000
commit1ba62015184c5e8cb750f4f39de9dd382d869cb8 (patch)
treee9459f03d96235d9b1f9779d467091a40492331a /src/mainboard/ocp/deltalake/ipmi.c
parentf9e12e82f75448c557ce5dc840b4a33eae63a342 (diff)
mb/ocp/deltalake: Send OEM IPMI command for CMOS clear on RTC failure
When RTC failure is detected, send IPMI OEM command to issue CMOS clear. This is to let the payload (LinuxBoot) handle the IPMI OEM CMOS clear command by resetting RTC data, erasing RW_VPD (TODO) and add a SEL, then reboot the system. Tested=on OCP Delta Lake, after removing RTC battery we can see the above flow can be executed correctly. Signed-off-by: Jingle Hsu <jingle_hsu@wiwynn.com> Change-Id: I27428c02e99040754e15e07782ec1ad8524def2f Reviewed-on: https://review.coreboot.org/c/coreboot/+/43005 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/mainboard/ocp/deltalake/ipmi.c')
-rw-r--r--src/mainboard/ocp/deltalake/ipmi.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/mainboard/ocp/deltalake/ipmi.c b/src/mainboard/ocp/deltalake/ipmi.c
index 9c5a0c0cfe..790038f380 100644
--- a/src/mainboard/ocp/deltalake/ipmi.c
+++ b/src/mainboard/ocp/deltalake/ipmi.c
@@ -129,3 +129,51 @@ void init_frb2_wdt(void)
ipmi_stop_bmc_wdt(CONFIG_BMC_KCS_BASE);
}
}
+
+enum cb_err ipmi_set_cmos_clear(void)
+{
+ int ret;
+
+ struct ipmi_oem_rsp {
+ struct ipmi_rsp resp;
+ struct boot_order data;
+ } __packed;
+
+ struct ipmi_oem_rsp rsp;
+ struct boot_order req;
+
+ /* IPMI OEM get bios boot order command to check if the valid bit and
+ the CMOS clear bit are both set from the response BootMode byte. */
+
+ ret = ipmi_kcs_message(CONFIG_BMC_KCS_BASE, IPMI_NETFN_OEM, 0x0,
+ IPMI_OEM_GET_BIOS_BOOT_ORDER,
+ NULL, 0,
+ (unsigned char *) &rsp, sizeof(rsp));
+
+ if (ret < sizeof(struct ipmi_rsp) || rsp.resp.completion_code) {
+ printk(BIOS_ERR, "IPMI: %s command failed (read ret=%d resp=0x%x)\n",
+ __func__, ret, rsp.resp.completion_code);
+ return CB_ERR;
+ }
+
+ if (!IS_CMOS_AND_VALID_BIT(rsp.data.boot_mode)) {
+ req = rsp.data;
+ SET_CMOS_AND_VALID_BIT(req.boot_mode);
+ ret = ipmi_kcs_message(CONFIG_BMC_KCS_BASE, IPMI_NETFN_OEM, 0x0,
+ IPMI_OEM_SET_BIOS_BOOT_ORDER,
+ (const unsigned char *) &req, sizeof(req),
+ (unsigned char *) &rsp, sizeof(rsp));
+
+ if (ret < sizeof(struct ipmi_rsp) || rsp.resp.completion_code) {
+ printk(BIOS_ERR, "IPMI: %s command failed (sent ret=%d resp=0x%x)\n",
+ __func__, ret, rsp.resp.completion_code);
+ return CB_ERR;
+ }
+
+ printk(BIOS_INFO, "IPMI CMOS clear requested because CMOS data is invalid.\n");
+
+ return CB_SUCCESS;
+ }
+
+ return CB_SUCCESS;
+}