2 * Copyright (c) 2016, NVIDIA CORPORATION.
4 * SPDX-License-Identifier: GPL-2.0
9 #include <reset-uclass.h>
11 #include <asm/reset.h>
13 #define SANDBOX_RESET_SIGNALS 101
15 struct sandbox_reset_signal {
19 struct sandbox_reset {
20 struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
23 static int sandbox_reset_request(struct reset_ctl *reset_ctl)
25 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
27 if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
33 static int sandbox_reset_free(struct reset_ctl *reset_ctl)
35 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
40 static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
42 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
44 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
46 sbr->signals[reset_ctl->id].asserted = true;
51 static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
53 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
55 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
57 sbr->signals[reset_ctl->id].asserted = false;
62 static int sandbox_reset_bind(struct udevice *dev)
64 debug("%s(dev=%p)\n", __func__, dev);
69 static int sandbox_reset_probe(struct udevice *dev)
71 debug("%s(dev=%p)\n", __func__, dev);
76 static const struct udevice_id sandbox_reset_ids[] = {
77 { .compatible = "sandbox,reset-ctl" },
81 struct reset_ops sandbox_reset_reset_ops = {
82 .request = sandbox_reset_request,
83 .free = sandbox_reset_free,
84 .rst_assert = sandbox_reset_assert,
85 .rst_deassert = sandbox_reset_deassert,
88 U_BOOT_DRIVER(sandbox_reset) = {
89 .name = "sandbox_reset",
91 .of_match = sandbox_reset_ids,
92 .bind = sandbox_reset_bind,
93 .probe = sandbox_reset_probe,
94 .priv_auto_alloc_size = sizeof(struct sandbox_reset),
95 .ops = &sandbox_reset_reset_ops,
98 int sandbox_reset_query(struct udevice *dev, unsigned long id)
100 struct sandbox_reset *sbr = dev_get_priv(dev);
102 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
104 if (id >= SANDBOX_RESET_SIGNALS)
107 return sbr->signals[id].asserted;