From e9e71132a308acbe5c6d5371fbe5f7d6ffe30cf4 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 12 Jul 2024 14:06:49 +0200 Subject: soc/amd/*/root_complex: introduce and use domain_iohc_info struct Instead of implementing the functions get_iohc_misc_smn_base and get_iohc_fabric_id in the SoC code, move those functions to the common AMD code, and implement get_iohc_info in the SoC code that returns a pointer to and the size of a SoC-specific array of domain_iohc_info structs that contains the info needed by the common code instead. This allows to iterate over the domain_iohc_info structs which will be used in a later patch to find the PSP MMIO base address in both ramstage and smm. TEST=Mandolin still boots and all non-PCI MIO resources are still reported to the resource allocator Signed-off-by: Felix Held Change-Id: Ifce3d2b540d14ba3cba36f7cbf248fb7c63483fe Reviewed-on: https://review.coreboot.org/c/coreboot/+/83443 Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier Reviewed-by: Varshit Pandya Reviewed-by: Martin Roth --- .../common/block/include/amdblocks/root_complex.h | 6 +++ src/soc/amd/common/block/root_complex/Makefile.mk | 1 + .../amd/common/block/root_complex/root_complex.c | 43 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/soc/amd/common/block/root_complex/root_complex.c (limited to 'src/soc/amd/common') diff --git a/src/soc/amd/common/block/include/amdblocks/root_complex.h b/src/soc/amd/common/block/include/amdblocks/root_complex.h index 9ef5d05925..bfabf973a7 100644 --- a/src/soc/amd/common/block/include/amdblocks/root_complex.h +++ b/src/soc/amd/common/block/include/amdblocks/root_complex.h @@ -15,6 +15,11 @@ #define NON_PCI_RES_IDX_AUTO 0 +struct domain_iohc_info { + uint16_t fabric_id; + uint32_t misc_smn_base; +}; + struct non_pci_mmio_reg { uint32_t iohc_misc_offset; uint64_t mask; @@ -27,6 +32,7 @@ void read_non_pci_resources(struct device *domain, unsigned long *idx); void read_soc_memmap_resources(struct device *domain, unsigned long *idx); uint32_t get_iohc_misc_smn_base(struct device *domain); +const struct domain_iohc_info *get_iohc_info(size_t *count); const struct non_pci_mmio_reg *get_iohc_non_pci_mmio_regs(size_t *count); signed int get_iohc_fabric_id(struct device *domain); diff --git a/src/soc/amd/common/block/root_complex/Makefile.mk b/src/soc/amd/common/block/root_complex/Makefile.mk index 07f3ab108e..a6aa0da502 100644 --- a/src/soc/amd/common/block/root_complex/Makefile.mk +++ b/src/soc/amd/common/block/root_complex/Makefile.mk @@ -3,5 +3,6 @@ ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_ROOT_COMPLEX),y) ramstage-y += ioapic.c ramstage-y += non_pci_resources.c +ramstage-y += root_complex.c endif # CONFIG_SOC_AMD_COMMON_BLOCK_ROOT_COMPLEX diff --git a/src/soc/amd/common/block/root_complex/root_complex.c b/src/soc/amd/common/block/root_complex/root_complex.c new file mode 100644 index 0000000000..2bcdc1d432 --- /dev/null +++ b/src/soc/amd/common/block/root_complex/root_complex.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +static const struct domain_iohc_info *get_domain_iohc_info(struct device *domain) +{ + const unsigned int domain_id = domain->path.domain.domain; + const struct domain_iohc_info *iohc; + size_t iohc_count; + + iohc = get_iohc_info(&iohc_count); + + if (domain_id < iohc_count) { + return &iohc[domain_id]; + } else { + printk(BIOS_ERR, "Invalid domain 0x%x with no corresponding IOHC device.\n", + domain_id); + return NULL; + } +} + +uint32_t get_iohc_misc_smn_base(struct device *domain) +{ + const struct domain_iohc_info *iohc_info = get_domain_iohc_info(domain); + + if (iohc_info) + return iohc_info->misc_smn_base; + else + return 0; +} + +signed int get_iohc_fabric_id(struct device *domain) +{ + const struct domain_iohc_info *iohc_info = get_domain_iohc_info(domain); + + if (iohc_info) + return iohc_info->fabric_id; + else + return -1; +} -- cgit v1.2.3