]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mach-snapdragon: track boot source
authorCaleb Connolly <caleb.connolly@linaro.org>
Fri, 11 Apr 2025 15:03:34 +0000 (17:03 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 24 Jun 2025 13:54:51 +0000 (07:54 -0600)
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>
arch/arm/mach-snapdragon/board.c
arch/arm/mach-snapdragon/qcom-priv.h

index fe29f2ea6e91268a70f83b3babe5471565fb8939..8f7fc19cadc93f6be253aa0ccec7b0098d707bcb 100644 (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();
 
index 4f398e2ba374f27811afd2ccf6e72037d0f9ee7f..b8bf574e8bbb2103d5c23f8f08ae9092e74796fb 100644 (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