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> 18 #include <tegra_platform.h> 19 #include <stdbool.h> 20 21 extern bool tegra_fake_system_suspend; 22 23 /******************************************************************************* 24 * Tegra194 SiP SMCs 25 ******************************************************************************/ 26 #define TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND 0xC2FFFE03U 27 28 /******************************************************************************* 29 * This function is responsible for handling all T194 SiP calls 30 ******************************************************************************/ 31 int32_t plat_sip_handler(uint32_t smc_fid, 32 uint64_t x1, 33 uint64_t x2, 34 uint64_t x3, 35 uint64_t x4, 36 const void *cookie, 37 void *handle, 38 uint64_t flags) 39 { 40 int32_t ret = -ENOTSUP; 41 42 (void)x1; 43 (void)x4; 44 (void)cookie; 45 (void)flags; 46 47 if (smc_fid == TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND) { 48 /* 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. 55 */ 56 if (tegra_platform_is_virt_dev_kit()) { 57 tegra_fake_system_suspend = true; 58 ret = 0; 59 } 60 } 61 62 return ret; 63 } 64