blob: 6f753ae8ae4a752205f6a386ce26077eed2c629d [file] [log] [blame]
Paolo Pisati45a6d232017-02-10 17:28:05 +01001/*
2 * Watchdog driver for Broadcom BCM2835
3 *
4 * Copyright (C) 2017 Paolo Pisati <p.pisati@gmail.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0
7 */
8
9#include <common.h>
10#include <efi_loader.h>
11#include <asm/io.h>
12#include <asm/arch/wdog.h>
13
14#define SECS_TO_WDOG_TICKS(x) ((x) << 16)
15#define MAX_TIMEOUT 0xf /* ~15s */
16
17static __efi_runtime_data bool enabled = true;
18
19extern void reset_cpu(ulong ticks);
20
21void hw_watchdog_reset(void)
22{
23 if (enabled)
24 reset_cpu(SECS_TO_WDOG_TICKS(MAX_TIMEOUT));
25}
26
27void hw_watchdog_init(void)
28{
29 hw_watchdog_reset();
30}
31
32void __efi_runtime hw_watchdog_disable(void)
33{
34 enabled = false;
35}