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> 18*01eb454eSThomas Gleixner #include <asm/processor.h> 19763142d1SPaul Mundt #include <asm/smp.h> 20e839ca52SDavid Howells #include <asm/bl_bit.h> 211da1180cSPaul Mundt 223738fa5bSLen Brown static void (*sh_idle)(void); 23fbb82b03SPaul Mundt default_idle(void)24f533c3d3SPaul Mundtvoid default_idle(void) 25f533c3d3SPaul Mundt { 2673a38b83SPaul Mundt set_bl_bit(); 2758c644baSPeter Zijlstra raw_local_irq_enable(); 28dc775dd8SThomas Gleixner /* Isn't this racy ? */ 29f533c3d3SPaul Mundt cpu_sleep(); 3089b30987SPeter Zijlstra raw_local_irq_disable(); 3173a38b83SPaul Mundt clear_bl_bit(); 32f533c3d3SPaul Mundt } 33f533c3d3SPaul Mundt arch_cpu_idle_dead(void)34071c44e4SJosh Poimboeufvoid __noreturn arch_cpu_idle_dead(void) 351da1180cSPaul Mundt { 36763142d1SPaul Mundt play_dead(); 37dc775dd8SThomas Gleixner } 38763142d1SPaul Mundt arch_cpu_idle(void)39dc775dd8SThomas Gleixnervoid arch_cpu_idle(void) 40dc775dd8SThomas Gleixner { 413738fa5bSLen Brown sh_idle(); 421da1180cSPaul Mundt } 432e046b94SPaul Mundt select_idle_routine(void)4490851c40SPaul Mundtvoid __init select_idle_routine(void) 45f533c3d3SPaul Mundt { 46f533c3d3SPaul Mundt /* 47f533c3d3SPaul Mundt * If a platform has set its own idle routine, leave it alone. 48f533c3d3SPaul Mundt */ 49dc775dd8SThomas Gleixner if (!sh_idle) 503738fa5bSLen Brown sh_idle = default_idle; 51f533c3d3SPaul Mundt } 52f533c3d3SPaul Mundt stop_this_cpu(void * unused)53fbb82b03SPaul Mundtvoid stop_this_cpu(void *unused) 54fbb82b03SPaul Mundt { 55fbb82b03SPaul Mundt local_irq_disable(); 56f0ccf277SPaul Mundt set_cpu_online(smp_processor_id(), false); 57fbb82b03SPaul Mundt 58fbb82b03SPaul Mundt for (;;) 59fbb82b03SPaul Mundt cpu_sleep(); 60fbb82b03SPaul Mundt } 61