blob: 41dcb2175299195e60f6a2b2b436c23c7cbab660 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Johannes Bergbe9c94d2007-04-30 21:37:15 +10002/*
3 * Common powerpc suspend code for 32 and 64 bits
4 *
5 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
Johannes Bergbe9c94d2007-04-30 21:37:15 +10006 */
7
8#include <linux/sched.h>
Tobin C. Harding1fc439c2017-03-06 19:25:31 +11009#include <linux/suspend.h>
Johannes Bergbe9c94d2007-04-30 21:37:15 +100010#include <asm/current.h>
11#include <asm/mmu_context.h>
David Howellsae3a1972012-03-28 18:30:02 +010012#include <asm/switch_to.h>
Johannes Bergbe9c94d2007-04-30 21:37:15 +100013
14void save_processor_state(void)
15{
16 /*
17 * flush out all the special registers so we don't need
18 * to save them in the snapshot
19 */
Anton Blanchard579e6332015-10-29 11:44:09 +110020 flush_all_to_thread(current);
Johannes Berg543b9fd2007-05-03 22:31:38 +100021
22#ifdef CONFIG_PPC64
23 hard_irq_disable();
24#endif
25
Johannes Bergbe9c94d2007-04-30 21:37:15 +100026}
27
28void restore_processor_state(void)
29{
30#ifdef CONFIG_PPC32
Aneesh Kumar K.Vd2adba32016-04-29 23:26:01 +100031 switch_mmu_context(current->active_mm, current->active_mm, NULL);
Johannes Bergbe9c94d2007-04-30 21:37:15 +100032#endif
Johannes Bergbe9c94d2007-04-30 21:37:15 +100033}