1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/kernel/sleep.S
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn>
8 * Copyright (C) 2001-2010 Guan Xuetao
11 #include <linux/linkage.h>
12 #include <asm/assembler.h>
13 #include <mach/hardware.h>
19 @ get coprocessor registers
21 movc r3, p0.c7, #0 @ PID
22 movc r4, p0.c2, #0 @ translation table base addr
23 movc r5, p0.c1, #0 @ control reg
26 @ store them plus current virtual stack ptr on stack
28 stm.w (r3 - r6), [sp-]
33 @ preserve phys address of stack
37 ldw r1, =sleep_save_sp
44 * Forces CPU into sleep state.
46 * r0 = value for PWRMODE M field for desired sleep state
49 ENTRY(puv3_cpu_suspend)
50 stm.w (r16 - r27, lr), [sp-] @ save registers on stack
51 stm.w (r4 - r15), [sp-] @ save registers on stack
53 #ifdef CONFIG_UNICORE_FPU_F64
54 sfm.w (f0 - f7 ), [sp-]
55 sfm.w (f8 - f15), [sp-]
56 sfm.w (f16 - f23), [sp-]
57 sfm.w (f24 - f31), [sp-]
61 b.l pkunity_cpu_save_cp
63 b.l pkunity_cpu_save_sp
76 ldw r0, =(PKUNITY_DDR2CTRL_BASE)
79 ldw r1, =(PKUNITY_PM_BASE)
81 @ set PLL_SYS_CFG reg, 275
84 @ set PLL_DDR_CFG reg, 66MHz
89 movl r8, #0x800001ff @ epip4d
96 @ prepare DDR2 refresh settings
98 or r5, r5, #0x00000001
100 @ prepare PMCR for PLL changing
103 @ prepare for closing PLL
109 @ movl r0, 0x11111111
111 b pkunity_cpu_do_suspend
115 pkunity_cpu_do_suspend:
117 @ put DDR2 into self-refresh
118 100: stw r5, [r0+], #0x24
126 @ wait for PLL changing complete
127 1: ldw r6, [r1+], #0x44
136 2: stw r7, [r1+], #0x4
147 * entry point from bootloader into kernel during resume
149 * Note: Yes, part of the following code is located into the .data section.
150 * This is to allow sleep_save_sp to be accessed with a relative load
151 * while we can't rely on any MMU translation. We could have put
152 * sleep_save_sp in the .text section as well, but some setups might
153 * insist on it to be truly read-only.
158 ENTRY(puv3_cpu_resume)
159 @ movl r0, 0x20202020
162 ldw r0, sleep_save_sp @ stack phys addr
163 ldw r2, =resume_after_mmu @ its absolute virtual address
164 ldm (r3 - r6), [r0]+ @ CP regs + virt stack ptr
165 mov sp, r6 @ CP regs + virt stack ptr
168 movc p0.c6, r1, #6 @ invalidate I & D TLBs
169 movc p0.c5, r1, #28 @ invalidate I & D caches, BTB
171 movc p0.c7, r3, #0 @ PID
172 movc p0.c2, r4, #0 @ translation table base addr
173 movc p0.c1, r5, #0 @ control reg, turn on mmu
183 .word 0 @ preserve stack phys ptr here
187 @ movl r0, 0x30303030
190 #ifdef CONFIG_UNICORE_FPU_F64
191 lfm.w (f0 - f7 ), [sp]+
192 lfm.w (f8 - f15), [sp]+
193 lfm.w (f16 - f23), [sp]+
194 lfm.w (f24 - f31), [sp]+
198 ldm.w (r4 - r15), [sp]+ @ restore registers from stack
199 ldm.w (r16 - r27, pc), [sp]+ @ return to caller