blob: a77830c7b006cb1bbf62e402a2caf074307959d0 [file] [log] [blame]
Felix Helde77d9392021-03-11 19:37:32 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <amdblocks/gpio_banks.h>
4#include <amdblocks/smi.h>
5#include <bootstate.h>
6#include <device/device.h>
7#include <drivers/usb/pci_xhci/pci_xhci.h>
8#include <soc/pci_devs.h>
9#include <soc/smi.h>
10
11static const struct sci_source xhci_sci_sources[] = {
12 {
13 .scimap = SMITYPE_XHC0_PME,
14 .gpe = GEVENT_31,
15 .direction = SMI_SCI_LVL_HIGH,
16 .level = SMI_SCI_EDG
17 },
18 {
19 .scimap = SMITYPE_XHC1_PME,
20 .gpe = GEVENT_31,
21 .direction = SMI_SCI_LVL_HIGH,
22 .level = SMI_SCI_EDG
23 }
24};
25
26enum cb_err pci_xhci_get_wake_gpe(const struct device *dev, int *gpe)
27{
28 if (dev->bus->dev->path.type != DEVICE_PATH_PCI)
29 return CB_ERR_ARG;
30
31 if (dev->bus->dev->path.pci.devfn != PCIE_ABC_A_DEVFN)
32 return CB_ERR_ARG;
33
34 if (dev->path.type != DEVICE_PATH_PCI)
35 return CB_ERR_ARG;
36
37 if (dev->path.pci.devfn == XHCI0_DEVFN)
38 *gpe = xhci_sci_sources[0].gpe;
39 else if (dev->path.pci.devfn == XHCI1_DEVFN)
40 *gpe = xhci_sci_sources[1].gpe;
41 else
42 return CB_ERR_ARG;
43
44 return CB_SUCCESS;
45}
46
47static void configure_xhci_sci(void *unused)
48{
49 gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources));
50}
51
52BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL);