blob: 89ec3601b6f67824a992940f2e07653d03f65233 [file] [log] [blame]
Roman Kovalivskyi21882dd2020-07-28 23:35:34 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2020 GlobalLogic.
4 * Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
5 */
6
7#include <common.h>
8#include <fastboot.h>
9
10/**
11 * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader
12 *
13 * Set flag which indicates that we should reboot into the bootloader
14 * following the reboot that fastboot executes after this function.
15 *
16 * This function should be overridden in your board file with one
17 * which sets whatever flag your board specific Android bootloader flow
18 * requires in order to re-enter the bootloader.
19 */
20int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
21{
22 char cmd[64];
23
24 if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
25 return -EINVAL;
26
27 snprintf(cmd, sizeof(cmd), "bcb load %d misc",
28 CONFIG_FASTBOOT_FLASH_MMC_DEV);
29
30 if (run_command(cmd, 0))
31 return -ENODEV;
32
33 snprintf(cmd, sizeof(cmd), "bcb set command %s",
34 fastboot_boot_cmds[reason]);
35
36 if (run_command(cmd, 0))
37 return -ENOEXEC;
38
39 if (run_command("bcb store", 0))
40 return -EIO;
41
42 return 0;
43}