xref: /openbmc/u-boot/arch/arm/cpu/armv7/psci-common.c (revision e8f80a5a)
145c334e6SChen-Yu Tsai /*
245c334e6SChen-Yu Tsai  * Common PSCI functions
345c334e6SChen-Yu Tsai  *
445c334e6SChen-Yu Tsai  * Copyright (C) 2016 Chen-Yu Tsai
545c334e6SChen-Yu Tsai  * Author: Chen-Yu Tsai <wens@csie.org>
645c334e6SChen-Yu Tsai  *
745c334e6SChen-Yu Tsai  * This program is free software; you can redistribute it and/or modify
845c334e6SChen-Yu Tsai  * it under the terms of the GNU General Public License version 2 as
945c334e6SChen-Yu Tsai  * published by the Free Software Foundation.
1045c334e6SChen-Yu Tsai  *
1145c334e6SChen-Yu Tsai  * This program is distributed in the hope that it will be useful,
1245c334e6SChen-Yu Tsai  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1345c334e6SChen-Yu Tsai  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1445c334e6SChen-Yu Tsai  * GNU General Public License for more details.
1545c334e6SChen-Yu Tsai  *
1645c334e6SChen-Yu Tsai  * You should have received a copy of the GNU General Public License
1745c334e6SChen-Yu Tsai  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
1845c334e6SChen-Yu Tsai  */
1945c334e6SChen-Yu Tsai 
2045c334e6SChen-Yu Tsai #include <config.h>
2145c334e6SChen-Yu Tsai #include <asm/armv7.h>
2245c334e6SChen-Yu Tsai #include <asm/macro.h>
2345c334e6SChen-Yu Tsai #include <asm/psci.h>
2445c334e6SChen-Yu Tsai #include <asm/secure.h>
2545c334e6SChen-Yu Tsai #include <linux/linkage.h>
2645c334e6SChen-Yu Tsai 
2745c334e6SChen-Yu Tsai static u32 psci_target_pc[CONFIG_ARMV7_PSCI_NR_CPUS] __secure_data = { 0 };
28*1a047c23SPatrick Delaunay static u32 psci_context_id[CONFIG_ARMV7_PSCI_NR_CPUS] __secure_data = { 0 };
2945c334e6SChen-Yu Tsai 
psci_save(int cpu,u32 pc,u32 context_id)30*1a047c23SPatrick Delaunay void __secure psci_save(int cpu, u32 pc, u32 context_id)
31*1a047c23SPatrick Delaunay {
32*1a047c23SPatrick Delaunay 	psci_target_pc[cpu] = pc;
33*1a047c23SPatrick Delaunay 	psci_context_id[cpu] = context_id;
34a78cd861STom Rini 	dsb();
3545c334e6SChen-Yu Tsai }
3645c334e6SChen-Yu Tsai 
psci_get_target_pc(int cpu)3745c334e6SChen-Yu Tsai u32 __secure psci_get_target_pc(int cpu)
3845c334e6SChen-Yu Tsai {
3945c334e6SChen-Yu Tsai 	return psci_target_pc[cpu];
4045c334e6SChen-Yu Tsai }
4145c334e6SChen-Yu Tsai 
psci_get_context_id(int cpu)42*1a047c23SPatrick Delaunay u32 __secure psci_get_context_id(int cpu)
43*1a047c23SPatrick Delaunay {
44*1a047c23SPatrick Delaunay 	return psci_context_id[cpu];
45*1a047c23SPatrick Delaunay }
46*1a047c23SPatrick Delaunay 
47