1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2017 Google, Inc
13 * Implement a simple watchdog uclass. Watchdog is basically a timer that
14 * is used to detect or recover from malfunction. During normal operation
15 * the watchdog would be regularly reset to prevent it from timing out.
16 * If, due to a hardware fault or program error, the computer fails to reset
17 * the watchdog, the timer will elapse and generate a timeout signal.
18 * The timeout signal is used to initiate corrective action or actions,
19 * which typically include placing the system in a safe, known state.
26 * @timeout_ms: Number of ticks (milliseconds) before timer expires
27 * @flags: Driver specific flags. This might be used to specify
28 * which action needs to be executed when the timer expires
29 * @return: 0 if OK, -ve on error
31 int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags);
34 * Stop the timer, thus disabling the Watchdog. Use wdt_start to start it again.
37 * @return: 0 if OK, -ve on error
39 int wdt_stop(struct udevice *dev);
42 * Reset the timer, typically restoring the counter to
43 * the value configured by start()
46 * @return: 0 if OK, -ve on error
48 int wdt_reset(struct udevice *dev);
51 * Expire the timer, thus executing its action immediately.
52 * This is typically used to reset the board or peripherals.
55 * @flags: Driver specific flags
56 * @return 0 if OK -ve on error. If wdt action is system reset,
57 * this function may never return.
59 int wdt_expire_now(struct udevice *dev, ulong flags);
62 * struct wdt_ops - Driver model wdt operations
64 * The uclass interface is implemented by all wdt devices which use
72 * @timeout_ms: Number of ticks (milliseconds) before the timer expires
73 * @flags: Driver specific flags. This might be used to specify
74 * which action needs to be executed when the timer expires
75 * @return: 0 if OK, -ve on error
77 int (*start)(struct udevice *dev, u64 timeout_ms, ulong flags);
82 * @return: 0 if OK, -ve on error
84 int (*stop)(struct udevice *dev);
86 * Reset the timer, typically restoring the counter to
87 * the value configured by start()
90 * @return: 0 if OK, -ve on error
92 int (*reset)(struct udevice *dev);
94 * Expire the timer, thus executing the action immediately (optional)
96 * If this function is not provided, a default implementation
97 * will be used, which sets the counter to 1
98 * and waits forever. This is good enough for system level
99 * reset, where the function is not expected to return, but might not be
100 * good enough for other use cases.
103 * @flags: Driver specific flags
104 * @return 0 if OK -ve on error. May not return.
106 int (*expire_now)(struct udevice *dev, ulong flags);
109 int initr_watchdog(void);