summaryrefslogtreecommitdiff
path: root/src/arch/x86
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2020-04-23 12:51:42 -0700
committerFurquan Shaikh <furquan@google.com>2020-04-28 19:09:25 +0000
commitd1130af40e5570f9b74e0cf44c05fe1c6a4e46b2 (patch)
tree22be23ad370ac167d3e8a923862b118d7dea9527 /src/arch/x86
parentef0cb90ae3a5849f17366338ec5f9f77c1fd3850 (diff)
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 and _STA defined for it. BUG=b:153858769 Signed-off-by: Furquan Shaikh <furquan@google.com> Change-Id: I932af917d91198876fe8e90af9bb7a2531bd8960 Reviewed-on: https://review.coreboot.org/c/coreboot/+/40674 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/arch/x86')
-rw-r--r--src/arch/x86/acpi_device.c32
-rw-r--r--src/arch/x86/include/arch/acpi_device.h9
2 files changed, 41 insertions, 0 deletions
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c
index 9f1710e35f..2c461558a2 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,34 @@ struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name,
return gpio;
}
+
+/*
+ * This function writes a PCI device with _ADR object:
+ * Example:
+ * Scope (\_SB.PCI0)
+ * {
+ * Device (IGFX)
+ * {
+ * Name (_ADR, 0x0000000000000000)
+ * Method (_STA, 0, NotSerialized) { Return (status) }
+ * }
+ * }
+ */
+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);
+
+ acpigen_write_scope(scope);
+ acpigen_write_device(name);
+
+ acpigen_write_ADR_pci_device(dev);
+ acpigen_write_STA(acpi_device_status(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 e9c5cd4de2..362efc4a62 100644
--- a/src/arch/x86/include/arch/acpi_device.h
+++ b/src/arch/x86/include/arch/acpi_device.h
@@ -501,4 +501,13 @@ size_t acpi_dp_add_property_list(struct acpi_dp *dp,
/* 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.
+ *
+ * IMPORTANT: Scope of a device created in SSDT cannot be used to add ACPI nodes under that
+ * scope in DSDT. So, if there are any references to this PCI device scope required from static
+ * asl files, do not use this function and instead add the device to DSDT as well.
+ */
+void acpi_device_write_pci_dev(struct device *dev);
+
#endif