blob: fc9f6eb9018bfed83359d726a479f5bddc5dbd86 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
2 * File: arch/blackfin/mach-common/dpmc.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created: ?
7 * Description: Watchdog Timer APIs
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/blackfin.h>
32#include <asm/mach/irq.h>
33
34.text
35
Bryan Wu1394f032007-05-06 14:50:22 -070036#if !defined(CONFIG_BF561)
37
38.section .l1.text
39
40ENTRY(_sleep_mode)
41 [--SP] = ( R7:0, P5:0 );
42 [--SP] = RETS;
43
44 call _set_sic_iwr;
45
46 R0 = 0xFFFF (Z);
Michael Hennerich4521ef42008-01-11 17:21:41 +080047 call _set_rtc_istat;
Bryan Wu1394f032007-05-06 14:50:22 -070048
49 P0.H = hi(PLL_CTL);
50 P0.L = lo(PLL_CTL);
51 R1 = W[P0](z);
52 BITSET (R1, 3);
53 W[P0] = R1.L;
54
55 CLI R2;
56 SSYNC;
57 IDLE;
58 STI R2;
59
60 call _test_pll_locked;
61
62 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +080063 R1 = IWR_DISABLE_ALL;
64 R2 = IWR_DISABLE_ALL;
65
Bryan Wu1394f032007-05-06 14:50:22 -070066 call _set_sic_iwr;
67
68 P0.H = hi(PLL_CTL);
69 P0.L = lo(PLL_CTL);
70 R7 = w[p0](z);
71 BITCLR (R7, 3);
72 BITCLR (R7, 5);
73 w[p0] = R7.L;
74 IDLE;
75 call _test_pll_locked;
76
77 RETS = [SP++];
78 ( R7:0, P5:0 ) = [SP++];
79 RTS;
80
81ENTRY(_hibernate_mode)
82 [--SP] = ( R7:0, P5:0 );
83 [--SP] = RETS;
84
85 call _set_sic_iwr;
86
87 R0 = 0xFFFF (Z);
Michael Hennerich4521ef42008-01-11 17:21:41 +080088 call _set_rtc_istat;
Bryan Wu1394f032007-05-06 14:50:22 -070089
90 P0.H = hi(VR_CTL);
91 P0.L = lo(VR_CTL);
92 R1 = W[P0](z);
93 BITSET (R1, 8);
94 BITCLR (R1, 0);
95 BITCLR (R1, 1);
96 W[P0] = R1.L;
97 SSYNC;
98
99 CLI R2;
100 IDLE;
101
102 /* Actually, adding anything may not be necessary...SDRAM contents
103 * are lost
104 */
105
106ENTRY(_deep_sleep)
107 [--SP] = ( R7:0, P5:0 );
108 [--SP] = RETS;
109
110 CLI R4;
111
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800112 R0 = IWR_ENABLE(0);
113 R1 = IWR_DISABLE_ALL;
114 R2 = IWR_DISABLE_ALL;
115
Bryan Wu1394f032007-05-06 14:50:22 -0700116 call _set_sic_iwr;
117
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800118 call _set_dram_srfs;
Bryan Wu1394f032007-05-06 14:50:22 -0700119
120 /* Clear all the interrupts,bits sticky */
121 R0 = 0xFFFF (Z);
122 call _set_rtc_istat
123
124 P0.H = hi(PLL_CTL);
125 P0.L = lo(PLL_CTL);
126 R0 = W[P0](z);
127 BITSET (R0, 5);
128 W[P0] = R0.L;
129
130 call _test_pll_locked;
131
132 SSYNC;
133 IDLE;
134
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800135 call _unset_dram_srfs;
Bryan Wu1394f032007-05-06 14:50:22 -0700136
137 call _test_pll_locked;
138
139 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800140 R1 = IWR_DISABLE_ALL;
141 R2 = IWR_DISABLE_ALL;
142
Bryan Wu1394f032007-05-06 14:50:22 -0700143 call _set_sic_iwr;
144
145 P0.H = hi(PLL_CTL);
146 P0.L = lo(PLL_CTL);
147 R0 = w[p0](z);
148 BITCLR (R0, 3);
149 BITCLR (R0, 5);
150 BITCLR (R0, 8);
151 w[p0] = R0;
152 IDLE;
153 call _test_pll_locked;
154
155 STI R4;
156
157 RETS = [SP++];
158 ( R7:0, P5:0 ) = [SP++];
159 RTS;
160
161ENTRY(_sleep_deeper)
162 [--SP] = ( R7:0, P5:0 );
163 [--SP] = RETS;
164
165 CLI R4;
166
167 P3 = R0;
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800168 P4 = R1;
169 P5 = R2;
170
Bryan Wu1394f032007-05-06 14:50:22 -0700171 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800172 R1 = IWR_DISABLE_ALL;
173 R2 = IWR_DISABLE_ALL;
174
Bryan Wu1394f032007-05-06 14:50:22 -0700175 call _set_sic_iwr;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800176 call _set_dram_srfs; /* Set SDRAM Self Refresh */
Bryan Wu1394f032007-05-06 14:50:22 -0700177
178 /* Clear all the interrupts,bits sticky */
179 R0 = 0xFFFF (Z);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800180 call _set_rtc_istat;
Bryan Wu1394f032007-05-06 14:50:22 -0700181 P0.H = hi(PLL_DIV);
182 P0.L = lo(PLL_DIV);
183 R6 = W[P0](z);
184 R0.L = 0xF;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800185 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
Bryan Wu1394f032007-05-06 14:50:22 -0700186
187 P0.H = hi(PLL_CTL);
188 P0.L = lo(PLL_CTL);
189 R5 = W[P0](z);
Robin Getzf16295e2007-08-03 18:07:17 +0800190 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800191 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
Bryan Wu1394f032007-05-06 14:50:22 -0700192
193 SSYNC;
194 IDLE;
195
196 call _test_pll_locked;
197
198 P0.H = hi(VR_CTL);
199 P0.L = lo(VR_CTL);
200 R7 = W[P0](z);
201 R1 = 0x6;
202 R1 <<= 16;
203 R2 = 0x0404(Z);
204 R1 = R1|R2;
205
206 R2 = DEPOSIT(R7, R1);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800207 W[P0] = R2; /* Set Min Core Voltage */
Bryan Wu1394f032007-05-06 14:50:22 -0700208
209 SSYNC;
210 IDLE;
211
212 call _test_pll_locked;
213
Michael Hennerich4521ef42008-01-11 17:21:41 +0800214 R0 = P3;
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800215 R1 = P4;
216 R3 = P5;
Michael Hennerich4521ef42008-01-11 17:21:41 +0800217 call _set_sic_iwr; /* Set Awake from IDLE */
218
Bryan Wu1394f032007-05-06 14:50:22 -0700219 P0.H = hi(PLL_CTL);
220 P0.L = lo(PLL_CTL);
221 R0 = W[P0](z);
222 BITSET (R0, 3);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800223 W[P0] = R0.L; /* Turn CCLK OFF */
Bryan Wu1394f032007-05-06 14:50:22 -0700224 SSYNC;
225 IDLE;
226
227 call _test_pll_locked;
228
229 R0 = IWR_ENABLE(0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800230 R1 = IWR_DISABLE_ALL;
231 R2 = IWR_DISABLE_ALL;
232
Michael Hennerich4521ef42008-01-11 17:21:41 +0800233 call _set_sic_iwr; /* Set Awake from IDLE PLL */
Bryan Wu1394f032007-05-06 14:50:22 -0700234
235 P0.H = hi(VR_CTL);
236 P0.L = lo(VR_CTL);
237 W[P0]= R7;
238
239 SSYNC;
240 IDLE;
241
242 call _test_pll_locked;
243
244 P0.H = hi(PLL_DIV);
245 P0.L = lo(PLL_DIV);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800246 W[P0]= R6; /* Restore CCLK and SCLK divider */
Bryan Wu1394f032007-05-06 14:50:22 -0700247
248 P0.H = hi(PLL_CTL);
249 P0.L = lo(PLL_CTL);
Michael Hennerich4521ef42008-01-11 17:21:41 +0800250 w[p0] = R5; /* Restore VCO multiplier */
Bryan Wu1394f032007-05-06 14:50:22 -0700251 IDLE;
252 call _test_pll_locked;
253
Michael Hennerich4521ef42008-01-11 17:21:41 +0800254 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
Bryan Wu1394f032007-05-06 14:50:22 -0700255
256 STI R4;
257
258 RETS = [SP++];
259 ( R7:0, P5:0 ) = [SP++];
260 RTS;
261
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800262ENTRY(_set_dram_srfs)
263 /* set the dram to 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 R2 = R2|R3;
278 [P0] = R2;
279 ssync;
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800280#if defined(CONFIG_BF54x)
281.LSRR_MODE:
282 R2 = [P0];
283 CC = BITTST(R2, 4);
284 if !CC JUMP .LSRR_MODE;
285#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700286 RTS;
287
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800288ENTRY(_unset_dram_srfs)
289 /* set the dram out of self refresh mode */
290#if defined(CONFIG_BF54x)
291 P0.H = hi(EBIU_RSTCTL);
292 P0.L = lo(EBIU_RSTCTL);
293 R2 = [P0];
294 R3.H = hi(SRREQ);
295 R3.L = lo(SRREQ);
296#else
Bryan Wu1394f032007-05-06 14:50:22 -0700297 P0.H = hi(EBIU_SDGCTL);
298 P0.L = lo(EBIU_SDGCTL);
299 R2 = [P0];
300 R3.H = hi(SRFS);
301 R3.L = lo(SRFS);
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800302#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700303 R3 = ~R3;
304 R2 = R2&R3;
305 [P0] = R2;
306 ssync;
307 RTS;
308
309ENTRY(_set_sic_iwr)
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800310#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800311 P0.H = hi(SIC_IWR0);
312 P0.L = lo(SIC_IWR0);
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800313 P1.H = hi(SIC_IWR1);
314 P1.L = lo(SIC_IWR1);
315 [P1] = R1;
316#if defined(CONFIG_BF54x)
317 P1.H = hi(SIC_IWR2);
318 P1.L = lo(SIC_IWR2);
319 [P1] = R2;
320#endif
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800321#else
Bryan Wu1394f032007-05-06 14:50:22 -0700322 P0.H = hi(SIC_IWR);
323 P0.L = lo(SIC_IWR);
Sonic Zhangfb5f0042007-12-23 23:02:13 +0800324#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700325 [P0] = R0;
Michael Hennerichcfefe3c2008-02-09 04:12:37 +0800326
Bryan Wu1394f032007-05-06 14:50:22 -0700327 SSYNC;
328 RTS;
329
330ENTRY(_set_rtc_istat)
331 P0.H = hi(RTC_ISTAT);
332 P0.L = lo(RTC_ISTAT);
333 w[P0] = R0.L;
334 SSYNC;
335 RTS;
336
337ENTRY(_test_pll_locked)
338 P0.H = hi(PLL_STAT);
339 P0.L = lo(PLL_STAT);
3401:
341 R0 = W[P0] (Z);
342 CC = BITTST(R0,5);
343 IF !CC JUMP 1b;
344 RTS;
345#endif