1
2
3
4
5
6
7
8
9
10
11#include <linux/io.h>
12#include <linux/delay.h>
13#include <linux/of.h>
14#include <linux/of_address.h>
15
16#include <asm/cacheflush.h>
17#include <asm/cp15.h>
18#include <asm/smp_plat.h>
19#include <asm/smp_scu.h>
20
21extern void ox820_secondary_startup(void);
22
23static void __iomem *cpu_ctrl;
24static void __iomem *gic_cpu_ctrl;
25
26#define HOLDINGPEN_CPU_OFFSET 0xc8
27#define HOLDINGPEN_LOCATION_OFFSET 0xc4
28
29#define GIC_NCPU_OFFSET(cpu) (0x100 + (cpu)*0x100)
30#define GIC_CPU_CTRL 0x00
31#define GIC_CPU_CTRL_ENABLE 1
32
33int __init ox820_boot_secondary(unsigned int cpu, struct task_struct *idle)
34{
35
36
37
38
39
40
41 writel(virt_to_phys(ox820_secondary_startup),
42 cpu_ctrl + HOLDINGPEN_LOCATION_OFFSET);
43
44 writel(cpu, cpu_ctrl + HOLDINGPEN_CPU_OFFSET);
45
46
47
48
49 writel(GIC_CPU_CTRL_ENABLE,
50 gic_cpu_ctrl + GIC_NCPU_OFFSET(cpu) + GIC_CPU_CTRL);
51
52
53
54
55
56
57 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
58
59 return 0;
60}
61
62static void __init ox820_smp_prepare_cpus(unsigned int max_cpus)
63{
64 struct device_node *np;
65 void __iomem *scu_base;
66
67 np = of_find_compatible_node(NULL, NULL, "arm,arm11mp-scu");
68 scu_base = of_iomap(np, 0);
69 of_node_put(np);
70 if (!scu_base)
71 return;
72
73
74 np = of_find_compatible_node(NULL, NULL, "arm,arm11mp-gic");
75 gic_cpu_ctrl = of_iomap(np, 1);
76 of_node_put(np);
77 if (!gic_cpu_ctrl)
78 goto unmap_scu;
79
80 np = of_find_compatible_node(NULL, NULL, "oxsemi,ox820-sys-ctrl");
81 cpu_ctrl = of_iomap(np, 0);
82 of_node_put(np);
83 if (!cpu_ctrl)
84 goto unmap_scu;
85
86 scu_enable(scu_base);
87 flush_cache_all();
88
89unmap_scu:
90 iounmap(scu_base);
91}
92
93static const struct smp_operations ox820_smp_ops __initconst = {
94 .smp_prepare_cpus = ox820_smp_prepare_cpus,
95 .smp_boot_secondary = ox820_boot_secondary,
96};
97
98CPU_METHOD_OF_DECLARE(ox820_smp, "oxsemi,ox820-smp", &ox820_smp_ops);
99