diff options
author | Karthikeyan Ramasubramanian <kramasub@google.com> | 2021-07-15 14:58:23 -0600 |
---|---|---|
committer | Werner Zeh <werner.zeh@siemens.com> | 2021-07-26 04:42:54 +0000 |
commit | 589ac69850c49ed4e24963a8756f76ec78d503c9 (patch) | |
tree | 651a43114651bce951e4d852e738fce67b3606ea /src/soc/amd | |
parent | 9adf4a6656c609beec7a9ecd2615aade1ecf8caa (diff) |
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>
Diffstat (limited to 'src/soc/amd')
-rw-r--r-- | src/soc/amd/common/block/acpi/Makefile.inc | 3 | ||||
-rw-r--r-- | src/soc/amd/common/block/acpi/acpi.c | 38 | ||||
-rw-r--r-- | src/soc/amd/common/block/acpi/elog.c | 39 | ||||
-rw-r--r-- | src/soc/amd/common/block/include/amdblocks/acpi.h | 2 |
4 files changed, 47 insertions, 35 deletions
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 <amdblocks/acpimmio.h> -#include <amdblocks/acpi.h> #include <acpi/acpi.h> #include <acpi/acpi_pm.h> +#include <amdblocks/acpimmio.h> +#include <amdblocks/acpi.h> #include <bootmode.h> #include <console/console.h> -#include <elog.h> #include <halt.h> #include <security/vboot/vboot_common.h> #include <soc/southbridge.h> @@ -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 <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); +} 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 */ |