From de10d5bf4dbf200c40ae218f5b2327e8e06c6749 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 14 Oct 2022 22:59:40 +0200 Subject: soc/amd: factor out common noncar bootblock This code is identical for all non-CAR AMD SoCs, so factor it out to soc/amd/common/block/cpu/noncar/bootblock.c to avoid code duplication. Also integrate the bootblock.c improvement to include cpu/cpu.h which provides cpuid_eax from commit 68eb439d8091 ("soc/amd/picasso: Clean up includes"). Signed-off-by: Felix Held Change-Id: I42e4aa85efd6312a3ab37f0323a35f6dd7acd8e6 Reviewed-on: https://review.coreboot.org/c/coreboot/+/68431 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Fred Reitberger --- src/soc/amd/cezanne/Makefile.inc | 1 - src/soc/amd/cezanne/bootblock.c | 50 ----------------------- src/soc/amd/common/block/cpu/noncar/Makefile.inc | 1 + src/soc/amd/common/block/cpu/noncar/bootblock.c | 51 +++++++++++++++++++++++ src/soc/amd/mendocino/Makefile.inc | 1 - src/soc/amd/mendocino/bootblock.c | 52 ------------------------ src/soc/amd/morgana/Makefile.inc | 1 - src/soc/amd/morgana/bootblock.c | 52 ------------------------ src/soc/amd/picasso/Makefile.inc | 1 - src/soc/amd/picasso/bootblock.c | 51 ----------------------- 10 files changed, 52 insertions(+), 209 deletions(-) delete mode 100644 src/soc/amd/cezanne/bootblock.c create mode 100644 src/soc/amd/common/block/cpu/noncar/bootblock.c delete mode 100644 src/soc/amd/mendocino/bootblock.c delete mode 100644 src/soc/amd/morgana/bootblock.c delete mode 100644 src/soc/amd/picasso/bootblock.c (limited to 'src/soc') diff --git a/src/soc/amd/cezanne/Makefile.inc b/src/soc/amd/cezanne/Makefile.inc index dc97c1ff4d..508ea1da99 100644 --- a/src/soc/amd/cezanne/Makefile.inc +++ b/src/soc/amd/cezanne/Makefile.inc @@ -8,7 +8,6 @@ subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage all-y += config.c all-y += aoac.c -bootblock-y += bootblock.c bootblock-y += early_fch.c bootblock-y += espi_util.c bootblock-y += gpio.c diff --git a/src/soc/amd/cezanne/bootblock.c b/src/soc/amd/cezanne/bootblock.c deleted file mode 100644 index c42ac0ac7c..0000000000 --- a/src/soc/amd/cezanne/bootblock.c +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include -#include -#include -#include -#include -#include - -asmlinkage void bootblock_c_entry(uint64_t base_timestamp) -{ - early_cache_setup(); - write_resume_eip(); - enable_pci_mmconf(); - - /* - * base_timestamp is raw tsc value. We need to divide by tsc_freq_mhz - * to get micro-seconds granularity. - */ - base_timestamp /= tsc_freq_mhz(); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) - boot_with_psp_timestamp(base_timestamp); - - /* - * if VBOOT_STARTS_BEFORE_BOOTBLOCK is not selected or - * previous step did nothing, proceed with normal bootblock main. - */ - bootblock_main_with_basetime(base_timestamp); -} - -void bootblock_soc_early_init(void) -{ - fch_pre_init(); -} - -void bootblock_soc_init(void) -{ - u32 val = cpuid_eax(1); - printk(BIOS_DEBUG, "Family_Model: %08x\n", val); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { - verify_psp_transfer_buf(); - show_psp_transfer_info(); - } - - fch_early_init(); -} diff --git a/src/soc/amd/common/block/cpu/noncar/Makefile.inc b/src/soc/amd/common/block/cpu/noncar/Makefile.inc index 2ffe52b361..2de2695b55 100644 --- a/src/soc/amd/common/block/cpu/noncar/Makefile.inc +++ b/src/soc/amd/common/block/cpu/noncar/Makefile.inc @@ -1,5 +1,6 @@ ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_NONCAR),y) +bootblock-y += bootblock.c bootblock-y += early_cache.c bootblock-y += pre_c.S bootblock-y += write_resume_eip.c diff --git a/src/soc/amd/common/block/cpu/noncar/bootblock.c b/src/soc/amd/common/block/cpu/noncar/bootblock.c new file mode 100644 index 0000000000..13bac18714 --- /dev/null +++ b/src/soc/amd/common/block/cpu/noncar/bootblock.c @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +asmlinkage void bootblock_c_entry(uint64_t base_timestamp) +{ + early_cache_setup(); + write_resume_eip(); + enable_pci_mmconf(); + + /* + * base_timestamp is raw tsc value. We need to divide by tsc_freq_mhz + * to get micro-seconds granularity. + */ + base_timestamp /= tsc_freq_mhz(); + + if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) + boot_with_psp_timestamp(base_timestamp); + + /* + * if VBOOT_STARTS_BEFORE_BOOTBLOCK is not selected or + * previous step did nothing, proceed with normal bootblock main. + */ + bootblock_main_with_basetime(base_timestamp); +} + +void bootblock_soc_early_init(void) +{ + fch_pre_init(); +} + +void bootblock_soc_init(void) +{ + u32 val = cpuid_eax(1); + printk(BIOS_DEBUG, "Family_Model: %08x\n", val); + + if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { + verify_psp_transfer_buf(); + show_psp_transfer_info(); + } + + fch_early_init(); +} diff --git a/src/soc/amd/mendocino/Makefile.inc b/src/soc/amd/mendocino/Makefile.inc index 9549426694..8f3425d83f 100644 --- a/src/soc/amd/mendocino/Makefile.inc +++ b/src/soc/amd/mendocino/Makefile.inc @@ -10,7 +10,6 @@ subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage all-y += config.c all-y += aoac.c -bootblock-y += bootblock.c bootblock-y += early_fch.c bootblock-y += espi_util.c bootblock-y += gpio.c diff --git a/src/soc/amd/mendocino/bootblock.c b/src/soc/amd/mendocino/bootblock.c deleted file mode 100644 index bbf56d360a..0000000000 --- a/src/soc/amd/mendocino/bootblock.c +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -/* TODO: Check if this is still correct */ - -#include -#include -#include -#include -#include -#include -#include -#include - -asmlinkage void bootblock_c_entry(uint64_t base_timestamp) -{ - early_cache_setup(); - write_resume_eip(); - enable_pci_mmconf(); - - /* - * base_timestamp is raw tsc value. We need to divide by tsc_freq_mhz - * to get micro-seconds granularity. - */ - base_timestamp /= tsc_freq_mhz(); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) - boot_with_psp_timestamp(base_timestamp); - - /* - * if VBOOT_STARTS_BEFORE_BOOTBLOCK is not selected or - * previous step did nothing, proceed with normal bootblock main. - */ - bootblock_main_with_basetime(base_timestamp); -} - -void bootblock_soc_early_init(void) -{ - fch_pre_init(); -} - -void bootblock_soc_init(void) -{ - u32 val = cpuid_eax(1); - printk(BIOS_DEBUG, "Family_Model: %08x\n", val); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { - verify_psp_transfer_buf(); - show_psp_transfer_info(); - } - - fch_early_init(); -} diff --git a/src/soc/amd/morgana/Makefile.inc b/src/soc/amd/morgana/Makefile.inc index 6c80d237ba..f4243bce27 100644 --- a/src/soc/amd/morgana/Makefile.inc +++ b/src/soc/amd/morgana/Makefile.inc @@ -11,7 +11,6 @@ subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage all-y += config.c all-y += aoac.c -bootblock-y += bootblock.c bootblock-y += early_fch.c bootblock-y += espi_util.c bootblock-y += gpio.c diff --git a/src/soc/amd/morgana/bootblock.c b/src/soc/amd/morgana/bootblock.c deleted file mode 100644 index 57fac992f6..0000000000 --- a/src/soc/amd/morgana/bootblock.c +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -/* TODO: Update for Morgana */ - -#include -#include -#include -#include -#include -#include -#include -#include - -asmlinkage void bootblock_c_entry(uint64_t base_timestamp) -{ - early_cache_setup(); - write_resume_eip(); - enable_pci_mmconf(); - - /* - * base_timestamp is raw tsc value. We need to divide by tsc_freq_mhz - * to get micro-seconds granularity. - */ - base_timestamp /= tsc_freq_mhz(); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) - boot_with_psp_timestamp(base_timestamp); - - /* - * if VBOOT_STARTS_BEFORE_BOOTBLOCK is not selected or - * previous step did nothing, proceed with normal bootblock main. - */ - bootblock_main_with_basetime(base_timestamp); -} - -void bootblock_soc_early_init(void) -{ - fch_pre_init(); -} - -void bootblock_soc_init(void) -{ - u32 val = cpuid_eax(1); - printk(BIOS_DEBUG, "Family_Model: %08x\n", val); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { - verify_psp_transfer_buf(); - show_psp_transfer_info(); - } - - fch_early_init(); -} diff --git a/src/soc/amd/picasso/Makefile.inc b/src/soc/amd/picasso/Makefile.inc index 3e43a3d82b..cff47af8e2 100644 --- a/src/soc/amd/picasso/Makefile.inc +++ b/src/soc/amd/picasso/Makefile.inc @@ -9,7 +9,6 @@ subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += ../common/psp_verstage all-y += config.c all-y += aoac.c -bootblock-y += bootblock.c bootblock-y += early_fch.c bootblock-y += gpio.c bootblock-y += i2c.c diff --git a/src/soc/amd/picasso/bootblock.c b/src/soc/amd/picasso/bootblock.c deleted file mode 100644 index 9e88ceaec4..0000000000 --- a/src/soc/amd/picasso/bootblock.c +++ /dev/null @@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -asmlinkage void bootblock_c_entry(uint64_t base_timestamp) -{ - early_cache_setup(); - write_resume_eip(); - enable_pci_mmconf(); - - /* - * base_timestamp is raw tsc value. We need to divide by tsc_freq_mhz - * when we use micro-seconds granularity for Zork - */ - base_timestamp /= tsc_freq_mhz(); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) - boot_with_psp_timestamp(base_timestamp); - - /* - * if VBOOT_STARTS_BEFORE_BOOTBLOCK is not selected or - * previous step did nothing, proceed with normal bootblock main. - */ - bootblock_main_with_basetime(base_timestamp); -} - -void bootblock_soc_early_init(void) -{ - fch_pre_init(); -} - -void bootblock_soc_init(void) -{ - u32 val = cpuid_eax(1); - printk(BIOS_DEBUG, "Family_Model: %08x\n", val); - - if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { - verify_psp_transfer_buf(); - show_psp_transfer_info(); - } - - fch_early_init(); -} -- cgit v1.2.3