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>
This commit is contained in:
parent
4b4114f709
commit
aed38a94e3
|
@ -3,8 +3,7 @@
|
||||||
#ifndef AMD_BLOCK_ESPI_H
|
#ifndef AMD_BLOCK_ESPI_H
|
||||||
#define AMD_BLOCK_ESPI_H
|
#define AMD_BLOCK_ESPI_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <types.h>
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/* eSPI MMIO base lives at an offset of 0x10000 from the address in SPI BAR. */
|
/* eSPI MMIO base lives at an offset of 0x10000 from the address in SPI BAR. */
|
||||||
#define ESPI_OFFSET_FROM_BAR 0x10000
|
#define ESPI_OFFSET_FROM_BAR 0x10000
|
||||||
|
@ -106,15 +105,13 @@ struct espi_config {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open I/O window using the provided base and size.
|
* 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.
|
* 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
|
* 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.
|
* 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 */
|
/* Run mainboard configuration needed to set up eSPI */
|
||||||
void mb_set_up_early_espi(void);
|
void mb_set_up_early_espi(void);
|
||||||
|
|
|
@ -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);
|
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;
|
size_t win_size;
|
||||||
int idx;
|
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,
|
printk(BIOS_ERR, "Cannot open IO window base %x size %zx\n", base,
|
||||||
size);
|
size);
|
||||||
printk(BIOS_ERR, "ERROR: No more available IO windows!\n");
|
printk(BIOS_ERR, "ERROR: No more available IO windows!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
espi_write_io_window(idx, base, win_size);
|
espi_write_io_window(idx, base, win_size);
|
||||||
espi_enable_decode(ESPI_DECODE_IO_RANGE_EN(idx));
|
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;
|
int std_io;
|
||||||
|
|
||||||
std_io = espi_std_io_decode(base, size);
|
std_io = espi_std_io_decode(base, size);
|
||||||
if (std_io != -1) {
|
if (std_io != -1) {
|
||||||
espi_enable_decode(std_io);
|
espi_enable_decode(std_io);
|
||||||
return 0;
|
return CB_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return espi_open_generic_io_window(base, size);
|
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);
|
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;
|
size_t win_size;
|
||||||
int idx;
|
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,
|
printk(BIOS_ERR, "Cannot open IO window base %x size %zx\n", base,
|
||||||
size);
|
size);
|
||||||
printk(BIOS_ERR, "ERROR: No more available MMIO windows!\n");
|
printk(BIOS_ERR, "ERROR: No more available MMIO windows!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
espi_write_mmio_window(idx, base, win_size);
|
espi_write_mmio_window(idx, base, win_size);
|
||||||
espi_enable_decode(ESPI_DECODE_MMIO_RANGE_EN(idx));
|
espi_enable_decode(ESPI_DECODE_MMIO_RANGE_EN(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return CB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct espi_config *espi_get_config(void)
|
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;
|
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;
|
int i;
|
||||||
|
|
||||||
|
@ -308,11 +308,11 @@ static int espi_configure_decodes(const struct espi_config *cfg)
|
||||||
if (cfg->generic_io_range[i].size == 0)
|
if (cfg->generic_io_range[i].size == 0)
|
||||||
continue;
|
continue;
|
||||||
if (espi_open_generic_io_window(cfg->generic_io_range[i].base,
|
if (espi_open_generic_io_window(cfg->generic_io_range[i].base,
|
||||||
cfg->generic_io_range[i].size))
|
cfg->generic_io_range[i].size) != CB_SUCCESS)
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return CB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ESPI_DN_TX_HDR0 0x00
|
#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);
|
espi_write32(ESPI_GLOBAL_CONTROL_1, global_ctrl_reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int espi_setup(void)
|
enum cb_err espi_setup(void)
|
||||||
{
|
{
|
||||||
uint32_t slave_caps;
|
uint32_t slave_caps;
|
||||||
const struct espi_config *cfg = espi_get_config();
|
const struct espi_config *cfg = espi_get_config();
|
||||||
|
@ -974,7 +974,7 @@ int espi_setup(void)
|
||||||
*/
|
*/
|
||||||
if (espi_send_reset() != CB_SUCCESS) {
|
if (espi_send_reset() != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: In-band reset failed!\n");
|
printk(BIOS_ERR, "Error: In-band reset failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
espi_set_initial_config(cfg);
|
espi_set_initial_config(cfg);
|
||||||
|
|
||||||
|
@ -984,7 +984,7 @@ int espi_setup(void)
|
||||||
*/
|
*/
|
||||||
if (espi_get_general_configuration(&slave_caps) != CB_SUCCESS) {
|
if (espi_get_general_configuration(&slave_caps) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: Slave GET_CONFIGURATION failed!\n");
|
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) {
|
if (espi_set_general_configuration(cfg, slave_caps) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: Slave SET_CONFIGURATION failed!\n");
|
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#. */
|
/* Set up VW first so we can deassert PLTRST#. */
|
||||||
if (espi_setup_vw_channel(cfg, slave_caps) != CB_SUCCESS) {
|
if (espi_setup_vw_channel(cfg, slave_caps) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: Setup VW channel failed!\n");
|
printk(BIOS_ERR, "Error: Setup VW channel failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Assert PLTRST# if VW channel is enabled by mainboard. */
|
/* Assert PLTRST# if VW channel is enabled by mainboard. */
|
||||||
if (espi_send_pltrst(cfg, true) != CB_SUCCESS) {
|
if (espi_send_pltrst(cfg, true) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: PLTRST# assertion failed!\n");
|
printk(BIOS_ERR, "Error: PLTRST# assertion failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* De-assert PLTRST# if VW channel is enabled by mainboard. */
|
/* De-assert PLTRST# if VW channel is enabled by mainboard. */
|
||||||
if (espi_send_pltrst(cfg, false) != CB_SUCCESS) {
|
if (espi_send_pltrst(cfg, false) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: PLTRST# deassertion failed!\n");
|
printk(BIOS_ERR, "Error: PLTRST# deassertion failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (espi_setup_periph_channel(cfg, slave_caps) != CB_SUCCESS) {
|
if (espi_setup_periph_channel(cfg, slave_caps) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: Setup Periph channel failed!\n");
|
printk(BIOS_ERR, "Error: Setup Periph channel failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (espi_setup_oob_channel(cfg, slave_caps) != CB_SUCCESS) {
|
if (espi_setup_oob_channel(cfg, slave_caps) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: Setup OOB channel failed!\n");
|
printk(BIOS_ERR, "Error: Setup OOB channel failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (espi_setup_flash_channel(cfg, slave_caps) != CB_SUCCESS) {
|
if (espi_setup_flash_channel(cfg, slave_caps) != CB_SUCCESS) {
|
||||||
printk(BIOS_ERR, "Error: Setup Flash channel failed!\n");
|
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");
|
printk(BIOS_ERR, "Error: Configuring decodes failed!\n");
|
||||||
return -1;
|
return CB_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable subtractive decode if configured */
|
/* Enable subtractive decode if configured */
|
||||||
|
@ -1053,7 +1053,7 @@ int espi_setup(void)
|
||||||
|
|
||||||
printk(BIOS_SPEW, "Finished initializing ESPI.\n");
|
printk(BIOS_SPEW, "Finished initializing ESPI.\n");
|
||||||
|
|
||||||
return 0;
|
return CB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup eSPI with any mainboard specific initialization. */
|
/* Setup eSPI with any mainboard specific initialization. */
|
||||||
|
|
Loading…
Reference in New Issue