From 63c5a0d5160ad9cb75da99f9521591f5d376e314 Mon Sep 17 00:00:00 2001 From: Fred Reitberger Date: Thu, 3 Nov 2022 14:48:28 -0400 Subject: [PATCH] soc/amd/mendocino/data_fabric.c: Make function more generic Make the data_fabric_acpi_name function more generic, in preparation to move it to common. TEST=build chausie, dump ACPI tables, and inspect DFD0 to DFD7 Signed-off-by: Fred Reitberger Change-Id: I77140d8d0d6bf3e048b737de03d18142a6e23c1d Reviewed-on: https://review.coreboot.org/c/coreboot/+/69172 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held --- src/soc/amd/mendocino/data_fabric.c | 37 +++++++++++++---------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/soc/amd/mendocino/data_fabric.c b/src/soc/amd/mendocino/data_fabric.c index 2569da8c67..e0942f2ab8 100644 --- a/src/soc/amd/mendocino/data_fabric.c +++ b/src/soc/amd/mendocino/data_fabric.c @@ -4,31 +4,26 @@ #include #include #include -#include +#include static const char *data_fabric_acpi_name(const struct device *dev) { - switch (dev->device) { - case PCI_DID_AMD_FAM17H_MODELA0H_DF0: - return "DFD0"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF1: - return "DFD1"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF2: - return "DFD2"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF3: - return "DFD3"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF4: - return "DFD4"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF5: - return "DFD5"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF6: - return "DFD6"; - case PCI_DID_AMD_FAM17H_MODELA0H_DF7: - return "DFD7"; - default: - printk(BIOS_ERR, "%s: Unhandled device id 0x%x\n", __func__, dev->device); - } + const char *df_acpi_names[8] = { + "DFD0", + "DFD1", + "DFD2", + "DFD3", + "DFD4", + "DFD5", + "DFD6", + "DFD7" + }; + if (dev->path.type == DEVICE_PATH_PCI && + PCI_SLOT(dev->path.pci.devfn) == DF_DEV) + return df_acpi_names[PCI_FUNC(dev->path.pci.devfn)]; + + printk(BIOS_ERR, "%s: Unhandled device id 0x%x\n", __func__, dev->device); return NULL; }