1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <linux/delay.h>
20#include <linux/init.h>
21#include <linux/smp.h>
22#include <linux/io.h>
23#include <linux/of.h>
24#include <linux/of_address.h>
25
26#include <asm/cacheflush.h>
27#include <asm/smp_scu.h>
28#include <asm/smp_plat.h>
29
30#include "core.h"
31
32static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
33{
34 int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
35
36 if (socfpga_cpu1start_addr) {
37
38 writel(RSTMGR_MPUMODRST_CPU1,
39 rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
40
41 memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
42
43 writel(__pa_symbol(secondary_startup),
44 sys_manager_base_addr + (socfpga_cpu1start_addr & 0x000000ff));
45
46 flush_cache_all();
47 smp_wmb();
48 outer_clean_range(0, trampoline_size);
49
50
51 writel(0, rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
52 }
53
54 return 0;
55}
56
57static int socfpga_a10_boot_secondary(unsigned int cpu, struct task_struct *idle)
58{
59 int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
60
61 if (socfpga_cpu1start_addr) {
62 writel(RSTMGR_MPUMODRST_CPU1, rst_manager_base_addr +
63 SOCFPGA_A10_RSTMGR_MODMPURST);
64 memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
65
66 writel(__pa_symbol(secondary_startup),
67 sys_manager_base_addr + (socfpga_cpu1start_addr & 0x00000fff));
68
69 flush_cache_all();
70 smp_wmb();
71 outer_clean_range(0, trampoline_size);
72
73
74 writel(0, rst_manager_base_addr + SOCFPGA_A10_RSTMGR_MODMPURST);
75 }
76
77 return 0;
78}
79
80static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
81{
82 struct device_node *np;
83 void __iomem *socfpga_scu_base_addr;
84
85 np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
86 if (!np) {
87 pr_err("%s: missing scu\n", __func__);
88 return;
89 }
90
91 socfpga_scu_base_addr = of_iomap(np, 0);
92 if (!socfpga_scu_base_addr)
93 return;
94 scu_enable(socfpga_scu_base_addr);
95}
96
97#ifdef CONFIG_HOTPLUG_CPU
98
99
100
101
102
103static void socfpga_cpu_die(unsigned int cpu)
104{
105
106 while (1)
107 cpu_do_idle();
108}
109
110
111
112
113
114
115
116static int socfpga_cpu_kill(unsigned int cpu)
117{
118 return 1;
119}
120#endif
121
122static const struct smp_operations socfpga_smp_ops __initconst = {
123 .smp_prepare_cpus = socfpga_smp_prepare_cpus,
124 .smp_boot_secondary = socfpga_boot_secondary,
125#ifdef CONFIG_HOTPLUG_CPU
126 .cpu_die = socfpga_cpu_die,
127 .cpu_kill = socfpga_cpu_kill,
128#endif
129};
130
131static const struct smp_operations socfpga_a10_smp_ops __initconst = {
132 .smp_prepare_cpus = socfpga_smp_prepare_cpus,
133 .smp_boot_secondary = socfpga_a10_boot_secondary,
134#ifdef CONFIG_HOTPLUG_CPU
135 .cpu_die = socfpga_cpu_die,
136 .cpu_kill = socfpga_cpu_kill,
137#endif
138};
139
140CPU_METHOD_OF_DECLARE(socfpga_smp, "altr,socfpga-smp", &socfpga_smp_ops);
141CPU_METHOD_OF_DECLARE(socfpga_a10_smp, "altr,socfpga-a10-smp", &socfpga_a10_smp_ops);
142