2 * linux/arch/arm/mach-axxia/platsmp.c
4 * Copyright (C) 2012 LSI Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/init.h>
13 #include <linux/smp.h>
15 #include <linux/of_address.h>
16 #include <asm/cacheflush.h>
18 /* Syscon register offsets for releasing cores from reset */
19 #define SC_CRIT_WRITE_KEY 0x1000
20 #define SC_RST_CPU_HOLD 0x1010
23 * Write the kernel entry point for secondary CPUs to the specified address
25 static void write_release_addr(u32 release_phys)
27 u32 *virt = (u32 *) phys_to_virt(release_phys);
28 writel_relaxed(__pa_symbol(secondary_startup), virt);
29 /* Make sure this store is visible to other CPUs */
31 __cpuc_flush_dcache_area(virt, sizeof(u32));
34 static int axxia_boot_secondary(unsigned int cpu, struct task_struct *idle)
36 struct device_node *syscon_np;
40 syscon_np = of_find_compatible_node(NULL, NULL, "lsi,axxia-syscon");
44 syscon = of_iomap(syscon_np, 0);
45 of_node_put(syscon_np);
49 tmp = readl(syscon + SC_RST_CPU_HOLD);
50 writel(0xab, syscon + SC_CRIT_WRITE_KEY);
52 writel(tmp, syscon + SC_RST_CPU_HOLD);
57 static void __init axxia_smp_prepare_cpus(unsigned int max_cpus)
63 * Initialise the present map, which describes the set of CPUs actually
64 * populated at the present time.
66 for_each_possible_cpu(cpu) {
67 struct device_node *np;
70 np = of_get_cpu_node(cpu, NULL);
73 if (of_property_read_u32(np, "cpu-release-addr", &release_phys))
76 if (cpu_count < max_cpus) {
77 set_cpu_present(cpu, true);
81 if (release_phys != 0)
82 write_release_addr(release_phys);
86 static const struct smp_operations axxia_smp_ops __initconst = {
87 .smp_prepare_cpus = axxia_smp_prepare_cpus,
88 .smp_boot_secondary = axxia_boot_secondary,
90 CPU_METHOD_OF_DECLARE(axxia_smp, "lsi,syscon-release", &axxia_smp_ops);