Johnny Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 129 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/1
diff --git a/src/drivers/ipmi/Kconfig b/src/drivers/ipmi/Kconfig index 37cfc0d..0304cb0 100644 --- a/src/drivers/ipmi/Kconfig +++ b/src/drivers/ipmi/Kconfig @@ -18,3 +18,10 @@ IPMB messages are limited to 32-bytes total. When the data size is larger than this value, IPMI can complete reading/writing the data over multiple commands. + +config IPMI_KCS_ROMSTAGE + bool + default n + depends on IPMI_KCS + help + IPMI KCS support in romstage. diff --git a/src/drivers/ipmi/Makefile.inc b/src/drivers/ipmi/Makefile.inc index 973fff8..06a3433 100644 --- a/src/drivers/ipmi/Makefile.inc +++ b/src/drivers/ipmi/Makefile.inc @@ -2,3 +2,6 @@ ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs_ops.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_ops.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_fru.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_ops.c diff --git a/src/drivers/ipmi/ipmi_kcs.h b/src/drivers/ipmi/ipmi_kcs.h index 9a04377..5de77ed 100644 --- a/src/drivers/ipmi/ipmi_kcs.h +++ b/src/drivers/ipmi/ipmi_kcs.h @@ -40,6 +40,9 @@ const unsigned char *inmsg, int inlen, unsigned char *outmsg, int outlen);
+/* Run basic IPMI init functions in romstage from the provided PnP device */ +void ipmi_kcs_premem_init(const u16 port, const u16 device); + struct ipmi_rsp { uint8_t lun; uint8_t cmd; diff --git a/src/drivers/ipmi/ipmi_kcs_ops_premem.c b/src/drivers/ipmi/ipmi_kcs_ops_premem.c new file mode 100644 index 0000000..e601041 --- /dev/null +++ b/src/drivers/ipmi/ipmi_kcs_ops_premem.c @@ -0,0 +1,116 @@ +/* + * 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 <console/console.h> + +#include <device/pnp.h> +#include <delay.h> +#include <timer.h> +#include "ipmi_kcs.h" +#include "chip.h" + +static int ipmi_get_bmc_self_test_result(const struct device *dev, + struct ipmi_selftest_rsp *rsp) +{ + int ret; + + ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_APPLICATION, 0, + IPMI_BMC_GET_SELFTEST_RESULTS, NULL, 0, (u8 *)rsp, + sizeof(*rsp)); + + if (ret < sizeof(struct ipmi_rsp) || rsp->resp.completion_code) { + printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n", + __func__, ret, rsp->resp.completion_code); + return 1; + } + if (ret != sizeof(*rsp)) { + printk(BIOS_ERR, "IPMI: %s response truncated\n", __func__); + return 1; + } + + return 0; +} + +void ipmi_kcs_premem_init(const u16 port, const u16 device) +{ + const struct drivers_ipmi_config *conf = NULL; + struct ipmi_selftest_rsp selftestrsp; + uint8_t retry_count; + const struct device *dev; + + /* Find IPMI pnp device from devicetree in romstage */ + dev = dev_find_slot_pnp(port, device); + + if (!dev) { + printk(BIOS_ERR, "IPMI: Cannot find pnp device port: %x, device %x\n", + port, device); + return; + } + if (!dev->enabled) + return; + + printk(BIOS_DEBUG, "IPMI: romstage PNP KCS 0x%x\n", dev->path.pnp.port); + if (dev->chip_info) + conf = dev->chip_info; + + if (conf && conf->wait_for_bmc && conf->bmc_boot_timeout) { + struct stopwatch sw; + stopwatch_init_msecs_expire(&sw, conf->bmc_boot_timeout * 1000); + printk(BIOS_INFO, "IPMI: Waiting for BMC...\n"); + + while (!stopwatch_expired(&sw)) { + if (inb(dev->path.pnp.port) != 0xff) + break; + mdelay(100); + } + if (stopwatch_expired(&sw)) { + printk(BIOS_INFO, "IPMI: Waiting for BMC timed out\n"); + return; + } + } + + printk(BIOS_INFO, "Get BMC self test result..."); + for (retry_count = 0; retry_count < conf->bmc_boot_timeout; retry_count++) { + if (!ipmi_get_bmc_self_test_result(dev, &selftestrsp)) + break; + + mdelay(1000); + } + + switch (selftestrsp.result) { + case IPMI_APP_SELFTEST_NO_ERROR: /* 0x55 */ + printk(BIOS_DEBUG, "No Error\n"); + break; + case IPMI_APP_SELFTEST_NOT_IMPLEMENTED: /* 0x56 */ + printk(BIOS_DEBUG, "Function Not Implemented\n"); + break; + case IPMI_APP_SELFTEST_ERROR: /* 0x57 */ + printk(BIOS_ERR, "BMC: Corrupted or inaccessible data or device\n"); + /* Don't write tables if communication failed */ + break; + case IPMI_APP_SELFTEST_FATAL_HW_ERROR: /* 0x58 */ + printk(BIOS_ERR, "BMC: Fatal Hardware Error\n"); + /* Don't write tables if communication failed */ + break; + case IPMI_APP_SELFTEST_RESERVED: /* 0xFF */ + printk(BIOS_DEBUG, "Reserved\n"); + break; + + default: /* Other Device Specific Hardware Error */ + printk(BIOS_ERR, "BMC: Device Specific Error\n"); + /* Don't write tables if communication failed */ + break; + } + +}
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#2).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 126 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/2
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#3).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 126 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/3
Andrey Petrov has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 2:
(2 comments)
looks good, thanks. just some minor style nits
https://review.coreboot.org/c/coreboot/+/40234/2/src/drivers/ipmi/ipmi_kcs_o... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/2/src/drivers/ipmi/ipmi_kcs_o... PS2, Line 1: * : * 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. : */ please update license header to new SPDX format
https://review.coreboot.org/c/coreboot/+/40234/2/src/drivers/ipmi/ipmi_kcs_o... PS2, Line 16: nit: why blank like here? I don't think it is needed
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#4).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 115 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/4
Johnny Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/c/coreboot/+/40234/2/src/drivers/ipmi/ipmi_kcs_o... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/2/src/drivers/ipmi/ipmi_kcs_o... PS2, Line 1: * : * 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. : */
please update license header to new SPDX format
Done
https://review.coreboot.org/c/coreboot/+/40234/2/src/drivers/ipmi/ipmi_kcs_o... PS2, Line 16:
nit: why blank like here? I don't think it is needed
Done
Andrey Petrov has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 4: Code-Review+2
Christian Walter has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40234/4/src/drivers/ipmi/ipmi_kcs_o... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/4/src/drivers/ipmi/ipmi_kcs_o... PS4, Line 98: printk(BIOS_ERR, "BMC: Device Specific Error\n"); Print error code here? As it is device specific, it would help if we print it here.
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#5).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 115 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/5
Johnny Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40234/4/src/drivers/ipmi/ipmi_kcs_o... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/4/src/drivers/ipmi/ipmi_kcs_o... PS4, Line 98: printk(BIOS_ERR, "BMC: Device Specific Error\n");
Print error code here? As it is device specific, it would help if we print it here.
Done
Christian Walter has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 5: Code-Review+1
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/c/coreboot/+/40234/5/src/drivers/ipmi/ipmi_kcs_o... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/5/src/drivers/ipmi/ipmi_kcs_o... PS5, Line 34: void ipmi_kcs_premem_init(const u16 port, const u16 device) This function should return a status. If the status is good, caller will proceed with BMC interactions (in romstage). If the status is not good, caller should skip BMC interaction in romstage, and try to test if BMC is up in ramstage. The principle is that if BMC is up, great we can do lots of things. But if BMC is not up, we manage to boot with reduced functionality.
https://review.coreboot.org/c/coreboot/+/40234/5/src/drivers/ipmi/ipmi_kcs_o... PS5, Line 37: struct ipmi_selftest_rsp selftestrsp; This needs to be zero initialized. There is a chance that BMC is not booted up to respond to BMC self test IPMI command till bmc_boot_timeout.
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#6).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 122 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/6
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#7).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 122 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/7
Johnny Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 7:
(2 comments)
https://review.coreboot.org/c/coreboot/+/40234/5/src/drivers/ipmi/ipmi_kcs_o... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/5/src/drivers/ipmi/ipmi_kcs_o... PS5, Line 34: void ipmi_kcs_premem_init(const u16 port, const u16 device)
This function should return a status. […]
Done
https://review.coreboot.org/c/coreboot/+/40234/5/src/drivers/ipmi/ipmi_kcs_o... PS5, Line 37: struct ipmi_selftest_rsp selftestrsp;
This needs to be zero initialized. […]
Done
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 7: Code-Review+1
LGTM
Christian Walter has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 10: Code-Review+1
Morgan Jang has uploaded a new patch set (#22) to the change originally created by Johnny Lin. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 122 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/22
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#23).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 122 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/23
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#25).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 122 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/25
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#29).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 121 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/29
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#31).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Add CONFIG_BMC_KCS_BASE for BMC KCS port address that can be used across romstage and ramstage.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 129 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/31
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 32: Code-Review+1
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 33:
(6 comments)
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/Kconfig File src/drivers/ipmi/Kconfig:
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/Kconfig@2... PS33, Line 29: BMC_KCS_BASE not used in code
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 73: conf possible null pointer dereference
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 83: No message is not useful as it doesn't have a prefix
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 87: printk(BIOS_DEBUG, "Function Not Implemented\n"); message is not useful as it doesn't have a prefix
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 91: BMC why is it prefixed with BMC?
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 97: printk(BIOS_DEBUG, "Reserved\n"); message is not useful as it doesn't have a prefix
Hello Philipp Deppenwiese, build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Christian Walter, David Hendricks, Jingle Hsu, Morgan Jang, Andrey Petrov, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/40234
to look at the new patch set (#35).
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Add CONFIG_BMC_KCS_BASE for BMC KCS port address that can be used across romstage and ramstage.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 134 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40234/35
Johnny Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 35:
(6 comments)
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/Kconfig File src/drivers/ipmi/Kconfig:
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/Kconfig@2... PS33, Line 29: BMC_KCS_BASE
not used in code
It's used in later depending changes, for examples: https://review.coreboot.org/c/coreboot/+/42495/10/src/mainboard/ocp/deltalak... https://review.coreboot.org/c/coreboot/+/41279/17/src/mainboard/ocp/deltalak...
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... File src/drivers/ipmi/ipmi_kcs_ops_premem.c:
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 73: conf
possible null pointer dereference
Done
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 83: No
message is not useful as it doesn't have a prefix
This is a continuation of the "Get BMC self test result" printk on L72, similar comment was discussed before at https://review.coreboot.org/c/coreboot/+/36638/9/src/drivers/ipmi/ipmi_kcs_o...
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 87: printk(BIOS_DEBUG, "Function Not Implemented\n");
message is not useful as it doesn't have a prefix
This is a continuation of the "Get BMC self test result" printk on L72.
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 91: BMC
why is it prefixed with BMC?
Done
https://review.coreboot.org/c/coreboot/+/40234/33/src/drivers/ipmi/ipmi_kcs_... PS33, Line 97: printk(BIOS_DEBUG, "Reserved\n");
message is not useful as it doesn't have a prefix
This is a continuation of the "Get BMC self test result" printk on L72.
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 35: Code-Review+1
LGTM
Philipp Deppenwiese has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
Patch Set 36: Code-Review+2
Philipp Deppenwiese has submitted this change. ( https://review.coreboot.org/c/coreboot/+/40234 )
Change subject: drivers/ipmi: Add IPMI KCS support in romstage ......................................................................
drivers/ipmi: Add IPMI KCS support in romstage
It's necessary to run IPMI commands in romstage for writing error SEL such as memory initialization error SEL, and also for other usages such as starting FRB2 timer, OEM commands, etc.
Add CONFIG_BMC_KCS_BASE for BMC KCS port address that can be used across romstage and ramstage.
Change-Id: Ie3198965670454b123e570f9056673fdf515f52b Signed-off-by: Johnny Lin johnny_lin@wiwynn.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/40234 Reviewed-by: Philipp Deppenwiese zaolin.daisuki@gmail.com Reviewed-by: Jonathan Zhang jonzhang@fb.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/ipmi/Kconfig M src/drivers/ipmi/Makefile.inc M src/drivers/ipmi/ipmi_kcs.h A src/drivers/ipmi/ipmi_kcs_ops_premem.c 4 files changed, 134 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Philipp Deppenwiese: Looks good to me, approved Jonathan Zhang: Looks good to me, but someone else must approve
diff --git a/src/drivers/ipmi/Kconfig b/src/drivers/ipmi/Kconfig index 37cfc0d..44ed17e 100644 --- a/src/drivers/ipmi/Kconfig +++ b/src/drivers/ipmi/Kconfig @@ -18,3 +18,18 @@ IPMB messages are limited to 32-bytes total. When the data size is larger than this value, IPMI can complete reading/writing the data over multiple commands. + +config IPMI_KCS_ROMSTAGE + bool + default n + depends on IPMI_KCS + help + IPMI KCS support in romstage. + +config BMC_KCS_BASE + hex + default 0xca2 + depends on IPMI_KCS + help + The PNP base address of BMC KCS. It must be equal to the + pnp port value defined in devicetree for chip drivers/ipmi. diff --git a/src/drivers/ipmi/Makefile.inc b/src/drivers/ipmi/Makefile.inc index 973fff8..06a3433 100644 --- a/src/drivers/ipmi/Makefile.inc +++ b/src/drivers/ipmi/Makefile.inc @@ -2,3 +2,6 @@ ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs_ops.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_ops.c ramstage-$(CONFIG_IPMI_KCS) += ipmi_fru.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_ops.c diff --git a/src/drivers/ipmi/ipmi_kcs.h b/src/drivers/ipmi/ipmi_kcs.h index 910d921..501e5dd 100644 --- a/src/drivers/ipmi/ipmi_kcs.h +++ b/src/drivers/ipmi/ipmi_kcs.h @@ -29,6 +29,10 @@ const unsigned char *inmsg, int inlen, unsigned char *outmsg, int outlen);
+/* Run basic IPMI init functions in romstage from the provided PnP device, + * returns CB_SUCCESS on success and CB_ERR if an error occurred. */ +enum cb_err ipmi_kcs_premem_init(const u16 port, const u16 device); + struct ipmi_rsp { uint8_t lun; uint8_t cmd; diff --git a/src/drivers/ipmi/ipmi_kcs_ops_premem.c b/src/drivers/ipmi/ipmi_kcs_ops_premem.c new file mode 100644 index 0000000..d799be1 --- /dev/null +++ b/src/drivers/ipmi/ipmi_kcs_ops_premem.c @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/pnp.h> +#include <delay.h> +#include <timer.h> + +#include "ipmi_kcs.h" +#include "chip.h" + +static int ipmi_get_bmc_self_test_result(const struct device *dev, + struct ipmi_selftest_rsp *rsp) +{ + int ret; + + ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_APPLICATION, 0, + IPMI_BMC_GET_SELFTEST_RESULTS, NULL, 0, (u8 *)rsp, + sizeof(*rsp)); + + if (ret < sizeof(struct ipmi_rsp) || rsp->resp.completion_code) { + printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n", + __func__, ret, rsp->resp.completion_code); + return 1; + } + if (ret != sizeof(*rsp)) { + printk(BIOS_ERR, "IPMI: %s response truncated\n", __func__); + return 1; + } + + return 0; +} + +enum cb_err ipmi_kcs_premem_init(const u16 port, const u16 device) +{ + const struct drivers_ipmi_config *conf = NULL; + struct ipmi_selftest_rsp selftestrsp = {0}; + uint8_t retry_count; + const struct device *dev; + + /* Find IPMI PNP device from devicetree in romstage */ + dev = dev_find_slot_pnp(port, device); + + if (!dev) { + printk(BIOS_ERR, "IPMI: Cannot find PNP device port: %x, device %x\n", + port, device); + return CB_ERR; + } + if (!dev->enabled) { + printk(BIOS_ERR, "IPMI: device is not enabled\n"); + return CB_ERR; + } + printk(BIOS_DEBUG, "IPMI: romstage PNP KCS 0x%x\n", dev->path.pnp.port); + if (dev->chip_info) + conf = dev->chip_info; + + if (conf && conf->wait_for_bmc && conf->bmc_boot_timeout) { + struct stopwatch sw; + stopwatch_init_msecs_expire(&sw, conf->bmc_boot_timeout * 1000); + printk(BIOS_DEBUG, "IPMI: Waiting for BMC...\n"); + + while (!stopwatch_expired(&sw)) { + if (inb(dev->path.pnp.port) != 0xff) + break; + mdelay(100); + } + if (stopwatch_expired(&sw)) { + printk(BIOS_INFO, "IPMI: Waiting for BMC timed out\n"); + return CB_ERR; + } + } + + printk(BIOS_INFO, "Get BMC self test result..."); + if (conf && conf->bmc_boot_timeout) { + for (retry_count = 0; retry_count < conf->bmc_boot_timeout; retry_count++) { + if (!ipmi_get_bmc_self_test_result(dev, &selftestrsp)) + break; + + mdelay(1000); + } + } else { + /* At least run once */ + ipmi_get_bmc_self_test_result(dev, &selftestrsp); + } + + int ret = CB_ERR; + switch (selftestrsp.result) { + case IPMI_APP_SELFTEST_NO_ERROR: /* 0x55 */ + printk(BIOS_DEBUG, "No Error\n"); + ret = CB_SUCCESS; + break; + case IPMI_APP_SELFTEST_NOT_IMPLEMENTED: /* 0x56 */ + printk(BIOS_DEBUG, "Function Not Implemented\n"); + ret = CB_SUCCESS; + break; + case IPMI_APP_SELFTEST_ERROR: /* 0x57 */ + printk(BIOS_ERR, "Corrupted or inaccessible data or device\n"); + break; + case IPMI_APP_SELFTEST_FATAL_HW_ERROR: /* 0x58 */ + printk(BIOS_ERR, "Fatal Hardware Error\n"); + break; + case IPMI_APP_SELFTEST_RESERVED: /* 0xFF */ + printk(BIOS_DEBUG, "Reserved\n"); + ret = CB_SUCCESS; + break; + + default: /* Other Device Specific Hardware Error */ + printk(BIOS_ERR, "Device Specific Error 0x%x 0x%x\n", selftestrsp.result, + selftestrsp.param); + break; + } + return ret; +}