aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/psci.c
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2015-07-31 10:46:17 -0400
committerWill Deacon <will.deacon@arm.com>2015-08-03 07:35:00 -0400
commit5211df00a4b595b96a7721a1253074b327945d33 (patch)
treecda7331e85fb141e5a857028bc37f9b9edca01fa /drivers/firmware/psci.c
parentbff60792f994a87324ab57e89e945b4572b1ef77 (diff)
drivers: psci: support native SMC{32,64} calls
A 32-bit OS cannot make calls with SMC64 IDs, while a 64-bit OS must invoke some PSCI functions with SMC64 IDs. This patch introduces and makes use of a new macro to choose the appropriate IDs based on the register width of the OS, which will allow 32-bit callers to use the PSCI client code. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Hanjun Guo <hanjun.guo@linaro.org> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/firmware/psci.c')
-rw-r--r--drivers/firmware/psci.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 36e2cea3809b..a6956007dd38 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -28,6 +28,18 @@
28#include <asm/smp_plat.h> 28#include <asm/smp_plat.h>
29 29
30/* 30/*
31 * While a 64-bit OS can make calls with SMC32 calling conventions, for some
32 * calls it is necessary to use SMC64 to pass or return 64-bit values. For such
33 * calls PSCI_0_2_FN_NATIVE(x) will choose the appropriate (native-width)
34 * function ID.
35 */
36#ifdef CONFIG_64BIT
37#define PSCI_0_2_FN_NATIVE(name) PSCI_0_2_FN64_##name
38#else
39#define PSCI_0_2_FN_NATIVE(name) PSCI_0_2_FN_##name
40#endif
41
42/*
31 * The CPU any Trusted OS is resident on. The trusted OS may reject CPU_OFF 43 * The CPU any Trusted OS is resident on. The trusted OS may reject CPU_OFF
32 * calls to its resident CPU, so we must avoid issuing those. We never migrate 44 * calls to its resident CPU, so we must avoid issuing those. We never migrate
33 * a Trusted OS even if it claims to be capable of migration -- doing so will 45 * a Trusted OS even if it claims to be capable of migration -- doing so will
@@ -122,8 +134,8 @@ static int psci_migrate(unsigned long cpuid)
122static int psci_affinity_info(unsigned long target_affinity, 134static int psci_affinity_info(unsigned long target_affinity,
123 unsigned long lowest_affinity_level) 135 unsigned long lowest_affinity_level)
124{ 136{
125 return invoke_psci_fn(PSCI_0_2_FN64_AFFINITY_INFO, target_affinity, 137 return invoke_psci_fn(PSCI_0_2_FN_NATIVE(AFFINITY_INFO),
126 lowest_affinity_level, 0); 138 target_affinity, lowest_affinity_level, 0);
127} 139}
128 140
129static int psci_migrate_info_type(void) 141static int psci_migrate_info_type(void)
@@ -133,7 +145,8 @@ static int psci_migrate_info_type(void)
133 145
134static unsigned long psci_migrate_info_up_cpu(void) 146static unsigned long psci_migrate_info_up_cpu(void)
135{ 147{
136 return invoke_psci_fn(PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU, 0, 0, 0); 148 return invoke_psci_fn(PSCI_0_2_FN_NATIVE(MIGRATE_INFO_UP_CPU),
149 0, 0, 0);
137} 150}
138 151
139static int get_set_conduit_method(struct device_node *np) 152static int get_set_conduit_method(struct device_node *np)
@@ -211,16 +224,16 @@ static void __init psci_init_migrate(void)
211static void __init psci_0_2_set_functions(void) 224static void __init psci_0_2_set_functions(void)
212{ 225{
213 pr_info("Using standard PSCI v0.2 function IDs\n"); 226 pr_info("Using standard PSCI v0.2 function IDs\n");
214 psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND; 227 psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN_NATIVE(CPU_SUSPEND);
215 psci_ops.cpu_suspend = psci_cpu_suspend; 228 psci_ops.cpu_suspend = psci_cpu_suspend;
216 229
217 psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF; 230 psci_function_id[PSCI_FN_CPU_OFF] = PSCI_0_2_FN_CPU_OFF;
218 psci_ops.cpu_off = psci_cpu_off; 231 psci_ops.cpu_off = psci_cpu_off;
219 232
220 psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN64_CPU_ON; 233 psci_function_id[PSCI_FN_CPU_ON] = PSCI_0_2_FN_NATIVE(CPU_ON);
221 psci_ops.cpu_on = psci_cpu_on; 234 psci_ops.cpu_on = psci_cpu_on;
222 235
223 psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN64_MIGRATE; 236 psci_function_id[PSCI_FN_MIGRATE] = PSCI_0_2_FN_NATIVE(MIGRATE);
224 psci_ops.migrate = psci_migrate; 237 psci_ops.migrate = psci_migrate;
225 238
226 psci_ops.affinity_info = psci_affinity_info; 239 psci_ops.affinity_info = psci_affinity_info;