mach-snapdragon: track boot source

Keep track of whether we were loaded via ABL or if U-Boot is running as
a first-stage bootloader.

For now we set this based on if we have a valid external FDT or not,
since it isn't possible to chainload U-Boot from ABL without there being
an external FDT.

This will be used to inform the capsule update logic which partition
U-Boot is flashed to.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Link: https://lore.kernel.org/r/20250411-b4-qcom-capsule-update-improvements-v2-1-27f6b2fcc4a9@linaro.org
Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
This commit is contained in:
Caleb Connolly
2025-04-11 17:03:34 +02:00
committed by Tom Rini
parent 32f0291900
commit 35cdb4676e
2 changed files with 40 additions and 0 deletions

View File

@@ -37,6 +37,8 @@
DECLARE_GLOBAL_DATA_PTR;
enum qcom_boot_source qcom_boot_source __section(".data") = 0;
static struct mm_region rbx_mem_map[CONFIG_NR_DRAM_BANKS + 2] = { { 0 } };
struct mm_region *mem_map = rbx_mem_map;
@@ -238,6 +240,12 @@ int board_fdt_blob_setup(void **fdtp)
if (ret < 0)
panic("No valid memory ranges found!\n");
/* If we have an external FDT, it can only have come from the Android bootloader. */
if (external_valid)
qcom_boot_source = QCOM_BOOT_SOURCE_ANDROID;
else
qcom_boot_source = QCOM_BOOT_SOURCE_XBL;
debug("ram_base = %#011lx, ram_size = %#011llx\n",
gd->ram_base, gd->ram_size);
@@ -481,6 +489,23 @@ static void configure_env(void)
qcom_set_serialno();
}
void qcom_show_boot_source(void)
{
const char *name = "UNKNOWN";
switch (qcom_boot_source) {
case QCOM_BOOT_SOURCE_ANDROID:
name = "ABL";
break;
case QCOM_BOOT_SOURCE_XBL:
name = "XBL";
break;
}
log_info("U-Boot loaded from %s\n", name);
env_set("boot_source", name);
}
void __weak qcom_late_init(void)
{
}
@@ -528,6 +553,7 @@ int board_late_init(void)
configure_env();
qcom_late_init();
qcom_show_boot_source();
/* Configure the dfu_string for capsule updates */
qcom_configure_capsule_updates();

View File

@@ -3,6 +3,20 @@
#ifndef __QCOM_PRIV_H__
#define __QCOM_PRIV_H__
/**
* enum qcom_boot_source - Track where we got loaded from.
* Used for capsule update logic.
*
* @QCOM_BOOT_SOURCE_ANDROID: chainloaded (typically from ABL)
* @QCOM_BOOT_SOURCE_XBL: flashed to the XBL or UEFI partition
*/
enum qcom_boot_source {
QCOM_BOOT_SOURCE_ANDROID = 1,
QCOM_BOOT_SOURCE_XBL,
};
extern enum qcom_boot_source qcom_boot_source;
#if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
void qcom_configure_capsule_updates(void);
#else