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