Attention is currently required from: Jason Glenesk, Raul Rangel, Marshall Dawson, Felix Held. Karthik Ramasubramanian has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56360 )
Change subject: soc/amd/common/block/acpi: Extract event logging helpers ......................................................................
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.
BUG=None TEST=Build and boot to OS in Guybrush.
Change-Id: I96df66edfc824eb3db108098a560d33d758f55ba Signed-off-by: Karthikeyan Ramasubramanian kramasub@google.com --- M src/soc/amd/cezanne/Kconfig M src/soc/amd/common/block/acpi/acpi.c A src/soc/amd/common/block/elog/Kconfig A src/soc/amd/common/block/elog/Makefile.inc A src/soc/amd/common/block/elog/elog.c A src/soc/amd/common/block/include/amdblocks/elog.h M src/soc/amd/picasso/Kconfig M src/soc/amd/stoneyridge/Kconfig 8 files changed, 64 insertions(+), 35 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/56360/1
diff --git a/src/soc/amd/cezanne/Kconfig b/src/soc/amd/cezanne/Kconfig index 71cca6a..b917964 100644 --- a/src/soc/amd/cezanne/Kconfig +++ b/src/soc/amd/cezanne/Kconfig @@ -44,6 +44,7 @@ select SOC_AMD_COMMON_BLOCK_APOB select SOC_AMD_COMMON_BLOCK_BANKED_GPIOS select SOC_AMD_COMMON_BLOCK_DATA_FABRIC + select SOC_AMD_COMMON_BLOCK_ELOG select SOC_AMD_COMMON_BLOCK_GRAPHICS select SOC_AMD_COMMON_BLOCK_HAS_ESPI select SOC_AMD_COMMON_BLOCK_I2C diff --git a/src/soc/amd/common/block/acpi/acpi.c b/src/soc/amd/common/block/acpi/acpi.c index df5b40d..d9807eb 100644 --- a/src/soc/amd/common/block/acpi/acpi.c +++ b/src/soc/amd/common/block/acpi/acpi.c @@ -1,12 +1,12 @@ /* 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 <amdblocks/elog.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 +65,6 @@ 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 +84,9 @@ return;
state = &ps->gpe_state; - log_pm1_status(state->pm1_sts); + elog_pm1_status(state->pm1_sts); print_pm1_status(state->pm1_sts); - log_gpe_events(state); + elog_gpe_events(state); }
void acpi_clear_pm_gpe_status(void) diff --git a/src/soc/amd/common/block/elog/Kconfig b/src/soc/amd/common/block/elog/Kconfig new file mode 100644 index 0000000..f3b5ba3 --- /dev/null +++ b/src/soc/amd/common/block/elog/Kconfig @@ -0,0 +1,4 @@ +config SOC_AMD_COMMON_BLOCK_ELOG + bool + help + Select this option to use common event logging library for AMD SoC. diff --git a/src/soc/amd/common/block/elog/Makefile.inc b/src/soc/amd/common/block/elog/Makefile.inc new file mode 100644 index 0000000..bfcd704 --- /dev/null +++ b/src/soc/amd/common/block/elog/Makefile.inc @@ -0,0 +1,2 @@ +all-$(CONFIG_SOC_AMD_COMMON_BLOCK_ELOG) += elog.c +smm-$(CONFIG_SOC_AMD_COMMON_BLOCK_ELOG) += elog.c diff --git a/src/soc/amd/common/block/elog/elog.c b/src/soc/amd/common/block/elog/elog.c new file mode 100644 index 0000000..a8c2e44 --- /dev/null +++ b/src/soc/amd/common/block/elog/elog.c @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <amdblocks/elog.h> +#include <elog.h> +#include <soc/southbridge.h> + +void elog_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); +} + +void elog_gpe_events(const struct acpi_pm_gpe_state *state) +{ + int i; + uint32_t valid_gpe = state->gpe0_sts & state->gpe0_en; + + if (!CONFIG(ELOG)) + return; + + for (i = 0; i <= 31; i++) { + if (valid_gpe & (1U << i)) + elog_add_event_wake(ELOG_WAKE_SOURCE_GPE, i); + } +} diff --git a/src/soc/amd/common/block/include/amdblocks/elog.h b/src/soc/amd/common/block/include/amdblocks/elog.h new file mode 100644 index 0000000..8b1e8fa --- /dev/null +++ b/src/soc/amd/common/block/include/amdblocks/elog.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_AMD_COMMON_BLOCK_ELOG_H +#define SOC_AMD_COMMON_BLOCK_ELOG_H + +#include <amdblocks/acpi.h> + +void elog_pm1_status(uint16_t pm1_sts); + +void elog_gpe_events(const struct acpi_pm_gpe_state *state); + +#endif /* SOC_AMD_COMMON_BLOCK_ELOG_H */ diff --git a/src/soc/amd/picasso/Kconfig b/src/soc/amd/picasso/Kconfig index 88bff50..c43ab6b 100644 --- a/src/soc/amd/picasso/Kconfig +++ b/src/soc/amd/picasso/Kconfig @@ -35,6 +35,7 @@ select SOC_AMD_COMMON_BLOCK_APOB select SOC_AMD_COMMON_BLOCK_BANKED_GPIOS select SOC_AMD_COMMON_BLOCK_DATA_FABRIC + select SOC_AMD_COMMON_BLOCK_ELOG select SOC_AMD_COMMON_BLOCK_GRAPHICS select SOC_AMD_COMMON_BLOCK_HAS_ESPI select SOC_AMD_COMMON_BLOCK_HDA diff --git a/src/soc/amd/stoneyridge/Kconfig b/src/soc/amd/stoneyridge/Kconfig index e799ea0..abafe3d 100644 --- a/src/soc/amd/stoneyridge/Kconfig +++ b/src/soc/amd/stoneyridge/Kconfig @@ -29,6 +29,7 @@ select SOC_AMD_COMMON_BLOCK_AOAC select SOC_AMD_COMMON_BLOCK_BANKED_GPIOS select SOC_AMD_COMMON_BLOCK_CAR + select SOC_AMD_COMMON_BLOCK_ELOG select SOC_AMD_COMMON_BLOCK_HDA select SOC_AMD_COMMON_BLOCK_I2C select SOC_AMD_COMMON_BLOCK_IOMMU