sleeper.S 3.6 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright 2002 Embedded Edge, LLC
 * Author: dan@embeddededge.com
 *
 * Sleep helper for Au1xxx sleep mode.
 *
 * This program is free software; you can redistribute	it and/or modify it
 * under  the terms of	the GNU General	 Public License as published by the
 * Free Software Foundation;  either version 2 of the  License, or (at your
 * option) any later version.
 */
12

L
Linus Torvalds 已提交
13 14 15 16 17
#include <asm/asm.h>
#include <asm/mipsregs.h>
#include <asm/regdef.h>
#include <asm/stackframe.h>

18 19
	.extern __flush_cache_all

L
Linus Torvalds 已提交
20
	.text
21 22
	.set noreorder
	.set noat
L
Linus Torvalds 已提交
23 24 25 26 27
	.align	5

/* Save all of the processor general registers and go to sleep.
 * A wakeup condition will get us back here to restore the registers.
 */
28
LEAF(au1xxx_save_and_sleep)
L
Linus Torvalds 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
	subu	sp, PT_SIZE
	sw	$1, PT_R1(sp)
	sw	$2, PT_R2(sp)
	sw	$3, PT_R3(sp)
	sw	$4, PT_R4(sp)
	sw	$5, PT_R5(sp)
	sw	$6, PT_R6(sp)
	sw	$7, PT_R7(sp)
	sw	$16, PT_R16(sp)
	sw	$17, PT_R17(sp)
	sw	$18, PT_R18(sp)
	sw	$19, PT_R19(sp)
	sw	$20, PT_R20(sp)
	sw	$21, PT_R21(sp)
	sw	$22, PT_R22(sp)
	sw	$23, PT_R23(sp)
	sw	$26, PT_R26(sp)
	sw	$27, PT_R27(sp)
	sw	$28, PT_R28(sp)
	sw	$30, PT_R30(sp)
	sw	$31, PT_R31(sp)
	mfc0	k0, CP0_STATUS
	sw	k0, 0x20(sp)
	mfc0	k0, CP0_CONTEXT
	sw	k0, 0x1c(sp)
	mfc0	k0, CP0_PAGEMASK
	sw	k0, 0x18(sp)
	mfc0	k0, CP0_CONFIG
	sw	k0, 0x14(sp)

59 60 61 62 63 64
	/* flush caches to make sure context is in memory */
	la	t1, __flush_cache_all
	lw	t0, 0(t1)
	jalr	t0
	 nop

L
Linus Torvalds 已提交
65 66
	/* Now set up the scratch registers so the boot rom will
	 * return to this point upon wakeup.
67 68
	 * sys_scratch0 : SP
	 * sys_scratch1 : RA
L
Linus Torvalds 已提交
69
	 */
70 71 72 73
	lui	t3, 0xb190		/* sys_xxx */
	sw	sp, 0x0018(t3)
	la	k0, 3f			/* resume path */
	sw	k0, 0x001c(t3)
L
Linus Torvalds 已提交
74

75 76 77 78
	/* Put SDRAM into self refresh:  Preload instructions into cache,
	 * issue a precharge, auto/self refresh, then sleep commands to it.
	 */
	la	t0, 1f
L
Linus Torvalds 已提交
79
	.set	mips3
R
Ralf Baechle 已提交
80 81 82 83
	cache	0x14, 0(t0)
	cache	0x14, 32(t0)
	cache	0x14, 64(t0)
	cache	0x14, 96(t0)
L
Linus Torvalds 已提交
84 85
	.set	mips0

86 87 88 89 90 91 92 93 94 95 96 97 98
1:	lui 	a0, 0xb400		/* mem_xxx */
#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100) ||	\
    defined(CONFIG_SOC_AU1500)
	sw	zero, 0x001c(a0) 	/* Precharge */
	sync
	sw	zero, 0x0020(a0)	/* Auto Refresh */
	sync
	sw	zero, 0x0030(a0)  	/* Sleep */
	sync
#endif

#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
	sw	zero, 0x08c0(a0) 	/* Precharge */
L
Linus Torvalds 已提交
99
	sync
100 101 102 103 104 105 106 107 108
	sw	zero, 0x08d0(a0)	/* Self Refresh */
	sync

	/* wait for sdram to enter self-refresh mode */
	lui 	t0, 0x0100
2:	lw 	t1, 0x0850(a0)		/* mem_sdstat */
	and	t2, t1, t0
	beq	t2, zero, 2b
	 nop
L
Linus Torvalds 已提交
109

110 111 112 113 114 115
	/* disable SDRAM clocks */
	lui	t0, 0xcfff
	ori	t0, t0, 0xffff
	lw 	t1, 0x0840(a0)		/* mem_sdconfiga */
	and 	t1, t0, t1		/* clear CE[1:0] */
	sw 	t1, 0x0840(a0)		/* mem_sdconfiga */
L
Linus Torvalds 已提交
116
	sync
117 118 119 120 121 122
#endif

	/* put power supply and processor to sleep */
	sw	zero, 0x0078(t3)	/* sys_slppwr */
	sync
	sw	zero, 0x007c(t3)	/* sys_sleep */
L
Linus Torvalds 已提交
123
	sync
124 125 126 127 128 129 130 131
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
L
Linus Torvalds 已提交
132 133 134 135

	/* This is where we return upon wakeup.
	 * Reload all of the registers and return.
	 */
136
3:	lw	k0, 0x20(sp)
L
Linus Torvalds 已提交
137 138 139 140 141 142 143
	mtc0	k0, CP0_STATUS
	lw	k0, 0x1c(sp)
	mtc0	k0, CP0_CONTEXT
	lw	k0, 0x18(sp)
	mtc0	k0, CP0_PAGEMASK
	lw	k0, 0x14(sp)
	mtc0	k0, CP0_CONFIG
144

145
	/* We need to catch the early Alchemy SOCs with
146 147 148
	 * the write-only Config[OD] bit and set it back to one...
	 */
	jal	au1x00_fixup_config_od
149
	 nop
L
Linus Torvalds 已提交
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
	lw	$1, PT_R1(sp)
	lw	$2, PT_R2(sp)
	lw	$3, PT_R3(sp)
	lw	$4, PT_R4(sp)
	lw	$5, PT_R5(sp)
	lw	$6, PT_R6(sp)
	lw	$7, PT_R7(sp)
	lw	$16, PT_R16(sp)
	lw	$17, PT_R17(sp)
	lw	$18, PT_R18(sp)
	lw	$19, PT_R19(sp)
	lw	$20, PT_R20(sp)
	lw	$21, PT_R21(sp)
	lw	$22, PT_R22(sp)
	lw	$23, PT_R23(sp)
	lw	$26, PT_R26(sp)
	lw	$27, PT_R27(sp)
	lw	$28, PT_R28(sp)
	lw	$30, PT_R30(sp)
	lw	$31, PT_R31(sp)
	jr	ra
171 172
	 addiu	sp, PT_SIZE
END(au1xxx_save_and_sleep)