Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56723 )
Change subject: drivers/pcie/: Add new `external` chip driver ......................................................................
drivers/pcie/: Add new `external` chip driver
The soc/intel/common/block/pcie/rtd3 chip driver, which is an ACPI driver, in addition to other things, adds a _DSD that specifies the "ExternalFacingPort" property. This property is also useful on its own, as it usually tells the operating system that any downstream DMA is from an external source and should be handled especially carefully. Therefore, copy this section of that driver out into a new driver.
BUG=b:190408519 TEST=With next patch, disassemble SSDT on brya0 and find: Scope (_SB.PCI0.RP01) { Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("efcc06cc-73ac-4bc3-bff0-76143807c389"), Package (0x01) { Package (0x02) { "ExternalFacingPort", One } } }) }
Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org Change-Id: I357cd673ad816bb954815ed3c9e4d4f70843a01d --- A src/drivers/pcie/external/Kconfig A src/drivers/pcie/external/Makefile.inc A src/drivers/pcie/external/chip.c A src/drivers/pcie/external/chip.h 4 files changed, 76 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/56723/1
diff --git a/src/drivers/pcie/external/Kconfig b/src/drivers/pcie/external/Kconfig new file mode 100644 index 0000000..5cef7bf --- /dev/null +++ b/src/drivers/pcie/external/Kconfig @@ -0,0 +1,8 @@ +config DRIVERS_PCIE_EXTERNAL + bool + default n + help + This config option adds the "ExternalFacingPort" property in a _DSD + for the PCIe root port any chip devices are added under. More + information can be found at + https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-r... diff --git a/src/drivers/pcie/external/Makefile.inc b/src/drivers/pcie/external/Makefile.inc new file mode 100644 index 0000000..cca7e3b --- /dev/null +++ b/src/drivers/pcie/external/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_PCIE_EXTERNAL) += chip.c diff --git a/src/drivers/pcie/external/chip.c b/src/drivers/pcie/external/chip.c new file mode 100644 index 0000000..a9054a0 --- /dev/null +++ b/src/drivers/pcie/external/chip.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <acpi/acpigen.h> +#include <acpi/acpi_device.h> +#include <console/console.h> +#include <device/device.h> + +/* + * The "ExternalFacingPort" property is defined at + * https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-r... + */ +#define PCIE_EXTERNAL_PORT_UUID "EFCC06CC-73AC-4BC3-BFF0-76143807C389" +#define PCIE_EXTERNAL_PORT_PROPERTY "ExternalFacingPort" + +static void external_rp_fill_ssdt(const struct device *dev) +{ + const struct device *parent = dev->bus->dev; + const char *scope; + struct acpi_dp *dsd, *pkg; + + if (!parent || !is_dev_enabled(parent)) { + printk(BIOS_ERR, "%s: Disabled PCIe root port\n", __func__); + return; + } + + scope = acpi_device_path(parent); + if (!scope) { + printk(BIOS_ERR, "%s: root port scope not found\n", __func__); + return; + } + + /* Indicate to the OS if the device provides an External facing port. */ + dsd = acpi_dp_new_table("_DSD"); + pkg = acpi_dp_new_table(PCIE_EXTERNAL_PORT_UUID); + acpi_dp_add_integer(pkg, PCIE_EXTERNAL_PORT_PROPERTY, 1); + acpi_dp_add_package(dsd, pkg); + + printk(BIOS_INFO, "%s: Added " PCIE_EXTERNAL_PORT_PROPERTY " property\n", scope); + + acpi_dp_write(dsd); + acpigen_write_scope_end(); +} + +static struct device_operations external_rp_ops = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .acpi_fill_ssdt = external_rp_fill_ssdt, +}; + +static void external_rp_acpi_enable(struct device *dev) +{ + dev->ops = &external_rp_ops; +} + +struct chip_operations drivers_pcie_external_ops = { + CHIP_NAME("Intel PCIe Runtime D3") + .enable_dev = external_rp_acpi_enable, +}; diff --git a/src/drivers/pcie/external/chip.h b/src/drivers/pcie/external/chip.h new file mode 100644 index 0000000..ff9a251 --- /dev/null +++ b/src/drivers/pcie/external/chip.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __DRIVERS_PCIE_EXTERNAL_H__ +#define __DRIVERS_PCIE_EXTERNAL_H__ + +struct drivers_pcie_external_config { +}; + +#endif /* __DRIVERS_PCIE_EXTERNAL_H__ */