Paul Mundt | 1da1180 | 2008-11-26 15:52:44 +0900 | [diff] [blame] | 1 | /* |
2 | * The idle loop for all SuperH platforms. | ||||
3 | * | ||||
Paul Mundt | 2e046b9 | 2009-06-19 14:40:51 +0900 | [diff] [blame] | 4 | * Copyright (C) 2002 - 2009 Paul Mundt |
Paul Mundt | 1da1180 | 2008-11-26 15:52:44 +0900 | [diff] [blame] | 5 | * |
6 | * This file is subject to the terms and conditions of the GNU General Public | ||||
7 | * License. See the file "COPYING" in the main directory of this archive | ||||
8 | * for more details. | ||||
9 | */ | ||||
10 | #include <linux/module.h> | ||||
11 | #include <linux/init.h> | ||||
12 | #include <linux/mm.h> | ||||
13 | #include <linux/pm.h> | ||||
14 | #include <linux/tick.h> | ||||
15 | #include <linux/preempt.h> | ||||
16 | #include <linux/thread_info.h> | ||||
17 | #include <linux/irqflags.h> | ||||
Paul Mundt | 2e046b9 | 2009-06-19 14:40:51 +0900 | [diff] [blame] | 18 | #include <linux/smp.h> |
Len Brown | a0bfa13 | 2011-04-01 19:34:59 -0400 | [diff] [blame] | 19 | #include <linux/cpuidle.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 20 | #include <linux/atomic.h> |
Paul Mundt | f03c486 | 2012-03-30 19:29:57 +0900 | [diff] [blame] | 21 | #include <asm/pgalloc.h> |
Paul Mundt | 763142d | 2010-04-26 19:08:55 +0900 | [diff] [blame] | 22 | #include <asm/smp.h> |
David Howells | e839ca5 | 2012-03-28 18:30:03 +0100 | [diff] [blame] | 23 | #include <asm/bl_bit.h> |
Paul Mundt | 1da1180 | 2008-11-26 15:52:44 +0900 | [diff] [blame] | 24 | |
Len Brown | 3738fa5 | 2013-02-09 22:52:57 -0500 | [diff] [blame] | 25 | static void (*sh_idle)(void); |
Paul Mundt | fbb82b0 | 2010-01-20 16:42:52 +0900 | [diff] [blame] | 26 | |
Paul Mundt | f533c3d | 2009-10-16 17:20:58 +0900 | [diff] [blame] | 27 | void default_idle(void) |
28 | { | ||||
Thomas Gleixner | dc775dd | 2013-03-21 22:49:59 +0100 | [diff] [blame] | 29 | set_bl_bit(); |
30 | local_irq_enable(); | ||||
31 | /* Isn't this racy ? */ | ||||
32 | cpu_sleep(); | ||||
33 | clear_bl_bit(); | ||||
Paul Mundt | f533c3d | 2009-10-16 17:20:58 +0900 | [diff] [blame] | 34 | } |
35 | |||||
Thomas Gleixner | dc775dd | 2013-03-21 22:49:59 +0100 | [diff] [blame] | 36 | void arch_cpu_idle_dead(void) |
Paul Mundt | 1da1180 | 2008-11-26 15:52:44 +0900 | [diff] [blame] | 37 | { |
Thomas Gleixner | dc775dd | 2013-03-21 22:49:59 +0100 | [diff] [blame] | 38 | play_dead(); |
39 | } | ||||
Paul Mundt | f533c3d | 2009-10-16 17:20:58 +0900 | [diff] [blame] | 40 | |
Thomas Gleixner | dc775dd | 2013-03-21 22:49:59 +0100 | [diff] [blame] | 41 | void arch_cpu_idle(void) |
42 | { | ||||
43 | if (cpuidle_idle_call()) | ||||
44 | sh_idle(); | ||||
Paul Mundt | 1da1180 | 2008-11-26 15:52:44 +0900 | [diff] [blame] | 45 | } |
Paul Mundt | 2e046b9 | 2009-06-19 14:40:51 +0900 | [diff] [blame] | 46 | |
Paul Mundt | 90851c4 | 2010-03-23 17:06:47 +0900 | [diff] [blame] | 47 | void __init select_idle_routine(void) |
Paul Mundt | f533c3d | 2009-10-16 17:20:58 +0900 | [diff] [blame] | 48 | { |
49 | /* | ||||
50 | * If a platform has set its own idle routine, leave it alone. | ||||
51 | */ | ||||
Thomas Gleixner | dc775dd | 2013-03-21 22:49:59 +0100 | [diff] [blame] | 52 | if (!sh_idle) |
Len Brown | 3738fa5 | 2013-02-09 22:52:57 -0500 | [diff] [blame] | 53 | sh_idle = default_idle; |
Paul Mundt | f533c3d | 2009-10-16 17:20:58 +0900 | [diff] [blame] | 54 | } |
55 | |||||
Paul Mundt | fbb82b0 | 2010-01-20 16:42:52 +0900 | [diff] [blame] | 56 | void stop_this_cpu(void *unused) |
57 | { | ||||
58 | local_irq_disable(); | ||||
Paul Mundt | f0ccf27 | 2010-04-26 18:39:50 +0900 | [diff] [blame] | 59 | set_cpu_online(smp_processor_id(), false); |
Paul Mundt | fbb82b0 | 2010-01-20 16:42:52 +0900 | [diff] [blame] | 60 | |
61 | for (;;) | ||||
62 | cpu_sleep(); | ||||
63 | } |