Skip to content

Commit 1df2531

Browse files
committed
soc/intel/common/block/usb4/usb4.c: Add TBT DMA _DSM
Mimic Intel's reference code. Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
1 parent 9b689da commit 1df2531

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

src/soc/intel/common/block/usb4/usb4.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define INTEL_TBT_IMR_VALID_UUID "C44D002F-69F9-4E7D-A904-A7BAABDF43F7"
1212
#define INTEL_TBT_WAKE_SUPPORTED_UUID "6C501103-C189-4296-BA72-9BF5A26EBE5D"
13+
#define INTEL_TBT_PCIE_SUPPORTED_UUID "197DB5E0-F095-4F33-B915-71DD70833E55"
1314

1415
#if CONFIG(HAVE_ACPI_TABLES)
1516
static const char *tbt_dma_acpi_name(const struct device *dev)
@@ -24,6 +25,51 @@ static const char *tbt_dma_acpi_name(const struct device *dev)
2425
}
2526
}
2627

28+
static bool tbt_pcie_enabled(struct device *tbt_pcie)
29+
{
30+
return (tbt_pcie && tbt_pcie->enabled);
31+
}
32+
33+
static void tbt_pcie_ports_present(void *arg)
34+
{
35+
uint8_t tbt0_bitmask, tbt1_bitmask;
36+
37+
tbt0_bitmask = tbt_pcie_enabled(SA_DEV_TBT0) | (tbt_pcie_enabled(SA_DEV_TBT1) << 1);
38+
tbt1_bitmask = tbt_pcie_enabled(SA_DEV_TBT2) | (tbt_pcie_enabled(SA_DEV_TBT3) << 1);
39+
40+
/* Name (PCPN, Buffer (1) {0}) */
41+
acpigen_write_name("PCPN");
42+
acpigen_emit_byte(BUFFER_OP);
43+
acpigen_write_len_f();
44+
acpigen_emit_byte(1);
45+
acpigen_emit_byte(0);
46+
acpigen_pop_len();
47+
48+
/* If DUID == 1 set TBT0/TBT1 bitmask, else set TBT2/TBT3 bitmask */
49+
acpigen_write_if_lequal_namestr_int("DUID", 0);
50+
acpigen_write_store_int_to_namestr(tbt0_bitmask, "PCPN");
51+
acpigen_write_else();
52+
acpigen_write_store_int_to_namestr(tbt1_bitmask, "PCPN");
53+
acpigen_write_if_end();
54+
55+
acpigen_write_return_namestr("PCPN");
56+
}
57+
58+
static void tbt_dma_caps_info(void *arg)
59+
{
60+
/*
61+
* Bit0 is IMR_VALID, bit1 is WAKE_SUPPORTED, bit2 is vPro Dock supported.
62+
* We hardcode both IMR_VALID and WAKE_SUPPORTED to 1.
63+
*/
64+
acpigen_write_return_singleton_buffer(3);
65+
}
66+
67+
static void (*tbt_pcie_helpers[])(void *) = {
68+
NULL, /* enumerate functions (autogenerated) */
69+
tbt_pcie_ports_present, /* Return supported TBT PCIe */
70+
tbt_dma_caps_info, /* Return supported TBT DMA capabilities */
71+
};
72+
2773
static void tbt_dma_fill_ssdt(const struct device *dev)
2874
{
2975
struct acpi_dp *dsd, *pkg;
@@ -47,6 +93,11 @@ static void tbt_dma_fill_ssdt(const struct device *dev)
4793
acpi_dp_add_package(dsd, pkg);
4894
acpi_dp_write(dsd);
4995

96+
acpigen_write_dsm(INTEL_TBT_PCIE_SUPPORTED_UUID,
97+
tbt_pcie_helpers,
98+
ARRAY_SIZE(tbt_pcie_helpers),
99+
NULL);
100+
50101
acpigen_pop_len(); /* Scope */
51102
}
52103
#endif

src/soc/intel/meteorlake/include/soc/pci_devs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,9 @@
241241
#define SA_DEVFN_ROOT PCI_DEVFN_ROOT
242242
#define SA_DEVFN_TCSS_DMA0 PCI_DEVFN_TCSS_DMA0
243243
#define SA_DEVFN_TCSS_DMA1 PCI_DEVFN_TCSS_DMA1
244+
#define SA_DEV_TBT0 PCI_DEV_TBT0
245+
#define SA_DEV_TBT1 PCI_DEV_TBT1
246+
#define SA_DEV_TBT2 PCI_DEV_TBT2
247+
#define SA_DEV_TBT3 PCI_DEV_TBT3
244248
#define SA_DEV_IGD PCI_DEV_IGD
245249
#define SA_DEVFN_IGD PCI_DEVFN_IGD

0 commit comments

Comments
 (0)