Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Martin Roth | 20646cd | 2023-01-04 21:27:06 -0700 | [diff] [blame^] | 3 | /* TODO: Update for Phoenix */ |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 4 | |
| 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 | |
| 14 | static 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 Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 26 | } |
| 27 | }; |
| 28 | |
| 29 | enum 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 Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | return CB_ERR_ARG; |
| 48 | } |
| 49 | |
| 50 | static void configure_xhci_sci(void *unused) |
| 51 | { |
| 52 | gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources) - 1); |
| 53 | } |
| 54 | |
| 55 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL); |