summaryrefslogtreecommitdiff
path: root/src/soc/amd/common
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2021-12-18 00:41:23 +0100
committerFelix Held <felix-coreboot@felixheld.de>2021-12-20 17:40:52 +0000
commitaed38a94e3488a2ed4465b208eb5f9df8af10d5f (patch)
tree08b07255246cb3386772c98341e4a3a85c22765b /src/soc/amd/common
parent4b4114f7098c83ad3733abeed066c2cea396a150 (diff)
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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/60208 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Raul Rangel <rrangel@chromium.org> Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Diffstat (limited to 'src/soc/amd/common')
-rw-r--r--src/soc/amd/common/block/include/amdblocks/espi.h12
-rw-r--r--src/soc/amd/common/block/lpc/espi_util.c50
2 files changed, 29 insertions, 33 deletions
diff --git a/src/soc/amd/common/block/include/amdblocks/espi.h b/src/soc/amd/common/block/include/amdblocks/espi.h
index f9e25707d0..adb9a1d9c1 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 @@ struct espi_config {
/*
* 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 @@ void espi_update_static_bar(uintptr_t bar);
/*
* 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 70bd351966..1d7be67c66 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 @@ static void espi_write_io_window(int idx, uint16_t base, size_t size)
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 @@ static int espi_open_generic_io_window(uint16_t base, size_t size)
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 @@ static void espi_write_mmio_window(int idx, uint32_t base, size_t size)
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 @@ int espi_open_mmio_window(uint32_t base, size_t size)
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 @@ static const struct espi_config *espi_get_config(void)
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 @@ static int espi_configure_decodes(const struct espi_config *cfg)
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
@@ -947,7 +947,7 @@ static void espi_setup_subtractive_decode(const struct espi_config *mb_cfg)
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();
@@ -974,7 +974,7 @@ int espi_setup(void)
*/
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);
@@ -984,7 +984,7 @@ int espi_setup(void)
*/
if (espi_get_general_configuration(&slave_caps) != CB_SUCCESS) {
printk(BIOS_ERR, "Error: Slave GET_CONFIGURATION failed!\n");
- return -1;
+ return CB_ERR;
}
/*
@@ -994,7 +994,7 @@ int espi_setup(void)
*/
if (espi_set_general_configuration(cfg, slave_caps) != CB_SUCCESS) {
printk(BIOS_ERR, "Error: Slave SET_CONFIGURATION failed!\n");
- return -1;
+ return CB_ERR;
}
/*
@@ -1010,39 +1010,39 @@ int espi_setup(void)
/* 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 */
@@ -1053,7 +1053,7 @@ int espi_setup(void)
printk(BIOS_SPEW, "Finished initializing ESPI.\n");
- return 0;
+ return CB_SUCCESS;
}
/* Setup eSPI with any mainboard specific initialization. */