1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2014 Imagination Technologies Ltd.
5 * CPU PM notifiers for saving/restoring general CPU state.
8 #include <linux/cpu_pm.h>
9 #include <linux/init.h>
13 #include <asm/mmu_context.h>
15 #include <asm/watch.h>
17 /* Used by PM helper macros in asm/pm.h */
18 struct mips_static_suspend_state mips_static_suspend_state
;
21 * mips_cpu_save() - Save general CPU state.
22 * Ensures that general CPU context is saved, notably FPU and DSP.
24 static int mips_cpu_save(void)
36 * mips_cpu_restore() - Restore general CPU state.
37 * Restores important CPU context.
39 static void mips_cpu_restore(void)
41 unsigned int cpu
= smp_processor_id();
45 write_c0_entryhi(cpu_asid(cpu
, current
->mm
));
47 /* Restore DSP state */
50 /* Restore UserLocal */
51 if (cpu_has_userlocal
)
52 write_c0_userlocal(current_thread_info()->tp_value
);
54 /* Restore watch registers */
55 __restore_watch(current
);
59 * mips_pm_notifier() - Notifier for preserving general CPU context.
60 * @self: Notifier block.
62 * @v: Private data (unused).
64 * This is called when a CPU power management event occurs, and is used to
65 * ensure that important CPU context is preserved across a CPU power down.
67 static int mips_pm_notifier(struct notifier_block
*self
, unsigned long cmd
,
74 ret
= mips_cpu_save();
78 case CPU_PM_ENTER_FAILED
:
87 static struct notifier_block mips_pm_notifier_block
= {
88 .notifier_call
= mips_pm_notifier
,
91 static int __init
mips_pm_init(void)
93 return cpu_pm_register_notifier(&mips_pm_notifier_block
);
95 arch_initcall(mips_pm_init
);