Paolo Pisati | 6213c55 | 2017-02-10 17:28:05 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | static __efi_runtime_data bool enabled = true; |
| 18 | |
| 19 | extern void reset_cpu(ulong ticks); |
| 20 | |
| 21 | void hw_watchdog_reset(void) |
| 22 | { |
| 23 | if (enabled) |
| 24 | reset_cpu(SECS_TO_WDOG_TICKS(MAX_TIMEOUT)); |
| 25 | } |
| 26 | |
| 27 | void hw_watchdog_init(void) |
| 28 | { |
| 29 | hw_watchdog_reset(); |
| 30 | } |
| 31 | |
| 32 | void __efi_runtime hw_watchdog_disable(void) |
| 33 | { |
| 34 | enabled = false; |
| 35 | } |