blob: 0a9777edcbad40348a0b000ff3d01d98673161b5 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk012771d2002-03-08 21:31:05 +00002/*
3 * (C) Copyright 2001
4 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
wdenk012771d2002-03-08 21:31:05 +00005 */
6
7/*
8 * Watchdog functions and macros.
9 */
10#ifndef _WATCHDOG_H_
11#define _WATCHDOG_H_
12
Simon Glassa6741bc2013-03-05 14:39:42 +000013#if !defined(__ASSEMBLY__)
Stefan Roese661cdaa2022-09-02 13:57:49 +020014#include <cyclic.h>
15
Simon Glassa6741bc2013-03-05 14:39:42 +000016/*
17 * Reset the watchdog timer, always returns 0
18 *
19 * This function is here since it is shared between board_f() and board_r(),
20 * and the legacy arch/<arch>/board.c code.
21 */
22int init_func_watchdog_reset(void);
23#endif
24
Simon Glass9be2e792016-05-14 18:49:35 -060025#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
Simon Glassa6741bc2013-03-05 14:39:42 +000026#define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
27#define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset,
28#else
29#define INIT_FUNC_WATCHDOG_INIT
30#define INIT_FUNC_WATCHDOG_RESET
31#endif
32
wdenk012771d2002-03-08 21:31:05 +000033#if defined(CONFIG_HW_WATCHDOG) && defined(CONFIG_WATCHDOG)
34# error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together."
35#endif
36
37/*
38 * Hardware watchdog
39 */
40#ifdef CONFIG_HW_WATCHDOG
41 #if defined(__ASSEMBLY__)
42 #define WATCHDOG_RESET bl hw_watchdog_reset
43 #else
44 extern void hw_watchdog_reset(void);
45
46 #define WATCHDOG_RESET hw_watchdog_reset
47 #endif /* __ASSEMBLY__ */
48#else
49 /*
50 * Maybe a software watchdog?
51 */
52 #if defined(CONFIG_WATCHDOG)
53 #if defined(__ASSEMBLY__)
Pali Rohár06ceff72022-04-28 13:33:09 +020054 /* Don't require the watchdog to be enabled in SPL */
55 #if defined(CONFIG_SPL_BUILD) && \
56 !defined(CONFIG_SPL_WATCHDOG)
57 #define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/
58 #else
59 #define WATCHDOG_RESET bl watchdog_reset
60 #endif
wdenk012771d2002-03-08 21:31:05 +000061 #else
Stefan Roese7fbd42f2019-04-02 10:57:18 +020062 /* Don't require the watchdog to be enabled in SPL */
63 #if defined(CONFIG_SPL_BUILD) && \
Simon Glass078111b2021-07-10 21:14:28 -060064 !defined(CONFIG_SPL_WATCHDOG)
Stefan Roese661cdaa2022-09-02 13:57:49 +020065 #define WATCHDOG_RESET() { \
66 cyclic_run(); \
67 }
Stefan Roese7fbd42f2019-04-02 10:57:18 +020068 #else
69 extern void watchdog_reset(void);
wdenk012771d2002-03-08 21:31:05 +000070
Stefan Roese661cdaa2022-09-02 13:57:49 +020071 #define WATCHDOG_RESET() { \
72 watchdog_reset(); \
73 cyclic_run(); \
74 }
Stefan Roese7fbd42f2019-04-02 10:57:18 +020075 #endif
wdenk012771d2002-03-08 21:31:05 +000076 #endif
77 #else
78 /*
79 * No hardware or software watchdog.
80 */
81 #if defined(__ASSEMBLY__)
82 #define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/
83 #else
Stefan Roese661cdaa2022-09-02 13:57:49 +020084 #define WATCHDOG_RESET() { \
85 cyclic_run(); \
86 }
wdenk012771d2002-03-08 21:31:05 +000087 #endif /* __ASSEMBLY__ */
88 #endif /* CONFIG_WATCHDOG && !__ASSEMBLY__ */
89#endif /* CONFIG_HW_WATCHDOG */
90
Stefan Roese661cdaa2022-09-02 13:57:49 +020091#if !defined(__ASSEMBLY__)
92/* Currently only needed for fs/cramfs/uncompress.c */
93static inline void watchdog_reset_func(void)
94{
95 WATCHDOG_RESET();
96}
97#endif
98
wdenk012771d2002-03-08 21:31:05 +000099/*
100 * Prototypes from $(CPU)/cpu.c.
101 */
102
Suniel Mahesh6912f2a2019-07-31 21:54:07 +0530103#if (defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)) && !defined(__ASSEMBLY__)
Tom Rinia6720762013-01-14 13:10:07 -0700104 void hw_watchdog_init(void);
105#endif
Boschung, Rainer0f8062b2014-06-03 09:05:14 +0200106
107#if defined(CONFIG_MPC85xx) && !defined(__ASSEMBLY__)
108 void init_85xx_watchdog(void);
109#endif
wdenk012771d2002-03-08 21:31:05 +0000110#endif /* _WATCHDOG_H_ */