Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83443?usp=email )
Change subject: soc/amd/*/root_complex: introduce and use domain_iohc_info struct ......................................................................
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 felix-coreboot@felixheld.de Change-Id: Ifce3d2b540d14ba3cba36f7cbf248fb7c63483fe --- M src/soc/amd/cezanne/root_complex.c M src/soc/amd/common/block/include/amdblocks/root_complex.h M src/soc/amd/common/block/root_complex/Makefile.mk A src/soc/amd/common/block/root_complex/root_complex.c M src/soc/amd/genoa_poc/root_complex.c M src/soc/amd/glinda/root_complex.c M src/soc/amd/mendocino/root_complex.c M src/soc/amd/phoenix/root_complex.c M src/soc/amd/picasso/root_complex.c 9 files changed, 121 insertions(+), 93 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/43/83443/1
diff --git a/src/soc/amd/cezanne/root_complex.c b/src/soc/amd/cezanne/root_complex.c index 72a2419..04fb90c 100644 --- a/src/soc/amd/cezanne/root_complex.c +++ b/src/soc/amd/cezanne/root_complex.c @@ -75,9 +75,17 @@ .acpi_fill_ssdt = root_complex_fill_ssdt, };
-uint32_t get_iohc_misc_smn_base(struct device *domain) +static const struct domain_iohc_info iohc_info[] = { + [0] = { + .fabric_id = IOMS0_FABRIC_ID, + .misc_smn_base = SMN_IOHC_MISC_BASE_13B1, + }, +}; + +const struct domain_iohc_info *get_iohc_info(size_t *count) { - return SMN_IOHC_MISC_BASE_13B1; + *count = ARRAY_SIZE(iohc_info); + return iohc_info; }
static const struct non_pci_mmio_reg non_pci_mmio[] = { @@ -99,13 +107,3 @@ *count = ARRAY_SIZE(non_pci_mmio); return non_pci_mmio; } - -signed int get_iohc_fabric_id(struct device *domain) -{ - switch (domain->path.domain.domain) { - case 0: - return IOMS0_FABRIC_ID; - default: - return -1; - } -} 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 767221e..8761626 100644 --- a/src/soc/amd/common/block/include/amdblocks/root_complex.h +++ b/src/soc/amd/common/block/include/amdblocks/root_complex.h @@ -13,6 +13,11 @@
#define NON_PCI_RES_IDX_AUTO 0
+struct domain_iohc_info { + uint32_t fabric_id; + uint32_t misc_smn_base; +}; + struct non_pci_mmio_reg { uint32_t iohc_misc_offset; uint64_t mask; @@ -25,6 +30,7 @@ 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 07f3ab1..a6aa0da 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 @@
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 0000000..d11c23e --- /dev/null +++ b/src/soc/amd/common/block/root_complex/root_complex.c @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <amdblocks/root_complex.h> +#include <console/console.h> +#include <device/device.h> +#include <types.h> + +static const struct domain_iohc_info *get_domain_iohc_info(struct device *domain) +{ + const struct domain_iohc_info *iohc; + size_t iohc_count; + + iohc = get_iohc_info(&iohc_count); + + if (domain->path.domain.domain < iohc_count) { + return &iohc[domain->path.domain.domain]; + } else { + printk(BIOS_ERR, "Invalid domain 0x%x with no corresponding IOHC device.\n", + domain->path.domain.domain); + 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; +} diff --git a/src/soc/amd/genoa_poc/root_complex.c b/src/soc/amd/genoa_poc/root_complex.c index 849bf77..3171feb 100644 --- a/src/soc/amd/genoa_poc/root_complex.c +++ b/src/soc/amd/genoa_poc/root_complex.c @@ -2,26 +2,31 @@
#include <amdblocks/ioapic.h> #include <amdblocks/root_complex.h> -#include <console/console.h> -#include <device/device.h> #include <types.h>
-uint32_t get_iohc_misc_smn_base(struct device *domain) +static const struct domain_iohc_info iohc_info[] = { + [0] = { + .fabric_id = 0x22, + .misc_smn_base = SMN_IOHC_MISC_BASE_13C1, + }, + [1] = { + .fabric_id = 0x23, + .misc_smn_base = SMN_IOHC_MISC_BASE_13B1, + }, + [2] = { + .fabric_id = 0x21, + .misc_smn_base = SMN_IOHC_MISC_BASE_13E1, + }, + [3] = { + .fabric_id = 0x20, + .misc_smn_base = SMN_IOHC_MISC_BASE_13D1, + }, +}; + +const struct domain_iohc_info *get_iohc_info(size_t *count) { - switch (domain->path.domain.domain) { - case 0: - return SMN_IOHC_MISC_BASE_13C1; - case 1: - return SMN_IOHC_MISC_BASE_13B1; - case 2: - return SMN_IOHC_MISC_BASE_13E1; - case 3: - return SMN_IOHC_MISC_BASE_13D1; - default: - printk(BIOS_ERR, "Invalid domain 0x%x with no corresponding IOHC device.\n", - domain->path.domain.domain); - return 0; - } + *count = ARRAY_SIZE(iohc_info); + return iohc_info; }
static const struct non_pci_mmio_reg non_pci_mmio[] = { @@ -44,19 +49,3 @@ *count = ARRAY_SIZE(non_pci_mmio); return non_pci_mmio; } - -signed int get_iohc_fabric_id(struct device *domain) -{ - switch (domain->path.domain.domain) { - case 0: - return 0x22; - case 1: - return 0x23; - case 2: - return 0x21; - case 3: - return 0x20; - default: - return -1; - } -} diff --git a/src/soc/amd/glinda/root_complex.c b/src/soc/amd/glinda/root_complex.c index d51fef2..776fc32 100644 --- a/src/soc/amd/glinda/root_complex.c +++ b/src/soc/amd/glinda/root_complex.c @@ -105,9 +105,17 @@ .acpi_fill_ssdt = root_complex_fill_ssdt, };
-uint32_t get_iohc_misc_smn_base(struct device *domain) +static const struct domain_iohc_info iohc_info[] = { + [0] = { + .fabric_id = IOMS0_FABRIC_ID, + .misc_smn_base = SMN_IOHC_MISC_BASE_13B1, + }, +}; + +const struct domain_iohc_info *get_iohc_info(size_t *count) { - return SMN_IOHC_MISC_BASE_13B1; + *count = ARRAY_SIZE(iohc_info); + return iohc_info; }
static const struct non_pci_mmio_reg non_pci_mmio[] = { @@ -132,13 +140,3 @@ *count = ARRAY_SIZE(non_pci_mmio); return non_pci_mmio; } - -signed int get_iohc_fabric_id(struct device *domain) -{ - switch (domain->path.domain.domain) { - case 0: - return IOMS0_FABRIC_ID; - default: - return -1; - } -} diff --git a/src/soc/amd/mendocino/root_complex.c b/src/soc/amd/mendocino/root_complex.c index 2179833..a7cbe51 100644 --- a/src/soc/amd/mendocino/root_complex.c +++ b/src/soc/amd/mendocino/root_complex.c @@ -266,9 +266,17 @@ .acpi_fill_ssdt = root_complex_fill_ssdt, };
-uint32_t get_iohc_misc_smn_base(struct device *domain) +static const struct domain_iohc_info iohc_info[] = { + [0] = { + .fabric_id = IOMS0_FABRIC_ID, + .misc_smn_base = SMN_IOHC_MISC_BASE_13B1, + }, +}; + +const struct domain_iohc_info *get_iohc_info(size_t *count) { - return SMN_IOHC_MISC_BASE_13B1; + *count = ARRAY_SIZE(iohc_info); + return iohc_info; }
static const struct non_pci_mmio_reg non_pci_mmio[] = { @@ -290,13 +298,3 @@ *count = ARRAY_SIZE(non_pci_mmio); return non_pci_mmio; } - -signed int get_iohc_fabric_id(struct device *domain) -{ - switch (domain->path.domain.domain) { - case 0: - return IOMS0_FABRIC_ID; - default: - return -1; - } -} diff --git a/src/soc/amd/phoenix/root_complex.c b/src/soc/amd/phoenix/root_complex.c index 918b7bd..7fed3bd 100644 --- a/src/soc/amd/phoenix/root_complex.c +++ b/src/soc/amd/phoenix/root_complex.c @@ -105,9 +105,17 @@ .acpi_fill_ssdt = root_complex_fill_ssdt, };
-uint32_t get_iohc_misc_smn_base(struct device *domain) +static const struct domain_iohc_info iohc_info[] = { + [0] = { + .fabric_id = IOMS0_FABRIC_ID, + .misc_smn_base = SMN_IOHC_MISC_BASE_13B1, + }, +}; + +const struct domain_iohc_info *get_iohc_info(size_t *count) { - return SMN_IOHC_MISC_BASE_13B1; + *count = ARRAY_SIZE(iohc_info); + return iohc_info; }
static const struct non_pci_mmio_reg non_pci_mmio[] = { @@ -132,13 +140,3 @@ *count = ARRAY_SIZE(non_pci_mmio); return non_pci_mmio; } - -signed int get_iohc_fabric_id(struct device *domain) -{ - switch (domain->path.domain.domain) { - case 0: - return IOMS0_FABRIC_ID; - default: - return -1; - } -} diff --git a/src/soc/amd/picasso/root_complex.c b/src/soc/amd/picasso/root_complex.c index dd39cb2..a3bd729 100644 --- a/src/soc/amd/picasso/root_complex.c +++ b/src/soc/amd/picasso/root_complex.c @@ -84,9 +84,17 @@ .acpi_fill_ssdt = root_complex_fill_ssdt, };
-uint32_t get_iohc_misc_smn_base(struct device *domain) +static const struct domain_iohc_info iohc_info[] = { + [0] = { + .fabric_id = IOMS0_FABRIC_ID, + .misc_smn_base = SMN_IOHC_MISC_BASE_13B1, + }, +}; + +const struct domain_iohc_info *get_iohc_info(size_t *count) { - return SMN_IOHC_MISC_BASE_13B1; + *count = ARRAY_SIZE(iohc_info); + return iohc_info; }
static const struct non_pci_mmio_reg non_pci_mmio[] = { @@ -107,13 +115,3 @@ *count = ARRAY_SIZE(non_pci_mmio); return non_pci_mmio; } - -signed int get_iohc_fabric_id(struct device *domain) -{ - switch (domain->path.domain.domain) { - case 0: - return IOMS0_FABRIC_ID; - default: - return -1; - } -}