2 * Copyright 2002 Embedded Edge, LLC
3 * Author: dan@embeddededge.com
5 * Sleep helper for Au1xxx sleep mode.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
14 #include <asm/mipsregs.h>
15 #include <asm/regdef.h>
16 #include <asm/stackframe.h>
18 .extern __flush_cache_all
26 /* preparatory stuff */
58 /* flush caches to make sure context is in memory */
59 la t1, __flush_cache_all
64 /* Now set up the scratch registers so the boot rom will
65 * return to this point upon wakeup.
69 lui t3, 0xb190 /* sys_xxx */
71 la k0, alchemy_sleep_wakeup /* resume path */
76 /* put power supply and processor to sleep */
77 sw zero, 0x0078(t3) /* sys_slppwr */
79 sw zero, 0x007c(t3) /* sys_sleep */
91 /* sleep code for Au1000/Au1100/Au1500 memory controller type */
92 LEAF(alchemy_sleep_au1000)
96 /* cache following instructions, as memory gets put to sleep */
105 1: lui a0, 0xb400 /* mem_xxx */
106 sw zero, 0x001c(a0) /* Precharge */
108 sw zero, 0x0020(a0) /* Auto Refresh */
110 sw zero, 0x0030(a0) /* Sleep */
115 END(alchemy_sleep_au1000)
117 /* sleep code for Au1550/Au1200 memory controller type */
118 LEAF(alchemy_sleep_au1550)
122 /* cache following instructions, as memory gets put to sleep */
131 1: lui a0, 0xb400 /* mem_xxx */
132 sw zero, 0x08c0(a0) /* Precharge */
134 sw zero, 0x08d0(a0) /* Self Refresh */
137 /* wait for sdram to enter self-refresh mode */
139 2: lw t1, 0x0850(a0) /* mem_sdstat */
144 /* disable SDRAM clocks */
147 lw t1, 0x0840(a0) /* mem_sdconfiga */
148 and t1, t0, t1 /* clear CE[1:0] */
149 sw t1, 0x0840(a0) /* mem_sdconfiga */
154 END(alchemy_sleep_au1550)
156 /* sleepcode for Au1300 memory controller type */
157 LEAF(alchemy_sleep_au1300)
161 /* cache following instructions, as memory gets put to sleep */
175 2: lui a0, 0xb400 /* mem_xxx */
177 /* disable all ports in mem_sdportcfga */
178 sw zero, 0x868(a0) /* mem_sdportcfga */
183 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
184 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
189 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
190 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
194 sw zero, 0x08c8(a0) /* mem_sdautoref */
197 /* block access to the DDR */
198 lw t0, 0x0848(a0) /* mem_sdconfigb */
199 li t1, (1 << 7 | 0x3F)
201 sw t0, 0x0848(a0) /* mem_sdconfigb */
204 /* issue the Self Refresh command */
206 sw t0, 0x08dc(a0) /* mem_sdcmd1 */
207 sw t0, 0x08d8(a0) /* mem_sdcmd0 */
210 /* wait for sdram to enter self-refresh mode */
212 3: lw t1, 0x0850(a0) /* mem_sdstat */
217 /* disable SDRAM clocks */
219 lw t1, 0x0840(a0) /* mem_sdconfiga */
220 and t1, t1, t0 /* clear CE[1:0] */
221 sw t1, 0x0840(a0) /* mem_sdconfiga */
227 END(alchemy_sleep_au1300)
230 /* This is where we return upon wakeup.
231 * Reload all of the registers and return.
233 LEAF(alchemy_sleep_wakeup)
239 mtc0 k0, CP0_PAGEMASK
243 /* We need to catch the early Alchemy SOCs with
244 * the write-only Config[OD] bit and set it back to one...
246 jal au1x00_fixup_config_od
270 END(alchemy_sleep_wakeup)