1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* TODO: Update for Glinda */
5 #include <amdblocks/gpio.h>
6 #include <amdblocks/smi.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>
14 static const struct sci_source xhci_sci_sources
[] = {
16 .scimap
= SMITYPE_XHC0_PME
,
18 .direction
= SMI_SCI_LVL_HIGH
,
22 .scimap
= SMITYPE_XHC1_PME
,
24 .direction
= SMI_SCI_LVL_HIGH
,
28 .scimap
= SMITYPE_XHC3_PME
,
30 .direction
= SMI_SCI_LVL_HIGH
,
34 .scimap
= SMITYPE_XHC4_PME
,
36 .direction
= SMI_SCI_LVL_HIGH
,
41 enum cb_err
pci_xhci_get_wake_gpe(const struct device
*dev
, int *gpe
)
43 if (dev
->upstream
->dev
->path
.type
!= DEVICE_PATH_PCI
)
46 if (dev
->path
.type
!= DEVICE_PATH_PCI
)
49 if (dev
->upstream
->dev
->path
.pci
.devfn
== PCIE_ABC_A_DEVFN
) {
50 if (dev
->path
.pci
.devfn
== XHCI1_DEVFN
) {
51 *gpe
= xhci_sci_sources
[1].gpe
;
54 } else if (dev
->upstream
->dev
->path
.pci
.devfn
== PCIE_ABC_C_DEVFN
) {
55 if (dev
->path
.pci
.devfn
== XHCI0_DEVFN
) {
56 *gpe
= xhci_sci_sources
[0].gpe
;
58 } else if (dev
->path
.pci
.devfn
== USB4_XHCI0_DEVFN
) {
59 *gpe
= xhci_sci_sources
[2].gpe
;
61 } else if (dev
->path
.pci
.devfn
== USB4_XHCI1_DEVFN
) {
62 *gpe
= xhci_sci_sources
[3].gpe
;
70 static void configure_xhci_sci(void *unused
)
72 gpe_configure_sci(xhci_sci_sources
, ARRAY_SIZE(xhci_sci_sources
) - 1);
75 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE
, BS_ON_ENTRY
, configure_xhci_sci
, NULL
);