blob: c25897d56b32a195a84fb73afcf6249d55979218 [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>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -07008#include <assert.h>
Steven Kao530b2172017-06-23 16:18:58 +08009#include <stdbool.h>
10#include <string.h>
11
12#include <arch_helpers.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070013#include <common/bl_common.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070014#include <common/debug.h>
Steven Kao530b2172017-06-23 16:18:58 +080015#include <context.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070016#include <denver.h>
Steven Kao530b2172017-06-23 16:18:58 +080017#include <lib/el3_runtime/context_mgmt.h>
18#include <lib/psci/psci.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070019#include <mce.h>
20#include <plat/common/platform.h>
Steven Kao530b2172017-06-23 16:18:58 +080021#include <se.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070022#include <smmu.h>
Tejal Kudav153ba222017-02-14 18:02:04 -080023#include <t194_nvg.h>
Varun Wadekare0c222f2017-11-10 13:23:34 -080024#include <tegra194_private.h>
Steven Kao530b2172017-06-23 16:18:58 +080025#include <tegra_platform.h>
26#include <tegra_private.h>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070027
Varun Wadekar362a6b22017-11-10 11:04:42 -080028extern void tegra194_cpu_reset_handler(void);
29extern uint32_t __tegra194_cpu_reset_handler_data,
30 __tegra194_cpu_reset_handler_end;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070031
32/* TZDRAM offset for saving SMMU context */
Varun Wadekar362a6b22017-11-10 11:04:42 -080033#define TEGRA194_SMMU_CTX_OFFSET 16U
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070034
35/* state id mask */
Varun Wadekar362a6b22017-11-10 11:04:42 -080036#define TEGRA194_STATE_ID_MASK 0xFU
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070037/* constants to get power state's wake time */
Varun Wadekar362a6b22017-11-10 11:04:42 -080038#define TEGRA194_WAKE_TIME_MASK 0x0FFFFFF0U
39#define TEGRA194_WAKE_TIME_SHIFT 4U
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070040/* default core wake mask for CPU_SUSPEND */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080041#define TEGRA194_CORE_WAKE_MASK 0x180cU
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070042
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080043static struct t19x_psci_percpu_data {
44 uint32_t wake_time;
45} __aligned(CACHE_WRITEBACK_GRANULE) t19x_percpu_data[PLATFORM_CORE_COUNT];
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070046
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -070047/*
48 * tegra_fake_system_suspend acts as a boolean var controlling whether
49 * we are going to take fake system suspend code or normal system suspend code
50 * path. This variable is set inside the sip call handlers, when the kernel
51 * requests an SIP call to set the suspend debug flags.
52 */
53bool tegra_fake_system_suspend;
54
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080055int32_t tegra_soc_validate_power_state(uint32_t power_state,
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070056 psci_power_state_t *req_state)
57{
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080058 uint8_t state_id = (uint8_t)psci_get_pstate_id(power_state) &
Varun Wadekar362a6b22017-11-10 11:04:42 -080059 TEGRA194_STATE_ID_MASK;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080060 uint32_t cpu = plat_my_core_pos();
61 int32_t ret = PSCI_E_SUCCESS;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070062
63 /* save the core wake time (in TSC ticks)*/
Varun Wadekar362a6b22017-11-10 11:04:42 -080064 t19x_percpu_data[cpu].wake_time = (power_state & TEGRA194_WAKE_TIME_MASK)
65 << TEGRA194_WAKE_TIME_SHIFT;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070066
67 /*
68 * Clean percpu_data[cpu] to DRAM. This needs to be done to ensure that
69 * the correct value is read in tegra_soc_pwr_domain_suspend(), which
70 * is called with caches disabled. It is possible to read a stale value
71 * from DRAM in that function, because the L2 cache is not flushed
72 * unless the cluster is entering CC6/CC7.
73 */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080074 clean_dcache_range((uint64_t)&t19x_percpu_data[cpu],
75 sizeof(t19x_percpu_data[cpu]));
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070076
77 /* Sanity check the requested state id */
78 switch (state_id) {
79 case PSTATE_ID_CORE_IDLE:
80 case PSTATE_ID_CORE_POWERDN:
81
82 /* Core powerdown request */
83 req_state->pwr_domain_state[MPIDR_AFFLVL0] = state_id;
84 req_state->pwr_domain_state[MPIDR_AFFLVL1] = state_id;
85
86 break;
87
88 default:
89 ERROR("%s: unsupported state id (%d)\n", __func__, state_id);
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080090 ret = PSCI_E_INVALID_PARAMS;
91 break;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070092 }
93
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080094 return ret;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070095}
96
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +080097int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -070098{
99 const plat_local_state_t *pwr_domain_state;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800100 uint8_t stateid_afflvl0, stateid_afflvl2;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700101 plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params();
102 uint64_t smmu_ctx_base;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700103 uint32_t val;
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700104 mce_cstate_info_t sc7_cstate_info = {
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800105 .cluster = (uint32_t)TEGRA_NVG_CLUSTER_CC6,
106 .system = (uint32_t)TEGRA_NVG_SYSTEM_SC7,
107 .system_state_force = 1U,
108 .update_wake_mask = 1U,
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700109 };
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800110 uint32_t cpu = plat_my_core_pos();
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700111 int32_t ret = 0;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700112
113 /* get the state ID */
114 pwr_domain_state = target_state->pwr_domain_state;
115 stateid_afflvl0 = pwr_domain_state[MPIDR_AFFLVL0] &
Varun Wadekar362a6b22017-11-10 11:04:42 -0800116 TEGRA194_STATE_ID_MASK;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700117 stateid_afflvl2 = pwr_domain_state[PLAT_MAX_PWR_LVL] &
Varun Wadekar362a6b22017-11-10 11:04:42 -0800118 TEGRA194_STATE_ID_MASK;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700119
120 if ((stateid_afflvl0 == PSTATE_ID_CORE_IDLE) ||
121 (stateid_afflvl0 == PSTATE_ID_CORE_POWERDN)) {
122
123 /* Enter CPU idle/powerdown */
Krishna Sitaramanc64afeb2017-01-23 16:15:44 -0800124 val = (stateid_afflvl0 == PSTATE_ID_CORE_IDLE) ?
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800125 (uint32_t)TEGRA_NVG_CORE_C6 : (uint32_t)TEGRA_NVG_CORE_C7;
126 ret = mce_command_handler((uint64_t)MCE_CMD_ENTER_CSTATE, (uint64_t)val,
Krishna Sitaramanc64afeb2017-01-23 16:15:44 -0800127 percpu_data[cpu].wake_time, 0);
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700128 assert(ret == 0);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700129
130 } else if (stateid_afflvl2 == PSTATE_ID_SOC_POWERDN) {
131
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700132 /* save 'Secure Boot' Processor Feature Config Register */
133 val = mmio_read_32(TEGRA_MISC_BASE + MISCREG_PFCFG);
Steven Kao4607f172017-10-23 18:35:14 +0800134 mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_SECURE_BOOTP_FCFG, val);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700135
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700136 /* save SMMU context */
137 smmu_ctx_base = params_from_bl2->tzdram_base +
Varun Wadekare0c222f2017-11-10 13:23:34 -0800138 tegra194_get_smmu_ctx_offset();
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700139 tegra_smmu_save_context((uintptr_t)smmu_ctx_base);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700140
Steven Kao530b2172017-06-23 16:18:58 +0800141 /*
142 * Suspend SE, RNG1 and PKA1 only on silcon and fpga,
143 * since VDK does not support atomic se ctx save
144 */
145 if (tegra_platform_is_silicon() || tegra_platform_is_fpga()) {
146 ret = tegra_se_suspend();
147 assert(ret == 0);
148 }
149
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700150 if (!tegra_fake_system_suspend) {
Vignesh Radhakrishnan0e2502f2017-04-10 15:07:39 -0700151
152 /* Prepare for system suspend */
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700153 mce_update_cstate_info(&sc7_cstate_info);
Vignesh Radhakrishnan0e2502f2017-04-10 15:07:39 -0700154
155 do {
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800156 val = (uint32_t)mce_command_handler(
157 (uint32_t)MCE_CMD_IS_SC7_ALLOWED,
158 (uint32_t)TEGRA_NVG_CORE_C7,
Vignesh Radhakrishnan0e2502f2017-04-10 15:07:39 -0700159 MCE_CORE_SLEEP_TIME_INFINITE,
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800160 0U);
161 } while (val == 0U);
Tejal Kudav153ba222017-02-14 18:02:04 -0800162
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800163 /* Instruct the MCE to enter system suspend state */
164 ret = mce_command_handler(
165 (uint64_t)MCE_CMD_ENTER_CSTATE,
166 (uint64_t)TEGRA_NVG_CORE_C7,
167 MCE_CORE_SLEEP_TIME_INFINITE,
168 0U);
169 assert(ret == 0);
Vignesh Radhakrishnan0e2502f2017-04-10 15:07:39 -0700170 }
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800171 } else {
172 ; /* do nothing */
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700173 }
174
175 return PSCI_E_SUCCESS;
176}
177
178/*******************************************************************************
179 * Platform handler to calculate the proper target power level at the
180 * specified affinity level
181 ******************************************************************************/
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800182plat_local_state_t tegra_soc_get_target_pwr_state(uint32_t lvl,
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700183 const plat_local_state_t *states,
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800184 uint32_t ncpu)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700185{
186 plat_local_state_t target = *states;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800187 int32_t cluster_powerdn = 1;
188 uint32_t core_pos = (uint32_t)read_mpidr() & MPIDR_CPU_MASK;
189 uint32_t num_cpus = ncpu, pos = 0;
Krishna Sitaramanc64afeb2017-01-23 16:15:44 -0800190 mce_cstate_info_t cstate_info = { 0 };
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700191
192 /* get the current core's power state */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800193 target = states[core_pos];
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700194
195 /* CPU suspend */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800196 if ((lvl == MPIDR_AFFLVL1) && (target == PSTATE_ID_CORE_POWERDN)) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700197
198 /* Program default wake mask */
Krishna Sitaramanc64afeb2017-01-23 16:15:44 -0800199 cstate_info.wake_mask = TEGRA194_CORE_WAKE_MASK;
200 cstate_info.update_wake_mask = 1;
201 mce_update_cstate_info(&cstate_info);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700202 }
203
204 /* CPU off */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800205 if ((lvl == MPIDR_AFFLVL1) && (target == PLAT_MAX_OFF_STATE)) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700206
207 /* find out the number of ON cpus in the cluster */
208 do {
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800209 target = states[pos];
210 if (target != PLAT_MAX_OFF_STATE) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700211 cluster_powerdn = 0;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800212 }
213 --num_cpus;
214 pos++;
215 } while (num_cpus != 0U);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700216
217 /* Enable cluster powerdn from last CPU in the cluster */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800218 if (cluster_powerdn != 0) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700219
Krishna Sitaraman74813f92017-07-14 13:51:44 -0700220 /* Enable CC6 */
221 /* todo */
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700222
Krishna Sitaraman74813f92017-07-14 13:51:44 -0700223 /* If cluster group needs to be railgated, request CG7 */
224 /* todo */
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700225
Krishna Sitaraman74813f92017-07-14 13:51:44 -0700226 /* Turn off wake mask */
227 cstate_info.update_wake_mask = 1U;
228 mce_update_cstate_info(&cstate_info);
229
230 } else {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700231 /* Turn off wake_mask */
Krishna Sitaraman74813f92017-07-14 13:51:44 -0700232 cstate_info.update_wake_mask = 1U;
233 mce_update_cstate_info(&cstate_info);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700234 }
235 }
236
237 /* System Suspend */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800238 if ((lvl == MPIDR_AFFLVL2) || (target == PSTATE_ID_SOC_POWERDN)) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700239 return PSTATE_ID_SOC_POWERDN;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800240 }
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700241
242 /* default state */
243 return PSCI_LOCAL_STATE_RUN;
244}
245
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800246int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700247{
248 const plat_local_state_t *pwr_domain_state =
249 target_state->pwr_domain_state;
250 plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params();
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800251 uint8_t stateid_afflvl2 = pwr_domain_state[PLAT_MAX_PWR_LVL] &
Varun Wadekar362a6b22017-11-10 11:04:42 -0800252 TEGRA194_STATE_ID_MASK;
Steven Kao55c2ce72016-12-23 15:51:32 +0800253 uint64_t val;
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700254 u_register_t ns_sctlr_el1;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700255
256 if (stateid_afflvl2 == PSTATE_ID_SOC_POWERDN) {
257 /*
258 * The TZRAM loses power when we enter system suspend. To
259 * allow graceful exit from system suspend, we need to copy
260 * BL3-1 over to TZDRAM.
261 */
262 val = params_from_bl2->tzdram_base +
Varun Wadekare0c222f2017-11-10 13:23:34 -0800263 tegra194_get_cpu_reset_handler_size();
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700264 memcpy((void *)(uintptr_t)val, (void *)(uintptr_t)BL31_BASE,
265 (uintptr_t)&__BL31_END__ - (uintptr_t)BL31_BASE);
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700266
Vignesh Radhakrishnand7a5c252017-05-25 16:27:42 -0700267 /*
268 * In fake suspend mode, ensure that the loopback procedure
269 * towards system suspend exit is started, instead of calling
270 * WFI. This is done by disabling both MMU's of EL1 & El3
271 * and calling tegra_secure_entrypoint().
272 */
273 if (tegra_fake_system_suspend) {
274
275 /*
276 * Disable EL1's MMU.
277 */
278 ns_sctlr_el1 = read_sctlr_el1();
279 ns_sctlr_el1 &= (~((u_register_t)SCTLR_M_BIT));
280 write_sctlr_el1(ns_sctlr_el1);
281
282 /*
283 * Disable MMU to power up the CPU in a "clean"
284 * state
285 */
286 disable_mmu_el3();
287 tegra_secure_entrypoint();
288 panic();
289 }
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700290 }
291
292 return PSCI_E_SUCCESS;
293}
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700294
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800295int32_t tegra_soc_pwr_domain_on(u_register_t mpidr)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700296{
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800297 uint64_t target_cpu = mpidr & MPIDR_CPU_MASK;
298 uint64_t target_cluster = (mpidr & MPIDR_CLUSTER_MASK) >>
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700299 MPIDR_AFFINITY_BITS;
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800300 int32_t ret = 0;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700301
Varun Wadekara4e0a812017-10-17 10:53:33 -0700302 if (target_cluster > ((uint32_t)PLATFORM_CLUSTER_COUNT - 1U)) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700303 ERROR("%s: unsupported CPU (0x%lx)\n", __func__ , mpidr);
304 return PSCI_E_NOT_PRESENT;
305 }
306
307 /* construct the target CPU # */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800308 target_cpu += (target_cluster << 1U);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700309
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800310 ret = mce_command_handler((uint64_t)MCE_CMD_ONLINE_CORE, target_cpu, 0U, 0U);
311 if (ret < 0) {
312 return PSCI_E_DENIED;
313 }
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700314
315 return PSCI_E_SUCCESS;
316}
317
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800318int32_t tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700319{
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800320 uint8_t stateid_afflvl2 = target_state->pwr_domain_state[PLAT_MAX_PWR_LVL];
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700321
322 /*
323 * Reset power state info for CPUs when onlining, we set
324 * deepest power when offlining a core but that may not be
325 * requested by non-secure sw which controls idle states. It
326 * will re-init this info from non-secure software when the
327 * core come online.
328 */
329
330 /*
331 * Check if we are exiting from deep sleep and restore SE
332 * context if we are.
333 */
334 if (stateid_afflvl2 == PSTATE_ID_SOC_POWERDN) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700335 /* Init SMMU */
Vignesh Radhakrishnan978887f2017-07-11 15:16:08 -0700336 tegra_smmu_init();
337
Steven Kao530b2172017-06-23 16:18:58 +0800338 /* Resume SE, RNG1 and PKA1 */
339 tegra_se_resume();
340
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700341 /*
342 * Reset power state info for the last core doing SC7
343 * entry and exit, we set deepest power state as CC7
344 * and SC7 for SC7 entry which may not be requested by
345 * non-secure SW which controls idle states.
346 */
347 }
348
349 return PSCI_E_SUCCESS;
350}
351
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800352int32_t tegra_soc_pwr_domain_off(const psci_power_state_t *target_state)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700353{
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800354 uint64_t impl = (read_midr() >> MIDR_IMPL_SHIFT) & MIDR_IMPL_MASK;
Krishna Sitaraman74813f92017-07-14 13:51:44 -0700355 int32_t ret = 0;
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700356
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800357 (void)target_state;
358
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700359 /* Disable Denver's DCO operations */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800360 if (impl == DENVER_IMPL) {
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700361 denver_disable_dco();
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800362 }
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700363
364 /* Turn off CPU */
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800365 ret = mce_command_handler((uint64_t)MCE_CMD_ENTER_CSTATE,
366 (uint64_t)TEGRA_NVG_CORE_C7, MCE_CORE_SLEEP_TIME_INFINITE, 0U);
Krishna Sitaraman74813f92017-07-14 13:51:44 -0700367 assert(ret == 0);
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700368
369 return PSCI_E_SUCCESS;
370}
371
372__dead2 void tegra_soc_prepare_system_off(void)
373{
374 /* System power off */
375
376 /* SC8 */
377
378 wfi();
379
380 /* wait for the system to power down */
381 for (;;) {
382 ;
383 }
384}
385
Anthony Zhou8bf6d4e2017-09-20 17:44:43 +0800386int32_t tegra_soc_prepare_system_reset(void)
Varun Wadekarecd6a5a2018-04-09 17:48:58 -0700387{
388 return PSCI_E_SUCCESS;
389}