Felix Held | e77d939 | 2021-03-11 19:37:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Felix Held | dea4e0f | 2021-09-22 20:05:53 +0200 | [diff] [blame] | 3 | #include <amdblocks/gpio.h> |
Felix Held | e77d939 | 2021-03-11 19:37:32 +0100 | [diff] [blame] | 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 | |
| 11 | static 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 | |
| 26 | enum 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 | |
| 47 | static void configure_xhci_sci(void *unused) |
| 48 | { |
| 49 | gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources)); |
| 50 | } |
| 51 | |
| 52 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL); |