1
2
3
4
5
6
7
8
9
10
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/smp.h>
14
15#include <asm/smp_plat.h>
16#include <asm/cp15.h>
17
18#include <plat/platsmp.h>
19
20static inline void versatile_immitation_enter_lowpower(unsigned int actrl_mask)
21{
22 unsigned int v;
23
24 asm volatile(
25 "mcr p15, 0, %1, c7, c5, 0\n"
26 " mcr p15, 0, %1, c7, c10, 4\n"
27
28
29
30 " mrc p15, 0, %0, c1, c0, 1\n"
31 " bic %0, %0, %3\n"
32 " mcr p15, 0, %0, c1, c0, 1\n"
33 " mrc p15, 0, %0, c1, c0, 0\n"
34 " bic %0, %0, %2\n"
35 " mcr p15, 0, %0, c1, c0, 0\n"
36 : "=&r" (v)
37 : "r" (0), "Ir" (CR_C), "Ir" (actrl_mask)
38 : "cc");
39}
40
41static inline void versatile_immitation_leave_lowpower(unsigned int actrl_mask)
42{
43 unsigned int v;
44
45 asm volatile(
46 "mrc p15, 0, %0, c1, c0, 0\n"
47 " orr %0, %0, %1\n"
48 " mcr p15, 0, %0, c1, c0, 0\n"
49 " mrc p15, 0, %0, c1, c0, 1\n"
50 " orr %0, %0, %2\n"
51 " mcr p15, 0, %0, c1, c0, 1\n"
52 : "=&r" (v)
53 : "Ir" (CR_C), "Ir" (actrl_mask)
54 : "cc");
55}
56
57static inline void versatile_immitation_do_lowpower(unsigned int cpu, int *spurious)
58{
59
60
61
62
63
64
65
66 for (;;) {
67 wfi();
68
69 if (versatile_cpu_release == cpu_logical_map(cpu)) {
70
71
72
73 break;
74 }
75
76
77
78
79
80
81
82
83 (*spurious)++;
84 }
85}
86
87
88
89
90
91
92void versatile_immitation_cpu_die(unsigned int cpu, unsigned int actrl_mask)
93{
94 int spurious = 0;
95
96 versatile_immitation_enter_lowpower(actrl_mask);
97 versatile_immitation_do_lowpower(cpu, &spurious);
98 versatile_immitation_leave_lowpower(actrl_mask);
99
100 if (spurious)
101 pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
102}
103