Hi Maxim, On 17 April 2017 at 13:00, Maxim Sloyko <[email protected]> wrote: > This is a simple uclass for Watchdog Timers. It has four operations: > start, restart, reset, stop. Drivers must implement start, restart and > stop operations, while implementing reset is optional: It's default > implementation expires watchdog timer in one clock tick. > > Signed-off-by: Maxim Sloyko <[email protected]> > --- > > Changes in v1: > - Rename wdt_reset to wdt_expire_now > - Rename wdt_restart to wdt_reset > - Clarified function documentation in few cases > - Add Sandbox WDT driver and unit tests > > > --- > arch/sandbox/dts/test.dts | 4 ++ > arch/sandbox/include/asm/state.h | 9 ++++ > configs/sandbox_defconfig | 2 + > drivers/watchdog/Kconfig | 21 ++++++++ > drivers/watchdog/Makefile | 2 + > drivers/watchdog/sandbox_wdt.c | 76 +++++++++++++++++++++++++++ > drivers/watchdog/wdt-uclass.c | 72 ++++++++++++++++++++++++++ > include/dm/uclass-id.h | 1 + > include/wdt.h | 107 > +++++++++++++++++++++++++++++++++++++++ > test/dm/Makefile | 1 + > test/dm/wdt.c | 40 +++++++++++++++ > 11 files changed, 335 insertions(+) > create mode 100644 drivers/watchdog/sandbox_wdt.c > create mode 100644 drivers/watchdog/wdt-uclass.c > create mode 100644 include/wdt.h > create mode 100644 test/dm/wdt.c
Reviewed-by: Simon Glass <[email protected]> nits below [...] > diff --git a/drivers/watchdog/sandbox_wdt.c b/drivers/watchdog/sandbox_wdt.c > new file mode 100644 > index 0000000000..34d90bee7e > --- /dev/null > +++ b/drivers/watchdog/sandbox_wdt.c > @@ -0,0 +1,76 @@ > +/* > + * Copyright 2017 Google, Inc > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include <common.h> > +#include <dm.h> > +#include <asm/state.h> Put this after wt.h > +#include <wdt.h> > + > +DECLARE_GLOBAL_DATA_PTR; > + > +static int sandbox_wdt_start(struct udevice *dev, u64 timeout, ulong flags) > +{ > + struct sandbox_state *state = state_get_current(); > + > + state->wdt.counter = timeout; > + state->wdt.running = true; > + > + return 0; > +} > + > +static int sandbox_wdt_stop(struct udevice *dev) > +{ > + struct sandbox_state *state = state_get_current(); > + > + state->wdt.running = false; > + > + return 0; > +} > + > +static int sandbox_wdt_reset(struct udevice *dev) > +{ > + struct sandbox_state *state = state_get_current(); > + > + state->wdt.reset_count++; > + > + return 0; > +} > + > +static int sandbox_wdt_expire_now(struct udevice *dev, ulong flags) > +{ > + sandbox_wdt_start(dev, 1, flags); > + > + return 0; > +} > + > +static int sandbox_wdt_probe(struct udevice *dev) > +{ > + struct sandbox_state *state = state_get_current(); > + > + memset(&state->wdt, 0, sizeof(state->wdt)); Driver model does this for you so this function is not needed. > + > + return 0; > +} > + > +static const struct wdt_ops sandbox_wdt_ops = { > + .start = sandbox_wdt_start, > + .reset = sandbox_wdt_reset, > + .stop = sandbox_wdt_stop, > + .expire_now = sandbox_wdt_expire_now, > +}; > + > +static const struct udevice_id sandbox_wdt_ids[] = { > + { .compatible = "sandbox,wdt" }, > + {} > +}; > + > +U_BOOT_DRIVER(wdt_sandbox) = { > + .name = "wdt_sandbox", > + .id = UCLASS_WDT, > + .of_match = sandbox_wdt_ids, > + .ops = &sandbox_wdt_ops, > + .probe = sandbox_wdt_probe, > +}; [...] _______________________________________________ U-Boot mailing list [email protected] https://lists.denx.de/listinfo/u-boot

