Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 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> |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 13 | #include <linux/smp.h> |
| 14 | #include <linux/io.h> |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame^] | 15 | #include <linux/of_address.h> |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 16 | #include <linux/vexpress.h> |
Pawel Moll | 95d5974 | 2012-02-24 09:18:14 +0000 | [diff] [blame] | 17 | |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 18 | #include <asm/mcpm.h> |
Pawel Moll | 95d5974 | 2012-02-24 09:18:14 +0000 | [diff] [blame] | 19 | #include <asm/smp_scu.h> |
Pawel Moll | 95d5974 | 2012-02-24 09:18:14 +0000 | [diff] [blame] | 20 | #include <asm/mach/map.h> |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 21 | |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 22 | #include <mach/motherboard.h> |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 23 | |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 24 | #include <plat/platsmp.h> |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 25 | |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 26 | #include "core.h" |
Russell King | 3705ff6 | 2010-12-18 10:53:12 +0000 | [diff] [blame] | 27 | |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 28 | /* |
| 29 | * Initialise the CPU possible map early - this describes the CPUs |
| 30 | * which may be present or become present in the system. |
| 31 | */ |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 32 | static void __init vexpress_smp_init_cpus(void) |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 33 | { |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame^] | 34 | ct_desc->init_cpu_map(); |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 37 | static void __init vexpress_smp_prepare_cpus(unsigned int max_cpus) |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 38 | { |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 39 | /* |
| 40 | * Initialise the present map, which describes the set of CPUs |
| 41 | * actually populated at the present time. |
| 42 | */ |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame^] | 43 | ct_desc->smp_enable(max_cpus); |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 44 | |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 45 | /* |
Russell King | 05c74a6 | 2010-12-03 11:09:48 +0000 | [diff] [blame] | 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. |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 50 | */ |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 51 | vexpress_flags_set(virt_to_phys(versatile_secondary_startup)); |
Russell King | 59ac59f | 2010-02-11 21:56:07 +0000 | [diff] [blame] | 52 | } |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 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 | }; |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 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 | } |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame^] | 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 |