xref: /OK3568_Linux_fs/u-boot/include/watchdog.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * (C) Copyright 2001
3*4882a593Smuzhiyun  * Erik Theisen,  Wave 7 Optics, etheisen@mindspring.com.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /*
9*4882a593Smuzhiyun  * Watchdog functions and macros.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun #ifndef _WATCHDOG_H_
12*4882a593Smuzhiyun #define _WATCHDOG_H_
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #if !defined(__ASSEMBLY__)
15*4882a593Smuzhiyun /*
16*4882a593Smuzhiyun  * Reset the watchdog timer, always returns 0
17*4882a593Smuzhiyun  *
18*4882a593Smuzhiyun  * This function is here since it is shared between board_f() and board_r(),
19*4882a593Smuzhiyun  * and the legacy arch/<arch>/board.c code.
20*4882a593Smuzhiyun  */
21*4882a593Smuzhiyun int init_func_watchdog_reset(void);
22*4882a593Smuzhiyun #endif
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
25*4882a593Smuzhiyun #define INIT_FUNC_WATCHDOG_INIT	init_func_watchdog_init,
26*4882a593Smuzhiyun #define INIT_FUNC_WATCHDOG_RESET	init_func_watchdog_reset,
27*4882a593Smuzhiyun #else
28*4882a593Smuzhiyun #define INIT_FUNC_WATCHDOG_INIT
29*4882a593Smuzhiyun #define INIT_FUNC_WATCHDOG_RESET
30*4882a593Smuzhiyun #endif
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #if defined(CONFIG_HW_WATCHDOG) && defined(CONFIG_WATCHDOG)
33*4882a593Smuzhiyun #  error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together."
34*4882a593Smuzhiyun #endif
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /*
37*4882a593Smuzhiyun  * Hardware watchdog
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun #ifdef CONFIG_HW_WATCHDOG
40*4882a593Smuzhiyun 	#if defined(__ASSEMBLY__)
41*4882a593Smuzhiyun 		#define WATCHDOG_RESET bl hw_watchdog_reset
42*4882a593Smuzhiyun 	#else
43*4882a593Smuzhiyun 		extern void hw_watchdog_reset(void);
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 		#define WATCHDOG_RESET hw_watchdog_reset
46*4882a593Smuzhiyun 	#endif /* __ASSEMBLY__ */
47*4882a593Smuzhiyun #else
48*4882a593Smuzhiyun 	/*
49*4882a593Smuzhiyun 	 * Maybe a software watchdog?
50*4882a593Smuzhiyun 	 */
51*4882a593Smuzhiyun 	#if defined(CONFIG_WATCHDOG)
52*4882a593Smuzhiyun 		#if defined(__ASSEMBLY__)
53*4882a593Smuzhiyun 			#define WATCHDOG_RESET bl watchdog_reset
54*4882a593Smuzhiyun 		#else
55*4882a593Smuzhiyun 			extern void watchdog_reset(void);
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun 			#define WATCHDOG_RESET watchdog_reset
58*4882a593Smuzhiyun 		#endif
59*4882a593Smuzhiyun 	#else
60*4882a593Smuzhiyun 		/*
61*4882a593Smuzhiyun 		 * No hardware or software watchdog.
62*4882a593Smuzhiyun 		 */
63*4882a593Smuzhiyun 		#if defined(__ASSEMBLY__)
64*4882a593Smuzhiyun 			#define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/
65*4882a593Smuzhiyun 		#else
66*4882a593Smuzhiyun 			#define WATCHDOG_RESET() {}
67*4882a593Smuzhiyun 		#endif /* __ASSEMBLY__ */
68*4882a593Smuzhiyun 	#endif /* CONFIG_WATCHDOG && !__ASSEMBLY__ */
69*4882a593Smuzhiyun #endif /* CONFIG_HW_WATCHDOG */
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun /*
72*4882a593Smuzhiyun  * Prototypes from $(CPU)/cpu.c.
73*4882a593Smuzhiyun  */
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun /* MPC 8xx */
76*4882a593Smuzhiyun #if defined(CONFIG_MPC8xx) && !defined(__ASSEMBLY__)
77*4882a593Smuzhiyun 	void reset_8xx_watchdog(immap_t __iomem *immr);
78*4882a593Smuzhiyun #endif
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun #if defined(CONFIG_HW_WATCHDOG) && !defined(__ASSEMBLY__)
81*4882a593Smuzhiyun 	void hw_watchdog_init(void);
82*4882a593Smuzhiyun #endif
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #if defined(CONFIG_MPC85xx) && !defined(__ASSEMBLY__)
85*4882a593Smuzhiyun 	void init_85xx_watchdog(void);
86*4882a593Smuzhiyun #endif
87*4882a593Smuzhiyun #endif /* _WATCHDOG_H_ */
88