blob: a238916b71eef77e06ef0bab97edddbbc79fea8b [file] [log] [blame]
Raul E Rangel0357ab72020-07-09 12:08:58 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Felix Helddea4e0f2021-09-22 20:05:53 +02003#include <amdblocks/gpio.h>
Felix Helda5a52952020-12-01 18:14:01 +01004#include <amdblocks/smi.h>
Raul E Rangel0357ab72020-07-09 12:08:58 -06005#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#include <soc/soc_util.h>
11
12static const struct sci_source xhci_sci_sources[] = {
13 {
14 .scimap = SMITYPE_XHC0_PME,
15 .gpe = GEVENT_31,
16 .direction = SMI_SCI_LVL_HIGH,
17 .level = SMI_SCI_EDG
18 },
19 {
20 .scimap = SMITYPE_XHC1_PME,
21 .gpe = GEVENT_31,
22 .direction = SMI_SCI_LVL_HIGH,
23 .level = SMI_SCI_EDG
24 }
25};
26
27enum cb_err pci_xhci_get_wake_gpe(const struct device *dev, int *gpe)
28{
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020029 if (dev->upstream->dev->path.type != DEVICE_PATH_PCI)
Raul E Rangel0357ab72020-07-09 12:08:58 -060030 return CB_ERR_ARG;
31
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020032 if (dev->upstream->dev->path.pci.devfn != PCIE_GPP_A_DEVFN)
Raul E Rangel0357ab72020-07-09 12:08:58 -060033 return CB_ERR_ARG;
34
35 if (dev->path.type != DEVICE_PATH_PCI)
36 return CB_ERR_ARG;
37
38 if (dev->path.pci.devfn == XHCI0_DEVFN)
39 *gpe = xhci_sci_sources[0].gpe;
40 else if (dev->path.pci.devfn == XHCI1_DEVFN)
41 *gpe = xhci_sci_sources[1].gpe;
42 else
43 return CB_ERR_ARG;
44
45 return CB_SUCCESS;
46}
47
48static void configure_xhci_sci(void *unused)
49{
50 if (soc_is_reduced_io_sku())
51 gpe_configure_sci(xhci_sci_sources, 1);
52 else
53 gpe_configure_sci(xhci_sci_sources, ARRAY_SIZE(xhci_sci_sources));
54}
55
Raul E Rangel0357ab72020-07-09 12:08:58 -060056BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, configure_xhci_sci, NULL);