diff --git a/src/mainboard/ocp/tiogapass/include/tp_pch_gpio.h b/src/mainboard/ocp/tiogapass/include/tp_pch_gpio.h index ac4422a387..27ae3d49db 100644 --- a/src/mainboard/ocp/tiogapass/include/tp_pch_gpio.h +++ b/src/mainboard/ocp/tiogapass/include/tp_pch_gpio.h @@ -5,6 +5,8 @@ #include +#define GPIO_BMC_READY_N GPP_F4 + /* Pad configuration table for C621 Lewisburg PCH */ static const struct pad_config gpio_table[] = { /* ------- GPIO Community 0 ------- */ @@ -116,7 +118,7 @@ static const struct pad_config gpio_table[] = { PAD_CFG_GPI_TRIG_OWN(GPP_F2, NONE, DEEP, OFF, DRIVER), /* GPP_F3 - GPIO */ PAD_CFG_GPI_TRIG_OWN(GPP_F3, NONE, DEEP, OFF, DRIVER), - /* GPP_F4 - GPIO */ + /* GPP_F4 - BMC_READY_N */ PAD_CFG_GPI_TRIG_OWN(GPP_F4, NONE, DEEP, OFF, DRIVER), /* GPP_F5 - GPIO */ PAD_CFG_GPI_TRIG_OWN(GPP_F5, NONE, DEEP, OFF, DRIVER), diff --git a/src/mainboard/ocp/tiogapass/romstage.c b/src/mainboard/ocp/tiogapass/romstage.c index 283d5f1266..276285ae03 100644 --- a/src/mainboard/ocp/tiogapass/romstage.c +++ b/src/mainboard/ocp/tiogapass/romstage.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include #include #include @@ -10,8 +11,10 @@ #include #include #include +#include #include "ipmi.h" +#include "tp_pch_gpio.h" static uint8_t iio_table_buf[sizeof(tp_iio_bifur_table)]; @@ -52,8 +55,31 @@ static void mainboard_config_iio(FSPM_UPD *mupd) oem_update_iio(mupd); } +static void mainboard_wait_for_bmc_ready(void) +{ + struct stopwatch sw; + static const long timeout_ms = 300 * 1000; + + printk(BIOS_DEBUG, "Waiting for BMC ready\n"); + gpio_input(GPIO_BMC_READY_N); + + stopwatch_init_msecs_expire(&sw, timeout_ms); + while (gpio_get(GPIO_BMC_READY_N)) { + if (stopwatch_expired(&sw)) { + printk(BIOS_WARNING, + "BMC not ready after %ld ms. Abort.\n", timeout_ms); + return; + } + } + printk(BIOS_DEBUG, "BMC ready after %lld ms\n", + stopwatch_duration_msecs(&sw)); +} + void mainboard_memory_init_params(FSPM_UPD *mupd) { + /* Need to wait for BMC ready so that IPMI works. */ + mainboard_wait_for_bmc_ready(); + /* It's better to run get BMC selftest result first */ if (ipmi_premem_init(CONFIG_BMC_KCS_BASE, 0) == CB_SUCCESS) { ipmi_set_post_start(CONFIG_BMC_KCS_BASE);