2 * SMP support for r8a7791
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Magnus Damm
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/smp.h>
20 #include <asm/smp_plat.h>
21 #include <mach/common.h>
22 #include <mach/r8a7791.h>
23 #include <mach/rcar-gen2.h>
25 #define RST 0xe6160000
26 #define CA15BAR 0x0020
27 #define CA15RESCNT 0x0040
28 #define RAM 0xe6300000
30 static void __init
r8a7791_smp_prepare_cpus(unsigned int max_cpus
)
35 /* let APMU code install data related to shmobile_boot_vector */
36 shmobile_smp_apmu_prepare_cpus(max_cpus
);
38 /* RAM for jump stub, because BAR requires 256KB aligned address */
39 p
= ioremap_nocache(RAM
, shmobile_boot_size
);
40 memcpy_toio(p
, shmobile_boot_vector
, shmobile_boot_size
);
43 /* setup reset vectors */
44 p
= ioremap_nocache(RST
, 0x63);
45 bar
= (RAM
>> 8) & 0xfffffc00;
46 writel_relaxed(bar
, p
+ CA15BAR
);
47 writel_relaxed(bar
| 0x10, p
+ CA15BAR
);
49 /* enable clocks to all CPUs */
50 writel_relaxed((readl_relaxed(p
+ CA15RESCNT
) & ~0x0f) | 0xa5a50000,
55 static int r8a7791_smp_boot_secondary(unsigned int cpu
,
56 struct task_struct
*idle
)
58 /* Error out when hardware debug mode is enabled */
59 if (rcar_gen2_read_mode_pins() & BIT(21)) {
60 pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu
);
64 return shmobile_smp_apmu_boot_secondary(cpu
, idle
);
67 struct smp_operations r8a7791_smp_ops __initdata
= {
68 .smp_prepare_cpus
= r8a7791_smp_prepare_cpus
,
69 .smp_boot_secondary
= r8a7791_smp_boot_secondary
,
70 #ifdef CONFIG_HOTPLUG_CPU
71 .cpu_disable
= shmobile_smp_cpu_disable
,
72 .cpu_die
= shmobile_smp_apmu_cpu_die
,
73 .cpu_kill
= shmobile_smp_apmu_cpu_kill
,