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 <[email protected]> --- arch/arm/mach-snapdragon/board.c | 56 +++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c index 5fb3240acc5..a596d052711 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,33 @@ 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; + + 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")) { + printf("Entering fastboot mode due to reboot reason...\n"); + run_command("run fastboot", 0); + } +} + void __weak qcom_late_init(void) { } @@ -570,6 +598,12 @@ int board_late_init(void) qcom_late_init(); qcom_show_boot_source(); + + /* Handle reboot-mode detection and fastboot entry */ +#if IS_ENABLED(CONFIG_DM_REBOOT_MODE) + qcom_handle_reboot_mode(); +#endif + /* Configure the dfu_string for capsule updates */ qcom_configure_capsule_updates(); -- 2.34.1

