1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016, NVIDIA CORPORATION.
12 #include <asm/reset.h>
13 #include <linux/err.h>
15 struct sandbox_reset_test {
17 struct reset_ctl_bulk bulk;
19 struct reset_ctl *ctlp;
20 struct reset_ctl_bulk *bulkp;
23 int sandbox_reset_test_get(struct udevice *dev)
25 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
27 sbrt->ctlp = &sbrt->ctl;
28 return reset_get_by_name(dev, "test", &sbrt->ctl);
31 int sandbox_reset_test_get_devm(struct udevice *dev)
33 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
36 r = devm_reset_control_get(dev, "not-a-valid-reset-ctl");
40 r = devm_reset_control_get_optional(dev, "not-a-valid-reset-ctl");
44 sbrt->ctlp = devm_reset_control_get(dev, "test");
45 if (IS_ERR(sbrt->ctlp))
46 return PTR_ERR(sbrt->ctlp);
51 int sandbox_reset_test_get_bulk(struct udevice *dev)
53 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
55 sbrt->bulkp = &sbrt->bulk;
56 return reset_get_bulk(dev, &sbrt->bulk);
59 int sandbox_reset_test_get_bulk_devm(struct udevice *dev)
61 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
62 struct reset_ctl_bulk *r;
64 r = devm_reset_bulk_get_optional(dev);
72 int sandbox_reset_test_assert(struct udevice *dev)
74 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
76 return reset_assert(sbrt->ctlp);
79 int sandbox_reset_test_assert_bulk(struct udevice *dev)
81 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
83 return reset_assert_bulk(sbrt->bulkp);
86 int sandbox_reset_test_deassert(struct udevice *dev)
88 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
90 return reset_deassert(sbrt->ctlp);
93 int sandbox_reset_test_deassert_bulk(struct udevice *dev)
95 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
97 return reset_deassert_bulk(sbrt->bulkp);
100 int sandbox_reset_test_free(struct udevice *dev)
102 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
104 return reset_free(sbrt->ctlp);
107 int sandbox_reset_test_release_bulk(struct udevice *dev)
109 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
111 return reset_release_bulk(sbrt->bulkp);
114 static const struct udevice_id sandbox_reset_test_ids[] = {
115 { .compatible = "sandbox,reset-ctl-test" },
119 U_BOOT_DRIVER(sandbox_reset_test) = {
120 .name = "sandbox_reset_test",
122 .of_match = sandbox_reset_test_ids,
123 .priv_auto_alloc_size = sizeof(struct sandbox_reset_test),