15933f6d2SKuninori Morimoto // SPDX-License-Identifier: GPL-2.0 21da1180cSPaul Mundt /* 31da1180cSPaul Mundt * The idle loop for all SuperH platforms. 41da1180cSPaul Mundt * 52e046b94SPaul Mundt * Copyright (C) 2002 - 2009 Paul Mundt 61da1180cSPaul Mundt */ 7fd49efb3SJosh Poimboeuf #include <linux/cpu.h> 81da1180cSPaul Mundt #include <linux/module.h> 91da1180cSPaul Mundt #include <linux/init.h> 101da1180cSPaul Mundt #include <linux/mm.h> 111da1180cSPaul Mundt #include <linux/pm.h> 121da1180cSPaul Mundt #include <linux/tick.h> 131da1180cSPaul Mundt #include <linux/preempt.h> 141da1180cSPaul Mundt #include <linux/thread_info.h> 151da1180cSPaul Mundt #include <linux/irqflags.h> 162e046b94SPaul Mundt #include <linux/smp.h> 1760063497SArun Sharma #include <linux/atomic.h> 18763142d1SPaul Mundt #include <asm/processor.h> 19e839ca52SDavid Howells #include <asm/smp.h> 201da1180cSPaul Mundt #include <asm/bl_bit.h> 213738fa5bSLen Brown 22fbb82b03SPaul Mundt static void (*sh_idle)(void); 23f533c3d3SPaul Mundt default_idle(void)24f533c3d3SPaul Mundtvoid default_idle(void) 2573a38b83SPaul Mundt { 2658c644baSPeter Zijlstra set_bl_bit(); 27dc775dd8SThomas Gleixner raw_local_irq_enable(); 28f533c3d3SPaul Mundt /* Isn't this racy ? */ 2989b30987SPeter Zijlstra cpu_sleep(); 3073a38b83SPaul Mundt raw_local_irq_disable(); 31f533c3d3SPaul Mundt clear_bl_bit(); 32f533c3d3SPaul Mundt } 33*071c44e4SJosh Poimboeuf arch_cpu_idle_dead(void)341da1180cSPaul Mundtvoid __noreturn arch_cpu_idle_dead(void) 35763142d1SPaul Mundt { 36dc775dd8SThomas Gleixner play_dead(); 37763142d1SPaul Mundt } 38dc775dd8SThomas Gleixner arch_cpu_idle(void)39dc775dd8SThomas Gleixnervoid arch_cpu_idle(void) 403738fa5bSLen Brown { 411da1180cSPaul Mundt sh_idle(); 422e046b94SPaul Mundt } 4390851c40SPaul Mundt select_idle_routine(void)44f533c3d3SPaul Mundtvoid __init select_idle_routine(void) 45f533c3d3SPaul Mundt { 46f533c3d3SPaul Mundt /* 47f533c3d3SPaul Mundt * If a platform has set its own idle routine, leave it alone. 48dc775dd8SThomas Gleixner */ 493738fa5bSLen Brown if (!sh_idle) 50f533c3d3SPaul Mundt sh_idle = default_idle; 51f533c3d3SPaul Mundt } 52fbb82b03SPaul Mundt stop_this_cpu(void * unused)53fbb82b03SPaul Mundtvoid stop_this_cpu(void *unused) 54fbb82b03SPaul Mundt { 55f0ccf277SPaul Mundt local_irq_disable(); 56fbb82b03SPaul Mundt set_cpu_online(smp_processor_id(), false); 57fbb82b03SPaul Mundt 58fbb82b03SPaul Mundt for (;;) 59fbb82b03SPaul Mundt cpu_sleep(); 60 } 61