blob: 06481edce26ef5d4ff5ed10e2fc6b5b8f5c11f4f [file] [log] [blame]
Martin Roth1a3de8e2022-10-06 15:57:21 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Martin Roth20646cd2023-01-04 21:27:06 -07003/* TODO: Update for Phoenix */
Martin Roth1a3de8e2022-10-06 15:57:21 -06004
5#include <amdblocks/gpio.h>
6#include <amdblocks/smi.h>
7#include <bootstate.h>
8#include <device/device.h>
9#include <device/pci_ids.h>
10#include <drivers/usb/pci_xhci/pci_xhci.h>
11#include <soc/pci_devs.h>
12#include <soc/smi.h>
13
14static const struct sci_source xhci_sci_sources[] = {
15 {
16 .scimap = SMITYPE_XHC0_PME,
17 .gpe = GEVENT_31,
18 .direction = SMI_SCI_LVL_HIGH,
19 .level = SMI_SCI_EDG
20 },
21 {
22 .scimap = SMITYPE_XHC1_PME,
23 .gpe = GEVENT_31,
24 .direction = SMI_SCI_LVL_HIGH,
25 .level = SMI_SCI_EDG
Martin Roth1a3de8e2022-10-06 15:57:21 -060026 }
27};
28
29enum cb_err pci_xhci_get_wake_gpe(const struct device *dev, int *gpe)
30{
31 if (dev->bus->dev->path.type != DEVICE_PATH_PCI)
32 return CB_ERR_ARG;
33
34 if (dev->path.type != DEVICE_PATH_PCI)
35 return CB_ERR_ARG;
36
37 if (dev->bus->dev->path.pci.devfn == PCIE_ABC_A_DEVFN) {
38 if (dev->path.pci.devfn == XHCI0_DEVFN) {
39 *gpe = xhci_sci_sources[0].gpe;
40 return CB_SUCCESS;
41 } else if (dev->path.pci.devfn == XHCI1_DEVFN) {
42 *gpe = xhci_sci_sources[1].gpe;
43 return CB_SUCCESS;
44 }
Martin Roth1a3de8e2022-10-06 15:57:21 -060045 }
46
47 return CB_ERR_ARG;
48}
49
50static void configure_xhci_sci(void *unused)
51{
Fred Reitberger88fefd42023-04-19 16:06:38 -040052 gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources));
Martin Roth1a3de8e2022-10-06 15:57:21 -060053}
54
55BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL);