blob: 2805272712c0c8f642f7f5b076196a090b432864 [file] [log] [blame]
Varun Wadekarb316e242015-05-19 16:48:04 +05301/*
Vignesh Radhakrishnanb4a72942017-03-03 10:58:05 -08002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Varun Wadekarb316e242015-05-19 16:48:04 +05303 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekarb316e242015-05-19 16:48:04 +05305 */
6
Varun Wadekarb316e242015-05-19 16:48:04 +05307#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <platform_def.h>
10
11#include <arch_helpers.h>
12#include <common/bl_common.h>
13#include <common/debug.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053014#include <context.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000015#include <drivers/console.h>
16#include <lib/el3_runtime/context_mgmt.h>
17#include <lib/mmio.h>
18#include <lib/psci/psci.h>
19#include <plat/common/platform.h>
20
Varun Wadekarb316e242015-05-19 16:48:04 +053021#include <memctrl.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053022#include <pmc.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053023#include <tegra_def.h>
Harvey Hsieh9e083c72017-04-10 16:20:32 +080024#include <tegra_platform.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053025#include <tegra_private.h>
26
27extern uint64_t tegra_bl31_phys_base;
Varun Wadekara78bb1b2015-08-07 10:03:00 +053028extern uint64_t tegra_sec_entry_point;
Varun Wadekara2c6be62016-08-01 22:16:21 -070029extern uint64_t tegra_console_base;
Varun Wadekarb316e242015-05-19 16:48:04 +053030
31/*
Vignesh Radhakrishnanb4a72942017-03-03 10:58:05 -080032 * tegra_fake_system_suspend acts as a boolean var controlling whether
33 * we are going to take fake system suspend code or normal system suspend code
34 * path. This variable is set inside the sip call handlers,when the kernel
35 * requests a SIP call to set the suspend debug flags.
36 */
37uint8_t tegra_fake_system_suspend;
38
39/*
Varun Wadekarb316e242015-05-19 16:48:04 +053040 * The following platform setup functions are weakly defined. They
41 * provide typical implementations that will be overridden by a SoC.
42 */
Varun Wadekar99782e82017-07-05 17:44:12 -070043#pragma weak tegra_soc_pwr_domain_suspend_pwrdown_early
Varun Wadekara78bb1b2015-08-07 10:03:00 +053044#pragma weak tegra_soc_pwr_domain_suspend
45#pragma weak tegra_soc_pwr_domain_on
46#pragma weak tegra_soc_pwr_domain_off
47#pragma weak tegra_soc_pwr_domain_on_finish
Varun Wadekard22429d2016-03-18 14:35:28 -070048#pragma weak tegra_soc_pwr_domain_power_down_wfi
Varun Wadekar8b82fae2015-11-09 17:39:28 -080049#pragma weak tegra_soc_prepare_system_reset
Varun Wadekare5caeed2016-01-07 14:04:21 -080050#pragma weak tegra_soc_prepare_system_off
Varun Wadekarf2aa1be2016-06-07 12:00:06 -070051#pragma weak tegra_soc_get_target_pwr_state
Varun Wadekarb316e242015-05-19 16:48:04 +053052
Anthony Zhou85a8fa02017-03-22 14:42:42 +080053int32_t tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
Varun Wadekar99782e82017-07-05 17:44:12 -070054{
55 return PSCI_E_NOT_SUPPORTED;
56}
57
Anthony Zhou85a8fa02017-03-22 14:42:42 +080058int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +053059{
Anthony Zhou85a8fa02017-03-22 14:42:42 +080060 (void)target_state;
Varun Wadekarb316e242015-05-19 16:48:04 +053061 return PSCI_E_NOT_SUPPORTED;
62}
63
Anthony Zhou85a8fa02017-03-22 14:42:42 +080064int32_t tegra_soc_pwr_domain_on(u_register_t mpidr)
Varun Wadekarb316e242015-05-19 16:48:04 +053065{
Anthony Zhou85a8fa02017-03-22 14:42:42 +080066 (void)mpidr;
Varun Wadekarb316e242015-05-19 16:48:04 +053067 return PSCI_E_SUCCESS;
68}
69
Anthony Zhou85a8fa02017-03-22 14:42:42 +080070int32_t tegra_soc_pwr_domain_off(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +053071{
Anthony Zhou85a8fa02017-03-22 14:42:42 +080072 (void)target_state;
Varun Wadekarb316e242015-05-19 16:48:04 +053073 return PSCI_E_SUCCESS;
74}
75
Anthony Zhou85a8fa02017-03-22 14:42:42 +080076int32_t tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +053077{
Anthony Zhou85a8fa02017-03-22 14:42:42 +080078 (void)target_state;
Varun Wadekarb316e242015-05-19 16:48:04 +053079 return PSCI_E_SUCCESS;
80}
81
Anthony Zhou85a8fa02017-03-22 14:42:42 +080082int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state)
Varun Wadekard22429d2016-03-18 14:35:28 -070083{
Anthony Zhou85a8fa02017-03-22 14:42:42 +080084 (void)target_state;
Varun Wadekard22429d2016-03-18 14:35:28 -070085 return PSCI_E_SUCCESS;
86}
87
Anthony Zhou85a8fa02017-03-22 14:42:42 +080088int32_t tegra_soc_prepare_system_reset(void)
Varun Wadekar8b82fae2015-11-09 17:39:28 -080089{
90 return PSCI_E_SUCCESS;
91}
92
Varun Wadekare5caeed2016-01-07 14:04:21 -080093__dead2 void tegra_soc_prepare_system_off(void)
94{
95 ERROR("Tegra System Off: operation not handled.\n");
96 panic();
97}
98
Anthony Zhou85a8fa02017-03-22 14:42:42 +080099plat_local_state_t tegra_soc_get_target_pwr_state(uint32_t lvl,
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700100 const plat_local_state_t *states,
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800101 uint32_t ncpu)
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700102{
Varun Wadekar14eaede2016-09-01 14:51:59 -0700103 plat_local_state_t target = PLAT_MAX_OFF_STATE, temp;
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800104 uint32_t num_cpu = ncpu;
105 const plat_local_state_t *local_state = states;
106
107 (void)lvl;
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700108
Anthony Zhou4408e882017-07-07 14:29:51 +0800109 assert(ncpu != 0U);
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700110
111 do {
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800112 temp = *local_state;
113 if ((temp < target)) {
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700114 target = temp;
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800115 }
116 --num_cpu;
117 local_state++;
118 } while (num_cpu != 0U);
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700119
120 return target;
121}
122
Varun Wadekarb316e242015-05-19 16:48:04 +0530123/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530124 * This handler is called by the PSCI implementation during the `SYSTEM_SUSPEND`
125 * call to get the `power_state` parameter. This allows the platform to encode
126 * the appropriate State-ID field within the `power_state` parameter which can
127 * be utilized in `pwr_domain_suspend()` to suspend to system affinity level.
128******************************************************************************/
129void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state)
Varun Wadekarb316e242015-05-19 16:48:04 +0530130{
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700131 /* all affinities use system suspend state id */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800132 for (uint32_t i = MPIDR_AFFLVL0; i <= PLAT_MAX_PWR_LVL; i++) {
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700133 req_state->pwr_domain_state[i] = PSTATE_ID_SOC_POWERDN;
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800134 }
Varun Wadekarb316e242015-05-19 16:48:04 +0530135}
136
137/*******************************************************************************
138 * Handler called when an affinity instance is about to enter standby.
139 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530140void tegra_cpu_standby(plat_local_state_t cpu_state)
Varun Wadekarb316e242015-05-19 16:48:04 +0530141{
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800142 (void)cpu_state;
143
Varun Wadekarb316e242015-05-19 16:48:04 +0530144 /*
145 * Enter standby state
146 * dsb is good practice before using wfi to enter low power states
147 */
148 dsb();
149 wfi();
150}
151
152/*******************************************************************************
Varun Wadekarb316e242015-05-19 16:48:04 +0530153 * Handler called when an affinity instance is about to be turned on. The
154 * level and mpidr determine the affinity instance.
155 ******************************************************************************/
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800156int32_t tegra_pwr_domain_on(u_register_t mpidr)
Varun Wadekarb316e242015-05-19 16:48:04 +0530157{
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530158 return tegra_soc_pwr_domain_on(mpidr);
Varun Wadekarb316e242015-05-19 16:48:04 +0530159}
160
161/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530162 * Handler called when a power domain is about to be turned off. The
163 * target_state encodes the power state that each level should transition to.
Varun Wadekarb316e242015-05-19 16:48:04 +0530164 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530165void tegra_pwr_domain_off(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +0530166{
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800167 (void)tegra_soc_pwr_domain_off(target_state);
Varun Wadekarb316e242015-05-19 16:48:04 +0530168}
169
170/*******************************************************************************
Varun Wadekard22429d2016-03-18 14:35:28 -0700171 * Handler called when a power domain is about to be suspended. The
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530172 * target_state encodes the power state that each level should transition to.
Varun Wadekar99782e82017-07-05 17:44:12 -0700173 * This handler is called with SMP and data cache enabled, when
174 * HW_ASSISTED_COHERENCY = 0
175 ******************************************************************************/
176void tegra_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
177{
178 tegra_soc_pwr_domain_suspend_pwrdown_early(target_state);
179}
180
181/*******************************************************************************
182 * Handler called when a power domain is about to be suspended. The
183 * target_state encodes the power state that each level should transition to.
Varun Wadekarb316e242015-05-19 16:48:04 +0530184 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530185void tegra_pwr_domain_suspend(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +0530186{
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800187 (void)tegra_soc_pwr_domain_suspend(target_state);
Varun Wadekarb316e242015-05-19 16:48:04 +0530188
Varun Wadekara2c6be62016-08-01 22:16:21 -0700189 /* Disable console if we are entering deep sleep. */
190 if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] ==
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800191 PSTATE_ID_SOC_POWERDN) {
192 (void)console_uninit();
193 }
Varun Wadekara2c6be62016-08-01 22:16:21 -0700194
Varun Wadekarb316e242015-05-19 16:48:04 +0530195 /* disable GICC */
196 tegra_gic_cpuif_deactivate();
197}
198
199/*******************************************************************************
Varun Wadekard22429d2016-03-18 14:35:28 -0700200 * Handler called at the end of the power domain suspend sequence. The
201 * target_state encodes the power state that each level should transition to.
202 ******************************************************************************/
203__dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t
204 *target_state)
205{
Vignesh Radhakrishnanb4a72942017-03-03 10:58:05 -0800206 uint8_t pwr_state = target_state->pwr_domain_state[PLAT_MAX_PWR_LVL];
207 uint64_t rmr_el3 = 0;
208
Varun Wadekard22429d2016-03-18 14:35:28 -0700209 /* call the chip's power down handler */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800210 (void)tegra_soc_pwr_domain_power_down_wfi(target_state);
Varun Wadekard22429d2016-03-18 14:35:28 -0700211
Vignesh Radhakrishnanb4a72942017-03-03 10:58:05 -0800212 /*
213 * If we are in fake system suspend mode, ensure we start doing
214 * procedures that help in looping back towards system suspend exit
215 * instead of calling WFI by requesting a warm reset.
216 * Else, just call WFI to enter low power state.
217 */
218 if ((tegra_fake_system_suspend != 0U) &&
219 (pwr_state == (uint8_t)PSTATE_ID_SOC_POWERDN)) {
220
221 /* warm reboot */
222 rmr_el3 = read_rmr_el3();
223 write_rmr_el3(rmr_el3 | RMR_WARM_RESET_CPU);
224
225 } else {
226 /* enter power down state */
227 wfi();
228 }
Varun Wadekard22429d2016-03-18 14:35:28 -0700229
230 /* we can never reach here */
Varun Wadekard22429d2016-03-18 14:35:28 -0700231 panic();
232}
233
234/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530235 * Handler called when a power domain has just been powered on after
236 * being turned off earlier. The target_state encodes the low power state that
237 * each level has woken up from.
Varun Wadekarb316e242015-05-19 16:48:04 +0530238 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530239void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +0530240{
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800241 const plat_params_from_bl2_t *plat_params;
Harvey Hsieh9e083c72017-04-10 16:20:32 +0800242 uint32_t console_clock;
Varun Wadekarb316e242015-05-19 16:48:04 +0530243
244 /*
Varun Wadekarb316e242015-05-19 16:48:04 +0530245 * Initialize the GIC cpu and distributor interfaces
246 */
Varun Wadekarb7b45752015-12-28 14:55:41 -0800247 plat_gic_setup();
Varun Wadekarb316e242015-05-19 16:48:04 +0530248
249 /*
250 * Check if we are exiting from deep sleep.
251 */
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530252 if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] ==
253 PSTATE_ID_SOC_POWERDN) {
Varun Wadekarb316e242015-05-19 16:48:04 +0530254
Harvey Hsieh9e083c72017-04-10 16:20:32 +0800255 /*
256 * Reference clock used by the FPGAs is a lot slower.
257 */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800258 if (tegra_platform_is_fpga()) {
Harvey Hsieh9e083c72017-04-10 16:20:32 +0800259 console_clock = TEGRA_BOOT_UART_CLK_13_MHZ;
260 } else {
261 console_clock = TEGRA_BOOT_UART_CLK_408_MHZ;
262 }
263
Varun Wadekara2c6be62016-08-01 22:16:21 -0700264 /* Initialize the runtime console */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800265 if (tegra_console_base != 0ULL) {
266 (void)console_init(tegra_console_base, console_clock,
Harvey Hsieh9e083c72017-04-10 16:20:32 +0800267 TEGRA_CONSOLE_BAUDRATE);
Damon Duan777baa52016-11-07 19:37:50 +0800268 }
Varun Wadekara2c6be62016-08-01 22:16:21 -0700269
Varun Wadekarb316e242015-05-19 16:48:04 +0530270 /*
Varun Wadekar6eec6d62016-03-03 13:28:10 -0800271 * Restore Memory Controller settings as it loses state
272 * during system suspend.
Varun Wadekarb316e242015-05-19 16:48:04 +0530273 */
Varun Wadekar6eec6d62016-03-03 13:28:10 -0800274 tegra_memctrl_restore_settings();
Varun Wadekarb316e242015-05-19 16:48:04 +0530275
276 /*
277 * Security configuration to allow DRAM/device access.
278 */
279 plat_params = bl31_get_plat_params();
Varun Wadekar6bb62462015-10-06 12:49:31 +0530280 tegra_memctrl_tzdram_setup(plat_params->tzdram_base,
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800281 (uint32_t)plat_params->tzdram_size);
Varun Wadekard5f578a2016-06-01 19:34:37 -0700282
283 /*
284 * Set up the TZRAM memory aperture to allow only secure world
285 * access
286 */
287 tegra_memctrl_tzram_setup(TEGRA_TZRAM_BASE, TEGRA_TZRAM_SIZE);
Varun Wadekarb316e242015-05-19 16:48:04 +0530288 }
289
290 /*
291 * Reset hardware settings.
292 */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800293 (void)tegra_soc_pwr_domain_on_finish(target_state);
Varun Wadekarb316e242015-05-19 16:48:04 +0530294}
295
296/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530297 * Handler called when a power domain has just been powered on after
298 * having been suspended earlier. The target_state encodes the low power state
299 * that each level has woken up from.
Varun Wadekarb316e242015-05-19 16:48:04 +0530300 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530301void tegra_pwr_domain_suspend_finish(const psci_power_state_t *target_state)
Varun Wadekarb316e242015-05-19 16:48:04 +0530302{
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530303 tegra_pwr_domain_on_finish(target_state);
Varun Wadekarb316e242015-05-19 16:48:04 +0530304}
305
306/*******************************************************************************
307 * Handler called when the system wants to be powered off
308 ******************************************************************************/
309__dead2 void tegra_system_off(void)
310{
Varun Wadekare5caeed2016-01-07 14:04:21 -0800311 INFO("Powering down system...\n");
312
313 tegra_soc_prepare_system_off();
Varun Wadekarb316e242015-05-19 16:48:04 +0530314}
315
316/*******************************************************************************
317 * Handler called when the system wants to be restarted.
318 ******************************************************************************/
319__dead2 void tegra_system_reset(void)
320{
Varun Wadekare5caeed2016-01-07 14:04:21 -0800321 INFO("Restarting system...\n");
322
Varun Wadekar8b82fae2015-11-09 17:39:28 -0800323 /* per-SoC system reset handler */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800324 (void)tegra_soc_prepare_system_reset();
Varun Wadekar8b82fae2015-11-09 17:39:28 -0800325
Varun Wadekarb316e242015-05-19 16:48:04 +0530326 /*
327 * Program the PMC in order to restart the system.
328 */
329 tegra_pmc_system_reset();
330}
331
332/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530333 * Handler called to check the validity of the power state parameter.
334 ******************************************************************************/
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800335int32_t tegra_validate_power_state(uint32_t power_state,
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530336 psci_power_state_t *req_state)
337{
Anthony Zhou4408e882017-07-07 14:29:51 +0800338 assert(req_state != NULL);
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530339
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530340 return tegra_soc_validate_power_state(power_state, req_state);
341}
342
343/*******************************************************************************
344 * Platform handler called to check the validity of the non secure entrypoint.
345 ******************************************************************************/
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800346int32_t tegra_validate_ns_entrypoint(uintptr_t entrypoint)
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530347{
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800348 int32_t ret = PSCI_E_INVALID_ADDRESS;
349
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530350 /*
351 * Check if the non secure entrypoint lies within the non
352 * secure DRAM.
353 */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800354 if ((entrypoint >= TEGRA_DRAM_BASE) && (entrypoint <= TEGRA_DRAM_END)) {
355 ret = PSCI_E_SUCCESS;
356 }
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530357
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800358 return ret;
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530359}
360
361/*******************************************************************************
Varun Wadekarb316e242015-05-19 16:48:04 +0530362 * Export the platform handlers to enable psci to invoke them
363 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530364static const plat_psci_ops_t tegra_plat_psci_ops = {
365 .cpu_standby = tegra_cpu_standby,
366 .pwr_domain_on = tegra_pwr_domain_on,
367 .pwr_domain_off = tegra_pwr_domain_off,
Varun Wadekar99782e82017-07-05 17:44:12 -0700368 .pwr_domain_suspend_pwrdown_early = tegra_pwr_domain_suspend_pwrdown_early,
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530369 .pwr_domain_suspend = tegra_pwr_domain_suspend,
370 .pwr_domain_on_finish = tegra_pwr_domain_on_finish,
371 .pwr_domain_suspend_finish = tegra_pwr_domain_suspend_finish,
Varun Wadekard22429d2016-03-18 14:35:28 -0700372 .pwr_domain_pwr_down_wfi = tegra_pwr_domain_power_down_wfi,
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530373 .system_off = tegra_system_off,
374 .system_reset = tegra_system_reset,
375 .validate_power_state = tegra_validate_power_state,
376 .validate_ns_entrypoint = tegra_validate_ns_entrypoint,
377 .get_sys_suspend_power_state = tegra_get_sys_suspend_power_state,
Varun Wadekarb316e242015-05-19 16:48:04 +0530378};
379
380/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530381 * Export the platform specific power ops and initialize Power Controller
Varun Wadekarb316e242015-05-19 16:48:04 +0530382 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530383int plat_setup_psci_ops(uintptr_t sec_entrypoint,
384 const plat_psci_ops_t **psci_ops)
Varun Wadekarb316e242015-05-19 16:48:04 +0530385{
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530386 psci_power_state_t target_state = { { PSCI_LOCAL_STATE_RUN } };
387
388 /*
389 * Flush entrypoint variable to PoC since it will be
390 * accessed after a reset with the caches turned off.
391 */
392 tegra_sec_entry_point = sec_entrypoint;
393 flush_dcache_range((uint64_t)&tegra_sec_entry_point, sizeof(uint64_t));
394
Varun Wadekarb316e242015-05-19 16:48:04 +0530395 /*
396 * Reset hardware settings.
397 */
Anthony Zhou85a8fa02017-03-22 14:42:42 +0800398 (void)tegra_soc_pwr_domain_on_finish(&target_state);
Varun Wadekarb316e242015-05-19 16:48:04 +0530399
400 /*
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530401 * Initialize PSCI ops struct
Varun Wadekarb316e242015-05-19 16:48:04 +0530402 */
Varun Wadekara78bb1b2015-08-07 10:03:00 +0530403 *psci_ops = &tegra_plat_psci_ops;
Varun Wadekarb316e242015-05-19 16:48:04 +0530404
405 return 0;
406}
Varun Wadekar24975392016-05-05 14:13:30 -0700407
408/*******************************************************************************
409 * Platform handler to calculate the proper target power level at the
410 * specified affinity level
411 ******************************************************************************/
412plat_local_state_t plat_get_target_pwr_state(unsigned int lvl,
413 const plat_local_state_t *states,
414 unsigned int ncpu)
415{
Varun Wadekarf2aa1be2016-06-07 12:00:06 -0700416 return tegra_soc_get_target_pwr_state(lvl, states, ncpu);
Varun Wadekar24975392016-05-05 14:13:30 -0700417}