Commit | Line | Data |
---|---|---|
59ac59f6 RK |
1 | /* |
2 | * linux/arch/arm/mach-vexpress/platsmp.c | |
3 | * | |
4 | * Copyright (C) 2002 ARM Ltd. | |
5 | * All Rights Reserved | |
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 | #include <linux/init.h> | |
12 | #include <linux/errno.h> | |
59ac59f6 RK |
13 | #include <linux/smp.h> |
14 | #include <linux/io.h> | |
033a899c | 15 | #include <linux/of.h> |
95d59741 | 16 | #include <linux/of_fdt.h> |
38669e04 | 17 | #include <linux/vexpress.h> |
95d59741 | 18 | |
033a899c | 19 | #include <asm/mcpm.h> |
95d59741 | 20 | #include <asm/smp_scu.h> |
95d59741 | 21 | #include <asm/mach/map.h> |
59ac59f6 | 22 | |
59ac59f6 | 23 | #include <mach/motherboard.h> |
59ac59f6 | 24 | |
3695adc2 | 25 | #include <plat/platsmp.h> |
59ac59f6 | 26 | |
3695adc2 | 27 | #include "core.h" |
3705ff6d | 28 | |
95d59741 PM |
29 | #if defined(CONFIG_OF) |
30 | ||
31 | static enum { | |
32 | GENERIC_SCU, | |
33 | CORTEX_A9_SCU, | |
34 | } vexpress_dt_scu __initdata = GENERIC_SCU; | |
35 | ||
36 | static struct map_desc vexpress_dt_cortex_a9_scu_map __initdata = { | |
37 | .virtual = V2T_PERIPH, | |
38 | /* .pfn set in vexpress_dt_init_cortex_a9_scu() */ | |
39 | .length = SZ_128, | |
40 | .type = MT_DEVICE, | |
41 | }; | |
42 | ||
43 | static void *vexpress_dt_cortex_a9_scu_base __initdata; | |
44 | ||
45 | const static char *vexpress_dt_cortex_a9_match[] __initconst = { | |
46 | "arm,cortex-a5-scu", | |
47 | "arm,cortex-a9-scu", | |
48 | NULL | |
49 | }; | |
50 | ||
51 | static int __init vexpress_dt_find_scu(unsigned long node, | |
52 | const char *uname, int depth, void *data) | |
53 | { | |
54 | if (of_flat_dt_match(node, vexpress_dt_cortex_a9_match)) { | |
55 | phys_addr_t phys_addr; | |
56 | __be32 *reg = of_get_flat_dt_prop(node, "reg", NULL); | |
57 | ||
58 | if (WARN_ON(!reg)) | |
59 | return -EINVAL; | |
60 | ||
61 | phys_addr = be32_to_cpup(reg); | |
62 | vexpress_dt_scu = CORTEX_A9_SCU; | |
63 | ||
64 | vexpress_dt_cortex_a9_scu_map.pfn = __phys_to_pfn(phys_addr); | |
65 | iotable_init(&vexpress_dt_cortex_a9_scu_map, 1); | |
66 | vexpress_dt_cortex_a9_scu_base = ioremap(phys_addr, SZ_256); | |
67 | if (WARN_ON(!vexpress_dt_cortex_a9_scu_base)) | |
68 | return -EFAULT; | |
69 | } | |
70 | ||
71 | return 0; | |
72 | } | |
73 | ||
74 | void __init vexpress_dt_smp_map_io(void) | |
75 | { | |
76 | if (initial_boot_params) | |
77 | WARN_ON(of_scan_flat_dt(vexpress_dt_find_scu, NULL)); | |
78 | } | |
79 | ||
95d59741 PM |
80 | static void __init vexpress_dt_smp_init_cpus(void) |
81 | { | |
82 | int ncores = 0, i; | |
83 | ||
84 | switch (vexpress_dt_scu) { | |
85 | case GENERIC_SCU: | |
dcdea629 | 86 | return; |
95d59741 PM |
87 | case CORTEX_A9_SCU: |
88 | ncores = scu_get_core_count(vexpress_dt_cortex_a9_scu_base); | |
89 | break; | |
90 | default: | |
91 | WARN_ON(1); | |
92 | break; | |
93 | } | |
94 | ||
95 | if (ncores < 2) | |
96 | return; | |
97 | ||
98 | if (ncores > nr_cpu_ids) { | |
99 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", | |
100 | ncores, nr_cpu_ids); | |
101 | ncores = nr_cpu_ids; | |
102 | } | |
103 | ||
104 | for (i = 0; i < ncores; ++i) | |
105 | set_cpu_possible(i, true); | |
95d59741 PM |
106 | } |
107 | ||
108 | static void __init vexpress_dt_smp_prepare_cpus(unsigned int max_cpus) | |
109 | { | |
95d59741 PM |
110 | |
111 | switch (vexpress_dt_scu) { | |
112 | case GENERIC_SCU: | |
95d59741 PM |
113 | break; |
114 | case CORTEX_A9_SCU: | |
115 | scu_enable(vexpress_dt_cortex_a9_scu_base); | |
116 | break; | |
117 | default: | |
118 | WARN_ON(1); | |
119 | break; | |
120 | } | |
121 | } | |
122 | ||
123 | #else | |
124 | ||
125 | static void __init vexpress_dt_smp_init_cpus(void) | |
126 | { | |
127 | WARN_ON(1); | |
128 | } | |
129 | ||
130 | void __init vexpress_dt_smp_prepare_cpus(unsigned int max_cpus) | |
131 | { | |
132 | WARN_ON(1); | |
133 | } | |
134 | ||
135 | #endif | |
136 | ||
59ac59f6 RK |
137 | /* |
138 | * Initialise the CPU possible map early - this describes the CPUs | |
139 | * which may be present or become present in the system. | |
140 | */ | |
3695adc2 | 141 | static void __init vexpress_smp_init_cpus(void) |
59ac59f6 | 142 | { |
95d59741 PM |
143 | if (ct_desc) |
144 | ct_desc->init_cpu_map(); | |
145 | else | |
146 | vexpress_dt_smp_init_cpus(); | |
147 | ||
59ac59f6 RK |
148 | } |
149 | ||
3695adc2 | 150 | static void __init vexpress_smp_prepare_cpus(unsigned int max_cpus) |
59ac59f6 | 151 | { |
59ac59f6 RK |
152 | /* |
153 | * Initialise the present map, which describes the set of CPUs | |
154 | * actually populated at the present time. | |
155 | */ | |
95d59741 PM |
156 | if (ct_desc) |
157 | ct_desc->smp_enable(max_cpus); | |
158 | else | |
159 | vexpress_dt_smp_prepare_cpus(max_cpus); | |
05c74a6c | 160 | |
59ac59f6 | 161 | /* |
05c74a6c RK |
162 | * Write the address of secondary startup into the |
163 | * system-wide flags register. The boot monitor waits | |
164 | * until it receives a soft interrupt, and then the | |
165 | * secondary CPU branches to this address. | |
59ac59f6 | 166 | */ |
38669e04 | 167 | vexpress_flags_set(virt_to_phys(versatile_secondary_startup)); |
59ac59f6 | 168 | } |
3695adc2 MZ |
169 | |
170 | struct smp_operations __initdata vexpress_smp_ops = { | |
171 | .smp_init_cpus = vexpress_smp_init_cpus, | |
172 | .smp_prepare_cpus = vexpress_smp_prepare_cpus, | |
173 | .smp_secondary_init = versatile_secondary_init, | |
174 | .smp_boot_secondary = versatile_boot_secondary, | |
175 | #ifdef CONFIG_HOTPLUG_CPU | |
176 | .cpu_die = vexpress_cpu_die, | |
177 | #endif | |
178 | }; | |
033a899c JM |
179 | |
180 | bool __init vexpress_smp_init_ops(void) | |
181 | { | |
182 | #ifdef CONFIG_MCPM | |
183 | /* | |
184 | * The best way to detect a multi-cluster configuration at the moment | |
185 | * is to look for the presence of a CCI in the system. | |
186 | * Override the default vexpress_smp_ops if so. | |
187 | */ | |
188 | struct device_node *node; | |
189 | node = of_find_compatible_node(NULL, NULL, "arm,cci-400"); | |
190 | if (node && of_device_is_available(node)) { | |
191 | mcpm_smp_set_ops(); | |
192 | return true; | |
193 | } | |
194 | #endif | |
195 | return false; | |
196 | } |