2 * linux/arch/arm/mach-vexpress/platsmp.c
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.
11 #include <linux/init.h>
12 #include <linux/errno.h>
13 #include <linux/smp.h>
15 #include <linux/of_fdt.h>
17 #include <asm/smp_scu.h>
18 #include <asm/hardware/gic.h>
19 #include <asm/mach/map.h>
21 #include <mach/motherboard.h>
25 extern void versatile_secondary_startup(void);
27 #if defined(CONFIG_OF)
32 } vexpress_dt_scu __initdata
= GENERIC_SCU
;
34 static struct map_desc vexpress_dt_cortex_a9_scu_map __initdata
= {
35 .virtual = V2T_PERIPH
,
36 /* .pfn set in vexpress_dt_init_cortex_a9_scu() */
41 static void *vexpress_dt_cortex_a9_scu_base __initdata
;
43 const static char *vexpress_dt_cortex_a9_match
[] __initconst
= {
49 static int __init
vexpress_dt_find_scu(unsigned long node
,
50 const char *uname
, int depth
, void *data
)
52 if (of_flat_dt_match(node
, vexpress_dt_cortex_a9_match
)) {
53 phys_addr_t phys_addr
;
54 __be32
*reg
= of_get_flat_dt_prop(node
, "reg", NULL
);
59 phys_addr
= be32_to_cpup(reg
);
60 vexpress_dt_scu
= CORTEX_A9_SCU
;
62 vexpress_dt_cortex_a9_scu_map
.pfn
= __phys_to_pfn(phys_addr
);
63 iotable_init(&vexpress_dt_cortex_a9_scu_map
, 1);
64 vexpress_dt_cortex_a9_scu_base
= ioremap(phys_addr
, SZ_256
);
65 if (WARN_ON(!vexpress_dt_cortex_a9_scu_base
))
72 void __init
vexpress_dt_smp_map_io(void)
74 if (initial_boot_params
)
75 WARN_ON(of_scan_flat_dt(vexpress_dt_find_scu
, NULL
));
78 static int __init
vexpress_dt_cpus_num(unsigned long node
, const char *uname
,
79 int depth
, void *data
)
81 static int prev_depth
= -1;
82 static int nr_cpus
= -1;
84 if (prev_depth
> depth
&& nr_cpus
> 0)
87 if (nr_cpus
< 0 && strcmp(uname
, "cpus") == 0)
91 const char *device_type
= of_get_flat_dt_prop(node
,
94 if (device_type
&& strcmp(device_type
, "cpu") == 0)
103 static void __init
vexpress_dt_smp_init_cpus(void)
107 switch (vexpress_dt_scu
) {
109 ncores
= of_scan_flat_dt(vexpress_dt_cpus_num
, NULL
);
112 ncores
= scu_get_core_count(vexpress_dt_cortex_a9_scu_base
);
122 if (ncores
> nr_cpu_ids
) {
123 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
128 for (i
= 0; i
< ncores
; ++i
)
129 set_cpu_possible(i
, true);
131 set_smp_cross_call(gic_raise_softirq
);
134 static void __init
vexpress_dt_smp_prepare_cpus(unsigned int max_cpus
)
138 switch (vexpress_dt_scu
) {
140 for (i
= 0; i
< max_cpus
; i
++)
141 set_cpu_present(i
, true);
144 scu_enable(vexpress_dt_cortex_a9_scu_base
);
154 static void __init
vexpress_dt_smp_init_cpus(void)
159 void __init
vexpress_dt_smp_prepare_cpus(unsigned int max_cpus
)
167 * Initialise the CPU possible map early - this describes the CPUs
168 * which may be present or become present in the system.
170 void __init
smp_init_cpus(void)
173 ct_desc
->init_cpu_map();
175 vexpress_dt_smp_init_cpus();
179 void __init
platform_smp_prepare_cpus(unsigned int max_cpus
)
182 * Initialise the present map, which describes the set of CPUs
183 * actually populated at the present time.
186 ct_desc
->smp_enable(max_cpus
);
188 vexpress_dt_smp_prepare_cpus(max_cpus
);
191 * Write the address of secondary startup into the
192 * system-wide flags register. The boot monitor waits
193 * until it receives a soft interrupt, and then the
194 * secondary CPU branches to this address.
196 v2m_flags_set(virt_to_phys(versatile_secondary_startup
));