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 <dlaurie@google.com>
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44916
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Duncan Laurie 2020-08-28 18:09:56 +00:00 committed by Tim Wawrzynczak
parent 950305de0a
commit d6331e0884

View file

@ -1,8 +1,55 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
#include <device/pci_ids.h>
#include <soc/pci_devs.h>
#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 = {