blob: a33d4533a82b9cc65fae8739e6f66072ccc7cfce [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren3017ab52016-09-13 10:45:58 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren3017ab52016-09-13 10:45:58 -06004 */
5
6#include <common.h>
7#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Simon Glass9bc15642020-02-03 07:36:16 -07009#include <malloc.h>
Stephen Warren3017ab52016-09-13 10:45:58 -060010#include <reset-uclass.h>
11#include <asm/arch/clock.h>
12#include <asm/arch-tegra/clk_rst.h>
13
14static int tegra_car_reset_request(struct reset_ctl *reset_ctl)
15{
16 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
17 reset_ctl->dev, reset_ctl->id);
18
19 /* PERIPH_ID_COUNT varies per SoC */
20 if (reset_ctl->id >= PERIPH_ID_COUNT)
21 return -EINVAL;
22
23 return 0;
24}
25
26static int tegra_car_reset_free(struct reset_ctl *reset_ctl)
27{
28 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
29 reset_ctl->dev, reset_ctl->id);
30
31 return 0;
32}
33
34static int tegra_car_reset_assert(struct reset_ctl *reset_ctl)
35{
36 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
37 reset_ctl->dev, reset_ctl->id);
38
39 reset_set_enable(reset_ctl->id, 1);
40
41 return 0;
42}
43
44static int tegra_car_reset_deassert(struct reset_ctl *reset_ctl)
45{
46 debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
47 reset_ctl->dev, reset_ctl->id);
48
49 reset_set_enable(reset_ctl->id, 0);
50
51 return 0;
52}
53
54struct reset_ops tegra_car_reset_ops = {
55 .request = tegra_car_reset_request,
Simon Glass1928cd42020-02-03 07:35:52 -070056 .rfree = tegra_car_reset_free,
Stephen Warren3017ab52016-09-13 10:45:58 -060057 .rst_assert = tegra_car_reset_assert,
58 .rst_deassert = tegra_car_reset_deassert,
59};
60
61static int tegra_car_reset_probe(struct udevice *dev)
62{
63 debug("%s(dev=%p)\n", __func__, dev);
64
65 return 0;
66}
67
68U_BOOT_DRIVER(tegra_car_reset) = {
69 .name = "tegra_car_reset",
70 .id = UCLASS_RESET,
71 .probe = tegra_car_reset_probe,
72 .ops = &tegra_car_reset_ops,
73};