summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCliff Huang <cliff.huang@intel.com>2022-02-23 15:43:32 -0800
committerFelix Held <felix-coreboot@felixheld.de>2022-03-10 23:57:16 +0000
commit5069f6c3c86a03084c7e5c84f99b7f5d36523f29 (patch)
tree43b63d19d9d7395a6f25910703cd9dbf9110a461 /src
parentce87832c6662f1060855fd82a00c4a8e47758fe6 (diff)
drivers/pcie/generic: Add support to generate code under companion device instead
Only one ACPI device should be added to a PCIe root port. For the root ports which already have device created, the generated code from this driver needs to be merged with the existing device. By default, this driver will create new device named DEV0. This change allows to generate code under an existing device. ex: (generate code under PXSX): Scope (\_SB.PCI0.RP01.PXSX) { Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") Package (0x01) { Package (0x02) { "UntrustedDevice", One } } }) } BUG=b:221250331 BRANCH=firmware-brya-14505.B Signed-off-by: Cliff Huang <cliff.huang@intel.com> Change-Id: I80634bbfc2927f26f2a55a9c244eca517c437079 Reviewed-on: https://review.coreboot.org/c/coreboot/+/62301 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/pcie/generic/chip.h8
-rw-r--r--src/drivers/pcie/generic/generic.c27
2 files changed, 27 insertions, 8 deletions
diff --git a/src/drivers/pcie/generic/chip.h b/src/drivers/pcie/generic/chip.h
index 3be57de530..5d762ec250 100644
--- a/src/drivers/pcie/generic/chip.h
+++ b/src/drivers/pcie/generic/chip.h
@@ -7,6 +7,14 @@
struct drivers_pcie_generic_config {
bool is_untrusted;
+ /*
+ * This needs to be pointed to the device instance in the device tree when
+ * there is already a device with the root port so that the ACPI code to be
+ * generated will be added to that existing device.
+ * By default, an ACPI device named 'DEV0' is created under the root port if
+ * this does not reference to a device.
+ */
+ DEVTREE_CONST struct device *companion_dev;
};
#endif /* _PCIE_GENERIC_H_ */
diff --git a/src/drivers/pcie/generic/generic.c b/src/drivers/pcie/generic/generic.c
index c14628f65b..0a9a243518 100644
--- a/src/drivers/pcie/generic/generic.c
+++ b/src/drivers/pcie/generic/generic.c
@@ -9,6 +9,10 @@
static const char *pcie_generic_acpi_name(const struct device *dev)
{
+ struct drivers_pcie_generic_config *config = dev->chip_info;
+
+ if (config->companion_dev)
+ return acpi_device_name(config->companion_dev);
return "DEV0";
}
@@ -26,22 +30,29 @@ static void pcie_generic_fill_ssdt(const struct device *dev)
if (!config || !config->is_untrusted || !dev->bus || !dev->bus->dev)
return;
- const char *scope = acpi_device_path(dev->bus->dev);
- const char *name = acpi_device_name(dev);
+ const char *scope;
+ const char *name;
+ /* Code will be generated under companion device instead if present. */
+ if (config->companion_dev)
+ scope = acpi_device_path(config->companion_dev);
+ else
+ scope = acpi_device_path(dev->bus->dev);
+ name = acpi_device_name(dev);
acpigen_write_scope(scope);
- acpigen_write_device(name);
- acpigen_write_ADR_pci_device(dev);
-
+ if (!config->companion_dev) {
+ acpigen_write_device(name);
+ acpigen_write_ADR_pci_device(dev);
+ }
dsd = acpi_dp_new_table("_DSD");
acpi_dp_add_integer(dsd, "DmaProperty", 1);
acpi_dp_write(dsd);
-
- acpigen_write_device_end();
+ if (!config->companion_dev)
+ acpigen_write_device_end();
acpigen_write_scope_end();
printk(BIOS_INFO, "%s.%s: Enable ACPI properties for %s (%s)\n", scope, name,
- dev_path(dev), dev->chip_ops->name);
+ dev_path(dev), dev->chip_ops->name);
}
struct device_operations pcie_generic_ops = {