[PATCH v4 3/7] mach-snapdragon: Integrate reboot-mode handling
Aswin Murugan
aswin.murugan at oss.qualcomm.com
Wed Apr 8 14:18:37 CEST 2026
Add reboot-mode detection and automatic fastboot entry to Qualcomm board
initialization. This enables 'reboot bootloader' functionality on
platforms with reboot-mode device tree configuration.
Changes:
- Add qcom_handle_reboot_mode() call in board_late_init()
- Conditionally compile with CONFIG_DM_REBOOT_MODE
- Reorganize header includes
Signed-off-by: Aswin Murugan <aswin.murugan at oss.qualcomm.com>
---
Changes in v4:
1. Added early return `if (!IS_ENABLED(CONFIG_DM_REBOOT_MODE))`
inside `qcom_handle_reboot_mode()`
2. Removed `#ifdef` wrapper around function call
3. Function now defined unconditionally with runtime check
4. Provides user feedback when fastboot command fails
Changes in v3:
1. No change in v3
---
arch/arm/mach-snapdragon/board.c | 59 ++++++++++++++++++++++++++------
1 file changed, 48 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index 5fb3240acc5..c3e97cdbfdf 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -9,6 +9,15 @@
#define LOG_CATEGORY LOGC_BOARD
#define pr_fmt(fmt) "QCOM: " fmt
+#include <command.h>
+#include <env.h>
+#include <fdt_support.h>
+#include <init.h>
+#include <lmb.h>
+#include <malloc.h>
+#include <sort.h>
+#include <time.h>
+#include <usb.h>
#include <asm/armv8/mmu.h>
#include <asm/gpio.h>
#include <asm/io.h>
@@ -16,22 +25,14 @@
#include <asm/system.h>
#include <dm/device.h>
#include <dm/pinctrl.h>
-#include <dm/uclass-internal.h>
#include <dm/read.h>
-#include <power/regulator.h>
-#include <env.h>
-#include <fdt_support.h>
-#include <init.h>
+#include <dm/uclass-internal.h>
#include <linux/arm-smccc.h>
#include <linux/bug.h>
#include <linux/psci.h>
#include <linux/sizes.h>
-#include <lmb.h>
-#include <malloc.h>
-#include <fdt_support.h>
-#include <usb.h>
-#include <sort.h>
-#include <time.h>
+#include <power/regulator.h>
+#include <reboot-mode/reboot-mode.h>
#include "qcom-priv.h"
@@ -506,6 +507,38 @@ void qcom_show_boot_source(void)
env_set("boot_source", name);
}
+/**
+ * qcom_handle_reboot_mode() - Process reboot-mode detection and handle fastboot entry
+ *
+ * This function detects the reboot reason from PMIC registers and automatically
+ * enters fastboot mode if the reboot reason was "bootloader".
+ */
+static void qcom_handle_reboot_mode(void)
+{
+ struct udevice *reboot_dev;
+ const char *reboot_mode;
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_DM_REBOOT_MODE))
+ return;
+
+ ret = uclass_first_device_err(UCLASS_REBOOT_MODE, &reboot_dev);
+ if (ret)
+ return;
+
+ ret = dm_reboot_mode_update(reboot_dev);
+ if (ret)
+ return;
+
+ reboot_mode = env_get("reboot-mode");
+ if (reboot_mode && !strcmp(reboot_mode, "bootloader")) {
+ log_info("Entering fastboot mode due to reboot reason...\n");
+ ret = run_command("run fastboot", 0);
+ if (ret)
+ log_warning("Failed to enter fastboot mode: %d\n", ret);
+ }
+}
+
void __weak qcom_late_init(void)
{
}
@@ -570,6 +603,10 @@ int board_late_init(void)
qcom_late_init();
qcom_show_boot_source();
+
+ /* Handle reboot-mode detection and fastboot entry */
+ qcom_handle_reboot_mode();
+
/* Configure the dfu_string for capsule updates */
qcom_configure_capsule_updates();
--
2.34.1
More information about the U-Boot
mailing list