blob: 7c545f6043c717168fd4fcbc7035a12adebea4ce [file] [log] [blame]
Tim Wawrzynczak950305d2020-10-07 13:47:33 -06001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
Duncan Lauried6331e02020-08-28 18:09:56 +00003#include <acpi/acpigen.h>
4#include <acpi/acpi_device.h>
Tim Wawrzynczak950305d2020-10-07 13:47:33 -06005#include <device/device.h>
6#include <device/pci.h>
Duncan Lauried6331e02020-08-28 18:09:56 +00007#include <device/pci_def.h>
Tim Wawrzynczak950305d2020-10-07 13:47:33 -06008#include <device/pci_ids.h>
Duncan Lauried6331e02020-08-28 18:09:56 +00009#include <soc/pci_devs.h>
10
11#define INTEL_TBT_IMR_VALID_UUID "C44D002F-69F9-4E7D-A904-A7BAABDF43F7"
12#define INTEL_TBT_WAKE_SUPPORTED_UUID "6C501103-C189-4296-BA72-9BF5A26EBE5D"
13
14#if CONFIG(HAVE_ACPI_TABLES)
15static const char *tbt_dma_acpi_name(const struct device *dev)
16{
17 switch (dev->path.pci.devfn) {
18 case SA_DEV_TCSS_DMA0:
19 return "TDM0";
20 case SA_DEV_TCSS_DMA1:
21 return "TDM1";
22 default:
23 return NULL;
24 }
25}
26
27static void tbt_dma_fill_ssdt(const struct device *dev)
28{
29 struct acpi_dp *dsd, *pkg;
30
31 if (!dev->enabled)
32 return;
33
34 acpigen_write_scope(acpi_device_path(dev));
35
36 dsd = acpi_dp_new_table("_DSD");
37
38 /* Indicate that device has valid IMR. */
39 pkg = acpi_dp_new_table(INTEL_TBT_IMR_VALID_UUID);
40 acpi_dp_add_integer(pkg, "IMR_VALID", 1);
41 acpi_dp_add_package(dsd, pkg);
42
43 /* Indicate that device is wake capable. */
44 pkg = acpi_dp_new_table(INTEL_TBT_WAKE_SUPPORTED_UUID);
45 acpi_dp_add_integer(pkg, "WAKE_SUPPORTED", 1);
46
47 acpi_dp_add_package(dsd, pkg);
48 acpi_dp_write(dsd);
49
50 acpigen_pop_len(); /* Scope */
51}
52#endif
Tim Wawrzynczak950305d2020-10-07 13:47:33 -060053
54static const unsigned short pci_device_ids[] = {
55 PCI_DEVICE_ID_INTEL_TGL_TBT_DMA0,
56 PCI_DEVICE_ID_INTEL_TGL_TBT_DMA1,
57 0
58};
59
60static struct device_operations usb4_dev_ops = {
61 .read_resources = pci_dev_read_resources,
62 .set_resources = pci_dev_set_resources,
63 .enable_resources = pci_dev_enable_resources,
64 .scan_bus = scan_generic_bus,
65 .ops_pci = &pci_dev_ops_pci,
Duncan Lauried6331e02020-08-28 18:09:56 +000066#if CONFIG(HAVE_ACPI_TABLES)
67 .acpi_name = tbt_dma_acpi_name,
68 .acpi_fill_ssdt = tbt_dma_fill_ssdt,
69#endif
Tim Wawrzynczak950305d2020-10-07 13:47:33 -060070};
71
72static const struct pci_driver usb4_driver __pci_driver = {
73 .ops = &usb4_dev_ops,
74 .vendor = PCI_VENDOR_ID_INTEL,
75 .devices = pci_device_ids,
76};