x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / arm / mach-shmobile / platsmp-scu.c
blobc96f50160be69eb8c0be9798c95374e664163615
1 /*
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.
9 */
10 #include <linux/delay.h>
11 #include <linux/init.h>
12 #include <linux/io.h>
13 #include <linux/smp.h>
14 #include <asm/cacheflush.h>
15 #include <asm/smp_plat.h>
16 #include <asm/smp_scu.h>
17 #include <mach/common.h>
19 void __init shmobile_smp_scu_prepare_cpus(unsigned int max_cpus)
21 /* install boot code shared by all CPUs */
22 shmobile_boot_fn = virt_to_phys(shmobile_smp_boot);
23 shmobile_boot_arg = MPIDR_HWID_BITMASK;
25 /* enable SCU and cache coherency on booting CPU */
26 scu_enable(shmobile_scu_base);
27 scu_power_mode(shmobile_scu_base, SCU_PM_NORMAL);
30 int shmobile_smp_scu_boot_secondary(unsigned int cpu, struct task_struct *idle)
32 /* For this particular CPU register SCU boot vector */
33 shmobile_smp_hook(cpu, virt_to_phys(shmobile_boot_scu),
34 (unsigned long)shmobile_scu_base);
35 return 0;
38 #ifdef CONFIG_HOTPLUG_CPU
39 void shmobile_smp_scu_cpu_die(unsigned int cpu)
41 /* For this particular CPU deregister boot vector */
42 shmobile_smp_hook(cpu, 0, 0);
44 dsb();
45 flush_cache_all();
47 /* disable cache coherency */
48 scu_power_mode(shmobile_scu_base, SCU_PM_POWEROFF);
50 /* jump to shared mach-shmobile sleep / reset code */
51 shmobile_smp_sleep();
54 static int shmobile_smp_scu_psr_core_disabled(int cpu)
56 unsigned long mask = SCU_PM_POWEROFF << (cpu * 8);
58 if ((__raw_readl(shmobile_scu_base + 8) & mask) == mask)
59 return 1;
61 return 0;
64 int shmobile_smp_scu_cpu_kill(unsigned int cpu)
66 int k;
68 /* this function is running on another CPU than the offline target,
69 * here we need wait for shutdown code in platform_cpu_die() to
70 * finish before asking SoC-specific code to power off the CPU core.
72 for (k = 0; k < 1000; k++) {
73 if (shmobile_smp_scu_psr_core_disabled(cpu))
74 return 1;
76 mdelay(1);
79 return 0;
81 #endif