1 /*
2  * Copyright 2020 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #include "hf/cpu.h"
10 #include "hf/dlog.h"
11 
12 #include "psci.h"
13 
14 static uint32_t el3_psci_version;
15 
16 /**
17  * Returns the PSCI version gathered from the EL3 PSCI layer during init.
18  */
plat_psci_version_get(void)19 uint32_t plat_psci_version_get(void)
20 {
21 	return el3_psci_version;
22 }
23 
24 /**
25  * Initialize the platform power managment module in context of
26  * running the Hypervisor. In particular it gathers the PSCI version
27  * from the EL3 PSCI firmware.
28  */
plat_psci_init(void)29 void plat_psci_init(void)
30 {
31 	struct ffa_value smc_res =
32 		smc32(PSCI_VERSION, 0, 0, 0, 0, 0, 0, SMCCC_CALLER_HYPERVISOR);
33 
34 	el3_psci_version = smc_res.func;
35 
36 	/* Check there's nothing unexpected about PSCI. */
37 	switch (el3_psci_version) {
38 	case PSCI_VERSION_0_2:
39 	case PSCI_VERSION_1_0:
40 	case PSCI_VERSION_1_1:
41 		/* Supported EL3 PSCI version. */
42 		dlog_info("Found PSCI version: %#x\n", el3_psci_version);
43 		break;
44 
45 	default:
46 		/* Unsupported EL3 PSCI version. Log a warning but continue. */
47 		dlog_warning("Unknown PSCI version: %#x\n", el3_psci_version);
48 		el3_psci_version = 0;
49 		break;
50 	}
51 }
52 
plat_psci_cpu_suspend(uint32_t power_state)53 void plat_psci_cpu_suspend(uint32_t power_state)
54 {
55 	(void)power_state;
56 }
57 
plat_psci_cpu_resume(struct cpu * c,ipaddr_t entry_point)58 void plat_psci_cpu_resume(struct cpu *c, ipaddr_t entry_point)
59 {
60 	(void)c;
61 	(void)entry_point;
62 }
63