]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/reset/sandbox-reset.c
gpio: mxc: add i.MX8M support
[people/ms/u-boot.git] / drivers / reset / sandbox-reset.c
1 /*
2 * Copyright (c) 2016, NVIDIA CORPORATION.
3 *
4 * SPDX-License-Identifier: GPL-2.0
5 */
6
7 #include <common.h>
8 #include <dm.h>
9 #include <reset-uclass.h>
10 #include <asm/io.h>
11 #include <asm/reset.h>
12
13 #define SANDBOX_RESET_SIGNALS 3
14
15 struct sandbox_reset_signal {
16 bool asserted;
17 };
18
19 struct sandbox_reset {
20 struct sandbox_reset_signal signals[SANDBOX_RESET_SIGNALS];
21 };
22
23 static int sandbox_reset_request(struct reset_ctl *reset_ctl)
24 {
25 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
26
27 if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
28 return -EINVAL;
29
30 return 0;
31 }
32
33 static int sandbox_reset_free(struct reset_ctl *reset_ctl)
34 {
35 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
36
37 return 0;
38 }
39
40 static int sandbox_reset_assert(struct reset_ctl *reset_ctl)
41 {
42 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
43
44 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
45
46 sbr->signals[reset_ctl->id].asserted = true;
47
48 return 0;
49 }
50
51 static int sandbox_reset_deassert(struct reset_ctl *reset_ctl)
52 {
53 struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
54
55 debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
56
57 sbr->signals[reset_ctl->id].asserted = false;
58
59 return 0;
60 }
61
62 static int sandbox_reset_bind(struct udevice *dev)
63 {
64 debug("%s(dev=%p)\n", __func__, dev);
65
66 return 0;
67 }
68
69 static int sandbox_reset_probe(struct udevice *dev)
70 {
71 debug("%s(dev=%p)\n", __func__, dev);
72
73 return 0;
74 }
75
76 static const struct udevice_id sandbox_reset_ids[] = {
77 { .compatible = "sandbox,reset-ctl" },
78 { }
79 };
80
81 struct reset_ops sandbox_reset_reset_ops = {
82 .request = sandbox_reset_request,
83 .free = sandbox_reset_free,
84 .rst_assert = sandbox_reset_assert,
85 .rst_deassert = sandbox_reset_deassert,
86 };
87
88 U_BOOT_DRIVER(sandbox_reset) = {
89 .name = "sandbox_reset",
90 .id = UCLASS_RESET,
91 .of_match = sandbox_reset_ids,
92 .bind = sandbox_reset_bind,
93 .probe = sandbox_reset_probe,
94 .priv_auto_alloc_size = sizeof(struct sandbox_reset),
95 .ops = &sandbox_reset_reset_ops,
96 };
97
98 int sandbox_reset_query(struct udevice *dev, unsigned long id)
99 {
100 struct sandbox_reset *sbr = dev_get_priv(dev);
101
102 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
103
104 if (id >= SANDBOX_RESET_SIGNALS)
105 return -EINVAL;
106
107 return sbr->signals[id].asserted;
108 }