acpi: Move PCI functions to separate file
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: Idc96b99da9f9037267c0bec2c839014b13ceb8cc
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51106
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Lance Zhao
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc
index 86f29e4..b8e4422 100644
--- a/src/acpi/Makefile.inc
+++ b/src/acpi/Makefile.inc
@@ -6,6 +6,7 @@
ramstage-y += acpigen.c
ramstage-y += acpigen_dptf.c
ramstage-y += acpigen_dsm.c
+ramstage-$(CONFIG_PCI) += acpigen_pci.c
ramstage-y += acpigen_ps2_keybd.c
ramstage-y += acpigen_usb.c
ramstage-y += device.c
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c
index 4d9395f..b3e112d 100644
--- a/src/acpi/acpigen.c
+++ b/src/acpi/acpigen.c
@@ -18,8 +18,6 @@
#include <assert.h>
#include <console/console.h>
#include <device/device.h>
-#include <device/pci_def.h>
-#include <device/pci_type.h>
#include <device/soundwire.h>
#include <types.h>
@@ -2033,23 +2031,6 @@
acpigen_write_name_qword("_ADR", adr);
}
-void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn)
-{
- /*
- * _ADR for PCI Bus is encoded as follows:
- * [63:32] - unused
- * [31:16] - device #
- * [15:0] - function #
- */
- acpigen_write_ADR(PCI_SLOT(devfn) << 16 | PCI_FUNC(devfn));
-}
-
-void acpigen_write_ADR_pci_device(const struct device *dev)
-{
- assert(dev->path.type == DEVICE_PATH_PCI);
- acpigen_write_ADR_pci_devfn(dev->path.pci.devfn);
-}
-
/**
* acpigen_write_ADR_soundwire_device() - SoundWire ACPI Device Address Encoding.
* @address: SoundWire device address properties.
diff --git a/src/acpi/acpigen_pci.c b/src/acpi/acpigen_pci.c
new file mode 100644
index 0000000..66f8dcd
--- /dev/null
+++ b/src/acpi/acpigen_pci.c
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
+#include <assert.h>
+#include <device/device.h>
+#include <device/pci_def.h>
+#include <device/pci_type.h>
+#include <types.h>
+
+void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn)
+{
+ /*
+ * _ADR for PCI Bus is encoded as follows:
+ * [63:32] - unused
+ * [31:16] - device #
+ * [15:0] - function #
+ */
+ acpigen_write_ADR(PCI_SLOT(devfn) << 16 | PCI_FUNC(devfn));
+}
+
+void acpigen_write_ADR_pci_device(const struct device *dev)
+{
+ assert(dev->path.type == DEVICE_PATH_PCI);
+ acpigen_write_ADR_pci_devfn(dev->path.pci.devfn);
+}
diff --git a/src/acpi/device.c b/src/acpi/device.c
index 5de31b7..5d4d9be 100644
--- a/src/acpi/device.c
+++ b/src/acpi/device.c
@@ -5,6 +5,7 @@
#include <acpi/acpi.h>
#include <acpi/acpi_device.h>
#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
#include <device/device.h>
#include <device/path.h>
#include <stdlib.h>
diff --git a/src/drivers/intel/dptf/dptf.c b/src/drivers/intel/dptf/dptf.c
index 0f1cc9c..1713e72 100644
--- a/src/drivers/intel/dptf/dptf.c
+++ b/src/drivers/intel/dptf/dptf.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/device.h>
#include "chip.h"
diff --git a/src/drivers/intel/mipi_camera/camera.c b/src/drivers/intel/mipi_camera/camera.c
index 7dfd650..65eba16 100644
--- a/src/drivers/intel/mipi_camera/camera.c
+++ b/src/drivers/intel/mipi_camera/camera.c
@@ -4,6 +4,7 @@
#include <acpi/acpi.h>
#include <acpi/acpi_device.h>
#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/i2c_simple.h>
#include <device/device.h>
diff --git a/src/drivers/usb/pci_xhci/pci_xhci.c b/src/drivers/usb/pci_xhci/pci_xhci.c
index 6a56ca2..821cb5f 100644
--- a/src/drivers/usb/pci_xhci/pci_xhci.c
+++ b/src/drivers/usb/pci_xhci/pci_xhci.c
@@ -2,6 +2,7 @@
#include "pci_xhci.h"
#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/pci.h>
#include <device/pci_ids.h>
diff --git a/src/drivers/wifi/generic/acpi.c b/src/drivers/wifi/generic/acpi.c
index 4440b81..3e3b5c1 100644
--- a/src/drivers/wifi/generic/acpi.c
+++ b/src/drivers/wifi/generic/acpi.c
@@ -2,6 +2,7 @@
#include <acpi/acpi_device.h>
#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
#include <console/console.h>
#include <device/pci_ids.h>
#include <sar.h>
diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h
index 7b1141c..f7974eb 100644
--- a/src/include/acpi/acpigen.h
+++ b/src/include/acpi/acpigen.h
@@ -394,8 +394,6 @@
void acpigen_write_upc(enum acpi_upc_type type);
void acpigen_write_pld(const struct acpi_pld *pld);
void acpigen_write_ADR(uint64_t adr);
-void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn);
-void acpigen_write_ADR_pci_device(const struct device *dev);
struct soundwire_address;
void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address);
void acpigen_write_create_byte_field(uint8_t op, size_t byte_offset, const char *name);
diff --git a/src/include/acpi/acpigen_pci.h b/src/include/acpi/acpigen_pci.h
new file mode 100644
index 0000000..f050575
--- /dev/null
+++ b/src/include/acpi/acpigen_pci.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef ACPIGEN_PCI_H
+#define ACPIGEN_PCI_H
+
+#include <device/device.h>
+#include <device/pci_def.h>
+#include <device/pci_type.h>
+
+void acpigen_write_ADR_pci_devfn(pci_devfn_t devfn);
+void acpigen_write_ADR_pci_device(const struct device *dev);
+
+#endif /* ACPIGEN_PCI_H */
diff --git a/src/soc/amd/picasso/pcie_gpp.c b/src/soc/amd/picasso/pcie_gpp.c
index 00b32a0..baa9fa3 100644
--- a/src/soc/amd/picasso/pcie_gpp.c
+++ b/src/soc/amd/picasso/pcie_gpp.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <acpi/acpigen.h>
+#include <acpi/acpigen_pci.h>
#include <arch/ioapic.h>
#include <assert.h>
#include <amdblocks/amd_pci_util.h>