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 );
96 call _set_dram_srfs; /* Set SDRAM Self Refresh */
98 /* Clear all the interrupts,bits sticky */
105 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
110 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
111 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
116 call _test_pll_locked;
126 R2 = DEPOSIT(R7, R1);
127 W[P0] = R2; /* Set Min Core Voltage */
132 call _test_pll_locked;
137 call _set_sic_iwr; /* Set Awake from IDLE */
143 W[P0] = R0.L; /* Turn CCLK OFF */
147 call _test_pll_locked;
150 R1 = IWR_DISABLE_ALL;
151 R2 = IWR_DISABLE_ALL;
153 call _set_sic_iwr; /* Set Awake from IDLE PLL */
162 call _test_pll_locked;
166 W[P0]= R6; /* Restore CCLK and SCLK divider */
170 w[p0] = R5; /* Restore VCO multiplier */
172 call _test_pll_locked;
174 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
179 ( R7:0, P5:0 ) = [SP++];
181 ENDPROC(_sleep_deeper)
183 ENTRY(_set_dram_srfs)
184 /* set the dram to self refresh mode */
186 #if defined(EBIU_RSTCTL) /* DDR */
187 P0.H = hi(EBIU_RSTCTL);
188 P0.L = lo(EBIU_RSTCTL);
190 BITSET(R2, 3); /* SRREQ enter self-refresh mode */
198 P0.L = lo(EBIU_SDGCTL);
199 P0.H = hi(EBIU_SDGCTL);
201 BITSET(R2, 24); /* SRFS enter self-refresh mode */
205 P0.L = lo(EBIU_SDSTAT);
206 P0.H = hi(EBIU_SDSTAT);
210 cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
213 P0.L = lo(EBIU_SDGCTL);
214 P0.H = hi(EBIU_SDGCTL);
216 BITCLR(R2, 0); /* SCTLE disable CLKOUT */
220 ENDPROC(_set_dram_srfs)
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);
228 BITCLR(R2, 3); /* clear SRREQ bit */
230 #elif defined(EBIU_SDGCTL) /* SDRAM */
232 P0.L = lo(EBIU_SDGCTL); /* release CLKOUT from self-refresh */
233 P0.H = hi(EBIU_SDGCTL);
235 BITSET(R2, 0); /* SCTLE enable CLKOUT */
239 P0.L = lo(EBIU_SDGCTL); /* release SDRAM from self-refresh */
240 P0.H = hi(EBIU_SDGCTL);
242 BITCLR(R2, 24); /* clear SRFS bit */
247 ENDPROC(_unset_dram_srfs)
250 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
256 #if defined(CONFIG_BF54x)
269 ENDPROC(_set_sic_iwr)
271 ENTRY(_set_rtc_istat)
273 P0.H = hi(RTC_ISTAT);
274 P0.L = lo(RTC_ISTAT);
277 #elif (ANOMALY_05000371)
284 ENDPROC(_set_rtc_istat)
286 ENTRY(_test_pll_locked)
294 ENDPROC(_test_pll_locked)
299 [--SP] = ( R7:0, P5:0 );
301 /* Save System MMRs */
307 PM_SYS_PUSH(SIC_IMASK0)
310 PM_SYS_PUSH(SIC_IMASK1)
313 PM_SYS_PUSH(SIC_IMASK2)
316 PM_SYS_PUSH(SIC_IMASK)
319 PM_SYS_PUSH(SICA_IMASK0)
322 PM_SYS_PUSH(SICA_IMASK1)
325 PM_SYS_PUSH(SIC_IAR0)
326 PM_SYS_PUSH(SIC_IAR1)
327 PM_SYS_PUSH(SIC_IAR2)
330 PM_SYS_PUSH(SIC_IAR3)
333 PM_SYS_PUSH(SIC_IAR4)
334 PM_SYS_PUSH(SIC_IAR5)
335 PM_SYS_PUSH(SIC_IAR6)
338 PM_SYS_PUSH(SIC_IAR7)
341 PM_SYS_PUSH(SIC_IAR8)
342 PM_SYS_PUSH(SIC_IAR9)
343 PM_SYS_PUSH(SIC_IAR10)
344 PM_SYS_PUSH(SIC_IAR11)
348 PM_SYS_PUSH(SICA_IAR0)
349 PM_SYS_PUSH(SICA_IAR1)
350 PM_SYS_PUSH(SICA_IAR2)
351 PM_SYS_PUSH(SICA_IAR3)
352 PM_SYS_PUSH(SICA_IAR4)
353 PM_SYS_PUSH(SICA_IAR5)
354 PM_SYS_PUSH(SICA_IAR6)
355 PM_SYS_PUSH(SICA_IAR7)
362 PM_SYS_PUSH(SIC_IWR0)
365 PM_SYS_PUSH(SIC_IWR1)
368 PM_SYS_PUSH(SIC_IWR2)
371 PM_SYS_PUSH(SICA_IWR0)
374 PM_SYS_PUSH(SICA_IWR1)
378 PM_SYS_PUSH(PINT0_ASSIGN)
379 PM_SYS_PUSH(PINT1_ASSIGN)
380 PM_SYS_PUSH(PINT2_ASSIGN)
381 PM_SYS_PUSH(PINT3_ASSIGN)
384 PM_SYS_PUSH(EBIU_AMBCTL0)
385 PM_SYS_PUSH(EBIU_AMBCTL1)
386 PM_SYS_PUSH16(EBIU_AMGCTL)
389 PM_SYS_PUSH(EBIU_MBSCTL)
390 PM_SYS_PUSH(EBIU_MODE)
391 PM_SYS_PUSH(EBIU_FCTL)
397 P0.H = hi(SRAM_BASE_ADDRESS);
398 P0.L = lo(SRAM_BASE_ADDRESS);
400 PM_PUSH(DMEM_CONTROL)
411 PM_PUSH(DCPLB_ADDR10)
412 PM_PUSH(DCPLB_ADDR11)
413 PM_PUSH(DCPLB_ADDR12)
414 PM_PUSH(DCPLB_ADDR13)
415 PM_PUSH(DCPLB_ADDR14)
416 PM_PUSH(DCPLB_ADDR15)
427 PM_PUSH(DCPLB_DATA10)
428 PM_PUSH(DCPLB_DATA11)
429 PM_PUSH(DCPLB_DATA12)
430 PM_PUSH(DCPLB_DATA13)
431 PM_PUSH(DCPLB_DATA14)
432 PM_PUSH(DCPLB_DATA15)
433 PM_PUSH(IMEM_CONTROL)
444 PM_PUSH(ICPLB_ADDR10)
445 PM_PUSH(ICPLB_ADDR11)
446 PM_PUSH(ICPLB_ADDR12)
447 PM_PUSH(ICPLB_ADDR13)
448 PM_PUSH(ICPLB_ADDR14)
449 PM_PUSH(ICPLB_ADDR15)
460 PM_PUSH(ICPLB_DATA10)
461 PM_PUSH(ICPLB_DATA11)
462 PM_PUSH(ICPLB_DATA12)
463 PM_PUSH(ICPLB_DATA13)
464 PM_PUSH(ICPLB_DATA14)
465 PM_PUSH(ICPLB_DATA15)
491 /* Save Core Registers */
493 [--sp] = ( R7:0, P5:0 );
540 /* Save Magic, return address and Stack Pointer */
543 R0.H = 0xDEAD; /* Hibernate Magic */
545 [P0++] = R0; /* Store Hibernate Magic */
546 R0.H = .Lpm_resume_here;
547 R0.L = .Lpm_resume_here;
548 [P0++] = R0; /* Save Return Address */
549 [P0++] = SP; /* Save Stack Pointer */
550 P0.H = _hibernate_mode;
551 P0.L = _hibernate_mode;
553 call (P0); /* Goodbye */
557 /* Restore Core Registers */
604 ( R7 : 0, P5 : 0) = [ SP ++ ];
607 /* Restore Core MMRs */
700 /* Restore System MMRs */
707 PM_SYS_POP(EBIU_FCTL)
708 PM_SYS_POP(EBIU_MODE)
709 PM_SYS_POP(EBIU_MBSCTL)
711 PM_SYS_POP16(EBIU_AMGCTL)
712 PM_SYS_POP(EBIU_AMBCTL1)
713 PM_SYS_POP(EBIU_AMBCTL0)
716 PM_SYS_POP(PINT3_ASSIGN)
717 PM_SYS_POP(PINT2_ASSIGN)
718 PM_SYS_POP(PINT1_ASSIGN)
719 PM_SYS_POP(PINT0_ASSIGN)
723 PM_SYS_POP(SICA_IWR1)
726 PM_SYS_POP(SICA_IWR0)
742 PM_SYS_POP(SICA_IAR7)
743 PM_SYS_POP(SICA_IAR6)
744 PM_SYS_POP(SICA_IAR5)
745 PM_SYS_POP(SICA_IAR4)
746 PM_SYS_POP(SICA_IAR3)
747 PM_SYS_POP(SICA_IAR2)
748 PM_SYS_POP(SICA_IAR1)
749 PM_SYS_POP(SICA_IAR0)
753 PM_SYS_POP(SIC_IAR11)
754 PM_SYS_POP(SIC_IAR10)
775 PM_SYS_POP(SICA_IMASK1)
778 PM_SYS_POP(SICA_IMASK0)
781 PM_SYS_POP(SIC_IMASK)
784 PM_SYS_POP(SIC_IMASK2)
787 PM_SYS_POP(SIC_IMASK1)
790 PM_SYS_POP(SIC_IMASK0)
793 [--sp] = RETI; /* Clear Global Interrupt Disable */
797 ( R7:0, P5:0 ) = [SP++];
799 ENDPROC(_do_hibernate)