2 * Copyright 2017 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/state.h>
12 static int sandbox_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
14 struct sandbox_state *state = state_get_current();
16 state->wdt.counter = timeout;
17 state->wdt.running = true;
22 static int sandbox_wdt_stop(struct udevice *dev)
24 struct sandbox_state *state = state_get_current();
26 state->wdt.running = false;
31 static int sandbox_wdt_reset(struct udevice *dev)
33 struct sandbox_state *state = state_get_current();
35 state->wdt.reset_count++;
40 static int sandbox_wdt_expire_now(struct udevice *dev, ulong flags)
42 sandbox_wdt_start(dev, 1, flags);
47 static const struct wdt_ops sandbox_wdt_ops = {
48 .start = sandbox_wdt_start,
49 .reset = sandbox_wdt_reset,
50 .stop = sandbox_wdt_stop,
51 .expire_now = sandbox_wdt_expire_now,
54 static const struct udevice_id sandbox_wdt_ids[] = {
55 { .compatible = "sandbox,wdt" },
59 U_BOOT_DRIVER(wdt_sandbox) = {
60 .name = "wdt_sandbox",
62 .of_match = sandbox_wdt_ids,
63 .ops = &sandbox_wdt_ops,