1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 #include <asm/state.h>
14 static int sandbox_warm_sysreset_request(struct udevice *dev,
17 struct sandbox_state *state = state_get_current();
21 state->last_sysreset = type;
26 if (!state->sysreset_allowed[type])
32 int sandbox_warm_sysreset_get_status(struct udevice *dev, char *buf, int size)
34 strlcpy(buf, "Reset Status: WARM", size);
39 static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
41 struct sandbox_state *state = state_get_current();
44 * If we have a device tree, the device we created from platform data
45 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
46 * If we are that device, return an error.
48 if (state->fdt_fname && !dev_of_valid(dev))
53 state->last_sysreset = type;
56 state->last_sysreset = type;
57 if (!state->sysreset_allowed[type])
64 if (!state->sysreset_allowed[type])
70 int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size)
72 strlcpy(buf, "Reset Status: COLD", size);
77 static struct sysreset_ops sandbox_sysreset_ops = {
78 .request = sandbox_sysreset_request,
79 .get_status = sandbox_sysreset_get_status,
82 static const struct udevice_id sandbox_sysreset_ids[] = {
83 { .compatible = "sandbox,reset" },
87 U_BOOT_DRIVER(sysreset_sandbox) = {
88 .name = "sysreset_sandbox",
89 .id = UCLASS_SYSRESET,
90 .of_match = sandbox_sysreset_ids,
91 .ops = &sandbox_sysreset_ops,
94 static struct sysreset_ops sandbox_warm_sysreset_ops = {
95 .request = sandbox_warm_sysreset_request,
96 .get_status = sandbox_warm_sysreset_get_status,
99 static const struct udevice_id sandbox_warm_sysreset_ids[] = {
100 { .compatible = "sandbox,warm-reset" },
104 U_BOOT_DRIVER(warm_sysreset_sandbox) = {
105 .name = "warm_sysreset_sandbox",
106 .id = UCLASS_SYSRESET,
107 .of_match = sandbox_warm_sysreset_ids,
108 .ops = &sandbox_warm_sysreset_ops,
111 /* This is here in case we don't have a device tree */
112 U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = {
113 .name = "sysreset_sandbox",