blob: 9bc4a7e0ded5d52124fef291cfbd5e707037094b [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren4581b712016-06-17 09:43:59 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren4581b712016-06-17 09:43:59 -06004 */
5
6#include <common.h>
7#include <dm.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -06008#include <log.h>
Simon Glass336d4612020-02-03 07:36:16 -07009#include <malloc.h>
Stephen Warren4581b712016-06-17 09:43:59 -060010#include <reset.h>
11#include <asm/io.h>
12#include <asm/reset.h>
13
14struct sandbox_reset_test {
15 struct reset_ctl ctl;
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020016 struct reset_ctl_bulk bulk;
Stephen Warren4581b712016-06-17 09:43:59 -060017};
18
19int sandbox_reset_test_get(struct udevice *dev)
20{
21 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
22
23 return reset_get_by_name(dev, "test", &sbrt->ctl);
24}
25
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020026int sandbox_reset_test_get_bulk(struct udevice *dev)
27{
28 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
29
30 return reset_get_bulk(dev, &sbrt->bulk);
31}
32
Stephen Warren4581b712016-06-17 09:43:59 -060033int sandbox_reset_test_assert(struct udevice *dev)
34{
35 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
36
37 return reset_assert(&sbrt->ctl);
38}
39
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020040int sandbox_reset_test_assert_bulk(struct udevice *dev)
41{
42 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
43
44 return reset_assert_bulk(&sbrt->bulk);
45}
46
Stephen Warren4581b712016-06-17 09:43:59 -060047int sandbox_reset_test_deassert(struct udevice *dev)
48{
49 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
50
51 return reset_deassert(&sbrt->ctl);
52}
53
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020054int sandbox_reset_test_deassert_bulk(struct udevice *dev)
55{
56 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
57
58 return reset_deassert_bulk(&sbrt->bulk);
59}
60
Stephen Warren4581b712016-06-17 09:43:59 -060061int sandbox_reset_test_free(struct udevice *dev)
62{
63 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
64
65 return reset_free(&sbrt->ctl);
66}
67
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020068int sandbox_reset_test_release_bulk(struct udevice *dev)
69{
70 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
71
72 return reset_release_bulk(&sbrt->bulk);
73}
74
Stephen Warren4581b712016-06-17 09:43:59 -060075static const struct udevice_id sandbox_reset_test_ids[] = {
76 { .compatible = "sandbox,reset-ctl-test" },
77 { }
78};
79
80U_BOOT_DRIVER(sandbox_reset_test) = {
81 .name = "sandbox_reset_test",
82 .id = UCLASS_MISC,
83 .of_match = sandbox_reset_test_ids,
84 .priv_auto_alloc_size = sizeof(struct sandbox_reset_test),
85};