ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / au1000 / common / sleeper.S
1 /*
2  * Copyright 2002 Embedded Edge, LLC
3  * Author: dan@embeddededge.com
4  *
5  * Sleep helper for Au1xxx sleep mode.
6  *
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.
11  */
12 #include <linux/config.h>
13 #include <asm/asm.h>
14 #include <asm/mipsregs.h>
15 #include <asm/addrspace.h>
16 #include <asm/regdef.h>
17 #include <asm/stackframe.h>
18
19         .text
20         .set    macro
21         .set    noat
22         .align  5
23
24 /* Save all of the processor general registers and go to sleep.
25  * A wakeup condition will get us back here to restore the registers.
26  */
27 LEAF(save_and_sleep)
28
29         subu    sp, PT_SIZE
30         sw      $1, PT_R1(sp)
31         sw      $2, PT_R2(sp)
32         sw      $3, PT_R3(sp)
33         sw      $4, PT_R4(sp)
34         sw      $5, PT_R5(sp)
35         sw      $6, PT_R6(sp)
36         sw      $7, PT_R7(sp)
37         sw      $8, PT_R8(sp)
38         sw      $9, PT_R9(sp)
39         sw      $10, PT_R10(sp)
40         sw      $11, PT_R11(sp)
41         sw      $12, PT_R12(sp)
42         sw      $13, PT_R13(sp)
43         sw      $14, PT_R14(sp)
44         sw      $15, PT_R15(sp)
45         sw      $16, PT_R16(sp)
46         sw      $17, PT_R17(sp)
47         sw      $18, PT_R18(sp)
48         sw      $19, PT_R19(sp)
49         sw      $20, PT_R20(sp)
50         sw      $21, PT_R21(sp)
51         sw      $22, PT_R22(sp)
52         sw      $23, PT_R23(sp)
53         sw      $24, PT_R24(sp)
54         sw      $25, PT_R25(sp)
55         sw      $26, PT_R26(sp)
56         sw      $27, PT_R27(sp)
57         sw      $28, PT_R28(sp)
58         sw      $29, PT_R29(sp)
59         sw      $30, PT_R30(sp)
60         sw      $31, PT_R31(sp)
61         mfc0    k0, CP0_STATUS
62         sw      k0, 0x20(sp)
63         mfc0    k0, CP0_CONTEXT
64         sw      k0, 0x1c(sp)
65         mfc0    k0, CP0_PAGEMASK
66         sw      k0, 0x18(sp)
67         mfc0    k0, CP0_CONFIG
68         sw      k0, 0x14(sp)
69
70         /* Now set up the scratch registers so the boot rom will
71          * return to this point upon wakeup.
72          */
73         la      k0, 1f
74         lui     k1, 0xb190
75         ori     k1, 0x18
76         sw      sp, 0(k1)
77         ori     k1, 0x1c
78         sw      k0, 0(k1)
79
80 /* Put SDRAM into self refresh.  Preload instructions into cache,
81  * issue a precharge, then auto refresh, then sleep commands to it.
82  */
83         la      t0, sdsleep
84         .set    mips3
85         cache   0x14, 0(t0)
86         cache   0x14, 32(t0)
87         cache   0x14, 64(t0)
88         cache   0x14, 96(t0)
89         .set    mips0
90
91 sdsleep:
92         lui     k0, 0xb400
93         sw      zero, 0x001c(k0)        /* Precharge */
94         sw      zero, 0x0020(k0)        /* Auto refresh */
95         sw      zero, 0x0030(k0)        /* SDRAM sleep */
96         sync
97
98         lui     k1, 0xb190
99         sw      zero, 0x0078(k1)        /* get ready  to sleep */
100         sync
101         sw      zero, 0x007c(k1)        /* Put processor to sleep */
102         sync
103
104         /* This is where we return upon wakeup.
105          * Reload all of the registers and return.
106          */
107 1:      nop
108         lw      k0, 0x20(sp)
109         mtc0    k0, CP0_STATUS
110         lw      k0, 0x1c(sp)
111         mtc0    k0, CP0_CONTEXT
112         lw      k0, 0x18(sp)
113         mtc0    k0, CP0_PAGEMASK
114         lw      k0, 0x14(sp)
115         mtc0    k0, CP0_CONFIG
116         lw      $1, PT_R1(sp)
117         lw      $2, PT_R2(sp)
118         lw      $3, PT_R3(sp)
119         lw      $4, PT_R4(sp)
120         lw      $5, PT_R5(sp)
121         lw      $6, PT_R6(sp)
122         lw      $7, PT_R7(sp)
123         lw      $8, PT_R8(sp)
124         lw      $9, PT_R9(sp)
125         lw      $10, PT_R10(sp)
126         lw      $11, PT_R11(sp)
127         lw      $12, PT_R12(sp)
128         lw      $13, PT_R13(sp)
129         lw      $14, PT_R14(sp)
130         lw      $15, PT_R15(sp)
131         lw      $16, PT_R16(sp)
132         lw      $17, PT_R17(sp)
133         lw      $18, PT_R18(sp)
134         lw      $19, PT_R19(sp)
135         lw      $20, PT_R20(sp)
136         lw      $21, PT_R21(sp)
137         lw      $22, PT_R22(sp)
138         lw      $23, PT_R23(sp)
139         lw      $24, PT_R24(sp)
140         lw      $25, PT_R25(sp)
141         lw      $26, PT_R26(sp)
142         lw      $27, PT_R27(sp)
143         lw      $28, PT_R28(sp)
144         lw      $29, PT_R29(sp)
145         lw      $30, PT_R30(sp)
146         lw      $31, PT_R31(sp)
147         addiu   sp, PT_SIZE
148
149         jr      ra
150 END(save_and_sleep)