16732bc65SLorenzo Pieralisi #ifndef __ASM_SUSPEND_H 26732bc65SLorenzo Pieralisi #define __ASM_SUSPEND_H 36732bc65SLorenzo Pieralisi 46732bc65SLorenzo Pieralisi #define NR_CTX_REGS 11 5*adc9b2dfSJames 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 2095322526SLorenzo Pieralisi struct sleep_save_sp { 2195322526SLorenzo Pieralisi phys_addr_t *save_ptr_stash; 2295322526SLorenzo Pieralisi phys_addr_t save_ptr_stash_phys; 2395322526SLorenzo Pieralisi }; 2495322526SLorenzo Pieralisi 25*adc9b2dfSJames Morse /* 26*adc9b2dfSJames Morse * Memory to save the cpu state is allocated on the stack by 27*adc9b2dfSJames Morse * __cpu_suspend_enter()'s caller, and populated by __cpu_suspend_enter(). 28*adc9b2dfSJames Morse * This data must survive until cpu_resume() is called. 29*adc9b2dfSJames Morse * 30*adc9b2dfSJames Morse * This struct desribes the size and the layout of the saved cpu state. 31*adc9b2dfSJames Morse * The layout of the callee_saved_regs is defined by the implementation 32*adc9b2dfSJames Morse * of __cpu_suspend_enter(), and cpu_resume(). This struct must be passed 33*adc9b2dfSJames Morse * in by the caller as __cpu_suspend_enter()'s stack-frame is gone once it 34*adc9b2dfSJames Morse * returns, and the data would be subsequently corrupted by the call to the 35*adc9b2dfSJames Morse * finisher. 36*adc9b2dfSJames Morse */ 37*adc9b2dfSJames Morse struct sleep_stack_data { 38*adc9b2dfSJames Morse struct cpu_suspend_ctx system_regs; 39*adc9b2dfSJames Morse unsigned long callee_saved_regs[NR_CALLEE_SAVED_REGS]; 40*adc9b2dfSJames Morse }; 41*adc9b2dfSJames Morse 42af391b15SSudeep Holla extern int cpu_suspend(unsigned long arg, int (*fn)(unsigned long)); 4395322526SLorenzo Pieralisi extern void cpu_resume(void); 44*adc9b2dfSJames Morse int __cpu_suspend_enter(struct sleep_stack_data *state); 45*adc9b2dfSJames Morse void __cpu_suspend_exit(void); 466732bc65SLorenzo Pieralisi #endif 47