2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-06-17 15:43:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016, NVIDIA CORPORATION.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2016-06-17 15:43:59 +00:00
|
|
|
#include <reset-uclass.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/reset.h>
|
|
|
|
|
2018-04-03 09:40:51 +00:00
|
|
|
#define SANDBOX_RESET_SIGNALS 101
|
2016-06-17 15:43:59 +00:00
|
|
|
|
|
|
|
struct sandbox_reset_signal {
|
|
|
|
bool asserted;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sandbox_reset {
|
|
|
|
struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
|
|
|
|
};
|
|
|
|
|
|
|
|
static int sandbox_reset_request(struct reset_ctl *reset_ctl)
|
|
|
|
{
|
|
|
|
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
|
|
|
|
|
|
|
|
if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sandbox_reset_free(struct reset_ctl *reset_ctl)
|
|
|
|
{
|
|
|
|
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
|
|
|
|
{
|
|
|
|
struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
|
|
|
|
|
|
|
|
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
|
|
|
|
|
|
|
|
sbr->signals[reset_ctl->id].asserted = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
|
|
|
|
{
|
|
|
|
struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
|
|
|
|
|
|
|
|
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
|
|
|
|
|
|
|
|
sbr->signals[reset_ctl->id].asserted = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sandbox_reset_bind(struct udevice *dev)
|
|
|
|
{
|
|
|
|
debug("%s(dev=%p)\n", __func__, dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sandbox_reset_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
debug("%s(dev=%p)\n", __func__, dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct udevice_id sandbox_reset_ids[] = {
|
|
|
|
{ .compatible = "sandbox,reset-ctl" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct reset_ops sandbox_reset_reset_ops = {
|
|
|
|
.request = sandbox_reset_request,
|
2020-02-03 14:35:52 +00:00
|
|
|
.rfree = sandbox_reset_free,
|
2016-06-17 15:43:59 +00:00
|
|
|
.rst_assert = sandbox_reset_assert,
|
|
|
|
.rst_deassert = sandbox_reset_deassert,
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(sandbox_reset) = {
|
|
|
|
.name = "sandbox_reset",
|
|
|
|
.id = UCLASS_RESET,
|
|
|
|
.of_match = sandbox_reset_ids,
|
|
|
|
.bind = sandbox_reset_bind,
|
|
|
|
.probe = sandbox_reset_probe,
|
|
|
|
.priv_auto_alloc_size = sizeof(struct sandbox_reset),
|
|
|
|
.ops = &sandbox_reset_reset_ops,
|
|
|
|
};
|
|
|
|
|
|
|
|
int sandbox_reset_query(struct udevice *dev, unsigned long id)
|
|
|
|
{
|
|
|
|
struct sandbox_reset *sbr = dev_get_priv(dev);
|
|
|
|
|
|
|
|
debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
|
|
|
|
|
|
|
|
if (id >= SANDBOX_RESET_SIGNALS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return sbr->signals[id].asserted;
|
|
|
|
}
|