xref: /linux/arch/powerpc/kernel/swsusp.c (revision 543b9fd3528f64c4b20439de0edb453764482de7)
1be9c94ddSJohannes Berg /*
2be9c94ddSJohannes Berg  * Common powerpc suspend code for 32 and 64 bits
3be9c94ddSJohannes Berg  *
4be9c94ddSJohannes Berg  * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
5be9c94ddSJohannes Berg  *
6be9c94ddSJohannes Berg  * This program is free software; you can redistribute it and/or
7be9c94ddSJohannes Berg  * modify it under the terms of the GNU General Public License
8be9c94ddSJohannes Berg  * as published by the Free Software Foundation; either version
9be9c94ddSJohannes Berg  * 2 of the License, or (at your option) any later version.
10be9c94ddSJohannes Berg  */
11be9c94ddSJohannes Berg 
12be9c94ddSJohannes Berg #include <linux/sched.h>
13be9c94ddSJohannes Berg #include <asm/suspend.h>
14be9c94ddSJohannes Berg #include <asm/system.h>
15be9c94ddSJohannes Berg #include <asm/current.h>
16be9c94ddSJohannes Berg #include <asm/mmu_context.h>
17be9c94ddSJohannes Berg 
18be9c94ddSJohannes Berg void save_processor_state(void)
19be9c94ddSJohannes Berg {
20be9c94ddSJohannes Berg 	/*
21be9c94ddSJohannes Berg 	 * flush out all the special registers so we don't need
22be9c94ddSJohannes Berg 	 * to save them in the snapshot
23be9c94ddSJohannes Berg 	 */
24be9c94ddSJohannes Berg 	flush_fp_to_thread(current);
25be9c94ddSJohannes Berg 	flush_altivec_to_thread(current);
26be9c94ddSJohannes Berg 	flush_spe_to_thread(current);
27*543b9fd3SJohannes Berg 
28*543b9fd3SJohannes Berg #ifdef CONFIG_PPC64
29*543b9fd3SJohannes Berg 	hard_irq_disable();
30*543b9fd3SJohannes Berg #endif
31*543b9fd3SJohannes Berg 
32be9c94ddSJohannes Berg }
33be9c94ddSJohannes Berg 
34be9c94ddSJohannes Berg void restore_processor_state(void)
35be9c94ddSJohannes Berg {
36be9c94ddSJohannes Berg #ifdef CONFIG_PPC32
37be9c94ddSJohannes Berg 	set_context(current->active_mm->context.id, current->active_mm->pgd);
38be9c94ddSJohannes Berg #endif
39*543b9fd3SJohannes Berg 
40*543b9fd3SJohannes Berg #ifdef CONFIG_PPC64
41*543b9fd3SJohannes Berg 	hard_irq_enable();
42*543b9fd3SJohannes Berg #endif
43be9c94ddSJohannes Berg }
44