2 * PowerPC 64-bit swsusp implementation
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
9 #include <linux/threads.h>
10 #include <asm/processor.h>
12 #include <asm/cputable.h>
13 #include <asm/thread_info.h>
14 #include <asm/ppc_asm.h>
15 #include <asm/asm-offsets.h>
18 * Structure for storing CPU registers on the save area.
20 #define SL_r1 0x00 /* stack pointer */
49 #define SL_SPRG1 0x100
51 #define SL_SIZE SL_TCR+8
53 /* these macros rely on the save area being
54 * pointed to by r11 */
56 #define SAVE_SPR(register) \
57 mfspr r0, SPRN_##register ;\
58 std r0, SL_##register(r11)
59 #define RESTORE_SPR(register) \
60 ld r0, SL_##register(r11) ;\
61 mtspr SPRN_##register, r0
62 #define SAVE_SPECIAL(special) \
64 std r0, SL_##special(r11)
65 #define RESTORE_SPECIAL(special) \
66 ld r0, SL_##special(r11) ;\
68 #define SAVE_REGISTER(reg) \
69 std reg, SL_##reg(r11)
70 #define RESTORE_REGISTER(reg) \
73 /* space for storing cpu state */
81 .tc swsusp_save_area[TC],swsusp_save_area
83 .tc restore_pblist[TC],restore_pblist
87 _GLOBAL(swsusp_arch_suspend)
88 ld r11,swsusp_save_area_ptr@toc(r2)
116 #ifdef CONFIG_PPC_BOOK3S_64
121 /* Save SPRG1, SPRG1 be used save paca */
125 /* we push the stack up 128 bytes but don't store the
126 * stack pointer on the stack like a real stackframe */
133 ld r11,swsusp_save_area_ptr@toc(r2)
140 _GLOBAL(swsusp_arch_resume)
141 /* Stop pending alitvec streams and memory accesses */
144 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
147 ld r12,restore_pblist_ptr@toc(r2)
154 ld r13,pbe_address(r12)
155 ld r14,pbe_orig_address(r12)
170 #ifdef CONFIG_PPC_BOOK3S_64
175 ori r3, r3, CONFIG_KERNEL_START>>48
189 ld r11,swsusp_save_area_ptr@toc(r2)
193 /* restore timebase */
196 /* get upper 32 bits of it */
198 /* clear tb lower to avoid wrap */
206 /* restore registers */
209 RESTORE_REGISTER(r12)
210 RESTORE_REGISTER(r13)
211 RESTORE_REGISTER(r14)
212 RESTORE_REGISTER(r15)
213 RESTORE_REGISTER(r16)
214 RESTORE_REGISTER(r17)
215 RESTORE_REGISTER(r18)
216 RESTORE_REGISTER(r19)
217 RESTORE_REGISTER(r20)
218 RESTORE_REGISTER(r21)
219 RESTORE_REGISTER(r22)
220 RESTORE_REGISTER(r23)
221 RESTORE_REGISTER(r24)
222 RESTORE_REGISTER(r25)
223 RESTORE_REGISTER(r26)
224 RESTORE_REGISTER(r27)
225 RESTORE_REGISTER(r28)
226 RESTORE_REGISTER(r29)
227 RESTORE_REGISTER(r30)
228 RESTORE_REGISTER(r31)
230 #ifdef CONFIG_PPC_BOOK3S_64
231 /* can't use RESTORE_SPECIAL(MSR) */
234 RESTORE_SPECIAL(SDR1)
236 /* Restore SPRG1, be used to save paca */
242 /* Restore TCR and clear any pending bits in TSR. */
244 lis r0, (TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS)@h
247 /* Kick decrementer */
251 /* Invalidate all tlbs */
259 #ifdef CONFIG_PPC_BOOK3S_64
260 bl slb_flush_and_rebolt
265 ld r11,swsusp_save_area_ptr@toc(r2)