1*85f199b7SChia-Wei Wang /* 2*85f199b7SChia-Wei Wang * Copyright (c) 2023, Aspeed Technology Inc. 3*85f199b7SChia-Wei Wang * 4*85f199b7SChia-Wei Wang * SPDX-License-Identifier: BSD-3-Clause 5*85f199b7SChia-Wei Wang */ 6*85f199b7SChia-Wei Wang 7*85f199b7SChia-Wei Wang #include <arch.h> 8*85f199b7SChia-Wei Wang #include <common/debug.h> 9*85f199b7SChia-Wei Wang #include <drivers/arm/gicv3.h> 10*85f199b7SChia-Wei Wang #include <drivers/console.h> 11*85f199b7SChia-Wei Wang #include <lib/mmio.h> 12*85f199b7SChia-Wei Wang #include <lib/psci/psci.h> 13*85f199b7SChia-Wei Wang #include <plat/common/platform.h> 14*85f199b7SChia-Wei Wang 15*85f199b7SChia-Wei Wang static uintptr_t sec_ep; 16*85f199b7SChia-Wei Wang plat_pwr_domain_on(u_register_t mpidr)17*85f199b7SChia-Wei Wangstatic int plat_pwr_domain_on(u_register_t mpidr) 18*85f199b7SChia-Wei Wang { 19*85f199b7SChia-Wei Wang unsigned int cpu = plat_core_pos_by_mpidr(mpidr); 20*85f199b7SChia-Wei Wang uintptr_t ep_reg; 21*85f199b7SChia-Wei Wang 22*85f199b7SChia-Wei Wang switch (cpu) { 23*85f199b7SChia-Wei Wang case 1U: 24*85f199b7SChia-Wei Wang ep_reg = SCU_CPU_SMP_EP1; 25*85f199b7SChia-Wei Wang break; 26*85f199b7SChia-Wei Wang case 2U: 27*85f199b7SChia-Wei Wang ep_reg = SCU_CPU_SMP_EP2; 28*85f199b7SChia-Wei Wang break; 29*85f199b7SChia-Wei Wang case 3U: 30*85f199b7SChia-Wei Wang ep_reg = SCU_CPU_SMP_EP3; 31*85f199b7SChia-Wei Wang break; 32*85f199b7SChia-Wei Wang default: 33*85f199b7SChia-Wei Wang return PSCI_E_INVALID_PARAMS; 34*85f199b7SChia-Wei Wang } 35*85f199b7SChia-Wei Wang 36*85f199b7SChia-Wei Wang mmio_write_64(ep_reg, sec_ep); 37*85f199b7SChia-Wei Wang 38*85f199b7SChia-Wei Wang dsbsy(); 39*85f199b7SChia-Wei Wang 40*85f199b7SChia-Wei Wang sev(); 41*85f199b7SChia-Wei Wang 42*85f199b7SChia-Wei Wang return PSCI_E_SUCCESS; 43*85f199b7SChia-Wei Wang } 44*85f199b7SChia-Wei Wang plat_pwr_domain_on_finish(const psci_power_state_t * target_state)45*85f199b7SChia-Wei Wangstatic void plat_pwr_domain_on_finish(const psci_power_state_t *target_state) 46*85f199b7SChia-Wei Wang { 47*85f199b7SChia-Wei Wang gicv3_rdistif_init(plat_my_core_pos()); 48*85f199b7SChia-Wei Wang gicv3_cpuif_enable(plat_my_core_pos()); 49*85f199b7SChia-Wei Wang } 50*85f199b7SChia-Wei Wang 51*85f199b7SChia-Wei Wang static const plat_psci_ops_t plat_psci_ops = { 52*85f199b7SChia-Wei Wang .pwr_domain_on = plat_pwr_domain_on, 53*85f199b7SChia-Wei Wang .pwr_domain_on_finish = plat_pwr_domain_on_finish, 54*85f199b7SChia-Wei Wang }; 55*85f199b7SChia-Wei Wang plat_setup_psci_ops(uintptr_t sec_entrypoint,const plat_psci_ops_t ** psci_ops)56*85f199b7SChia-Wei Wangint plat_setup_psci_ops(uintptr_t sec_entrypoint, 57*85f199b7SChia-Wei Wang const plat_psci_ops_t **psci_ops) 58*85f199b7SChia-Wei Wang { 59*85f199b7SChia-Wei Wang sec_ep = sec_entrypoint; 60*85f199b7SChia-Wei Wang *psci_ops = &plat_psci_ops; 61*85f199b7SChia-Wei Wang 62*85f199b7SChia-Wei Wang return 0; 63*85f199b7SChia-Wei Wang } 64