2018-12-28 00:32:24 -08:00
// SPDX-License-Identifier: GPL-2.0
2008-11-26 15:52:44 +09:00
/*
* The idle loop for all SuperH platforms .
*
2009-06-19 14:40:51 +09:00
* Copyright ( C ) 2002 - 2009 Paul Mundt
2008-11-26 15:52:44 +09:00
*/
2023-02-13 23:05:49 -08:00
# include <linux/cpu.h>
2008-11-26 15:52:44 +09:00
# include <linux/module.h>
# include <linux/init.h>
# include <linux/mm.h>
# include <linux/pm.h>
# include <linux/tick.h>
# include <linux/preempt.h>
# include <linux/thread_info.h>
# include <linux/irqflags.h>
2009-06-19 14:40:51 +09:00
# include <linux/smp.h>
2011-07-26 16:09:06 -07:00
# include <linux/atomic.h>
2023-06-14 01:39:33 +02:00
# include <asm/processor.h>
2010-04-26 19:08:55 +09:00
# include <asm/smp.h>
2012-03-28 18:30:03 +01:00
# include <asm/bl_bit.h>
2008-11-26 15:52:44 +09:00
2013-02-09 22:52:57 -05:00
static void ( * sh_idle ) ( void ) ;
2010-01-20 16:42:52 +09:00
2013-03-21 22:49:59 +01:00
void default_idle ( void )
2009-10-16 17:20:58 +09:00
{
2013-03-21 22:49:59 +01:00
set_bl_bit ( ) ;
2020-11-20 11:50:35 +01:00
raw_local_irq_enable ( ) ;
2013-03-21 22:49:59 +01:00
/* Isn't this racy ? */
cpu_sleep ( ) ;
2023-01-12 20:43:35 +01:00
raw_local_irq_disable ( ) ;
2013-03-21 22:49:59 +01:00
clear_bl_bit ( ) ;
2009-10-16 17:20:58 +09:00
}
2023-02-13 23:05:58 -08:00
void __noreturn arch_cpu_idle_dead ( void )
2008-11-26 15:52:44 +09:00
{
2013-03-21 22:49:59 +01:00
play_dead ( ) ;
2008-11-26 15:52:44 +09:00
}
2013-03-21 22:49:59 +01:00
void arch_cpu_idle ( void )
2008-11-26 15:52:44 +09:00
{
2014-01-29 12:45:11 -05:00
sh_idle ( ) ;
2008-11-26 15:52:44 +09:00
}
2009-06-19 14:40:51 +09:00
2010-03-23 17:06:47 +09:00
void __init select_idle_routine ( void )
2009-10-16 17:20:58 +09:00
{
/*
* If a platform has set its own idle routine , leave it alone .
*/
2013-03-21 22:49:59 +01:00
if ( ! sh_idle )
2013-02-09 22:52:57 -05:00
sh_idle = default_idle ;
2009-10-16 17:20:58 +09:00
}
2010-01-20 16:42:52 +09:00
void stop_this_cpu ( void * unused )
{
local_irq_disable ( ) ;
2010-04-26 18:39:50 +09:00
set_cpu_online ( smp_processor_id ( ) , false ) ;
2010-01-20 16:42:52 +09:00
for ( ; ; )
cpu_sleep ( ) ;
}