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> 809d40e0eSAntonio Nino Diaz 908438e24SVarun Wadekar #include <platform_def.h> 1009d40e0eSAntonio Nino Diaz 1109d40e0eSAntonio Nino Diaz #include <arch_helpers.h> 1209d40e0eSAntonio Nino Diaz #include <common/bl_common.h> 1309d40e0eSAntonio Nino Diaz #include <common/debug.h> 1409d40e0eSAntonio Nino Diaz #include <context.h> 1509d40e0eSAntonio Nino Diaz #include <drivers/console.h> 1609d40e0eSAntonio Nino Diaz #include <lib/el3_runtime/context_mgmt.h> 1709d40e0eSAntonio Nino Diaz #include <lib/mmio.h> 1809d40e0eSAntonio Nino Diaz #include <lib/psci/psci.h> 1909d40e0eSAntonio Nino Diaz #include <plat/common/platform.h> 2009d40e0eSAntonio Nino Diaz 2109d40e0eSAntonio Nino Diaz #include <memctrl.h> 2208438e24SVarun Wadekar #include <pmc.h> 2308438e24SVarun Wadekar #include <tegra_def.h> 24322e7c3eSHarvey Hsieh #include <tegra_platform.h> 2508438e24SVarun Wadekar #include <tegra_private.h> 2608438e24SVarun Wadekar 2708438e24SVarun Wadekar extern uint64_t tegra_bl31_phys_base; 2871cb26eaSVarun Wadekar extern uint64_t tegra_sec_entry_point; 295b5928e8SVarun Wadekar extern uint64_t tegra_console_base; 3008438e24SVarun Wadekar 3108438e24SVarun Wadekar /* 32a9e0260cSVignesh Radhakrishnan * tegra_fake_system_suspend acts as a boolean var controlling whether 33a9e0260cSVignesh Radhakrishnan * we are going to take fake system suspend code or normal system suspend code 34a9e0260cSVignesh Radhakrishnan * path. This variable is set inside the sip call handlers,when the kernel 35a9e0260cSVignesh Radhakrishnan * requests a SIP call to set the suspend debug flags. 36a9e0260cSVignesh Radhakrishnan */ 37a9e0260cSVignesh Radhakrishnan uint8_t tegra_fake_system_suspend; 38a9e0260cSVignesh Radhakrishnan 39a9e0260cSVignesh Radhakrishnan /* 4008438e24SVarun Wadekar * The following platform setup functions are weakly defined. They 4108438e24SVarun Wadekar * provide typical implementations that will be overridden by a SoC. 4208438e24SVarun Wadekar */ 43cb95a19aSVarun Wadekar #pragma weak tegra_soc_pwr_domain_suspend_pwrdown_early 4471cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_suspend 4571cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_on 4671cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_off 4771cb26eaSVarun Wadekar #pragma weak tegra_soc_pwr_domain_on_finish 4826c0d9b2SVarun Wadekar #pragma weak tegra_soc_pwr_domain_power_down_wfi 493b40f993SVarun Wadekar #pragma weak tegra_soc_prepare_system_reset 5031a4957cSVarun Wadekar #pragma weak tegra_soc_prepare_system_off 51a7cd0953SVarun Wadekar #pragma weak tegra_soc_get_target_pwr_state 5208438e24SVarun Wadekar 53*b36aea5aSAnthony Zhou int32_t tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state) 54cb95a19aSVarun Wadekar { 55cb95a19aSVarun Wadekar return PSCI_E_NOT_SUPPORTED; 56cb95a19aSVarun Wadekar } 57cb95a19aSVarun Wadekar 58*b36aea5aSAnthony Zhou int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state) 5908438e24SVarun Wadekar { 60*b36aea5aSAnthony Zhou (void)target_state; 6108438e24SVarun Wadekar return PSCI_E_NOT_SUPPORTED; 6208438e24SVarun Wadekar } 6308438e24SVarun Wadekar 64*b36aea5aSAnthony Zhou int32_t tegra_soc_pwr_domain_on(u_register_t mpidr) 6508438e24SVarun Wadekar { 66*b36aea5aSAnthony Zhou (void)mpidr; 6708438e24SVarun Wadekar return PSCI_E_SUCCESS; 6808438e24SVarun Wadekar } 6908438e24SVarun Wadekar 70*b36aea5aSAnthony Zhou int32_t tegra_soc_pwr_domain_off(const psci_power_state_t *target_state) 7108438e24SVarun Wadekar { 72*b36aea5aSAnthony Zhou (void)target_state; 7308438e24SVarun Wadekar return PSCI_E_SUCCESS; 7408438e24SVarun Wadekar } 7508438e24SVarun Wadekar 76*b36aea5aSAnthony Zhou int32_t tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state) 7708438e24SVarun Wadekar { 78*b36aea5aSAnthony Zhou (void)target_state; 7908438e24SVarun Wadekar return PSCI_E_SUCCESS; 8008438e24SVarun Wadekar } 8108438e24SVarun Wadekar 82*b36aea5aSAnthony Zhou int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state) 8326c0d9b2SVarun Wadekar { 84*b36aea5aSAnthony Zhou (void)target_state; 8526c0d9b2SVarun Wadekar return PSCI_E_SUCCESS; 8626c0d9b2SVarun Wadekar } 8726c0d9b2SVarun Wadekar 88*b36aea5aSAnthony Zhou int32_t tegra_soc_prepare_system_reset(void) 893b40f993SVarun Wadekar { 903b40f993SVarun Wadekar return PSCI_E_SUCCESS; 913b40f993SVarun Wadekar } 923b40f993SVarun Wadekar 9331a4957cSVarun Wadekar __dead2 void tegra_soc_prepare_system_off(void) 9431a4957cSVarun Wadekar { 9531a4957cSVarun Wadekar ERROR("Tegra System Off: operation not handled.\n"); 9631a4957cSVarun Wadekar panic(); 9731a4957cSVarun Wadekar } 9831a4957cSVarun Wadekar 99*b36aea5aSAnthony Zhou plat_local_state_t tegra_soc_get_target_pwr_state(uint32_t lvl, 100a7cd0953SVarun Wadekar const plat_local_state_t *states, 101*b36aea5aSAnthony Zhou uint32_t ncpu) 102a7cd0953SVarun Wadekar { 1038539f45dSVarun Wadekar plat_local_state_t target = PLAT_MAX_OFF_STATE, temp; 104*b36aea5aSAnthony Zhou uint32_t num_cpu = ncpu; 105*b36aea5aSAnthony Zhou const plat_local_state_t *local_state = states; 106*b36aea5aSAnthony Zhou 107*b36aea5aSAnthony Zhou (void)lvl; 108a7cd0953SVarun Wadekar 109a7cd0953SVarun Wadekar assert(ncpu); 110a7cd0953SVarun Wadekar 111a7cd0953SVarun Wadekar do { 112*b36aea5aSAnthony Zhou temp = *local_state; 113*b36aea5aSAnthony Zhou if ((temp < target)) { 114a7cd0953SVarun Wadekar target = temp; 115*b36aea5aSAnthony Zhou } 116*b36aea5aSAnthony Zhou --num_cpu; 117*b36aea5aSAnthony Zhou local_state++; 118*b36aea5aSAnthony Zhou } while (num_cpu != 0U); 119a7cd0953SVarun Wadekar 120a7cd0953SVarun Wadekar return target; 121a7cd0953SVarun Wadekar } 122a7cd0953SVarun Wadekar 12308438e24SVarun Wadekar /******************************************************************************* 12471cb26eaSVarun Wadekar * This handler is called by the PSCI implementation during the `SYSTEM_SUSPEND` 12571cb26eaSVarun Wadekar * call to get the `power_state` parameter. This allows the platform to encode 12671cb26eaSVarun Wadekar * the appropriate State-ID field within the `power_state` parameter which can 12771cb26eaSVarun Wadekar * be utilized in `pwr_domain_suspend()` to suspend to system affinity level. 12808438e24SVarun Wadekar ******************************************************************************/ 12971cb26eaSVarun Wadekar void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state) 13008438e24SVarun Wadekar { 131a7cd0953SVarun Wadekar /* all affinities use system suspend state id */ 132*b36aea5aSAnthony Zhou for (uint32_t i = MPIDR_AFFLVL0; i <= PLAT_MAX_PWR_LVL; i++) { 133a7cd0953SVarun Wadekar req_state->pwr_domain_state[i] = PSTATE_ID_SOC_POWERDN; 13408438e24SVarun Wadekar } 135*b36aea5aSAnthony Zhou } 13608438e24SVarun Wadekar 13708438e24SVarun Wadekar /******************************************************************************* 13808438e24SVarun Wadekar * Handler called when an affinity instance is about to enter standby. 13908438e24SVarun Wadekar ******************************************************************************/ 14071cb26eaSVarun Wadekar void tegra_cpu_standby(plat_local_state_t cpu_state) 14108438e24SVarun Wadekar { 142*b36aea5aSAnthony Zhou (void)cpu_state; 143*b36aea5aSAnthony Zhou 14408438e24SVarun Wadekar /* 14508438e24SVarun Wadekar * Enter standby state 14608438e24SVarun Wadekar * dsb is good practice before using wfi to enter low power states 14708438e24SVarun Wadekar */ 14808438e24SVarun Wadekar dsb(); 14908438e24SVarun Wadekar wfi(); 15008438e24SVarun Wadekar } 15108438e24SVarun Wadekar 15208438e24SVarun Wadekar /******************************************************************************* 15308438e24SVarun Wadekar * Handler called when an affinity instance is about to be turned on. The 15408438e24SVarun Wadekar * level and mpidr determine the affinity instance. 15508438e24SVarun Wadekar ******************************************************************************/ 156*b36aea5aSAnthony Zhou int32_t tegra_pwr_domain_on(u_register_t mpidr) 15708438e24SVarun Wadekar { 15871cb26eaSVarun Wadekar return tegra_soc_pwr_domain_on(mpidr); 15908438e24SVarun Wadekar } 16008438e24SVarun Wadekar 16108438e24SVarun Wadekar /******************************************************************************* 16271cb26eaSVarun Wadekar * Handler called when a power domain is about to be turned off. The 16371cb26eaSVarun Wadekar * target_state encodes the power state that each level should transition to. 16408438e24SVarun Wadekar ******************************************************************************/ 16571cb26eaSVarun Wadekar void tegra_pwr_domain_off(const psci_power_state_t *target_state) 16608438e24SVarun Wadekar { 167*b36aea5aSAnthony Zhou (void)tegra_soc_pwr_domain_off(target_state); 16808438e24SVarun Wadekar } 16908438e24SVarun Wadekar 17008438e24SVarun Wadekar /******************************************************************************* 17126c0d9b2SVarun Wadekar * Handler called when a power domain is about to be suspended. The 17271cb26eaSVarun Wadekar * target_state encodes the power state that each level should transition to. 173cb95a19aSVarun Wadekar * This handler is called with SMP and data cache enabled, when 174cb95a19aSVarun Wadekar * HW_ASSISTED_COHERENCY = 0 175cb95a19aSVarun Wadekar ******************************************************************************/ 176cb95a19aSVarun Wadekar void tegra_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state) 177cb95a19aSVarun Wadekar { 178cb95a19aSVarun Wadekar tegra_soc_pwr_domain_suspend_pwrdown_early(target_state); 179cb95a19aSVarun Wadekar } 180cb95a19aSVarun Wadekar 181cb95a19aSVarun Wadekar /******************************************************************************* 182cb95a19aSVarun Wadekar * Handler called when a power domain is about to be suspended. The 183cb95a19aSVarun Wadekar * target_state encodes the power state that each level should transition to. 18408438e24SVarun Wadekar ******************************************************************************/ 18571cb26eaSVarun Wadekar void tegra_pwr_domain_suspend(const psci_power_state_t *target_state) 18608438e24SVarun Wadekar { 187*b36aea5aSAnthony Zhou (void)tegra_soc_pwr_domain_suspend(target_state); 18808438e24SVarun Wadekar 1895b5928e8SVarun Wadekar /* Disable console if we are entering deep sleep. */ 1905b5928e8SVarun Wadekar if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] == 191*b36aea5aSAnthony Zhou PSTATE_ID_SOC_POWERDN) { 192*b36aea5aSAnthony Zhou (void)console_uninit(); 193*b36aea5aSAnthony Zhou } 1945b5928e8SVarun Wadekar 19508438e24SVarun Wadekar /* disable GICC */ 19608438e24SVarun Wadekar tegra_gic_cpuif_deactivate(); 19708438e24SVarun Wadekar } 19808438e24SVarun Wadekar 19908438e24SVarun Wadekar /******************************************************************************* 20026c0d9b2SVarun Wadekar * Handler called at the end of the power domain suspend sequence. The 20126c0d9b2SVarun Wadekar * target_state encodes the power state that each level should transition to. 20226c0d9b2SVarun Wadekar ******************************************************************************/ 20326c0d9b2SVarun Wadekar __dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t 20426c0d9b2SVarun Wadekar *target_state) 20526c0d9b2SVarun Wadekar { 206a9e0260cSVignesh Radhakrishnan uint8_t pwr_state = target_state->pwr_domain_state[PLAT_MAX_PWR_LVL]; 207a9e0260cSVignesh Radhakrishnan uint64_t rmr_el3 = 0; 208a9e0260cSVignesh Radhakrishnan 20926c0d9b2SVarun Wadekar /* call the chip's power down handler */ 210*b36aea5aSAnthony Zhou (void)tegra_soc_pwr_domain_power_down_wfi(target_state); 21126c0d9b2SVarun Wadekar 212a9e0260cSVignesh Radhakrishnan /* 213a9e0260cSVignesh Radhakrishnan * If we are in fake system suspend mode, ensure we start doing 214a9e0260cSVignesh Radhakrishnan * procedures that help in looping back towards system suspend exit 215a9e0260cSVignesh Radhakrishnan * instead of calling WFI by requesting a warm reset. 216a9e0260cSVignesh Radhakrishnan * Else, just call WFI to enter low power state. 217a9e0260cSVignesh Radhakrishnan */ 218a9e0260cSVignesh Radhakrishnan if ((tegra_fake_system_suspend != 0U) && 219a9e0260cSVignesh Radhakrishnan (pwr_state == (uint8_t)PSTATE_ID_SOC_POWERDN)) { 220a9e0260cSVignesh Radhakrishnan 221a9e0260cSVignesh Radhakrishnan /* warm reboot */ 222a9e0260cSVignesh Radhakrishnan rmr_el3 = read_rmr_el3(); 223a9e0260cSVignesh Radhakrishnan write_rmr_el3(rmr_el3 | RMR_WARM_RESET_CPU); 224a9e0260cSVignesh Radhakrishnan 225a9e0260cSVignesh Radhakrishnan } else { 22626c0d9b2SVarun Wadekar /* enter power down state */ 22726c0d9b2SVarun Wadekar wfi(); 228a9e0260cSVignesh Radhakrishnan } 22926c0d9b2SVarun Wadekar 23026c0d9b2SVarun Wadekar /* we can never reach here */ 23126c0d9b2SVarun Wadekar panic(); 23226c0d9b2SVarun Wadekar } 23326c0d9b2SVarun Wadekar 23426c0d9b2SVarun Wadekar /******************************************************************************* 23571cb26eaSVarun Wadekar * Handler called when a power domain has just been powered on after 23671cb26eaSVarun Wadekar * being turned off earlier. The target_state encodes the low power state that 23771cb26eaSVarun Wadekar * each level has woken up from. 23808438e24SVarun Wadekar ******************************************************************************/ 23971cb26eaSVarun Wadekar void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state) 24008438e24SVarun Wadekar { 241*b36aea5aSAnthony Zhou const plat_params_from_bl2_t *plat_params; 242322e7c3eSHarvey Hsieh uint32_t console_clock; 24308438e24SVarun Wadekar 24408438e24SVarun Wadekar /* 24508438e24SVarun Wadekar * Initialize the GIC cpu and distributor interfaces 24608438e24SVarun Wadekar */ 247d3360301SVarun Wadekar plat_gic_setup(); 24808438e24SVarun Wadekar 24908438e24SVarun Wadekar /* 25008438e24SVarun Wadekar * Check if we are exiting from deep sleep. 25108438e24SVarun Wadekar */ 25271cb26eaSVarun Wadekar if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] == 25371cb26eaSVarun Wadekar PSTATE_ID_SOC_POWERDN) { 25408438e24SVarun Wadekar 255322e7c3eSHarvey Hsieh /* 256322e7c3eSHarvey Hsieh * Reference clock used by the FPGAs is a lot slower. 257322e7c3eSHarvey Hsieh */ 258*b36aea5aSAnthony Zhou if (tegra_platform_is_fpga()) { 259322e7c3eSHarvey Hsieh console_clock = TEGRA_BOOT_UART_CLK_13_MHZ; 260322e7c3eSHarvey Hsieh } else { 261322e7c3eSHarvey Hsieh console_clock = TEGRA_BOOT_UART_CLK_408_MHZ; 262322e7c3eSHarvey Hsieh } 263322e7c3eSHarvey Hsieh 2645b5928e8SVarun Wadekar /* Initialize the runtime console */ 265*b36aea5aSAnthony Zhou if (tegra_console_base != 0ULL) { 266*b36aea5aSAnthony Zhou (void)console_init(tegra_console_base, console_clock, 2675b5928e8SVarun Wadekar TEGRA_CONSOLE_BAUDRATE); 2689b514f83SDamon Duan } 2695b5928e8SVarun Wadekar 27008438e24SVarun Wadekar /* 271102e4087SVarun Wadekar * Restore Memory Controller settings as it loses state 272102e4087SVarun Wadekar * during system suspend. 27308438e24SVarun Wadekar */ 274102e4087SVarun Wadekar tegra_memctrl_restore_settings(); 27508438e24SVarun Wadekar 27608438e24SVarun Wadekar /* 27708438e24SVarun Wadekar * Security configuration to allow DRAM/device access. 27808438e24SVarun Wadekar */ 27908438e24SVarun Wadekar plat_params = bl31_get_plat_params(); 280e0d4158cSVarun Wadekar tegra_memctrl_tzdram_setup(plat_params->tzdram_base, 281*b36aea5aSAnthony Zhou (uint32_t)plat_params->tzdram_size); 282207680c6SVarun Wadekar 283207680c6SVarun Wadekar /* 284207680c6SVarun Wadekar * Set up the TZRAM memory aperture to allow only secure world 285207680c6SVarun Wadekar * access 286207680c6SVarun Wadekar */ 287207680c6SVarun Wadekar tegra_memctrl_tzram_setup(TEGRA_TZRAM_BASE, TEGRA_TZRAM_SIZE); 28808438e24SVarun Wadekar } 28908438e24SVarun Wadekar 29008438e24SVarun Wadekar /* 29108438e24SVarun Wadekar * Reset hardware settings. 29208438e24SVarun Wadekar */ 293*b36aea5aSAnthony Zhou (void)tegra_soc_pwr_domain_on_finish(target_state); 29408438e24SVarun Wadekar } 29508438e24SVarun Wadekar 29608438e24SVarun Wadekar /******************************************************************************* 29771cb26eaSVarun Wadekar * Handler called when a power domain has just been powered on after 29871cb26eaSVarun Wadekar * having been suspended earlier. The target_state encodes the low power state 29971cb26eaSVarun Wadekar * that each level has woken up from. 30008438e24SVarun Wadekar ******************************************************************************/ 30171cb26eaSVarun Wadekar void tegra_pwr_domain_suspend_finish(const psci_power_state_t *target_state) 30208438e24SVarun Wadekar { 30371cb26eaSVarun Wadekar tegra_pwr_domain_on_finish(target_state); 30408438e24SVarun Wadekar } 30508438e24SVarun Wadekar 30608438e24SVarun Wadekar /******************************************************************************* 30708438e24SVarun Wadekar * Handler called when the system wants to be powered off 30808438e24SVarun Wadekar ******************************************************************************/ 30908438e24SVarun Wadekar __dead2 void tegra_system_off(void) 31008438e24SVarun Wadekar { 31131a4957cSVarun Wadekar INFO("Powering down system...\n"); 31231a4957cSVarun Wadekar 31331a4957cSVarun Wadekar tegra_soc_prepare_system_off(); 31408438e24SVarun Wadekar } 31508438e24SVarun Wadekar 31608438e24SVarun Wadekar /******************************************************************************* 31708438e24SVarun Wadekar * Handler called when the system wants to be restarted. 31808438e24SVarun Wadekar ******************************************************************************/ 31908438e24SVarun Wadekar __dead2 void tegra_system_reset(void) 32008438e24SVarun Wadekar { 32131a4957cSVarun Wadekar INFO("Restarting system...\n"); 32231a4957cSVarun Wadekar 3233b40f993SVarun Wadekar /* per-SoC system reset handler */ 324*b36aea5aSAnthony Zhou (void)tegra_soc_prepare_system_reset(); 3253b40f993SVarun Wadekar 32608438e24SVarun Wadekar /* 32708438e24SVarun Wadekar * Program the PMC in order to restart the system. 32808438e24SVarun Wadekar */ 32908438e24SVarun Wadekar tegra_pmc_system_reset(); 33008438e24SVarun Wadekar } 33108438e24SVarun Wadekar 33208438e24SVarun Wadekar /******************************************************************************* 33371cb26eaSVarun Wadekar * Handler called to check the validity of the power state parameter. 33471cb26eaSVarun Wadekar ******************************************************************************/ 335*b36aea5aSAnthony Zhou int32_t tegra_validate_power_state(uint32_t power_state, 33671cb26eaSVarun Wadekar psci_power_state_t *req_state) 33771cb26eaSVarun Wadekar { 33871cb26eaSVarun Wadekar assert(req_state); 33971cb26eaSVarun Wadekar 34071cb26eaSVarun Wadekar return tegra_soc_validate_power_state(power_state, req_state); 34171cb26eaSVarun Wadekar } 34271cb26eaSVarun Wadekar 34371cb26eaSVarun Wadekar /******************************************************************************* 34471cb26eaSVarun Wadekar * Platform handler called to check the validity of the non secure entrypoint. 34571cb26eaSVarun Wadekar ******************************************************************************/ 346*b36aea5aSAnthony Zhou int32_t tegra_validate_ns_entrypoint(uintptr_t entrypoint) 34771cb26eaSVarun Wadekar { 348*b36aea5aSAnthony Zhou int32_t ret = PSCI_E_INVALID_ADDRESS; 349*b36aea5aSAnthony Zhou 35071cb26eaSVarun Wadekar /* 35171cb26eaSVarun Wadekar * Check if the non secure entrypoint lies within the non 35271cb26eaSVarun Wadekar * secure DRAM. 35371cb26eaSVarun Wadekar */ 354*b36aea5aSAnthony Zhou if ((entrypoint >= TEGRA_DRAM_BASE) && (entrypoint <= TEGRA_DRAM_END)) { 355*b36aea5aSAnthony Zhou ret = PSCI_E_SUCCESS; 356*b36aea5aSAnthony Zhou } 35771cb26eaSVarun Wadekar 358*b36aea5aSAnthony Zhou return ret; 35971cb26eaSVarun Wadekar } 36071cb26eaSVarun Wadekar 36171cb26eaSVarun Wadekar /******************************************************************************* 36208438e24SVarun Wadekar * Export the platform handlers to enable psci to invoke them 36308438e24SVarun Wadekar ******************************************************************************/ 36471cb26eaSVarun Wadekar static const plat_psci_ops_t tegra_plat_psci_ops = { 36571cb26eaSVarun Wadekar .cpu_standby = tegra_cpu_standby, 36671cb26eaSVarun Wadekar .pwr_domain_on = tegra_pwr_domain_on, 36771cb26eaSVarun Wadekar .pwr_domain_off = tegra_pwr_domain_off, 368cb95a19aSVarun Wadekar .pwr_domain_suspend_pwrdown_early = tegra_pwr_domain_suspend_pwrdown_early, 36971cb26eaSVarun Wadekar .pwr_domain_suspend = tegra_pwr_domain_suspend, 37071cb26eaSVarun Wadekar .pwr_domain_on_finish = tegra_pwr_domain_on_finish, 37171cb26eaSVarun Wadekar .pwr_domain_suspend_finish = tegra_pwr_domain_suspend_finish, 37226c0d9b2SVarun Wadekar .pwr_domain_pwr_down_wfi = tegra_pwr_domain_power_down_wfi, 37308438e24SVarun Wadekar .system_off = tegra_system_off, 37408438e24SVarun Wadekar .system_reset = tegra_system_reset, 37594c672e7SVarun Wadekar .validate_power_state = tegra_validate_power_state, 37671cb26eaSVarun Wadekar .validate_ns_entrypoint = tegra_validate_ns_entrypoint, 37771cb26eaSVarun Wadekar .get_sys_suspend_power_state = tegra_get_sys_suspend_power_state, 37808438e24SVarun Wadekar }; 37908438e24SVarun Wadekar 38008438e24SVarun Wadekar /******************************************************************************* 38171cb26eaSVarun Wadekar * Export the platform specific power ops and initialize Power Controller 38208438e24SVarun Wadekar ******************************************************************************/ 38371cb26eaSVarun Wadekar int plat_setup_psci_ops(uintptr_t sec_entrypoint, 38471cb26eaSVarun Wadekar const plat_psci_ops_t **psci_ops) 38508438e24SVarun Wadekar { 38671cb26eaSVarun Wadekar psci_power_state_t target_state = { { PSCI_LOCAL_STATE_RUN } }; 38771cb26eaSVarun Wadekar 38871cb26eaSVarun Wadekar /* 38971cb26eaSVarun Wadekar * Flush entrypoint variable to PoC since it will be 39071cb26eaSVarun Wadekar * accessed after a reset with the caches turned off. 39171cb26eaSVarun Wadekar */ 39271cb26eaSVarun Wadekar tegra_sec_entry_point = sec_entrypoint; 39371cb26eaSVarun Wadekar flush_dcache_range((uint64_t)&tegra_sec_entry_point, sizeof(uint64_t)); 39471cb26eaSVarun Wadekar 39508438e24SVarun Wadekar /* 39608438e24SVarun Wadekar * Reset hardware settings. 39708438e24SVarun Wadekar */ 398*b36aea5aSAnthony Zhou (void)tegra_soc_pwr_domain_on_finish(&target_state); 39908438e24SVarun Wadekar 40008438e24SVarun Wadekar /* 40171cb26eaSVarun Wadekar * Initialize PSCI ops struct 40208438e24SVarun Wadekar */ 40371cb26eaSVarun Wadekar *psci_ops = &tegra_plat_psci_ops; 40408438e24SVarun Wadekar 40508438e24SVarun Wadekar return 0; 40608438e24SVarun Wadekar } 4072693f1dbSVarun Wadekar 4082693f1dbSVarun Wadekar /******************************************************************************* 4092693f1dbSVarun Wadekar * Platform handler to calculate the proper target power level at the 4102693f1dbSVarun Wadekar * specified affinity level 4112693f1dbSVarun Wadekar ******************************************************************************/ 4122693f1dbSVarun Wadekar plat_local_state_t plat_get_target_pwr_state(unsigned int lvl, 4132693f1dbSVarun Wadekar const plat_local_state_t *states, 4142693f1dbSVarun Wadekar unsigned int ncpu) 4152693f1dbSVarun Wadekar { 416a7cd0953SVarun Wadekar return tegra_soc_get_target_pwr_state(lvl, states, ncpu); 4172693f1dbSVarun Wadekar } 418