summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2021-04-12 23:44:14 +0200
committerFelix Held <felix-coreboot@felixheld.de>2021-04-14 00:00:27 +0000
commit0d2c0019e284aea3b1889579782495afb6e52daf (patch)
treeac8a6a574b8f4be3f8264b5d3e2466b27eddc249
parent651d5214d25641052a757e3f6eec75e4a1af9f9c (diff)
downloadcoreboot-0d2c0019e284aea3b1889579782495afb6e52daf.tar.gz
coreboot-0d2c0019e284aea3b1889579782495afb6e52daf.tar.bz2
coreboot-0d2c0019e284aea3b1889579782495afb6e52daf.zip
soc/amd/picasso/romstage: factor out chipset state saving functionality
Since Cezanne needs the exact same code, move it to the common directory and add a Kconfig option to add this functionality to the build. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I04c4295071a3df7afcb4dfd5435b11fb0bf6963f Reviewed-on: https://review.coreboot.org/c/coreboot/+/52272 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Raul Rangel <rrangel@chromium.org>
-rw-r--r--src/soc/amd/common/block/include/amdblocks/pmlib.h3
-rw-r--r--src/soc/amd/common/block/pm/Kconfig6
-rw-r--r--src/soc/amd/common/block/pm/Makefile.inc2
-rw-r--r--src/soc/amd/common/block/pm/chipset_state.c27
-rw-r--r--src/soc/amd/picasso/Kconfig2
-rw-r--r--src/soc/amd/picasso/romstage.c24
6 files changed, 41 insertions, 23 deletions
diff --git a/src/soc/amd/common/block/include/amdblocks/pmlib.h b/src/soc/amd/common/block/include/amdblocks/pmlib.h
index c778664a4976..d9b80a29d1d2 100644
--- a/src/soc/amd/common/block/include/amdblocks/pmlib.h
+++ b/src/soc/amd/common/block/include/amdblocks/pmlib.h
@@ -17,4 +17,7 @@ enum {
*/
void pm_set_power_failure_state(void);
+/* stash ACPI PM/GPE and GPIO wake state before FSP-M call */
+void fill_chipset_state(void);
+
#endif /* SOC_AMD_COMMON_BLOCK_PMLIB_H */
diff --git a/src/soc/amd/common/block/pm/Kconfig b/src/soc/amd/common/block/pm/Kconfig
index c976d017ec8c..e250bf0a2b78 100644
--- a/src/soc/amd/common/block/pm/Kconfig
+++ b/src/soc/amd/common/block/pm/Kconfig
@@ -10,4 +10,10 @@ if SOC_AMD_COMMON_BLOCK_PM
config POWER_STATE_DEFAULT_ON_AFTER_FAILURE
default y
+config SOC_AMD_COMMON_BLOCK_PM_CHIPSET_STATE_SAVE
+ bool
+ help
+ Add common functionality to write CBMEM_ID_POWER_STATE for AMD
+ platforms that use FSP for hardware initialization.
+
endif # SOC_AMD_COMMON_BLOCK_PM
diff --git a/src/soc/amd/common/block/pm/Makefile.inc b/src/soc/amd/common/block/pm/Makefile.inc
index f465e99ec156..f016a9db022e 100644
--- a/src/soc/amd/common/block/pm/Makefile.inc
+++ b/src/soc/amd/common/block/pm/Makefile.inc
@@ -1 +1,3 @@
bootblock-$(CONFIG_SOC_AMD_COMMON_BLOCK_PM) += pmlib.c
+
+romstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_PM_CHIPSET_STATE_SAVE) += chipset_state.c
diff --git a/src/soc/amd/common/block/pm/chipset_state.c b/src/soc/amd/common/block/pm/chipset_state.c
new file mode 100644
index 000000000000..3a4a0ba50607
--- /dev/null
+++ b/src/soc/amd/common/block/pm/chipset_state.c
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <amdblocks/acpi.h>
+#include <amdblocks/gpio_banks.h>
+#include <amdblocks/pmlib.h>
+#include <cbmem.h>
+#include <string.h>
+
+static struct chipset_power_state chipset_state;
+
+void fill_chipset_state(void)
+{
+ acpi_fill_pm_gpe_state(&chipset_state.gpe_state);
+ gpio_fill_wake_state(&chipset_state.gpio_state);
+}
+
+static void add_chipset_state_cbmem(int unused)
+{
+ struct chipset_power_state *state;
+
+ state = cbmem_add(CBMEM_ID_POWER_STATE, sizeof(*state));
+
+ if (state)
+ memcpy(state, &chipset_state, sizeof(*state));
+}
+
+ROMSTAGE_CBMEM_INIT_HOOK(add_chipset_state_cbmem);
diff --git a/src/soc/amd/picasso/Kconfig b/src/soc/amd/picasso/Kconfig
index 765ed600c659..b464539ae67d 100644
--- a/src/soc/amd/picasso/Kconfig
+++ b/src/soc/amd/picasso/Kconfig
@@ -40,6 +40,8 @@ config CPU_SPECIFIC_OPTIONS
select SOC_AMD_COMMON_BLOCK_LPC
select SOC_AMD_COMMON_BLOCK_NONCAR
select SOC_AMD_COMMON_BLOCK_PCI
+ select SOC_AMD_COMMON_BLOCK_PM
+ select SOC_AMD_COMMON_BLOCK_PM_CHIPSET_STATE_SAVE
select SOC_AMD_COMMON_BLOCK_PSP_GEN2
select SOC_AMD_COMMON_BLOCK_SATA
select SOC_AMD_COMMON_BLOCK_SMBUS
diff --git a/src/soc/amd/picasso/romstage.c b/src/soc/amd/picasso/romstage.c
index 3e75ebef0151..7e207687d30a 100644
--- a/src/soc/amd/picasso/romstage.c
+++ b/src/soc/amd/picasso/romstage.c
@@ -1,38 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpi.h>
-#include <amdblocks/acpi.h>
#include <amdblocks/apob_cache.h>
#include <amdblocks/memmap.h>
+#include <amdblocks/pmlib.h>
#include <arch/cpu.h>
-#include <cbmem.h>
#include <commonlib/helpers.h>
#include <console/console.h>
#include <fsp/api.h>
#include <program_loading.h>
-#include <soc/acpi.h>
#include <types.h>
-static struct chipset_power_state chipset_state;
-
-static void fill_chipset_state(void)
-{
- acpi_fill_pm_gpe_state(&chipset_state.gpe_state);
- gpio_fill_wake_state(&chipset_state.gpio_state);
-}
-
-static void add_chipset_state_cbmem(int unused)
-{
- struct chipset_power_state *state;
-
- state = cbmem_add(CBMEM_ID_POWER_STATE, sizeof(*state));
-
- if (state)
- memcpy(state, &chipset_state, sizeof(*state));
-}
-
-ROMSTAGE_CBMEM_INIT_HOOK(add_chipset_state_cbmem);
-
asmlinkage void car_stage_entry(void)
{
post_code(0x40);