blob: 2ea4483fd7227c669796644bc47bd3e80b252222 [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>
Len Browna0bfa132011-04-01 19:34:59 -040019#include <linux/cpuidle.h>
Arun Sharma600634972011-07-26 16:09:06 -070020#include <linux/atomic.h>
Paul Mundtf03c4862012-03-30 19:29:57 +090021#include <asm/pgalloc.h>
Paul Mundt763142d2010-04-26 19:08:55 +090022#include <asm/smp.h>
David Howellse839ca52012-03-28 18:30:03 +010023#include <asm/bl_bit.h>
Paul Mundt1da11802008-11-26 15:52:44 +090024
Len Brown3738fa52013-02-09 22:52:57 -050025static void (*sh_idle)(void);
Paul Mundtfbb82b02010-01-20 16:42:52 +090026
Paul Mundtf533c3d2009-10-16 17:20:58 +090027void default_idle(void)
28{
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010029 set_bl_bit();
30 local_irq_enable();
31 /* Isn't this racy ? */
32 cpu_sleep();
33 clear_bl_bit();
Paul Mundtf533c3d2009-10-16 17:20:58 +090034}
35
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010036void arch_cpu_idle_dead(void)
Paul Mundt1da11802008-11-26 15:52:44 +090037{
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010038 play_dead();
39}
Paul Mundtf533c3d2009-10-16 17:20:58 +090040
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010041void arch_cpu_idle(void)
42{
43 if (cpuidle_idle_call())
44 sh_idle();
Paul Mundt1da11802008-11-26 15:52:44 +090045}
Paul Mundt2e046b92009-06-19 14:40:51 +090046
Paul Mundt90851c42010-03-23 17:06:47 +090047void __init select_idle_routine(void)
Paul Mundtf533c3d2009-10-16 17:20:58 +090048{
49 /*
50 * If a platform has set its own idle routine, leave it alone.
51 */
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010052 if (!sh_idle)
Len Brown3738fa52013-02-09 22:52:57 -050053 sh_idle = default_idle;
Paul Mundtf533c3d2009-10-16 17:20:58 +090054}
55
Paul Mundtfbb82b02010-01-20 16:42:52 +090056void stop_this_cpu(void *unused)
57{
58 local_irq_disable();
Paul Mundtf0ccf272010-04-26 18:39:50 +090059 set_cpu_online(smp_processor_id(), false);
Paul Mundtfbb82b02010-01-20 16:42:52 +090060
61 for (;;)
62 cpu_sleep();
63}