blob: 8873358cd71dc3b6b96d06d274e1ec5bacd65bf8 [file] [log] [blame]
Varun Wadekarecd6a5a2018-04-09 17:48:58 -07001/*
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 Radhakrishnand7a5c252017-05-25 16:27:42 -070018#include <tegra_platform.h>
19#include <stdbool.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070020
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -070021extern bool tegra_fake_system_suspend;
22
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070023/*******************************************************************************
Varun Wadekar362a6b22017-11-10 11:04:42 -080024 * Tegra194 SiP SMCs
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070025 ******************************************************************************/
Anthony Zhouacdf4112017-10-25 18:17:08 +080026#define TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND 0xC2FFFE03U
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070027
28/*******************************************************************************
Varun Wadekar362a6b22017-11-10 11:04:42 -080029 * This function is responsible for handling all T194 SiP calls
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070030 ******************************************************************************/
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080031int32_t plat_sip_handler(uint32_t smc_fid,
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070032 uint64_t x1,
33 uint64_t x2,
34 uint64_t x3,
35 uint64_t x4,
Varun Wadekar5c5f78c2017-04-28 18:15:09 -070036 const void *cookie,
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070037 void *handle,
38 uint64_t flags)
39{
Varun Wadekar7aa6c032017-10-19 12:02:17 -070040 int32_t ret = -ENOTSUP;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080041
Varun Wadekar7aa6c032017-10-19 12:02:17 -070042 (void)x1;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080043 (void)x4;
44 (void)cookie;
45 (void)flags;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070046
Varun Wadekar7aa6c032017-10-19 12:02:17 -070047 if (smc_fid == TEGRA_SIP_ENABLE_FAKE_SYSTEM_SUSPEND) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070048 /*
Varun Wadekar7aa6c032017-10-19 12:02:17 -070049 * 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 Radhakrishnand7a5c252017-05-25 16:27:42 -070055 */
56 if (tegra_platform_is_virt_dev_kit()) {
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -070057 tegra_fake_system_suspend = true;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080058 ret = 0;
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -070059 }
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070060 }
61
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080062 return ret;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070063}