Commit | Line | Data |
---|---|---|
4552386a | 1 | /* |
11adcc29 CY |
2 | * Cloned from linux/arch/arm/mach-realview/hotplug.c |
3 | * | |
4 | * Copyright (C) 2002 ARM Ltd. | |
5 | * All Rights Reserved | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | */ | |
11 | ||
12 | #include <linux/kernel.h> | |
13 | #include <linux/errno.h> | |
14 | #include <linux/smp.h> | |
911c29b0 | 15 | #include <linux/io.h> |
11adcc29 CY |
16 | |
17 | #include <asm/cacheflush.h> | |
15d07dc9 | 18 | #include <asm/cp15.h> |
eb50439b | 19 | #include <asm/smp_plat.h> |
11adcc29 | 20 | |
06853ae4 | 21 | #include "common.h" |
65c9a853 | 22 | #include "regs-pmu.h" |
06853ae4 | 23 | |
11adcc29 CY |
24 | static inline void cpu_leave_lowpower(void) |
25 | { | |
26 | unsigned int v; | |
27 | ||
28 | asm volatile( | |
29 | "mrc p15, 0, %0, c1, c0, 0\n" | |
e3d9c625 | 30 | " orr %0, %0, %1\n" |
11adcc29 CY |
31 | " mcr p15, 0, %0, c1, c0, 0\n" |
32 | " mrc p15, 0, %0, c1, c0, 1\n" | |
ad849a22 | 33 | " orr %0, %0, %2\n" |
11adcc29 CY |
34 | " mcr p15, 0, %0, c1, c0, 1\n" |
35 | : "=&r" (v) | |
ad849a22 | 36 | : "Ir" (CR_C), "Ir" (0x40) |
11adcc29 CY |
37 | : "cc"); |
38 | } | |
39 | ||
d4450261 | 40 | static inline void platform_do_lowpower(unsigned int cpu, int *spurious) |
11adcc29 | 41 | { |
9637f30e TF |
42 | u32 mpidr = cpu_logical_map(cpu); |
43 | u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); | |
44 | ||
11adcc29 | 45 | for (;;) { |
911c29b0 | 46 | |
9637f30e TF |
47 | /* Turn the CPU off on next WFI instruction. */ |
48 | exynos_cpu_power_down(core_id); | |
911c29b0 | 49 | |
b92ad209 | 50 | wfi(); |
11adcc29 | 51 | |
9637f30e | 52 | if (pen_release == core_id) { |
11adcc29 CY |
53 | /* |
54 | * OK, proper wakeup, we're done | |
55 | */ | |
56 | break; | |
57 | } | |
58 | ||
59 | /* | |
d4450261 | 60 | * Getting here, means that we have come out of WFI without |
11adcc29 CY |
61 | * having been woken up - this shouldn't happen |
62 | * | |
d4450261 RK |
63 | * Just note it happening - when we're woken, we can report |
64 | * its occurrence. | |
11adcc29 | 65 | */ |
d4450261 | 66 | (*spurious)++; |
11adcc29 CY |
67 | } |
68 | } | |
69 | ||
11adcc29 CY |
70 | /* |
71 | * platform-specific code to shutdown a CPU | |
72 | * | |
73 | * Called with IRQs disabled | |
74 | */ | |
06853ae4 | 75 | void __ref exynos_cpu_die(unsigned int cpu) |
11adcc29 | 76 | { |
d4450261 RK |
77 | int spurious = 0; |
78 | ||
75ad2ab2 | 79 | v7_exit_coherency_flush(louis); |
756e46db | 80 | |
d4450261 | 81 | platform_do_lowpower(cpu, &spurious); |
11adcc29 CY |
82 | |
83 | /* | |
84 | * bring this CPU back into the world of cache | |
85 | * coherency, and then restore interrupts | |
86 | */ | |
87 | cpu_leave_lowpower(); | |
d4450261 RK |
88 | |
89 | if (spurious) | |
90 | pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious); | |
11adcc29 | 91 | } |