Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <arch_helpers.h> |
| 9 | #include <assert.h> |
| 10 | #include <common/bl_common.h> |
| 11 | #include <lib/el3_runtime/context_mgmt.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <errno.h> |
| 14 | #include <mce.h> |
| 15 | #include <memctrl.h> |
| 16 | #include <common/runtime_svc.h> |
| 17 | #include <tegra_private.h> |
Vignesh Radhakrishnan | d7a5c25 | 2017-05-25 16:27:42 -0700 | [diff] [blame] | 18 | #include <tegra_platform.h> |
| 19 | #include <stdbool.h> |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 20 | |
Vignesh Radhakrishnan | d7a5c25 | 2017-05-25 16:27:42 -0700 | [diff] [blame] | 21 | extern bool tegra_fake_system_suspend; |
| 22 | |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 23 | /******************************************************************************* |
Varun Wadekar | 362a6b2 | 2017-11-10 11:04:42 -0800 | [diff] [blame] | 24 | * Tegra194 SiP SMCs |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 25 | ******************************************************************************/ |
Anthony Zhou | acdf411 | 2017-10-25 18:17:08 +0800 | [diff] [blame] | 26 | #define TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND 0xC2FFFE03U |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 27 | |
| 28 | /******************************************************************************* |
Varun Wadekar | 362a6b2 | 2017-11-10 11:04:42 -0800 | [diff] [blame] | 29 | * This function is responsible for handling all T194 SiP calls |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 30 | ******************************************************************************/ |
Anthony Zhou | 8bf6d4e | 2017-09-20 17:44:43 +0800 | [diff] [blame] | 31 | int32_t plat_sip_handler(uint32_t smc_fid, |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 32 | uint64_t x1, |
| 33 | uint64_t x2, |
| 34 | uint64_t x3, |
| 35 | uint64_t x4, |
Varun Wadekar | 5c5f78c | 2017-04-28 18:15:09 -0700 | [diff] [blame] | 36 | const void *cookie, |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 37 | void *handle, |
| 38 | uint64_t flags) |
| 39 | { |
Varun Wadekar | 7aa6c03 | 2017-10-19 12:02:17 -0700 | [diff] [blame] | 40 | int32_t ret = -ENOTSUP; |
Anthony Zhou | 8bf6d4e | 2017-09-20 17:44:43 +0800 | [diff] [blame] | 41 | |
Varun Wadekar | 7aa6c03 | 2017-10-19 12:02:17 -0700 | [diff] [blame] | 42 | (void)x1; |
Anthony Zhou | 8bf6d4e | 2017-09-20 17:44:43 +0800 | [diff] [blame] | 43 | (void)x4; |
| 44 | (void)cookie; |
| 45 | (void)flags; |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 46 | |
Varun Wadekar | 7aa6c03 | 2017-10-19 12:02:17 -0700 | [diff] [blame] | 47 | if (smc_fid == TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND) { |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 48 | /* |
Varun Wadekar | 7aa6c03 | 2017-10-19 12:02:17 -0700 | [diff] [blame] | 49 | * System suspend mode is set if the platform ATF is |
| 50 | * running on VDK and there is a debug SIP call. This mode |
| 51 | * ensures that the debug path is exercised, instead of |
| 52 | * regular code path to suit the pre-silicon platform needs. |
| 53 | * This includes replacing the call to WFI, with calls to |
| 54 | * system suspend exit procedures. |
Vignesh Radhakrishnan | d7a5c25 | 2017-05-25 16:27:42 -0700 | [diff] [blame] | 55 | */ |
| 56 | if (tegra_platform_is_virt_dev_kit()) { |
Vignesh Radhakrishnan | d7a5c25 | 2017-05-25 16:27:42 -0700 | [diff] [blame] | 57 | tegra_fake_system_suspend = true; |
Anthony Zhou | 8bf6d4e | 2017-09-20 17:44:43 +0800 | [diff] [blame] | 58 | ret = 0; |
Vignesh Radhakrishnan | d7a5c25 | 2017-05-25 16:27:42 -0700 | [diff] [blame] | 59 | } |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Anthony Zhou | 8bf6d4e | 2017-09-20 17:44:43 +0800 | [diff] [blame] | 62 | return ret; |
Varun Wadekar | ecd6a5a | 2018-04-09 17:48:58 -0700 | [diff] [blame] | 63 | } |