1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2015 Linus Walleij
8 #include <linux/of_address.h>
9 #include <linux/regmap.h>
10 #include <linux/mfd/syscon.h>
12 #include <asm/cacheflush.h>
13 #include <asm/smp_plat.h>
14 #include <asm/smp_scu.h>
18 #define REALVIEW_SYS_FLAGSSET_OFFSET 0x30
20 static const struct of_device_id realview_scu_match
[] = {
22 * The ARM11MP SCU compatible is only provided as fallback for
23 * old RealView EB Cortex-A9 device trees that were using this
24 * compatible by mistake.
26 { .compatible
= "arm,arm11mp-scu", },
27 { .compatible
= "arm,cortex-a9-scu", },
28 { .compatible
= "arm,cortex-a5-scu", },
32 static const struct of_device_id realview_syscon_match
[] = {
33 { .compatible
= "arm,core-module-integrator", },
34 { .compatible
= "arm,realview-eb-syscon", },
35 { .compatible
= "arm,realview-pbx-syscon", },
39 static void __init
realview_smp_prepare_cpus(unsigned int max_cpus
)
41 struct device_node
*np
;
42 void __iomem
*scu_base
;
47 np
= of_find_matching_node(NULL
, realview_scu_match
);
49 pr_err("PLATSMP: No SCU base address\n");
52 scu_base
= of_iomap(np
, 0);
55 pr_err("PLATSMP: No SCU remap\n");
60 ncores
= scu_get_core_count(scu_base
);
61 pr_info("SCU: %d cores detected\n", ncores
);
62 for (i
= 0; i
< ncores
; i
++)
63 set_cpu_possible(i
, true);
66 /* The syscon contains the magic SMP start address registers */
67 np
= of_find_matching_node(NULL
, realview_syscon_match
);
69 pr_err("PLATSMP: No syscon match\n");
72 map
= syscon_node_to_regmap(np
);
75 pr_err("PLATSMP: No syscon regmap\n");
78 /* Put the boot address in this magic register */
79 regmap_write(map
, REALVIEW_SYS_FLAGSSET_OFFSET
,
80 __pa_symbol(versatile_secondary_startup
));
83 #ifdef CONFIG_HOTPLUG_CPU
84 static void realview_cpu_die(unsigned int cpu
)
86 return versatile_immitation_cpu_die(cpu
, 0x20);
90 static const struct smp_operations realview_dt_smp_ops __initconst
= {
91 .smp_prepare_cpus
= realview_smp_prepare_cpus
,
92 .smp_secondary_init
= versatile_secondary_init
,
93 .smp_boot_secondary
= versatile_boot_secondary
,
94 #ifdef CONFIG_HOTPLUG_CPU
95 .cpu_die
= realview_cpu_die
,
98 CPU_METHOD_OF_DECLARE(realview_smp
, "arm,realview-smp", &realview_dt_smp_ops
);