Blame view

arch/arm/mach-realview/hotplug.c 2.52 KB
97a63ecff   Russell King   [ARM SMP] Add CPU...
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
   *  linux/arch/arm/mach-realview/hotplug.c
   *
   *  Copyright (C) 2002 ARM Ltd.
   *  All Rights Reserved
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  #include <linux/kernel.h>
  #include <linux/errno.h>
  #include <linux/smp.h>
97a63ecff   Russell King   [ARM SMP] Add CPU...
14

8aa2da872   Harry Fearnhamm   RealView: Use flu...
15
  #include <asm/cacheflush.h>
97a63ecff   Russell King   [ARM SMP] Add CPU...
16
  extern volatile int pen_release;
97a63ecff   Russell King   [ARM SMP] Add CPU...
17
18
19
  static inline void cpu_enter_lowpower(void)
  {
  	unsigned int v;
8aa2da872   Harry Fearnhamm   RealView: Use flu...
20
21
  	flush_cache_all();
  	asm volatile(
97a63ecff   Russell King   [ARM SMP] Add CPU...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  	"	mcr	p15, 0, %1, c7, c5, 0
  "
  	"	mcr	p15, 0, %1, c7, c10, 4
  "
  	/*
  	 * Turn off coherency
  	 */
  	"	mrc	p15, 0, %0, c1, c0, 1
  "
  	"	bic	%0, %0, #0x20
  "
  	"	mcr	p15, 0, %0, c1, c0, 1
  "
  	"	mrc	p15, 0, %0, c1, c0, 0
  "
e3d9c625f   Russell King   ARM: CPU hotplug:...
37
38
  	"	bic	%0, %0, %2
  "
97a63ecff   Russell King   [ARM SMP] Add CPU...
39
40
41
  	"	mcr	p15, 0, %0, c1, c0, 0
  "
  	  : "=&r" (v)
e3d9c625f   Russell King   ARM: CPU hotplug:...
42
  	  : "r" (0), "Ir" (CR_C)
97a63ecff   Russell King   [ARM SMP] Add CPU...
43
44
45
46
47
48
49
50
51
  	  : "cc");
  }
  
  static inline void cpu_leave_lowpower(void)
  {
  	unsigned int v;
  
  	asm volatile(	"mrc	p15, 0, %0, c1, c0, 0
  "
e3d9c625f   Russell King   ARM: CPU hotplug:...
52
53
  	"	orr	%0, %0, %1
  "
97a63ecff   Russell King   [ARM SMP] Add CPU...
54
55
56
57
58
59
60
61
62
  	"	mcr	p15, 0, %0, c1, c0, 0
  "
  	"	mrc	p15, 0, %0, c1, c0, 1
  "
  	"	orr	%0, %0, #0x20
  "
  	"	mcr	p15, 0, %0, c1, c0, 1
  "
  	  : "=&r" (v)
e3d9c625f   Russell King   ARM: CPU hotplug:...
63
  	  : "Ir" (CR_C)
97a63ecff   Russell King   [ARM SMP] Add CPU...
64
65
  	  : "cc");
  }
d4450261e   Russell King   ARM: CPU hotplug:...
66
  static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
97a63ecff   Russell King   [ARM SMP] Add CPU...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  {
  	/*
  	 * there is no power-control hardware on this platform, so all
  	 * we can do is put the core into WFI; this is safe as the calling
  	 * code will have already disabled interrupts
  	 */
  	for (;;) {
  		/*
  		 * here's the WFI
  		 */
  		asm(".word	0xe320f003
  "
  		    :
  		    :
  		    : "memory", "cc");
4a139b647   Will Deacon   ARM: versatile: c...
82
  		if (pen_release == cpu_logical_map(cpu)) {
97a63ecff   Russell King   [ARM SMP] Add CPU...
83
84
85
86
87
88
89
  			/*
  			 * OK, proper wakeup, we're done
  			 */
  			break;
  		}
  
  		/*
d4450261e   Russell King   ARM: CPU hotplug:...
90
  		 * Getting here, means that we have come out of WFI without
97a63ecff   Russell King   [ARM SMP] Add CPU...
91
92
  		 * having been woken up - this shouldn't happen
  		 *
d4450261e   Russell King   ARM: CPU hotplug:...
93
94
  		 * Just note it happening - when we're woken, we can report
  		 * its occurrence.
97a63ecff   Russell King   [ARM SMP] Add CPU...
95
  		 */
d4450261e   Russell King   ARM: CPU hotplug:...
96
  		(*spurious)++;
97a63ecff   Russell King   [ARM SMP] Add CPU...
97
98
99
100
101
  	}
  }
  
  int platform_cpu_kill(unsigned int cpu)
  {
3c030beab   Russell King   ARM: CPU hotplug:...
102
  	return 1;
97a63ecff   Russell King   [ARM SMP] Add CPU...
103
104
105
106
107
108
109
110
111
  }
  
  /*
   * platform-specific code to shutdown a CPU
   *
   * Called with IRQs disabled
   */
  void platform_cpu_die(unsigned int cpu)
  {
d4450261e   Russell King   ARM: CPU hotplug:...
112
  	int spurious = 0;
97a63ecff   Russell King   [ARM SMP] Add CPU...
113
114
115
116
  	/*
  	 * we're ready for shutdown now, so do it
  	 */
  	cpu_enter_lowpower();
d4450261e   Russell King   ARM: CPU hotplug:...
117
  	platform_do_lowpower(cpu, &spurious);
97a63ecff   Russell King   [ARM SMP] Add CPU...
118
119
120
121
122
123
  
  	/*
  	 * bring this CPU back into the world of cache
  	 * coherency, and then restore interrupts
  	 */
  	cpu_leave_lowpower();
d4450261e   Russell King   ARM: CPU hotplug:...
124
125
126
127
  
  	if (spurious)
  		pr_warn("CPU%u: %u spurious wakeup calls
  ", cpu, spurious);
97a63ecff   Russell King   [ARM SMP] Add CPU...
128
  }
8e2a43f5f   Russell King   ARM: rename mach_...
129
  int platform_cpu_disable(unsigned int cpu)
97a63ecff   Russell King   [ARM SMP] Add CPU...
130
131
132
133
134
135
136
  {
  	/*
  	 * we don't allow CPU 0 to be shutdown (it is still too special
  	 * e.g. clock tick interrupts)
  	 */
  	return cpu == 0 ? -EPERM : 0;
  }