[PATCH] ppc32: Added support for the Book-E style Watchdog Timer
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / ppc / kernel / idle.c
blob53547b6de45bd491e96c0444907b74b36915592c
1 /*
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>
17 #include <linux/mm.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>
26 #include <asm/pgtable.h>
27 #include <asm/uaccess.h>
28 #include <asm/system.h>
29 #include <asm/io.h>
30 #include <asm/mmu.h>
31 #include <asm/cache.h>
32 #include <asm/cputable.h>
33 #include <asm/machdep.h>
35 void default_idle(void)
37 void (*powersave)(void);
39 powersave = ppc_md.power_save;
41 if (!need_resched()) {
42 if (powersave != NULL)
43 powersave();
44 #ifdef CONFIG_SMP
45 else {
46 set_thread_flag(TIF_POLLING_NRFLAG);
47 while (!need_resched())
48 barrier();
49 clear_thread_flag(TIF_POLLING_NRFLAG);
51 #endif
53 if (need_resched())
54 schedule();
58 * The body of the idle task.
60 void cpu_idle(void)
62 for (;;)
63 if (ppc_md.idle != NULL)
64 ppc_md.idle();
65 else
66 default_idle();
69 #if defined(CONFIG_SYSCTL) && defined(CONFIG_6xx)
71 * Register the sysctl to set/clear powersave_nap.
73 extern unsigned long powersave_nap;
75 static ctl_table powersave_nap_ctl_table[]={
77 .ctl_name = KERN_PPC_POWERSAVE_NAP,
78 .procname = "powersave-nap",
79 .data = &powersave_nap,
80 .maxlen = sizeof(int),
81 .mode = 0644,
82 .proc_handler = &proc_dointvec,
84 { 0, },
86 static ctl_table powersave_nap_sysctl_root[] = {
87 { 1, "kernel", NULL, 0, 0755, powersave_nap_ctl_table, },
88 { 0,},
91 static int __init
92 register_powersave_nap_sysctl(void)
94 register_sysctl_table(powersave_nap_sysctl_root, 0);
96 return 0;
99 __initcall(register_powersave_nap_sysctl);
100 #endif