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