Sundar Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 1 | /* |
| 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 Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 14 | |
| 15 | #include <asm/cacheflush.h> |
Will Deacon | eb50439 | 2012-01-20 12:01:12 +0100 | [diff] [blame] | 16 | #include <asm/smp_plat.h> |
Sundar Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 17 | |
| 18 | extern volatile int pen_release; |
| 19 | |
Sundar Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 20 | static inline void platform_do_lowpower(unsigned int cpu) |
| 21 | { |
| 22 | flush_cache_all(); |
| 23 | |
| 24 | /* we put the platform to just WFI */ |
| 25 | for (;;) { |
| 26 | __asm__ __volatile__("dsb\n\t" "wfi\n\t" |
| 27 | : : : "memory"); |
Will Deacon | 2876348 | 2011-08-09 12:21:36 +0100 | [diff] [blame] | 28 | if (pen_release == cpu_logical_map(cpu)) { |
Sundar Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 29 | /* |
| 30 | * OK, proper wakeup, we're done |
| 31 | */ |
| 32 | break; |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | int platform_cpu_kill(unsigned int cpu) |
| 38 | { |
Russell King | 3c030be | 2010-11-30 11:07:35 +0000 | [diff] [blame] | 39 | return 1; |
Sundar Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | /* |
| 43 | * platform-specific code to shutdown a CPU |
| 44 | * |
| 45 | * Called with IRQs disabled |
| 46 | */ |
| 47 | void platform_cpu_die(unsigned int cpu) |
| 48 | { |
Sundar Iyer | 9d704c0 | 2010-09-15 10:45:51 +0100 | [diff] [blame] | 49 | /* directly enter low power state, skipping secure registers */ |
| 50 | platform_do_lowpower(cpu); |
| 51 | } |
| 52 | |
| 53 | int platform_cpu_disable(unsigned int cpu) |
| 54 | { |
| 55 | /* |
| 56 | * we don't allow CPU 0 to be shutdown (it is still too special |
| 57 | * e.g. clock tick interrupts) |
| 58 | */ |
| 59 | return cpu == 0 ? -EPERM : 0; |
| 60 | } |