From patchwork Wed Jun 10 16:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 242083 List-Id: U-Boot discussion From: roman.kovalivskyi at globallogic.com (Roman Kovalivskyi) Date: Wed, 10 Jun 2020 19:36:45 +0300 Subject: [PATCH v3 1/3] fastboot: Extend fastboot_set_reboot_flag with reboot reason In-Reply-To: References: Message-ID: Extend fastboot_set_reboot_flag arguments with reboot reason so that it could handle different reboot cases in future. Signed-off-by: Roman Kovalivskyi --- arch/arm/mach-meson/board-common.c | 6 +++++- arch/arm/mach-rockchip/board.c | 6 +++++- board/amazon/kc1/kc1.c | 6 +++++- board/lg/sniper/sniper.c | 6 +++++- board/ti/am57xx/board.c | 6 +++++- board/ti/dra7xx/evm.c | 6 +++++- drivers/fastboot/fb_command.c | 2 +- drivers/fastboot/fb_common.c | 2 +- include/fastboot.h | 10 +++++++++- 9 files changed, 41 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c index 19e5bfd3660c..a1f08bb98c6f 100644 --- a/arch/arm/mach-meson/board-common.c +++ b/arch/arm/mach-meson/board-common.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -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); diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 430c0cbf41e4..ba4da72b3910 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c index fb1828ff44da..445980f16e62 100644 --- a/board/amazon/kc1/kc1.c +++ b/board/amazon/kc1/kc1.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -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"); } diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c index 2825eccc035a..99b832fe601b 100644 --- a/board/lg/sniper/sniper.c +++ b/board/lg/sniper/sniper.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -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"); } diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index 8720eb87a55d..49afd3bc927b 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -1169,8 +1170,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(); diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index acf7ff169170..3bc40c721146 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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(); diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 49f6a61c3745..8ce5d32fb2ba 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -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); diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index c3735a44af74..736ce1cd024f 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -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; } diff --git a/include/fastboot.h b/include/fastboot.h index 1933b1d98e3b..14f4c68868d8 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -40,6 +40,14 @@ enum { FASTBOOT_COMMAND_COUNT }; +/** + * Reboot reasons + */ +enum fastboot_reboot_reason { + FASTBOOT_REBOOT_REASON_BOOTLOADER, + FASTBOOT_REBOOT_REASONS_COUNT +}; + /** * fastboot_response() - Writes a response of the form "$tag$reason". * @@ -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