From 0c707d4dbc0753b5e40559b8940c6cb2afd80e4d Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 8 Jul 2020 16:54:40 -0700 Subject: [PATCH] soc/amd/picasso: Add PCI driver for data fabric devices Data fabric devices are PCI devices which support PCI configuration space but do not require any MMIO/IO resources. This change adds a PCI driver for the data fabric devices which only provides device operations for adding node to SSDT and returning the ACPI name for the device. Signed-off-by: Furquan Shaikh Change-Id: I3da9287db5febf1a1d7eb1dfbed9f1348f80a588 Reviewed-on: https://review.coreboot.org/c/coreboot/+/43314 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/soc/amd/picasso/Makefile.inc | 2 +- .../{data_fabric_util.c => data_fabric.c} | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) rename src/soc/amd/picasso/{data_fabric_util.c => data_fabric.c} (73%) diff --git a/src/soc/amd/picasso/Makefile.inc b/src/soc/amd/picasso/Makefile.inc index b6c0ddb915..d19402f79d 100644 --- a/src/soc/amd/picasso/Makefile.inc +++ b/src/soc/amd/picasso/Makefile.inc @@ -52,7 +52,7 @@ verstage_x86-y += reset.c ramstage-y += i2c.c ramstage-y += chip.c ramstage-y += cpu.c -ramstage-y += data_fabric_util.c +ramstage-y += data_fabric.c ramstage-y += root_complex.c ramstage-y += mca.c ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c diff --git a/src/soc/amd/picasso/data_fabric_util.c b/src/soc/amd/picasso/data_fabric.c similarity index 73% rename from src/soc/amd/picasso/data_fabric_util.c rename to src/soc/amd/picasso/data_fabric.c index a375b84477..23cb94c837 100644 --- a/src/soc/amd/picasso/data_fabric_util.c +++ b/src/soc/amd/picasso/data_fabric.c @@ -1,7 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include +#include +#include +#include #include #include #include @@ -115,3 +119,51 @@ void data_fabric_set_mmio_np(void) (IOMS0_FABRIC_ID << MMIO_DST_FABRIC_ID_SHIFT) | MMIO_NP | MMIO_WE | MMIO_RE); } + +static const char *data_fabric_acpi_name(const struct device *dev) +{ + switch (dev->device) { + case PCI_DEVICE_ID_AMD_FAM17H_DF0: + return "DFD0"; + case PCI_DEVICE_ID_AMD_FAM17H_DF1: + return "DFD1"; + case PCI_DEVICE_ID_AMD_FAM17H_DF2: + return "DFD2"; + case PCI_DEVICE_ID_AMD_FAM17H_DF3: + return "DFD3"; + case PCI_DEVICE_ID_AMD_FAM17H_DF4: + return "DFD4"; + case PCI_DEVICE_ID_AMD_FAM17H_DF5: + return "DFD5"; + case PCI_DEVICE_ID_AMD_FAM17H_DF6: + return "DFD6"; + default: + printk(BIOS_ERR, "%s: Unhandled device id 0x%x\n", __func__, dev->device); + } + + return NULL; +} + +static struct device_operations data_fabric_ops = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .acpi_name = data_fabric_acpi_name, + .acpi_fill_ssdt = acpi_device_write_pci_dev, +}; + +static const unsigned short pci_device_ids[] = { + PCI_DEVICE_ID_AMD_FAM17H_DF0, + PCI_DEVICE_ID_AMD_FAM17H_DF1, + PCI_DEVICE_ID_AMD_FAM17H_DF2, + PCI_DEVICE_ID_AMD_FAM17H_DF3, + PCI_DEVICE_ID_AMD_FAM17H_DF4, + PCI_DEVICE_ID_AMD_FAM17H_DF5, + PCI_DEVICE_ID_AMD_FAM17H_DF6, + 0 +}; + +static const struct pci_driver data_fabric_driver __pci_driver = { + .ops = &data_fabric_ops, + .vendor = PCI_VENDOR_ID_AMD, + .devices = pci_device_ids, +};