diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2022-12-13 17:01:22 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-12-14 16:05:50 +0000 |
commit | 84429e092f1c80f6e05e9d15f675923eb043352e (patch) | |
tree | 5068d66297a5a2e6c1374a64ea2658454ac7fc41 /src/soc/amd/common/block | |
parent | 4f2b5a5dbd40d6b1561c872a8883b124a8e24008 (diff) |
soc/amd/common/block/lpc/espi_util: make eSPI pin setup failure nonfatal
Improve the eSPI pin configuration setup so that a failure in there
won't call die() and stop booting at this point, but return an error to
the caller so that the rest of the eSPI configuration will be skipped.
This will prevent an early boot failure if the EC is missing or the eSPI
interface is in a non-functional state. Also slightly shorten the
function names so that the code still fits into 96 chars.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Ice2d3a791d6a464eff4fb69d02aeca0bfe580be2
Reviewed-on: https://review.coreboot.org/c/coreboot/+/70730
Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-by: Nikolai Vyssotski <nikolai.vyssotski@amd.corp-partner.google.com>
Diffstat (limited to 'src/soc/amd/common/block')
-rw-r--r-- | src/soc/amd/common/block/lpc/espi_util.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/soc/amd/common/block/lpc/espi_util.c b/src/soc/amd/common/block/lpc/espi_util.c index 4fc050b0ee..4b23b3f10e 100644 --- a/src/soc/amd/common/block/lpc/espi_util.c +++ b/src/soc/amd/common/block/lpc/espi_util.c @@ -680,8 +680,8 @@ static enum cb_err espi_get_general_configuration(uint32_t *config) return CB_SUCCESS; } -static void espi_set_io_mode_config(enum espi_io_mode mb_io_mode, uint32_t slave_caps, - uint32_t *slave_config, uint32_t *ctrlr_config) +static enum cb_err espi_set_io_mode_cfg(enum espi_io_mode mb_io_mode, uint32_t slave_caps, + uint32_t *slave_config, uint32_t *ctrlr_config) { switch (mb_io_mode) { case ESPI_IO_MODE_QUAD: @@ -706,12 +706,14 @@ static void espi_set_io_mode_config(enum espi_io_mode mb_io_mode, uint32_t slave *ctrlr_config |= ESPI_IO_MODE_SINGLE; break; default: - die("No supported eSPI I/O modes!\n"); + printk(BIOS_ERR, "No supported eSPI I/O modes!\n"); + return CB_ERR; } + return CB_SUCCESS; } -static void espi_set_op_freq_config(enum espi_op_freq mb_op_freq, uint32_t slave_caps, - uint32_t *slave_config, uint32_t *ctrlr_config) +static enum cb_err espi_set_op_freq_cfg(enum espi_op_freq mb_op_freq, uint32_t slave_caps, + uint32_t *slave_config, uint32_t *ctrlr_config) { int slave_max_speed_mhz = espi_slave_max_speed_mhz_supported(slave_caps); @@ -744,30 +746,35 @@ static void espi_set_op_freq_config(enum espi_op_freq mb_op_freq, uint32_t slave } __fallthrough; default: - die("No supported eSPI Operating Frequency!\n"); + printk(BIOS_ERR, "No supported eSPI Operating Frequency!\n"); + return CB_ERR; } + return CB_SUCCESS; } -static void espi_set_alert_pin_config(enum espi_alert_pin alert_pin, uint32_t slave_caps, - uint32_t *slave_config, uint32_t *ctrlr_config) +static enum cb_err espi_set_alert_pin_cfg(enum espi_alert_pin alert_pin, uint32_t slave_caps, + uint32_t *slave_config, uint32_t *ctrlr_config) { switch (alert_pin) { case ESPI_ALERT_PIN_IN_BAND: *slave_config |= ESPI_SLAVE_ALERT_MODE_IO1; - return; + return CB_SUCCESS; case ESPI_ALERT_PIN_PUSH_PULL: *slave_config |= ESPI_SLAVE_ALERT_MODE_PIN | ESPI_SLAVE_PUSH_PULL_ALERT_SEL; *ctrlr_config |= ESPI_ALERT_MODE; - return; + return CB_SUCCESS; case ESPI_ALERT_PIN_OPEN_DRAIN: - if (!(slave_caps & ESPI_SLAVE_OPEN_DRAIN_ALERT_SUPP)) - die("eSPI peripheral does not support open drain alert!"); + if (!(slave_caps & ESPI_SLAVE_OPEN_DRAIN_ALERT_SUPP)) { + printk(BIOS_ERR, "eSPI peripheral does not support open drain alert!"); + return CB_ERR; + } *slave_config |= ESPI_SLAVE_ALERT_MODE_PIN | ESPI_SLAVE_OPEN_DRAIN_ALERT_SEL; *ctrlr_config |= ESPI_ALERT_MODE; - return; + return CB_SUCCESS; default: - die("Unknown espi alert config: %u!\n", alert_pin); + printk(BIOS_ERR, "Unknown espi alert config: %u!\n", alert_pin); + return CB_ERR; } } @@ -782,9 +789,15 @@ static enum cb_err espi_set_general_configuration(const struct espi_config *mb_c ctrlr_config |= ESPI_CRC_CHECKING_EN; } - espi_set_alert_pin_config(mb_cfg->alert_pin, slave_caps, &slave_config, &ctrlr_config); - espi_set_io_mode_config(mb_cfg->io_mode, slave_caps, &slave_config, &ctrlr_config); - espi_set_op_freq_config(mb_cfg->op_freq_mhz, slave_caps, &slave_config, &ctrlr_config); + if (espi_set_alert_pin_cfg(mb_cfg->alert_pin, slave_caps, &slave_config, &ctrlr_config) + != CB_SUCCESS) + return CB_ERR; + if (espi_set_io_mode_cfg(mb_cfg->io_mode, slave_caps, &slave_config, &ctrlr_config) + != CB_SUCCESS) + return CB_ERR; + if (espi_set_op_freq_cfg(mb_cfg->op_freq_mhz, slave_caps, &slave_config, &ctrlr_config) + != CB_SUCCESS) + return CB_ERR; if (CONFIG(ESPI_DEBUG)) printk(BIOS_INFO, "Setting general configuration: slave: 0x%x controller: 0x%x\n", |