1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2017 Google, Inc
10 * Implement a simple watchdog uclass. Watchdog is basically a timer that
11 * is used to detect or recover from malfunction. During normal operation
12 * the watchdog would be regularly reset to prevent it from timing out.
13 * If, due to a hardware fault or program error, the computer fails to reset
14 * the watchdog, the timer will elapse and generate a timeout signal.
15 * The timeout signal is used to initiate corrective action or actions,
16 * which typically include placing the system in a safe, known state.
23 * @timeout_ms: Number of ticks (milliseconds) before timer expires
24 * @flags: Driver specific flags. This might be used to specify
25 * which action needs to be executed when the timer expires
26 * @return: 0 if OK, -ve on error
28 int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags);
31 * Stop the timer, thus disabling the Watchdog. Use wdt_start to start it again.
34 * @return: 0 if OK, -ve on error
36 int wdt_stop(struct udevice *dev);
39 * Reset the timer, typically restoring the counter to
40 * the value configured by start()
43 * @return: 0 if OK, -ve on error
45 int wdt_reset(struct udevice *dev);
48 * Expire the timer, thus executing its action immediately.
49 * This is typically used to reset the board or peripherals.
52 * @flags: Driver specific flags
53 * @return 0 if OK -ve on error. If wdt action is system reset,
54 * this function may never return.
56 int wdt_expire_now(struct udevice *dev, ulong flags);
59 * struct wdt_ops - Driver model wdt operations
61 * The uclass interface is implemented by all wdt devices which use
69 * @timeout_ms: Number of ticks (milliseconds) before the timer expires
70 * @flags: Driver specific flags. This might be used to specify
71 * which action needs to be executed when the timer expires
72 * @return: 0 if OK, -ve on error
74 int (*start)(struct udevice *dev, u64 timeout_ms, ulong flags);
79 * @return: 0 if OK, -ve on error
81 int (*stop)(struct udevice *dev);
83 * Reset the timer, typically restoring the counter to
84 * the value configured by start()
87 * @return: 0 if OK, -ve on error
89 int (*reset)(struct udevice *dev);
91 * Expire the timer, thus executing the action immediately (optional)
93 * If this function is not provided, a default implementation
94 * will be used, which sets the counter to 1
95 * and waits forever. This is good enough for system level
96 * reset, where the function is not expected to return, but might not be
97 * good enough for other use cases.
100 * @flags: Driver specific flags
101 * @return 0 if OK -ve on error. May not return.
103 int (*expire_now)(struct udevice *dev, ulong flags);