1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016, NVIDIA CORPORATION.
10 #include <reset-uclass.h>
12 #include <asm/reset.h>
14 #define SANDBOX_RESET_SIGNALS 101
16 struct sandbox_reset_signal {
21 struct sandbox_reset {
22 struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
25 static int sandbox_reset_request(struct reset_ctl *reset_ctl)
27 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
29 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
31 if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
34 sbr->signals[reset_ctl->id].requested = true;
38 static int sandbox_reset_free(struct reset_ctl *reset_ctl)
40 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
42 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
44 sbr->signals[reset_ctl->id].requested = false;
48 static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
50 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
52 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
54 sbr->signals[reset_ctl->id].asserted = true;
59 static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
61 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
63 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
65 sbr->signals[reset_ctl->id].asserted = false;
70 static int sandbox_reset_bind(struct udevice *dev)
72 debug("%s(dev=%p)\n", __func__, dev);
77 static int sandbox_reset_probe(struct udevice *dev)
79 debug("%s(dev=%p)\n", __func__, dev);
84 static const struct udevice_id sandbox_reset_ids[] = {
85 { .compatible = "sandbox,reset-ctl" },
89 struct reset_ops sandbox_reset_reset_ops = {
90 .request = sandbox_reset_request,
91 .rfree = sandbox_reset_free,
92 .rst_assert = sandbox_reset_assert,
93 .rst_deassert = sandbox_reset_deassert,
96 U_BOOT_DRIVER(sandbox_reset) = {
97 .name = "sandbox_reset",
99 .of_match = sandbox_reset_ids,
100 .bind = sandbox_reset_bind,
101 .probe = sandbox_reset_probe,
102 .priv_auto = sizeof(struct sandbox_reset),
103 .ops = &sandbox_reset_reset_ops,
106 int sandbox_reset_query(struct udevice *dev, unsigned long id)
108 struct sandbox_reset *sbr = dev_get_priv(dev);
110 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
112 if (id >= SANDBOX_RESET_SIGNALS)
115 return sbr->signals[id].asserted;
118 int sandbox_reset_is_requested(struct udevice *dev, unsigned long id)
120 struct sandbox_reset *sbr = dev_get_priv(dev);
122 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
124 if (id >= SANDBOX_RESET_SIGNALS)
127 return sbr->signals[id].requested;