2 * Symmetric Multi Processing (SMP) support for Armada XP
4 * Copyright (C) 2012 Marvell
6 * Lior Amsalem <alior@marvell.com>
7 * Yehuda Yitschak <yehuday@marvell.com>
8 * Gregory CLEMENT <gregory.clement@free-electrons.com>
9 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
15 * The Armada XP SoC has 4 ARMv7 PJ4B CPUs running in full HW coherency
16 * This file implements the routines for preparing the SMP infrastructure
17 * and waking up the secondary CPUs
20 #include <linux/init.h>
21 #include <linux/smp.h>
22 #include <linux/clk.h>
24 #include <linux/mbus.h>
25 #include <asm/cacheflush.h>
26 #include <asm/smp_plat.h>
28 #include "armada-370-xp.h"
30 #include "coherency.h"
32 static struct clk *__init get_cpu_clk(int cpu)
35 struct device_node *np = of_get_cpu_node(cpu, NULL);
37 if (WARN(!np, "missing cpu node\n"))
39 cpu_clk = of_clk_get(np, 0);
40 if (WARN_ON(IS_ERR(cpu_clk)))
45 void __init set_secondary_cpus_clock(void)
51 thiscpu = smp_processor_id();
52 cpu_clk = get_cpu_clk(thiscpu);
55 clk_prepare_enable(cpu_clk);
56 rate = clk_get_rate(cpu_clk);
58 /* set all the other CPU clk to the same rate than the boot CPU */
59 for_each_possible_cpu(cpu) {
62 cpu_clk = get_cpu_clk(cpu);
65 clk_set_rate(cpu_clk, rate);
69 static void armada_xp_secondary_init(unsigned int cpu)
71 armada_xp_mpic_smp_cpu_init();
74 static int armada_xp_boot_secondary(unsigned int cpu, struct task_struct *idle)
76 pr_info("Booting CPU %d\n", cpu);
78 armada_xp_boot_cpu(cpu, armada_xp_secondary_startup);
83 static void __init armada_xp_smp_init_cpus(void)
85 unsigned int ncores = num_possible_cpus();
87 if (ncores == 0 || ncores > ARMADA_XP_MAX_CPUS)
88 panic("Invalid number of CPUs in DT\n");
90 set_smp_cross_call(armada_mpic_send_doorbell);
93 void __init armada_xp_smp_prepare_cpus(unsigned int max_cpus)
95 set_secondary_cpus_clock();
97 set_cpu_coherent(cpu_logical_map(smp_processor_id()), 0);
98 mvebu_mbus_add_window("bootrom", 0xfff00000, SZ_1M);
101 struct smp_operations armada_xp_smp_ops __initdata = {
102 .smp_init_cpus = armada_xp_smp_init_cpus,
103 .smp_prepare_cpus = armada_xp_smp_prepare_cpus,
104 .smp_secondary_init = armada_xp_secondary_init,
105 .smp_boot_secondary = armada_xp_boot_secondary,
106 #ifdef CONFIG_HOTPLUG_CPU
107 .cpu_die = armada_xp_cpu_die,