]>
Commit | Line | Data |
---|---|---|
5420b4b1 LW |
1 | /* |
2 | * Copyright (C) 2015 Linus Walleij | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | */ | |
8 | #include <linux/smp.h> | |
9 | #include <linux/io.h> | |
10 | #include <linux/of.h> | |
11 | #include <linux/of_address.h> | |
12 | #include <linux/regmap.h> | |
13 | #include <linux/mfd/syscon.h> | |
14 | ||
15 | #include <asm/cacheflush.h> | |
16 | #include <asm/smp_plat.h> | |
17 | #include <asm/smp_scu.h> | |
18 | ||
19 | #include <plat/platsmp.h> | |
5420b4b1 LW |
20 | |
21 | #define REALVIEW_SYS_FLAGSSET_OFFSET 0x30 | |
22 | ||
23 | static const struct of_device_id realview_scu_match[] = { | |
24 | { .compatible = "arm,arm11mp-scu", }, | |
25 | { .compatible = "arm,cortex-a9-scu", }, | |
26 | { .compatible = "arm,cortex-a5-scu", }, | |
27 | { } | |
28 | }; | |
29 | ||
30 | static const struct of_device_id realview_syscon_match[] = { | |
31 | { .compatible = "arm,core-module-integrator", }, | |
32 | { .compatible = "arm,realview-eb-syscon", }, | |
33 | { .compatible = "arm,realview-pb11mp-syscon", }, | |
34 | { .compatible = "arm,realview-pbx-syscon", }, | |
35 | { }, | |
36 | }; | |
37 | ||
38 | static void __init realview_smp_prepare_cpus(unsigned int max_cpus) | |
39 | { | |
40 | struct device_node *np; | |
41 | void __iomem *scu_base; | |
42 | struct regmap *map; | |
43 | unsigned int ncores; | |
44 | int i; | |
45 | ||
46 | np = of_find_matching_node(NULL, realview_scu_match); | |
47 | if (!np) { | |
48 | pr_err("PLATSMP: No SCU base address\n"); | |
49 | return; | |
50 | } | |
51 | scu_base = of_iomap(np, 0); | |
52 | of_node_put(np); | |
53 | if (!scu_base) { | |
54 | pr_err("PLATSMP: No SCU remap\n"); | |
55 | return; | |
56 | } | |
57 | ||
58 | scu_enable(scu_base); | |
59 | ncores = scu_get_core_count(scu_base); | |
60 | pr_info("SCU: %d cores detected\n", ncores); | |
61 | for (i = 0; i < ncores; i++) | |
62 | set_cpu_possible(i, true); | |
63 | iounmap(scu_base); | |
64 | ||
65 | /* The syscon contains the magic SMP start address registers */ | |
66 | np = of_find_matching_node(NULL, realview_syscon_match); | |
67 | if (!np) { | |
68 | pr_err("PLATSMP: No syscon match\n"); | |
69 | return; | |
70 | } | |
71 | map = syscon_node_to_regmap(np); | |
72 | if (IS_ERR(map)) { | |
73 | pr_err("PLATSMP: No syscon regmap\n"); | |
74 | return; | |
75 | } | |
76 | /* Put the boot address in this magic register */ | |
77 | regmap_write(map, REALVIEW_SYS_FLAGSSET_OFFSET, | |
64fc2a94 | 78 | __pa_symbol(versatile_secondary_startup)); |
5420b4b1 LW |
79 | } |
80 | ||
4fb68e12 RK |
81 | #ifdef CONFIG_HOTPLUG_CPU |
82 | static void realview_cpu_die(unsigned int cpu) | |
83 | { | |
84 | return versatile_immitation_cpu_die(cpu, 0x20); | |
85 | } | |
86 | #endif | |
87 | ||
567fdd9d | 88 | static const struct smp_operations realview_dt_smp_ops __initconst = { |
5420b4b1 LW |
89 | .smp_prepare_cpus = realview_smp_prepare_cpus, |
90 | .smp_secondary_init = versatile_secondary_init, | |
91 | .smp_boot_secondary = versatile_boot_secondary, | |
92 | #ifdef CONFIG_HOTPLUG_CPU | |
93 | .cpu_die = realview_cpu_die, | |
94 | #endif | |
95 | }; | |
96 | CPU_METHOD_OF_DECLARE(realview_smp, "arm,realview-smp", &realview_dt_smp_ops); |