blob: c20fc5487e051f47a71cdb337b3f6e8794315d99 [file] [log] [blame]
Kuninori Morimoto5933f6d2018-12-28 00:32:24 -08001// SPDX-License-Identifier: GPL-2.0
Paul Mundt1da11802008-11-26 15:52:44 +09002/*
3 * The idle loop for all SuperH platforms.
4 *
Paul Mundt2e046b92009-06-19 14:40:51 +09005 * Copyright (C) 2002 - 2009 Paul Mundt
Paul Mundt1da11802008-11-26 15:52:44 +09006 */
7#include <linux/module.h>
8#include <linux/init.h>
9#include <linux/mm.h>
10#include <linux/pm.h>
11#include <linux/tick.h>
12#include <linux/preempt.h>
13#include <linux/thread_info.h>
14#include <linux/irqflags.h>
Paul Mundt2e046b92009-06-19 14:40:51 +090015#include <linux/smp.h>
Arun Sharma600634972011-07-26 16:09:06 -070016#include <linux/atomic.h>
Paul Mundtf03c4862012-03-30 19:29:57 +090017#include <asm/pgalloc.h>
Paul Mundt763142d2010-04-26 19:08:55 +090018#include <asm/smp.h>
David Howellse839ca52012-03-28 18:30:03 +010019#include <asm/bl_bit.h>
Paul Mundt1da11802008-11-26 15:52:44 +090020
Len Brown3738fa52013-02-09 22:52:57 -050021static void (*sh_idle)(void);
Paul Mundtfbb82b02010-01-20 16:42:52 +090022
Paul Mundtf533c3d2009-10-16 17:20:58 +090023void default_idle(void)
24{
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010025 set_bl_bit();
26 local_irq_enable();
27 /* Isn't this racy ? */
28 cpu_sleep();
29 clear_bl_bit();
Paul Mundtf533c3d2009-10-16 17:20:58 +090030}
31
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010032void arch_cpu_idle_dead(void)
Paul Mundt1da11802008-11-26 15:52:44 +090033{
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010034 play_dead();
35}
Paul Mundtf533c3d2009-10-16 17:20:58 +090036
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010037void arch_cpu_idle(void)
38{
Nicolas Pitref0c5cdb2014-01-29 12:45:11 -050039 sh_idle();
Paul Mundt1da11802008-11-26 15:52:44 +090040}
Paul Mundt2e046b92009-06-19 14:40:51 +090041
Paul Mundt90851c42010-03-23 17:06:47 +090042void __init select_idle_routine(void)
Paul Mundtf533c3d2009-10-16 17:20:58 +090043{
44 /*
45 * If a platform has set its own idle routine, leave it alone.
46 */
Thomas Gleixnerdc775dd2013-03-21 22:49:59 +010047 if (!sh_idle)
Len Brown3738fa52013-02-09 22:52:57 -050048 sh_idle = default_idle;
Paul Mundtf533c3d2009-10-16 17:20:58 +090049}
50
Paul Mundtfbb82b02010-01-20 16:42:52 +090051void stop_this_cpu(void *unused)
52{
53 local_irq_disable();
Paul Mundtf0ccf272010-04-26 18:39:50 +090054 set_cpu_online(smp_processor_id(), false);
Paul Mundtfbb82b02010-01-20 16:42:52 +090055
56 for (;;)
57 cpu_sleep();
58}