blob: 750446feb444083aca6c39bb11e8067681c61f35 [file] [log] [blame]
Jeff Ohlstein9f1890a52010-12-02 12:11:27 -08001/*
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
13#include <asm/cacheflush.h>
Will Deaconeb504392012-01-20 12:01:12 +010014#include <asm/smp_plat.h>
Jeff Ohlstein9f1890a52010-12-02 12:11:27 -080015
David Brownbe2109e2012-09-12 16:01:40 -070016#include "common.h"
Marc Zyngier44ea3492011-09-08 13:15:22 +010017
Jeff Ohlstein9f1890a52010-12-02 12:11:27 -080018static inline void cpu_enter_lowpower(void)
19{
20 /* Just flush the cache. Changing the coherency is not yet
21 * available on msm. */
22 flush_cache_all();
23}
24
25static inline void cpu_leave_lowpower(void)
26{
27}
28
29static inline void platform_do_lowpower(unsigned int cpu)
30{
31 /* Just enter wfi for now. TODO: Properly shut off the cpu. */
32 for (;;) {
33 /*
34 * here's the WFI
35 */
36 asm("wfi"
37 :
38 :
39 : "memory", "cc");
40
Will Deacon1d3cfb32011-08-09 12:02:27 +010041 if (pen_release == cpu_logical_map(cpu)) {
Jeff Ohlstein9f1890a52010-12-02 12:11:27 -080042 /*
43 * OK, proper wakeup, we're done
44 */
45 break;
46 }
47
48 /*
49 * getting here, means that we have come out of WFI without
50 * having been woken up - this shouldn't happen
51 *
52 * The trouble is, letting people know about this is not really
53 * possible, since we are currently running incoherently, and
54 * therefore cannot safely call printk() or anything else
55 */
56 pr_debug("CPU%u: spurious wakeup call\n", cpu);
57 }
58}
59
Jeff Ohlstein9f1890a52010-12-02 12:11:27 -080060/*
61 * platform-specific code to shutdown a CPU
62 *
63 * Called with IRQs disabled
64 */
Marc Zyngier44ea3492011-09-08 13:15:22 +010065void __ref msm_cpu_die(unsigned int cpu)
Jeff Ohlstein9f1890a52010-12-02 12:11:27 -080066{
67 /*
68 * we're ready for shutdown now, so do it
69 */
70 cpu_enter_lowpower();
71 platform_do_lowpower(cpu);
72
73 /*
74 * bring this CPU back into the world of cache
75 * coherency, and then restore interrupts
76 */
77 cpu_leave_lowpower();
78}