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:4, P5:3);
31 call _test_pll_locked;
46 call _test_pll_locked;
49 (R7:4, P5:3) = [SP++];
54 * This func never returns as it puts the part into hibernate, and
55 * is only called from do_hibernate, so we don't bother saving or
56 * restoring any of the normal C runtime state. When we wake up,
57 * the entry point will be in do_hibernate and not here.
59 * We accept just one argument -- the value to write to VR_CTL.
61 ENTRY(_hibernate_mode)
62 /* Save/setup the regs we need early for minor pipeline optimization */
67 /* Disable all wakeup sources */
75 /* Finally, we climb into our cave to hibernate */
81 ENDPROC(_hibernate_mode)
84 [--SP] = (R7:4, P5:3);
98 call _set_dram_srfs; /* Set SDRAM Self Refresh */
104 W[P0] = R0.l; /* Set Max VCO to SCLK divider */
109 R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
110 W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
115 call _test_pll_locked;
125 R2 = DEPOSIT(R7, R1);
126 W[P0] = R2; /* Set Min Core Voltage */
131 call _test_pll_locked;
136 call _set_sic_iwr; /* Set Awake from IDLE */
142 W[P0] = R0.L; /* Turn CCLK OFF */
146 call _test_pll_locked;
149 R1 = IWR_DISABLE_ALL;
150 R2 = IWR_DISABLE_ALL;
152 call _set_sic_iwr; /* Set Awake from IDLE PLL */
161 call _test_pll_locked;
165 W[P0]= R6; /* Restore CCLK and SCLK divider */
169 w[p0] = R5; /* Restore VCO multiplier */
171 call _test_pll_locked;
173 call _unset_dram_srfs; /* SDRAM Self Refresh Off */
178 (R7:4, P5:3) = [SP++];
180 ENDPROC(_sleep_deeper)
182 ENTRY(_set_dram_srfs)
183 /* set the dram to self refresh mode */
185 #if defined(EBIU_RSTCTL) /* DDR */
186 P0.H = hi(EBIU_RSTCTL);
187 P0.L = lo(EBIU_RSTCTL);
189 BITSET(R2, 3); /* SRREQ enter self-refresh mode */
197 P0.L = lo(EBIU_SDGCTL);
198 P0.H = hi(EBIU_SDGCTL);
199 P1.L = lo(EBIU_SDSTAT);
200 P1.H = hi(EBIU_SDSTAT);
203 BITSET(R2, 24); /* SRFS enter self-refresh mode */
210 cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
214 BITCLR(R2, 0); /* SCTLE disable CLKOUT */
218 ENDPROC(_set_dram_srfs)
220 ENTRY(_unset_dram_srfs)
221 /* set the dram out of self refresh mode */
223 #if defined(EBIU_RSTCTL) /* DDR */
224 P0.H = hi(EBIU_RSTCTL);
225 P0.L = lo(EBIU_RSTCTL);
227 BITCLR(R2, 3); /* clear SRREQ bit */
229 #elif defined(EBIU_SDGCTL) /* SDRAM */
230 /* release CLKOUT from self-refresh */
231 P0.L = lo(EBIU_SDGCTL);
232 P0.H = hi(EBIU_SDGCTL);
235 BITSET(R2, 0); /* SCTLE enable CLKOUT */
239 /* release SDRAM from self-refresh */
241 BITCLR(R2, 24); /* clear SRFS bit */
247 ENDPROC(_unset_dram_srfs)
251 P0.H = hi(SYSMMR_BASE);
252 P0.L = lo(SYSMMR_BASE);
253 [P0 + (SIC_IWR0 - SYSMMR_BASE)] = R0;
254 [P0 + (SIC_IWR1 - SYSMMR_BASE)] = R1;
256 [P0 + (SIC_IWR2 - SYSMMR_BASE)] = R2;
266 ENDPROC(_set_sic_iwr)
268 ENTRY(_test_pll_locked)
276 ENDPROC(_test_pll_locked)
295 #define PM_REGSET0 R7:7
296 #define PM_REGSET1 R7:6
297 #define PM_REGSET2 R7:5
298 #define PM_REGSET3 R7:4
299 #define PM_REGSET4 R7:3
300 #define PM_REGSET5 R7:2
301 #define PM_REGSET6 R7:1
302 #define PM_REGSET7 R7:0
303 #define PM_REGSET8 R7:0, P5:5
304 #define PM_REGSET9 R7:0, P5:4
305 #define PM_REGSET10 R7:0, P5:3
306 #define PM_REGSET11 R7:0, P5:2
307 #define PM_REGSET12 R7:0, P5:1
308 #define PM_REGSET13 R7:0, P5:0
310 #define _PM_PUSH(n, x, w, base) PM_REG##n = w[FP + ((x) - (base))];
311 #define _PM_POP(n, x, w, base) w[FP + ((x) - (base))] = PM_REG##n;
312 #define PM_PUSH_SYNC(n) [--sp] = (PM_REGSET##n);
313 #define PM_POP_SYNC(n) (PM_REGSET##n) = [sp++];
314 #define PM_PUSH(n, x) PM_REG##n = [FP++];
315 #define PM_POP(n, x) [FP--] = PM_REG##n;
316 #define PM_CORE_PUSH(n, x) _PM_PUSH(n, x, , COREMMR_BASE)
317 #define PM_CORE_POP(n, x) _PM_POP(n, x, , COREMMR_BASE)
318 #define PM_SYS_PUSH(n, x) _PM_PUSH(n, x, , SYSMMR_BASE)
319 #define PM_SYS_POP(n, x) _PM_POP(n, x, , SYSMMR_BASE)
320 #define PM_SYS_PUSH16(n, x) _PM_PUSH(n, x, w, SYSMMR_BASE)
321 #define PM_SYS_POP16(n, x) _PM_POP(n, x, w, SYSMMR_BASE)
325 * Save the core regs early so we can blow them away when
326 * saving/restoring MMR states
328 [--sp] = (R7:0, P5:0);
363 /* We can't push RETI directly as that'll change IPEND[4] */
374 /* Save first func arg in M3 */
377 /* Save system MMRs */
378 FP.H = hi(SYSMMR_BASE);
379 FP.L = lo(SYSMMR_BASE);
382 PM_SYS_PUSH(0, SIC_IMASK0)
383 PM_SYS_PUSH(1, SIC_IMASK1)
385 PM_SYS_PUSH(2, SIC_IMASK2)
388 PM_SYS_PUSH(0, SIC_IMASK)
391 PM_SYS_PUSH(3, SIC_IAR0)
392 PM_SYS_PUSH(4, SIC_IAR1)
393 PM_SYS_PUSH(5, SIC_IAR2)
396 PM_SYS_PUSH(6, SIC_IAR3)
399 PM_SYS_PUSH(7, SIC_IAR4)
400 PM_SYS_PUSH(8, SIC_IAR5)
401 PM_SYS_PUSH(9, SIC_IAR6)
404 PM_SYS_PUSH(10, SIC_IAR7)
407 PM_SYS_PUSH(11, SIC_IAR8)
408 PM_SYS_PUSH(12, SIC_IAR9)
409 PM_SYS_PUSH(13, SIC_IAR10)
413 PM_SYS_PUSH(0, SIC_IAR11)
417 PM_SYS_PUSH(1, SIC_IWR)
420 PM_SYS_PUSH(1, SIC_IWR0)
423 PM_SYS_PUSH(2, SIC_IWR1)
426 PM_SYS_PUSH(3, SIC_IWR2)
430 PM_SYS_PUSH(4, PINT0_MASK_SET)
431 PM_SYS_PUSH(5, PINT1_MASK_SET)
432 PM_SYS_PUSH(6, PINT2_MASK_SET)
433 PM_SYS_PUSH(7, PINT3_MASK_SET)
434 PM_SYS_PUSH(8, PINT0_ASSIGN)
435 PM_SYS_PUSH(9, PINT1_ASSIGN)
436 PM_SYS_PUSH(10, PINT2_ASSIGN)
437 PM_SYS_PUSH(11, PINT3_ASSIGN)
438 PM_SYS_PUSH(12, PINT0_INVERT_SET)
439 PM_SYS_PUSH(13, PINT1_INVERT_SET)
441 PM_SYS_PUSH(0, PINT2_INVERT_SET)
442 PM_SYS_PUSH(1, PINT3_INVERT_SET)
443 PM_SYS_PUSH(2, PINT0_EDGE_SET)
444 PM_SYS_PUSH(3, PINT1_EDGE_SET)
445 PM_SYS_PUSH(4, PINT2_EDGE_SET)
446 PM_SYS_PUSH(5, PINT3_EDGE_SET)
449 PM_SYS_PUSH16(6, SYSCR)
451 PM_SYS_PUSH16(7, EBIU_AMGCTL)
452 PM_SYS_PUSH(8, EBIU_AMBCTL0)
453 PM_SYS_PUSH(9, EBIU_AMBCTL1)
455 PM_SYS_PUSH(10, EBIU_MBSCTL)
456 PM_SYS_PUSH(11, EBIU_MODE)
457 PM_SYS_PUSH(12, EBIU_FCTL)
464 I0.H = hi(COREMMR_BASE);
465 I0.L = lo(COREMMR_BASE);
473 I1.L = lo(DCPLB_ADDR0);
474 I2.L = lo(DCPLB_DATA0);
475 I3.L = lo(ICPLB_ADDR0);
476 B0.L = lo(ICPLB_DATA0);
483 PM_PUSH(0, DCPLB_ADDR0)
484 PM_PUSH(1, DCPLB_ADDR1)
485 PM_PUSH(2, DCPLB_ADDR2)
486 PM_PUSH(3, DCPLB_ADDR3)
487 PM_PUSH(4, DCPLB_ADDR4)
488 PM_PUSH(5, DCPLB_ADDR5)
489 PM_PUSH(6, DCPLB_ADDR6)
490 PM_PUSH(7, DCPLB_ADDR7)
491 PM_PUSH(8, DCPLB_ADDR8)
492 PM_PUSH(9, DCPLB_ADDR9)
493 PM_PUSH(10, DCPLB_ADDR10)
494 PM_PUSH(11, DCPLB_ADDR11)
495 PM_PUSH(12, DCPLB_ADDR12)
496 PM_PUSH(13, DCPLB_ADDR13)
498 PM_PUSH(0, DCPLB_ADDR14)
499 PM_PUSH(1, DCPLB_ADDR15)
503 PM_PUSH(2, DCPLB_DATA0)
504 PM_PUSH(3, DCPLB_DATA1)
505 PM_PUSH(4, DCPLB_DATA2)
506 PM_PUSH(5, DCPLB_DATA3)
507 PM_PUSH(6, DCPLB_DATA4)
508 PM_PUSH(7, DCPLB_DATA5)
509 PM_PUSH(8, DCPLB_DATA6)
510 PM_PUSH(9, DCPLB_DATA7)
511 PM_PUSH(10, DCPLB_DATA8)
512 PM_PUSH(11, DCPLB_DATA9)
513 PM_PUSH(12, DCPLB_DATA10)
514 PM_PUSH(13, DCPLB_DATA11)
516 PM_PUSH(0, DCPLB_DATA12)
517 PM_PUSH(1, DCPLB_DATA13)
518 PM_PUSH(2, DCPLB_DATA14)
519 PM_PUSH(3, DCPLB_DATA15)
523 PM_PUSH(4, ICPLB_ADDR0)
524 PM_PUSH(5, ICPLB_ADDR1)
525 PM_PUSH(6, ICPLB_ADDR2)
526 PM_PUSH(7, ICPLB_ADDR3)
527 PM_PUSH(8, ICPLB_ADDR4)
528 PM_PUSH(9, ICPLB_ADDR5)
529 PM_PUSH(10, ICPLB_ADDR6)
530 PM_PUSH(11, ICPLB_ADDR7)
531 PM_PUSH(12, ICPLB_ADDR8)
532 PM_PUSH(13, ICPLB_ADDR9)
534 PM_PUSH(0, ICPLB_ADDR10)
535 PM_PUSH(1, ICPLB_ADDR11)
536 PM_PUSH(2, ICPLB_ADDR12)
537 PM_PUSH(3, ICPLB_ADDR13)
538 PM_PUSH(4, ICPLB_ADDR14)
539 PM_PUSH(5, ICPLB_ADDR15)
543 PM_PUSH(6, ICPLB_DATA0)
544 PM_PUSH(7, ICPLB_DATA1)
545 PM_PUSH(8, ICPLB_DATA2)
546 PM_PUSH(9, ICPLB_DATA3)
547 PM_PUSH(10, ICPLB_DATA4)
548 PM_PUSH(11, ICPLB_DATA5)
549 PM_PUSH(12, ICPLB_DATA6)
550 PM_PUSH(13, ICPLB_DATA7)
552 PM_PUSH(0, ICPLB_DATA8)
553 PM_PUSH(1, ICPLB_DATA9)
554 PM_PUSH(2, ICPLB_DATA10)
555 PM_PUSH(3, ICPLB_DATA11)
556 PM_PUSH(4, ICPLB_DATA12)
557 PM_PUSH(5, ICPLB_DATA13)
558 PM_PUSH(6, ICPLB_DATA14)
559 PM_PUSH(7, ICPLB_DATA15)
594 /* Misc non-contiguous registers */
596 PM_CORE_PUSH(0, DMEM_CONTROL);
597 PM_CORE_PUSH(1, IMEM_CONTROL);
598 PM_CORE_PUSH(2, TBUFCTL);
601 /* Setup args to hibernate mode early for pipeline optimization */
603 P1.H = _hibernate_mode;
604 P1.L = _hibernate_mode;
606 /* Save Magic, return address and Stack Pointer */
608 R1.H = 0xDEAD; /* Hibernate Magic */
610 R2.H = .Lpm_resume_here;
611 R2.L = .Lpm_resume_here;
612 [P0++] = R1; /* Store Hibernate Magic */
613 [P0++] = R2; /* Save Return Address */
614 [P0++] = SP; /* Save Stack Pointer */
616 /* Must use an indirect call as we need to jump to L1 */
617 call (P1); /* Goodbye */
621 /* Restore Core MMRs */
622 I0.H = hi(COREMMR_BASE);
623 I0.L = lo(COREMMR_BASE);
631 I1.L = lo(DCPLB_ADDR15);
632 I2.L = lo(DCPLB_DATA15);
633 I3.L = lo(ICPLB_ADDR15);
634 B0.L = lo(ICPLB_DATA15);
639 /* Misc non-contiguous registers */
642 PM_CORE_POP(2, TBUFCTL)
643 PM_CORE_POP(1, IMEM_CONTROL)
644 PM_CORE_POP(0, DMEM_CONTROL)
658 FP += -4; /* IPEND */
681 PM_POP(7, ICPLB_DATA15)
682 PM_POP(6, ICPLB_DATA14)
683 PM_POP(5, ICPLB_DATA13)
684 PM_POP(4, ICPLB_DATA12)
685 PM_POP(3, ICPLB_DATA11)
686 PM_POP(2, ICPLB_DATA10)
687 PM_POP(1, ICPLB_DATA9)
688 PM_POP(0, ICPLB_DATA8)
690 PM_POP(13, ICPLB_DATA7)
691 PM_POP(12, ICPLB_DATA6)
692 PM_POP(11, ICPLB_DATA5)
693 PM_POP(10, ICPLB_DATA4)
694 PM_POP(9, ICPLB_DATA3)
695 PM_POP(8, ICPLB_DATA2)
696 PM_POP(7, ICPLB_DATA1)
697 PM_POP(6, ICPLB_DATA0)
701 PM_POP(5, ICPLB_ADDR15)
702 PM_POP(4, ICPLB_ADDR14)
703 PM_POP(3, ICPLB_ADDR13)
704 PM_POP(2, ICPLB_ADDR12)
705 PM_POP(1, ICPLB_ADDR11)
706 PM_POP(0, ICPLB_ADDR10)
708 PM_POP(13, ICPLB_ADDR9)
709 PM_POP(12, ICPLB_ADDR8)
710 PM_POP(11, ICPLB_ADDR7)
711 PM_POP(10, ICPLB_ADDR6)
712 PM_POP(9, ICPLB_ADDR5)
713 PM_POP(8, ICPLB_ADDR4)
714 PM_POP(7, ICPLB_ADDR3)
715 PM_POP(6, ICPLB_ADDR2)
716 PM_POP(5, ICPLB_ADDR1)
717 PM_POP(4, ICPLB_ADDR0)
721 PM_POP(3, DCPLB_DATA15)
722 PM_POP(2, DCPLB_DATA14)
723 PM_POP(1, DCPLB_DATA13)
724 PM_POP(0, DCPLB_DATA12)
726 PM_POP(13, DCPLB_DATA11)
727 PM_POP(12, DCPLB_DATA10)
728 PM_POP(11, DCPLB_DATA9)
729 PM_POP(10, DCPLB_DATA8)
730 PM_POP(9, DCPLB_DATA7)
731 PM_POP(8, DCPLB_DATA6)
732 PM_POP(7, DCPLB_DATA5)
733 PM_POP(6, DCPLB_DATA4)
734 PM_POP(5, DCPLB_DATA3)
735 PM_POP(4, DCPLB_DATA2)
736 PM_POP(3, DCPLB_DATA1)
737 PM_POP(2, DCPLB_DATA0)
741 PM_POP(1, DCPLB_ADDR15)
742 PM_POP(0, DCPLB_ADDR14)
744 PM_POP(13, DCPLB_ADDR13)
745 PM_POP(12, DCPLB_ADDR12)
746 PM_POP(11, DCPLB_ADDR11)
747 PM_POP(10, DCPLB_ADDR10)
748 PM_POP(9, DCPLB_ADDR9)
749 PM_POP(8, DCPLB_ADDR8)
750 PM_POP(7, DCPLB_ADDR7)
751 PM_POP(6, DCPLB_ADDR6)
752 PM_POP(5, DCPLB_ADDR5)
753 PM_POP(4, DCPLB_ADDR4)
754 PM_POP(3, DCPLB_ADDR3)
755 PM_POP(2, DCPLB_ADDR2)
756 PM_POP(1, DCPLB_ADDR1)
757 PM_POP(0, DCPLB_ADDR0)
759 /* Restore System MMRs */
760 FP.H = hi(SYSMMR_BASE);
761 FP.L = lo(SYSMMR_BASE);
765 PM_SYS_POP(12, EBIU_FCTL)
766 PM_SYS_POP(11, EBIU_MODE)
767 PM_SYS_POP(10, EBIU_MBSCTL)
771 PM_SYS_POP(9, EBIU_AMBCTL1)
772 PM_SYS_POP(8, EBIU_AMBCTL0)
773 PM_SYS_POP16(7, EBIU_AMGCTL)
775 PM_SYS_POP16(6, SYSCR)
778 PM_SYS_POP(5, PINT3_EDGE_SET)
779 PM_SYS_POP(4, PINT2_EDGE_SET)
780 PM_SYS_POP(3, PINT1_EDGE_SET)
781 PM_SYS_POP(2, PINT0_EDGE_SET)
782 PM_SYS_POP(1, PINT3_INVERT_SET)
783 PM_SYS_POP(0, PINT2_INVERT_SET)
785 PM_SYS_POP(13, PINT1_INVERT_SET)
786 PM_SYS_POP(12, PINT0_INVERT_SET)
787 PM_SYS_POP(11, PINT3_ASSIGN)
788 PM_SYS_POP(10, PINT2_ASSIGN)
789 PM_SYS_POP(9, PINT1_ASSIGN)
790 PM_SYS_POP(8, PINT0_ASSIGN)
791 PM_SYS_POP(7, PINT3_MASK_SET)
792 PM_SYS_POP(6, PINT2_MASK_SET)
793 PM_SYS_POP(5, PINT1_MASK_SET)
794 PM_SYS_POP(4, PINT0_MASK_SET)
798 PM_SYS_POP(3, SIC_IWR2)
801 PM_SYS_POP(2, SIC_IWR1)
804 PM_SYS_POP(1, SIC_IWR0)
807 PM_SYS_POP(1, SIC_IWR)
811 PM_SYS_POP(0, SIC_IAR11)
815 PM_SYS_POP(13, SIC_IAR10)
816 PM_SYS_POP(12, SIC_IAR9)
817 PM_SYS_POP(11, SIC_IAR8)
820 PM_SYS_POP(10, SIC_IAR7)
823 PM_SYS_POP(9, SIC_IAR6)
824 PM_SYS_POP(8, SIC_IAR5)
825 PM_SYS_POP(7, SIC_IAR4)
828 PM_SYS_POP(6, SIC_IAR3)
831 PM_SYS_POP(5, SIC_IAR2)
832 PM_SYS_POP(4, SIC_IAR1)
833 PM_SYS_POP(3, SIC_IAR0)
837 PM_SYS_POP(2, SIC_IMASK2)
839 PM_SYS_POP(1, SIC_IMASK1)
840 PM_SYS_POP(0, SIC_IMASK0)
842 PM_SYS_POP(0, SIC_IMASK)
845 /* Restore Core Registers */
888 (R7:0, P5:0) = [sp++];
890 [--sp] = RETI; /* Clear Global Interrupt Disable */
894 ENDPROC(_do_hibernate)