1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2017 Google, Inc
14 * Implement a simple watchdog uclass. Watchdog is basically a timer that
15 * is used to detect or recover from malfunction. During normal operation
16 * the watchdog would be regularly reset to prevent it from timing out.
17 * If, due to a hardware fault or program error, the computer fails to reset
18 * the watchdog, the timer will elapse and generate a timeout signal.
19 * The timeout signal is used to initiate corrective action or actions,
20 * which typically include placing the system in a safe, known state.
27 * @timeout_ms: Number of ticks (milliseconds) before timer expires
28 * @flags: Driver specific flags. This might be used to specify
29 * which action needs to be executed when the timer expires
30 * @return: 0 if OK, -ve on error
32 int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags);
35 * Stop the timer, thus disabling the Watchdog. Use wdt_start to start it again.
38 * @return: 0 if OK, -ve on error
40 int wdt_stop(struct udevice *dev);
43 * Reset the timer, typically restoring the counter to
44 * the value configured by start()
47 * @return: 0 if OK, -ve on error
49 int wdt_reset(struct udevice *dev);
52 * Expire the timer, thus executing its action immediately.
53 * This is typically used to reset the board or peripherals.
56 * @flags: Driver specific flags
57 * @return 0 if OK -ve on error. If wdt action is system reset,
58 * this function may never return.
60 int wdt_expire_now(struct udevice *dev, ulong flags);
63 * struct wdt_ops - Driver model wdt operations
65 * The uclass interface is implemented by all wdt devices which use
73 * @timeout_ms: Number of ticks (milliseconds) before the timer expires
74 * @flags: Driver specific flags. This might be used to specify
75 * which action needs to be executed when the timer expires
76 * @return: 0 if OK, -ve on error
78 int (*start)(struct udevice *dev, u64 timeout_ms, ulong flags);
83 * @return: 0 if OK, -ve on error
85 int (*stop)(struct udevice *dev);
87 * Reset the timer, typically restoring the counter to
88 * the value configured by start()
91 * @return: 0 if OK, -ve on error
93 int (*reset)(struct udevice *dev);
95 * Expire the timer, thus executing the action immediately (optional)
97 * If this function is not provided, a default implementation
98 * will be used, which sets the counter to 1
99 * and waits forever. This is good enough for system level
100 * reset, where the function is not expected to return, but might not be
101 * good enough for other use cases.
104 * @flags: Driver specific flags
105 * @return 0 if OK -ve on error. May not return.
107 int (*expire_now)(struct udevice *dev, ulong flags);
110 int initr_watchdog(void);