Raul E Rangel | 0357ab7 | 2020-07-09 12:08:58 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/gpio_banks.h> |
| 4 | #include <bootstate.h> |
| 5 | #include <device/device.h> |
| 6 | #include <drivers/usb/pci_xhci/pci_xhci.h> |
| 7 | #include <soc/pci_devs.h> |
| 8 | #include <soc/smi.h> |
| 9 | #include <soc/soc_util.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_GPP_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 | if (soc_is_reduced_io_sku()) |
| 50 | gpe_configure_sci(xhci_sci_sources, 1); |
| 51 | else |
| 52 | gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources)); |
| 53 | } |
| 54 | |
Raul E Rangel | 0357ab7 | 2020-07-09 12:08:58 -0600 | [diff] [blame] | 55 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL); |