1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* TODO: Check if this is still correct */
5 #include <amdblocks/gpio.h>
6 #include <amdblocks/smi.h>
7 #include <amdblocks/xhci.h>
9 #include <device/device.h>
10 #include <device/pci_ids.h>
11 #include <drivers/usb/pci_xhci/pci_xhci.h>
12 #include <soc/pci_devs.h>
16 static const struct sci_source xhci_sci_sources
[] = {
18 .scimap
= SMITYPE_XHC0_PME
,
20 .direction
= SMI_SCI_LVL_HIGH
,
24 .scimap
= SMITYPE_XHC1_PME
,
26 .direction
= SMI_SCI_LVL_HIGH
,
30 .scimap
= SMITYPE_XHC2_PME
,
32 .direction
= SMI_SCI_LVL_HIGH
,
37 enum cb_err
pci_xhci_get_wake_gpe(const struct device
*dev
, int *gpe
)
39 if (dev
->upstream
->dev
->path
.type
!= DEVICE_PATH_PCI
)
42 if (dev
->path
.type
!= DEVICE_PATH_PCI
)
45 if (dev
->upstream
->dev
->path
.pci
.devfn
== PCIE_ABC_A_DEVFN
) {
46 if (dev
->path
.pci
.devfn
== XHCI0_DEVFN
) {
47 *gpe
= xhci_sci_sources
[0].gpe
;
49 } else if (dev
->path
.pci
.devfn
== XHCI1_DEVFN
) {
50 *gpe
= xhci_sci_sources
[1].gpe
;
53 } else if (dev
->upstream
->dev
->path
.pci
.devfn
== PCIE_ABC_C_DEVFN
) {
54 if (dev
->path
.pci
.devfn
== XHCI2_DEVFN
55 && dev
->device
== PCI_DID_AMD_FAM17H_MODELA0H_XHCI2
) {
56 *gpe
= xhci_sci_sources
[2].gpe
;
64 static void configure_xhci_sci(void *unused
)
66 const struct device
*xhci_2
= DEV_PTR(xhci_2
);
67 if (xhci_2
->device
== PCI_DID_AMD_FAM17H_MODELA0H_XHCI2
)
68 gpe_configure_sci(xhci_sci_sources
, ARRAY_SIZE(xhci_sci_sources
));
70 gpe_configure_sci(xhci_sci_sources
, ARRAY_SIZE(xhci_sci_sources
) - 1);
73 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE
, BS_ON_ENTRY
, configure_xhci_sci
, NULL
);