]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - arch/arm/mach-oxnas/hotplug.c
Merge tag 'for-linus-4.12b-rc0c-tag' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-eoan-kernel.git] / arch / arm / mach-oxnas / hotplug.c
1 /*
2 * Copyright (C) 2002 ARM Ltd.
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/smp.h>
12
13 #include <asm/cp15.h>
14 #include <asm/smp_plat.h>
15
16 static inline void cpu_enter_lowpower(void)
17 {
18 unsigned int v;
19
20 asm volatile(
21 " mcr p15, 0, %1, c7, c5, 0\n"
22 " mcr p15, 0, %1, c7, c10, 4\n"
23 /*
24 * Turn off coherency
25 */
26 " mrc p15, 0, %0, c1, c0, 1\n"
27 " bic %0, %0, #0x20\n"
28 " mcr p15, 0, %0, c1, c0, 1\n"
29 " mrc p15, 0, %0, c1, c0, 0\n"
30 " bic %0, %0, %2\n"
31 " mcr p15, 0, %0, c1, c0, 0\n"
32 : "=&r" (v)
33 : "r" (0), "Ir" (CR_C)
34 : "cc");
35 }
36
37 static inline void cpu_leave_lowpower(void)
38 {
39 unsigned int v;
40
41 asm volatile( "mrc p15, 0, %0, c1, c0, 0\n"
42 " orr %0, %0, %1\n"
43 " mcr p15, 0, %0, c1, c0, 0\n"
44 " mrc p15, 0, %0, c1, c0, 1\n"
45 " orr %0, %0, #0x20\n"
46 " mcr p15, 0, %0, c1, c0, 1\n"
47 : "=&r" (v)
48 : "Ir" (CR_C)
49 : "cc");
50 }
51
52 static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
53 {
54 /*
55 * there is no power-control hardware on this platform, so all
56 * we can do is put the core into WFI; this is safe as the calling
57 * code will have already disabled interrupts
58 */
59 for (;;) {
60 /*
61 * here's the WFI
62 */
63 asm(".word 0xe320f003\n"
64 :
65 :
66 : "memory", "cc");
67
68 if (pen_release == cpu_logical_map(cpu)) {
69 /*
70 * OK, proper wakeup, we're done
71 */
72 break;
73 }
74
75 /*
76 * Getting here, means that we have come out of WFI without
77 * having been woken up - this shouldn't happen
78 *
79 * Just note it happening - when we're woken, we can report
80 * its occurrence.
81 */
82 (*spurious)++;
83 }
84 }
85
86 /*
87 * platform-specific code to shutdown a CPU
88 *
89 * Called with IRQs disabled
90 */
91 void ox820_cpu_die(unsigned int cpu)
92 {
93 int spurious = 0;
94
95 /*
96 * we're ready for shutdown now, so do it
97 */
98 cpu_enter_lowpower();
99 platform_do_lowpower(cpu, &spurious);
100
101 /*
102 * bring this CPU back into the world of cache
103 * coherency, and then restore interrupts
104 */
105 cpu_leave_lowpower();
106
107 if (spurious)
108 pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
109 }