2 * Idle daemon for PowerPC. Idle daemon will handle any action
3 * that needs to be taken when the system becomes idle.
5 * Written by Cort Dougan (cort@cs.nmt.edu). Subsequently hacked
6 * on by Tom Rini, Armin Kuster, Paul Mackerras and others.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
13 #include <linux/config.h>
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/kernel.h>
18 #include <linux/smp.h>
19 #include <linux/smp_lock.h>
20 #include <linux/stddef.h>
21 #include <linux/unistd.h>
22 #include <linux/ptrace.h>
23 #include <linux/slab.h>
24 #include <linux/sysctl.h>
25 #include <linux/cpu.h>
27 #include <asm/pgtable.h>
28 #include <asm/uaccess.h>
29 #include <asm/system.h>
32 #include <asm/cache.h>
33 #include <asm/cputable.h>
34 #include <asm/machdep.h>
37 void default_idle(void)
39 void (*powersave)(void);
41 powersave = ppc_md.power_save;
43 if (!need_resched()) {
44 if (powersave != NULL)
48 set_thread_flag(TIF_POLLING_NRFLAG);
49 while (!need_resched() &&
50 !cpu_is_offline(smp_processor_id()))
52 clear_thread_flag(TIF_POLLING_NRFLAG);
59 * The body of the idle task.
63 int cpu = smp_processor_id();
66 while (!need_resched()) {
67 if (ppc_md.idle != NULL)
73 if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
75 preempt_enable_no_resched();
81 #if defined(CONFIG_SYSCTL) && defined(CONFIG_6xx)
83 * Register the sysctl to set/clear powersave_nap.
85 extern int powersave_nap;
87 static ctl_table powersave_nap_ctl_table[]={
89 .ctl_name = KERN_PPC_POWERSAVE_NAP,
90 .procname = "powersave-nap",
91 .data = &powersave_nap,
92 .maxlen = sizeof(int),
94 .proc_handler = &proc_dointvec,
98 static ctl_table powersave_nap_sysctl_root[] = {
99 { 1, "kernel", NULL, 0, 0755, powersave_nap_ctl_table, },
104 register_powersave_nap_sysctl(void)
106 register_sysctl_table(powersave_nap_sysctl_root, 0);
111 __initcall(register_powersave_nap_sysctl);