Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  Copyright (C) 2002 ARM Ltd.
0004  *  All Rights Reserved
0005  */
0006 #include <linux/init.h>
0007 #include <linux/errno.h>
0008 #include <linux/smp.h>
0009 #include <linux/io.h>
0010 #include <linux/of_address.h>
0011 #include <linux/vexpress.h>
0012 
0013 #include <asm/mcpm.h>
0014 #include <asm/smp_scu.h>
0015 #include <asm/mach/map.h>
0016 
0017 #include "platsmp.h"
0018 #include "vexpress.h"
0019 
0020 bool __init vexpress_smp_init_ops(void)
0021 {
0022 #ifdef CONFIG_MCPM
0023     int cpu;
0024     struct device_node *cpu_node, *cci_node;
0025 
0026     /*
0027      * The best way to detect a multi-cluster configuration
0028      * is to detect if the kernel can take over CCI ports
0029      * control. Loop over possible CPUs and check if CCI
0030      * port control is available.
0031      * Override the default vexpress_smp_ops if so.
0032      */
0033     for_each_possible_cpu(cpu) {
0034         bool available;
0035 
0036         cpu_node = of_get_cpu_node(cpu, NULL);
0037         if (WARN(!cpu_node, "Missing cpu device node!"))
0038             return false;
0039 
0040         cci_node = of_parse_phandle(cpu_node, "cci-control-port", 0);
0041         available = cci_node && of_device_is_available(cci_node);
0042         of_node_put(cci_node);
0043         of_node_put(cpu_node);
0044 
0045         if (!available)
0046             return false;
0047     }
0048 
0049     mcpm_smp_set_ops();
0050     return true;
0051 #else
0052     return false;
0053 #endif
0054 }
0055 
0056 static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = {
0057     { .compatible = "arm,cortex-a5-scu", },
0058     { .compatible = "arm,cortex-a9-scu", },
0059     {}
0060 };
0061 
0062 static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus)
0063 {
0064     struct device_node *scu = of_find_matching_node(NULL,
0065             vexpress_smp_dt_scu_match);
0066 
0067     if (scu)
0068         scu_enable(of_iomap(scu, 0));
0069 
0070     /*
0071      * Write the address of secondary startup into the
0072      * system-wide flags register. The boot monitor waits
0073      * until it receives a soft interrupt, and then the
0074      * secondary CPU branches to this address.
0075      */
0076     vexpress_flags_set(__pa_symbol(versatile_secondary_startup));
0077 }
0078 
0079 #ifdef CONFIG_HOTPLUG_CPU
0080 static void vexpress_cpu_die(unsigned int cpu)
0081 {
0082     versatile_immitation_cpu_die(cpu, 0x40);
0083 }
0084 #endif
0085 
0086 const struct smp_operations vexpress_smp_dt_ops __initconst = {
0087     .smp_prepare_cpus   = vexpress_smp_dt_prepare_cpus,
0088     .smp_secondary_init = versatile_secondary_init,
0089     .smp_boot_secondary = versatile_boot_secondary,
0090 #ifdef CONFIG_HOTPLUG_CPU
0091     .cpu_die        = vexpress_cpu_die,
0092 #endif
0093 };