percpu: Replace smp_read_barrier_depends() with lockless_dereference()
[sfrench/cifs-2.6.git] / arch / arm / mach-vexpress / platsmp.c
1 /*
2  *  linux/arch/arm/mach-vexpress/platsmp.c
3  *
4  *  Copyright (C) 2002 ARM Ltd.
5  *  All Rights Reserved
6  *
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.
10  */
11 #include <linux/init.h>
12 #include <linux/errno.h>
13 #include <linux/smp.h>
14 #include <linux/io.h>
15 #include <linux/of_address.h>
16 #include <linux/vexpress.h>
17
18 #include <asm/mcpm.h>
19 #include <asm/smp_scu.h>
20 #include <asm/mach/map.h>
21
22 #include <mach/motherboard.h>
23
24 #include <plat/platsmp.h>
25
26 #include "core.h"
27
28 /*
29  * Initialise the CPU possible map early - this describes the CPUs
30  * which may be present or become present in the system.
31  */
32 static void __init vexpress_smp_init_cpus(void)
33 {
34         ct_desc->init_cpu_map();
35 }
36
37 static void __init vexpress_smp_prepare_cpus(unsigned int max_cpus)
38 {
39         /*
40          * Initialise the present map, which describes the set of CPUs
41          * actually populated at the present time.
42          */
43         ct_desc->smp_enable(max_cpus);
44
45         /*
46          * Write the address of secondary startup into the
47          * system-wide flags register. The boot monitor waits
48          * until it receives a soft interrupt, and then the
49          * secondary CPU branches to this address.
50          */
51         vexpress_flags_set(virt_to_phys(versatile_secondary_startup));
52 }
53
54 struct smp_operations __initdata vexpress_smp_ops = {
55         .smp_init_cpus          = vexpress_smp_init_cpus,
56         .smp_prepare_cpus       = vexpress_smp_prepare_cpus,
57         .smp_secondary_init     = versatile_secondary_init,
58         .smp_boot_secondary     = versatile_boot_secondary,
59 #ifdef CONFIG_HOTPLUG_CPU
60         .cpu_die                = vexpress_cpu_die,
61 #endif
62 };
63
64 bool __init vexpress_smp_init_ops(void)
65 {
66 #ifdef CONFIG_MCPM
67         /*
68          * The best way to detect a multi-cluster configuration at the moment
69          * is to look for the presence of a CCI in the system.
70          * Override the default vexpress_smp_ops if so.
71          */
72         struct device_node *node;
73         node = of_find_compatible_node(NULL, NULL, "arm,cci-400");
74         if (node && of_device_is_available(node)) {
75                 mcpm_smp_set_ops();
76                 return true;
77         }
78 #endif
79         return false;
80 }
81
82 #if defined(CONFIG_OF)
83
84 static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = {
85         { .compatible = "arm,cortex-a5-scu", },
86         { .compatible = "arm,cortex-a9-scu", },
87         {}
88 };
89
90 static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus)
91 {
92         struct device_node *scu = of_find_matching_node(NULL,
93                         vexpress_smp_dt_scu_match);
94
95         if (scu)
96                 scu_enable(of_iomap(scu, 0));
97
98         /*
99          * Write the address of secondary startup into the
100          * system-wide flags register. The boot monitor waits
101          * until it receives a soft interrupt, and then the
102          * secondary CPU branches to this address.
103          */
104         vexpress_flags_set(virt_to_phys(versatile_secondary_startup));
105 }
106
107 struct smp_operations __initdata vexpress_smp_dt_ops = {
108         .smp_prepare_cpus       = vexpress_smp_dt_prepare_cpus,
109         .smp_secondary_init     = versatile_secondary_init,
110         .smp_boot_secondary     = versatile_boot_secondary,
111 #ifdef CONFIG_HOTPLUG_CPU
112         .cpu_die                = vexpress_cpu_die,
113 #endif
114 };
115
116 #endif