xref: /rk3399_ARM-atf/plat/nvidia/tegra/common/tegra_pm.c (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
108438e24SVarun Wadekar /*
2a9e0260cSVignesh Radhakrishnan  * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
308438e24SVarun Wadekar  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
508438e24SVarun Wadekar  */
608438e24SVarun Wadekar 
708438e24SVarun Wadekar #include <assert.h>
8*09d40e0eSAntonio Nino Diaz 
908438e24SVarun Wadekar #include <platform_def.h>
10*09d40e0eSAntonio Nino Diaz 
11*09d40e0eSAntonio Nino Diaz #include <arch_helpers.h>
12*09d40e0eSAntonio Nino Diaz #include <common/bl_common.h>
13*09d40e0eSAntonio Nino Diaz #include <common/debug.h>
14*09d40e0eSAntonio Nino Diaz #include <context.h>
15*09d40e0eSAntonio Nino Diaz #include <drivers/console.h>
16*09d40e0eSAntonio Nino Diaz #include <lib/el3_runtime/context_mgmt.h>
17*09d40e0eSAntonio Nino Diaz #include <lib/mmio.h>
18*09d40e0eSAntonio Nino Diaz #include <lib/psci/psci.h>
19*09d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
20*09d40e0eSAntonio Nino Diaz 
21*09d40e0eSAntonio Nino Diaz #include <memctrl.h>
2208438e24SVarun Wadekar #include <pmc.h>
2308438e24SVarun Wadekar #include <tegra_def.h>
2408438e24SVarun Wadekar #include <tegra_private.h>
2508438e24SVarun Wadekar 
2608438e24SVarun Wadekar extern uint64_t tegra_bl31_phys_base;
2771cb26eaSVarun Wadekar extern uint64_t tegra_sec_entry_point;
285b5928e8SVarun Wadekar extern uint64_t tegra_console_base;
2908438e24SVarun Wadekar 
3008438e24SVarun Wadekar /*
31a9e0260cSVignesh Radhakrishnan  * tegra_fake_system_suspend acts as a boolean var controlling whether
32a9e0260cSVignesh Radhakrishnan  * we are going to take fake system suspend code or normal system suspend code
33a9e0260cSVignesh Radhakrishnan  * path. This variable is set inside the sip call handlers,when the kernel
34a9e0260cSVignesh Radhakrishnan  * requests a SIP call to set the suspend debug flags.
35a9e0260cSVignesh Radhakrishnan  */
36a9e0260cSVignesh Radhakrishnan uint8_t tegra_fake_system_suspend;
37a9e0260cSVignesh Radhakrishnan 
38a9e0260cSVignesh Radhakrishnan /*
3908438e24SVarun Wadekar  * The following platform setup functions are weakly defined. They
4008438e24SVarun Wadekar  * provide typical implementations that will be overridden by a SoC.
4108438e24SVarun Wadekar  */
42cb95a19aSVarun Wadekar #pragma weak tegra_soc_pwr_domain_suspend_pwrdown_early
4371cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_suspend
4471cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_on
4571cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_off
4671cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_on_finish
4726c0d9b2SVarun Wadekar #pragma weak tegra_soc_pwr_domain_power_down_wfi
483b40f993SVarun Wadekar #pragma weak tegra_soc_prepare_system_reset
4931a4957cSVarun Wadekar #pragma weak tegra_soc_prepare_system_off
50a7cd0953SVarun Wadekar #pragma weak tegra_soc_get_target_pwr_state
5108438e24SVarun Wadekar 
52cb95a19aSVarun Wadekar int tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
53cb95a19aSVarun Wadekar {
54cb95a19aSVarun Wadekar 	return PSCI_E_NOT_SUPPORTED;
55cb95a19aSVarun Wadekar }
56cb95a19aSVarun Wadekar 
5771cb26eaSVarun Wadekar int tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
5808438e24SVarun Wadekar {
5908438e24SVarun Wadekar 	return PSCI_E_NOT_SUPPORTED;
6008438e24SVarun Wadekar }
6108438e24SVarun Wadekar 
6271cb26eaSVarun Wadekar int tegra_soc_pwr_domain_on(u_register_t mpidr)
6308438e24SVarun Wadekar {
6408438e24SVarun Wadekar 	return PSCI_E_SUCCESS;
6508438e24SVarun Wadekar }
6608438e24SVarun Wadekar 
6771cb26eaSVarun Wadekar int tegra_soc_pwr_domain_off(const psci_power_state_t *target_state)
6808438e24SVarun Wadekar {
6908438e24SVarun Wadekar 	return PSCI_E_SUCCESS;
7008438e24SVarun Wadekar }
7108438e24SVarun Wadekar 
7271cb26eaSVarun Wadekar int tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state)
7308438e24SVarun Wadekar {
7408438e24SVarun Wadekar 	return PSCI_E_SUCCESS;
7508438e24SVarun Wadekar }
7608438e24SVarun Wadekar 
7726c0d9b2SVarun Wadekar int tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state)
7826c0d9b2SVarun Wadekar {
7926c0d9b2SVarun Wadekar 	return PSCI_E_SUCCESS;
8026c0d9b2SVarun Wadekar }
8126c0d9b2SVarun Wadekar 
823b40f993SVarun Wadekar int tegra_soc_prepare_system_reset(void)
833b40f993SVarun Wadekar {
843b40f993SVarun Wadekar 	return PSCI_E_SUCCESS;
853b40f993SVarun Wadekar }
863b40f993SVarun Wadekar 
8731a4957cSVarun Wadekar __dead2 void tegra_soc_prepare_system_off(void)
8831a4957cSVarun Wadekar {
8931a4957cSVarun Wadekar 	ERROR("Tegra System Off: operation not handled.\n");
9031a4957cSVarun Wadekar 	panic();
9131a4957cSVarun Wadekar }
9231a4957cSVarun Wadekar 
93a7cd0953SVarun Wadekar plat_local_state_t tegra_soc_get_target_pwr_state(unsigned int lvl,
94a7cd0953SVarun Wadekar 					     const plat_local_state_t *states,
95a7cd0953SVarun Wadekar 					     unsigned int ncpu)
96a7cd0953SVarun Wadekar {
978539f45dSVarun Wadekar 	plat_local_state_t target = PLAT_MAX_OFF_STATE, temp;
98a7cd0953SVarun Wadekar 
99a7cd0953SVarun Wadekar 	assert(ncpu);
100a7cd0953SVarun Wadekar 
101a7cd0953SVarun Wadekar 	do {
102a7cd0953SVarun Wadekar 		temp = *states++;
1038539f45dSVarun Wadekar 		if ((temp < target))
104a7cd0953SVarun Wadekar 			target = temp;
105a7cd0953SVarun Wadekar 	} while (--ncpu);
106a7cd0953SVarun Wadekar 
107a7cd0953SVarun Wadekar 	return target;
108a7cd0953SVarun Wadekar }
109a7cd0953SVarun Wadekar 
11008438e24SVarun Wadekar /*******************************************************************************
11171cb26eaSVarun Wadekar  * This handler is called by the PSCI implementation during the `SYSTEM_SUSPEND`
11271cb26eaSVarun Wadekar  * call to get the `power_state` parameter. This allows the platform to encode
11371cb26eaSVarun Wadekar  * the appropriate State-ID field within the `power_state` parameter which can
11471cb26eaSVarun Wadekar  * be utilized in `pwr_domain_suspend()` to suspend to system affinity level.
11508438e24SVarun Wadekar ******************************************************************************/
11671cb26eaSVarun Wadekar void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state)
11708438e24SVarun Wadekar {
118a7cd0953SVarun Wadekar 	/* all affinities use system suspend state id */
1196311f63dSVarun Wadekar 	for (uint32_t i = MPIDR_AFFLVL0; i <= PLAT_MAX_PWR_LVL; i++)
120a7cd0953SVarun Wadekar 		req_state->pwr_domain_state[i] = PSTATE_ID_SOC_POWERDN;
12108438e24SVarun Wadekar }
12208438e24SVarun Wadekar 
12308438e24SVarun Wadekar /*******************************************************************************
12408438e24SVarun Wadekar  * Handler called when an affinity instance is about to enter standby.
12508438e24SVarun Wadekar  ******************************************************************************/
12671cb26eaSVarun Wadekar void tegra_cpu_standby(plat_local_state_t cpu_state)
12708438e24SVarun Wadekar {
12808438e24SVarun Wadekar 	/*
12908438e24SVarun Wadekar 	 * Enter standby state
13008438e24SVarun Wadekar 	 * dsb is good practice before using wfi to enter low power states
13108438e24SVarun Wadekar 	 */
13208438e24SVarun Wadekar 	dsb();
13308438e24SVarun Wadekar 	wfi();
13408438e24SVarun Wadekar }
13508438e24SVarun Wadekar 
13608438e24SVarun Wadekar /*******************************************************************************
13708438e24SVarun Wadekar  * Handler called when an affinity instance is about to be turned on. The
13808438e24SVarun Wadekar  * level and mpidr determine the affinity instance.
13908438e24SVarun Wadekar  ******************************************************************************/
14071cb26eaSVarun Wadekar int tegra_pwr_domain_on(u_register_t mpidr)
14108438e24SVarun Wadekar {
14271cb26eaSVarun Wadekar 	return tegra_soc_pwr_domain_on(mpidr);
14308438e24SVarun Wadekar }
14408438e24SVarun Wadekar 
14508438e24SVarun Wadekar /*******************************************************************************
14671cb26eaSVarun Wadekar  * Handler called when a power domain is about to be turned off. The
14771cb26eaSVarun Wadekar  * target_state encodes the power state that each level should transition to.
14808438e24SVarun Wadekar  ******************************************************************************/
14971cb26eaSVarun Wadekar void tegra_pwr_domain_off(const psci_power_state_t *target_state)
15008438e24SVarun Wadekar {
15171cb26eaSVarun Wadekar 	tegra_soc_pwr_domain_off(target_state);
15208438e24SVarun Wadekar }
15308438e24SVarun Wadekar 
15408438e24SVarun Wadekar /*******************************************************************************
15526c0d9b2SVarun Wadekar  * Handler called when a power domain is about to be suspended. The
15671cb26eaSVarun Wadekar  * target_state encodes the power state that each level should transition to.
157cb95a19aSVarun Wadekar  * This handler is called with SMP and data cache enabled, when
158cb95a19aSVarun Wadekar  * HW_ASSISTED_COHERENCY = 0
159cb95a19aSVarun Wadekar  ******************************************************************************/
160cb95a19aSVarun Wadekar void tegra_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
161cb95a19aSVarun Wadekar {
162cb95a19aSVarun Wadekar 	tegra_soc_pwr_domain_suspend_pwrdown_early(target_state);
163cb95a19aSVarun Wadekar }
164cb95a19aSVarun Wadekar 
165cb95a19aSVarun Wadekar /*******************************************************************************
166cb95a19aSVarun Wadekar  * Handler called when a power domain is about to be suspended. The
167cb95a19aSVarun Wadekar  * target_state encodes the power state that each level should transition to.
16808438e24SVarun Wadekar  ******************************************************************************/
16971cb26eaSVarun Wadekar void tegra_pwr_domain_suspend(const psci_power_state_t *target_state)
17008438e24SVarun Wadekar {
17171cb26eaSVarun Wadekar 	tegra_soc_pwr_domain_suspend(target_state);
17208438e24SVarun Wadekar 
1735b5928e8SVarun Wadekar 	/* Disable console if we are entering deep sleep. */
1745b5928e8SVarun Wadekar 	if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] ==
1755b5928e8SVarun Wadekar 			PSTATE_ID_SOC_POWERDN)
1765b5928e8SVarun Wadekar 		console_uninit();
1775b5928e8SVarun Wadekar 
17808438e24SVarun Wadekar 	/* disable GICC */
17908438e24SVarun Wadekar 	tegra_gic_cpuif_deactivate();
18008438e24SVarun Wadekar }
18108438e24SVarun Wadekar 
18208438e24SVarun Wadekar /*******************************************************************************
18326c0d9b2SVarun Wadekar  * Handler called at the end of the power domain suspend sequence. The
18426c0d9b2SVarun Wadekar  * target_state encodes the power state that each level should transition to.
18526c0d9b2SVarun Wadekar  ******************************************************************************/
18626c0d9b2SVarun Wadekar __dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t
18726c0d9b2SVarun Wadekar 					     *target_state)
18826c0d9b2SVarun Wadekar {
189a9e0260cSVignesh Radhakrishnan 	uint8_t pwr_state = target_state->pwr_domain_state[PLAT_MAX_PWR_LVL];
190a9e0260cSVignesh Radhakrishnan 	uint64_t rmr_el3 = 0;
191a9e0260cSVignesh Radhakrishnan 
19226c0d9b2SVarun Wadekar 	/* call the chip's power down handler */
19326c0d9b2SVarun Wadekar 	tegra_soc_pwr_domain_power_down_wfi(target_state);
19426c0d9b2SVarun Wadekar 
195a9e0260cSVignesh Radhakrishnan 	/*
196a9e0260cSVignesh Radhakrishnan 	 * If we are in fake system suspend mode, ensure we start doing
197a9e0260cSVignesh Radhakrishnan 	 * procedures that help in looping back towards system suspend exit
198a9e0260cSVignesh Radhakrishnan 	 * instead of calling WFI by requesting a warm reset.
199a9e0260cSVignesh Radhakrishnan 	 * Else, just call WFI to enter low power state.
200a9e0260cSVignesh Radhakrishnan 	 */
201a9e0260cSVignesh Radhakrishnan 	if ((tegra_fake_system_suspend != 0U) &&
202a9e0260cSVignesh Radhakrishnan 	    (pwr_state == (uint8_t)PSTATE_ID_SOC_POWERDN)) {
203a9e0260cSVignesh Radhakrishnan 
204a9e0260cSVignesh Radhakrishnan 		/* warm reboot */
205a9e0260cSVignesh Radhakrishnan 		rmr_el3 = read_rmr_el3();
206a9e0260cSVignesh Radhakrishnan 		write_rmr_el3(rmr_el3 | RMR_WARM_RESET_CPU);
207a9e0260cSVignesh Radhakrishnan 
208a9e0260cSVignesh Radhakrishnan 	} else {
20926c0d9b2SVarun Wadekar 		/* enter power down state */
21026c0d9b2SVarun Wadekar 		wfi();
211a9e0260cSVignesh Radhakrishnan 	}
21226c0d9b2SVarun Wadekar 
21326c0d9b2SVarun Wadekar 	/* we can never reach here */
21426c0d9b2SVarun Wadekar 	panic();
21526c0d9b2SVarun Wadekar }
21626c0d9b2SVarun Wadekar 
21726c0d9b2SVarun Wadekar /*******************************************************************************
21871cb26eaSVarun Wadekar  * Handler called when a power domain has just been powered on after
21971cb26eaSVarun Wadekar  * being turned off earlier. The target_state encodes the low power state that
22071cb26eaSVarun Wadekar  * each level has woken up from.
22108438e24SVarun Wadekar  ******************************************************************************/
22271cb26eaSVarun Wadekar void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state)
22308438e24SVarun Wadekar {
22408438e24SVarun Wadekar 	plat_params_from_bl2_t *plat_params;
22508438e24SVarun Wadekar 
22608438e24SVarun Wadekar 	/*
22708438e24SVarun Wadekar 	 * Initialize the GIC cpu and distributor interfaces
22808438e24SVarun Wadekar 	 */
229d3360301SVarun Wadekar 	plat_gic_setup();
23008438e24SVarun Wadekar 
23108438e24SVarun Wadekar 	/*
23208438e24SVarun Wadekar 	 * Check if we are exiting from deep sleep.
23308438e24SVarun Wadekar 	 */
23471cb26eaSVarun Wadekar 	if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] ==
23571cb26eaSVarun Wadekar 			PSTATE_ID_SOC_POWERDN) {
23608438e24SVarun Wadekar 
2375b5928e8SVarun Wadekar 		/* Initialize the runtime console */
2389b514f83SDamon Duan 		if (tegra_console_base != (uint64_t)0) {
2395b5928e8SVarun Wadekar 			console_init(tegra_console_base, TEGRA_BOOT_UART_CLK_IN_HZ,
2405b5928e8SVarun Wadekar 				TEGRA_CONSOLE_BAUDRATE);
2419b514f83SDamon Duan 		}
2425b5928e8SVarun Wadekar 
24308438e24SVarun Wadekar 		/*
244102e4087SVarun Wadekar 		 * Restore Memory Controller settings as it loses state
245102e4087SVarun Wadekar 		 * during system suspend.
24608438e24SVarun Wadekar 		 */
247102e4087SVarun Wadekar 		tegra_memctrl_restore_settings();
24808438e24SVarun Wadekar 
24908438e24SVarun Wadekar 		/*
25008438e24SVarun Wadekar 		 * Security configuration to allow DRAM/device access.
25108438e24SVarun Wadekar 		 */
25208438e24SVarun Wadekar 		plat_params = bl31_get_plat_params();
253e0d4158cSVarun Wadekar 		tegra_memctrl_tzdram_setup(plat_params->tzdram_base,
25408438e24SVarun Wadekar 			plat_params->tzdram_size);
255207680c6SVarun Wadekar 
256207680c6SVarun Wadekar 		/*
257207680c6SVarun Wadekar 		 * Set up the TZRAM memory aperture to allow only secure world
258207680c6SVarun Wadekar 		 * access
259207680c6SVarun Wadekar 		 */
260207680c6SVarun Wadekar 		tegra_memctrl_tzram_setup(TEGRA_TZRAM_BASE, TEGRA_TZRAM_SIZE);
26108438e24SVarun Wadekar 	}
26208438e24SVarun Wadekar 
26308438e24SVarun Wadekar 	/*
26408438e24SVarun Wadekar 	 * Reset hardware settings.
26508438e24SVarun Wadekar 	 */
26671cb26eaSVarun Wadekar 	tegra_soc_pwr_domain_on_finish(target_state);
26708438e24SVarun Wadekar }
26808438e24SVarun Wadekar 
26908438e24SVarun Wadekar /*******************************************************************************
27071cb26eaSVarun Wadekar  * Handler called when a power domain has just been powered on after
27171cb26eaSVarun Wadekar  * having been suspended earlier. The target_state encodes the low power state
27271cb26eaSVarun Wadekar  * that each level has woken up from.
27308438e24SVarun Wadekar  ******************************************************************************/
27471cb26eaSVarun Wadekar void tegra_pwr_domain_suspend_finish(const psci_power_state_t *target_state)
27508438e24SVarun Wadekar {
27671cb26eaSVarun Wadekar 	tegra_pwr_domain_on_finish(target_state);
27708438e24SVarun Wadekar }
27808438e24SVarun Wadekar 
27908438e24SVarun Wadekar /*******************************************************************************
28008438e24SVarun Wadekar  * Handler called when the system wants to be powered off
28108438e24SVarun Wadekar  ******************************************************************************/
28208438e24SVarun Wadekar __dead2 void tegra_system_off(void)
28308438e24SVarun Wadekar {
28431a4957cSVarun Wadekar 	INFO("Powering down system...\n");
28531a4957cSVarun Wadekar 
28631a4957cSVarun Wadekar 	tegra_soc_prepare_system_off();
28708438e24SVarun Wadekar }
28808438e24SVarun Wadekar 
28908438e24SVarun Wadekar /*******************************************************************************
29008438e24SVarun Wadekar  * Handler called when the system wants to be restarted.
29108438e24SVarun Wadekar  ******************************************************************************/
29208438e24SVarun Wadekar __dead2 void tegra_system_reset(void)
29308438e24SVarun Wadekar {
29431a4957cSVarun Wadekar 	INFO("Restarting system...\n");
29531a4957cSVarun Wadekar 
2963b40f993SVarun Wadekar 	/* per-SoC system reset handler */
2973b40f993SVarun Wadekar 	tegra_soc_prepare_system_reset();
2983b40f993SVarun Wadekar 
29908438e24SVarun Wadekar 	/*
30008438e24SVarun Wadekar 	 * Program the PMC in order to restart the system.
30108438e24SVarun Wadekar 	 */
30208438e24SVarun Wadekar 	tegra_pmc_system_reset();
30308438e24SVarun Wadekar }
30408438e24SVarun Wadekar 
30508438e24SVarun Wadekar /*******************************************************************************
30671cb26eaSVarun Wadekar  * Handler called to check the validity of the power state parameter.
30771cb26eaSVarun Wadekar  ******************************************************************************/
30871cb26eaSVarun Wadekar int32_t tegra_validate_power_state(unsigned int power_state,
30971cb26eaSVarun Wadekar 				   psci_power_state_t *req_state)
31071cb26eaSVarun Wadekar {
31171cb26eaSVarun Wadekar 	assert(req_state);
31271cb26eaSVarun Wadekar 
31371cb26eaSVarun Wadekar 	return tegra_soc_validate_power_state(power_state, req_state);
31471cb26eaSVarun Wadekar }
31571cb26eaSVarun Wadekar 
31671cb26eaSVarun Wadekar /*******************************************************************************
31771cb26eaSVarun Wadekar  * Platform handler called to check the validity of the non secure entrypoint.
31871cb26eaSVarun Wadekar  ******************************************************************************/
31971cb26eaSVarun Wadekar int tegra_validate_ns_entrypoint(uintptr_t entrypoint)
32071cb26eaSVarun Wadekar {
32171cb26eaSVarun Wadekar 	/*
32271cb26eaSVarun Wadekar 	 * Check if the non secure entrypoint lies within the non
32371cb26eaSVarun Wadekar 	 * secure DRAM.
32471cb26eaSVarun Wadekar 	 */
32571cb26eaSVarun Wadekar 	if ((entrypoint >= TEGRA_DRAM_BASE) && (entrypoint <= TEGRA_DRAM_END))
32671cb26eaSVarun Wadekar 		return PSCI_E_SUCCESS;
32771cb26eaSVarun Wadekar 
32871cb26eaSVarun Wadekar 	return PSCI_E_INVALID_ADDRESS;
32971cb26eaSVarun Wadekar }
33071cb26eaSVarun Wadekar 
33171cb26eaSVarun Wadekar /*******************************************************************************
33208438e24SVarun Wadekar  * Export the platform handlers to enable psci to invoke them
33308438e24SVarun Wadekar  ******************************************************************************/
33471cb26eaSVarun Wadekar static const plat_psci_ops_t tegra_plat_psci_ops = {
33571cb26eaSVarun Wadekar 	.cpu_standby			= tegra_cpu_standby,
33671cb26eaSVarun Wadekar 	.pwr_domain_on			= tegra_pwr_domain_on,
33771cb26eaSVarun Wadekar 	.pwr_domain_off			= tegra_pwr_domain_off,
338cb95a19aSVarun Wadekar 	.pwr_domain_suspend_pwrdown_early = tegra_pwr_domain_suspend_pwrdown_early,
33971cb26eaSVarun Wadekar 	.pwr_domain_suspend		= tegra_pwr_domain_suspend,
34071cb26eaSVarun Wadekar 	.pwr_domain_on_finish		= tegra_pwr_domain_on_finish,
34171cb26eaSVarun Wadekar 	.pwr_domain_suspend_finish	= tegra_pwr_domain_suspend_finish,
34226c0d9b2SVarun Wadekar 	.pwr_domain_pwr_down_wfi	= tegra_pwr_domain_power_down_wfi,
34308438e24SVarun Wadekar 	.system_off			= tegra_system_off,
34408438e24SVarun Wadekar 	.system_reset			= tegra_system_reset,
34594c672e7SVarun Wadekar 	.validate_power_state		= tegra_validate_power_state,
34671cb26eaSVarun Wadekar 	.validate_ns_entrypoint		= tegra_validate_ns_entrypoint,
34771cb26eaSVarun Wadekar 	.get_sys_suspend_power_state	= tegra_get_sys_suspend_power_state,
34808438e24SVarun Wadekar };
34908438e24SVarun Wadekar 
35008438e24SVarun Wadekar /*******************************************************************************
35171cb26eaSVarun Wadekar  * Export the platform specific power ops and initialize Power Controller
35208438e24SVarun Wadekar  ******************************************************************************/
35371cb26eaSVarun Wadekar int plat_setup_psci_ops(uintptr_t sec_entrypoint,
35471cb26eaSVarun Wadekar 			const plat_psci_ops_t **psci_ops)
35508438e24SVarun Wadekar {
35671cb26eaSVarun Wadekar 	psci_power_state_t target_state = { { PSCI_LOCAL_STATE_RUN } };
35771cb26eaSVarun Wadekar 
35871cb26eaSVarun Wadekar 	/*
35971cb26eaSVarun Wadekar 	 * Flush entrypoint variable to PoC since it will be
36071cb26eaSVarun Wadekar 	 * accessed after a reset with the caches turned off.
36171cb26eaSVarun Wadekar 	 */
36271cb26eaSVarun Wadekar 	tegra_sec_entry_point = sec_entrypoint;
36371cb26eaSVarun Wadekar 	flush_dcache_range((uint64_t)&tegra_sec_entry_point, sizeof(uint64_t));
36471cb26eaSVarun Wadekar 
36508438e24SVarun Wadekar 	/*
36608438e24SVarun Wadekar 	 * Reset hardware settings.
36708438e24SVarun Wadekar 	 */
36871cb26eaSVarun Wadekar 	tegra_soc_pwr_domain_on_finish(&target_state);
36908438e24SVarun Wadekar 
37008438e24SVarun Wadekar 	/*
37171cb26eaSVarun Wadekar 	 * Initialize PSCI ops struct
37208438e24SVarun Wadekar 	 */
37371cb26eaSVarun Wadekar 	*psci_ops = &tegra_plat_psci_ops;
37408438e24SVarun Wadekar 
37508438e24SVarun Wadekar 	return 0;
37608438e24SVarun Wadekar }
3772693f1dbSVarun Wadekar 
3782693f1dbSVarun Wadekar /*******************************************************************************
3792693f1dbSVarun Wadekar  * Platform handler to calculate the proper target power level at the
3802693f1dbSVarun Wadekar  * specified affinity level
3812693f1dbSVarun Wadekar  ******************************************************************************/
3822693f1dbSVarun Wadekar plat_local_state_t plat_get_target_pwr_state(unsigned int lvl,
3832693f1dbSVarun Wadekar 					     const plat_local_state_t *states,
3842693f1dbSVarun Wadekar 					     unsigned int ncpu)
3852693f1dbSVarun Wadekar {
386a7cd0953SVarun Wadekar 	return tegra_soc_get_target_pwr_state(lvl, states, ncpu);
3872693f1dbSVarun Wadekar }
388