Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 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 | |
Will Deacon | eb50439 | 2012-01-20 12:01:12 +0100 | [diff] [blame] | 13 | #include <asm/smp_plat.h> |
Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 14 | |
David Brown | be2109e | 2012-09-12 16:01:40 -0700 | [diff] [blame] | 15 | #include "common.h" |
Marc Zyngier | 44ea349 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 16 | |
Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 17 | static inline void cpu_enter_lowpower(void) |
| 18 | { |
Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | static inline void cpu_leave_lowpower(void) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | static inline void platform_do_lowpower(unsigned int cpu) |
| 26 | { |
| 27 | /* Just enter wfi for now. TODO: Properly shut off the cpu. */ |
| 28 | for (;;) { |
| 29 | /* |
| 30 | * here's the WFI |
| 31 | */ |
| 32 | asm("wfi" |
| 33 | : |
| 34 | : |
| 35 | : "memory", "cc"); |
| 36 | |
Will Deacon | 1d3cfb3 | 2011-08-09 12:02:27 +0100 | [diff] [blame] | 37 | if (pen_release == cpu_logical_map(cpu)) { |
Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 38 | /* |
| 39 | * OK, proper wakeup, we're done |
| 40 | */ |
| 41 | break; |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | * getting here, means that we have come out of WFI without |
| 46 | * having been woken up - this shouldn't happen |
| 47 | * |
| 48 | * The trouble is, letting people know about this is not really |
| 49 | * possible, since we are currently running incoherently, and |
| 50 | * therefore cannot safely call printk() or anything else |
| 51 | */ |
| 52 | pr_debug("CPU%u: spurious wakeup call\n", cpu); |
| 53 | } |
| 54 | } |
| 55 | |
Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 56 | /* |
| 57 | * platform-specific code to shutdown a CPU |
| 58 | * |
| 59 | * Called with IRQs disabled |
| 60 | */ |
Marc Zyngier | 44ea349 | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 61 | void __ref msm_cpu_die(unsigned int cpu) |
Jeff Ohlstein | 9f1890a5 | 2010-12-02 12:11:27 -0800 | [diff] [blame] | 62 | { |
| 63 | /* |
| 64 | * we're ready for shutdown now, so do it |
| 65 | */ |
| 66 | cpu_enter_lowpower(); |
| 67 | platform_do_lowpower(cpu); |
| 68 | |
| 69 | /* |
| 70 | * bring this CPU back into the world of cache |
| 71 | * coherency, and then restore interrupts |
| 72 | */ |
| 73 | cpu_leave_lowpower(); |
| 74 | } |