blob: a1f3804fd5a549586e18725aecd3089f1c627081 [file] [log] [blame]
Russell King59ac59f2010-02-11 21:56:07 +00001/*
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>
Russell King59ac59f2010-02-11 21:56:07 +000013#include <linux/smp.h>
14#include <linux/io.h>
Pawel Molld2606f82013-09-17 18:30:58 +010015#include <linux/of_address.h>
Pawel Moll38669e02012-10-09 12:56:36 +010016#include <linux/vexpress.h>
Pawel Moll95d59742012-02-24 09:18:14 +000017
Jon Medhurst033a8992013-01-30 09:12:55 +000018#include <asm/mcpm.h>
Pawel Moll95d59742012-02-24 09:18:14 +000019#include <asm/smp_scu.h>
Pawel Moll95d59742012-02-24 09:18:14 +000020#include <asm/mach/map.h>
Russell King59ac59f2010-02-11 21:56:07 +000021
Russell King59ac59f2010-02-11 21:56:07 +000022#include <mach/motherboard.h>
Russell King59ac59f2010-02-11 21:56:07 +000023
Marc Zyngier3695adc2011-09-08 13:15:22 +010024#include <plat/platsmp.h>
Russell King59ac59f2010-02-11 21:56:07 +000025
Marc Zyngier3695adc2011-09-08 13:15:22 +010026#include "core.h"
Russell King3705ff62010-12-18 10:53:12 +000027
Russell King59ac59f2010-02-11 21:56:07 +000028/*
29 * Initialise the CPU possible map early - this describes the CPUs
30 * which may be present or become present in the system.
31 */
Marc Zyngier3695adc2011-09-08 13:15:22 +010032static void __init vexpress_smp_init_cpus(void)
Russell King59ac59f2010-02-11 21:56:07 +000033{
Pawel Molld2606f82013-09-17 18:30:58 +010034 ct_desc->init_cpu_map();
Russell King59ac59f2010-02-11 21:56:07 +000035}
36
Marc Zyngier3695adc2011-09-08 13:15:22 +010037static void __init vexpress_smp_prepare_cpus(unsigned int max_cpus)
Russell King59ac59f2010-02-11 21:56:07 +000038{
Russell King59ac59f2010-02-11 21:56:07 +000039 /*
40 * Initialise the present map, which describes the set of CPUs
41 * actually populated at the present time.
42 */
Pawel Molld2606f82013-09-17 18:30:58 +010043 ct_desc->smp_enable(max_cpus);
Russell King05c74a62010-12-03 11:09:48 +000044
Russell King59ac59f2010-02-11 21:56:07 +000045 /*
Russell King05c74a62010-12-03 11:09:48 +000046 * 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.
Russell King59ac59f2010-02-11 21:56:07 +000050 */
Pawel Moll38669e02012-10-09 12:56:36 +010051 vexpress_flags_set(virt_to_phys(versatile_secondary_startup));
Russell King59ac59f2010-02-11 21:56:07 +000052}
Marc Zyngier3695adc2011-09-08 13:15:22 +010053
54struct 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};
Jon Medhurst033a8992013-01-30 09:12:55 +000063
64bool __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}
Pawel Molld2606f82013-09-17 18:30:58 +010081
82#if defined(CONFIG_OF)
83
84static 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
90static 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
107struct 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