2 * Copyright 2004-2008 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
7 #include <linux/linkage.h>
8 #include <asm/blackfin.h>
9 #include <asm/mach/irq.h>
15 [--SP] = ( R7:0, P5:0 );
34 call _test_pll_locked;
49 call _test_pll_locked;
52 ( R7:0, P5:0 ) = [SP++];
56 ENTRY(_hibernate_mode)
57 [--SP] = ( R7:0, P5:0 );
79 ENDPROC(_hibernate_mode)
82 [--SP] = ( R7:0, P5:0 );
95 /* Clear all the interrupts,bits sticky */
105 call _test_pll_locked;
110 call _unset_dram_srfs;
112 call _test_pll_locked;
115 R1 = IWR_DISABLE_ALL;
116 R2 = IWR_DISABLE_ALL;
128 call _test_pll_locked;
133 ( R7:0, P5:0 ) = [SP++];
138 [--SP] = ( R7:0, P5:0 );
148 R1 = IWR_DISABLE_ALL;
149 R2 = IWR_DISABLE_ALL;
152 call _set_dram_srfs; /* Set SDRAM Self Refresh */
154 /* Clear all the interrupts,bits sticky */
161 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
166 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
167 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
172 call _test_pll_locked;
182 R2 = DEPOSIT(R7, R1);
183 W[P0] = R2; /* Set Min Core Voltage */
188 call _test_pll_locked;
193 call _set_sic_iwr; /* Set Awake from IDLE */
199 W[P0] = R0.L; /* Turn CCLK OFF */
203 call _test_pll_locked;
206 R1 = IWR_DISABLE_ALL;
207 R2 = IWR_DISABLE_ALL;
209 call _set_sic_iwr; /* Set Awake from IDLE PLL */
218 call _test_pll_locked;
222 W[P0]= R6; /* Restore CCLK and SCLK divider */
226 w[p0] = R5; /* Restore VCO multiplier */
228 call _test_pll_locked;
230 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
235 ( R7:0, P5:0 ) = [SP++];
237 ENDPROC(_sleep_deeper)
239 ENTRY(_set_dram_srfs)
240 /* set the dram to self refresh mode */
242 #if defined(EBIU_RSTCTL) /* DDR */
243 P0.H = hi(EBIU_RSTCTL);
244 P0.L = lo(EBIU_RSTCTL);
246 BITSET(R2, 3); /* SRREQ enter self-refresh mode */
254 P0.L = lo(EBIU_SDGCTL);
255 P0.H = hi(EBIU_SDGCTL);
257 BITSET(R2, 24); /* SRFS enter self-refresh mode */
261 P0.L = lo(EBIU_SDSTAT);
262 P0.H = hi(EBIU_SDSTAT);
266 cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
269 P0.L = lo(EBIU_SDGCTL);
270 P0.H = hi(EBIU_SDGCTL);
272 BITCLR(R2, 0); /* SCTLE disable CLKOUT */
276 ENDPROC(_set_dram_srfs)
278 ENTRY(_unset_dram_srfs)
279 /* set the dram out of self refresh mode */
280 #if defined(EBIU_RSTCTL) /* DDR */
281 P0.H = hi(EBIU_RSTCTL);
282 P0.L = lo(EBIU_RSTCTL);
284 BITCLR(R2, 3); /* clear SRREQ bit */
286 #elif defined(EBIU_SDGCTL) /* SDRAM */
288 P0.L = lo(EBIU_SDGCTL); /* release CLKOUT from self-refresh */
289 P0.H = hi(EBIU_SDGCTL);
291 BITSET(R2, 0); /* SCTLE enable CLKOUT */
295 P0.L = lo(EBIU_SDGCTL); /* release SDRAM from self-refresh */
296 P0.H = hi(EBIU_SDGCTL);
298 BITCLR(R2, 24); /* clear SRFS bit */
303 ENDPROC(_unset_dram_srfs)
306 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
312 #if defined(CONFIG_BF54x)
325 ENDPROC(_set_sic_iwr)
327 ENTRY(_set_rtc_istat)
329 P0.H = hi(RTC_ISTAT);
330 P0.L = lo(RTC_ISTAT);
333 #elif (ANOMALY_05000371)
340 ENDPROC(_set_rtc_istat)
342 ENTRY(_test_pll_locked)
350 ENDPROC(_test_pll_locked)
355 [--SP] = ( R7:0, P5:0 );
357 /* Save System MMRs */
363 PM_SYS_PUSH(SIC_IMASK0)
366 PM_SYS_PUSH(SIC_IMASK1)
369 PM_SYS_PUSH(SIC_IMASK2)
372 PM_SYS_PUSH(SIC_IMASK)
375 PM_SYS_PUSH(SICA_IMASK0)
378 PM_SYS_PUSH(SICA_IMASK1)
381 PM_SYS_PUSH(SIC_IAR0)
382 PM_SYS_PUSH(SIC_IAR1)
383 PM_SYS_PUSH(SIC_IAR2)
386 PM_SYS_PUSH(SIC_IAR3)
389 PM_SYS_PUSH(SIC_IAR4)
390 PM_SYS_PUSH(SIC_IAR5)
391 PM_SYS_PUSH(SIC_IAR6)
394 PM_SYS_PUSH(SIC_IAR7)
397 PM_SYS_PUSH(SIC_IAR8)
398 PM_SYS_PUSH(SIC_IAR9)
399 PM_SYS_PUSH(SIC_IAR10)
400 PM_SYS_PUSH(SIC_IAR11)
404 PM_SYS_PUSH(SICA_IAR0)
405 PM_SYS_PUSH(SICA_IAR1)
406 PM_SYS_PUSH(SICA_IAR2)
407 PM_SYS_PUSH(SICA_IAR3)
408 PM_SYS_PUSH(SICA_IAR4)
409 PM_SYS_PUSH(SICA_IAR5)
410 PM_SYS_PUSH(SICA_IAR6)
411 PM_SYS_PUSH(SICA_IAR7)
418 PM_SYS_PUSH(SIC_IWR0)
421 PM_SYS_PUSH(SIC_IWR1)
424 PM_SYS_PUSH(SIC_IWR2)
427 PM_SYS_PUSH(SICA_IWR0)
430 PM_SYS_PUSH(SICA_IWR1)
434 PM_SYS_PUSH(PINT0_ASSIGN)
435 PM_SYS_PUSH(PINT1_ASSIGN)
436 PM_SYS_PUSH(PINT2_ASSIGN)
437 PM_SYS_PUSH(PINT3_ASSIGN)
440 PM_SYS_PUSH(EBIU_AMBCTL0)
441 PM_SYS_PUSH(EBIU_AMBCTL1)
442 PM_SYS_PUSH16(EBIU_AMGCTL)
445 PM_SYS_PUSH(EBIU_MBSCTL)
446 PM_SYS_PUSH(EBIU_MODE)
447 PM_SYS_PUSH(EBIU_FCTL)
453 P0.H = hi(SRAM_BASE_ADDRESS);
454 P0.L = lo(SRAM_BASE_ADDRESS);
456 PM_PUSH(DMEM_CONTROL)
467 PM_PUSH(DCPLB_ADDR10)
468 PM_PUSH(DCPLB_ADDR11)
469 PM_PUSH(DCPLB_ADDR12)
470 PM_PUSH(DCPLB_ADDR13)
471 PM_PUSH(DCPLB_ADDR14)
472 PM_PUSH(DCPLB_ADDR15)
483 PM_PUSH(DCPLB_DATA10)
484 PM_PUSH(DCPLB_DATA11)
485 PM_PUSH(DCPLB_DATA12)
486 PM_PUSH(DCPLB_DATA13)
487 PM_PUSH(DCPLB_DATA14)
488 PM_PUSH(DCPLB_DATA15)
489 PM_PUSH(IMEM_CONTROL)
500 PM_PUSH(ICPLB_ADDR10)
501 PM_PUSH(ICPLB_ADDR11)
502 PM_PUSH(ICPLB_ADDR12)
503 PM_PUSH(ICPLB_ADDR13)
504 PM_PUSH(ICPLB_ADDR14)
505 PM_PUSH(ICPLB_ADDR15)
516 PM_PUSH(ICPLB_DATA10)
517 PM_PUSH(ICPLB_DATA11)
518 PM_PUSH(ICPLB_DATA12)
519 PM_PUSH(ICPLB_DATA13)
520 PM_PUSH(ICPLB_DATA14)
521 PM_PUSH(ICPLB_DATA15)
547 /* Save Core Registers */
549 [--sp] = ( R7:0, P5:0 );
596 /* Save Magic, return address and Stack Pointer */
599 R0.H = 0xDEAD; /* Hibernate Magic */
601 [P0++] = R0; /* Store Hibernate Magic */
602 R0.H = .Lpm_resume_here;
603 R0.L = .Lpm_resume_here;
604 [P0++] = R0; /* Save Return Address */
605 [P0++] = SP; /* Save Stack Pointer */
606 P0.H = _hibernate_mode;
607 P0.L = _hibernate_mode;
609 call (P0); /* Goodbye */
613 /* Restore Core Registers */
660 ( R7 : 0, P5 : 0) = [ SP ++ ];
663 /* Restore Core MMRs */
756 /* Restore System MMRs */
763 PM_SYS_POP(EBIU_FCTL)
764 PM_SYS_POP(EBIU_MODE)
765 PM_SYS_POP(EBIU_MBSCTL)
767 PM_SYS_POP16(EBIU_AMGCTL)
768 PM_SYS_POP(EBIU_AMBCTL1)
769 PM_SYS_POP(EBIU_AMBCTL0)
772 PM_SYS_POP(PINT3_ASSIGN)
773 PM_SYS_POP(PINT2_ASSIGN)
774 PM_SYS_POP(PINT1_ASSIGN)
775 PM_SYS_POP(PINT0_ASSIGN)
779 PM_SYS_POP(SICA_IWR1)
782 PM_SYS_POP(SICA_IWR0)
798 PM_SYS_POP(SICA_IAR7)
799 PM_SYS_POP(SICA_IAR6)
800 PM_SYS_POP(SICA_IAR5)
801 PM_SYS_POP(SICA_IAR4)
802 PM_SYS_POP(SICA_IAR3)
803 PM_SYS_POP(SICA_IAR2)
804 PM_SYS_POP(SICA_IAR1)
805 PM_SYS_POP(SICA_IAR0)
809 PM_SYS_POP(SIC_IAR11)
810 PM_SYS_POP(SIC_IAR10)
831 PM_SYS_POP(SICA_IMASK1)
834 PM_SYS_POP(SICA_IMASK0)
837 PM_SYS_POP(SIC_IMASK)
840 PM_SYS_POP(SIC_IMASK2)
843 PM_SYS_POP(SIC_IMASK1)
846 PM_SYS_POP(SIC_IMASK0)
849 [--sp] = RETI; /* Clear Global Interrupt Disable */
853 ( R7:0, P5:0 ) = [SP++];
855 ENDPROC(_do_hibernate)