diff options
Diffstat (limited to 'arch/powerpc/platforms/pasemi/idle.c')
-rw-r--r-- | arch/powerpc/platforms/pasemi/idle.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/pasemi/idle.c b/arch/powerpc/platforms/pasemi/idle.c new file mode 100644 index 000000000000..1ca3ff381591 --- /dev/null +++ b/arch/powerpc/platforms/pasemi/idle.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006-2007 PA Semi, Inc | ||
3 | * | ||
4 | * Maintained by: Olof Johansson <olof@lixom.net> | ||
5 | * | ||
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. | ||
9 | * | ||
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. | ||
14 | * | ||
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 | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #undef DEBUG | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/string.h> | ||
25 | |||
26 | #include <asm/machdep.h> | ||
27 | #include <asm/reg.h> | ||
28 | |||
29 | #include "pasemi.h" | ||
30 | |||
31 | struct sleep_mode { | ||
32 | char *name; | ||
33 | void (*entry)(void); | ||
34 | }; | ||
35 | |||
36 | static struct sleep_mode modes[] = { | ||
37 | { .name = "spin", .entry = &idle_spin }, | ||
38 | { .name = "doze", .entry = &idle_doze }, | ||
39 | }; | ||
40 | |||
41 | static int current_mode = 0; | ||
42 | |||
43 | static int pasemi_system_reset_exception(struct pt_regs *regs) | ||
44 | { | ||
45 | /* If we were woken up from power savings, we need to return | ||
46 | * to the calling function, since nip is not saved across | ||
47 | * all modes. | ||
48 | */ | ||
49 | |||
50 | if (regs->msr & SRR1_WAKEMASK) | ||
51 | regs->nip = regs->link; | ||
52 | |||
53 | switch (regs->msr & SRR1_WAKEMASK) { | ||
54 | case SRR1_WAKEEE: | ||
55 | do_IRQ(regs); | ||
56 | break; | ||
57 | case SRR1_WAKEDEC: | ||
58 | timer_interrupt(regs); | ||
59 | break; | ||
60 | default: | ||
61 | /* do system reset */ | ||
62 | return 0; | ||
63 | } | ||
64 | /* everything handled */ | ||
65 | regs->msr |= MSR_RI; | ||
66 | return 1; | ||
67 | } | ||
68 | |||
69 | void __init pasemi_idle_init(void) | ||
70 | { | ||
71 | ppc_md.system_reset_exception = pasemi_system_reset_exception; | ||
72 | ppc_md.power_save = modes[current_mode].entry; | ||
73 | printk(KERN_INFO "Using PA6T idle loop (%s)\n", modes[current_mode].name); | ||
74 | } | ||
75 | |||
76 | static int __init idle_param(char *p) | ||
77 | { | ||
78 | int i; | ||
79 | for (i = 0; i < sizeof(modes)/sizeof(struct sleep_mode); i++) { | ||
80 | if (!strcmp(modes[i].name, p)) { | ||
81 | current_mode = i; | ||
82 | break; | ||
83 | } | ||
84 | } | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | early_param("idle", idle_param); | ||