mb/google/brya/var/orisa: Update Type C DisplayPort HPD Configuration
[coreboot2.git] / src / soc / amd / phoenix / xhci.c
blob79d4d079fec1fa1bb5bc2e0cc663fa72d0da5646
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/gpio.h>
4 #include <amdblocks/smi.h>
5 #include <amdblocks/xhci.h>
6 #include <bootstate.h>
7 #include <device/device.h>
8 #include <device/pci_ids.h>
9 #include <drivers/usb/pci_xhci/pci_xhci.h>
10 #include <soc/pci_devs.h>
11 #include <soc/smi.h>
13 static const struct sci_source xhci_sci_sources[] = {
15 .scimap = SMITYPE_XHC0_PME,
16 .gpe = XHCI_GEVENT,
17 .direction = SMI_SCI_LVL_HIGH,
18 .level = SMI_SCI_EDG
21 .scimap = SMITYPE_XHC1_PME,
22 .gpe = XHCI_GEVENT,
23 .direction = SMI_SCI_LVL_HIGH,
24 .level = SMI_SCI_EDG
27 .scimap = SMITYPE_XHC3_PME,
28 .gpe = XHCI_GEVENT,
29 .direction = SMI_SCI_LVL_HIGH,
30 .level = SMI_SCI_EDG
33 .scimap = SMITYPE_XHC4_PME,
34 .gpe = XHCI_GEVENT,
35 .direction = SMI_SCI_LVL_HIGH,
36 .level = SMI_SCI_EDG
40 enum cb_err pci_xhci_get_wake_gpe(const struct device *dev, int *gpe)
42 if (dev->upstream->dev->path.type != DEVICE_PATH_PCI)
43 return CB_ERR_ARG;
45 if (dev->path.type != DEVICE_PATH_PCI)
46 return CB_ERR_ARG;
48 if (dev->upstream->dev->path.pci.devfn == PCIE_ABC_A_DEVFN) {
49 if (dev->path.pci.devfn == XHCI0_DEVFN) {
50 *gpe = xhci_sci_sources[0].gpe;
51 return CB_SUCCESS;
52 } else if (dev->path.pci.devfn == XHCI1_DEVFN) {
53 *gpe = xhci_sci_sources[1].gpe;
54 return CB_SUCCESS;
58 if (dev->upstream->dev->path.pci.devfn == PCIE_ABC_C_DEVFN) {
59 if (dev->path.pci.devfn == USB4_XHCI0_DEVFN) {
60 *gpe = xhci_sci_sources[2].gpe;
61 return CB_SUCCESS;
62 } else if (dev->path.pci.devfn == USB4_XHCI1_DEVFN) {
63 *gpe = xhci_sci_sources[3].gpe;
64 return CB_SUCCESS;
68 return CB_ERR_ARG;
71 static void configure_xhci_sci(void *unused)
73 gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources));
76 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL);