xref: /OK3568_Linux_fs/kernel/arch/arm64/include/asm/suspend.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __ASM_SUSPEND_H
3*4882a593Smuzhiyun #define __ASM_SUSPEND_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #define NR_CTX_REGS 13
6*4882a593Smuzhiyun #define NR_CALLEE_SAVED_REGS 12
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /*
9*4882a593Smuzhiyun  * struct cpu_suspend_ctx must be 16-byte aligned since it is allocated on
10*4882a593Smuzhiyun  * the stack, which must be 16-byte aligned on v8
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun struct cpu_suspend_ctx {
13*4882a593Smuzhiyun 	/*
14*4882a593Smuzhiyun 	 * This struct must be kept in sync with
15*4882a593Smuzhiyun 	 * cpu_do_{suspend/resume} in mm/proc.S
16*4882a593Smuzhiyun 	 */
17*4882a593Smuzhiyun 	u64 ctx_regs[NR_CTX_REGS];
18*4882a593Smuzhiyun 	u64 sp;
19*4882a593Smuzhiyun } __aligned(16);
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun /*
22*4882a593Smuzhiyun  * Memory to save the cpu state is allocated on the stack by
23*4882a593Smuzhiyun  * __cpu_suspend_enter()'s caller, and populated by __cpu_suspend_enter().
24*4882a593Smuzhiyun  * This data must survive until cpu_resume() is called.
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  * This struct desribes the size and the layout of the saved cpu state.
27*4882a593Smuzhiyun  * The layout of the callee_saved_regs is defined by the implementation
28*4882a593Smuzhiyun  * of __cpu_suspend_enter(), and cpu_resume(). This struct must be passed
29*4882a593Smuzhiyun  * in by the caller as __cpu_suspend_enter()'s stack-frame is gone once it
30*4882a593Smuzhiyun  * returns, and the data would be subsequently corrupted by the call to the
31*4882a593Smuzhiyun  * finisher.
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun struct sleep_stack_data {
34*4882a593Smuzhiyun 	struct cpu_suspend_ctx	system_regs;
35*4882a593Smuzhiyun 	unsigned long		callee_saved_regs[NR_CALLEE_SAVED_REGS];
36*4882a593Smuzhiyun };
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun extern unsigned long *sleep_save_stash;
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun extern int cpu_suspend(unsigned long arg, int (*fn)(unsigned long));
41*4882a593Smuzhiyun extern void cpu_resume(void);
42*4882a593Smuzhiyun int __cpu_suspend_enter(struct sleep_stack_data *state);
43*4882a593Smuzhiyun void __cpu_suspend_exit(void);
44*4882a593Smuzhiyun void _cpu_resume(void);
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun int swsusp_arch_suspend(void);
47*4882a593Smuzhiyun int swsusp_arch_resume(void);
48*4882a593Smuzhiyun int arch_hibernation_header_save(void *addr, unsigned int max_size);
49*4882a593Smuzhiyun int arch_hibernation_header_restore(void *addr);
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun /* Used to resume on the CPU we hibernated on */
52*4882a593Smuzhiyun int hibernate_resume_nonboot_cpu_disable(void);
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #endif
55