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)
408 PM_SYS_PUSH16(PORTCIO_DIR)
409 PM_SYS_PUSH16(PORTCIO_INEN)
410 PM_SYS_PUSH16(PORTCIO)
411 PM_SYS_PUSH16(PORTCIO_FER)
412 PM_SYS_PUSH16(PORTDIO_DIR)
413 PM_SYS_PUSH16(PORTDIO_INEN)
414 PM_SYS_PUSH16(PORTDIO)
415 PM_SYS_PUSH16(PORTDIO_FER)
416 PM_SYS_PUSH16(PORTEIO_DIR)
417 PM_SYS_PUSH16(PORTEIO_INEN)
418 PM_SYS_PUSH16(PORTEIO)
419 PM_SYS_PUSH16(PORTEIO_FER)
425 P0.H = hi(SRAM_BASE_ADDRESS);
426 P0.L = lo(SRAM_BASE_ADDRESS);
428 PM_PUSH(DMEM_CONTROL)
439 PM_PUSH(DCPLB_ADDR10)
440 PM_PUSH(DCPLB_ADDR11)
441 PM_PUSH(DCPLB_ADDR12)
442 PM_PUSH(DCPLB_ADDR13)
443 PM_PUSH(DCPLB_ADDR14)
444 PM_PUSH(DCPLB_ADDR15)
455 PM_PUSH(DCPLB_DATA10)
456 PM_PUSH(DCPLB_DATA11)
457 PM_PUSH(DCPLB_DATA12)
458 PM_PUSH(DCPLB_DATA13)
459 PM_PUSH(DCPLB_DATA14)
460 PM_PUSH(DCPLB_DATA15)
461 PM_PUSH(IMEM_CONTROL)
472 PM_PUSH(ICPLB_ADDR10)
473 PM_PUSH(ICPLB_ADDR11)
474 PM_PUSH(ICPLB_ADDR12)
475 PM_PUSH(ICPLB_ADDR13)
476 PM_PUSH(ICPLB_ADDR14)
477 PM_PUSH(ICPLB_ADDR15)
488 PM_PUSH(ICPLB_DATA10)
489 PM_PUSH(ICPLB_DATA11)
490 PM_PUSH(ICPLB_DATA12)
491 PM_PUSH(ICPLB_DATA13)
492 PM_PUSH(ICPLB_DATA14)
493 PM_PUSH(ICPLB_DATA15)
519 /* Save Core Registers */
521 [--sp] = ( R7:0, P5:0 );
568 /* Save Magic, return address and Stack Pointer */
571 R0.H = 0xDEAD; /* Hibernate Magic */
573 [P0++] = R0; /* Store Hibernate Magic */
574 R0.H = .Lpm_resume_here;
575 R0.L = .Lpm_resume_here;
576 [P0++] = R0; /* Save Return Address */
577 [P0++] = SP; /* Save Stack Pointer */
578 P0.H = _hibernate_mode;
579 P0.L = _hibernate_mode;
581 call (P0); /* Goodbye */
585 /* Restore Core Registers */
632 ( R7 : 0, P5 : 0) = [ SP ++ ];
635 /* Restore Core MMRs */
728 /* Restore System MMRs */
735 PM_SYS_POP16(PORTEIO_FER)
736 PM_SYS_POP16(PORTEIO)
737 PM_SYS_POP16(PORTEIO_INEN)
738 PM_SYS_POP16(PORTEIO_DIR)
739 PM_SYS_POP16(PORTDIO_FER)
740 PM_SYS_POP16(PORTDIO)
741 PM_SYS_POP16(PORTDIO_INEN)
742 PM_SYS_POP16(PORTDIO_DIR)
743 PM_SYS_POP16(PORTCIO_FER)
744 PM_SYS_POP16(PORTCIO)
745 PM_SYS_POP16(PORTCIO_INEN)
746 PM_SYS_POP16(PORTCIO_DIR)
750 PM_SYS_POP(EBIU_FCTL)
751 PM_SYS_POP(EBIU_MODE)
752 PM_SYS_POP(EBIU_MBSCTL)
754 PM_SYS_POP16(EBIU_AMGCTL)
755 PM_SYS_POP(EBIU_AMBCTL1)
756 PM_SYS_POP(EBIU_AMBCTL0)
759 PM_SYS_POP(PINT3_EDGE_SET)
760 PM_SYS_POP(PINT2_EDGE_SET)
761 PM_SYS_POP(PINT1_EDGE_SET)
762 PM_SYS_POP(PINT0_EDGE_SET)
763 PM_SYS_POP(PINT3_INVERT_SET)
764 PM_SYS_POP(PINT2_INVERT_SET)
765 PM_SYS_POP(PINT1_INVERT_SET)
766 PM_SYS_POP(PINT0_INVERT_SET)
767 PM_SYS_POP(PINT3_ASSIGN)
768 PM_SYS_POP(PINT2_ASSIGN)
769 PM_SYS_POP(PINT1_ASSIGN)
770 PM_SYS_POP(PINT0_ASSIGN)
771 PM_SYS_POP(PINT3_MASK_SET)
772 PM_SYS_POP(PINT2_MASK_SET)
773 PM_SYS_POP(PINT1_MASK_SET)
774 PM_SYS_POP(PINT0_MASK_SET)
778 PM_SYS_POP(SICA_IWR1)
781 PM_SYS_POP(SICA_IWR0)
797 PM_SYS_POP(SICA_IAR7)
798 PM_SYS_POP(SICA_IAR6)
799 PM_SYS_POP(SICA_IAR5)
800 PM_SYS_POP(SICA_IAR4)
801 PM_SYS_POP(SICA_IAR3)
802 PM_SYS_POP(SICA_IAR2)
803 PM_SYS_POP(SICA_IAR1)
804 PM_SYS_POP(SICA_IAR0)
808 PM_SYS_POP(SIC_IAR11)
809 PM_SYS_POP(SIC_IAR10)
830 PM_SYS_POP(SICA_IMASK1)
833 PM_SYS_POP(SICA_IMASK0)
836 PM_SYS_POP(SIC_IMASK)
839 PM_SYS_POP(SIC_IMASK2)
842 PM_SYS_POP(SIC_IMASK1)
845 PM_SYS_POP(SIC_IMASK0)
848 [--sp] = RETI; /* Clear Global Interrupt Disable */
852 ( R7:0, P5:0 ) = [SP++];
854 ENDPROC(_do_hibernate)