Commit | Line | Data |
---|---|---|
9ff221ba NP |
1 | /* |
2 | * linux/arch/arm/mach-vexpress/mcpm_platsmp.c | |
3 | * | |
4 | * Created by: Nicolas Pitre, November 2012 | |
5 | * Copyright: (C) 2012-2013 Linaro Limited | |
6 | * | |
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. | |
10 | * | |
11 | * Code to handle secondary CPU bringup and hotplug for the cluster power API. | |
12 | */ | |
13 | ||
14 | #include <linux/init.h> | |
15 | #include <linux/smp.h> | |
16 | #include <linux/spinlock.h> | |
17 | ||
9ff221ba NP |
18 | #include <asm/mcpm.h> |
19 | #include <asm/smp.h> | |
20 | #include <asm/smp_plat.h> | |
21 | ||
22 | static void __init simple_smp_init_cpus(void) | |
23 | { | |
24 | } | |
25 | ||
26 | static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle) | |
27 | { | |
28 | unsigned int mpidr, pcpu, pcluster, ret; | |
29 | extern void secondary_startup(void); | |
30 | ||
31 | mpidr = cpu_logical_map(cpu); | |
32 | pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); | |
33 | pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); | |
34 | pr_debug("%s: logical CPU %d is physical CPU %d cluster %d\n", | |
35 | __func__, cpu, pcpu, pcluster); | |
36 | ||
37 | mcpm_set_entry_vector(pcpu, pcluster, NULL); | |
38 | ret = mcpm_cpu_power_up(pcpu, pcluster); | |
39 | if (ret) | |
40 | return ret; | |
41 | mcpm_set_entry_vector(pcpu, pcluster, secondary_startup); | |
42 | arch_send_wakeup_ipi_mask(cpumask_of(cpu)); | |
43 | dsb_sev(); | |
44 | return 0; | |
45 | } | |
46 | ||
47 | static void __cpuinit mcpm_secondary_init(unsigned int cpu) | |
48 | { | |
49 | mcpm_cpu_powered_up(); | |
9ff221ba NP |
50 | } |
51 | ||
52 | #ifdef CONFIG_HOTPLUG_CPU | |
53 | ||
54 | static int mcpm_cpu_disable(unsigned int cpu) | |
55 | { | |
56 | /* | |
57 | * We assume all CPUs may be shut down. | |
58 | * This would be the hook to use for eventual Secure | |
59 | * OS migration requests as described in the PSCI spec. | |
60 | */ | |
61 | return 0; | |
62 | } | |
63 | ||
64 | static void mcpm_cpu_die(unsigned int cpu) | |
65 | { | |
66 | unsigned int mpidr, pcpu, pcluster; | |
67 | mpidr = read_cpuid_mpidr(); | |
68 | pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); | |
69 | pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); | |
70 | mcpm_set_entry_vector(pcpu, pcluster, NULL); | |
71 | mcpm_cpu_power_down(); | |
72 | } | |
73 | ||
74 | #endif | |
75 | ||
a7eb7c6f | 76 | static struct smp_operations __initdata mcpm_smp_ops = { |
9ff221ba NP |
77 | .smp_init_cpus = simple_smp_init_cpus, |
78 | .smp_boot_secondary = mcpm_boot_secondary, | |
79 | .smp_secondary_init = mcpm_secondary_init, | |
80 | #ifdef CONFIG_HOTPLUG_CPU | |
81 | .cpu_disable = mcpm_cpu_disable, | |
82 | .cpu_die = mcpm_cpu_die, | |
83 | #endif | |
84 | }; | |
a7eb7c6f NP |
85 | |
86 | void __init mcpm_smp_set_ops(void) | |
87 | { | |
88 | smp_set_ops(&mcpm_smp_ops); | |
89 | } |