blob: 7a4890b96e5cecbbfd04f242a2c99450584fa520 [file] [log] [blame]
Sundar Iyer9d704c02010-09-15 10:45:51 +01001/*
2 * Copyright (C) STMicroelectronics 2009
3 * Copyright (C) ST-Ericsson SA 2010
4 *
5 * License Terms: GNU General Public License v2
6 * Based on ARM realview platform
7 *
8 * Author: Sundar Iyer <sundar.iyer@stericsson.com>
9 *
10 */
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/smp.h>
Sundar Iyer9d704c02010-09-15 10:45:51 +010014
15#include <asm/cacheflush.h>
16
17extern volatile int pen_release;
18
Sundar Iyer9d704c02010-09-15 10:45:51 +010019static inline void platform_do_lowpower(unsigned int cpu)
20{
21 flush_cache_all();
22
23 /* we put the platform to just WFI */
24 for (;;) {
25 __asm__ __volatile__("dsb\n\t" "wfi\n\t"
26 : : : "memory");
27 if (pen_release == cpu) {
28 /*
29 * OK, proper wakeup, we're done
30 */
31 break;
32 }
33 }
34}
35
36int platform_cpu_kill(unsigned int cpu)
37{
Russell King3c030be2010-11-30 11:07:35 +000038 return 1;
Sundar Iyer9d704c02010-09-15 10:45:51 +010039}
40
41/*
42 * platform-specific code to shutdown a CPU
43 *
44 * Called with IRQs disabled
45 */
46void platform_cpu_die(unsigned int cpu)
47{
48#ifdef DEBUG
49 unsigned int this_cpu = hard_smp_processor_id();
50
51 if (cpu != this_cpu) {
52 printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
53 this_cpu, cpu);
54 BUG();
55 }
56#endif
57
Sundar Iyer9d704c02010-09-15 10:45:51 +010058 /* directly enter low power state, skipping secure registers */
59 platform_do_lowpower(cpu);
60}
61
62int platform_cpu_disable(unsigned int cpu)
63{
64 /*
65 * we don't allow CPU 0 to be shutdown (it is still too special
66 * e.g. clock tick interrupts)
67 */
68 return cpu == 0 ? -EPERM : 0;
69}