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_ASSIGN)
380 PM_SYS_PUSH(PINT1_ASSIGN)
381 PM_SYS_PUSH(PINT2_ASSIGN)
382 PM_SYS_PUSH(PINT3_ASSIGN)
385 PM_SYS_PUSH(EBIU_AMBCTL0)
386 PM_SYS_PUSH(EBIU_AMBCTL1)
387 PM_SYS_PUSH16(EBIU_AMGCTL)
390 PM_SYS_PUSH(EBIU_MBSCTL)
391 PM_SYS_PUSH(EBIU_MODE)
392 PM_SYS_PUSH(EBIU_FCTL)
398 P0.H = hi(SRAM_BASE_ADDRESS);
399 P0.L = lo(SRAM_BASE_ADDRESS);
401 PM_PUSH(DMEM_CONTROL)
412 PM_PUSH(DCPLB_ADDR10)
413 PM_PUSH(DCPLB_ADDR11)
414 PM_PUSH(DCPLB_ADDR12)
415 PM_PUSH(DCPLB_ADDR13)
416 PM_PUSH(DCPLB_ADDR14)
417 PM_PUSH(DCPLB_ADDR15)
428 PM_PUSH(DCPLB_DATA10)
429 PM_PUSH(DCPLB_DATA11)
430 PM_PUSH(DCPLB_DATA12)
431 PM_PUSH(DCPLB_DATA13)
432 PM_PUSH(DCPLB_DATA14)
433 PM_PUSH(DCPLB_DATA15)
434 PM_PUSH(IMEM_CONTROL)
445 PM_PUSH(ICPLB_ADDR10)
446 PM_PUSH(ICPLB_ADDR11)
447 PM_PUSH(ICPLB_ADDR12)
448 PM_PUSH(ICPLB_ADDR13)
449 PM_PUSH(ICPLB_ADDR14)
450 PM_PUSH(ICPLB_ADDR15)
461 PM_PUSH(ICPLB_DATA10)
462 PM_PUSH(ICPLB_DATA11)
463 PM_PUSH(ICPLB_DATA12)
464 PM_PUSH(ICPLB_DATA13)
465 PM_PUSH(ICPLB_DATA14)
466 PM_PUSH(ICPLB_DATA15)
492 /* Save Core Registers */
494 [--sp] = ( R7:0, P5:0 );
541 /* Save Magic, return address and Stack Pointer */
544 R0.H = 0xDEAD; /* Hibernate Magic */
546 [P0++] = R0; /* Store Hibernate Magic */
547 R0.H = .Lpm_resume_here;
548 R0.L = .Lpm_resume_here;
549 [P0++] = R0; /* Save Return Address */
550 [P0++] = SP; /* Save Stack Pointer */
551 P0.H = _hibernate_mode;
552 P0.L = _hibernate_mode;
554 call (P0); /* Goodbye */
558 /* Restore Core Registers */
605 ( R7 : 0, P5 : 0) = [ SP ++ ];
608 /* Restore Core MMRs */
701 /* Restore System MMRs */
708 PM_SYS_POP(EBIU_FCTL)
709 PM_SYS_POP(EBIU_MODE)
710 PM_SYS_POP(EBIU_MBSCTL)
712 PM_SYS_POP16(EBIU_AMGCTL)
713 PM_SYS_POP(EBIU_AMBCTL1)
714 PM_SYS_POP(EBIU_AMBCTL0)
717 PM_SYS_POP(PINT3_ASSIGN)
718 PM_SYS_POP(PINT2_ASSIGN)
719 PM_SYS_POP(PINT1_ASSIGN)
720 PM_SYS_POP(PINT0_ASSIGN)
724 PM_SYS_POP(SICA_IWR1)
727 PM_SYS_POP(SICA_IWR0)
743 PM_SYS_POP(SICA_IAR7)
744 PM_SYS_POP(SICA_IAR6)
745 PM_SYS_POP(SICA_IAR5)
746 PM_SYS_POP(SICA_IAR4)
747 PM_SYS_POP(SICA_IAR3)
748 PM_SYS_POP(SICA_IAR2)
749 PM_SYS_POP(SICA_IAR1)
750 PM_SYS_POP(SICA_IAR0)
754 PM_SYS_POP(SIC_IAR11)
755 PM_SYS_POP(SIC_IAR10)
776 PM_SYS_POP(SICA_IMASK1)
779 PM_SYS_POP(SICA_IMASK0)
782 PM_SYS_POP(SIC_IMASK)
785 PM_SYS_POP(SIC_IMASK2)
788 PM_SYS_POP(SIC_IMASK1)
791 PM_SYS_POP(SIC_IMASK0)
794 [--sp] = RETI; /* Clear Global Interrupt Disable */
798 ( R7:0, P5:0 ) = [SP++];
800 ENDPROC(_do_hibernate)