Attention is currently required from: Jason Glenesk, Raul Rangel, Marshall Dawson. Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/60208 )
Change subject: soc/amd/common/lpc/espi_util: use enum cb_err type for return values ......................................................................
soc/amd/common/lpc/espi_util: use enum cb_err type for return values
Use enum cb_err as return type of all remaining functions that only return success or failure.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: I6cff8480d99641fdfb613bb3e4edc4055ad5efc6 --- M src/soc/amd/common/block/include/amdblocks/espi.h M src/soc/amd/common/block/lpc/espi_util.c 2 files changed, 29 insertions(+), 33 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/08/60208/1
diff --git a/src/soc/amd/common/block/include/amdblocks/espi.h b/src/soc/amd/common/block/include/amdblocks/espi.h index f9e2570..adb9a1d 100644 --- a/src/soc/amd/common/block/include/amdblocks/espi.h +++ b/src/soc/amd/common/block/include/amdblocks/espi.h @@ -3,8 +3,7 @@ #ifndef AMD_BLOCK_ESPI_H #define AMD_BLOCK_ESPI_H
-#include <stdint.h> -#include <stddef.h> +#include <types.h>
/* eSPI MMIO base lives at an offset of 0x10000 from the address in SPI BAR. */ #define ESPI_OFFSET_FROM_BAR 0x10000 @@ -106,15 +105,13 @@
/* * Open I/O window using the provided base and size. - * Return value: 0 = success, -1 = error. */ -int espi_open_io_window(uint16_t base, size_t size); +enum cb_err espi_open_io_window(uint16_t base, size_t size);
/* * Open MMIO window using the provided base and size. - * Return value: 0 = success, -1 = error. */ -int espi_open_mmio_window(uint32_t base, size_t size); +enum cb_err espi_open_mmio_window(uint32_t base, size_t size);
/* * In cases where eSPI BAR is statically provided by SoC, use that BAR instead of reading @@ -124,9 +121,8 @@
/* * Perform eSPI connection setup to the slave. Currently, this supports slave0 only. - * Returns 0 on success and -1 on error. */ -int espi_setup(void); +enum cb_err espi_setup(void);
/* Run mainboard configuration needed to set up eSPI */ void mb_set_up_early_espi(void); diff --git a/src/soc/amd/common/block/lpc/espi_util.c b/src/soc/amd/common/block/lpc/espi_util.c index e27167a..4c42c04 100644 --- a/src/soc/amd/common/block/lpc/espi_util.c +++ b/src/soc/amd/common/block/lpc/espi_util.c @@ -156,7 +156,7 @@ espi_write8(ESPI_IO_RANGE_SIZE(idx), size - 1); }
-static int espi_open_generic_io_window(uint16_t base, size_t size) +static enum cb_err espi_open_generic_io_window(uint16_t base, size_t size) { size_t win_size; int idx; @@ -186,24 +186,24 @@ printk(BIOS_ERR, "Cannot open IO window base %x size %zx\n", base, size); printk(BIOS_ERR, "ERROR: No more available IO windows!\n"); - return -1; + return CB_ERR; }
espi_write_io_window(idx, base, win_size); espi_enable_decode(ESPI_DECODE_IO_RANGE_EN(idx)); }
- return 0; + return CB_SUCCESS; }
-int espi_open_io_window(uint16_t base, size_t size) +enum cb_err espi_open_io_window(uint16_t base, size_t size) { int std_io;
std_io = espi_std_io_decode(base, size); if (std_io != -1) { espi_enable_decode(std_io); - return 0; + return CB_SUCCESS; } else { return espi_open_generic_io_window(base, size); } @@ -248,7 +248,7 @@ espi_write16(ESPI_MMIO_RANGE_SIZE(idx), size - 1); }
-int espi_open_mmio_window(uint32_t base, size_t size) +enum cb_err espi_open_mmio_window(uint32_t base, size_t size) { size_t win_size; int idx; @@ -278,14 +278,14 @@ printk(BIOS_ERR, "Cannot open IO window base %x size %zx\n", base, size); printk(BIOS_ERR, "ERROR: No more available MMIO windows!\n"); - return -1; + return CB_ERR; }
espi_write_mmio_window(idx, base, win_size); espi_enable_decode(ESPI_DECODE_MMIO_RANGE_EN(idx)); }
- return 0; + return CB_SUCCESS; }
static const struct espi_config *espi_get_config(void) @@ -298,7 +298,7 @@ return &soc_cfg->espi_config; }
-static int espi_configure_decodes(const struct espi_config *cfg) +static enum cb_err espi_configure_decodes(const struct espi_config *cfg) { int i;
@@ -308,11 +308,11 @@ if (cfg->generic_io_range[i].size == 0) continue; if (espi_open_generic_io_window(cfg->generic_io_range[i].base, - cfg->generic_io_range[i].size)) - return -1; + cfg->generic_io_range[i].size) != CB_SUCCESS) + return CB_ERR; }
- return 0; + return CB_SUCCESS; }
#define ESPI_DN_TX_HDR0 0x00 @@ -943,7 +943,7 @@ espi_write32(ESPI_GLOBAL_CONTROL_1, global_ctrl_reg); }
-int espi_setup(void) +enum cb_err espi_setup(void) { uint32_t slave_caps; const struct espi_config *cfg = espi_get_config(); @@ -970,7 +970,7 @@ */ if (espi_send_reset() != CB_SUCCESS) { printk(BIOS_ERR, "Error: In-band reset failed!\n"); - return -1; + return CB_ERR; } espi_set_initial_config(cfg);
@@ -980,7 +980,7 @@ */ if (espi_get_general_configuration(&slave_caps) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Slave GET_CONFIGURATION failed!\n"); - return -1; + return CB_ERR; }
/* @@ -990,7 +990,7 @@ */ if (espi_set_general_configuration(cfg, slave_caps) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Slave SET_CONFIGURATION failed!\n"); - return -1; + return CB_ERR; }
/* @@ -1006,39 +1006,39 @@ /* Set up VW first so we can deassert PLTRST#. */ if (espi_setup_vw_channel(cfg, slave_caps) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Setup VW channel failed!\n"); - return -1; + return CB_ERR; }
/* Assert PLTRST# if VW channel is enabled by mainboard. */ if (espi_send_pltrst(cfg, true) != CB_SUCCESS) { printk(BIOS_ERR, "Error: PLTRST# assertion failed!\n"); - return -1; + return CB_ERR; }
/* De-assert PLTRST# if VW channel is enabled by mainboard. */ if (espi_send_pltrst(cfg, false) != CB_SUCCESS) { printk(BIOS_ERR, "Error: PLTRST# deassertion failed!\n"); - return -1; + return CB_ERR; }
if (espi_setup_periph_channel(cfg, slave_caps) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Setup Periph channel failed!\n"); - return -1; + return CB_ERR; }
if (espi_setup_oob_channel(cfg, slave_caps) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Setup OOB channel failed!\n"); - return -1; + return CB_ERR; }
if (espi_setup_flash_channel(cfg, slave_caps) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Setup Flash channel failed!\n"); - return -1; + return CB_ERR; }
- if (espi_configure_decodes(cfg) == -1) { + if (espi_configure_decodes(cfg) != CB_SUCCESS) { printk(BIOS_ERR, "Error: Configuring decodes failed!\n"); - return -1; + return CB_ERR; }
/* Enable subtractive decode if configured */ @@ -1049,7 +1049,7 @@
printk(BIOS_SPEW, "Finished initializing ESPI.\n");
- return 0; + return CB_SUCCESS; }
/* Setup eSPI with any mainboard specific initialization. */