blob: ae79be0730dab90b4624f567d34f77adc5a3c1cf [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren6488e642016-06-17 09:43:59 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren6488e642016-06-17 09:43:59 -06004 */
5
6#include <common.h>
7#include <dm.h>
Simon Glass9bc15642020-02-03 07:36:16 -07008#include <malloc.h>
Stephen Warren6488e642016-06-17 09:43:59 -06009#include <reset.h>
10#include <asm/io.h>
11#include <asm/reset.h>
12
13struct sandbox_reset_test {
14 struct reset_ctl ctl;
Neil Armstrong20c633d2018-04-03 11:40:51 +020015 struct reset_ctl_bulk bulk;
Stephen Warren6488e642016-06-17 09:43:59 -060016};
17
18int sandbox_reset_test_get(struct udevice *dev)
19{
20 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
21
22 return reset_get_by_name(dev, "test", &sbrt->ctl);
23}
24
Neil Armstrong20c633d2018-04-03 11:40:51 +020025int sandbox_reset_test_get_bulk(struct udevice *dev)
26{
27 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
28
29 return reset_get_bulk(dev, &sbrt->bulk);
30}
31
Stephen Warren6488e642016-06-17 09:43:59 -060032int sandbox_reset_test_assert(struct udevice *dev)
33{
34 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
35
36 return reset_assert(&sbrt->ctl);
37}
38
Neil Armstrong20c633d2018-04-03 11:40:51 +020039int sandbox_reset_test_assert_bulk(struct udevice *dev)
40{
41 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
42
43 return reset_assert_bulk(&sbrt->bulk);
44}
45
Stephen Warren6488e642016-06-17 09:43:59 -060046int sandbox_reset_test_deassert(struct udevice *dev)
47{
48 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
49
50 return reset_deassert(&sbrt->ctl);
51}
52
Neil Armstrong20c633d2018-04-03 11:40:51 +020053int sandbox_reset_test_deassert_bulk(struct udevice *dev)
54{
55 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
56
57 return reset_deassert_bulk(&sbrt->bulk);
58}
59
Stephen Warren6488e642016-06-17 09:43:59 -060060int sandbox_reset_test_free(struct udevice *dev)
61{
62 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
63
64 return reset_free(&sbrt->ctl);
65}
66
Neil Armstrong20c633d2018-04-03 11:40:51 +020067int sandbox_reset_test_release_bulk(struct udevice *dev)
68{
69 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
70
71 return reset_release_bulk(&sbrt->bulk);
72}
73
Stephen Warren6488e642016-06-17 09:43:59 -060074static const struct udevice_id sandbox_reset_test_ids[] = {
75 { .compatible = "sandbox,reset-ctl-test" },
76 { }
77};
78
79U_BOOT_DRIVER(sandbox_reset_test) = {
80 .name = "sandbox_reset_test",
81 .id = UCLASS_MISC,
82 .of_match = sandbox_reset_test_ids,
83 .priv_auto_alloc_size = sizeof(struct sandbox_reset_test),
84};