2
* linux/arch/unicore32/kernel/sleep.S
4
* Code specific to PKUnity SoC and UniCore ISA
6
* Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn>
7
* Copyright (C) 2001-2010 Guan Xuetao
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License version 2 as
11
* published by the Free Software Foundation.
14
#include <linux/linkage.h>
15
#include <asm/assembler.h>
16
#include <mach/hardware.h>
22
@ get coprocessor registers
24
movc r3, p0.c7, #0 @ PID
25
movc r4, p0.c2, #0 @ translation table base addr
26
movc r5, p0.c1, #0 @ control reg
29
@ store them plus current virtual stack ptr on stack
31
stm.w (r3 - r6), [sp-]
36
@ preserve phys address of stack
40
ldw r1, =sleep_save_sp
47
* Forces CPU into sleep state.
49
* r0 = value for PWRMODE M field for desired sleep state
52
ENTRY(puv3_cpu_suspend)
53
stm.w (r16 - r27, lr), [sp-] @ save registers on stack
54
stm.w (r4 - r15), [sp-] @ save registers on stack
56
#ifdef CONFIG_UNICORE_FPU_F64
57
sfm.w (f0 - f7 ), [sp-]
58
sfm.w (f8 - f15), [sp-]
59
sfm.w (f16 - f23), [sp-]
60
sfm.w (f24 - f31), [sp-]
64
b.l pkunity_cpu_save_cp
66
b.l pkunity_cpu_save_sp
79
ldw r0, =(PKUNITY_DDR2CTRL_BASE)
82
ldw r1, =(PKUNITY_PM_BASE)
84
@ set PLL_SYS_CFG reg, 275
87
@ set PLL_DDR_CFG reg, 66MHz
92
movl r8, #0x800001ff @ epip4d
99
@ prepare DDR2 refresh settings
101
or r5, r5, #0x00000001
103
@ prepare PMCR for PLL changing
106
@ prepare for closing PLL
112
@ movl r0, 0x11111111
114
b pkunity_cpu_do_suspend
118
pkunity_cpu_do_suspend:
120
@ put DDR2 into self-refresh
121
100: stw r5, [r0+], #0x24
129
@ wait for PLL changing complete
130
1: ldw r6, [r1+], #0x44
139
2: stw r7, [r1+], #0x4
150
* entry point from bootloader into kernel during resume
152
* Note: Yes, part of the following code is located into the .data section.
153
* This is to allow sleep_save_sp to be accessed with a relative load
154
* while we can't rely on any MMU translation. We could have put
155
* sleep_save_sp in the .text section as well, but some setups might
156
* insist on it to be truly read-only.
161
ENTRY(puv3_cpu_resume)
162
@ movl r0, 0x20202020
165
ldw r0, sleep_save_sp @ stack phys addr
166
ldw r2, =resume_after_mmu @ its absolute virtual address
167
ldm (r3 - r6), [r0]+ @ CP regs + virt stack ptr
168
mov sp, r6 @ CP regs + virt stack ptr
171
movc p0.c6, r1, #6 @ invalidate I & D TLBs
172
movc p0.c5, r1, #28 @ invalidate I & D caches, BTB
174
movc p0.c7, r3, #0 @ PID
175
movc p0.c2, r4, #0 @ translation table base addr
176
movc p0.c1, r5, #0 @ control reg, turn on mmu
186
.word 0 @ preserve stack phys ptr here
190
@ movl r0, 0x30303030
193
#ifdef CONFIG_UNICORE_FPU_F64
194
lfm.w (f0 - f7 ), [sp]+
195
lfm.w (f8 - f15), [sp]+
196
lfm.w (f16 - f23), [sp]+
197
lfm.w (f24 - f31), [sp]+
201
ldm.w (r4 - r15), [sp]+ @ restore registers from stack
202
ldm.w (r16 - r27, pc), [sp]+ @ return to caller