1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <amdblocks/acpi.h>
4 #include <amdblocks/xhci.h>
6 #include <soc/southbridge.h>
8 static void elog_pm1_status(const struct acpi_pm_gpe_state
*state
)
10 uint16_t pm1_sts
= state
->pm1_sts
;
12 if (pm1_sts
& WAK_STS
)
13 elog_add_event_byte(ELOG_TYPE_ACPI_WAKE
, state
->previous_sx_state
);
15 if (pm1_sts
& PWRBTN_STS
)
16 elog_add_event_wake(ELOG_WAKE_SOURCE_PWRBTN
, 0);
18 if (pm1_sts
& RTC_STS
)
19 elog_add_event_wake(ELOG_WAKE_SOURCE_RTC
, 0);
21 if (pm1_sts
& PCIEXPWAK_STS
)
22 elog_add_event_wake(ELOG_WAKE_SOURCE_PCIE
, 0);
25 static void elog_gpe_events(const struct acpi_pm_gpe_state
*state
)
28 uint32_t valid_gpe
= state
->gpe0_sts
& state
->gpe0_en
;
33 for (i
= 0; i
<= 31; i
++) {
34 if (valid_gpe
& (1U << i
)) {
35 elog_add_event_wake(ELOG_WAKE_SOURCE_GPE
, i
);
37 if (CONFIG(SOC_AMD_COMMON_BLOCK_XHCI_ELOG
) && i
== XHCI_GEVENT
)
38 soc_xhci_log_wake_events();
43 void acpi_log_events(const struct chipset_power_state
*ps
)
45 elog_pm1_status(&ps
->gpe_state
);
46 elog_gpe_events(&ps
->gpe_state
);