xref: /OK3568_Linux_fs/kernel/arch/mips/power/cpu.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Suspend support specific for mips.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2009 Lemote Inc.
6*4882a593Smuzhiyun  * Author: Hu Hongbing <huhb@lemote.com>
7*4882a593Smuzhiyun  *	   Wu Zhangjin <wuzhangjin@gmail.com>
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun #include <asm/sections.h>
10*4882a593Smuzhiyun #include <asm/fpu.h>
11*4882a593Smuzhiyun #include <asm/dsp.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun static u32 saved_status;
14*4882a593Smuzhiyun struct pt_regs saved_regs;
15*4882a593Smuzhiyun 
save_processor_state(void)16*4882a593Smuzhiyun void save_processor_state(void)
17*4882a593Smuzhiyun {
18*4882a593Smuzhiyun 	saved_status = read_c0_status();
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun 	if (is_fpu_owner())
21*4882a593Smuzhiyun 		save_fp(current);
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun 	save_dsp(current);
24*4882a593Smuzhiyun }
25*4882a593Smuzhiyun 
restore_processor_state(void)26*4882a593Smuzhiyun void restore_processor_state(void)
27*4882a593Smuzhiyun {
28*4882a593Smuzhiyun 	write_c0_status(saved_status);
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun 	if (is_fpu_owner())
31*4882a593Smuzhiyun 		restore_fp(current);
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun 	restore_dsp(current);
34*4882a593Smuzhiyun }
35*4882a593Smuzhiyun 
pfn_is_nosave(unsigned long pfn)36*4882a593Smuzhiyun int pfn_is_nosave(unsigned long pfn)
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun 	unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
39*4882a593Smuzhiyun 	unsigned long nosave_end_pfn = PFN_UP(__pa(&__nosave_end));
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun 	return	(pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
42*4882a593Smuzhiyun }
43