Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / powerpc / platforms / pasemi / idle.c
blob44e0d9226f0a720b228f560b79b92ea51f3119ee
1 /*
2 * Copyright (C) 2006-2007 PA Semi, Inc
4 * Maintained by: Olof Johansson <olof@lixom.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #undef DEBUG
23 #include <linux/kernel.h>
24 #include <linux/string.h>
25 #include <linux/irq.h>
27 #include <asm/machdep.h>
28 #include <asm/reg.h>
29 #include <asm/smp.h>
31 #include "pasemi.h"
33 struct sleep_mode {
34 char *name;
35 void (*entry)(void);
38 static struct sleep_mode modes[] = {
39 { .name = "spin", .entry = &idle_spin },
40 { .name = "doze", .entry = &idle_doze },
43 static int current_mode = 0;
45 static int pasemi_system_reset_exception(struct pt_regs *regs)
47 /* If we were woken up from power savings, we need to return
48 * to the calling function, since nip is not saved across
49 * all modes.
52 if (regs->msr & SRR1_WAKEMASK)
53 regs->nip = regs->link;
55 switch (regs->msr & SRR1_WAKEMASK) {
56 case SRR1_WAKEDEC:
57 set_dec(1);
58 case SRR1_WAKEEE:
60 * Handle these when interrupts get re-enabled and we take
61 * them as regular exceptions. We are in an NMI context
62 * and can't handle these here.
64 break;
65 default:
66 /* do system reset */
67 return 0;
70 /* Set higher astate since we come out of power savings at 0 */
71 restore_astate(hard_smp_processor_id());
73 /* everything handled */
74 regs->msr |= MSR_RI;
75 return 1;
78 static int __init pasemi_idle_init(void)
80 #ifndef CONFIG_PPC_PASEMI_CPUFREQ
81 printk(KERN_WARNING "No cpufreq driver, powersavings modes disabled\n");
82 current_mode = 0;
83 #endif
85 ppc_md.system_reset_exception = pasemi_system_reset_exception;
86 ppc_md.power_save = modes[current_mode].entry;
87 printk(KERN_INFO "Using PA6T idle loop (%s)\n", modes[current_mode].name);
89 return 0;
91 machine_late_initcall(pasemi, pasemi_idle_init);
93 static int __init idle_param(char *p)
95 int i;
96 for (i = 0; i < ARRAY_SIZE(modes); i++) {
97 if (!strcmp(modes[i].name, p)) {
98 current_mode = i;
99 break;
102 return 0;
105 early_param("idle", idle_param);