2 * Copyright (C) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
13 #include <dm/device-internal.h>
16 #include <linux/err.h>
18 int sysreset_request(struct udevice *dev, enum sysreset_t type)
20 struct sysreset_ops *ops = sysreset_get_ops(dev);
25 return ops->request(dev, type);
28 int sysreset_walk(enum sysreset_t type)
33 while (ret != -EINPROGRESS && type < SYSRESET_COUNT) {
34 for (uclass_first_device(UCLASS_SYSRESET, &dev);
36 uclass_next_device(&dev)) {
37 ret = sysreset_request(dev, type);
38 if (ret == -EINPROGRESS)
47 void sysreset_walk_halt(enum sysreset_t type)
51 ret = sysreset_walk(type);
53 /* Wait for the reset to take effect */
54 if (ret == -EINPROGRESS)
57 /* Still no reset? Give up */
58 debug("System reset not supported on this platform\n");
63 * reset_cpu() - calls sysreset_walk(SYSRESET_WARM)
65 void reset_cpu(ulong addr)
67 sysreset_walk_halt(SYSRESET_WARM);
71 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
73 sysreset_walk_halt(SYSRESET_WARM);
78 UCLASS_DRIVER(sysreset) = {
79 .id = UCLASS_SYSRESET,