bcm2835_wdt.c 616 B

12345678910111213141516171819202122232425262728293031323334
  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. #include <common.h>
  8. #include <efi_loader.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/wdog.h>
  11. #define SECS_TO_WDOG_TICKS(x) ((x) << 16)
  12. #define MAX_TIMEOUT 0xf /* ~15s */
  13. static __efi_runtime_data bool enabled = true;
  14. extern void reset_cpu(ulong ticks);
  15. void hw_watchdog_reset(void)
  16. {
  17. if (enabled)
  18. reset_cpu(SECS_TO_WDOG_TICKS(MAX_TIMEOUT));
  19. }
  20. void hw_watchdog_init(void)
  21. {
  22. hw_watchdog_reset();
  23. }
  24. void __efi_runtime hw_watchdog_disable(void)
  25. {
  26. enabled = false;
  27. }