Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Paolo Pisati | 6213c55 | 2017-02-10 17:28:05 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Watchdog driver for Broadcom BCM2835 |
| 4 | * |
| 5 | * Copyright (C) 2017 Paolo Pisati <p.pisati@gmail.com> |
Paolo Pisati | 6213c55 | 2017-02-10 17:28:05 +0100 | [diff] [blame] | 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 | } |