blob: 6cffcb15e05d5eace1ce745834ea0c27daa9bacb [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Paolo Pisati45a6d232017-02-10 17:28:05 +01002/*
3 * Watchdog driver for Broadcom BCM2835
4 *
5 * Copyright (C) 2017 Paolo Pisati <p.pisati@gmail.com>
Paolo Pisati45a6d232017-02-10 17:28:05 +01006 */
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
16static __efi_runtime_data bool enabled = true;
17
18extern void reset_cpu(ulong ticks);
19
20void hw_watchdog_reset(void)
21{
22 if (enabled)
23 reset_cpu(SECS_TO_WDOG_TICKS(MAX_TIMEOUT));
24}
25
26void hw_watchdog_init(void)
27{
28 hw_watchdog_reset();
29}
30
31void __efi_runtime hw_watchdog_disable(void)
32{
33 enabled = false;
34}