From d6331e0884ceb6a17f7fd446b287b7cb5e50fcc1 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Fri, 28 Aug 2020 18:09:56 +0000 Subject: soc/intel/common/block: Add common support for USB4/Thunderbolt This common intel driver will add the requried ACPI _DSD entries for enabled USB4/Thunderbolt ports' DMA devices the SSDT instead of using hardcoded values in the DSDT. Change-Id: Ic4a58202d4569cf092ea21a4a83a3af6c42ce9d0 Signed-off-by: Duncan Laurie Signed-off-by: Tim Wawrzynczak Reviewed-on: https://review.coreboot.org/c/coreboot/+/44916 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/soc/intel/common/block/usb4/usb4.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src') diff --git a/src/soc/intel/common/block/usb4/usb4.c b/src/soc/intel/common/block/usb4/usb4.c index a0afc20f5b..7c545f6043 100644 --- a/src/soc/intel/common/block/usb4/usb4.c +++ b/src/soc/intel/common/block/usb4/usb4.c @@ -1,8 +1,55 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include +#include #include #include +#include #include +#include + +#define INTEL_TBT_IMR_VALID_UUID "C44D002F-69F9-4E7D-A904-A7BAABDF43F7" +#define INTEL_TBT_WAKE_SUPPORTED_UUID "6C501103-C189-4296-BA72-9BF5A26EBE5D" + +#if CONFIG(HAVE_ACPI_TABLES) +static const char *tbt_dma_acpi_name(const struct device *dev) +{ + switch (dev->path.pci.devfn) { + case SA_DEV_TCSS_DMA0: + return "TDM0"; + case SA_DEV_TCSS_DMA1: + return "TDM1"; + default: + return NULL; + } +} + +static void tbt_dma_fill_ssdt(const struct device *dev) +{ + struct acpi_dp *dsd, *pkg; + + if (!dev->enabled) + return; + + acpigen_write_scope(acpi_device_path(dev)); + + dsd = acpi_dp_new_table("_DSD"); + + /* Indicate that device has valid IMR. */ + pkg = acpi_dp_new_table(INTEL_TBT_IMR_VALID_UUID); + acpi_dp_add_integer(pkg, "IMR_VALID", 1); + acpi_dp_add_package(dsd, pkg); + + /* Indicate that device is wake capable. */ + pkg = acpi_dp_new_table(INTEL_TBT_WAKE_SUPPORTED_UUID); + acpi_dp_add_integer(pkg, "WAKE_SUPPORTED", 1); + + acpi_dp_add_package(dsd, pkg); + acpi_dp_write(dsd); + + acpigen_pop_len(); /* Scope */ +} +#endif static const unsigned short pci_device_ids[] = { PCI_DEVICE_ID_INTEL_TGL_TBT_DMA0, @@ -16,6 +63,10 @@ static struct device_operations usb4_dev_ops = { .enable_resources = pci_dev_enable_resources, .scan_bus = scan_generic_bus, .ops_pci = &pci_dev_ops_pci, +#if CONFIG(HAVE_ACPI_TABLES) + .acpi_name = tbt_dma_acpi_name, + .acpi_fill_ssdt = tbt_dma_fill_ssdt, +#endif }; static const struct pci_driver usb4_driver __pci_driver = { -- cgit v1.2.3