1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright 2002 Embedded Edge, LLC
4 * Author: dan@embeddededge.com
6 * Sleep helper for Au1xxx sleep mode.
10 #include <asm/mipsregs.h>
11 #include <asm/regdef.h>
12 #include <asm/stackframe.h>
14 .extern __flush_cache_all
22 /* preparatory stuff */
54 /* flush caches to make sure context is in memory */
55 la t1, __flush_cache_all
60 /* Now set up the scratch registers so the boot rom will
61 * return to this point upon wakeup.
65 lui t3, 0xb190 /* sys_xxx */
67 la k0, alchemy_sleep_wakeup /* resume path */
72 /* put power supply and processor to sleep */
73 sw zero, 0x0078(t3) /* sys_slppwr */
75 sw zero, 0x007c(t3) /* sys_sleep */
87 /* sleep code for Au1000/Au1100/Au1500 memory controller type */
88 LEAF(alchemy_sleep_au1000)
92 /* cache following instructions, as memory gets put to sleep */
101 1: lui a0, 0xb400 /* mem_xxx */
102 sw zero, 0x001c(a0) /* Precharge */
104 sw zero, 0x0020(a0) /* Auto Refresh */
106 sw zero, 0x0030(a0) /* Sleep */
111 END(alchemy_sleep_au1000)
113 /* sleep code for Au1550/Au1200 memory controller type */
114 LEAF(alchemy_sleep_au1550)
118 /* cache following instructions, as memory gets put to sleep */
127 1: lui a0, 0xb400 /* mem_xxx */
128 sw zero, 0x08c0(a0) /* Precharge */
130 sw zero, 0x08d0(a0) /* Self Refresh */
133 /* wait for sdram to enter self-refresh mode */
135 2: lw t1, 0x0850(a0) /* mem_sdstat */
140 /* disable SDRAM clocks */
143 lw t1, 0x0840(a0) /* mem_sdconfiga */
144 and t1, t0, t1 /* clear CE[1:0] */
145 sw t1, 0x0840(a0) /* mem_sdconfiga */
150 END(alchemy_sleep_au1550)
152 /* sleepcode for Au1300 memory controller type */
153 LEAF(alchemy_sleep_au1300)
157 /* cache following instructions, as memory gets put to sleep */
171 2: lui a0, 0xb400 /* mem_xxx */
173 /* disable all ports in mem_sdportcfga */
174 sw zero, 0x868(a0) /* mem_sdportcfga */
179 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
180 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
185 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
186 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
190 sw zero, 0x08c8(a0) /* mem_sdautoref */
193 /* block access to the DDR */
194 lw t0, 0x0848(a0) /* mem_sdconfigb */
195 li t1, (1 << 7 | 0x3F)
197 sw t0, 0x0848(a0) /* mem_sdconfigb */
200 /* issue the Self Refresh command */
202 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
203 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
206 /* wait for sdram to enter self-refresh mode */
208 3: lw t1, 0x0850(a0) /* mem_sdstat */
213 /* disable SDRAM clocks */
215 lw t1, 0x0840(a0) /* mem_sdconfiga */
216 and t1, t1, t0 /* clear CE[1:0] */
217 sw t1, 0x0840(a0) /* mem_sdconfiga */
223 END(alchemy_sleep_au1300)
226 /* This is where we return upon wakeup.
227 * Reload all of the registers and return.
229 LEAF(alchemy_sleep_wakeup)
235 mtc0 k0, CP0_PAGEMASK
239 /* We need to catch the early Alchemy SOCs with
240 * the write-only Config[OD] bit and set it back to one...
242 jal au1x00_fixup_config_od
266 END(alchemy_sleep_wakeup)