1 /* 2 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <plat_private.h> 8 #include <pm_common.h> 9 #include <common/debug.h> 10 #include <lib/mmio.h> 11 #include <lib/psci/psci.h> 12 #include <plat/common/platform.h> 13 14 #include "pm_api_sys.h" 15 #include "pm_client.h" 16 17 static uintptr_t versal_sec_entry; 18 19 static int versal_pwr_domain_on(u_register_t mpidr) 20 { 21 unsigned int cpu_id = plat_core_pos_by_mpidr(mpidr); 22 const struct pm_proc *proc; 23 24 VERBOSE("%s: mpidr: 0x%lx\n", __func__, mpidr); 25 26 if (cpu_id == -1) 27 return PSCI_E_INTERN_FAIL; 28 29 proc = pm_get_proc(cpu_id); 30 31 /* Send request to PMC to wake up selected ACPU core */ 32 pm_req_wakeup(proc->node_id, (versal_sec_entry & 0xFFFFFFFF) | 0x1, 33 versal_sec_entry >> 32, 0); 34 35 /* Clear power down request */ 36 pm_client_wakeup(proc); 37 38 return PSCI_E_SUCCESS; 39 } 40 41 void versal_pwr_domain_on_finish(const psci_power_state_t *target_state) 42 { 43 /* Enable the gic cpu interface */ 44 plat_versal_gic_pcpu_init(); 45 46 /* Program the gic per-cpu distributor or re-distributor interface */ 47 plat_versal_gic_cpuif_enable(); 48 } 49 50 static const struct plat_psci_ops versal_nopmc_psci_ops = { 51 .pwr_domain_on = versal_pwr_domain_on, 52 .pwr_domain_on_finish = versal_pwr_domain_on_finish, 53 }; 54 55 /******************************************************************************* 56 * Export the platform specific power ops. 57 ******************************************************************************/ 58 int plat_setup_psci_ops(uintptr_t sec_entrypoint, 59 const struct plat_psci_ops **psci_ops) 60 { 61 versal_sec_entry = sec_entrypoint; 62 63 *psci_ops = &versal_nopmc_psci_ops; 64 65 return 0; 66 } 67