1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2006-2007 PA Semi, Inc
5 * Maintained by: Olof Johansson <olof@lixom.net>
10 #include <linux/kernel.h>
11 #include <linux/string.h>
12 #include <linux/irq.h>
14 #include <asm/machdep.h>
25 static struct sleep_mode modes[] = {
26 { .name = "spin", .entry = &idle_spin },
27 { .name = "doze", .entry = &idle_doze },
30 static int current_mode = 0;
32 static int pasemi_system_reset_exception(struct pt_regs *regs)
34 /* If we were woken up from power savings, we need to return
35 * to the calling function, since nip is not saved across
39 if (regs->msr & SRR1_WAKEMASK)
40 regs->nip = regs->link;
42 switch (regs->msr & SRR1_WAKEMASK) {
47 * Handle these when interrupts get re-enabled and we take
48 * them as regular exceptions. We are in an NMI context
49 * and can't handle these here.
57 /* Set higher astate since we come out of power savings at 0 */
58 restore_astate(hard_smp_processor_id());
60 /* everything handled */
65 static int __init pasemi_idle_init(void)
67 #ifndef CONFIG_PPC_PASEMI_CPUFREQ
68 pr_warn("No cpufreq driver, powersavings modes disabled\n");
72 ppc_md.system_reset_exception = pasemi_system_reset_exception;
73 ppc_md.power_save = modes[current_mode].entry;
74 pr_info("Using PA6T idle loop (%s)\n", modes[current_mode].name);
78 machine_late_initcall(pasemi, pasemi_idle_init);
80 static int __init idle_param(char *p)
83 for (i = 0; i < ARRAY_SIZE(modes); i++) {
84 if (!strcmp(modes[i].name, p)) {
92 early_param("idle", idle_param);