powerpc/ppc/ppc64: Various compile fixes.
[sfrench/cifs-2.6.git] / arch / ppc / kernel / idle.c
1 /*
2  * Idle daemon for PowerPC.  Idle daemon will handle any action
3  * that needs to be taken when the system becomes idle.
4  *
5  * Written by Cort Dougan (cort@cs.nmt.edu).  Subsequently hacked
6  * on by Tom Rini, Armin Kuster, Paul Mackerras and others.
7  *
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.
12  */
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>
25 #include <linux/cpu.h>
26
27 #include <asm/pgtable.h>
28 #include <asm/uaccess.h>
29 #include <asm/system.h>
30 #include <asm/io.h>
31 #include <asm/mmu.h>
32 #include <asm/cache.h>
33 #include <asm/cputable.h>
34 #include <asm/machdep.h>
35 #include <asm/smp.h>
36
37 void default_idle(void)
38 {
39         void (*powersave)(void);
40         int cpu = smp_processor_id();
41
42         powersave = ppc_md.power_save;
43
44         if (!need_resched()) {
45                 if (powersave != NULL)
46                         powersave();
47 #ifdef CONFIG_SMP
48                 else {
49                         set_thread_flag(TIF_POLLING_NRFLAG);
50                         while (!need_resched() && !cpu_is_offline(cpu))
51                                 barrier();
52                         clear_thread_flag(TIF_POLLING_NRFLAG);
53                 }
54 #endif
55         }
56         if (need_resched())
57                 schedule();
58         if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
59                 cpu_die();
60 }
61
62 /*
63  * The body of the idle task.
64  */
65 void cpu_idle(void)
66 {
67         for (;;)
68                 if (ppc_md.idle != NULL)
69                         ppc_md.idle();
70                 else
71                         default_idle();
72 }
73
74 #if defined(CONFIG_SYSCTL) && defined(CONFIG_6xx)
75 /*
76  * Register the sysctl to set/clear powersave_nap.
77  */
78 extern int powersave_nap;
79
80 static ctl_table powersave_nap_ctl_table[]={
81         {
82                 .ctl_name       = KERN_PPC_POWERSAVE_NAP,
83                 .procname       = "powersave-nap",
84                 .data           = &powersave_nap,
85                 .maxlen         = sizeof(int),
86                 .mode           = 0644,
87                 .proc_handler   = &proc_dointvec,
88         },
89         { 0, },
90 };
91 static ctl_table powersave_nap_sysctl_root[] = {
92         { 1, "kernel", NULL, 0, 0755, powersave_nap_ctl_table, },
93         { 0,},
94 };
95
96 static int __init
97 register_powersave_nap_sysctl(void)
98 {
99         register_sysctl_table(powersave_nap_sysctl_root, 0);
100
101         return 0;
102 }
103
104 __initcall(register_powersave_nap_sysctl);
105 #endif