From 08bd2077bf89da9e4d1cd1f42952975a07e3fd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Thu, 21 Jan 2021 16:41:16 +0200 Subject: soc/amd/common: Refactor ACPI wake source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5cb65e131bf2a35c4305ea971812d9799b964c4d Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/49837 Reviewed-by: Felix Held Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/acpi/pm_state.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/soc') diff --git a/src/soc/amd/common/block/acpi/pm_state.c b/src/soc/amd/common/block/acpi/pm_state.c index ed97afbcf5..a0097185dc 100644 --- a/src/soc/amd/common/block/acpi/pm_state.c +++ b/src/soc/amd/common/block/acpi/pm_state.c @@ -29,12 +29,9 @@ static int get_index_bit(uint32_t value, uint16_t limit) return i; } -static void pm_fill_gnvs(const struct acpi_pm_gpe_state *state) +static void pm_fill_gnvs(struct global_nvs *gnvs, const struct acpi_pm_gpe_state *state) { int index; - struct global_nvs *gnvs = acpi_get_gnvs(); - if (gnvs == NULL) - return; index = get_index_bit(state->pm1_sts & state->pm1_en, PM1_LIMIT); if (index < 0) @@ -49,15 +46,17 @@ static void pm_fill_gnvs(const struct acpi_pm_gpe_state *state) gnvs->gpei = index; } -static void set_nvs_sws(void *unused) +static void acpi_save_wake_source(void *unused) { - struct chipset_power_state *state; + const struct chipset_power_state *ps; + struct global_nvs *gnvs = acpi_get_gnvs(); + if (!gnvs) + return; - state = acpi_get_pm_state(); - if (state == NULL) + if (acpi_pm_state_for_wake(&ps) < 0) return; - pm_fill_gnvs(&state->gpe_state); + pm_fill_gnvs(gnvs, &ps->gpe_state); } -BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, set_nvs_sws, NULL); +BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, acpi_save_wake_source, NULL); -- cgit v1.2.3