]> git.ipfire.org Git - thirdparty/u-boot.git/blame - common/bootretry.c
ARM: add psci_arch_init() declaration for CONFIG_ARMV7_PSCI
[thirdparty/u-boot.git] / common / bootretry.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0098e179
SG
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
0098e179
SG
5 */
6
7#include <common.h>
8#include <bootretry.h>
9#include <cli.h>
7b51b576 10#include <env.h>
0098e179 11#include <errno.h>
1045315d 12#include <time.h>
0098e179
SG
13#include <watchdog.h>
14
15#ifndef CONFIG_BOOT_RETRY_MIN
16#define CONFIG_BOOT_RETRY_MIN CONFIG_BOOT_RETRY_TIME
17#endif
18
19static uint64_t endtime; /* must be set, default is instant timeout */
20static int retry_time = -1; /* -1 so can call readline before main_loop */
21
22/***************************************************************************
23 * initialize command line timeout
24 */
b26440f1 25void bootretry_init_cmd_timeout(void)
0098e179 26{
00caae6d 27 char *s = env_get("bootretry");
0098e179
SG
28
29 if (s != NULL)
30 retry_time = (int)simple_strtol(s, NULL, 10);
31 else
32 retry_time = CONFIG_BOOT_RETRY_TIME;
33
34 if (retry_time >= 0 && retry_time < CONFIG_BOOT_RETRY_MIN)
35 retry_time = CONFIG_BOOT_RETRY_MIN;
36}
37
38/***************************************************************************
39 * reset command line timeout to retry_time seconds
40 */
b26440f1 41void bootretry_reset_cmd_timeout(void)
0098e179
SG
42{
43 endtime = endtick(retry_time);
44}
45
46int bootretry_tstc_timeout(void)
47{
48 while (!tstc()) { /* while no incoming data */
49 if (retry_time >= 0 && get_ticks() > endtime)
50 return -ETIMEDOUT;
51 WATCHDOG_RESET();
52 }
53
54 return 0;
55}
56
57void bootretry_dont_retry(void)
58{
59 retry_time = -1;
60}