This source file includes following definitions.
- zynq_cpun_start
- zynq_boot_secondary
- zynq_smp_init_cpus
- zynq_smp_prepare_cpus
- zynq_secondary_init
- zynq_cpu_kill
- zynq_cpu_die
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/export.h>
14 #include <linux/jiffies.h>
15 #include <linux/init.h>
16 #include <linux/io.h>
17 #include <asm/cacheflush.h>
18 #include <asm/smp_scu.h>
19 #include <linux/irqchip/arm-gic.h>
20 #include "common.h"
21
22
23
24
25
26
27 static int ncores;
28
29 int zynq_cpun_start(u32 address, int cpu)
30 {
31 u32 trampoline_code_size = &zynq_secondary_trampoline_end -
32 &zynq_secondary_trampoline;
33
34
35
36 if (!(address & 3) && (!address || (address >= trampoline_code_size))) {
37
38 static u8 __iomem *zero;
39 u32 trampoline_size = &zynq_secondary_trampoline_jump -
40 &zynq_secondary_trampoline;
41
42 zynq_slcr_cpu_stop(cpu);
43 if (address) {
44 if (__pa(PAGE_OFFSET)) {
45 zero = ioremap(0, trampoline_code_size);
46 if (!zero) {
47 pr_warn("BOOTUP jump vectors not accessible\n");
48 return -1;
49 }
50 } else {
51 zero = (__force u8 __iomem *)PAGE_OFFSET;
52 }
53
54
55
56
57
58
59
60 memcpy_toio(zero, &zynq_secondary_trampoline,
61 trampoline_size);
62 writel(address, zero + trampoline_size);
63
64 flush_cache_all();
65 outer_flush_range(0, trampoline_code_size);
66 smp_wmb();
67
68 if (__pa(PAGE_OFFSET))
69 iounmap(zero);
70 }
71 zynq_slcr_cpu_start(cpu);
72
73 return 0;
74 }
75
76 pr_warn("Can't start CPU%d: Wrong starting address %x\n", cpu, address);
77
78 return -1;
79 }
80 EXPORT_SYMBOL(zynq_cpun_start);
81
82 static int zynq_boot_secondary(unsigned int cpu, struct task_struct *idle)
83 {
84 return zynq_cpun_start(__pa_symbol(secondary_startup_arm), cpu);
85 }
86
87
88
89
90
91 static void __init zynq_smp_init_cpus(void)
92 {
93 int i;
94
95 ncores = scu_get_core_count(zynq_scu_base);
96
97 for (i = 0; i < ncores && i < CONFIG_NR_CPUS; i++)
98 set_cpu_possible(i, true);
99 }
100
101 static void __init zynq_smp_prepare_cpus(unsigned int max_cpus)
102 {
103 scu_enable(zynq_scu_base);
104 }
105
106
107
108
109
110
111
112
113 static void zynq_secondary_init(unsigned int cpu)
114 {
115 zynq_core_pm_init();
116 }
117
118 #ifdef CONFIG_HOTPLUG_CPU
119 static int zynq_cpu_kill(unsigned cpu)
120 {
121 unsigned long timeout = jiffies + msecs_to_jiffies(50);
122
123 while (zynq_slcr_cpu_state_read(cpu))
124 if (time_after(jiffies, timeout))
125 return 0;
126
127 zynq_slcr_cpu_stop(cpu);
128 return 1;
129 }
130
131
132
133
134
135
136
137
138 static void zynq_cpu_die(unsigned int cpu)
139 {
140 zynq_slcr_cpu_state_write(cpu, true);
141
142
143
144
145
146
147 for (;;)
148 cpu_do_idle();
149 }
150 #endif
151
152 const struct smp_operations zynq_smp_ops __initconst = {
153 .smp_init_cpus = zynq_smp_init_cpus,
154 .smp_prepare_cpus = zynq_smp_prepare_cpus,
155 .smp_boot_secondary = zynq_boot_secondary,
156 .smp_secondary_init = zynq_secondary_init,
157 #ifdef CONFIG_HOTPLUG_CPU
158 .cpu_die = zynq_cpu_die,
159 .cpu_kill = zynq_cpu_kill,
160 #endif
161 };