2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/state.h>
15 static int sandbox_warm_sysreset_request(struct udevice *dev,
18 struct sandbox_state *state = state_get_current();
22 state->last_sysreset = type;
27 if (!state->sysreset_allowed[type])
33 static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
35 struct sandbox_state *state = state_get_current();
38 * If we have a device tree, the device we created from platform data
39 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
40 * If we are that device, return an error.
42 if (state->fdt_fname && !dev_of_valid(dev))
47 state->last_sysreset = type;
50 state->last_sysreset = type;
51 if (!state->sysreset_allowed[type])
58 if (!state->sysreset_allowed[type])
64 static struct sysreset_ops sandbox_sysreset_ops = {
65 .request = sandbox_sysreset_request,
68 static const struct udevice_id sandbox_sysreset_ids[] = {
69 { .compatible = "sandbox,reset" },
73 U_BOOT_DRIVER(sysreset_sandbox) = {
74 .name = "sysreset_sandbox",
75 .id = UCLASS_SYSRESET,
76 .of_match = sandbox_sysreset_ids,
77 .ops = &sandbox_sysreset_ops,
80 static struct sysreset_ops sandbox_warm_sysreset_ops = {
81 .request = sandbox_warm_sysreset_request,
84 static const struct udevice_id sandbox_warm_sysreset_ids[] = {
85 { .compatible = "sandbox,warm-reset" },
89 U_BOOT_DRIVER(warm_sysreset_sandbox) = {
90 .name = "warm_sysreset_sandbox",
91 .id = UCLASS_SYSRESET,
92 .of_match = sandbox_warm_sysreset_ids,
93 .ops = &sandbox_warm_sysreset_ops,
96 /* This is here in case we don't have a device tree */
97 U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = {
98 .name = "sysreset_sandbox",