Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 6 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 7 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 8 | #include <malloc.h> |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 9 | #include <reset-uclass.h> |
| 10 | #include <asm/arch/clock.h> |
| 11 | #include <asm/arch-tegra/clk_rst.h> |
| 12 | |
| 13 | static int tegra_car_reset_request(struct reset_ctl *reset_ctl) |
| 14 | { |
| 15 | debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl, |
| 16 | reset_ctl->dev, reset_ctl->id); |
| 17 | |
| 18 | /* PERIPH_ID_COUNT varies per SoC */ |
| 19 | if (reset_ctl->id >= PERIPH_ID_COUNT) |
| 20 | return -EINVAL; |
| 21 | |
| 22 | return 0; |
| 23 | } |
| 24 | |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 25 | static int tegra_car_reset_assert(struct reset_ctl *reset_ctl) |
| 26 | { |
| 27 | debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl, |
| 28 | reset_ctl->dev, reset_ctl->id); |
| 29 | |
| 30 | reset_set_enable(reset_ctl->id, 1); |
| 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | static int tegra_car_reset_deassert(struct reset_ctl *reset_ctl) |
| 36 | { |
| 37 | debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl, |
| 38 | reset_ctl->dev, reset_ctl->id); |
| 39 | |
| 40 | reset_set_enable(reset_ctl->id, 0); |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | struct reset_ops tegra_car_reset_ops = { |
| 46 | .request = tegra_car_reset_request, |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 47 | .rst_assert = tegra_car_reset_assert, |
| 48 | .rst_deassert = tegra_car_reset_deassert, |
| 49 | }; |
| 50 | |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 51 | U_BOOT_DRIVER(tegra_car_reset) = { |
| 52 | .name = "tegra_car_reset", |
| 53 | .id = UCLASS_RESET, |
Stephen Warren | 3017ab5 | 2016-09-13 10:45:58 -0600 | [diff] [blame] | 54 | .ops = &tegra_car_reset_ops, |
| 55 | }; |