summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Connolly <[email protected]>2025-04-11 17:03:34 +0200
committerTom Rini <[email protected]>2025-06-24 07:54:51 -0600
commit35cdb4676e90583c334682380549acaa8fbff2a3 (patch)
tree43958db8deb4f44110b9191f1409d10d59cef1c5
parent32f0291900a584858de1fd8ff9756f6a454a6f0d (diff)
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 <[email protected]> Link: https://lore.kernel.org/r/20250411-b4-qcom-capsule-update-improvements-v2-1-27f6b2fcc4a9@linaro.org Signed-off-by: Casey Connolly <[email protected]>
-rw-r--r--arch/arm/mach-snapdragon/board.c26
-rw-r--r--arch/arm/mach-snapdragon/qcom-priv.h14
2 files changed, 40 insertions, 0 deletions
diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index fe29f2ea6e9..8f7fc19cadc 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -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();
diff --git a/arch/arm/mach-snapdragon/qcom-priv.h b/arch/arm/mach-snapdragon/qcom-priv.h
index 4f398e2ba37..b8bf574e8bb 100644
--- a/arch/arm/mach-snapdragon/qcom-priv.h
+++ b/arch/arm/mach-snapdragon/qcom-priv.h
@@ -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