2 * Copyright (C) 2016 Neil Armstrong <narmstrong@baylibre.com>
3 * Copyright (C) 2013 Ma Haijun <mahaijuns@gmail.com>
4 * Copyright (C) 2002 ARM Ltd.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/delay.h>
14 #include <linux/of_address.h>
16 #include <asm/cacheflush.h>
18 #include <asm/smp_plat.h>
19 #include <asm/smp_scu.h>
21 extern void ox820_secondary_startup(void);
23 static void __iomem
*cpu_ctrl
;
24 static void __iomem
*gic_cpu_ctrl
;
26 #define HOLDINGPEN_CPU_OFFSET 0xc8
27 #define HOLDINGPEN_LOCATION_OFFSET 0xc4
29 #define GIC_NCPU_OFFSET(cpu) (0x100 + (cpu)*0x100)
30 #define GIC_CPU_CTRL 0x00
31 #define GIC_CPU_CTRL_ENABLE 1
33 int __init
ox820_boot_secondary(unsigned int cpu
, struct task_struct
*idle
)
36 * Write the address of secondary startup into the
37 * system-wide flags register. The BootMonitor waits
38 * until it receives a soft interrupt, and then the
39 * secondary CPU branches to this address.
41 writel(virt_to_phys(ox820_secondary_startup
),
42 cpu_ctrl
+ HOLDINGPEN_LOCATION_OFFSET
);
44 writel(cpu
, cpu_ctrl
+ HOLDINGPEN_CPU_OFFSET
);
47 * Enable GIC cpu interface in CPU Interface Control Register
49 writel(GIC_CPU_CTRL_ENABLE
,
50 gic_cpu_ctrl
+ GIC_NCPU_OFFSET(cpu
) + GIC_CPU_CTRL
);
53 * Send the secondary CPU a soft interrupt, thereby causing
54 * the boot monitor to read the system wide flags register,
55 * and branch to the address found there.
57 arch_send_wakeup_ipi_mask(cpumask_of(cpu
));
62 static void __init
ox820_smp_prepare_cpus(unsigned int max_cpus
)
64 struct device_node
*np
;
65 void __iomem
*scu_base
;
67 np
= of_find_compatible_node(NULL
, NULL
, "arm,arm11mp-scu");
68 scu_base
= of_iomap(np
, 0);
73 /* Remap CPU Interrupt Interface Registers */
74 np
= of_find_compatible_node(NULL
, NULL
, "arm,arm11mp-gic");
75 gic_cpu_ctrl
= of_iomap(np
, 1);
80 np
= of_find_compatible_node(NULL
, NULL
, "oxsemi,ox820-sys-ctrl");
81 cpu_ctrl
= of_iomap(np
, 0);
93 static const struct smp_operations ox820_smp_ops __initconst
= {
94 .smp_prepare_cpus
= ox820_smp_prepare_cpus
,
95 .smp_boot_secondary
= ox820_boot_secondary
,
98 CPU_METHOD_OF_DECLARE(ox820_smp
, "oxsemi,ox820-smp", &ox820_smp_ops
);