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 {
20 struct sandbox_reset {
21 struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
24 static int sandbox_reset_request(struct reset_ctl *reset_ctl)
26 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
28 if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
34 static int sandbox_reset_free(struct reset_ctl *reset_ctl)
36 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
41 static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
43 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
45 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
47 sbr->signals[reset_ctl->id].asserted = true;
52 static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
54 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
56 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
58 sbr->signals[reset_ctl->id].asserted = false;
63 static int sandbox_reset_bind(struct udevice *dev)
65 debug("%s(dev=%p)\n", __func__, dev);
70 static int sandbox_reset_probe(struct udevice *dev)
72 debug("%s(dev=%p)\n", __func__, dev);
77 static const struct udevice_id sandbox_reset_ids[] = {
78 { .compatible = "sandbox,reset-ctl" },
82 struct reset_ops sandbox_reset_reset_ops = {
83 .request = sandbox_reset_request,
84 .rfree = sandbox_reset_free,
85 .rst_assert = sandbox_reset_assert,
86 .rst_deassert = sandbox_reset_deassert,
89 U_BOOT_DRIVER(sandbox_reset) = {
90 .name = "sandbox_reset",
92 .of_match = sandbox_reset_ids,
93 .bind = sandbox_reset_bind,
94 .probe = sandbox_reset_probe,
95 .priv_auto_alloc_size = sizeof(struct sandbox_reset),
96 .ops = &sandbox_reset_reset_ops,
99 int sandbox_reset_query(struct udevice *dev, unsigned long id)
101 struct sandbox_reset *sbr = dev_get_priv(dev);
103 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
105 if (id >= SANDBOX_RESET_SIGNALS)
108 return sbr->signals[id].asserted;