1
2
3
4
5
6
7#include <common.h>
8#include <dm.h>
9#include <wdt.h>
10#include <asm/state.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14static int sandbox_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
15{
16 struct sandbox_state *state = state_get_current();
17
18 state->wdt.counter = timeout;
19 state->wdt.running = true;
20
21 return 0;
22}
23
24static int sandbox_wdt_stop(struct udevice *dev)
25{
26 struct sandbox_state *state = state_get_current();
27
28 state->wdt.running = false;
29
30 return 0;
31}
32
33static int sandbox_wdt_reset(struct udevice *dev)
34{
35 struct sandbox_state *state = state_get_current();
36
37 state->wdt.reset_count++;
38
39 return 0;
40}
41
42static int sandbox_wdt_expire_now(struct udevice *dev, ulong flags)
43{
44 sandbox_wdt_start(dev, 1, flags);
45
46 return 0;
47}
48
49static const struct wdt_ops sandbox_wdt_ops = {
50 .start = sandbox_wdt_start,
51 .reset = sandbox_wdt_reset,
52 .stop = sandbox_wdt_stop,
53 .expire_now = sandbox_wdt_expire_now,
54};
55
56static const struct udevice_id sandbox_wdt_ids[] = {
57 { .compatible = "sandbox,wdt" },
58 {}
59};
60
61U_BOOT_DRIVER(wdt_sandbox) = {
62 .name = "wdt_sandbox",
63 .id = UCLASS_WDT,
64 .of_match = sandbox_wdt_ids,
65 .ops = &sandbox_wdt_ops,
66};
67