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>
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) || \
251 defined(CONFIG_BF538) || defined(CONFIG_BF539) || defined(CONFIG_BF51x)
257 #if defined(CONFIG_BF54x)
270 ENDPROC(_set_sic_iwr)
272 ENTRY(_set_rtc_istat)
274 P0.H = hi(RTC_ISTAT);
275 P0.L = lo(RTC_ISTAT);
278 #elif (ANOMALY_05000371)
285 ENDPROC(_set_rtc_istat)
287 ENTRY(_test_pll_locked)
295 ENDPROC(_test_pll_locked)
300 [--SP] = ( R7:0, P5:0 );
302 /* Save System MMRs */
308 PM_SYS_PUSH(SIC_IMASK0)
311 PM_SYS_PUSH(SIC_IMASK1)
314 PM_SYS_PUSH(SIC_IMASK2)
317 PM_SYS_PUSH(SIC_IMASK)
320 PM_SYS_PUSH(SICA_IMASK0)
323 PM_SYS_PUSH(SICA_IMASK1)
326 PM_SYS_PUSH(SIC_IAR0)
327 PM_SYS_PUSH(SIC_IAR1)
328 PM_SYS_PUSH(SIC_IAR2)
331 PM_SYS_PUSH(SIC_IAR3)
334 PM_SYS_PUSH(SIC_IAR4)
335 PM_SYS_PUSH(SIC_IAR5)
336 PM_SYS_PUSH(SIC_IAR6)
339 PM_SYS_PUSH(SIC_IAR7)
342 PM_SYS_PUSH(SIC_IAR8)
343 PM_SYS_PUSH(SIC_IAR9)
344 PM_SYS_PUSH(SIC_IAR10)
345 PM_SYS_PUSH(SIC_IAR11)
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)
363 PM_SYS_PUSH(SIC_IWR0)
366 PM_SYS_PUSH(SIC_IWR1)
369 PM_SYS_PUSH(SIC_IWR2)
372 PM_SYS_PUSH(SICA_IWR0)
375 PM_SYS_PUSH(SICA_IWR1)
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)
397 PM_SYS_PUSH(EBIU_AMBCTL0)
398 PM_SYS_PUSH(EBIU_AMBCTL1)
399 PM_SYS_PUSH16(EBIU_AMGCTL)
402 PM_SYS_PUSH(EBIU_MBSCTL)
403 PM_SYS_PUSH(EBIU_MODE)
404 PM_SYS_PUSH(EBIU_FCTL)
410 P0.H = hi(SRAM_BASE_ADDRESS);
411 P0.L = lo(SRAM_BASE_ADDRESS);
413 PM_PUSH(DMEM_CONTROL)
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)
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)
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)
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)
504 /* Save Core Registers */
506 [--sp] = ( R7:0, P5:0 );
553 /* Save Magic, return address and Stack Pointer */
556 R0.H = 0xDEAD; /* Hibernate Magic */
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;
566 call (P0); /* Goodbye */
570 /* Restore Core Registers */
617 ( R7 : 0, P5 : 0) = [ SP ++ ];
620 /* Restore Core MMRs */
713 /* Restore System MMRs */
720 PM_SYS_POP(EBIU_FCTL)
721 PM_SYS_POP(EBIU_MODE)
722 PM_SYS_POP(EBIU_MBSCTL)
724 PM_SYS_POP16(EBIU_AMGCTL)
725 PM_SYS_POP(EBIU_AMBCTL1)
726 PM_SYS_POP(EBIU_AMBCTL0)
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)
748 PM_SYS_POP(SICA_IWR1)
751 PM_SYS_POP(SICA_IWR0)
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)
778 PM_SYS_POP(SIC_IAR11)
779 PM_SYS_POP(SIC_IAR10)
800 PM_SYS_POP(SICA_IMASK1)
803 PM_SYS_POP(SICA_IMASK0)
806 PM_SYS_POP(SIC_IMASK)
809 PM_SYS_POP(SIC_IMASK2)
812 PM_SYS_POP(SIC_IMASK1)
815 PM_SYS_POP(SIC_IMASK0)
818 [--sp] = RETI; /* Clear Global Interrupt Disable */
822 ( R7:0, P5:0 ) = [SP++];
824 ENDPROC(_do_hibernate)