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> |
John Zhao | 3c46371 | 2022-01-10 15:49:37 -0800 | [diff] [blame] | 9 | #include <intelblocks/tcss.h> |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 10 | #include <soc/pci_devs.h> |
| 11 | |
| 12 | #define INTEL_TBT_IMR_VALID_UUID "C44D002F-69F9-4E7D-A904-A7BAABDF43F7" |
| 13 | #define INTEL_TBT_WAKE_SUPPORTED_UUID "6C501103-C189-4296-BA72-9BF5A26EBE5D" |
| 14 | |
| 15 | #if CONFIG(HAVE_ACPI_TABLES) |
| 16 | static const char *tbt_dma_acpi_name(const struct device *dev) |
| 17 | { |
| 18 | switch (dev->path.pci.devfn) { |
Duncan Laurie | fcbf18c | 2020-10-18 15:03:21 -0700 | [diff] [blame] | 19 | case SA_DEVFN_TCSS_DMA0: |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 20 | return "TDM0"; |
Duncan Laurie | fcbf18c | 2020-10-18 15:03:21 -0700 | [diff] [blame] | 21 | case SA_DEVFN_TCSS_DMA1: |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 22 | return "TDM1"; |
| 23 | default: |
| 24 | return NULL; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | static void tbt_dma_fill_ssdt(const struct device *dev) |
| 29 | { |
| 30 | struct acpi_dp *dsd, *pkg; |
| 31 | |
John Zhao | 3c46371 | 2022-01-10 15:49:37 -0800 | [diff] [blame] | 32 | if (!tcss_valid_tbt_auth()) |
John Zhao | 3748170 | 2021-05-19 15:04:53 -0700 | [diff] [blame] | 33 | return; |
| 34 | |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 35 | acpigen_write_scope(acpi_device_path(dev)); |
| 36 | |
| 37 | dsd = acpi_dp_new_table("_DSD"); |
| 38 | |
| 39 | /* Indicate that device has valid IMR. */ |
| 40 | pkg = acpi_dp_new_table(INTEL_TBT_IMR_VALID_UUID); |
| 41 | acpi_dp_add_integer(pkg, "IMR_VALID", 1); |
| 42 | acpi_dp_add_package(dsd, pkg); |
| 43 | |
| 44 | /* Indicate that device is wake capable. */ |
| 45 | pkg = acpi_dp_new_table(INTEL_TBT_WAKE_SUPPORTED_UUID); |
| 46 | acpi_dp_add_integer(pkg, "WAKE_SUPPORTED", 1); |
| 47 | |
| 48 | acpi_dp_add_package(dsd, pkg); |
| 49 | acpi_dp_write(dsd); |
| 50 | |
| 51 | acpigen_pop_len(); /* Scope */ |
| 52 | } |
| 53 | #endif |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 54 | |
| 55 | static const unsigned short pci_device_ids[] = { |
| 56 | PCI_DEVICE_ID_INTEL_TGL_TBT_DMA0, |
| 57 | PCI_DEVICE_ID_INTEL_TGL_TBT_DMA1, |
Jeremy Soller | 191a8d7 | 2021-08-10 14:06:51 -0600 | [diff] [blame] | 58 | PCI_DEVICE_ID_INTEL_TGL_H_TBT_DMA0, |
| 59 | PCI_DEVICE_ID_INTEL_TGL_H_TBT_DMA1, |
Subrata Banik | 3e6cfa2 | 2020-12-07 11:47:13 +0530 | [diff] [blame] | 60 | PCI_DEVICE_ID_INTEL_ADL_TBT_DMA0, |
| 61 | PCI_DEVICE_ID_INTEL_ADL_TBT_DMA1, |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 62 | 0 |
| 63 | }; |
| 64 | |
| 65 | static struct device_operations usb4_dev_ops = { |
| 66 | .read_resources = pci_dev_read_resources, |
| 67 | .set_resources = pci_dev_set_resources, |
| 68 | .enable_resources = pci_dev_enable_resources, |
| 69 | .scan_bus = scan_generic_bus, |
| 70 | .ops_pci = &pci_dev_ops_pci, |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 71 | #if CONFIG(HAVE_ACPI_TABLES) |
| 72 | .acpi_name = tbt_dma_acpi_name, |
| 73 | .acpi_fill_ssdt = tbt_dma_fill_ssdt, |
| 74 | #endif |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static const struct pci_driver usb4_driver __pci_driver = { |
| 78 | .ops = &usb4_dev_ops, |
| 79 | .vendor = PCI_VENDOR_ID_INTEL, |
| 80 | .devices = pci_device_ids, |
| 81 | }; |