Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 3 | #include <acpi/acpigen.h> |
| 4 | #include <acpi/acpi_device.h> |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 7 | #include <device/pci_def.h> |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 8 | #include <device/pci_ids.h> |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 9 | #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) |
| 15 | static 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 | |
| 27 | static 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 Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 53 | |
| 54 | static 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 | |
| 60 | static 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 Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 66 | #if CONFIG(HAVE_ACPI_TABLES) |
| 67 | .acpi_name = tbt_dma_acpi_name, |
| 68 | .acpi_fill_ssdt = tbt_dma_fill_ssdt, |
| 69 | #endif |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | static 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 | }; |