]> git.ipfire.org Git - thirdparty/u-boot.git/blame - drivers/watchdog/sandbox_wdt.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / drivers / watchdog / sandbox_wdt.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0753bc2d 2/*
3 * Copyright 2017 Google, Inc
0753bc2d 4 */
5
d678a59d 6#include <common.h>
0753bc2d 7#include <dm.h>
0753bc2d 8#include <wdt.h>
78df5e1e 9#include <asm/state.h>
0753bc2d 10
0753bc2d 11static int sandbox_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
12{
13 struct sandbox_state *state = state_get_current();
14
15 state->wdt.counter = timeout;
16 state->wdt.running = true;
17
18 return 0;
19}
20
21static int sandbox_wdt_stop(struct udevice *dev)
22{
23 struct sandbox_state *state = state_get_current();
24
25 state->wdt.running = false;
26
27 return 0;
28}
29
30static int sandbox_wdt_reset(struct udevice *dev)
31{
32 struct sandbox_state *state = state_get_current();
33
34 state->wdt.reset_count++;
35
36 return 0;
37}
38
39static int sandbox_wdt_expire_now(struct udevice *dev, ulong flags)
40{
41 sandbox_wdt_start(dev, 1, flags);
592e2e59 42 sandbox_reset();
0753bc2d 43
44 return 0;
45}
46
0753bc2d 47static 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,
52};
53
54static const struct udevice_id sandbox_wdt_ids[] = {
55 { .compatible = "sandbox,wdt" },
56 {}
57};
58
59U_BOOT_DRIVER(wdt_sandbox) = {
60 .name = "wdt_sandbox",
61 .id = UCLASS_WDT,
62 .of_match = sandbox_wdt_ids,
63 .ops = &sandbox_wdt_ops,
0753bc2d 64};