[PATCH v4 3/7] mach-snapdragon: Integrate reboot-mode handling
Casey Connolly
casey.connolly at linaro.org
Mon Apr 13 14:24:32 CEST 2026
On 2026-04-08 17:48 +0530, Aswin Murugan wrote:
> 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
Please shuffle around headers in a separate path. Also you add power/regulator.h here but it's not
clear why?
Rather than adding board code for this, could we instead teach reboot-mode-uclass to just probe
the FIRST reboot-mode driver automatically and call dm_reboot_mode_update()? Maybe put this
behind a kconfig option?
It's a bit of a mystery to me why this functionality is stuffed into DM when it clearly doesn't
really belong there, but yeah as usual I'd rather fix the core code here than continue the cycle
of board/platform-specific boilerplate that is wholely unnecessary.
With that change b/q/default.env can be updated to check the env var in preboot_cmd rather than
jumping the gun and running commands before we even get through late init.
Again apologies for the late review.
Kind regards,
>
> 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