diff options
author | Felix Held <felix-coreboot@felixheld.de> | 2021-02-13 21:10:08 +0100 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-02-14 20:53:22 +0000 |
commit | 602f93ed520552585a3f15c1b5e7161fb9329d6c (patch) | |
tree | dcb65d806d87d07563a5c6c8c698c7dfa0f0e111 /src/soc/amd/common/block/data_fabric | |
parent | 0a1491366bfd4b1af44052d73325247667b84fd8 (diff) |
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>
Diffstat (limited to 'src/soc/amd/common/block/data_fabric')
-rw-r--r-- | src/soc/amd/common/block/data_fabric/data_fabric_helper.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/soc/amd/common/block/data_fabric/data_fabric_helper.c b/src/soc/amd/common/block/data_fabric/data_fabric_helper.c index e784d508ff..d65bc8dac6 100644 --- a/src/soc/amd/common/block/data_fabric/data_fabric_helper.c +++ b/src/soc/amd/common/block/data_fabric/data_fabric_helper.c @@ -3,6 +3,7 @@ #include <amdblocks/data_fabric.h> #include <amdblocks/pci_devs.h> #include <device/pci_ops.h> +#include <soc/data_fabric.h> #include <soc/pci_devs.h> #include <types.h> #include "data_fabric_def.h" @@ -40,3 +41,26 @@ void data_fabric_write32(uint8_t function, uint16_t reg, uint8_t instance_id, ui data_fabric_set_indirect_address(function, reg, instance_id); pci_write_config32(SOC_DF_F4_DEV, DF_FICAD_LO, data); } + +void data_fabric_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)); +} + +int data_fabric_find_unused_mmio_reg(void) +{ + for (unsigned int i = 0; i < NUM_NB_MMIO_REGS; i++) { + if (is_mmio_reg_disabled(i)) + return i; + } + return -1; +} |