xref: /linux/arch/arm64/include/asm/suspend.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
26732bc65SLorenzo Pieralisi #ifndef __ASM_SUSPEND_H
36732bc65SLorenzo Pieralisi #define __ASM_SUSPEND_H
46732bc65SLorenzo Pieralisi 
5*6d37d81fSSami Tolvanen #define NR_CTX_REGS 13
6adc9b2dfSJames Morse #define NR_CALLEE_SAVED_REGS 12
76732bc65SLorenzo Pieralisi 
86732bc65SLorenzo Pieralisi /*
96732bc65SLorenzo Pieralisi  * struct cpu_suspend_ctx must be 16-byte aligned since it is allocated on
106732bc65SLorenzo Pieralisi  * the stack, which must be 16-byte aligned on v8
116732bc65SLorenzo Pieralisi  */
126732bc65SLorenzo Pieralisi struct cpu_suspend_ctx {
136732bc65SLorenzo Pieralisi 	/*
146732bc65SLorenzo Pieralisi 	 * This struct must be kept in sync with
156732bc65SLorenzo Pieralisi 	 * cpu_do_{suspend/resume} in mm/proc.S
166732bc65SLorenzo Pieralisi 	 */
176732bc65SLorenzo Pieralisi 	u64 ctx_regs[NR_CTX_REGS];
186732bc65SLorenzo Pieralisi 	u64 sp;
196732bc65SLorenzo Pieralisi } __aligned(16);
2095322526SLorenzo Pieralisi 
21adc9b2dfSJames Morse /*
22adc9b2dfSJames Morse  * Memory to save the cpu state is allocated on the stack by
23adc9b2dfSJames Morse  * __cpu_suspend_enter()'s caller, and populated by __cpu_suspend_enter().
24adc9b2dfSJames Morse  * This data must survive until cpu_resume() is called.
25adc9b2dfSJames Morse  *
26adc9b2dfSJames Morse  * This struct desribes the size and the layout of the saved cpu state.
27adc9b2dfSJames Morse  * The layout of the callee_saved_regs is defined by the implementation
28adc9b2dfSJames Morse  * of __cpu_suspend_enter(), and cpu_resume(). This struct must be passed
29adc9b2dfSJames Morse  * in by the caller as __cpu_suspend_enter()'s stack-frame is gone once it
30adc9b2dfSJames Morse  * returns, and the data would be subsequently corrupted by the call to the
31adc9b2dfSJames Morse  * finisher.
32adc9b2dfSJames Morse  */
33adc9b2dfSJames Morse struct sleep_stack_data {
34adc9b2dfSJames Morse 	struct cpu_suspend_ctx	system_regs;
35adc9b2dfSJames Morse 	unsigned long		callee_saved_regs[NR_CALLEE_SAVED_REGS];
36adc9b2dfSJames Morse };
37adc9b2dfSJames Morse 
38cabe1c81SJames Morse extern unsigned long *sleep_save_stash;
39cabe1c81SJames Morse 
40af391b15SSudeep Holla extern int cpu_suspend(unsigned long arg, int (*fn)(unsigned long));
4195322526SLorenzo Pieralisi extern void cpu_resume(void);
42adc9b2dfSJames Morse int __cpu_suspend_enter(struct sleep_stack_data *state);
43adc9b2dfSJames Morse void __cpu_suspend_exit(void);
4482869ac5SJames Morse void _cpu_resume(void);
4582869ac5SJames Morse 
4682869ac5SJames Morse int swsusp_arch_suspend(void);
4782869ac5SJames Morse int swsusp_arch_resume(void);
4882869ac5SJames Morse int arch_hibernation_header_save(void *addr, unsigned int max_size);
4982869ac5SJames Morse int arch_hibernation_header_restore(void *addr);
5082869ac5SJames Morse 
518ec058fdSJames Morse /* Used to resume on the CPU we hibernated on */
528ec058fdSJames Morse int hibernate_resume_nonboot_cpu_disable(void);
538ec058fdSJames Morse 
546732bc65SLorenzo Pieralisi #endif
55