18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __ASM_SUSPEND_H
38c2ecf20Sopenharmony_ci#define __ASM_SUSPEND_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define NR_CTX_REGS 13
68c2ecf20Sopenharmony_ci#define NR_CALLEE_SAVED_REGS 12
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * struct cpu_suspend_ctx must be 16-byte aligned since it is allocated on
108c2ecf20Sopenharmony_ci * the stack, which must be 16-byte aligned on v8
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_cistruct cpu_suspend_ctx {
138c2ecf20Sopenharmony_ci	/*
148c2ecf20Sopenharmony_ci	 * This struct must be kept in sync with
158c2ecf20Sopenharmony_ci	 * cpu_do_{suspend/resume} in mm/proc.S
168c2ecf20Sopenharmony_ci	 */
178c2ecf20Sopenharmony_ci	u64 ctx_regs[NR_CTX_REGS];
188c2ecf20Sopenharmony_ci	u64 sp;
198c2ecf20Sopenharmony_ci} __aligned(16);
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/*
228c2ecf20Sopenharmony_ci * Memory to save the cpu state is allocated on the stack by
238c2ecf20Sopenharmony_ci * __cpu_suspend_enter()'s caller, and populated by __cpu_suspend_enter().
248c2ecf20Sopenharmony_ci * This data must survive until cpu_resume() is called.
258c2ecf20Sopenharmony_ci *
268c2ecf20Sopenharmony_ci * This struct desribes the size and the layout of the saved cpu state.
278c2ecf20Sopenharmony_ci * The layout of the callee_saved_regs is defined by the implementation
288c2ecf20Sopenharmony_ci * of __cpu_suspend_enter(), and cpu_resume(). This struct must be passed
298c2ecf20Sopenharmony_ci * in by the caller as __cpu_suspend_enter()'s stack-frame is gone once it
308c2ecf20Sopenharmony_ci * returns, and the data would be subsequently corrupted by the call to the
318c2ecf20Sopenharmony_ci * finisher.
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_cistruct sleep_stack_data {
348c2ecf20Sopenharmony_ci	struct cpu_suspend_ctx	system_regs;
358c2ecf20Sopenharmony_ci	unsigned long		callee_saved_regs[NR_CALLEE_SAVED_REGS];
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciextern unsigned long *sleep_save_stash;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciextern int cpu_suspend(unsigned long arg, int (*fn)(unsigned long));
418c2ecf20Sopenharmony_ciextern void cpu_resume(void);
428c2ecf20Sopenharmony_ciint __cpu_suspend_enter(struct sleep_stack_data *state);
438c2ecf20Sopenharmony_civoid __cpu_suspend_exit(void);
448c2ecf20Sopenharmony_civoid _cpu_resume(void);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciint swsusp_arch_suspend(void);
478c2ecf20Sopenharmony_ciint swsusp_arch_resume(void);
488c2ecf20Sopenharmony_ciint arch_hibernation_header_save(void *addr, unsigned int max_size);
498c2ecf20Sopenharmony_ciint arch_hibernation_header_restore(void *addr);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/* Used to resume on the CPU we hibernated on */
528c2ecf20Sopenharmony_ciint hibernate_resume_nonboot_cpu_disable(void);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#endif
55