blob: b7981d31c39212b42ea0d1ce56017e9a1867cb43 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Michael Hennerich14b03202008-05-07 11:41:26 +08002 * Copyright 2004-2008 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Michael Hennerich14b03202008-05-07 11:41:26 +08004 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07005 */
6
7#include <linux/linkage.h>
8#include <asm/blackfin.h>
9#include <asm/mach/irq.h>
10
Bryan Wu1394f032007-05-06 14:50:22 -070011
12.section .l1.text
13
14ENTRY(_sleep_mode)
15 [--SP] = ( R7:0, P5:0 );
16 [--SP] = RETS;
17
18 call _set_sic_iwr;
19
20 R0 = 0xFFFF (Z);
Michael Hennerich4521ef42008-01-11 17:21:41 +080021 call _set_rtc_istat;
Bryan Wu1394f032007-05-06 14:50:22 -070022
23 P0.H = hi(PLL_CTL);
24 P0.L = lo(PLL_CTL);
25 R1 = W[P0](z);
26 BITSET (R1, 3);
27 W[P0] = R1.L;
28
29 CLI R2;
30 SSYNC;
31 IDLE;
32 STI R2;
33
34 call _test_pll_locked;
35
36 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +080037 R1 = IWR_DISABLE_ALL;
38 R2 = IWR_DISABLE_ALL;
39
Bryan Wu1394f032007-05-06 14:50:22 -070040 call _set_sic_iwr;
41
42 P0.H = hi(PLL_CTL);
43 P0.L = lo(PLL_CTL);
44 R7 = w[p0](z);
45 BITCLR (R7, 3);
46 BITCLR (R7, 5);
47 w[p0] = R7.L;
48 IDLE;
49 call _test_pll_locked;
50
51 RETS = [SP++];
52 ( R7:0, P5:0 ) = [SP++];
53 RTS;
54
55ENTRY(_hibernate_mode)
56 [--SP] = ( R7:0, P5:0 );
57 [--SP] = RETS;
58
59 call _set_sic_iwr;
60
61 R0 = 0xFFFF (Z);
Michael Hennerich4521ef42008-01-11 17:21:41 +080062 call _set_rtc_istat;
Bryan Wu1394f032007-05-06 14:50:22 -070063
64 P0.H = hi(VR_CTL);
65 P0.L = lo(VR_CTL);
66 R1 = W[P0](z);
67 BITSET (R1, 8);
68 BITCLR (R1, 0);
69 BITCLR (R1, 1);
70 W[P0] = R1.L;
71 SSYNC;
72
73 CLI R2;
74 IDLE;
75
76 /* Actually, adding anything may not be necessary...SDRAM contents
77 * are lost
78 */
79
80ENTRY(_deep_sleep)
81 [--SP] = ( R7:0, P5:0 );
82 [--SP] = RETS;
83
84 CLI R4;
85
Michael Hennerichcfefe3c2008-02-09 04:12:37 +080086 R0 = IWR_ENABLE(0);
87 R1 = IWR_DISABLE_ALL;
88 R2 = IWR_DISABLE_ALL;
89
Bryan Wu1394f032007-05-06 14:50:22 -070090 call _set_sic_iwr;
91
Sonic Zhangfb5f0042007-12-23 23:02:13 +080092 call _set_dram_srfs;
Bryan Wu1394f032007-05-06 14:50:22 -070093
94 /* Clear all the interrupts,bits sticky */
95 R0 = 0xFFFF (Z);
96 call _set_rtc_istat
97
98 P0.H = hi(PLL_CTL);
99 P0.L = lo(PLL_CTL);
100 R0 = W[P0](z);
101 BITSET (R0, 5);
102 W[P0] = R0.L;
103
104 call _test_pll_locked;
105
106 SSYNC;
107 IDLE;
108
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800109 call _unset_dram_srfs;
Bryan Wu1394f032007-05-06 14:50:22 -0700110
111 call _test_pll_locked;
112
113 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800114 R1 = IWR_DISABLE_ALL;
115 R2 = IWR_DISABLE_ALL;
116
Bryan Wu1394f032007-05-06 14:50:22 -0700117 call _set_sic_iwr;
118
119 P0.H = hi(PLL_CTL);
120 P0.L = lo(PLL_CTL);
121 R0 = w[p0](z);
122 BITCLR (R0, 3);
123 BITCLR (R0, 5);
124 BITCLR (R0, 8);
125 w[p0] = R0;
126 IDLE;
127 call _test_pll_locked;
128
129 STI R4;
130
131 RETS = [SP++];
132 ( R7:0, P5:0 ) = [SP++];
133 RTS;
134
135ENTRY(_sleep_deeper)
136 [--SP] = ( R7:0, P5:0 );
137 [--SP] = RETS;
138
139 CLI R4;
140
141 P3 = R0;
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800142 P4 = R1;
143 P5 = R2;
144
Bryan Wu1394f032007-05-06 14:50:22 -0700145 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800146 R1 = IWR_DISABLE_ALL;
147 R2 = IWR_DISABLE_ALL;
148
Bryan Wu1394f032007-05-06 14:50:22 -0700149 call _set_sic_iwr;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800150 call _set_dram_srfs; /* Set SDRAM Self Refresh */
Bryan Wu1394f032007-05-06 14:50:22 -0700151
152 /* Clear all the interrupts,bits sticky */
153 R0 = 0xFFFF (Z);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800154 call _set_rtc_istat;
Bryan Wu1394f032007-05-06 14:50:22 -0700155 P0.H = hi(PLL_DIV);
156 P0.L = lo(PLL_DIV);
157 R6 = W[P0](z);
158 R0.L = 0xF;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800159 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
Bryan Wu1394f032007-05-06 14:50:22 -0700160
161 P0.H = hi(PLL_CTL);
162 P0.L = lo(PLL_CTL);
163 R5 = W[P0](z);
Robin Getzf16295e2007-08-03 18:07:17 +0800164 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800165 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
Bryan Wu1394f032007-05-06 14:50:22 -0700166
167 SSYNC;
168 IDLE;
169
170 call _test_pll_locked;
171
172 P0.H = hi(VR_CTL);
173 P0.L = lo(VR_CTL);
174 R7 = W[P0](z);
175 R1 = 0x6;
176 R1 <<= 16;
177 R2 = 0x0404(Z);
178 R1 = R1|R2;
179
180 R2 = DEPOSIT(R7, R1);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800181 W[P0] = R2; /* Set Min Core Voltage */
Bryan Wu1394f032007-05-06 14:50:22 -0700182
183 SSYNC;
184 IDLE;
185
186 call _test_pll_locked;
187
Michael Hennerich4521ef42008-01-11 17:21:41 +0800188 R0 = P3;
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800189 R1 = P4;
190 R3 = P5;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800191 call _set_sic_iwr; /* Set Awake from IDLE */
192
Bryan Wu1394f032007-05-06 14:50:22 -0700193 P0.H = hi(PLL_CTL);
194 P0.L = lo(PLL_CTL);
195 R0 = W[P0](z);
196 BITSET (R0, 3);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800197 W[P0] = R0.L; /* Turn CCLK OFF */
Bryan Wu1394f032007-05-06 14:50:22 -0700198 SSYNC;
199 IDLE;
200
201 call _test_pll_locked;
202
203 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800204 R1 = IWR_DISABLE_ALL;
205 R2 = IWR_DISABLE_ALL;
206
Michael Hennerich4521ef42008-01-11 17:21:41 +0800207 call _set_sic_iwr; /* Set Awake from IDLE PLL */
Bryan Wu1394f032007-05-06 14:50:22 -0700208
209 P0.H = hi(VR_CTL);
210 P0.L = lo(VR_CTL);
211 W[P0]= R7;
212
213 SSYNC;
214 IDLE;
215
216 call _test_pll_locked;
217
218 P0.H = hi(PLL_DIV);
219 P0.L = lo(PLL_DIV);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800220 W[P0]= R6; /* Restore CCLK and SCLK divider */
Bryan Wu1394f032007-05-06 14:50:22 -0700221
222 P0.H = hi(PLL_CTL);
223 P0.L = lo(PLL_CTL);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800224 w[p0] = R5; /* Restore VCO multiplier */
Bryan Wu1394f032007-05-06 14:50:22 -0700225 IDLE;
226 call _test_pll_locked;
227
Michael Hennerich4521ef42008-01-11 17:21:41 +0800228 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
Bryan Wu1394f032007-05-06 14:50:22 -0700229
230 STI R4;
231
232 RETS = [SP++];
233 ( R7:0, P5:0 ) = [SP++];
234 RTS;
235
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800236ENTRY(_set_dram_srfs)
237 /* set the dram to self refresh mode */
238#if defined(CONFIG_BF54x)
239 P0.H = hi(EBIU_RSTCTL);
240 P0.L = lo(EBIU_RSTCTL);
241 R2 = [P0];
242 R3.H = hi(SRREQ);
243 R3.L = lo(SRREQ);
244#else
Bryan Wu1394f032007-05-06 14:50:22 -0700245 P0.H = hi(EBIU_SDGCTL);
246 P0.L = lo(EBIU_SDGCTL);
247 R2 = [P0];
248 R3.H = hi(SRFS);
249 R3.L = lo(SRFS);
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800250#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700251 R2 = R2|R3;
252 [P0] = R2;
253 ssync;
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800254#if defined(CONFIG_BF54x)
255.LSRR_MODE:
256 R2 = [P0];
257 CC = BITTST(R2, 4);
258 if !CC JUMP .LSRR_MODE;
259#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700260 RTS;
261
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800262ENTRY(_unset_dram_srfs)
263 /* set the dram out of self refresh mode */
264#if defined(CONFIG_BF54x)
265 P0.H = hi(EBIU_RSTCTL);
266 P0.L = lo(EBIU_RSTCTL);
267 R2 = [P0];
268 R3.H = hi(SRREQ);
269 R3.L = lo(SRREQ);
270#else
Bryan Wu1394f032007-05-06 14:50:22 -0700271 P0.H = hi(EBIU_SDGCTL);
272 P0.L = lo(EBIU_SDGCTL);
273 R2 = [P0];
274 R3.H = hi(SRFS);
275 R3.L = lo(SRFS);
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800276#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700277 R3 = ~R3;
278 R2 = R2&R3;
279 [P0] = R2;
280 ssync;
281 RTS;
282
283ENTRY(_set_sic_iwr)
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800284#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800285 P0.H = hi(SIC_IWR0);
286 P0.L = lo(SIC_IWR0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800287 P1.H = hi(SIC_IWR1);
288 P1.L = lo(SIC_IWR1);
289 [P1] = R1;
290#if defined(CONFIG_BF54x)
291 P1.H = hi(SIC_IWR2);
292 P1.L = lo(SIC_IWR2);
293 [P1] = R2;
294#endif
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800295#else
Bryan Wu1394f032007-05-06 14:50:22 -0700296 P0.H = hi(SIC_IWR);
297 P0.L = lo(SIC_IWR);
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800298#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700299 [P0] = R0;
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800300
Bryan Wu1394f032007-05-06 14:50:22 -0700301 SSYNC;
302 RTS;
303
304ENTRY(_set_rtc_istat)
Michael Hennerich39278192008-02-25 14:39:50 +0800305#ifndef CONFIG_BF561
Bryan Wu1394f032007-05-06 14:50:22 -0700306 P0.H = hi(RTC_ISTAT);
307 P0.L = lo(RTC_ISTAT);
308 w[P0] = R0.L;
309 SSYNC;
Michael Hennerich39278192008-02-25 14:39:50 +0800310#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700311 RTS;
312
313ENTRY(_test_pll_locked)
314 P0.H = hi(PLL_STAT);
315 P0.L = lo(PLL_STAT);
3161:
317 R0 = W[P0] (Z);
318 CC = BITTST(R0,5);
319 IF !CC JUMP 1b;
320 RTS;