fastboot: Extend fastboot_set_reboot_flag with reboot reason
authorRoman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Tue, 28 Jul 2020 20:35:32 +0000 (23:35 +0300)
committerMarek Vasut <marex@denx.de>
Tue, 1 Sep 2020 12:47:43 +0000 (14:47 +0200)
Extend fastboot_set_reboot_flag arguments with reboot reason so that
it could handle different reboot cases in future.

Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
arch/arm/mach-meson/board-common.c
arch/arm/mach-rockchip/board.c
board/amazon/kc1/kc1.c
board/lg/sniper/sniper.c
board/ti/am57xx/board.c
board/ti/dra7xx/evm.c
drivers/fastboot/fb_command.c
drivers/fastboot/fb_common.c
include/fastboot.h

index 0f21ec8..7ea0ed4 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <cpu_func.h>
+#include <fastboot.h>
 #include <init.h>
 #include <net.h>
 #include <asm/arch/boot.h>
@@ -153,8 +154,11 @@ int board_late_init(void)
 #if CONFIG_IS_ENABLED(FASTBOOT)
 static unsigned int reboot_reason = REBOOT_REASON_NORMAL;
 
-int fastboot_set_reboot_flag()
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
+       if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
+               return -ENOTSUPP;
+
        reboot_reason = REBOOT_REASON_BOOTLOADER;
 
        printf("Using reboot reason: 0x%x\n", reboot_reason);
index 430c0cb..ba4da72 100644 (file)
@@ -6,6 +6,7 @@
 #include <clk.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <fastboot.h>
 #include <init.h>
 #include <log.h>
 #include <ram.h>
@@ -152,8 +153,11 @@ int board_usb_init(int index, enum usb_init_type init)
 #endif /* CONFIG_USB_GADGET */
 
 #if CONFIG_IS_ENABLED(FASTBOOT)
-int fastboot_set_reboot_flag(void)
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
+       if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
+               return -ENOTSUPP;
+
        printf("Setting reboot to fastboot flag ...\n");
        /* Set boot mode to fastboot */
        writel(BOOT_FASTBOOT, CONFIG_ROCKCHIP_BOOT_MODE_REG);
index 7d62a1d..973bc5a 100644 (file)
@@ -8,6 +8,7 @@
 #include <config.h>
 #include <common.h>
 #include <env.h>
+#include <fastboot.h>
 #include <init.h>
 #include <linux/ctype.h>
 #include <linux/usb/musb.h>
@@ -163,8 +164,11 @@ void get_board_serial(struct tag_serialnr *serialnr)
        omap_die_id_get_board_serial(serialnr);
 }
 
-int fastboot_set_reboot_flag(void)
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
+       if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
+               return -ENOTSUPP;
+
        return omap_reboot_mode_store("b");
 }
 
index b08a267..dff1590 100644 (file)
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <dm.h>
 #include <env.h>
+#include <fastboot.h>
 #include <init.h>
 #include <linux/ctype.h>
 #include <linux/usb/musb.h>
@@ -175,8 +176,11 @@ void reset_misc(void)
        omap_reboot_mode_store(reboot_mode);
 }
 
-int fastboot_set_reboot_flag(void)
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
+       if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
+               return -ENOTSUPP;
+
        return omap_reboot_mode_store("b");
 }
 
index 69dce70..7809875 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <env.h>
+#include <fastboot.h>
 #include <fdt_support.h>
 #include <image.h>
 #include <init.h>
@@ -1172,8 +1173,11 @@ int board_fit_config_name_match(const char *name)
 #endif
 
 #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
-int fastboot_set_reboot_flag(void)
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
+       if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
+               return -ENOTSUPP;
+
        printf("Setting reboot to fastboot flag ...\n");
        env_set("dofastboot", "1");
        env_save();
index 5ae179f..ca1976e 100644 (file)
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <env.h>
 #include <fdt_support.h>
+#include <fastboot.h>
 #include <image.h>
 #include <init.h>
 #include <spl.h>
@@ -1050,8 +1051,11 @@ int board_fit_config_name_match(const char *name)
 #endif
 
 #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
-int fastboot_set_reboot_flag(void)
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
+       if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
+               return -ENOTSUPP;
+
        printf("Setting reboot to fastboot flag ...\n");
        env_set("dofastboot", "1");
        env_save();
index 49f6a61..8ce5d32 100644 (file)
@@ -307,7 +307,7 @@ static void erase(char *cmd_parameter, char *response)
  */
 static void reboot_bootloader(char *cmd_parameter, char *response)
 {
-       if (fastboot_set_reboot_flag())
+       if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_BOOTLOADER))
                fastboot_fail("Cannot set reboot flag", response);
        else
                fastboot_okay(NULL, response);
index c3735a4..736ce1c 100644 (file)
@@ -88,7 +88,7 @@ void fastboot_okay(const char *reason, char *response)
  * which sets whatever flag your board specific Android bootloader flow
  * requires in order to re-enter the bootloader.
  */
-int __weak fastboot_set_reboot_flag(void)
+int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
        return -ENOSYS;
 }
index 1933b1d..14f4c68 100644 (file)
@@ -41,6 +41,14 @@ enum {
 };
 
 /**
+ * Reboot reasons
+ */
+enum fastboot_reboot_reason {
+       FASTBOOT_REBOOT_REASON_BOOTLOADER,
+       FASTBOOT_REBOOT_REASONS_COUNT
+};
+
+/**
  * fastboot_response() - Writes a response of the form "$tag$reason".
  *
  * @tag: The first part of the response
@@ -77,7 +85,7 @@ void fastboot_okay(const char *reason, char *response);
  * which sets whatever flag your board specific Android bootloader flow
  * requires in order to re-enter the bootloader.
  */
-int fastboot_set_reboot_flag(void);
+int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason);
 
 /**
  * fastboot_set_progress_callback() - set progress callback