aboutsummaryrefslogtreecommitdiff
path: root/src/soc/amd/common
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2021-01-21 16:34:43 +0200
committerFelix Held <felix-coreboot@felixheld.de>2021-01-25 17:01:12 +0000
commitb0db813523ab6de2fa0894d1e2cb979f22a01871 (patch)
tree47ff3bb8ae27616cfca97198e2f92f01fefec8a9 /src/soc/amd/common
parentb218c20c0015da77377bbc1efc0fc2efbe204360 (diff)
soc/amd: Refactor ACPI power state and ELOG
Change-Id: Ib7423c8d80355871393c377ebaffdfe2846d8852 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/49836 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/soc/amd/common')
-rw-r--r--src/soc/amd/common/block/acpi/acpi.c10
-rw-r--r--src/soc/amd/common/block/gpio_banks/gpio.c10
-rw-r--r--src/soc/amd/common/block/include/amdblocks/acpi.h8
-rw-r--r--src/soc/amd/common/block/include/amdblocks/gpio_banks.h2
4 files changed, 26 insertions, 4 deletions
diff --git a/src/soc/amd/common/block/acpi/acpi.c b/src/soc/amd/common/block/acpi/acpi.c
index 43cc49ccb0..16da743efb 100644
--- a/src/soc/amd/common/block/acpi/acpi.c
+++ b/src/soc/amd/common/block/acpi/acpi.c
@@ -4,6 +4,7 @@
#include <amdblocks/acpi.h>
#include <acpi/acpi.h>
#include <acpi/acpi_gnvs.h>
+#include <acpi/acpi_pm.h>
#include <bootmode.h>
#include <console/console.h>
#include <elog.h>
@@ -106,8 +107,15 @@ void acpi_fill_pm_gpe_state(struct acpi_pm_gpe_state *state)
state->aligning_field = 0;
}
-void acpi_pm_gpe_add_events_print_events(const struct acpi_pm_gpe_state *state)
+void acpi_pm_gpe_add_events_print_events(void)
{
+ const struct chipset_power_state *ps;
+ const struct acpi_pm_gpe_state *state;
+
+ if (acpi_pm_state_for_elog(&ps) < 0)
+ return;
+
+ state = &ps->gpe_state;
log_pm1_status(state->pm1_sts);
print_pm1_status(state->pm1_sts);
log_gpe_events(state);
diff --git a/src/soc/amd/common/block/gpio_banks/gpio.c b/src/soc/amd/common/block/gpio_banks/gpio.c
index bdc243fa2c..5b0111b28f 100644
--- a/src/soc/amd/common/block/gpio_banks/gpio.c
+++ b/src/soc/amd/common/block/gpio_banks/gpio.c
@@ -1,10 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only */
+#include <acpi/acpi_pm.h>
#include <device/mmio.h>
#include <device/device.h>
#include <console/console.h>
#include <elog.h>
#include <gpio.h>
+#include <amdblocks/acpi.h>
#include <amdblocks/acpimmio.h>
#include <amdblocks/gpio_banks.h>
#include <amdblocks/smi.h>
@@ -363,11 +365,17 @@ void gpio_fill_wake_state(struct gpio_wake_state *state)
check_gpios(state->wake_stat[1], 14, 128, state);
}
-void gpio_add_events(const struct gpio_wake_state *state)
+void gpio_add_events(void)
{
+ const struct chipset_power_state *ps;
+ const struct gpio_wake_state *state;
int i;
int end;
+ if (acpi_pm_state_for_elog(&ps) < 0)
+ return;
+ state = &ps->gpio_state;
+
end = MIN(state->num_valid_wake_gpios, ARRAY_SIZE(state->wake_gpios));
for (i = 0; i < end; i++)
elog_add_event_wake(ELOG_WAKE_SOURCE_GPIO, state->wake_gpios[i]);
diff --git a/src/soc/amd/common/block/include/amdblocks/acpi.h b/src/soc/amd/common/block/include/amdblocks/acpi.h
index 74b8408488..aa40706f96 100644
--- a/src/soc/amd/common/block/include/amdblocks/acpi.h
+++ b/src/soc/amd/common/block/include/amdblocks/acpi.h
@@ -4,6 +4,7 @@
#define AMD_BLOCK_ACPI_H
#include <types.h>
+#include <amdblocks/gpio_banks.h>
/* ACPI MMIO registers 0xfed80800 */
#define MMIO_ACPI_PM1_STS 0x00
@@ -29,7 +30,7 @@ struct acpi_pm_gpe_state {
/* Fill object with the ACPI PM and GPE state. */
void acpi_fill_pm_gpe_state(struct acpi_pm_gpe_state *state);
/* Save events to eventlog log and also print information on console. */
-void acpi_pm_gpe_add_events_print_events(const struct acpi_pm_gpe_state *state);
+void acpi_pm_gpe_add_events_print_events(void);
/* Clear PM and GPE status registers. */
void acpi_clear_pm_gpe_status(void);
@@ -41,4 +42,9 @@ void set_pm1cnt_s5(void);
void acpi_enable_sci(void);
void acpi_disable_sci(void);
+struct chipset_power_state {
+ struct acpi_pm_gpe_state gpe_state;
+ struct gpio_wake_state gpio_state;
+};
+
#endif /* AMD_BLOCK_ACPI_H */
diff --git a/src/soc/amd/common/block/include/amdblocks/gpio_banks.h b/src/soc/amd/common/block/include/amdblocks/gpio_banks.h
index 6524d05a54..2d3c769438 100644
--- a/src/soc/amd/common/block/include/amdblocks/gpio_banks.h
+++ b/src/soc/amd/common/block/include/amdblocks/gpio_banks.h
@@ -30,7 +30,7 @@ struct gpio_wake_state {
/* Fill gpio_wake_state object for future event reporting. */
void gpio_fill_wake_state(struct gpio_wake_state *state);
/* Add gpio events to the eventlog. */
-void gpio_add_events(const struct gpio_wake_state *state);
+void gpio_add_events(void);
enum {
GEVENT_0,