blob: be616ee0cf8799a6c7deeb058a7a92da6a8f213c [file] [log] [blame]
Paul Mundt1da11802008-11-26 15:52:44 +09001/*
2 * The idle loop for all SuperH platforms.
3 *
Paul Mundt2e046b92009-06-19 14:40:51 +09004 * Copyright (C) 2002 - 2009 Paul Mundt
Paul Mundt1da11802008-11-26 15:52:44 +09005 *
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 Mundt2e046b92009-06-19 14:40:51 +090018#include <linux/smp.h>
Arun Sharma600634972011-07-26 16:09:06 -070019#include <linux/atomic.h>
Paul Mundtf03c4862012-03-30 19:29:57 +090020#include <asm/pgalloc.h>
Paul Mundt763142d2010-04-26 19:08:55 +090021#include <asm/smp.h>
David Howellse839ca52012-03-28 18:30:03 +010022#include <asm/bl_bit.h>
Paul Mundt1da11802008-11-26 15:52:44 +090023
Len Brown3738fa52013-02-09 22:52:57 -050024static void (*sh_idle)(void);
Paul Mundtfbb82b02010-01-20 16:42:52 +090025
Paul Mundtf533c3d2009-10-16 17:20:58 +090026void default_idle(void)
27{
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010028 set_bl_bit();
29 local_irq_enable();
30 /* Isn't this racy ? */
31 cpu_sleep();
32 clear_bl_bit();
Paul Mundtf533c3d2009-10-16 17:20:58 +090033}
34
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010035void arch_cpu_idle_dead(void)
Paul Mundt1da11802008-11-26 15:52:44 +090036{
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010037 play_dead();
38}
Paul Mundtf533c3d2009-10-16 17:20:58 +090039
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010040void arch_cpu_idle(void)
41{
Nicolas Pitref0c5cdb2014-01-29 12:45:11 -050042 sh_idle();
Paul Mundt1da11802008-11-26 15:52:44 +090043}
Paul Mundt2e046b92009-06-19 14:40:51 +090044
Paul Mundt90851c42010-03-23 17:06:47 +090045void __init select_idle_routine(void)
Paul Mundtf533c3d2009-10-16 17:20:58 +090046{
47 /*
48 * If a platform has set its own idle routine, leave it alone.
49 */
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010050 if (!sh_idle)
Len Brown3738fa52013-02-09 22:52:57 -050051 sh_idle = default_idle;
Paul Mundtf533c3d2009-10-16 17:20:58 +090052}
53
Paul Mundtfbb82b02010-01-20 16:42:52 +090054void stop_this_cpu(void *unused)
55{
56 local_irq_disable();
Paul Mundtf0ccf272010-04-26 18:39:50 +090057 set_cpu_online(smp_processor_id(), false);
Paul Mundtfbb82b02010-01-20 16:42:52 +090058
59 for (;;)
60 cpu_sleep();
61}