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 DECLARE_GLOBAL_DATA_PTR;
17 static int sandbox_warm_sysreset_request(struct udevice *dev,
20 struct sandbox_state *state = state_get_current();
24 state->last_sysreset = type;
29 if (!state->sysreset_allowed[type])
35 static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
37 struct sandbox_state *state = state_get_current();
40 * If we have a device tree, the device we created from platform data
41 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
42 * If we are that device, return an error.
44 if (state->fdt_fname && !dev_of_valid(dev))
49 state->last_sysreset = type;
52 state->last_sysreset = type;
53 if (!state->sysreset_allowed[type])
60 if (!state->sysreset_allowed[type])
66 static struct sysreset_ops sandbox_sysreset_ops = {
67 .request = sandbox_sysreset_request,
70 static const struct udevice_id sandbox_sysreset_ids[] = {
71 { .compatible = "sandbox,reset" },
75 U_BOOT_DRIVER(sysreset_sandbox) = {
76 .name = "sysreset_sandbox",
77 .id = UCLASS_SYSRESET,
78 .of_match = sandbox_sysreset_ids,
79 .ops = &sandbox_sysreset_ops,
82 static struct sysreset_ops sandbox_warm_sysreset_ops = {
83 .request = sandbox_warm_sysreset_request,
86 static const struct udevice_id sandbox_warm_sysreset_ids[] = {
87 { .compatible = "sandbox,warm-reset" },
91 U_BOOT_DRIVER(warm_sysreset_sandbox) = {
92 .name = "warm_sysreset_sandbox",
93 .id = UCLASS_SYSRESET,
94 .of_match = sandbox_warm_sysreset_ids,
95 .ops = &sandbox_warm_sysreset_ops,
98 /* This is here in case we don't have a device tree */
99 U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = {
100 .name = "sysreset_sandbox",