1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016, NVIDIA CORPORATION.
8 #include <reset-uclass.h>
10 #include <asm/reset.h>
12 #define SANDBOX_RESET_SIGNALS 101
14 struct sandbox_reset_signal {
18 struct sandbox_reset {
19 struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
22 static int sandbox_reset_request(struct reset_ctl *reset_ctl)
24 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
26 if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
32 static int sandbox_reset_free(struct reset_ctl *reset_ctl)
34 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
39 static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
41 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
43 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
45 sbr->signals[reset_ctl->id].asserted = true;
50 static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
52 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
54 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
56 sbr->signals[reset_ctl->id].asserted = false;
61 static int sandbox_reset_bind(struct udevice *dev)
63 debug("%s(dev=%p)\n", __func__, dev);
68 static int sandbox_reset_probe(struct udevice *dev)
70 debug("%s(dev=%p)\n", __func__, dev);
75 static const struct udevice_id sandbox_reset_ids[] = {
76 { .compatible = "sandbox,reset-ctl" },
80 struct reset_ops sandbox_reset_reset_ops = {
81 .request = sandbox_reset_request,
82 .free = sandbox_reset_free,
83 .rst_assert = sandbox_reset_assert,
84 .rst_deassert = sandbox_reset_deassert,
87 U_BOOT_DRIVER(sandbox_reset) = {
88 .name = "sandbox_reset",
90 .of_match = sandbox_reset_ids,
91 .bind = sandbox_reset_bind,
92 .probe = sandbox_reset_probe,
93 .priv_auto_alloc_size = sizeof(struct sandbox_reset),
94 .ops = &sandbox_reset_reset_ops,
97 int sandbox_reset_query(struct udevice *dev, unsigned long id)
99 struct sandbox_reset *sbr = dev_get_priv(dev);
101 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
103 if (id >= SANDBOX_RESET_SIGNALS)
106 return sbr->signals[id].asserted;