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> | |
20 | ||
21 | #include "core.h" | |
22 | ||
23 | #define REALVIEW_SYS_FLAGSSET_OFFSET 0x30 | |
24 | ||
25 | static const struct of_device_id realview_scu_match[] = { | |
26 | { .compatible = "arm,arm11mp-scu", }, | |
27 | { .compatible = "arm,cortex-a9-scu", }, | |
28 | { .compatible = "arm,cortex-a5-scu", }, | |
29 | { } | |
30 | }; | |
31 | ||
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-pb11mp-syscon", }, | |
36 | { .compatible = "arm,realview-pbx-syscon", }, | |
37 | { }, | |
38 | }; | |
39 | ||
40 | static void __init realview_smp_prepare_cpus(unsigned int max_cpus) | |
41 | { | |
42 | struct device_node *np; | |
43 | void __iomem *scu_base; | |
44 | struct regmap *map; | |
45 | unsigned int ncores; | |
46 | int i; | |
47 | ||
48 | np = of_find_matching_node(NULL, realview_scu_match); | |
49 | if (!np) { | |
50 | pr_err("PLATSMP: No SCU base address\n"); | |
51 | return; | |
52 | } | |
53 | scu_base = of_iomap(np, 0); | |
54 | of_node_put(np); | |
55 | if (!scu_base) { | |
56 | pr_err("PLATSMP: No SCU remap\n"); | |
57 | return; | |
58 | } | |
59 | ||
60 | scu_enable(scu_base); | |
61 | ncores = scu_get_core_count(scu_base); | |
62 | pr_info("SCU: %d cores detected\n", ncores); | |
63 | for (i = 0; i < ncores; i++) | |
64 | set_cpu_possible(i, true); | |
65 | iounmap(scu_base); | |
66 | ||
67 | /* The syscon contains the magic SMP start address registers */ | |
68 | np = of_find_matching_node(NULL, realview_syscon_match); | |
69 | if (!np) { | |
70 | pr_err("PLATSMP: No syscon match\n"); | |
71 | return; | |
72 | } | |
73 | map = syscon_node_to_regmap(np); | |
74 | if (IS_ERR(map)) { | |
75 | pr_err("PLATSMP: No syscon regmap\n"); | |
76 | return; | |
77 | } | |
78 | /* Put the boot address in this magic register */ | |
79 | regmap_write(map, REALVIEW_SYS_FLAGSSET_OFFSET, | |
80 | virt_to_phys(versatile_secondary_startup)); | |
81 | } | |
82 | ||
83 | struct smp_operations realview_dt_smp_ops __initdata = { | |
84 | .smp_prepare_cpus = realview_smp_prepare_cpus, | |
85 | .smp_secondary_init = versatile_secondary_init, | |
86 | .smp_boot_secondary = versatile_boot_secondary, | |
87 | #ifdef CONFIG_HOTPLUG_CPU | |
88 | .cpu_die = realview_cpu_die, | |
89 | #endif | |
90 | }; | |
91 | CPU_METHOD_OF_DECLARE(realview_smp, "arm,realview-smp", &realview_dt_smp_ops); |