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 static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
34 struct sandbox_state *state = state_get_current();
37 * If we have a device tree, the device we created from platform data
38 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
39 * If we are that device, return an error.
41 if (state->fdt_fname && !dev_of_valid(dev))
46 state->last_sysreset = type;
49 state->last_sysreset = type;
50 if (!state->sysreset_allowed[type])
57 if (!state->sysreset_allowed[type])
63 static struct sysreset_ops sandbox_sysreset_ops = {
64 .request = sandbox_sysreset_request,
67 static const struct udevice_id sandbox_sysreset_ids[] = {
68 { .compatible = "sandbox,reset" },
72 U_BOOT_DRIVER(sysreset_sandbox) = {
73 .name = "sysreset_sandbox",
74 .id = UCLASS_SYSRESET,
75 .of_match = sandbox_sysreset_ids,
76 .ops = &sandbox_sysreset_ops,
79 static struct sysreset_ops sandbox_warm_sysreset_ops = {
80 .request = sandbox_warm_sysreset_request,
83 static const struct udevice_id sandbox_warm_sysreset_ids[] = {
84 { .compatible = "sandbox,warm-reset" },
88 U_BOOT_DRIVER(warm_sysreset_sandbox) = {
89 .name = "warm_sysreset_sandbox",
90 .id = UCLASS_SYSRESET,
91 .of_match = sandbox_warm_sysreset_ids,
92 .ops = &sandbox_warm_sysreset_ops,
95 /* This is here in case we don't have a device tree */
96 U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = {
97 .name = "sysreset_sandbox",