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> |
| 7 | #include <device/pci_ids.h> |
John Zhao | 3c46371 | 2022-01-10 15:49:37 -0800 | [diff] [blame] | 8 | #include <intelblocks/tcss.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) { |
Duncan Laurie | fcbf18c | 2020-10-18 15:03:21 -0700 | [diff] [blame] | 18 | case SA_DEVFN_TCSS_DMA0: |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 19 | return "TDM0"; |
Duncan Laurie | fcbf18c | 2020-10-18 15:03:21 -0700 | [diff] [blame] | 20 | case SA_DEVFN_TCSS_DMA1: |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 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 | |
John | 848b425 | 2022-03-09 17:51:56 -0800 | [diff] [blame] | 31 | if (tcss_ops.valid_tbt_auth && !tcss_ops.valid_tbt_auth()) |
John Zhao | 3748170 | 2021-05-19 15:04:53 -0700 | [diff] [blame] | 32 | return; |
| 33 | |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 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[] = { |
Appukuttan V K | 50c8f2e | 2024-01-11 18:05:11 +0530 | [diff] [blame] | 55 | PCI_DID_INTEL_LNL_TBT_DMA0, |
| 56 | PCI_DID_INTEL_LNL_TBT_DMA1, |
Bora Guvendik | a15b25f | 2022-02-28 14:43:49 -0800 | [diff] [blame] | 57 | PCI_DID_INTEL_RPL_TBT_DMA0, |
| 58 | PCI_DID_INTEL_RPL_TBT_DMA1, |
Wonkyu Kim | 9f40107 | 2020-11-13 15:16:32 -0800 | [diff] [blame] | 59 | PCI_DID_INTEL_MTL_M_TBT_DMA0, |
| 60 | PCI_DID_INTEL_MTL_P_TBT_DMA0, |
| 61 | PCI_DID_INTEL_MTL_P_TBT_DMA1, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 62 | PCI_DID_INTEL_TGL_TBT_DMA0, |
| 63 | PCI_DID_INTEL_TGL_TBT_DMA1, |
| 64 | PCI_DID_INTEL_TGL_H_TBT_DMA0, |
| 65 | PCI_DID_INTEL_TGL_H_TBT_DMA1, |
| 66 | PCI_DID_INTEL_ADL_TBT_DMA0, |
| 67 | PCI_DID_INTEL_ADL_TBT_DMA1, |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 68 | 0 |
| 69 | }; |
| 70 | |
| 71 | static struct device_operations usb4_dev_ops = { |
| 72 | .read_resources = pci_dev_read_resources, |
| 73 | .set_resources = pci_dev_set_resources, |
| 74 | .enable_resources = pci_dev_enable_resources, |
| 75 | .scan_bus = scan_generic_bus, |
| 76 | .ops_pci = &pci_dev_ops_pci, |
Duncan Laurie | d6331e0 | 2020-08-28 18:09:56 +0000 | [diff] [blame] | 77 | #if CONFIG(HAVE_ACPI_TABLES) |
| 78 | .acpi_name = tbt_dma_acpi_name, |
| 79 | .acpi_fill_ssdt = tbt_dma_fill_ssdt, |
| 80 | #endif |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | static const struct pci_driver usb4_driver __pci_driver = { |
| 84 | .ops = &usb4_dev_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 85 | .vendor = PCI_VID_INTEL, |
Tim Wawrzynczak | 950305d | 2020-10-07 13:47:33 -0600 | [diff] [blame] | 86 | .devices = pci_device_ids, |
| 87 | }; |