tree: Remove unused <assert.h>
[coreboot.git] / src / soc / amd / mendocino / xhci.c
blobed8be752b491f4cddcf2f3eb7032d04ef15597ea
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* TODO: Check if this is still correct */
5 #include <amdblocks/gpio.h>
6 #include <amdblocks/smi.h>
7 #include <amdblocks/xhci.h>
8 #include <bootstate.h>
9 #include <device/device.h>
10 #include <device/pci_ids.h>
11 #include <drivers/usb/pci_xhci/pci_xhci.h>
12 #include <soc/pci_devs.h>
13 #include <soc/smi.h>
14 #include <static.h>
16 static const struct sci_source xhci_sci_sources[] = {
18 .scimap = SMITYPE_XHC0_PME,
19 .gpe = XHCI_GEVENT,
20 .direction = SMI_SCI_LVL_HIGH,
21 .level = SMI_SCI_EDG
24 .scimap = SMITYPE_XHC1_PME,
25 .gpe = XHCI_GEVENT,
26 .direction = SMI_SCI_LVL_HIGH,
27 .level = SMI_SCI_EDG
30 .scimap = SMITYPE_XHC2_PME,
31 .gpe = XHCI_GEVENT,
32 .direction = SMI_SCI_LVL_HIGH,
33 .level = SMI_SCI_EDG
37 enum cb_err pci_xhci_get_wake_gpe(const struct device *dev, int *gpe)
39 if (dev->upstream->dev->path.type != DEVICE_PATH_PCI)
40 return CB_ERR_ARG;
42 if (dev->path.type != DEVICE_PATH_PCI)
43 return CB_ERR_ARG;
45 if (dev->upstream->dev->path.pci.devfn == PCIE_ABC_A_DEVFN) {
46 if (dev->path.pci.devfn == XHCI0_DEVFN) {
47 *gpe = xhci_sci_sources[0].gpe;
48 return CB_SUCCESS;
49 } else if (dev->path.pci.devfn == XHCI1_DEVFN) {
50 *gpe = xhci_sci_sources[1].gpe;
51 return CB_SUCCESS;
53 } else if (dev->upstream->dev->path.pci.devfn == PCIE_ABC_C_DEVFN) {
54 if (dev->path.pci.devfn == XHCI2_DEVFN
55 && dev->device == PCI_DID_AMD_FAM17H_MODELA0H_XHCI2) {
56 *gpe = xhci_sci_sources[2].gpe;
57 return CB_SUCCESS;
61 return CB_ERR_ARG;
64 static void configure_xhci_sci(void *unused)
66 const struct device *xhci_2 = DEV_PTR(xhci_2);
67 if (xhci_2->device == PCI_DID_AMD_FAM17H_MODELA0H_XHCI2)
68 gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources));
69 else
70 gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources) - 1);
73 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL);