1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2002 ARM Ltd.
9 #include <linux/delay.h>
11 #include <linux/of_address.h>
13 #include <asm/cacheflush.h>
15 #include <asm/smp_plat.h>
16 #include <asm/smp_scu.h>
18 extern void ox820_secondary_startup(void);
20 static void __iomem *cpu_ctrl;
21 static void __iomem *gic_cpu_ctrl;
23 #define HOLDINGPEN_CPU_OFFSET 0xc8
24 #define HOLDINGPEN_LOCATION_OFFSET 0xc4
26 #define GIC_NCPU_OFFSET(cpu) (0x100 + (cpu)*0x100)
27 #define GIC_CPU_CTRL 0x00
28 #define GIC_CPU_CTRL_ENABLE 1
30 static int __init ox820_boot_secondary(unsigned int cpu,
31 struct task_struct *idle)
34 * Write the address of secondary startup into the
35 * system-wide flags register. The BootMonitor waits
36 * until it receives a soft interrupt, and then the
37 * secondary CPU branches to this address.
39 writel(virt_to_phys(ox820_secondary_startup),
40 cpu_ctrl + HOLDINGPEN_LOCATION_OFFSET);
42 writel(cpu, cpu_ctrl + HOLDINGPEN_CPU_OFFSET);
45 * Enable GIC cpu interface in CPU Interface Control Register
47 writel(GIC_CPU_CTRL_ENABLE,
48 gic_cpu_ctrl + GIC_NCPU_OFFSET(cpu) + GIC_CPU_CTRL);
51 * Send the secondary CPU a soft interrupt, thereby causing
52 * the boot monitor to read the system wide flags register,
53 * and branch to the address found there.
55 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
60 static void __init ox820_smp_prepare_cpus(unsigned int max_cpus)
62 struct device_node *np;
63 void __iomem *scu_base;
65 np = of_find_compatible_node(NULL, NULL, "arm,arm11mp-scu");
66 scu_base = of_iomap(np, 0);
71 /* Remap CPU Interrupt Interface Registers */
72 np = of_find_compatible_node(NULL, NULL, "arm,arm11mp-gic");
73 gic_cpu_ctrl = of_iomap(np, 1);
78 np = of_find_compatible_node(NULL, NULL, "oxsemi,ox820-sys-ctrl");
79 cpu_ctrl = of_iomap(np, 0);
91 static const struct smp_operations ox820_smp_ops __initconst = {
92 .smp_prepare_cpus = ox820_smp_prepare_cpus,
93 .smp_boot_secondary = ox820_boot_secondary,
96 CPU_METHOD_OF_DECLARE(ox820_smp, "oxsemi,ox820-smp", &ox820_smp_ops);