Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2001 |
| 4 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. |
wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Watchdog functions and macros. |
| 9 | */ |
| 10 | #ifndef _WATCHDOG_H_ |
| 11 | #define _WATCHDOG_H_ |
| 12 | |
Simon Glass | a6741bc | 2013-03-05 14:39:42 +0000 | [diff] [blame] | 13 | #if !defined(__ASSEMBLY__) |
| 14 | /* |
| 15 | * Reset the watchdog timer, always returns 0 |
| 16 | * |
| 17 | * This function is here since it is shared between board_f() and board_r(), |
| 18 | * and the legacy arch/<arch>/board.c code. |
| 19 | */ |
| 20 | int init_func_watchdog_reset(void); |
| 21 | #endif |
| 22 | |
Simon Glass | 9be2e79 | 2016-05-14 18:49:35 -0600 | [diff] [blame] | 23 | #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG) |
Simon Glass | a6741bc | 2013-03-05 14:39:42 +0000 | [diff] [blame] | 24 | #define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init, |
| 25 | #define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset, |
| 26 | #else |
| 27 | #define INIT_FUNC_WATCHDOG_INIT |
| 28 | #define INIT_FUNC_WATCHDOG_RESET |
| 29 | #endif |
| 30 | |
wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 31 | #if defined(CONFIG_HW_WATCHDOG) && defined(CONFIG_WATCHDOG) |
| 32 | # error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together." |
| 33 | #endif |
| 34 | |
| 35 | /* |
| 36 | * Hardware watchdog |
| 37 | */ |
| 38 | #ifdef CONFIG_HW_WATCHDOG |
| 39 | #if defined(__ASSEMBLY__) |
| 40 | #define WATCHDOG_RESET bl hw_watchdog_reset |
| 41 | #else |
| 42 | extern void hw_watchdog_reset(void); |
| 43 | |
| 44 | #define WATCHDOG_RESET hw_watchdog_reset |
| 45 | #endif /* __ASSEMBLY__ */ |
| 46 | #else |
| 47 | /* |
| 48 | * Maybe a software watchdog? |
| 49 | */ |
| 50 | #if defined(CONFIG_WATCHDOG) |
| 51 | #if defined(__ASSEMBLY__) |
| 52 | #define WATCHDOG_RESET bl watchdog_reset |
| 53 | #else |
Stefan Roese | 7fbd42f | 2019-04-02 10:57:18 +0200 | [diff] [blame] | 54 | /* Don't require the watchdog to be enabled in SPL */ |
| 55 | #if defined(CONFIG_SPL_BUILD) && \ |
Simon Glass | 078111b | 2021-07-10 21:14:28 -0600 | [diff] [blame^] | 56 | !defined(CONFIG_SPL_WATCHDOG) |
Stefan Roese | 7fbd42f | 2019-04-02 10:57:18 +0200 | [diff] [blame] | 57 | #define WATCHDOG_RESET() {} |
| 58 | #else |
| 59 | extern void watchdog_reset(void); |
wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 60 | |
Stefan Roese | 7fbd42f | 2019-04-02 10:57:18 +0200 | [diff] [blame] | 61 | #define WATCHDOG_RESET watchdog_reset |
| 62 | #endif |
wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 63 | #endif |
| 64 | #else |
| 65 | /* |
| 66 | * No hardware or software watchdog. |
| 67 | */ |
| 68 | #if defined(__ASSEMBLY__) |
| 69 | #define WATCHDOG_RESET /*XXX DO_NOT_DEL_THIS_COMMENT*/ |
| 70 | #else |
| 71 | #define WATCHDOG_RESET() {} |
| 72 | #endif /* __ASSEMBLY__ */ |
| 73 | #endif /* CONFIG_WATCHDOG && !__ASSEMBLY__ */ |
| 74 | #endif /* CONFIG_HW_WATCHDOG */ |
| 75 | |
| 76 | /* |
| 77 | * Prototypes from $(CPU)/cpu.c. |
| 78 | */ |
| 79 | |
Suniel Mahesh | 6912f2a | 2019-07-31 21:54:07 +0530 | [diff] [blame] | 80 | #if (defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)) && !defined(__ASSEMBLY__) |
Tom Rini | a672076 | 2013-01-14 13:10:07 -0700 | [diff] [blame] | 81 | void hw_watchdog_init(void); |
| 82 | #endif |
Boschung, Rainer | 0f8062b | 2014-06-03 09:05:14 +0200 | [diff] [blame] | 83 | |
| 84 | #if defined(CONFIG_MPC85xx) && !defined(__ASSEMBLY__) |
| 85 | void init_85xx_watchdog(void); |
| 86 | #endif |
wdenk | 012771d | 2002-03-08 21:31:05 +0000 | [diff] [blame] | 87 | #endif /* _WATCHDOG_H_ */ |