xref: /openbmc/u-boot/include/watchdog.h (revision 63495ad7)
1 /*
2  * (C) Copyright 2001
3  * Erik Theisen,  Wave 7 Optics, etheisen@mindspring.com.
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 
24 /*
25  * Watchdog functions and macros.
26  */
27 #ifndef _WATCHDOG_H_
28 #define _WATCHDOG_H_
29 
30 #if !defined(__ASSEMBLY__)
31 /*
32  * Reset the watchdog timer, always returns 0
33  *
34  * This function is here since it is shared between board_f() and board_r(),
35  * and the legacy arch/<arch>/board.c code.
36  */
37 int init_func_watchdog_reset(void);
38 #endif
39 
40 #ifdef CONFIG_WATCHDOG
41 #define INIT_FUNC_WATCHDOG_INIT	init_func_watchdog_init,
42 #define INIT_FUNC_WATCHDOG_RESET	init_func_watchdog_reset,
43 #else
44 #define INIT_FUNC_WATCHDOG_INIT
45 #define INIT_FUNC_WATCHDOG_RESET
46 #endif
47 
48 #if defined(CONFIG_HW_WATCHDOG) && defined(CONFIG_WATCHDOG)
49 #  error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together."
50 #endif
51 
52 /*
53  * Hardware watchdog
54  */
55 #ifdef CONFIG_HW_WATCHDOG
56 	#if defined(__ASSEMBLY__)
57 		#define WATCHDOG_RESET bl hw_watchdog_reset
58 	#else
59 		extern void hw_watchdog_reset(void);
60 
61 		#define WATCHDOG_RESET hw_watchdog_reset
62 	#endif /* __ASSEMBLY__ */
63 #else
64 	/*
65 	 * Maybe a software watchdog?
66 	 */
67 	#if defined(CONFIG_WATCHDOG)
68 		#if defined(__ASSEMBLY__)
69 			#define WATCHDOG_RESET bl watchdog_reset
70 		#else
71 			extern void watchdog_reset(void);
72 
73 			#define WATCHDOG_RESET watchdog_reset
74 		#endif
75 	#else
76 		/*
77 		 * No hardware or software watchdog.
78 		 */
79 		#if defined(__ASSEMBLY__)
80 			#define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/
81 		#else
82 			#define WATCHDOG_RESET() {}
83 		#endif /* __ASSEMBLY__ */
84 	#endif /* CONFIG_WATCHDOG && !__ASSEMBLY__ */
85 #endif /* CONFIG_HW_WATCHDOG */
86 
87 /*
88  * Prototypes from $(CPU)/cpu.c.
89  */
90 
91 /* MPC 8xx */
92 #if (defined(CONFIG_8xx) || defined(CONFIG_MPC860)) && !defined(__ASSEMBLY__)
93 	void reset_8xx_watchdog(volatile immap_t *immr);
94 #endif
95 
96 /* MPC 5xx */
97 #if defined(CONFIG_5xx) && !defined(__ASSEMBLY__)
98 	void reset_5xx_watchdog(volatile immap_t *immr);
99 #endif
100 
101 /* MPC 5xxx */
102 #if defined(CONFIG_MPC5xxx) && !defined(__ASSEMBLY__)
103 	void reset_5xxx_watchdog(void);
104 #endif
105 
106 /* AMCC 4xx */
107 #if defined(CONFIG_4xx) && !defined(__ASSEMBLY__)
108 	void reset_4xx_watchdog(void);
109 #endif
110 
111 /* Freescale i.MX */
112 #if defined(CONFIG_IMX_WATCHDOG) && !defined(__ASSEMBLY__)
113 	void hw_watchdog_init(void);
114 #endif
115 #endif /* _WATCHDOG_H_ */
116