2 * SMP support for SoCs with SCU covered by mach-shmobile
4 * Copyright (C) 2013 Magnus Damm
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/cpu.h>
11 #include <linux/delay.h>
12 #include <linux/init.h>
14 #include <linux/smp.h>
15 #include <asm/cacheflush.h>
16 #include <asm/smp_plat.h>
17 #include <asm/smp_scu.h>
18 #include <mach/common.h>
20 static int shmobile_smp_scu_notifier_call(struct notifier_block
*nfb
,
21 unsigned long action
, void *hcpu
)
23 unsigned int cpu
= (long)hcpu
;
27 /* For this particular CPU register SCU SMP boot vector */
28 shmobile_smp_hook(cpu
, virt_to_phys(shmobile_boot_scu
),
29 (unsigned long)shmobile_scu_base
);
36 static struct notifier_block shmobile_smp_scu_notifier
= {
37 .notifier_call
= shmobile_smp_scu_notifier_call
,
40 void __init
shmobile_smp_scu_prepare_cpus(unsigned int max_cpus
)
42 /* install boot code shared by all CPUs */
43 shmobile_boot_fn
= virt_to_phys(shmobile_smp_boot
);
44 shmobile_boot_arg
= MPIDR_HWID_BITMASK
;
46 /* enable SCU and cache coherency on booting CPU */
47 scu_enable(shmobile_scu_base
);
48 scu_power_mode(shmobile_scu_base
, SCU_PM_NORMAL
);
50 /* Use CPU notifier for reset vector control */
51 register_cpu_notifier(&shmobile_smp_scu_notifier
);
54 #ifdef CONFIG_HOTPLUG_CPU
55 void shmobile_smp_scu_cpu_die(unsigned int cpu
)
57 /* For this particular CPU deregister boot vector */
58 shmobile_smp_hook(cpu
, 0, 0);
63 /* disable cache coherency */
64 scu_power_mode(shmobile_scu_base
, SCU_PM_POWEROFF
);
66 /* jump to shared mach-shmobile sleep / reset code */
70 static int shmobile_smp_scu_psr_core_disabled(int cpu
)
72 unsigned long mask
= SCU_PM_POWEROFF
<< (cpu
* 8);
74 if ((__raw_readl(shmobile_scu_base
+ 8) & mask
) == mask
)
80 int shmobile_smp_scu_cpu_kill(unsigned int cpu
)
84 /* this function is running on another CPU than the offline target,
85 * here we need wait for shutdown code in platform_cpu_die() to
86 * finish before asking SoC-specific code to power off the CPU core.
88 for (k
= 0; k
< 1000; k
++) {
89 if (shmobile_smp_scu_psr_core_disabled(cpu
))