diff --git a/src/soc/amd/common/block/acpi/Makefile.inc b/src/soc/amd/common/block/acpi/Makefile.inc index 30e01ddbcc..41ce92bf80 100644 --- a/src/soc/amd/common/block/acpi/Makefile.inc +++ b/src/soc/amd/common/block/acpi/Makefile.inc @@ -13,4 +13,7 @@ ramstage-$(CONFIG_ACPI_BERT) += bert.c ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_ACPI_ALIB) += alib.c ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_ACPI_GPIO) += gpio.c +romstage-y += elog.c +ramstage-y += elog.c + endif # CONFIG_SOC_AMD_COMMON_BLOCK_ACPI diff --git a/src/soc/amd/common/block/acpi/acpi.c b/src/soc/amd/common/block/acpi/acpi.c index df5b40d70f..9e4010d340 100644 --- a/src/soc/amd/common/block/acpi/acpi.c +++ b/src/soc/amd/common/block/acpi/acpi.c @@ -1,12 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#include -#include #include #include +#include +#include #include #include -#include #include #include #include @@ -65,36 +64,6 @@ static uint16_t print_pm1_status(uint16_t pm1_sts) return pm1_sts; } -static void log_pm1_status(uint16_t pm1_sts) -{ - if (!CONFIG(ELOG)) - return; - - if (pm1_sts & WAK_STS) - elog_add_event_byte(ELOG_TYPE_ACPI_WAKE, - acpi_is_wakeup_s3() ? ACPI_S3 : ACPI_S5); - - if (pm1_sts & PWRBTN_STS) - elog_add_event_wake(ELOG_WAKE_SOURCE_PWRBTN, 0); - - if (pm1_sts & RTC_STS) - elog_add_event_wake(ELOG_WAKE_SOURCE_RTC, 0); - - if (pm1_sts & PCIEXPWAK_STS) - elog_add_event_wake(ELOG_WAKE_SOURCE_PCIE, 0); -} - -static void log_gpe_events(const struct acpi_pm_gpe_state *state) -{ - int i; - uint32_t valid_gpe = state->gpe0_sts & state->gpe0_en; - - for (i = 0; i <= 31; i++) { - if (valid_gpe & (1U << i)) - elog_add_event_wake(ELOG_WAKE_SOURCE_GPE, i); - } -} - void acpi_fill_pm_gpe_state(struct acpi_pm_gpe_state *state) { state->pm1_sts = acpi_read16(MMIO_ACPI_PM1_STS); @@ -114,9 +83,8 @@ void acpi_pm_gpe_add_events_print_events(void) return; state = &ps->gpe_state; - log_pm1_status(state->pm1_sts); print_pm1_status(state->pm1_sts); - log_gpe_events(state); + acpi_log_events(ps); } void acpi_clear_pm_gpe_status(void) diff --git a/src/soc/amd/common/block/acpi/elog.c b/src/soc/amd/common/block/acpi/elog.c new file mode 100644 index 0000000000..b9268aa7a8 --- /dev/null +++ b/src/soc/amd/common/block/acpi/elog.c @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +static void elog_pm1_status(const struct acpi_pm_gpe_state *state) +{ + uint16_t pm1_sts = state->pm1_sts; + + if (pm1_sts & WAK_STS) + elog_add_event_byte(ELOG_TYPE_ACPI_WAKE, state->previous_sx_state); + + if (pm1_sts & PWRBTN_STS) + elog_add_event_wake(ELOG_WAKE_SOURCE_PWRBTN, 0); + + if (pm1_sts & RTC_STS) + elog_add_event_wake(ELOG_WAKE_SOURCE_RTC, 0); + + if (pm1_sts & PCIEXPWAK_STS) + elog_add_event_wake(ELOG_WAKE_SOURCE_PCIE, 0); +} + +static void elog_gpe_events(const struct acpi_pm_gpe_state *state) +{ + int i; + uint32_t valid_gpe = state->gpe0_sts & state->gpe0_en; + + for (i = 0; i <= 31; i++) { + if (valid_gpe & (1U << i)) + elog_add_event_wake(ELOG_WAKE_SOURCE_GPE, i); + } +} + +void acpi_log_events(const struct chipset_power_state *ps) +{ + elog_pm1_status(&ps->gpe_state); + elog_gpe_events(&ps->gpe_state); +} diff --git a/src/soc/amd/common/block/include/amdblocks/acpi.h b/src/soc/amd/common/block/include/amdblocks/acpi.h index eec5a3fc17..fa75e5ae53 100644 --- a/src/soc/amd/common/block/include/amdblocks/acpi.h +++ b/src/soc/amd/common/block/include/amdblocks/acpi.h @@ -59,4 +59,6 @@ void acpi_fill_root_complex_tom(const struct device *device); uintptr_t add_agesa_fsp_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *rsdp, uintptr_t current); +void acpi_log_events(const struct chipset_power_state *ps); + #endif /* AMD_BLOCK_ACPI_H */