USB: serial: option: reimplement interface masking
[linux/fpc-iii.git] / arch / arm / mach-axxia / platsmp.c
blob502e3df69f696e4a740cd09def122a923386e7c9
1 /*
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.
9 */
11 #include <linux/init.h>
12 #include <linux/io.h>
13 #include <linux/smp.h>
14 #include <linux/of.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 */
30 smp_wmb();
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;
37 void __iomem *syscon;
38 u32 tmp;
40 syscon_np = of_find_compatible_node(NULL, NULL, "lsi,axxia-syscon");
41 if (!syscon_np)
42 return -ENOENT;
44 syscon = of_iomap(syscon_np, 0);
45 if (!syscon)
46 return -ENOMEM;
48 tmp = readl(syscon + SC_RST_CPU_HOLD);
49 writel(0xab, syscon + SC_CRIT_WRITE_KEY);
50 tmp &= ~(1 << cpu);
51 writel(tmp, syscon + SC_RST_CPU_HOLD);
53 return 0;
56 static void __init axxia_smp_prepare_cpus(unsigned int max_cpus)
58 int cpu_count = 0;
59 int cpu;
62 * Initialise the present map, which describes the set of CPUs actually
63 * populated at the present time.
65 for_each_possible_cpu(cpu) {
66 struct device_node *np;
67 u32 release_phys;
69 np = of_get_cpu_node(cpu, NULL);
70 if (!np)
71 continue;
72 if (of_property_read_u32(np, "cpu-release-addr", &release_phys))
73 continue;
75 if (cpu_count < max_cpus) {
76 set_cpu_present(cpu, true);
77 cpu_count++;
80 if (release_phys != 0)
81 write_release_addr(release_phys);
85 static const struct smp_operations axxia_smp_ops __initconst = {
86 .smp_prepare_cpus = axxia_smp_prepare_cpus,
87 .smp_boot_secondary = axxia_boot_secondary,
89 CPU_METHOD_OF_DECLARE(axxia_smp, "lsi,syscon-release", &axxia_smp_ops);