Tim Chu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
drivers/ocp/ipmi: Add ipmi POST start/end command
Add functions of sending POST start/end command to BMC. These functions are used in ramstage.
Signed-off-by: TimChu Tim.Chu@quantatw.com Change-Id: Ide0e2a52876db555ed8b5e919215e85731fd80ed --- 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 4 files changed, 132 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/41605/1
diff --git a/src/drivers/ocp/ipmi/Kconfig b/src/drivers/ocp/ipmi/Kconfig new file mode 100644 index 0000000..95c51c0 --- /dev/null +++ b/src/drivers/ocp/ipmi/Kconfig @@ -0,0 +1,3 @@ +config IPMI_OCP + bool + default n diff --git a/src/drivers/ocp/ipmi/Makefile.inc b/src/drivers/ocp/ipmi/Makefile.inc new file mode 100644 index 0000000..8291f82 --- /dev/null +++ b/src/drivers/ocp/ipmi/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_IPMI_OCP) += ipmi_ocp.c diff --git a/src/drivers/ocp/ipmi/ipmi_ocp.c b/src/drivers/ocp/ipmi/ipmi_ocp.c new file mode 100644 index 0000000..c1766d9 --- /dev/null +++ b/src/drivers/ocp/ipmi/ipmi_ocp.c @@ -0,0 +1,118 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * 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, +}; diff --git a/src/drivers/ocp/ipmi/ipmi_ocp.h b/src/drivers/ocp/ipmi/ipmi_ocp.h new file mode 100644 index 0000000..1cdea2f --- /dev/null +++ b/src/drivers/ocp/ipmi/ipmi_ocp.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#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
Tim Chu has removed Patrick Georgi from this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Removed reviewer Patrick Georgi.
Tim Chu has removed Martin Roth from this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Removed reviewer Martin Roth.
Tim Chu has removed Patrick Georgi from this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Removed reviewer Patrick Georgi.
Tim Chu has removed Martin Roth from this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Removed reviewer Martin Roth.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41605/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/41605/2//COMMIT_MSG@9 PS2, Line 9: of sending to send
Hello build bot (Jenkins), Ryback Hung, Jonathan Zhang, Rocky Phagura, Bryant Ou,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41605
to look at the new patch set (#3).
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
drivers/ocp/ipmi: Add ipmi POST start/end command
Add functions to send POST start/end command to BMC. These functions are used in ramstage.
Signed-off-by: TimChu Tim.Chu@quantatw.com Change-Id: Ide0e2a52876db555ed8b5e919215e85731fd80ed --- 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 4 files changed, 132 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/41605/3
Tim Chu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 3:
(1 comment)
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41605/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/41605/2//COMMIT_MSG@9 PS2, Line 9: of sending
to send
Done
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 3: Code-Review+1
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 3: Code-Review+1
(2 comments)
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... File src/drivers/ocp/ipmi/ipmi_ocp.h:
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... PS1, Line 6: #define IPMI_NETFN_OEM 0x30 Let's add tabs and align to statements below.
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... File src/drivers/ocp/ipmi/ipmi_ocp.c:
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... PS1, Line 28: return 1; Let's include cb_err.h, and use CB_ERR, CB_SUCCESS.
Hello Philipp Deppenwiese, build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Ryback Hung, Johnny Lin, Paul Menzel, Rocky Phagura, Bryant Ou, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41605
to look at the new patch set (#4).
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
drivers/ocp/ipmi: Add ipmi POST start/end command
Add functions to send POST start/end command to BMC. These functions are used in ramstage.
Signed-off-by: TimChu Tim.Chu@quantatw.com Change-Id: Ide0e2a52876db555ed8b5e919215e85731fd80ed --- 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 4 files changed, 132 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/41605/4
Tim Chu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 4:
(2 comments)
Patch Set 3: Code-Review+1
(2 comments)
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... File src/drivers/ocp/ipmi/ipmi_ocp.h:
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... PS1, Line 6: #define IPMI_NETFN_OEM 0x30
Let's add tabs and align to statements below.
Done
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... File src/drivers/ocp/ipmi/ipmi_ocp.c:
https://review.coreboot.org/c/coreboot/+/41605/1/src/drivers/ocp/ipmi/ipmi_o... PS1, Line 28: return 1;
Let's include cb_err.h, and use CB_ERR, CB_SUCCESS.
Done
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 4: Code-Review+1
LGTM
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 4: -Code-Review
With this design, POST start/end IPMI commands are sent during ramstage, when the IPMI_OCP device is initialized and finalized.
Ideally the behavior should be similar to traditional firmware,I think: * POST start IPMI command should be sent as early as possible, in romstage when IPMI communication is established. * POST end IPMI command should be sent as late as possible, either in ramstage just before control is given to payload, or in Linuxboot uinit just before control is given to target OS.
Philipp Deppenwiese has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41605/4/src/drivers/ocp/ipmi/Kconfi... File src/drivers/ocp/ipmi/Kconfig:
https://review.coreboot.org/c/coreboot/+/41605/4/src/drivers/ocp/ipmi/Kconfi... PS4, Line 2: bool description and documentation please
Johnny Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 4:
Patch Set 4: -Code-Review
With this design, POST start/end IPMI commands are sent during ramstage, when the IPMI_OCP device is initialized and finalized.
Ideally the behavior should be similar to traditional firmware,I think:
- POST start IPMI command should be sent as early as possible, in romstage when IPMI communication is established.
- POST end IPMI command should be sent as late as possible, either in ramstage just before control is given to payload, or in Linuxboot uinit just before control is given to target OS.
Another option is to similar to CB:38002, make the functions with kcs_port parameter that can be called from mainboard romstage and ramstage, ex: void supermicro_ipmi_oem(const uint16_t kcs_port);
Tim Chu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: drivers/ocp/ipmi: Add ipmi POST start/end command ......................................................................
Patch Set 4:
Patch Set 4: -Code-Review
With this design, POST start/end IPMI commands are sent during ramstage, when the IPMI_OCP device is initialized and finalized.
Ideally the behavior should be similar to traditional firmware,I think:
- POST start IPMI command should be sent as early as possible, in romstage when IPMI communication is established.
- POST end IPMI command should be sent as late as possible, either in ramstage just before control is given to payload, or in Linuxboot uinit just before control is given to target OS.
For the POST end, function can work in u-root now. For the POST start, since it is ocp specific, I'll add it in drivers/ocp/ipmi and call this function in mainboard_memory_init_params, which may execute in romstage and use ipmi_kcs_premem_init in CB:40234 to check BMC status. However it is a little complicated to use ocp specific command with normal command, I'll try to do it much more clearly.
Hello Philipp Deppenwiese, build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Ryback Hung, Johnny Lin, Christian Walter, Paul Menzel, Rocky Phagura, Bryant Ou, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41605
to look at the new patch set (#5).
Change subject: mb/ocp/deltalake: Add ipmi POST start command in romstage ......................................................................
mb/ocp/deltalake: Add ipmi POST start command in romstage
Add function to send POST start command to BMC. This function is used in romstage and the POST end command will be sent in u-root.
TEST=Read POST command log in OpenBMC, if command received successfully, message may show as below,
root@bmc-oob:~# cat /var/log/messages |grep -i "POST" 2020 Jul 15 16:36:11 bmc-oob. user.info fby3-v2020.23.1: ipmid: POST Start Event for Payload#2 root@bmc-oob:~#
Signed-off-by: TimChu Tim.Chu@quantatw.com Change-Id: Ide0e2a52876db555ed8b5e919215e85731fd80ed --- M src/mainboard/ocp/deltalake/ipmi.c M src/mainboard/ocp/deltalake/ipmi.h M src/mainboard/ocp/deltalake/romstage.c 3 files changed, 28 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/41605/5
Hello Philipp Deppenwiese, build bot (Jenkins), Patrick Georgi, Martin Roth, Jonathan Zhang, Ryback Hung, Johnny Lin, Christian Walter, Paul Menzel, Rocky Phagura, Bryant Ou, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41605
to look at the new patch set (#6).
Change subject: mb/ocp/deltalake: Add ipmi POST start command in romstage ......................................................................
mb/ocp/deltalake: Add ipmi POST start command in romstage
Add function to send POST start command to BMC. This function is used in romstage and the POST end command will be sent in u-root.
TEST=Read POST command log in OpenBMC, if command received successfully, message may show as below,
root@bmc-oob:~# cat /var/log/messages |grep -i "POST" 2020 Jul 15 16:36:11 bmc-oob. user.info fby3-v2020.23.1: ipmid: POST Start Event for Payload#2 root@bmc-oob:~#
Signed-off-by: TimChu Tim.Chu@quantatw.com Change-Id: Ide0e2a52876db555ed8b5e919215e85731fd80ed --- M src/mainboard/ocp/deltalake/ipmi.c M src/mainboard/ocp/deltalake/ipmi.h M src/mainboard/ocp/deltalake/romstage.c 3 files changed, 28 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/41605/6
Tim Chu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: mb/ocp/deltalake: Add ipmi POST start command in romstage ......................................................................
Patch Set 6:
(1 comment)
Still thanks.
https://review.coreboot.org/c/coreboot/+/41605/4/src/drivers/ocp/ipmi/Kconfi... File src/drivers/ocp/ipmi/Kconfig:
https://review.coreboot.org/c/coreboot/+/41605/4/src/drivers/ocp/ipmi/Kconfi... PS4, Line 2: bool
description and documentation please
This file has been cancelled.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: mb/ocp/deltalake: Add ipmi POST start command in romstage ......................................................................
Patch Set 6: Code-Review+2
Angel Pons has submitted this change. ( https://review.coreboot.org/c/coreboot/+/41605 )
Change subject: mb/ocp/deltalake: Add ipmi POST start command in romstage ......................................................................
mb/ocp/deltalake: Add ipmi POST start command in romstage
Add function to send POST start command to BMC. This function is used in romstage and the POST end command will be sent in u-root.
TEST=Read POST command log in OpenBMC, if command received successfully, message may show as below,
root@bmc-oob:~# cat /var/log/messages |grep -i "POST" 2020 Jul 15 16:36:11 bmc-oob. user.info fby3-v2020.23.1: ipmid: POST Start Event for Payload#2 root@bmc-oob:~#
Signed-off-by: TimChu Tim.Chu@quantatw.com Change-Id: Ide0e2a52876db555ed8b5e919215e85731fd80ed Reviewed-on: https://review.coreboot.org/c/coreboot/+/41605 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M src/mainboard/ocp/deltalake/ipmi.c M src/mainboard/ocp/deltalake/ipmi.h M src/mainboard/ocp/deltalake/romstage.c 3 files changed, 28 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/src/mainboard/ocp/deltalake/ipmi.c b/src/mainboard/ocp/deltalake/ipmi.c index acff3db..9c5a0c0 100644 --- a/src/mainboard/ocp/deltalake/ipmi.c +++ b/src/mainboard/ocp/deltalake/ipmi.c @@ -75,6 +75,29 @@ return CB_SUCCESS; }
+enum cb_err ipmi_set_post_start(const int port) +{ + int ret; + struct ipmi_rsp rsp; + + ret = ipmi_kcs_message(port, IPMI_NETFN_OEM, 0x0, + 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 CB_ERR; + } + if (ret != sizeof(rsp)) { + printk(BIOS_ERR, "IPMI: %s response truncated\n", __func__); + return CB_ERR; + } + + printk(BIOS_DEBUG, "IPMI BMC POST is started\n"); + return CB_SUCCESS; +} + void init_frb2_wdt(void) { char val[VPD_LEN]; diff --git a/src/mainboard/ocp/deltalake/ipmi.h b/src/mainboard/ocp/deltalake/ipmi.h index 840f999..bb0b4a6 100644 --- a/src/mainboard/ocp/deltalake/ipmi.h +++ b/src/mainboard/ocp/deltalake/ipmi.h @@ -9,6 +9,7 @@ #define IPMI_OEM_SET_PPIN 0x77 #define IPMI_OEM_GET_PCIE_CONFIG 0xf4 #define IPMI_OEM_GET_BOARD_ID 0x37 +#define IPMI_BMC_SET_POST_START 0x73
enum config_type { PCIE_CONFIG_UNKNOWN = 0x0, @@ -28,5 +29,6 @@ enum cb_err ipmi_set_ppin(struct ppin_req *req); enum cb_err ipmi_get_pcie_config(uint8_t *config); enum cb_err ipmi_get_slot_id(uint8_t *slot_id); +enum cb_err ipmi_set_post_start(const int port); void init_frb2_wdt(void); #endif diff --git a/src/mainboard/ocp/deltalake/romstage.c b/src/mainboard/ocp/deltalake/romstage.c index 52679df..b366fd9 100644 --- a/src/mainboard/ocp/deltalake/romstage.c +++ b/src/mainboard/ocp/deltalake/romstage.c @@ -117,8 +117,10 @@ { /* Since it's the first IPMI command, it's better to run get BMC selftest result first */ - if (ipmi_kcs_premem_init(CONFIG_BMC_KCS_BASE, 0) == CB_SUCCESS) + if (ipmi_kcs_premem_init(CONFIG_BMC_KCS_BASE, 0) == CB_SUCCESS) { + ipmi_set_post_start(CONFIG_BMC_KCS_BASE); init_frb2_wdt(); + }
mainboard_config_gpios(mupd); mainboard_config_iio(mupd);