1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2017 Google, Inc
10 #include <dm/device-internal.h>
13 int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
15 const struct wdt_ops *ops = device_get_ops(dev);
20 return ops->start(dev, timeout_ms, flags);
23 int wdt_stop(struct udevice *dev)
25 const struct wdt_ops *ops = device_get_ops(dev);
30 return ops->stop(dev);
33 int wdt_reset(struct udevice *dev)
35 const struct wdt_ops *ops = device_get_ops(dev);
40 return ops->reset(dev);
43 int wdt_expire_now(struct udevice *dev, ulong flags)
46 const struct wdt_ops *ops;
48 debug("WDT Resetting: %lu\n", flags);
49 ops = device_get_ops(dev);
50 if (ops->expire_now) {
51 return ops->expire_now(dev, flags);
56 ret = ops->start(dev, 1, flags);
66 static int wdt_post_bind(struct udevice *dev)
68 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
69 struct wdt_ops *ops = (struct wdt_ops *)device_get_ops(dev);
70 static int reloc_done;
74 ops->start += gd->reloc_off;
76 ops->stop += gd->reloc_off;
78 ops->reset += gd->reloc_off;
80 ops->expire_now += gd->reloc_off;
88 UCLASS_DRIVER(wdt) = {
91 .flags = DM_UC_FLAG_SEQ_ALIAS,
92 .post_bind = wdt_post_bind,