2 * Copyright 2017 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
11 * Implement a simple watchdog uclass. Watchdog is basically a timer that
12 * is used to detect or recover from malfunction. During normal operation
13 * the watchdog would be regularly reset to prevent it from timing out.
14 * If, due to a hardware fault or program error, the computer fails to reset
15 * the watchdog, the timer will elapse and generate a timeout signal.
16 * The timeout signal is used to initiate corrective action or actions,
17 * which typically include placing the system in a safe, known state.
24 * @timeout_ms: Number of ticks (milliseconds) before timer expires
25 * @flags: Driver specific flags. This might be used to specify
26 * which action needs to be executed when the timer expires
27 * @return: 0 if OK, -ve on error
29 int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags);
32 * Stop the timer, thus disabling the Watchdog. Use wdt_start to start it again.
35 * @return: 0 if OK, -ve on error
37 int wdt_stop(struct udevice *dev);
40 * Reset the timer, typically restoring the counter to
41 * the value configured by start()
44 * @return: 0 if OK, -ve on error
46 int wdt_reset(struct udevice *dev);
49 * Expire the timer, thus executing its action immediately.
50 * This is typically used to reset the board or peripherals.
53 * @flags: Driver specific flags
54 * @return 0 if OK -ve on error. If wdt action is system reset,
55 * this function may never return.
57 int wdt_expire_now(struct udevice *dev, ulong flags);
60 * struct wdt_ops - Driver model wdt operations
62 * The uclass interface is implemented by all wdt devices which use
70 * @timeout_ms: Number of ticks (milliseconds) before the timer expires
71 * @flags: Driver specific flags. This might be used to specify
72 * which action needs to be executed when the timer expires
73 * @return: 0 if OK, -ve on error
75 int (*start)(struct udevice *dev, u64 timeout_ms, ulong flags);
80 * @return: 0 if OK, -ve on error
82 int (*stop)(struct udevice *dev);
84 * Reset the timer, typically restoring the counter to
85 * the value configured by start()
88 * @return: 0 if OK, -ve on error
90 int (*reset)(struct udevice *dev);
92 * Expire the timer, thus executing the action immediately (optional)
94 * If this function is not provided, a default implementation
95 * will be used, which sets the counter to 1
96 * and waits forever. This is good enough for system level
97 * reset, where the function is not expected to return, but might not be
98 * good enough for other use cases.
101 * @flags: Driver specific flags
102 * @return 0 if OK -ve on error. May not return.
104 int (*expire_now)(struct udevice *dev, ulong flags);