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