1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/gpio.h>
4 #include <amdblocks/smi.h>
5 #include <amdblocks/xhci.h>
7 #include <device/device.h>
8 #include <device/pci_ids.h>
9 #include <drivers/usb/pci_xhci/pci_xhci.h>
10 #include <soc/pci_devs.h>
13 static const struct sci_source xhci_sci_sources
[] = {
15 .scimap
= SMITYPE_XHC0_PME
,
17 .direction
= SMI_SCI_LVL_HIGH
,
21 .scimap
= SMITYPE_XHC1_PME
,
23 .direction
= SMI_SCI_LVL_HIGH
,
27 .scimap
= SMITYPE_XHC3_PME
,
29 .direction
= SMI_SCI_LVL_HIGH
,
33 .scimap
= SMITYPE_XHC4_PME
,
35 .direction
= SMI_SCI_LVL_HIGH
,
40 enum cb_err
pci_xhci_get_wake_gpe(const struct device
*dev
, int *gpe
)
42 if (dev
->upstream
->dev
->path
.type
!= DEVICE_PATH_PCI
)
45 if (dev
->path
.type
!= DEVICE_PATH_PCI
)
48 if (dev
->upstream
->dev
->path
.pci
.devfn
== PCIE_ABC_A_DEVFN
) {
49 if (dev
->path
.pci
.devfn
== XHCI0_DEVFN
) {
50 *gpe
= xhci_sci_sources
[0].gpe
;
52 } else if (dev
->path
.pci
.devfn
== XHCI1_DEVFN
) {
53 *gpe
= xhci_sci_sources
[1].gpe
;
58 if (dev
->upstream
->dev
->path
.pci
.devfn
== PCIE_ABC_C_DEVFN
) {
59 if (dev
->path
.pci
.devfn
== USB4_XHCI0_DEVFN
) {
60 *gpe
= xhci_sci_sources
[2].gpe
;
62 } else if (dev
->path
.pci
.devfn
== USB4_XHCI1_DEVFN
) {
63 *gpe
= xhci_sci_sources
[3].gpe
;
71 static void configure_xhci_sci(void *unused
)
73 gpe_configure_sci(xhci_sci_sources
, ARRAY_SIZE(xhci_sci_sources
));
76 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE
, BS_ON_ENTRY
, configure_xhci_sci
, NULL
);