1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2017 Google, Inc
11 static int sandbox_wdt_start(struct udevice
*dev
, u64 timeout
, ulong flags
)
13 struct sandbox_state
*state
= state_get_current();
15 state
->wdt
.counter
= timeout
;
16 state
->wdt
.running
= true;
21 static int sandbox_wdt_stop(struct udevice
*dev
)
23 struct sandbox_state
*state
= state_get_current();
25 state
->wdt
.running
= false;
30 static int sandbox_wdt_reset(struct udevice
*dev
)
32 struct sandbox_state
*state
= state_get_current();
34 state
->wdt
.reset_count
++;
39 static int sandbox_wdt_expire_now(struct udevice
*dev
, ulong flags
)
41 sandbox_wdt_start(dev
, 1, flags
);
46 static const struct wdt_ops sandbox_wdt_ops
= {
47 .start
= sandbox_wdt_start
,
48 .reset
= sandbox_wdt_reset
,
49 .stop
= sandbox_wdt_stop
,
50 .expire_now
= sandbox_wdt_expire_now
,
53 static const struct udevice_id sandbox_wdt_ids
[] = {
54 { .compatible
= "sandbox,wdt" },
58 U_BOOT_DRIVER(wdt_sandbox
) = {
59 .name
= "wdt_sandbox",
61 .of_match
= sandbox_wdt_ids
,
62 .ops
= &sandbox_wdt_ops
,