2 * Copyright 2017 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/state.h>
12 DECLARE_GLOBAL_DATA_PTR
;
14 static int sandbox_wdt_start(struct udevice
*dev
, u64 timeout
, ulong flags
)
16 struct sandbox_state
*state
= state_get_current();
18 state
->wdt
.counter
= timeout
;
19 state
->wdt
.running
= true;
24 static int sandbox_wdt_stop(struct udevice
*dev
)
26 struct sandbox_state
*state
= state_get_current();
28 state
->wdt
.running
= false;
33 static int sandbox_wdt_reset(struct udevice
*dev
)
35 struct sandbox_state
*state
= state_get_current();
37 state
->wdt
.reset_count
++;
42 static int sandbox_wdt_expire_now(struct udevice
*dev
, ulong flags
)
44 sandbox_wdt_start(dev
, 1, flags
);
49 static 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
,
56 static const struct udevice_id sandbox_wdt_ids
[] = {
57 { .compatible
= "sandbox,wdt" },
61 U_BOOT_DRIVER(wdt_sandbox
) = {
62 .name
= "wdt_sandbox",
64 .of_match
= sandbox_wdt_ids
,
65 .ops
= &sandbox_wdt_ops
,