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 );
31 call _test_pll_locked;
46 call _test_pll_locked;
49 ( R7:0, P5:0 ) = [SP++];
53 ENTRY(_hibernate_mode)
54 [--SP] = ( R7:0, P5:0 );
73 ENDPROC(_hibernate_mode)
76 [--SP] = ( R7:0, P5:0 );
90 call _set_dram_srfs; /* Set SDRAM Self Refresh */
96 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
101 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
102 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
107 call _test_pll_locked;
117 R2 = DEPOSIT(R7, R1);
118 W[P0] = R2; /* Set Min Core Voltage */
123 call _test_pll_locked;
128 call _set_sic_iwr; /* Set Awake from IDLE */
134 W[P0] = R0.L; /* Turn CCLK OFF */
138 call _test_pll_locked;
141 R1 = IWR_DISABLE_ALL;
142 R2 = IWR_DISABLE_ALL;
144 call _set_sic_iwr; /* Set Awake from IDLE PLL */
153 call _test_pll_locked;
157 W[P0]= R6; /* Restore CCLK and SCLK divider */
161 w[p0] = R5; /* Restore VCO multiplier */
163 call _test_pll_locked;
165 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
170 ( R7:0, P5:0 ) = [SP++];
172 ENDPROC(_sleep_deeper)
174 ENTRY(_set_dram_srfs)
175 /* set the dram to self refresh mode */
177 #if defined(EBIU_RSTCTL) /* DDR */
178 P0.H = hi(EBIU_RSTCTL);
179 P0.L = lo(EBIU_RSTCTL);
181 BITSET(R2, 3); /* SRREQ enter self-refresh mode */
189 P0.L = lo(EBIU_SDGCTL);
190 P0.H = hi(EBIU_SDGCTL);
192 BITSET(R2, 24); /* SRFS enter self-refresh mode */
196 P0.L = lo(EBIU_SDSTAT);
197 P0.H = hi(EBIU_SDSTAT);
201 cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
204 P0.L = lo(EBIU_SDGCTL);
205 P0.H = hi(EBIU_SDGCTL);
207 BITCLR(R2, 0); /* SCTLE disable CLKOUT */
211 ENDPROC(_set_dram_srfs)
213 ENTRY(_unset_dram_srfs)
214 /* set the dram out of self refresh mode */
215 #if defined(EBIU_RSTCTL) /* DDR */
216 P0.H = hi(EBIU_RSTCTL);
217 P0.L = lo(EBIU_RSTCTL);
219 BITCLR(R2, 3); /* clear SRREQ bit */
221 #elif defined(EBIU_SDGCTL) /* SDRAM */
223 P0.L = lo(EBIU_SDGCTL); /* release CLKOUT from self-refresh */
224 P0.H = hi(EBIU_SDGCTL);
226 BITSET(R2, 0); /* SCTLE enable CLKOUT */
230 P0.L = lo(EBIU_SDGCTL); /* release SDRAM from self-refresh */
231 P0.H = hi(EBIU_SDGCTL);
233 BITCLR(R2, 24); /* clear SRFS bit */
238 ENDPROC(_unset_dram_srfs)
241 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) || \
242 defined(CONFIG_BF538) || defined(CONFIG_BF539) || defined(CONFIG_BF51x)
248 #if defined(CONFIG_BF54x)
261 ENDPROC(_set_sic_iwr)
263 ENTRY(_test_pll_locked)
271 ENDPROC(_test_pll_locked)
276 [--SP] = ( R7:0, P5:0 );
278 /* Save System MMRs */
284 PM_SYS_PUSH(SIC_IMASK0)
287 PM_SYS_PUSH(SIC_IMASK1)
290 PM_SYS_PUSH(SIC_IMASK2)
293 PM_SYS_PUSH(SIC_IMASK)
296 PM_SYS_PUSH(SIC_IAR0)
297 PM_SYS_PUSH(SIC_IAR1)
298 PM_SYS_PUSH(SIC_IAR2)
301 PM_SYS_PUSH(SIC_IAR3)
304 PM_SYS_PUSH(SIC_IAR4)
305 PM_SYS_PUSH(SIC_IAR5)
306 PM_SYS_PUSH(SIC_IAR6)
309 PM_SYS_PUSH(SIC_IAR7)
312 PM_SYS_PUSH(SIC_IAR8)
313 PM_SYS_PUSH(SIC_IAR9)
314 PM_SYS_PUSH(SIC_IAR10)
315 PM_SYS_PUSH(SIC_IAR11)
322 PM_SYS_PUSH(SIC_IWR0)
325 PM_SYS_PUSH(SIC_IWR1)
328 PM_SYS_PUSH(SIC_IWR2)
332 PM_SYS_PUSH(PINT0_MASK_SET)
333 PM_SYS_PUSH(PINT1_MASK_SET)
334 PM_SYS_PUSH(PINT2_MASK_SET)
335 PM_SYS_PUSH(PINT3_MASK_SET)
336 PM_SYS_PUSH(PINT0_ASSIGN)
337 PM_SYS_PUSH(PINT1_ASSIGN)
338 PM_SYS_PUSH(PINT2_ASSIGN)
339 PM_SYS_PUSH(PINT3_ASSIGN)
340 PM_SYS_PUSH(PINT0_INVERT_SET)
341 PM_SYS_PUSH(PINT1_INVERT_SET)
342 PM_SYS_PUSH(PINT2_INVERT_SET)
343 PM_SYS_PUSH(PINT3_INVERT_SET)
344 PM_SYS_PUSH(PINT0_EDGE_SET)
345 PM_SYS_PUSH(PINT1_EDGE_SET)
346 PM_SYS_PUSH(PINT2_EDGE_SET)
347 PM_SYS_PUSH(PINT3_EDGE_SET)
350 PM_SYS_PUSH(EBIU_AMBCTL0)
351 PM_SYS_PUSH(EBIU_AMBCTL1)
352 PM_SYS_PUSH16(EBIU_AMGCTL)
355 PM_SYS_PUSH(EBIU_MBSCTL)
356 PM_SYS_PUSH(EBIU_MODE)
357 PM_SYS_PUSH(EBIU_FCTL)
361 PM_SYS_PUSH16(PORTCIO_DIR)
362 PM_SYS_PUSH16(PORTCIO_INEN)
363 PM_SYS_PUSH16(PORTCIO)
364 PM_SYS_PUSH16(PORTCIO_FER)
365 PM_SYS_PUSH16(PORTDIO_DIR)
366 PM_SYS_PUSH16(PORTDIO_INEN)
367 PM_SYS_PUSH16(PORTDIO)
368 PM_SYS_PUSH16(PORTDIO_FER)
369 PM_SYS_PUSH16(PORTEIO_DIR)
370 PM_SYS_PUSH16(PORTEIO_INEN)
371 PM_SYS_PUSH16(PORTEIO)
372 PM_SYS_PUSH16(PORTEIO_FER)
378 P0.H = hi(SRAM_BASE_ADDRESS);
379 P0.L = lo(SRAM_BASE_ADDRESS);
381 PM_PUSH(DMEM_CONTROL)
392 PM_PUSH(DCPLB_ADDR10)
393 PM_PUSH(DCPLB_ADDR11)
394 PM_PUSH(DCPLB_ADDR12)
395 PM_PUSH(DCPLB_ADDR13)
396 PM_PUSH(DCPLB_ADDR14)
397 PM_PUSH(DCPLB_ADDR15)
408 PM_PUSH(DCPLB_DATA10)
409 PM_PUSH(DCPLB_DATA11)
410 PM_PUSH(DCPLB_DATA12)
411 PM_PUSH(DCPLB_DATA13)
412 PM_PUSH(DCPLB_DATA14)
413 PM_PUSH(DCPLB_DATA15)
414 PM_PUSH(IMEM_CONTROL)
425 PM_PUSH(ICPLB_ADDR10)
426 PM_PUSH(ICPLB_ADDR11)
427 PM_PUSH(ICPLB_ADDR12)
428 PM_PUSH(ICPLB_ADDR13)
429 PM_PUSH(ICPLB_ADDR14)
430 PM_PUSH(ICPLB_ADDR15)
441 PM_PUSH(ICPLB_DATA10)
442 PM_PUSH(ICPLB_DATA11)
443 PM_PUSH(ICPLB_DATA12)
444 PM_PUSH(ICPLB_DATA13)
445 PM_PUSH(ICPLB_DATA14)
446 PM_PUSH(ICPLB_DATA15)
472 /* Save Core Registers */
474 [--sp] = ( R7:0, P5:0 );
521 /* Save Magic, return address and Stack Pointer */
524 R0.H = 0xDEAD; /* Hibernate Magic */
526 [P0++] = R0; /* Store Hibernate Magic */
527 R0.H = .Lpm_resume_here;
528 R0.L = .Lpm_resume_here;
529 [P0++] = R0; /* Save Return Address */
530 [P0++] = SP; /* Save Stack Pointer */
531 P0.H = _hibernate_mode;
532 P0.L = _hibernate_mode;
534 call (P0); /* Goodbye */
538 /* Restore Core Registers */
585 ( R7 : 0, P5 : 0) = [ SP ++ ];
588 /* Restore Core MMRs */
681 /* Restore System MMRs */
688 PM_SYS_POP16(PORTEIO_FER)
689 PM_SYS_POP16(PORTEIO)
690 PM_SYS_POP16(PORTEIO_INEN)
691 PM_SYS_POP16(PORTEIO_DIR)
692 PM_SYS_POP16(PORTDIO_FER)
693 PM_SYS_POP16(PORTDIO)
694 PM_SYS_POP16(PORTDIO_INEN)
695 PM_SYS_POP16(PORTDIO_DIR)
696 PM_SYS_POP16(PORTCIO_FER)
697 PM_SYS_POP16(PORTCIO)
698 PM_SYS_POP16(PORTCIO_INEN)
699 PM_SYS_POP16(PORTCIO_DIR)
703 PM_SYS_POP(EBIU_FCTL)
704 PM_SYS_POP(EBIU_MODE)
705 PM_SYS_POP(EBIU_MBSCTL)
707 PM_SYS_POP16(EBIU_AMGCTL)
708 PM_SYS_POP(EBIU_AMBCTL1)
709 PM_SYS_POP(EBIU_AMBCTL0)
712 PM_SYS_POP(PINT3_EDGE_SET)
713 PM_SYS_POP(PINT2_EDGE_SET)
714 PM_SYS_POP(PINT1_EDGE_SET)
715 PM_SYS_POP(PINT0_EDGE_SET)
716 PM_SYS_POP(PINT3_INVERT_SET)
717 PM_SYS_POP(PINT2_INVERT_SET)
718 PM_SYS_POP(PINT1_INVERT_SET)
719 PM_SYS_POP(PINT0_INVERT_SET)
720 PM_SYS_POP(PINT3_ASSIGN)
721 PM_SYS_POP(PINT2_ASSIGN)
722 PM_SYS_POP(PINT1_ASSIGN)
723 PM_SYS_POP(PINT0_ASSIGN)
724 PM_SYS_POP(PINT3_MASK_SET)
725 PM_SYS_POP(PINT2_MASK_SET)
726 PM_SYS_POP(PINT1_MASK_SET)
727 PM_SYS_POP(PINT0_MASK_SET)
744 PM_SYS_POP(SIC_IAR11)
745 PM_SYS_POP(SIC_IAR10)
766 PM_SYS_POP(SIC_IMASK)
769 PM_SYS_POP(SIC_IMASK2)
772 PM_SYS_POP(SIC_IMASK1)
775 PM_SYS_POP(SIC_IMASK0)
778 [--sp] = RETI; /* Clear Global Interrupt Disable */
782 ( R7:0, P5:0 ) = [SP++];
784 ENDPROC(_do_hibernate)