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 | |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 22 | #include <plat/platsmp.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 "core.h" |
Russell King | 3705ff6 | 2010-12-18 10:53:12 +0000 | [diff] [blame] | 25 | |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 26 | bool __init vexpress_smp_init_ops(void) |
| 27 | { |
| 28 | #ifdef CONFIG_MCPM |
Lorenzo Pieralisi | 525d401 | 2016-09-23 14:09:06 +0100 | [diff] [blame] | 29 | int cpu; |
| 30 | struct device_node *cpu_node, *cci_node; |
| 31 | |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 32 | /* |
Lorenzo Pieralisi | 525d401 | 2016-09-23 14:09:06 +0100 | [diff] [blame] | 33 | * The best way to detect a multi-cluster configuration |
| 34 | * is to detect if the kernel can take over CCI ports |
| 35 | * control. Loop over possible CPUs and check if CCI |
| 36 | * port control is available. |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 37 | * Override the default vexpress_smp_ops if so. |
| 38 | */ |
Lorenzo Pieralisi | 525d401 | 2016-09-23 14:09:06 +0100 | [diff] [blame] | 39 | for_each_possible_cpu(cpu) { |
| 40 | bool available; |
| 41 | |
| 42 | cpu_node = of_get_cpu_node(cpu, NULL); |
| 43 | if (WARN(!cpu_node, "Missing cpu device node!")) |
| 44 | return false; |
| 45 | |
| 46 | cci_node = of_parse_phandle(cpu_node, "cci-control-port", 0); |
| 47 | available = cci_node && of_device_is_available(cci_node); |
| 48 | of_node_put(cci_node); |
| 49 | of_node_put(cpu_node); |
| 50 | |
| 51 | if (!available) |
| 52 | return false; |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 53 | } |
Lorenzo Pieralisi | 525d401 | 2016-09-23 14:09:06 +0100 | [diff] [blame] | 54 | |
| 55 | mcpm_smp_set_ops(); |
| 56 | return true; |
| 57 | #else |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 58 | return false; |
Lorenzo Pieralisi | 525d401 | 2016-09-23 14:09:06 +0100 | [diff] [blame] | 59 | #endif |
Jon Medhurst | 033a899 | 2013-01-30 09:12:55 +0000 | [diff] [blame] | 60 | } |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame] | 61 | |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame] | 62 | static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = { |
| 63 | { .compatible = "arm,cortex-a5-scu", }, |
| 64 | { .compatible = "arm,cortex-a9-scu", }, |
| 65 | {} |
| 66 | }; |
| 67 | |
| 68 | static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus) |
| 69 | { |
| 70 | struct device_node *scu = of_find_matching_node(NULL, |
| 71 | vexpress_smp_dt_scu_match); |
| 72 | |
| 73 | if (scu) |
| 74 | scu_enable(of_iomap(scu, 0)); |
| 75 | |
| 76 | /* |
| 77 | * Write the address of secondary startup into the |
| 78 | * system-wide flags register. The boot monitor waits |
| 79 | * until it receives a soft interrupt, and then the |
| 80 | * secondary CPU branches to this address. |
| 81 | */ |
Florian Fainelli | 64fc2a9 | 2017-01-15 03:59:29 +0100 | [diff] [blame] | 82 | vexpress_flags_set(__pa_symbol(versatile_secondary_startup)); |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Masahiro Yamada | 7530527 | 2015-11-15 10:39:53 +0900 | [diff] [blame] | 85 | const struct smp_operations vexpress_smp_dt_ops __initconst = { |
Pawel Moll | d2606f8 | 2013-09-17 18:30:58 +0100 | [diff] [blame] | 86 | .smp_prepare_cpus = vexpress_smp_dt_prepare_cpus, |
| 87 | .smp_secondary_init = versatile_secondary_init, |
| 88 | .smp_boot_secondary = versatile_boot_secondary, |
| 89 | #ifdef CONFIG_HOTPLUG_CPU |
| 90 | .cpu_die = vexpress_cpu_die, |
| 91 | #endif |
| 92 | }; |