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 3045c334e6SChen-Yu Tsai void __secure psci_save_target_pc(int cpu, u32 pc) 3145c334e6SChen-Yu Tsai { 3245c334e6SChen-Yu Tsai psci_target_pc[cpu] = pc; 33*1a047c23SPatrick Delaunay psci_context_id[cpu] = 0; 34*1a047c23SPatrick Delaunay dsb(); 35*1a047c23SPatrick Delaunay } 36*1a047c23SPatrick Delaunay 37*1a047c23SPatrick Delaunay void __secure psci_save(int cpu, u32 pc, u32 context_id) 38*1a047c23SPatrick Delaunay { 39*1a047c23SPatrick Delaunay psci_target_pc[cpu] = pc; 40*1a047c23SPatrick Delaunay psci_context_id[cpu] = context_id; 41a78cd861STom Rini dsb(); 4245c334e6SChen-Yu Tsai } 4345c334e6SChen-Yu Tsai 4445c334e6SChen-Yu Tsai u32 __secure psci_get_target_pc(int cpu) 4545c334e6SChen-Yu Tsai { 4645c334e6SChen-Yu Tsai return psci_target_pc[cpu]; 4745c334e6SChen-Yu Tsai } 4845c334e6SChen-Yu Tsai 49*1a047c23SPatrick Delaunay u32 __secure psci_get_context_id(int cpu) 50*1a047c23SPatrick Delaunay { 51*1a047c23SPatrick Delaunay return psci_context_id[cpu]; 52*1a047c23SPatrick Delaunay } 53*1a047c23SPatrick Delaunay 54