Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / arm / mach-hisi / platsmp.c
blob471f1ee3be2b90d538b37b4185a9f481a600e64e
1 /*
2 * Copyright (c) 2013 Linaro Ltd.
3 * Copyright (c) 2013 Hisilicon Limited.
4 * Based on arch/arm/mach-vexpress/platsmp.c, Copyright (C) 2002 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 */
10 #include <linux/smp.h>
11 #include <linux/io.h>
12 #include <linux/of_address.h>
14 #include <asm/cacheflush.h>
15 #include <asm/smp_plat.h>
16 #include <asm/smp_scu.h>
18 #include "core.h"
20 static void __iomem *ctrl_base;
22 void hi3xxx_set_cpu_jump(int cpu, void *jump_addr)
24 cpu = cpu_logical_map(cpu);
25 if (!cpu || !ctrl_base)
26 return;
27 writel_relaxed(virt_to_phys(jump_addr), ctrl_base + ((cpu - 1) << 2));
30 int hi3xxx_get_cpu_jump(int cpu)
32 cpu = cpu_logical_map(cpu);
33 if (!cpu || !ctrl_base)
34 return 0;
35 return readl_relaxed(ctrl_base + ((cpu - 1) << 2));
38 static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus)
40 struct device_node *np = NULL;
41 unsigned long base = 0;
42 u32 offset = 0;
43 void __iomem *scu_base = NULL;
45 if (scu_a9_has_base()) {
46 base = scu_a9_get_base();
47 scu_base = ioremap(base, SZ_4K);
48 if (!scu_base) {
49 pr_err("ioremap(scu_base) failed\n");
50 return;
52 scu_enable(scu_base);
53 iounmap(scu_base);
55 if (!ctrl_base) {
56 np = of_find_compatible_node(NULL, NULL, "hisilicon,sysctrl");
57 if (!np) {
58 pr_err("failed to find hisilicon,sysctrl node\n");
59 return;
61 ctrl_base = of_iomap(np, 0);
62 if (!ctrl_base) {
63 pr_err("failed to map address\n");
64 return;
66 if (of_property_read_u32(np, "smp-offset", &offset) < 0) {
67 pr_err("failed to find smp-offset property\n");
68 return;
70 ctrl_base += offset;
74 static int hi3xxx_boot_secondary(unsigned int cpu, struct task_struct *idle)
76 hi3xxx_set_cpu(cpu, true);
77 hi3xxx_set_cpu_jump(cpu, secondary_startup);
78 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
79 return 0;
82 struct smp_operations hi3xxx_smp_ops __initdata = {
83 .smp_prepare_cpus = hi3xxx_smp_prepare_cpus,
84 .smp_boot_secondary = hi3xxx_boot_secondary,
85 #ifdef CONFIG_HOTPLUG_CPU
86 .cpu_die = hi3xxx_cpu_die,
87 .cpu_kill = hi3xxx_cpu_kill,
88 #endif