Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6] / arch / blackfin / mach-common / dpmc_modes.S
1 /*
2  * Copyright 2004-2008 Analog Devices Inc.
3  *
4  * Licensed under the GPL-2 or later.
5  */
6
7 #include <linux/linkage.h>
8 #include <asm/blackfin.h>
9 #include <mach/irq.h>
10 #include <asm/dpmc.h>
11
12 .section .l1.text
13
14 ENTRY(_sleep_mode)
15         [--SP] = ( R7:0, P5:0 );
16         [--SP] =  RETS;
17
18         call _set_sic_iwr;
19
20         R0 = 0xFFFF (Z);
21         call _set_rtc_istat;
22
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);
37         R1 = IWR_DISABLE_ALL;
38         R2 = IWR_DISABLE_ALL;
39
40         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 ENDPROC(_sleep_mode)
55
56 ENTRY(_hibernate_mode)
57         [--SP] = ( R7:0, P5:0 );
58         [--SP] =  RETS;
59
60         R3 = R0;
61         R0 = IWR_DISABLE_ALL;
62         R1 = IWR_DISABLE_ALL;
63         R2 = IWR_DISABLE_ALL;
64         call _set_sic_iwr;
65         call _set_dram_srfs;
66         SSYNC;
67
68         R0 = 0xFFFF (Z);
69         call _set_rtc_istat;
70
71         P0.H = hi(VR_CTL);
72         P0.L = lo(VR_CTL);
73
74         W[P0] = R3.L;
75         CLI R2;
76         IDLE;
77 .Lforever:
78         jump .Lforever;
79 ENDPROC(_hibernate_mode)
80
81 ENTRY(_sleep_deeper)
82         [--SP] = ( R7:0, P5:0 );
83         [--SP] =  RETS;
84
85         CLI R4;
86
87         P3 = R0;
88         P4 = R1;
89         P5 = R2;
90
91         R0 = IWR_ENABLE(0);
92         R1 = IWR_DISABLE_ALL;
93         R2 = IWR_DISABLE_ALL;
94
95         call _set_sic_iwr;
96         call _set_dram_srfs;    /* Set SDRAM Self Refresh */
97
98         /* Clear all the interrupts,bits sticky */
99         R0 = 0xFFFF (Z);
100         call _set_rtc_istat;
101         P0.H = hi(PLL_DIV);
102         P0.L = lo(PLL_DIV);
103         R6 = W[P0](z);
104         R0.L = 0xF;
105         W[P0] = R0.l;           /* Set Max VCO to SCLK divider */
106
107         P0.H = hi(PLL_CTL);
108         P0.L = lo(PLL_CTL);
109         R5 = W[P0](z);
110         R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
111         W[P0] = R0.l;           /* Set Min CLKIN to VCO multiplier */
112
113         SSYNC;
114         IDLE;
115
116         call _test_pll_locked;
117
118         P0.H = hi(VR_CTL);
119         P0.L = lo(VR_CTL);
120         R7 = W[P0](z);
121         R1 = 0x6;
122         R1 <<= 16;
123         R2 = 0x0404(Z);
124         R1 = R1|R2;
125
126         R2 = DEPOSIT(R7, R1);
127         W[P0] = R2;             /* Set Min Core Voltage */
128
129         SSYNC;
130         IDLE;
131
132         call _test_pll_locked;
133
134         R0 = P3;
135         R1 = P4;
136         R3 = P5;
137         call _set_sic_iwr;      /* Set Awake from IDLE */
138
139         P0.H = hi(PLL_CTL);
140         P0.L = lo(PLL_CTL);
141         R0 = W[P0](z);
142         BITSET (R0, 3);
143         W[P0] = R0.L;           /* Turn CCLK OFF */
144         SSYNC;
145         IDLE;
146
147         call _test_pll_locked;
148
149         R0 = IWR_ENABLE(0);
150         R1 = IWR_DISABLE_ALL;
151         R2 = IWR_DISABLE_ALL;
152
153         call _set_sic_iwr;      /* Set Awake from IDLE PLL */
154
155         P0.H = hi(VR_CTL);
156         P0.L = lo(VR_CTL);
157         W[P0]= R7;
158
159         SSYNC;
160         IDLE;
161
162         call _test_pll_locked;
163
164         P0.H = hi(PLL_DIV);
165         P0.L = lo(PLL_DIV);
166         W[P0]= R6;              /* Restore CCLK and SCLK divider */
167
168         P0.H = hi(PLL_CTL);
169         P0.L = lo(PLL_CTL);
170         w[p0] = R5;             /* Restore VCO multiplier */
171         IDLE;
172         call _test_pll_locked;
173
174         call _unset_dram_srfs;  /* SDRAM Self Refresh Off */
175
176         STI R4;
177
178         RETS = [SP++];
179         ( R7:0, P5:0 ) = [SP++];
180         RTS;
181 ENDPROC(_sleep_deeper)
182
183 ENTRY(_set_dram_srfs)
184         /*  set the dram to self refresh mode */
185         SSYNC;
186 #if defined(EBIU_RSTCTL)        /* DDR */
187         P0.H = hi(EBIU_RSTCTL);
188         P0.L = lo(EBIU_RSTCTL);
189         R2 = [P0];
190         BITSET(R2, 3); /* SRREQ enter self-refresh mode */
191         [P0] = R2;
192         SSYNC;
193 1:
194         R2 = [P0];
195         CC = BITTST(R2, 4);
196         if !CC JUMP 1b;
197 #else                           /* SDRAM */
198         P0.L = lo(EBIU_SDGCTL);
199         P0.H = hi(EBIU_SDGCTL);
200         R2 = [P0];
201         BITSET(R2, 24); /* SRFS enter self-refresh mode */
202         [P0] = R2;
203         SSYNC;
204
205         P0.L = lo(EBIU_SDSTAT);
206         P0.H = hi(EBIU_SDSTAT);
207 1:
208         R2 = w[P0];
209         SSYNC;
210         cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
211         if !cc jump 1b;
212
213         P0.L = lo(EBIU_SDGCTL);
214         P0.H = hi(EBIU_SDGCTL);
215         R2 = [P0];
216         BITCLR(R2, 0); /* SCTLE disable CLKOUT */
217         [P0] = R2;
218 #endif
219         RTS;
220 ENDPROC(_set_dram_srfs)
221
222 ENTRY(_unset_dram_srfs)
223         /*  set the dram out of self refresh mode */
224 #if defined(EBIU_RSTCTL)        /* DDR */
225         P0.H = hi(EBIU_RSTCTL);
226         P0.L = lo(EBIU_RSTCTL);
227         R2 = [P0];
228         BITCLR(R2, 3); /* clear SRREQ bit */
229         [P0] = R2;
230 #elif defined(EBIU_SDGCTL)      /* SDRAM */
231
232         P0.L = lo(EBIU_SDGCTL); /* release CLKOUT from self-refresh */
233         P0.H = hi(EBIU_SDGCTL);
234         R2 = [P0];
235         BITSET(R2, 0); /* SCTLE enable CLKOUT */
236         [P0] = R2
237         SSYNC;
238
239         P0.L = lo(EBIU_SDGCTL); /* release SDRAM from self-refresh */
240         P0.H = hi(EBIU_SDGCTL);
241         R2 = [P0];
242         BITCLR(R2, 24); /* clear SRFS bit */
243         [P0] = R2
244 #endif
245         SSYNC;
246         RTS;
247 ENDPROC(_unset_dram_srfs)
248
249 ENTRY(_set_sic_iwr)
250 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) || \
251         defined(CONFIG_BF538) || defined(CONFIG_BF539) || defined(CONFIG_BF51x)
252         P0.H = hi(SIC_IWR0);
253         P0.L = lo(SIC_IWR0);
254         P1.H = hi(SIC_IWR1);
255         P1.L = lo(SIC_IWR1);
256         [P1] = R1;
257 #if defined(CONFIG_BF54x)
258         P1.H = hi(SIC_IWR2);
259         P1.L = lo(SIC_IWR2);
260         [P1] = R2;
261 #endif
262 #else
263         P0.H = hi(SIC_IWR);
264         P0.L = lo(SIC_IWR);
265 #endif
266         [P0] = R0;
267
268         SSYNC;
269         RTS;
270 ENDPROC(_set_sic_iwr)
271
272 ENTRY(_set_rtc_istat)
273 #ifndef CONFIG_BF561
274         P0.H = hi(RTC_ISTAT);
275         P0.L = lo(RTC_ISTAT);
276         w[P0] = R0.L;
277         SSYNC;
278 #elif (ANOMALY_05000371)
279         nop;
280         nop;
281         nop;
282         nop;
283 #endif
284         RTS;
285 ENDPROC(_set_rtc_istat)
286
287 ENTRY(_test_pll_locked)
288         P0.H = hi(PLL_STAT);
289         P0.L = lo(PLL_STAT);
290 1:
291         R0 = W[P0] (Z);
292         CC = BITTST(R0,5);
293         IF !CC JUMP 1b;
294         RTS;
295 ENDPROC(_test_pll_locked)
296
297 .section .text
298
299 ENTRY(_do_hibernate)
300         [--SP] = ( R7:0, P5:0 );
301         [--SP] =  RETS;
302         /* Save System MMRs */
303         R2 = R0;
304         P0.H = hi(PLL_CTL);
305         P0.L = lo(PLL_CTL);
306
307 #ifdef SIC_IMASK0
308         PM_SYS_PUSH(SIC_IMASK0)
309 #endif
310 #ifdef SIC_IMASK1
311         PM_SYS_PUSH(SIC_IMASK1)
312 #endif
313 #ifdef SIC_IMASK2
314         PM_SYS_PUSH(SIC_IMASK2)
315 #endif
316 #ifdef SIC_IMASK
317         PM_SYS_PUSH(SIC_IMASK)
318 #endif
319 #ifdef SICA_IMASK0
320         PM_SYS_PUSH(SICA_IMASK0)
321 #endif
322 #ifdef SICA_IMASK1
323         PM_SYS_PUSH(SICA_IMASK1)
324 #endif
325 #ifdef SIC_IAR2
326         PM_SYS_PUSH(SIC_IAR0)
327         PM_SYS_PUSH(SIC_IAR1)
328         PM_SYS_PUSH(SIC_IAR2)
329 #endif
330 #ifdef SIC_IAR3
331         PM_SYS_PUSH(SIC_IAR3)
332 #endif
333 #ifdef SIC_IAR4
334         PM_SYS_PUSH(SIC_IAR4)
335         PM_SYS_PUSH(SIC_IAR5)
336         PM_SYS_PUSH(SIC_IAR6)
337 #endif
338 #ifdef SIC_IAR7
339         PM_SYS_PUSH(SIC_IAR7)
340 #endif
341 #ifdef SIC_IAR8
342         PM_SYS_PUSH(SIC_IAR8)
343         PM_SYS_PUSH(SIC_IAR9)
344         PM_SYS_PUSH(SIC_IAR10)
345         PM_SYS_PUSH(SIC_IAR11)
346 #endif
347
348 #ifdef SICA_IAR0
349         PM_SYS_PUSH(SICA_IAR0)
350         PM_SYS_PUSH(SICA_IAR1)
351         PM_SYS_PUSH(SICA_IAR2)
352         PM_SYS_PUSH(SICA_IAR3)
353         PM_SYS_PUSH(SICA_IAR4)
354         PM_SYS_PUSH(SICA_IAR5)
355         PM_SYS_PUSH(SICA_IAR6)
356         PM_SYS_PUSH(SICA_IAR7)
357 #endif
358
359 #ifdef SIC_IWR
360         PM_SYS_PUSH(SIC_IWR)
361 #endif
362 #ifdef SIC_IWR0
363         PM_SYS_PUSH(SIC_IWR0)
364 #endif
365 #ifdef SIC_IWR1
366         PM_SYS_PUSH(SIC_IWR1)
367 #endif
368 #ifdef SIC_IWR2
369         PM_SYS_PUSH(SIC_IWR2)
370 #endif
371 #ifdef SICA_IWR0
372         PM_SYS_PUSH(SICA_IWR0)
373 #endif
374 #ifdef SICA_IWR1
375         PM_SYS_PUSH(SICA_IWR1)
376 #endif
377
378 #ifdef PINT0_ASSIGN
379         PM_SYS_PUSH(PINT0_MASK_SET)
380         PM_SYS_PUSH(PINT1_MASK_SET)
381         PM_SYS_PUSH(PINT2_MASK_SET)
382         PM_SYS_PUSH(PINT3_MASK_SET)
383         PM_SYS_PUSH(PINT0_ASSIGN)
384         PM_SYS_PUSH(PINT1_ASSIGN)
385         PM_SYS_PUSH(PINT2_ASSIGN)
386         PM_SYS_PUSH(PINT3_ASSIGN)
387         PM_SYS_PUSH(PINT0_INVERT_SET)
388         PM_SYS_PUSH(PINT1_INVERT_SET)
389         PM_SYS_PUSH(PINT2_INVERT_SET)
390         PM_SYS_PUSH(PINT3_INVERT_SET)
391         PM_SYS_PUSH(PINT0_EDGE_SET)
392         PM_SYS_PUSH(PINT1_EDGE_SET)
393         PM_SYS_PUSH(PINT2_EDGE_SET)
394         PM_SYS_PUSH(PINT3_EDGE_SET)
395 #endif
396
397         PM_SYS_PUSH(EBIU_AMBCTL0)
398         PM_SYS_PUSH(EBIU_AMBCTL1)
399         PM_SYS_PUSH16(EBIU_AMGCTL)
400
401 #ifdef EBIU_FCTL
402         PM_SYS_PUSH(EBIU_MBSCTL)
403         PM_SYS_PUSH(EBIU_MODE)
404         PM_SYS_PUSH(EBIU_FCTL)
405 #endif
406
407         PM_SYS_PUSH16(SYSCR)
408
409         /* Save Core MMRs */
410         P0.H = hi(SRAM_BASE_ADDRESS);
411         P0.L = lo(SRAM_BASE_ADDRESS);
412
413         PM_PUSH(DMEM_CONTROL)
414         PM_PUSH(DCPLB_ADDR0)
415         PM_PUSH(DCPLB_ADDR1)
416         PM_PUSH(DCPLB_ADDR2)
417         PM_PUSH(DCPLB_ADDR3)
418         PM_PUSH(DCPLB_ADDR4)
419         PM_PUSH(DCPLB_ADDR5)
420         PM_PUSH(DCPLB_ADDR6)
421         PM_PUSH(DCPLB_ADDR7)
422         PM_PUSH(DCPLB_ADDR8)
423         PM_PUSH(DCPLB_ADDR9)
424         PM_PUSH(DCPLB_ADDR10)
425         PM_PUSH(DCPLB_ADDR11)
426         PM_PUSH(DCPLB_ADDR12)
427         PM_PUSH(DCPLB_ADDR13)
428         PM_PUSH(DCPLB_ADDR14)
429         PM_PUSH(DCPLB_ADDR15)
430         PM_PUSH(DCPLB_DATA0)
431         PM_PUSH(DCPLB_DATA1)
432         PM_PUSH(DCPLB_DATA2)
433         PM_PUSH(DCPLB_DATA3)
434         PM_PUSH(DCPLB_DATA4)
435         PM_PUSH(DCPLB_DATA5)
436         PM_PUSH(DCPLB_DATA6)
437         PM_PUSH(DCPLB_DATA7)
438         PM_PUSH(DCPLB_DATA8)
439         PM_PUSH(DCPLB_DATA9)
440         PM_PUSH(DCPLB_DATA10)
441         PM_PUSH(DCPLB_DATA11)
442         PM_PUSH(DCPLB_DATA12)
443         PM_PUSH(DCPLB_DATA13)
444         PM_PUSH(DCPLB_DATA14)
445         PM_PUSH(DCPLB_DATA15)
446         PM_PUSH(IMEM_CONTROL)
447         PM_PUSH(ICPLB_ADDR0)
448         PM_PUSH(ICPLB_ADDR1)
449         PM_PUSH(ICPLB_ADDR2)
450         PM_PUSH(ICPLB_ADDR3)
451         PM_PUSH(ICPLB_ADDR4)
452         PM_PUSH(ICPLB_ADDR5)
453         PM_PUSH(ICPLB_ADDR6)
454         PM_PUSH(ICPLB_ADDR7)
455         PM_PUSH(ICPLB_ADDR8)
456         PM_PUSH(ICPLB_ADDR9)
457         PM_PUSH(ICPLB_ADDR10)
458         PM_PUSH(ICPLB_ADDR11)
459         PM_PUSH(ICPLB_ADDR12)
460         PM_PUSH(ICPLB_ADDR13)
461         PM_PUSH(ICPLB_ADDR14)
462         PM_PUSH(ICPLB_ADDR15)
463         PM_PUSH(ICPLB_DATA0)
464         PM_PUSH(ICPLB_DATA1)
465         PM_PUSH(ICPLB_DATA2)
466         PM_PUSH(ICPLB_DATA3)
467         PM_PUSH(ICPLB_DATA4)
468         PM_PUSH(ICPLB_DATA5)
469         PM_PUSH(ICPLB_DATA6)
470         PM_PUSH(ICPLB_DATA7)
471         PM_PUSH(ICPLB_DATA8)
472         PM_PUSH(ICPLB_DATA9)
473         PM_PUSH(ICPLB_DATA10)
474         PM_PUSH(ICPLB_DATA11)
475         PM_PUSH(ICPLB_DATA12)
476         PM_PUSH(ICPLB_DATA13)
477         PM_PUSH(ICPLB_DATA14)
478         PM_PUSH(ICPLB_DATA15)
479         PM_PUSH(EVT0)
480         PM_PUSH(EVT1)
481         PM_PUSH(EVT2)
482         PM_PUSH(EVT3)
483         PM_PUSH(EVT4)
484         PM_PUSH(EVT5)
485         PM_PUSH(EVT6)
486         PM_PUSH(EVT7)
487         PM_PUSH(EVT8)
488         PM_PUSH(EVT9)
489         PM_PUSH(EVT10)
490         PM_PUSH(EVT11)
491         PM_PUSH(EVT12)
492         PM_PUSH(EVT13)
493         PM_PUSH(EVT14)
494         PM_PUSH(EVT15)
495         PM_PUSH(IMASK)
496         PM_PUSH(ILAT)
497         PM_PUSH(IPRIO)
498         PM_PUSH(TCNTL)
499         PM_PUSH(TPERIOD)
500         PM_PUSH(TSCALE)
501         PM_PUSH(TCOUNT)
502         PM_PUSH(TBUFCTL)
503
504         /* Save Core Registers */
505         [--sp] = SYSCFG;
506         [--sp] = ( R7:0, P5:0 );
507         [--sp] = fp;
508         [--sp] = usp;
509
510         [--sp] = i0;
511         [--sp] = i1;
512         [--sp] = i2;
513         [--sp] = i3;
514
515         [--sp] = m0;
516         [--sp] = m1;
517         [--sp] = m2;
518         [--sp] = m3;
519
520         [--sp] = l0;
521         [--sp] = l1;
522         [--sp] = l2;
523         [--sp] = l3;
524
525         [--sp] = b0;
526         [--sp] = b1;
527         [--sp] = b2;
528         [--sp] = b3;
529         [--sp] = a0.x;
530         [--sp] = a0.w;
531         [--sp] = a1.x;
532         [--sp] = a1.w;
533
534         [--sp] = LC0;
535         [--sp] = LC1;
536         [--sp] = LT0;
537         [--sp] = LT1;
538         [--sp] = LB0;
539         [--sp] = LB1;
540
541         [--sp] = ASTAT;
542         [--sp] = CYCLES;
543         [--sp] = CYCLES2;
544
545         [--sp] = RETS;
546         r0 = RETI;
547         [--sp] = r0;
548         [--sp] = RETX;
549         [--sp] = RETN;
550         [--sp] = RETE;
551         [--sp] = SEQSTAT;
552
553         /* Save Magic, return address and Stack Pointer */
554         P0.H = 0;
555         P0.L = 0;
556         R0.H = 0xDEAD;  /* Hibernate Magic */
557         R0.L = 0xBEEF;
558         [P0++] = R0;    /* Store Hibernate Magic */
559         R0.H = .Lpm_resume_here;
560         R0.L = .Lpm_resume_here;
561         [P0++] = R0;    /* Save Return Address */
562         [P0++] = SP;    /* Save Stack Pointer */
563         P0.H = _hibernate_mode;
564         P0.L = _hibernate_mode;
565         R0 = R2;
566         call (P0); /* Goodbye */
567
568 .Lpm_resume_here:
569
570         /* Restore Core Registers */
571         SEQSTAT = [sp++];
572         RETE = [sp++];
573         RETN = [sp++];
574         RETX = [sp++];
575         r0 = [sp++];
576         RETI = r0;
577         RETS = [sp++];
578
579         CYCLES2 = [sp++];
580         CYCLES = [sp++];
581         ASTAT = [sp++];
582
583         LB1 = [sp++];
584         LB0 = [sp++];
585         LT1 = [sp++];
586         LT0 = [sp++];
587         LC1 = [sp++];
588         LC0 = [sp++];
589
590         a1.w = [sp++];
591         a1.x = [sp++];
592         a0.w = [sp++];
593         a0.x = [sp++];
594         b3 = [sp++];
595         b2 = [sp++];
596         b1 = [sp++];
597         b0 = [sp++];
598
599         l3 = [sp++];
600         l2 = [sp++];
601         l1 = [sp++];
602         l0 = [sp++];
603
604         m3 = [sp++];
605         m2 = [sp++];
606         m1 = [sp++];
607         m0 = [sp++];
608
609         i3 = [sp++];
610         i2 = [sp++];
611         i1 = [sp++];
612         i0 = [sp++];
613
614         usp = [sp++];
615         fp = [sp++];
616
617         ( R7 : 0, P5 : 0) = [ SP ++ ];
618         SYSCFG = [sp++];
619
620         /* Restore Core MMRs */
621
622         PM_POP(TBUFCTL)
623         PM_POP(TCOUNT)
624         PM_POP(TSCALE)
625         PM_POP(TPERIOD)
626         PM_POP(TCNTL)
627         PM_POP(IPRIO)
628         PM_POP(ILAT)
629         PM_POP(IMASK)
630         PM_POP(EVT15)
631         PM_POP(EVT14)
632         PM_POP(EVT13)
633         PM_POP(EVT12)
634         PM_POP(EVT11)
635         PM_POP(EVT10)
636         PM_POP(EVT9)
637         PM_POP(EVT8)
638         PM_POP(EVT7)
639         PM_POP(EVT6)
640         PM_POP(EVT5)
641         PM_POP(EVT4)
642         PM_POP(EVT3)
643         PM_POP(EVT2)
644         PM_POP(EVT1)
645         PM_POP(EVT0)
646         PM_POP(ICPLB_DATA15)
647         PM_POP(ICPLB_DATA14)
648         PM_POP(ICPLB_DATA13)
649         PM_POP(ICPLB_DATA12)
650         PM_POP(ICPLB_DATA11)
651         PM_POP(ICPLB_DATA10)
652         PM_POP(ICPLB_DATA9)
653         PM_POP(ICPLB_DATA8)
654         PM_POP(ICPLB_DATA7)
655         PM_POP(ICPLB_DATA6)
656         PM_POP(ICPLB_DATA5)
657         PM_POP(ICPLB_DATA4)
658         PM_POP(ICPLB_DATA3)
659         PM_POP(ICPLB_DATA2)
660         PM_POP(ICPLB_DATA1)
661         PM_POP(ICPLB_DATA0)
662         PM_POP(ICPLB_ADDR15)
663         PM_POP(ICPLB_ADDR14)
664         PM_POP(ICPLB_ADDR13)
665         PM_POP(ICPLB_ADDR12)
666         PM_POP(ICPLB_ADDR11)
667         PM_POP(ICPLB_ADDR10)
668         PM_POP(ICPLB_ADDR9)
669         PM_POP(ICPLB_ADDR8)
670         PM_POP(ICPLB_ADDR7)
671         PM_POP(ICPLB_ADDR6)
672         PM_POP(ICPLB_ADDR5)
673         PM_POP(ICPLB_ADDR4)
674         PM_POP(ICPLB_ADDR3)
675         PM_POP(ICPLB_ADDR2)
676         PM_POP(ICPLB_ADDR1)
677         PM_POP(ICPLB_ADDR0)
678         PM_POP(IMEM_CONTROL)
679         PM_POP(DCPLB_DATA15)
680         PM_POP(DCPLB_DATA14)
681         PM_POP(DCPLB_DATA13)
682         PM_POP(DCPLB_DATA12)
683         PM_POP(DCPLB_DATA11)
684         PM_POP(DCPLB_DATA10)
685         PM_POP(DCPLB_DATA9)
686         PM_POP(DCPLB_DATA8)
687         PM_POP(DCPLB_DATA7)
688         PM_POP(DCPLB_DATA6)
689         PM_POP(DCPLB_DATA5)
690         PM_POP(DCPLB_DATA4)
691         PM_POP(DCPLB_DATA3)
692         PM_POP(DCPLB_DATA2)
693         PM_POP(DCPLB_DATA1)
694         PM_POP(DCPLB_DATA0)
695         PM_POP(DCPLB_ADDR15)
696         PM_POP(DCPLB_ADDR14)
697         PM_POP(DCPLB_ADDR13)
698         PM_POP(DCPLB_ADDR12)
699         PM_POP(DCPLB_ADDR11)
700         PM_POP(DCPLB_ADDR10)
701         PM_POP(DCPLB_ADDR9)
702         PM_POP(DCPLB_ADDR8)
703         PM_POP(DCPLB_ADDR7)
704         PM_POP(DCPLB_ADDR6)
705         PM_POP(DCPLB_ADDR5)
706         PM_POP(DCPLB_ADDR4)
707         PM_POP(DCPLB_ADDR3)
708         PM_POP(DCPLB_ADDR2)
709         PM_POP(DCPLB_ADDR1)
710         PM_POP(DCPLB_ADDR0)
711         PM_POP(DMEM_CONTROL)
712
713         /* Restore System MMRs */
714
715         P0.H = hi(PLL_CTL);
716         P0.L = lo(PLL_CTL);
717         PM_SYS_POP16(SYSCR)
718
719 #ifdef EBIU_FCTL
720         PM_SYS_POP(EBIU_FCTL)
721         PM_SYS_POP(EBIU_MODE)
722         PM_SYS_POP(EBIU_MBSCTL)
723 #endif
724         PM_SYS_POP16(EBIU_AMGCTL)
725         PM_SYS_POP(EBIU_AMBCTL1)
726         PM_SYS_POP(EBIU_AMBCTL0)
727
728 #ifdef PINT0_ASSIGN
729         PM_SYS_POP(PINT3_EDGE_SET)
730         PM_SYS_POP(PINT2_EDGE_SET)
731         PM_SYS_POP(PINT1_EDGE_SET)
732         PM_SYS_POP(PINT0_EDGE_SET)
733         PM_SYS_POP(PINT3_INVERT_SET)
734         PM_SYS_POP(PINT2_INVERT_SET)
735         PM_SYS_POP(PINT1_INVERT_SET)
736         PM_SYS_POP(PINT0_INVERT_SET)
737         PM_SYS_POP(PINT3_ASSIGN)
738         PM_SYS_POP(PINT2_ASSIGN)
739         PM_SYS_POP(PINT1_ASSIGN)
740         PM_SYS_POP(PINT0_ASSIGN)
741         PM_SYS_POP(PINT3_MASK_SET)
742         PM_SYS_POP(PINT2_MASK_SET)
743         PM_SYS_POP(PINT1_MASK_SET)
744         PM_SYS_POP(PINT0_MASK_SET)
745 #endif
746
747 #ifdef SICA_IWR1
748         PM_SYS_POP(SICA_IWR1)
749 #endif
750 #ifdef SICA_IWR0
751         PM_SYS_POP(SICA_IWR0)
752 #endif
753 #ifdef SIC_IWR2
754         PM_SYS_POP(SIC_IWR2)
755 #endif
756 #ifdef SIC_IWR1
757         PM_SYS_POP(SIC_IWR1)
758 #endif
759 #ifdef SIC_IWR0
760         PM_SYS_POP(SIC_IWR0)
761 #endif
762 #ifdef SIC_IWR
763         PM_SYS_POP(SIC_IWR)
764 #endif
765
766 #ifdef SICA_IAR0
767         PM_SYS_POP(SICA_IAR7)
768         PM_SYS_POP(SICA_IAR6)
769         PM_SYS_POP(SICA_IAR5)
770         PM_SYS_POP(SICA_IAR4)
771         PM_SYS_POP(SICA_IAR3)
772         PM_SYS_POP(SICA_IAR2)
773         PM_SYS_POP(SICA_IAR1)
774         PM_SYS_POP(SICA_IAR0)
775 #endif
776
777 #ifdef SIC_IAR8
778         PM_SYS_POP(SIC_IAR11)
779         PM_SYS_POP(SIC_IAR10)
780         PM_SYS_POP(SIC_IAR9)
781         PM_SYS_POP(SIC_IAR8)
782 #endif
783 #ifdef SIC_IAR7
784         PM_SYS_POP(SIC_IAR7)
785 #endif
786 #ifdef SIC_IAR6
787         PM_SYS_POP(SIC_IAR6)
788         PM_SYS_POP(SIC_IAR5)
789         PM_SYS_POP(SIC_IAR4)
790 #endif
791 #ifdef SIC_IAR3
792         PM_SYS_POP(SIC_IAR3)
793 #endif
794 #ifdef SIC_IAR2
795         PM_SYS_POP(SIC_IAR2)
796         PM_SYS_POP(SIC_IAR1)
797         PM_SYS_POP(SIC_IAR0)
798 #endif
799 #ifdef SICA_IMASK1
800         PM_SYS_POP(SICA_IMASK1)
801 #endif
802 #ifdef SICA_IMASK0
803         PM_SYS_POP(SICA_IMASK0)
804 #endif
805 #ifdef SIC_IMASK
806         PM_SYS_POP(SIC_IMASK)
807 #endif
808 #ifdef SIC_IMASK2
809         PM_SYS_POP(SIC_IMASK2)
810 #endif
811 #ifdef SIC_IMASK1
812         PM_SYS_POP(SIC_IMASK1)
813 #endif
814 #ifdef SIC_IMASK0
815         PM_SYS_POP(SIC_IMASK0)
816 #endif
817
818         [--sp] = RETI;  /* Clear Global Interrupt Disable */
819         SP += 4;
820
821         RETS = [SP++];
822         ( R7:0, P5:0 ) = [SP++];
823         RTS;
824 ENDPROC(_do_hibernate)