Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | fe60f06 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | fe60f06 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 9 | #include <malloc.h> |
Stephen Warren | fe60f06 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 10 | #include <reset-uclass.h> |
| 11 | #include <asm/arch/clock.h> |
| 12 | #include <asm/arch-tegra/clk_rst.h> |
| 13 | |
| 14 | static 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 | |
| 26 | static 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 | |
| 34 | static 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 | |
| 44 | static 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 | |
| 54 | struct reset_ops tegra_car_reset_ops = { |
| 55 | .request = tegra_car_reset_request, |
Simon Glass | 94474b2 | 2020-02-03 07:35:52 -0700 | [diff] [blame] | 56 | .rfree = tegra_car_reset_free, |
Stephen Warren | fe60f06 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 57 | .rst_assert = tegra_car_reset_assert, |
| 58 | .rst_deassert = tegra_car_reset_deassert, |
| 59 | }; |
| 60 | |
| 61 | static int tegra_car_reset_probe(struct udevice *dev) |
| 62 | { |
| 63 | debug("%s(dev=%p)\n", __func__, dev); |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | U_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 | }; |