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