1 /* SPDX-License-Identifier: GPL-2.0
3 * arch/sh/kernel/cpu/sh3/swsusp.S
5 * Copyright (C) 2009 Magnus Damm
8 #include <linux/errno.h>
9 #include <linux/linkage.h>
10 #include <asm/asm-offsets.h>
19 ! swsusp_arch_resume()
20 ! - copy restore_pblist pages
21 ! - restore registers from swsusp_arch_regs_cpu0
23 ENTRY(swsusp_arch_resume)
31 bt swsusp_restore_regs
33 mov.l @(PBE_ADDRESS, r4), r2
34 mov.l @(PBE_ORIG_ADDRESS, r4), r5
36 mov #(PAGE_SIZE >> 10), r3
38 shlr2 r3 /* PAGE_SIZE / 16 */
41 mov.l @r2+,r1 /* 16n+0 */
44 mov.l @r2+,r1 /* 16n+4 */
47 mov.l @r2+,r1 /* 16n+8 */
50 mov.l @r2+,r1 /* 16n+12 */
56 mov.l @(PBE_NEXT, r4), r4
59 ! BL=0: R7->R0 is bank0
65 ! BL=1: R7->R0 is bank1
80 ! BL=0: R7->R0 is bank0
83 1: .long swsusp_arch_regs_cpu0
84 2: .long restore_pblist
85 3: .long 0x20000000 ! RB=1
88 ! swsusp_arch_suspend()
89 ! - prepare pc for resume, return from function without swsusp_save on resume
90 ! - save registers in swsusp_arch_regs_cpu0
91 ! - call swsusp_save write suspend image
93 ENTRY(swsusp_arch_suspend)
94 sts pr, r0 ! save pr in r0
95 mov r15, r2 ! save sp in r2
96 mov r8, r5 ! save r8 in r5
98 ldc r1, ssr ! save sr in ssr
100 ldc r1, spc ! setup pc value for resuming
101 mov.l 5f, r15 ! use swsusp_arch_regs_cpu0 as stack
103 add r3, r15 ! save from top of structure
105 ! BL=0: R7->R0 is bank0
106 mov.l 2f, r3 ! get new SR value for bank1
109 jsr @r1 ! switch to bank1 and save bank1 r7->r0
112 ! BL=1: R7->R0 is bank1
113 stc r2_bank, k0 ! fetch old sp from r2_bank0
114 mov.l 3f, k4 ! SR bits to clear in k4
116 jsr @k1 ! switch to bank0 and save all regs
117 stc r0_bank, k3 ! fetch old pr from r0_bank0
119 ! BL=0: R7->R0 is bank0
120 mov r2, r15 ! restore old sp
121 mov r5, r8 ! restore old r8
123 ldc r1, sr ! restore old sr
124 lds r0, pr ! restore old pr
130 mov r2, r15 ! restore old sp
131 mov r5, r8 ! restore old r8
132 lds r0, pr ! restore old pr
137 1: .long swsusp_call_save
138 2: .long 0x20000000 ! RB=1
139 3: .long 0xdfffffff ! RB=0
141 5: .long swsusp_arch_regs_cpu0
142 6: .long SWSUSP_ARCH_REGS_SIZE
143 7: .long save_low_regs