mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-13 14:53:06 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
98 lines
2.1 KiB
C
98 lines
2.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (c) 2015 Google, Inc
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <sysreset.h>
|
|
#include <asm/state.h>
|
|
#include <asm/test.h>
|
|
|
|
static int sandbox_warm_sysreset_request(struct udevice *dev,
|
|
enum sysreset_t type)
|
|
{
|
|
struct sandbox_state *state = state_get_current();
|
|
|
|
switch (type) {
|
|
case SYSRESET_WARM:
|
|
state->last_sysreset = type;
|
|
break;
|
|
default:
|
|
return -ENOSYS;
|
|
}
|
|
if (!state->sysreset_allowed[type])
|
|
return -EACCES;
|
|
|
|
return -EINPROGRESS;
|
|
}
|
|
|
|
static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
|
{
|
|
struct sandbox_state *state = state_get_current();
|
|
|
|
/*
|
|
* If we have a device tree, the device we created from platform data
|
|
* (see the U_BOOT_DEVICE() declaration below) should not do anything.
|
|
* If we are that device, return an error.
|
|
*/
|
|
if (state->fdt_fname && !dev_of_valid(dev))
|
|
return -ENODEV;
|
|
|
|
switch (type) {
|
|
case SYSRESET_COLD:
|
|
state->last_sysreset = type;
|
|
break;
|
|
case SYSRESET_POWER:
|
|
state->last_sysreset = type;
|
|
if (!state->sysreset_allowed[type])
|
|
return -EACCES;
|
|
sandbox_exit();
|
|
break;
|
|
default:
|
|
return -ENOSYS;
|
|
}
|
|
if (!state->sysreset_allowed[type])
|
|
return -EACCES;
|
|
|
|
return -EINPROGRESS;
|
|
}
|
|
|
|
static struct sysreset_ops sandbox_sysreset_ops = {
|
|
.request = sandbox_sysreset_request,
|
|
};
|
|
|
|
static const struct udevice_id sandbox_sysreset_ids[] = {
|
|
{ .compatible = "sandbox,reset" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(sysreset_sandbox) = {
|
|
.name = "sysreset_sandbox",
|
|
.id = UCLASS_SYSRESET,
|
|
.of_match = sandbox_sysreset_ids,
|
|
.ops = &sandbox_sysreset_ops,
|
|
};
|
|
|
|
static struct sysreset_ops sandbox_warm_sysreset_ops = {
|
|
.request = sandbox_warm_sysreset_request,
|
|
};
|
|
|
|
static const struct udevice_id sandbox_warm_sysreset_ids[] = {
|
|
{ .compatible = "sandbox,warm-reset" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(warm_sysreset_sandbox) = {
|
|
.name = "warm_sysreset_sandbox",
|
|
.id = UCLASS_SYSRESET,
|
|
.of_match = sandbox_warm_sysreset_ids,
|
|
.ops = &sandbox_warm_sysreset_ops,
|
|
};
|
|
|
|
/* This is here in case we don't have a device tree */
|
|
U_BOOT_DEVICE(sysreset_sandbox_non_fdt) = {
|
|
.name = "sysreset_sandbox",
|
|
};
|