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_reset_request(struct udevice *dev, enum reset_t type)
19 struct sandbox_state *state = state_get_current();
23 state->last_reset = type;
28 if (!state->reset_allowed[type])
34 static int sandbox_reset_request(struct udevice *dev, enum reset_t type)
36 struct sandbox_state *state = state_get_current();
39 * If we have a device tree, the device we created from platform data
40 * (see the U_BOOT_DEVICE() declaration below) should not do anything.
41 * If we are that device, return an error.
43 if (gd->fdt_blob && dev->of_offset == -1)
48 state->last_reset = type;
51 state->last_reset = type;
52 if (!state->reset_allowed[type])
59 if (!state->reset_allowed[type])
65 static struct reset_ops sandbox_reset_ops = {
66 .request = sandbox_reset_request,
69 static const struct udevice_id sandbox_reset_ids[] = {
70 { .compatible = "sandbox,reset" },
74 U_BOOT_DRIVER(reset_sandbox) = {
75 .name = "reset_sandbox",
77 .of_match = sandbox_reset_ids,
78 .ops = &sandbox_reset_ops,
81 static struct reset_ops sandbox_warm_reset_ops = {
82 .request = sandbox_warm_reset_request,
85 static const struct udevice_id sandbox_warm_reset_ids[] = {
86 { .compatible = "sandbox,warm-reset" },
90 U_BOOT_DRIVER(warm_reset_sandbox) = {
91 .name = "warm_reset_sandbox",
93 .of_match = sandbox_warm_reset_ids,
94 .ops = &sandbox_warm_reset_ops,
97 /* This is here in case we don't have a device tree */
98 U_BOOT_DEVICE(reset_sandbox_non_fdt) = {
99 .name = "reset_sandbox",