Currently we locate the coreboot table in arch_cpu_init(). One of the first things that happens in initcall_run_f() initialization is fdtdec_setup() is called which could inspect the DTB for memory information (see mach-snapdragon's board_fdt_blob_setup() code). Introduce an initcall specifically to locate the coreboot table early on in the boot process so that board_fdt_blob_setup() can know that the memory is described in the coreboot tables instead of the DTB that's either embedded in the ELF file or provided by the earlier stage bootloader. This will also help in the future when we want to pick the DTB from a FIT image based on the board and revision ID bits in the coreboot tables.
Signed-off-by: Stephen Boyd <swb...@chromium.org> --- arch/x86/cpu/coreboot/coreboot.c | 8 ++++---- common/board_f.c | 4 ++++ include/cb_sysinfo.h | 7 +++++++ lib/coreboot/cb_sysinfo.c | 11 +++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c index cd9ad22b3db3..e1dbce4f0b29 100644 --- a/arch/x86/cpu/coreboot/coreboot.c +++ b/arch/x86/cpu/coreboot/coreboot.c @@ -27,11 +27,11 @@ int arch_cpu_init(void) if (ret) return ret; - ret = get_coreboot_info(&lib_sysinfo); - if (ret != 0) { - printf("Failed to parse coreboot tables.\n"); - return ret; + if (!gd->arch.coreboot_table) + printf("Failed to locate coreboot tables.\n"); + return -ENOENT; } + gd_set_acpi_start(map_to_sysmem(lib_sysinfo.rsdp)); gd_set_smbios_start(lib_sysinfo.smbios_start); diff --git a/common/board_f.c b/common/board_f.c index bff465d9cb2f..7e314b20c60e 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -12,6 +12,7 @@ #include <config.h> #include <bloblist.h> #include <bootstage.h> +#include <cb_sysinfo.h> #include <clock_legacy.h> #include <console.h> #include <cpu.h> @@ -896,6 +897,9 @@ static void initcall_run_f(void) * For simplicity it should remain an ordered list of function calls. */ INITCALL(setup_mon_len); +#if CONFIG_IS_ENABLED(SYS_COREBOOT) + INITCALL(coreboot_early_init); +#endif #if CONFIG_IS_ENABLED(OF_CONTROL) INITCALL(fdtdec_setup); #endif diff --git a/include/cb_sysinfo.h b/include/cb_sysinfo.h index 62a483e10cef..40d8030dbb8b 100644 --- a/include/cb_sysinfo.h +++ b/include/cb_sysinfo.h @@ -239,6 +239,13 @@ extern struct sysinfo_t lib_sysinfo; */ int get_coreboot_info(struct sysinfo_t *info); +/** + * coreboot_early_init() - locate the coreboot tables during early init + * + * Return: 0 + */ +int coreboot_early_init(void); + /** * cb_get_sysinfo() - get a pointer to the parsed coreboot sysinfo * diff --git a/lib/coreboot/cb_sysinfo.c b/lib/coreboot/cb_sysinfo.c index f8f2002d46f0..1ea4ec4a0487 100644 --- a/lib/coreboot/cb_sysinfo.c +++ b/lib/coreboot/cb_sysinfo.c @@ -465,6 +465,17 @@ int get_coreboot_info(struct sysinfo_t *info) return 0; } +int coreboot_early_init(void) +{ + int ret; + + ret = get_coreboot_info(&lib_sysinfo); + if (ret != 0) + debug("Failed to parse coreboot tables.\n"); + + return 0; +} + const struct sysinfo_t *cb_get_sysinfo(void) { if (!ll_boot_init()) -- Sent by a computer, using git, on the internet