soc/amd/common/block/acpi: Extract event logging helpers
Move the event logging helpers defined in acpi into a separate library. This will allow logging power management and GPE events for both S3 and Modern Standby. Introduce a single helper acpi_log_events function to log both PM and GPE events. BUG=None TEST=Build and boot to OS in Guybrush. Change-Id: I96df66edfc824eb3db108098a560d33d758f55ba Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/56360 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
parent
9adf4a6656
commit
589ac69850
|
@ -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_ALIB) += alib.c
|
||||||
ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_ACPI_GPIO) += gpio.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
|
endif # CONFIG_SOC_AMD_COMMON_BLOCK_ACPI
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
|
||||||
#include <amdblocks/acpimmio.h>
|
|
||||||
#include <amdblocks/acpi.h>
|
|
||||||
#include <acpi/acpi.h>
|
#include <acpi/acpi.h>
|
||||||
#include <acpi/acpi_pm.h>
|
#include <acpi/acpi_pm.h>
|
||||||
|
#include <amdblocks/acpimmio.h>
|
||||||
|
#include <amdblocks/acpi.h>
|
||||||
#include <bootmode.h>
|
#include <bootmode.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <elog.h>
|
|
||||||
#include <halt.h>
|
#include <halt.h>
|
||||||
#include <security/vboot/vboot_common.h>
|
#include <security/vboot/vboot_common.h>
|
||||||
#include <soc/southbridge.h>
|
#include <soc/southbridge.h>
|
||||||
|
@ -65,36 +64,6 @@ static uint16_t print_pm1_status(uint16_t pm1_sts)
|
||||||
return 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)
|
void acpi_fill_pm_gpe_state(struct acpi_pm_gpe_state *state)
|
||||||
{
|
{
|
||||||
state->pm1_sts = acpi_read16(MMIO_ACPI_PM1_STS);
|
state->pm1_sts = acpi_read16(MMIO_ACPI_PM1_STS);
|
||||||
|
@ -114,9 +83,8 @@ void acpi_pm_gpe_add_events_print_events(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
state = &ps->gpe_state;
|
state = &ps->gpe_state;
|
||||||
log_pm1_status(state->pm1_sts);
|
|
||||||
print_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)
|
void acpi_clear_pm_gpe_status(void)
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
|
||||||
|
#include <amdblocks/acpi.h>
|
||||||
|
#include <elog.h>
|
||||||
|
#include <soc/southbridge.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
|
@ -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 add_agesa_fsp_acpi_table(guid_t guid, const char *name, acpi_rsdp_t *rsdp,
|
||||||
uintptr_t current);
|
uintptr_t current);
|
||||||
|
|
||||||
|
void acpi_log_events(const struct chipset_power_state *ps);
|
||||||
|
|
||||||
#endif /* AMD_BLOCK_ACPI_H */
|
#endif /* AMD_BLOCK_ACPI_H */
|
||||||
|
|
Loading…
Reference in New Issue