ACPI: Add helpers for CBMEM_ID_POWER_STATE
Create uniform logging for the (unlikely) case of a CBMEM
entry disappearing.
Change-Id: I7c5414a03d869423c8ae5192a990fde5f9582f2d
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49817
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
diff --git a/src/soc/intel/alderlake/pmutil.c b/src/soc/intel/alderlake/pmutil.c
index 79088dd..43d5084 100644
--- a/src/soc/intel/alderlake/pmutil.c
+++ b/src/soc/intel/alderlake/pmutil.c
@@ -13,8 +13,8 @@
#define __SIMPLE_DEVICE__
+#include <acpi/acpi_pm.h>
#include <device/mmio.h>
-#include <cbmem.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
@@ -187,12 +187,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon_b);
}
diff --git a/src/soc/intel/apollolake/elog.c b/src/soc/intel/apollolake/elog.c
index d17d407..47b68f1 100644
--- a/src/soc/intel/apollolake/elog.c
+++ b/src/soc/intel/apollolake/elog.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <device/pci_type.h>
#include <elog.h>
@@ -88,14 +88,10 @@
void pch_log_state(void)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (ps == NULL) {
- printk(BIOS_ERR,
- "Not logging power state information. "
- "Power state not found in cbmem.\n");
+ if (acpi_pm_state_for_elog(&ps) < 0)
return;
- }
/* Power and Reset */
pch_log_power_and_resets(ps);
diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c
index 6e96b57..1d4a558 100644
--- a/src/soc/intel/apollolake/pmutil.c
+++ b/src/soc/intel/apollolake/pmutil.c
@@ -3,9 +3,9 @@
#define __SIMPLE_DEVICE__
#include <acpi/acpi.h>
+#include <acpi/acpi_pm.h>
#include <arch/io.h>
#include <device/mmio.h>
-#include <cbmem.h>
#include <console/console.h>
#include <cpu/x86/msr.h>
#include <device/device.h>
@@ -185,12 +185,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon1);
}
diff --git a/src/soc/intel/baytrail/elog.c b/src/soc/intel/baytrail/elog.c
index 7e92e90..b299c37 100644
--- a/src/soc/intel/baytrail/elog.c
+++ b/src/soc/intel/baytrail/elog.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpi.h>
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
@@ -76,13 +76,10 @@
void southcluster_log_state(void)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (ps == NULL) {
- printk(BIOS_DEBUG,
- "Not logging power state information. Power state not found in cbmem.\n");
+ if (acpi_pm_state_for_elog(&ps) < 0)
return;
- }
log_power_and_resets(ps);
log_wake_events(ps);
diff --git a/src/soc/intel/baytrail/pmutil.c b/src/soc/intel/baytrail/pmutil.c
index cc1dd42..7ab61ac 100644
--- a/src/soc/intel/baytrail/pmutil.c
+++ b/src/soc/intel/baytrail/pmutil.c
@@ -2,13 +2,13 @@
#include <stdint.h>
#include <acpi/acpi.h>
+#include <acpi/acpi_pm.h>
#include <arch/io.h>
#include <bootmode.h>
#include <device/device.h>
#include <device/mmio.h>
#include <device/pci.h>
#include <device/pci_ops.h>
-#include <cbmem.h>
#include <console/console.h>
#include <soc/iomap.h>
@@ -349,7 +349,7 @@
{
uint32_t gen_pmcon1;
int rtc_fail;
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ struct chipset_power_state *ps = acpi_get_pm_state();
if (ps != NULL)
gen_pmcon1 = ps->gen_pmcon1;
diff --git a/src/soc/intel/baytrail/ramstage.c b/src/soc/intel/baytrail/ramstage.c
index 1e7cc08..0c955e3 100644
--- a/src/soc/intel/baytrail/ramstage.c
+++ b/src/soc/intel/baytrail/ramstage.c
@@ -3,7 +3,7 @@
#include <arch/cpu.h>
#include <acpi/acpi.h>
#include <acpi/acpi_gnvs.h>
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <cpu/intel/microcode.h>
#include <cpu/x86/cr.h>
@@ -119,7 +119,7 @@
/* Save bit index for first enabled event in PM1_STS for \_SB._SWS */
static void save_acpi_wake_source(void)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ struct chipset_power_state *ps = acpi_get_pm_state();
struct global_nvs *gnvs = acpi_get_gnvs();
uint16_t pm1;
diff --git a/src/soc/intel/braswell/elog.c b/src/soc/intel/braswell/elog.c
index 7e92e90..b299c37 100644
--- a/src/soc/intel/braswell/elog.c
+++ b/src/soc/intel/braswell/elog.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpi.h>
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
@@ -76,13 +76,10 @@
void southcluster_log_state(void)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (ps == NULL) {
- printk(BIOS_DEBUG,
- "Not logging power state information. Power state not found in cbmem.\n");
+ if (acpi_pm_state_for_elog(&ps) < 0)
return;
- }
log_power_and_resets(ps);
log_wake_events(ps);
diff --git a/src/soc/intel/braswell/ramstage.c b/src/soc/intel/braswell/ramstage.c
index de90cb7..f49c760 100644
--- a/src/soc/intel/braswell/ramstage.c
+++ b/src/soc/intel/braswell/ramstage.c
@@ -2,7 +2,7 @@
#include <arch/cpu.h>
#include <acpi/acpi.h>
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <cpu/intel/microcode.h>
#include <cpu/x86/cr.h>
@@ -122,7 +122,7 @@
/* Save wake source information for calculating ACPI _SWS values */
int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ struct chipset_power_state *ps = acpi_get_pm_state();
static uint32_t gpe0_sts;
if (!ps)
diff --git a/src/soc/intel/broadwell/pch/elog.c b/src/soc/intel/broadwell/pch/elog.c
index 1d4d773..3f62556 100644
--- a/src/soc/intel/broadwell/pch/elog.c
+++ b/src/soc/intel/broadwell/pch/elog.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
+#include <acpi/acpi_pm.h>
#include <bootstate.h>
-#include <cbmem.h>
#include <console/console.h>
#include <stdint.h>
#include <elog.h>
@@ -106,13 +106,10 @@
static void pch_log_state(void *unused)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (ps == NULL) {
- printk(BIOS_ERR, "Not logging power state information. "
- "Power state not found in cbmem.\n");
+ if (acpi_pm_state_for_elog(&ps) < 0)
return;
- }
/* Power and Reset */
pch_log_power_and_resets(ps);
diff --git a/src/soc/intel/broadwell/ramstage.c b/src/soc/intel/broadwell/ramstage.c
index 418e469..93bc01d 100644
--- a/src/soc/intel/broadwell/ramstage.c
+++ b/src/soc/intel/broadwell/ramstage.c
@@ -2,7 +2,7 @@
#include <acpi/acpi.h>
#include <acpi/acpi_gnvs.h>
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <device/device.h>
#include <string.h>
@@ -14,7 +14,7 @@
/* Save bit index for PM1_STS and GPE_STS for ACPI _SWS */
static void save_acpi_wake_source(void)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ struct chipset_power_state *ps = acpi_get_pm_state();
struct global_nvs *gnvs = acpi_get_gnvs();
uint16_t pm1;
int gpe_reg;
diff --git a/src/soc/intel/cannonlake/pmutil.c b/src/soc/intel/cannonlake/pmutil.c
index 785283c..b2dbfbe 100644
--- a/src/soc/intel/cannonlake/pmutil.c
+++ b/src/soc/intel/cannonlake/pmutil.c
@@ -7,8 +7,8 @@
#define __SIMPLE_DEVICE__
+#include <acpi/acpi_pm.h>
#include <device/mmio.h>
-#include <cbmem.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
@@ -180,12 +180,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon_b);
}
diff --git a/src/soc/intel/common/block/acpi/acpi.c b/src/soc/intel/common/block/acpi/acpi.c
index 65e5f44..cbc6a58 100644
--- a/src/soc/intel/common/block/acpi/acpi.c
+++ b/src/soc/intel/common/block/acpi/acpi.c
@@ -1,12 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <acpi/acpi_gnvs.h>
+#include <acpi/acpi_pm.h>
#include <acpi/acpigen.h>
#include <arch/cpu.h>
#include <arch/ioapic.h>
#include <arch/smp/mpspec.h>
#include <bootstate.h>
-#include <cbmem.h>
#include <cf9_reset.h>
#include <console/console.h>
#include <cpu/intel/turbo.h>
@@ -213,7 +213,7 @@
uint32_t pm1_en;
int i;
- ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ ps = acpi_get_pm_state();
if (ps == NULL)
return -1;
diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c
index 09af749..3b7aa0a 100644
--- a/src/soc/intel/common/block/pmc/pmclib.c
+++ b/src/soc/intel/common/block/pmc/pmclib.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
+#include <acpi/acpi_pm.h>
#include <arch/io.h>
#include <bootmode.h>
#include <device/mmio.h>
@@ -56,7 +57,7 @@
struct chipset_power_state *ptr = NULL;
if (cbmem_possibly_online())
- ptr = cbmem_find(CBMEM_ID_POWER_STATE);
+ ptr = acpi_get_pm_state();
/* cbmem is online but ptr is not populated yet */
if (ptr == NULL && !(ENV_RAMSTAGE || ENV_POSTCAR))
diff --git a/src/soc/intel/elkhartlake/pmutil.c b/src/soc/intel/elkhartlake/pmutil.c
index 4d5c04d..b969ba5 100644
--- a/src/soc/intel/elkhartlake/pmutil.c
+++ b/src/soc/intel/elkhartlake/pmutil.c
@@ -7,7 +7,7 @@
#define __SIMPLE_DEVICE__
-#include <cbmem.h>
+#include <acpi/acpi_pm.h>
#include <console/console.h>
#include <device/device.h>
#include <device/mmio.h>
@@ -180,12 +180,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon_b);
}
diff --git a/src/soc/intel/icelake/pmutil.c b/src/soc/intel/icelake/pmutil.c
index 66cc73e..263bfa2 100644
--- a/src/soc/intel/icelake/pmutil.c
+++ b/src/soc/intel/icelake/pmutil.c
@@ -7,8 +7,8 @@
#define __SIMPLE_DEVICE__
+#include <acpi/acpi_pm.h>
#include <device/mmio.h>
-#include <cbmem.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
@@ -180,12 +180,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon_b);
}
diff --git a/src/soc/intel/jasperlake/pmutil.c b/src/soc/intel/jasperlake/pmutil.c
index ebe46b1..7a42d77 100644
--- a/src/soc/intel/jasperlake/pmutil.c
+++ b/src/soc/intel/jasperlake/pmutil.c
@@ -7,8 +7,8 @@
#define __SIMPLE_DEVICE__
+#include <acpi/acpi_pm.h>
#include <device/mmio.h>
-#include <cbmem.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
@@ -180,12 +180,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon_b);
}
diff --git a/src/soc/intel/skylake/acpi.c b/src/soc/intel/skylake/acpi.c
index 99a52d1..3545a94 100644
--- a/src/soc/intel/skylake/acpi.c
+++ b/src/soc/intel/skylake/acpi.c
@@ -2,11 +2,11 @@
#include <acpi/acpi.h>
#include <acpi/acpi_gnvs.h>
+#include <acpi/acpi_pm.h>
#include <acpi/acpigen.h>
#include <arch/cpu.h>
#include <arch/ioapic.h>
#include <arch/smp/mpspec.h>
-#include <cbmem.h>
#include <console/console.h>
#include <cpu/x86/smm.h>
#include <cpu/x86/msr.h>
@@ -530,7 +530,7 @@
int i;
const int last_index = GPE0_REG_MAX - 1;
- ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ ps = acpi_get_pm_state();
if (ps == NULL)
return -1;
diff --git a/src/soc/intel/skylake/elog.c b/src/soc/intel/skylake/elog.c
index c9b719f..d325a93 100644
--- a/src/soc/intel/skylake/elog.c
+++ b/src/soc/intel/skylake/elog.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
+#include <acpi/acpi_pm.h>
#include <bootstate.h>
-#include <cbmem.h>
#include <commonlib/helpers.h>
#include <console/console.h>
#include <device/mmio.h>
@@ -231,13 +231,10 @@
static void pch_log_state(void *unused)
{
- struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (ps == NULL) {
- printk(BIOS_ERR,
- "Not logging power state information. Power state not found in cbmem.\n");
+ if (acpi_pm_state_for_elog(&ps) < 0)
return;
- }
/* Power and Reset */
pch_log_power_and_resets(ps);
diff --git a/src/soc/intel/tigerlake/pmutil.c b/src/soc/intel/tigerlake/pmutil.c
index f2ff483..39fc36b 100644
--- a/src/soc/intel/tigerlake/pmutil.c
+++ b/src/soc/intel/tigerlake/pmutil.c
@@ -13,8 +13,8 @@
#define __SIMPLE_DEVICE__
+#include <acpi/acpi_pm.h>
#include <device/mmio.h>
-#include <cbmem.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
@@ -186,12 +186,10 @@
int soc_get_rtc_failed(void)
{
- const struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
+ const struct chipset_power_state *ps;
- if (!ps) {
- printk(BIOS_ERR, "Could not find power state in cbmem, RTC init aborted\n");
+ if (acpi_pm_state_for_rtc(&ps) < 0)
return 1;
- }
return rtc_failed(ps->gen_pmcon_b);
}