blob: 9927c063c3252796598b857da2cd57b7d60557ec [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warrenfccc9c52016-08-08 11:28:25 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warrenfccc9c52016-08-08 11:28:25 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <misc.h>
9#include <reset-uclass.h>
10#include <asm/arch-tegra/bpmp_abi.h>
11
12static int tegra186_reset_request(struct reset_ctl *reset_ctl)
13{
14 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
15 reset_ctl->dev, reset_ctl->id);
16
17 return 0;
18}
19
20static int tegra186_reset_free(struct reset_ctl *reset_ctl)
21{
22 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
23 reset_ctl->dev, reset_ctl->id);
24
25 return 0;
26}
27
28static int tegra186_reset_common(struct reset_ctl *reset_ctl,
29 enum mrq_reset_commands cmd)
30{
31 struct mrq_reset_request req;
32 int ret;
33
34 req.cmd = cmd;
35 req.reset_id = reset_ctl->id;
36
37 ret = misc_call(reset_ctl->dev->parent, MRQ_RESET, &req, sizeof(req),
38 NULL, 0);
39 if (ret < 0)
40 return ret;
41
42 return 0;
43}
44
45static int tegra186_reset_assert(struct reset_ctl *reset_ctl)
46{
47 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
48 reset_ctl->dev, reset_ctl->id);
49
50 return tegra186_reset_common(reset_ctl, CMD_RESET_ASSERT);
51}
52
53static int tegra186_reset_deassert(struct reset_ctl *reset_ctl)
54{
55 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
56 reset_ctl->dev, reset_ctl->id);
57
58 return tegra186_reset_common(reset_ctl, CMD_RESET_DEASSERT);
59}
60
61struct reset_ops tegra186_reset_ops = {
62 .request = tegra186_reset_request,
63 .free = tegra186_reset_free,
64 .rst_assert = tegra186_reset_assert,
65 .rst_deassert = tegra186_reset_deassert,
66};
67
68static int tegra186_reset_probe(struct udevice *dev)
69{
70 debug("%s(dev=%p)\n", __func__, dev);
71
72 return 0;
73}
74
75U_BOOT_DRIVER(tegra186_reset) = {
76 .name = "tegra186_reset",
77 .id = UCLASS_RESET,
78 .probe = tegra186_reset_probe,
79 .ops = &tegra186_reset_ops,
80};