Furquan Shaikh has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40674 )
Change subject: arch/x86/acpi_device: Add a helper function to write PCI device ......................................................................
arch/x86/acpi_device: Add a helper function to write PCI device
This change adds a helper function to write a PCI device with _ADR object defined for it.
BUG=b:153858769
Signed-off-by: Furquan Shaikh furquan@google.com Change-Id: I932af917d91198876fe8e90af9bb7a2531bd8960 --- M src/arch/x86/acpi_device.c M src/arch/x86/include/arch/acpi_device.h 2 files changed, 25 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/40674/1
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c index 9f1710e..9e7a58b 100644 --- a/src/arch/x86/acpi_device.c +++ b/src/arch/x86/acpi_device.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* This file is part of the coreboot project. */
+#include <assert.h> #include <string.h> #include <arch/acpi.h> #include <arch/acpi_device.h> @@ -927,3 +928,24 @@
return gpio; } + +void acpi_device_write_pci_dev(struct device *dev) +{ + const char *scope = acpi_device_scope(dev); + const char *name = acpi_device_name(dev); + + assert(dev->path.type == DEVICE_PATH_PCI); + assert(name); + assert(scope); + + if (!dev->enabled) + return; + + acpigen_write_scope(scope); + acpigen_write_device(name); + + acpigen_write_ADR_pci_device(dev); + + acpigen_pop_len(); /* Device */ + acpigen_pop_len(); /* Scope */ +} diff --git a/src/arch/x86/include/arch/acpi_device.h b/src/arch/x86/include/arch/acpi_device.h index e9c5cd4..7b9e169 100644 --- a/src/arch/x86/include/arch/acpi_device.h +++ b/src/arch/x86/include/arch/acpi_device.h @@ -501,4 +501,7 @@ /* Write Device Property hierarchy and clean up resources */ void acpi_dp_write(struct acpi_dp *table);
+/* Helper function to write a PCI device with _ADR object defined. */ +void acpi_device_write_pci_dev(struct device *dev); + #endif