2 * linux/arch/arm/mach-vexpress/mcpm_platsmp.c
4 * Created by: Nicolas Pitre, November 2012
5 * Copyright: (C) 2012-2013 Linaro Limited
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * Code to handle secondary CPU bringup and hotplug for the cluster power API.
14 #include <linux/init.h>
15 #include <linux/smp.h>
16 #include <linux/spinlock.h>
20 #include <asm/smp_plat.h>
22 static int mcpm_boot_secondary(unsigned int cpu
, struct task_struct
*idle
)
24 unsigned int mpidr
, pcpu
, pcluster
, ret
;
25 extern void secondary_startup(void);
27 mpidr
= cpu_logical_map(cpu
);
28 pcpu
= MPIDR_AFFINITY_LEVEL(mpidr
, 0);
29 pcluster
= MPIDR_AFFINITY_LEVEL(mpidr
, 1);
30 pr_debug("%s: logical CPU %d is physical CPU %d cluster %d\n",
31 __func__
, cpu
, pcpu
, pcluster
);
33 mcpm_set_entry_vector(pcpu
, pcluster
, NULL
);
34 ret
= mcpm_cpu_power_up(pcpu
, pcluster
);
37 mcpm_set_entry_vector(pcpu
, pcluster
, secondary_startup
);
38 arch_send_wakeup_ipi_mask(cpumask_of(cpu
));
43 static void mcpm_secondary_init(unsigned int cpu
)
45 mcpm_cpu_powered_up();
48 #ifdef CONFIG_HOTPLUG_CPU
50 static int mcpm_cpu_disable(unsigned int cpu
)
53 * We assume all CPUs may be shut down.
54 * This would be the hook to use for eventual Secure
55 * OS migration requests as described in the PSCI spec.
60 static void mcpm_cpu_die(unsigned int cpu
)
62 unsigned int mpidr
, pcpu
, pcluster
;
63 mpidr
= read_cpuid_mpidr();
64 pcpu
= MPIDR_AFFINITY_LEVEL(mpidr
, 0);
65 pcluster
= MPIDR_AFFINITY_LEVEL(mpidr
, 1);
66 mcpm_set_entry_vector(pcpu
, pcluster
, NULL
);
67 mcpm_cpu_power_down();
72 static struct smp_operations __initdata mcpm_smp_ops
= {
73 .smp_boot_secondary
= mcpm_boot_secondary
,
74 .smp_secondary_init
= mcpm_secondary_init
,
75 #ifdef CONFIG_HOTPLUG_CPU
76 .cpu_disable
= mcpm_cpu_disable
,
77 .cpu_die
= mcpm_cpu_die
,
81 void __init
mcpm_smp_set_ops(void)
83 smp_set_ops(&mcpm_smp_ops
);