xref: /rk3399_ARM-atf/lib/psci/psci_main.c (revision cf0b1492ede6cbbf788144a56d276d8d7924500a)
1532ed618SSoby Mathew /*
2532ed618SSoby Mathew  * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
3532ed618SSoby Mathew  *
4532ed618SSoby Mathew  * Redistribution and use in source and binary forms, with or without
5532ed618SSoby Mathew  * modification, are permitted provided that the following conditions are met:
6532ed618SSoby Mathew  *
7532ed618SSoby Mathew  * Redistributions of source code must retain the above copyright notice, this
8532ed618SSoby Mathew  * list of conditions and the following disclaimer.
9532ed618SSoby Mathew  *
10532ed618SSoby Mathew  * Redistributions in binary form must reproduce the above copyright notice,
11532ed618SSoby Mathew  * this list of conditions and the following disclaimer in the documentation
12532ed618SSoby Mathew  * and/or other materials provided with the distribution.
13532ed618SSoby Mathew  *
14532ed618SSoby Mathew  * Neither the name of ARM nor the names of its contributors may be used
15532ed618SSoby Mathew  * to endorse or promote products derived from this software without specific
16532ed618SSoby Mathew  * prior written permission.
17532ed618SSoby Mathew  *
18532ed618SSoby Mathew  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19532ed618SSoby Mathew  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20532ed618SSoby Mathew  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21532ed618SSoby Mathew  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22532ed618SSoby Mathew  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23532ed618SSoby Mathew  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24532ed618SSoby Mathew  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25532ed618SSoby Mathew  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26532ed618SSoby Mathew  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27532ed618SSoby Mathew  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28532ed618SSoby Mathew  * POSSIBILITY OF SUCH DAMAGE.
29532ed618SSoby Mathew  */
30532ed618SSoby Mathew 
31532ed618SSoby Mathew #include <arch.h>
32532ed618SSoby Mathew #include <arch_helpers.h>
33532ed618SSoby Mathew #include <assert.h>
34532ed618SSoby Mathew #include <debug.h>
35532ed618SSoby Mathew #include <platform.h>
36*cf0b1492SSoby Mathew #include <smcc.h>
37532ed618SSoby Mathew #include <string.h>
38532ed618SSoby Mathew #include "psci_private.h"
39532ed618SSoby Mathew 
40532ed618SSoby Mathew /*******************************************************************************
41532ed618SSoby Mathew  * PSCI frontend api for servicing SMCs. Described in the PSCI spec.
42532ed618SSoby Mathew  ******************************************************************************/
43532ed618SSoby Mathew int psci_cpu_on(u_register_t target_cpu,
44532ed618SSoby Mathew 		uintptr_t entrypoint,
45532ed618SSoby Mathew 		u_register_t context_id)
46532ed618SSoby Mathew 
47532ed618SSoby Mathew {
48532ed618SSoby Mathew 	int rc;
49532ed618SSoby Mathew 	entry_point_info_t ep;
50532ed618SSoby Mathew 
51532ed618SSoby Mathew 	/* Determine if the cpu exists of not */
52532ed618SSoby Mathew 	rc = psci_validate_mpidr(target_cpu);
53532ed618SSoby Mathew 	if (rc != PSCI_E_SUCCESS)
54532ed618SSoby Mathew 		return PSCI_E_INVALID_PARAMS;
55532ed618SSoby Mathew 
56532ed618SSoby Mathew 	/* Validate the entry point and get the entry_point_info */
57532ed618SSoby Mathew 	rc = psci_validate_entry_point(&ep, entrypoint, context_id);
58532ed618SSoby Mathew 	if (rc != PSCI_E_SUCCESS)
59532ed618SSoby Mathew 		return rc;
60532ed618SSoby Mathew 
61532ed618SSoby Mathew 	/*
62532ed618SSoby Mathew 	 * To turn this cpu on, specify which power
63532ed618SSoby Mathew 	 * levels need to be turned on
64532ed618SSoby Mathew 	 */
65532ed618SSoby Mathew 	return psci_cpu_on_start(target_cpu, &ep);
66532ed618SSoby Mathew }
67532ed618SSoby Mathew 
68532ed618SSoby Mathew unsigned int psci_version(void)
69532ed618SSoby Mathew {
70532ed618SSoby Mathew 	return PSCI_MAJOR_VER | PSCI_MINOR_VER;
71532ed618SSoby Mathew }
72532ed618SSoby Mathew 
73532ed618SSoby Mathew int psci_cpu_suspend(unsigned int power_state,
74532ed618SSoby Mathew 		     uintptr_t entrypoint,
75532ed618SSoby Mathew 		     u_register_t context_id)
76532ed618SSoby Mathew {
77532ed618SSoby Mathew 	int rc;
78532ed618SSoby Mathew 	unsigned int target_pwrlvl, is_power_down_state;
79532ed618SSoby Mathew 	entry_point_info_t ep;
80532ed618SSoby Mathew 	psci_power_state_t state_info = { {PSCI_LOCAL_STATE_RUN} };
81532ed618SSoby Mathew 	plat_local_state_t cpu_pd_state;
82532ed618SSoby Mathew 
83532ed618SSoby Mathew 	/* Validate the power_state parameter */
84532ed618SSoby Mathew 	rc = psci_validate_power_state(power_state, &state_info);
85532ed618SSoby Mathew 	if (rc != PSCI_E_SUCCESS) {
86532ed618SSoby Mathew 		assert(rc == PSCI_E_INVALID_PARAMS);
87532ed618SSoby Mathew 		return rc;
88532ed618SSoby Mathew 	}
89532ed618SSoby Mathew 
90532ed618SSoby Mathew 	/*
91532ed618SSoby Mathew 	 * Get the value of the state type bit from the power state parameter.
92532ed618SSoby Mathew 	 */
93532ed618SSoby Mathew 	is_power_down_state = psci_get_pstate_type(power_state);
94532ed618SSoby Mathew 
95532ed618SSoby Mathew 	/* Sanity check the requested suspend levels */
96532ed618SSoby Mathew 	assert(psci_validate_suspend_req(&state_info, is_power_down_state)
97532ed618SSoby Mathew 			== PSCI_E_SUCCESS);
98532ed618SSoby Mathew 
99532ed618SSoby Mathew 	target_pwrlvl = psci_find_target_suspend_lvl(&state_info);
100532ed618SSoby Mathew 
101532ed618SSoby Mathew 	/* Fast path for CPU standby.*/
102532ed618SSoby Mathew 	if (is_cpu_standby_req(is_power_down_state, target_pwrlvl)) {
103532ed618SSoby Mathew 		if  (!psci_plat_pm_ops->cpu_standby)
104532ed618SSoby Mathew 			return PSCI_E_INVALID_PARAMS;
105532ed618SSoby Mathew 
106532ed618SSoby Mathew 		/*
107532ed618SSoby Mathew 		 * Set the state of the CPU power domain to the platform
108532ed618SSoby Mathew 		 * specific retention state and enter the standby state.
109532ed618SSoby Mathew 		 */
110532ed618SSoby Mathew 		cpu_pd_state = state_info.pwr_domain_state[PSCI_CPU_PWR_LVL];
111532ed618SSoby Mathew 		psci_set_cpu_local_state(cpu_pd_state);
112532ed618SSoby Mathew 
113532ed618SSoby Mathew #if ENABLE_PSCI_STAT
114532ed618SSoby Mathew 		/*
115532ed618SSoby Mathew 		 * Capture time-stamp before CPU standby
116532ed618SSoby Mathew 		 * No cache maintenance is needed as caches
117532ed618SSoby Mathew 		 * are ON through out the CPU standby operation.
118532ed618SSoby Mathew 		 */
119532ed618SSoby Mathew 		PMF_CAPTURE_TIMESTAMP(psci_svc, PSCI_STAT_ID_ENTER_LOW_PWR,
120532ed618SSoby Mathew 			PMF_NO_CACHE_MAINT);
121532ed618SSoby Mathew #endif
122532ed618SSoby Mathew 
123532ed618SSoby Mathew 		psci_plat_pm_ops->cpu_standby(cpu_pd_state);
124532ed618SSoby Mathew 
125532ed618SSoby Mathew 		/* Upon exit from standby, set the state back to RUN. */
126532ed618SSoby Mathew 		psci_set_cpu_local_state(PSCI_LOCAL_STATE_RUN);
127532ed618SSoby Mathew 
128532ed618SSoby Mathew #if ENABLE_PSCI_STAT
129532ed618SSoby Mathew 		/* Capture time-stamp after CPU standby */
130532ed618SSoby Mathew 		PMF_CAPTURE_TIMESTAMP(psci_svc, PSCI_STAT_ID_EXIT_LOW_PWR,
131532ed618SSoby Mathew 			PMF_NO_CACHE_MAINT);
132532ed618SSoby Mathew 
133532ed618SSoby Mathew 		/* Update PSCI stats */
134532ed618SSoby Mathew 		psci_stats_update_pwr_up(PSCI_CPU_PWR_LVL, &state_info,
135532ed618SSoby Mathew 			PMF_NO_CACHE_MAINT);
136532ed618SSoby Mathew #endif
137532ed618SSoby Mathew 
138532ed618SSoby Mathew 		return PSCI_E_SUCCESS;
139532ed618SSoby Mathew 	}
140532ed618SSoby Mathew 
141532ed618SSoby Mathew 	/*
142532ed618SSoby Mathew 	 * If a power down state has been requested, we need to verify entry
143532ed618SSoby Mathew 	 * point and program entry information.
144532ed618SSoby Mathew 	 */
145532ed618SSoby Mathew 	if (is_power_down_state) {
146532ed618SSoby Mathew 		rc = psci_validate_entry_point(&ep, entrypoint, context_id);
147532ed618SSoby Mathew 		if (rc != PSCI_E_SUCCESS)
148532ed618SSoby Mathew 			return rc;
149532ed618SSoby Mathew 	}
150532ed618SSoby Mathew 
151532ed618SSoby Mathew 	/*
152532ed618SSoby Mathew 	 * Do what is needed to enter the power down state. Upon success,
153532ed618SSoby Mathew 	 * enter the final wfi which will power down this CPU. This function
154532ed618SSoby Mathew 	 * might return if the power down was abandoned for any reason, e.g.
155532ed618SSoby Mathew 	 * arrival of an interrupt
156532ed618SSoby Mathew 	 */
157532ed618SSoby Mathew 	psci_cpu_suspend_start(&ep,
158532ed618SSoby Mathew 			    target_pwrlvl,
159532ed618SSoby Mathew 			    &state_info,
160532ed618SSoby Mathew 			    is_power_down_state);
161532ed618SSoby Mathew 
162532ed618SSoby Mathew 	return PSCI_E_SUCCESS;
163532ed618SSoby Mathew }
164532ed618SSoby Mathew 
165532ed618SSoby Mathew 
166532ed618SSoby Mathew int psci_system_suspend(uintptr_t entrypoint, u_register_t context_id)
167532ed618SSoby Mathew {
168532ed618SSoby Mathew 	int rc;
169532ed618SSoby Mathew 	psci_power_state_t state_info;
170532ed618SSoby Mathew 	entry_point_info_t ep;
171532ed618SSoby Mathew 
172532ed618SSoby Mathew 	/* Check if the current CPU is the last ON CPU in the system */
173532ed618SSoby Mathew 	if (!psci_is_last_on_cpu())
174532ed618SSoby Mathew 		return PSCI_E_DENIED;
175532ed618SSoby Mathew 
176532ed618SSoby Mathew 	/* Validate the entry point and get the entry_point_info */
177532ed618SSoby Mathew 	rc = psci_validate_entry_point(&ep, entrypoint, context_id);
178532ed618SSoby Mathew 	if (rc != PSCI_E_SUCCESS)
179532ed618SSoby Mathew 		return rc;
180532ed618SSoby Mathew 
181532ed618SSoby Mathew 	/* Query the psci_power_state for system suspend */
182532ed618SSoby Mathew 	psci_query_sys_suspend_pwrstate(&state_info);
183532ed618SSoby Mathew 
184532ed618SSoby Mathew 	/* Ensure that the psci_power_state makes sense */
185532ed618SSoby Mathew 	assert(psci_find_target_suspend_lvl(&state_info) == PLAT_MAX_PWR_LVL);
186532ed618SSoby Mathew 	assert(psci_validate_suspend_req(&state_info, PSTATE_TYPE_POWERDOWN)
187532ed618SSoby Mathew 						== PSCI_E_SUCCESS);
188532ed618SSoby Mathew 	assert(is_local_state_off(state_info.pwr_domain_state[PLAT_MAX_PWR_LVL]));
189532ed618SSoby Mathew 
190532ed618SSoby Mathew 	/*
191532ed618SSoby Mathew 	 * Do what is needed to enter the system suspend state. This function
192532ed618SSoby Mathew 	 * might return if the power down was abandoned for any reason, e.g.
193532ed618SSoby Mathew 	 * arrival of an interrupt
194532ed618SSoby Mathew 	 */
195532ed618SSoby Mathew 	psci_cpu_suspend_start(&ep,
196532ed618SSoby Mathew 			    PLAT_MAX_PWR_LVL,
197532ed618SSoby Mathew 			    &state_info,
198532ed618SSoby Mathew 			    PSTATE_TYPE_POWERDOWN);
199532ed618SSoby Mathew 
200532ed618SSoby Mathew 	return PSCI_E_SUCCESS;
201532ed618SSoby Mathew }
202532ed618SSoby Mathew 
203532ed618SSoby Mathew int psci_cpu_off(void)
204532ed618SSoby Mathew {
205532ed618SSoby Mathew 	int rc;
206532ed618SSoby Mathew 	unsigned int target_pwrlvl = PLAT_MAX_PWR_LVL;
207532ed618SSoby Mathew 
208532ed618SSoby Mathew 	/*
209532ed618SSoby Mathew 	 * Do what is needed to power off this CPU and possible higher power
210532ed618SSoby Mathew 	 * levels if it able to do so. Upon success, enter the final wfi
211532ed618SSoby Mathew 	 * which will power down this CPU.
212532ed618SSoby Mathew 	 */
213532ed618SSoby Mathew 	rc = psci_do_cpu_off(target_pwrlvl);
214532ed618SSoby Mathew 
215532ed618SSoby Mathew 	/*
216532ed618SSoby Mathew 	 * The only error cpu_off can return is E_DENIED. So check if that's
217532ed618SSoby Mathew 	 * indeed the case.
218532ed618SSoby Mathew 	 */
219532ed618SSoby Mathew 	assert(rc == PSCI_E_DENIED);
220532ed618SSoby Mathew 
221532ed618SSoby Mathew 	return rc;
222532ed618SSoby Mathew }
223532ed618SSoby Mathew 
224532ed618SSoby Mathew int psci_affinity_info(u_register_t target_affinity,
225532ed618SSoby Mathew 		       unsigned int lowest_affinity_level)
226532ed618SSoby Mathew {
227532ed618SSoby Mathew 	unsigned int target_idx;
228532ed618SSoby Mathew 
229532ed618SSoby Mathew 	/* We dont support level higher than PSCI_CPU_PWR_LVL */
230532ed618SSoby Mathew 	if (lowest_affinity_level > PSCI_CPU_PWR_LVL)
231532ed618SSoby Mathew 		return PSCI_E_INVALID_PARAMS;
232532ed618SSoby Mathew 
233532ed618SSoby Mathew 	/* Calculate the cpu index of the target */
234532ed618SSoby Mathew 	target_idx = plat_core_pos_by_mpidr(target_affinity);
235532ed618SSoby Mathew 	if (target_idx == -1)
236532ed618SSoby Mathew 		return PSCI_E_INVALID_PARAMS;
237532ed618SSoby Mathew 
238532ed618SSoby Mathew 	return psci_get_aff_info_state_by_idx(target_idx);
239532ed618SSoby Mathew }
240532ed618SSoby Mathew 
241532ed618SSoby Mathew int psci_migrate(u_register_t target_cpu)
242532ed618SSoby Mathew {
243532ed618SSoby Mathew 	int rc;
244532ed618SSoby Mathew 	u_register_t resident_cpu_mpidr;
245532ed618SSoby Mathew 
246532ed618SSoby Mathew 	rc = psci_spd_migrate_info(&resident_cpu_mpidr);
247532ed618SSoby Mathew 	if (rc != PSCI_TOS_UP_MIG_CAP)
248532ed618SSoby Mathew 		return (rc == PSCI_TOS_NOT_UP_MIG_CAP) ?
249532ed618SSoby Mathew 			  PSCI_E_DENIED : PSCI_E_NOT_SUPPORTED;
250532ed618SSoby Mathew 
251532ed618SSoby Mathew 	/*
252532ed618SSoby Mathew 	 * Migrate should only be invoked on the CPU where
253532ed618SSoby Mathew 	 * the Secure OS is resident.
254532ed618SSoby Mathew 	 */
255532ed618SSoby Mathew 	if (resident_cpu_mpidr != read_mpidr_el1())
256532ed618SSoby Mathew 		return PSCI_E_NOT_PRESENT;
257532ed618SSoby Mathew 
258532ed618SSoby Mathew 	/* Check the validity of the specified target cpu */
259532ed618SSoby Mathew 	rc = psci_validate_mpidr(target_cpu);
260532ed618SSoby Mathew 	if (rc != PSCI_E_SUCCESS)
261532ed618SSoby Mathew 		return PSCI_E_INVALID_PARAMS;
262532ed618SSoby Mathew 
263532ed618SSoby Mathew 	assert(psci_spd_pm && psci_spd_pm->svc_migrate);
264532ed618SSoby Mathew 
265532ed618SSoby Mathew 	rc = psci_spd_pm->svc_migrate(read_mpidr_el1(), target_cpu);
266532ed618SSoby Mathew 	assert(rc == PSCI_E_SUCCESS || rc == PSCI_E_INTERN_FAIL);
267532ed618SSoby Mathew 
268532ed618SSoby Mathew 	return rc;
269532ed618SSoby Mathew }
270532ed618SSoby Mathew 
271532ed618SSoby Mathew int psci_migrate_info_type(void)
272532ed618SSoby Mathew {
273532ed618SSoby Mathew 	u_register_t resident_cpu_mpidr;
274532ed618SSoby Mathew 
275532ed618SSoby Mathew 	return psci_spd_migrate_info(&resident_cpu_mpidr);
276532ed618SSoby Mathew }
277532ed618SSoby Mathew 
278532ed618SSoby Mathew long psci_migrate_info_up_cpu(void)
279532ed618SSoby Mathew {
280532ed618SSoby Mathew 	u_register_t resident_cpu_mpidr;
281532ed618SSoby Mathew 	int rc;
282532ed618SSoby Mathew 
283532ed618SSoby Mathew 	/*
284532ed618SSoby Mathew 	 * Return value of this depends upon what
285532ed618SSoby Mathew 	 * psci_spd_migrate_info() returns.
286532ed618SSoby Mathew 	 */
287532ed618SSoby Mathew 	rc = psci_spd_migrate_info(&resident_cpu_mpidr);
288532ed618SSoby Mathew 	if (rc != PSCI_TOS_NOT_UP_MIG_CAP && rc != PSCI_TOS_UP_MIG_CAP)
289532ed618SSoby Mathew 		return PSCI_E_INVALID_PARAMS;
290532ed618SSoby Mathew 
291532ed618SSoby Mathew 	return resident_cpu_mpidr;
292532ed618SSoby Mathew }
293532ed618SSoby Mathew 
294532ed618SSoby Mathew int psci_features(unsigned int psci_fid)
295532ed618SSoby Mathew {
296532ed618SSoby Mathew 	unsigned int local_caps = psci_caps;
297532ed618SSoby Mathew 
298532ed618SSoby Mathew 	/* Check if it is a 64 bit function */
299532ed618SSoby Mathew 	if (((psci_fid >> FUNCID_CC_SHIFT) & FUNCID_CC_MASK) == SMC_64)
300532ed618SSoby Mathew 		local_caps &= PSCI_CAP_64BIT_MASK;
301532ed618SSoby Mathew 
302532ed618SSoby Mathew 	/* Check for invalid fid */
303532ed618SSoby Mathew 	if (!(is_std_svc_call(psci_fid) && is_valid_fast_smc(psci_fid)
304532ed618SSoby Mathew 			&& is_psci_fid(psci_fid)))
305532ed618SSoby Mathew 		return PSCI_E_NOT_SUPPORTED;
306532ed618SSoby Mathew 
307532ed618SSoby Mathew 
308532ed618SSoby Mathew 	/* Check if the psci fid is supported or not */
309532ed618SSoby Mathew 	if (!(local_caps & define_psci_cap(psci_fid)))
310532ed618SSoby Mathew 		return PSCI_E_NOT_SUPPORTED;
311532ed618SSoby Mathew 
312532ed618SSoby Mathew 	/* Format the feature flags */
313532ed618SSoby Mathew 	if (psci_fid == PSCI_CPU_SUSPEND_AARCH32 ||
314532ed618SSoby Mathew 			psci_fid == PSCI_CPU_SUSPEND_AARCH64) {
315532ed618SSoby Mathew 		/*
316532ed618SSoby Mathew 		 * The trusted firmware does not support OS Initiated Mode.
317532ed618SSoby Mathew 		 */
318532ed618SSoby Mathew 		return (FF_PSTATE << FF_PSTATE_SHIFT) |
319532ed618SSoby Mathew 			((!FF_SUPPORTS_OS_INIT_MODE) << FF_MODE_SUPPORT_SHIFT);
320532ed618SSoby Mathew 	}
321532ed618SSoby Mathew 
322532ed618SSoby Mathew 	/* Return 0 for all other fid's */
323532ed618SSoby Mathew 	return PSCI_E_SUCCESS;
324532ed618SSoby Mathew }
325532ed618SSoby Mathew 
326532ed618SSoby Mathew /*******************************************************************************
327532ed618SSoby Mathew  * PSCI top level handler for servicing SMCs.
328532ed618SSoby Mathew  ******************************************************************************/
329*cf0b1492SSoby Mathew u_register_t psci_smc_handler(uint32_t smc_fid,
330532ed618SSoby Mathew 			  u_register_t x1,
331532ed618SSoby Mathew 			  u_register_t x2,
332532ed618SSoby Mathew 			  u_register_t x3,
333532ed618SSoby Mathew 			  u_register_t x4,
334532ed618SSoby Mathew 			  void *cookie,
335532ed618SSoby Mathew 			  void *handle,
336532ed618SSoby Mathew 			  u_register_t flags)
337532ed618SSoby Mathew {
338532ed618SSoby Mathew 	if (is_caller_secure(flags))
339*cf0b1492SSoby Mathew 		return SMC_UNK;
340532ed618SSoby Mathew 
341532ed618SSoby Mathew 	/* Check the fid against the capabilities */
342532ed618SSoby Mathew 	if (!(psci_caps & define_psci_cap(smc_fid)))
343*cf0b1492SSoby Mathew 		return SMC_UNK;
344532ed618SSoby Mathew 
345532ed618SSoby Mathew 	if (((smc_fid >> FUNCID_CC_SHIFT) & FUNCID_CC_MASK) == SMC_32) {
346532ed618SSoby Mathew 		/* 32-bit PSCI function, clear top parameter bits */
347532ed618SSoby Mathew 
348532ed618SSoby Mathew 		x1 = (uint32_t)x1;
349532ed618SSoby Mathew 		x2 = (uint32_t)x2;
350532ed618SSoby Mathew 		x3 = (uint32_t)x3;
351532ed618SSoby Mathew 
352532ed618SSoby Mathew 		switch (smc_fid) {
353532ed618SSoby Mathew 		case PSCI_VERSION:
354*cf0b1492SSoby Mathew 			return psci_version();
355532ed618SSoby Mathew 
356532ed618SSoby Mathew 		case PSCI_CPU_OFF:
357*cf0b1492SSoby Mathew 			return psci_cpu_off();
358532ed618SSoby Mathew 
359532ed618SSoby Mathew 		case PSCI_CPU_SUSPEND_AARCH32:
360*cf0b1492SSoby Mathew 			return psci_cpu_suspend(x1, x2, x3);
361532ed618SSoby Mathew 
362532ed618SSoby Mathew 		case PSCI_CPU_ON_AARCH32:
363*cf0b1492SSoby Mathew 			return psci_cpu_on(x1, x2, x3);
364532ed618SSoby Mathew 
365532ed618SSoby Mathew 		case PSCI_AFFINITY_INFO_AARCH32:
366*cf0b1492SSoby Mathew 			return psci_affinity_info(x1, x2);
367532ed618SSoby Mathew 
368532ed618SSoby Mathew 		case PSCI_MIG_AARCH32:
369*cf0b1492SSoby Mathew 			return psci_migrate(x1);
370532ed618SSoby Mathew 
371532ed618SSoby Mathew 		case PSCI_MIG_INFO_TYPE:
372*cf0b1492SSoby Mathew 			return psci_migrate_info_type();
373532ed618SSoby Mathew 
374532ed618SSoby Mathew 		case PSCI_MIG_INFO_UP_CPU_AARCH32:
375*cf0b1492SSoby Mathew 			return psci_migrate_info_up_cpu();
376532ed618SSoby Mathew 
377532ed618SSoby Mathew 		case PSCI_SYSTEM_SUSPEND_AARCH32:
378*cf0b1492SSoby Mathew 			return psci_system_suspend(x1, x2);
379532ed618SSoby Mathew 
380532ed618SSoby Mathew 		case PSCI_SYSTEM_OFF:
381532ed618SSoby Mathew 			psci_system_off();
382532ed618SSoby Mathew 			/* We should never return from psci_system_off() */
383532ed618SSoby Mathew 
384532ed618SSoby Mathew 		case PSCI_SYSTEM_RESET:
385532ed618SSoby Mathew 			psci_system_reset();
386532ed618SSoby Mathew 			/* We should never return from psci_system_reset() */
387532ed618SSoby Mathew 
388532ed618SSoby Mathew 		case PSCI_FEATURES:
389*cf0b1492SSoby Mathew 			return psci_features(x1);
390532ed618SSoby Mathew 
391532ed618SSoby Mathew #if ENABLE_PSCI_STAT
392532ed618SSoby Mathew 		case PSCI_STAT_RESIDENCY_AARCH32:
393*cf0b1492SSoby Mathew 			return psci_stat_residency(x1, x2);
394532ed618SSoby Mathew 
395532ed618SSoby Mathew 		case PSCI_STAT_COUNT_AARCH32:
396*cf0b1492SSoby Mathew 			return psci_stat_count(x1, x2);
397532ed618SSoby Mathew #endif
398532ed618SSoby Mathew 
399532ed618SSoby Mathew 		default:
400532ed618SSoby Mathew 			break;
401532ed618SSoby Mathew 		}
402532ed618SSoby Mathew 	} else {
403532ed618SSoby Mathew 		/* 64-bit PSCI function */
404532ed618SSoby Mathew 
405532ed618SSoby Mathew 		switch (smc_fid) {
406532ed618SSoby Mathew 		case PSCI_CPU_SUSPEND_AARCH64:
407*cf0b1492SSoby Mathew 			return psci_cpu_suspend(x1, x2, x3);
408532ed618SSoby Mathew 
409532ed618SSoby Mathew 		case PSCI_CPU_ON_AARCH64:
410*cf0b1492SSoby Mathew 			return psci_cpu_on(x1, x2, x3);
411532ed618SSoby Mathew 
412532ed618SSoby Mathew 		case PSCI_AFFINITY_INFO_AARCH64:
413*cf0b1492SSoby Mathew 			return psci_affinity_info(x1, x2);
414532ed618SSoby Mathew 
415532ed618SSoby Mathew 		case PSCI_MIG_AARCH64:
416*cf0b1492SSoby Mathew 			return psci_migrate(x1);
417532ed618SSoby Mathew 
418532ed618SSoby Mathew 		case PSCI_MIG_INFO_UP_CPU_AARCH64:
419*cf0b1492SSoby Mathew 			return psci_migrate_info_up_cpu();
420532ed618SSoby Mathew 
421532ed618SSoby Mathew 		case PSCI_SYSTEM_SUSPEND_AARCH64:
422*cf0b1492SSoby Mathew 			return psci_system_suspend(x1, x2);
423532ed618SSoby Mathew 
424532ed618SSoby Mathew #if ENABLE_PSCI_STAT
425532ed618SSoby Mathew 		case PSCI_STAT_RESIDENCY_AARCH64:
426*cf0b1492SSoby Mathew 			return psci_stat_residency(x1, x2);
427532ed618SSoby Mathew 
428532ed618SSoby Mathew 		case PSCI_STAT_COUNT_AARCH64:
429*cf0b1492SSoby Mathew 			return psci_stat_count(x1, x2);
430532ed618SSoby Mathew #endif
431532ed618SSoby Mathew 
432532ed618SSoby Mathew 		default:
433532ed618SSoby Mathew 			break;
434532ed618SSoby Mathew 		}
435532ed618SSoby Mathew 	}
436532ed618SSoby Mathew 
437532ed618SSoby Mathew 	WARN("Unimplemented PSCI Call: 0x%x \n", smc_fid);
438*cf0b1492SSoby Mathew 	return SMC_UNK;
439532ed618SSoby Mathew }
440