From 70f051f236dd483536681c19ff5d1ba1e6c99034 Mon Sep 17 00:00:00 2001 From: Marshall Dawson Date: Tue, 20 Mar 2018 10:27:41 -0600 Subject: amd/stoneyridge: Add PM1 wake status to boot log Print the wake status bits to the console. The format is kept similar to Intel's to maintain compatilibity with inspection utilities. Add relevant wake events from the register to the ELOG. Clear the register before continuing. TEST=Inspect console and ELOG for Grunt BUG=b:75020968 Change-Id: Idc9d12326abb290e4f7a5c60677eb6e057d475b2 Signed-off-by: Marshall Dawson Reviewed-on: https://review.coreboot.org/25300 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Aaron Durbin Reviewed-by: Marc Jones --- src/soc/amd/stoneyridge/southbridge.c | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'src/soc/amd/stoneyridge') diff --git a/src/soc/amd/stoneyridge/southbridge.c b/src/soc/amd/stoneyridge/southbridge.c index 55e39569d0..a2a54c211c 100644 --- a/src/soc/amd/stoneyridge/southbridge.c +++ b/src/soc/amd/stoneyridge/southbridge.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -604,9 +605,79 @@ static void sb_init_acpi_ports(void) PM_ACPI_TIMER_EN_EN); } +static void print_num_status_bits(int num_bits, uint32_t status, + const char *const bit_names[]) +{ + int i; + + if (!status) + return; + + for (i = num_bits - 1; i >= 0; i--) { + if (status & (1 << i)) { + if (bit_names[i]) + printk(BIOS_DEBUG, "%s ", bit_names[i]); + else + printk(BIOS_DEBUG, "BIT%d ", i); + } + } +} + +static uint16_t reset_pm1_status(void) +{ + uint16_t pm1_sts = inw(ACPI_PM_EVT_BLK); + outw(pm1_sts, ACPI_PM_EVT_BLK); + return pm1_sts; +} + +static uint16_t print_pm1_status(uint16_t pm1_sts) +{ + static const char *const pm1_sts_bits[] = { + [0] = "TMROF", + [4] = "BMSTATUS", + [5] = "GBL", + [8] = "PWRBTN", + [10] = "RTC", + [14] = "PCIEXPWAK", + [15] = "WAK", + }; + + if (!pm1_sts) + return 0; + + printk(BIOS_SPEW, "PM1_STS: "); + print_num_status_bits(ARRAY_SIZE(pm1_sts_bits), pm1_sts, pm1_sts_bits); + printk(BIOS_SPEW, "\n"); + + return pm1_sts; +} + +static void sb_log_pm1_status(uint16_t pm1_sts) +{ + if (!IS_ENABLED(CONFIG_ELOG)) + return; + + 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 sb_clear_pm1_status(void) +{ + uint16_t pm1_sts = reset_pm1_status(); + sb_log_pm1_status(pm1_sts); + print_pm1_status(pm1_sts); +} + void southbridge_init(void *chip_info) { sb_init_acpi_ports(); + sb_clear_pm1_status(); } void southbridge_final(void *chip_info) -- cgit v1.2.3