1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
4 */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <log.h>
9 #include <malloc.h>
10 #include <misc.h>
11 #include <reset-uclass.h>
12 #include <asm/arch-tegra/bpmp_abi.h>
13
tegra186_reset_common(struct reset_ctl * reset_ctl,enum mrq_reset_commands cmd)14 static int tegra186_reset_common(struct reset_ctl *reset_ctl,
15 enum mrq_reset_commands cmd)
16 {
17 struct mrq_reset_request req;
18 int ret;
19
20 req.cmd = cmd;
21 req.reset_id = reset_ctl->id;
22
23 ret = misc_call(reset_ctl->dev->parent, MRQ_RESET, &req, sizeof(req),
24 NULL, 0);
25 if (ret < 0)
26 return ret;
27
28 return 0;
29 }
30
tegra186_reset_assert(struct reset_ctl * reset_ctl)31 static int tegra186_reset_assert(struct reset_ctl *reset_ctl)
32 {
33 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
34 reset_ctl->dev, reset_ctl->id);
35
36 return tegra186_reset_common(reset_ctl, CMD_RESET_ASSERT);
37 }
38
tegra186_reset_deassert(struct reset_ctl * reset_ctl)39 static int tegra186_reset_deassert(struct reset_ctl *reset_ctl)
40 {
41 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
42 reset_ctl->dev, reset_ctl->id);
43
44 return tegra186_reset_common(reset_ctl, CMD_RESET_DEASSERT);
45 }
46
47 struct reset_ops tegra186_reset_ops = {
48 .rst_assert = tegra186_reset_assert,
49 .rst_deassert = tegra186_reset_deassert,
50 };
51
52 U_BOOT_DRIVER(tegra186_reset) = {
53 .name = "tegra186_reset",
54 .id = UCLASS_RESET,
55 .ops = &tegra186_reset_ops,
56 };
57