soc/amd: Make espi_configure_decodes private

This is only ever called after espi_setup.

55861 - AMD System Peripheral Bus Overview also says that io ranges
should be configured before enabling the BUS_MASTER bit.

BUG=b:183524609
TEST=Boot guybrush to OS

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I074e487d8768a578ee889a125b9948e3aa6c7269
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52059
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
diff --git a/src/soc/amd/common/block/lpc/espi_util.c b/src/soc/amd/common/block/lpc/espi_util.c
index c7269d0..0b690b8 100644
--- a/src/soc/amd/common/block/lpc/espi_util.c
+++ b/src/soc/amd/common/block/lpc/espi_util.c
@@ -298,19 +298,22 @@
 	return &soc_cfg->espi_config;
 }
 
-void espi_configure_decodes(void)
+static int espi_configure_decodes(const struct espi_config *cfg)
 {
-	int i;
-	const struct espi_config *cfg = espi_get_config();
+	int i, ret;
 
 	espi_enable_decode(cfg->std_io_decode_bitmap);
 
 	for (i = 0; i < ESPI_GENERIC_IO_WIN_COUNT; i++) {
 		if (cfg->generic_io_range[i].size == 0)
 			continue;
-		espi_open_generic_io_window(cfg->generic_io_range[i].base,
-					    cfg->generic_io_range[i].size);
+		ret = espi_open_generic_io_window(cfg->generic_io_range[i].base,
+						  cfg->generic_io_range[i].size);
+		if (ret)
+			return ret;
 	}
+
+	return 0;
 }
 
 #define ESPI_DN_TX_HDR0			0x00
@@ -966,6 +969,11 @@
 		return -1;
 	}
 
+	if (espi_configure_decodes(cfg) == -1) {
+		printk(BIOS_ERR, "Error: Configuring decodes failed!\n");
+		return -1;
+	}
+
 	/* Enable subtractive decode if configured */
 	espi_setup_subtractive_decode(cfg);