]> git.sur5r.net Git - u-boot/blob - drivers/watchdog/bcm2835_wdt.c
dwc2 USB controller hangs with lan78xx
[u-boot] / drivers / watchdog / bcm2835_wdt.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Watchdog driver for Broadcom BCM2835
4  *
5  * Copyright (C) 2017 Paolo Pisati <p.pisati@gmail.com>
6  */
7
8 #include <common.h>
9 #include <efi_loader.h>
10 #include <asm/io.h>
11 #include <asm/arch/wdog.h>
12
13 #define SECS_TO_WDOG_TICKS(x) ((x) << 16)
14 #define MAX_TIMEOUT   0xf /* ~15s */
15
16 static __efi_runtime_data bool enabled = true;
17
18 extern void reset_cpu(ulong ticks);
19
20 void hw_watchdog_reset(void)
21 {
22         if (enabled)
23                 reset_cpu(SECS_TO_WDOG_TICKS(MAX_TIMEOUT));
24 }
25
26 void hw_watchdog_init(void)
27 {
28         hw_watchdog_reset();
29 }
30
31 void __efi_runtime hw_watchdog_disable(void)
32 {
33         enabled = false;
34 }