soc/amd/picasso/data_fabric: move more helper functions to common code
The number of data fabric MMIO registers is SoC-specific, so we need to
keep that in the SoC code. This also removes a redundant pair of
brackets and moves a loop counter declaration into the head of the loop.
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I8499f1c1f7bf6849b5955a463de2e06962d5de68
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50638
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/soc/amd/picasso/data_fabric.c b/src/soc/amd/picasso/data_fabric.c
index 3b6c4f9..d07555a 100644
--- a/src/soc/amd/picasso/data_fabric.c
+++ b/src/soc/amd/picasso/data_fabric.c
@@ -11,31 +11,6 @@
#include <soc/iomap.h>
#include <types.h>
-static void disable_mmio_reg(unsigned int reg)
-{
- data_fabric_broadcast_write32(0, NB_MMIO_CONTROL(reg),
- IOMS0_FABRIC_ID << MMIO_DST_FABRIC_ID_SHIFT);
- data_fabric_broadcast_write32(0, NB_MMIO_BASE(reg), 0);
- data_fabric_broadcast_write32(0, NB_MMIO_LIMIT(reg), 0);
-}
-
-static bool is_mmio_reg_disabled(unsigned int reg)
-{
- uint32_t val = data_fabric_broadcast_read32(0, NB_MMIO_CONTROL(reg));
- return !(val & ((MMIO_WE | MMIO_RE)));
-}
-
-static int find_unused_mmio_reg(void)
-{
- unsigned int i;
-
- for (i = 0; i < NUM_NB_MMIO_REGS; i++) {
- if (is_mmio_reg_disabled(i))
- return i;
- }
- return -1;
-}
-
void data_fabric_set_mmio_np(void)
{
/*
@@ -77,14 +52,14 @@
continue; /* no overlap at all */
if (base >= np_bot && limit <= np_top) {
- disable_mmio_reg(i); /* 100% within, so remove */
+ data_fabric_disable_mmio_reg(i); /* 100% within, so remove */
continue;
}
if (base < np_bot && limit > np_top) {
/* Split the configured region */
data_fabric_broadcast_write32(0, NB_MMIO_LIMIT(i), np_bot - 1);
- reg = find_unused_mmio_reg();
+ reg = data_fabric_find_unused_mmio_reg();
if (reg < 0) {
/* Although a pair could be freed later, this condition is
* very unusual and deserves analysis. Flag an error and
@@ -106,7 +81,7 @@
data_fabric_broadcast_write32(0, NB_MMIO_BASE(i), np_top + 1);
}
- reg = find_unused_mmio_reg();
+ reg = data_fabric_find_unused_mmio_reg();
if (reg < 0) {
printk(BIOS_ERR, "Error: cannot configure region as NP\n");
return;