Commit 9faf4f08e752ca95d0986a200d48b67b59cde5ef
Committed by
sonic
1 parent
49c2da53b7
Exists in
master
and in
53 other branches
blackfin: bf60x: add resume from hibernate
Add Bf60x resume from hibernate support Signed-off-by: Steven Miao <realmz6@gmail.com> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Bob Liu <lliubbo@gmail.com> Signed-off-by: Sonic Zhang <sonic.adi@gmail.com>
Showing 1 changed file with 46 additions and 0 deletions Side-by-side Diff
arch/blackfin/cpu/initcode.c
... | ... | @@ -509,6 +509,11 @@ |
509 | 509 | return false; |
510 | 510 | |
511 | 511 | #ifdef __ADSPBF60x__ |
512 | + /* resume from hibernate, return false let ddr initialize */ | |
513 | + if ((bfin_read32(DPM0_STAT) & 0xF0) == 0x50) { | |
514 | + serial_putc('b'); | |
515 | + return false; | |
516 | + } | |
512 | 517 | |
513 | 518 | #else /* __ADSPBF60x__ */ |
514 | 519 | |
... | ... | @@ -827,6 +832,7 @@ |
827 | 832 | while (!(bfin_read_DMC0_STAT() & DLLCALDONE)) |
828 | 833 | continue; |
829 | 834 | serial_putc('!'); |
835 | + | |
830 | 836 | #else /* __ADSPBF60x__ */ |
831 | 837 | |
832 | 838 | /* Program the external memory controller before we come out of |
833 | 839 | |
... | ... | @@ -894,7 +900,46 @@ |
894 | 900 | return; |
895 | 901 | |
896 | 902 | serial_putc('b'); |
903 | +#ifdef __ADSPBF60x__ | |
904 | + if (bfin_read32(DPM0_RESTORE0) != 0) { | |
905 | + uint32_t reg = bfin_read_DMC0_CTL(); | |
906 | + reg &= ~0x8; | |
907 | + bfin_write_DMC0_CTL(reg); | |
897 | 908 | |
909 | + while ((bfin_read_DMC0_STAT() & 0x8)) | |
910 | + continue; | |
911 | + while (!(bfin_read_DMC0_STAT() & 0x1)) | |
912 | + continue; | |
913 | + | |
914 | + serial_putc('z'); | |
915 | + uint32_t *hibernate_magic = bfin_read32(DPM0_RESTORE4); | |
916 | + SSYNC(); /* make sure memory controller is done */ | |
917 | + if (hibernate_magic[0] == 0xDEADBEEF) { | |
918 | + serial_putc('c'); | |
919 | + SSYNC(); | |
920 | + bfin_write_EVT15(hibernate_magic[1]); | |
921 | + bfin_write_IMASK(EVT_IVG15); | |
922 | + __asm__ __volatile__ ( | |
923 | + /* load reti early to avoid anomaly 281 */ | |
924 | + "reti = %2;" | |
925 | + /* clear hibernate magic */ | |
926 | + "[%0] = %1;" | |
927 | + /* load stack pointer */ | |
928 | + "SP = [%0 + 8];" | |
929 | + /* lower ourselves from reset ivg to ivg15 */ | |
930 | + "raise 15;" | |
931 | + "nop;nop;nop;" | |
932 | + "rti;" | |
933 | + : | |
934 | + : "p"(hibernate_magic), | |
935 | + "d"(0x2000 /* jump.s 0 */), | |
936 | + "d"(0xffa00000) | |
937 | + ); | |
938 | + } | |
939 | + | |
940 | + | |
941 | + } | |
942 | +#else | |
898 | 943 | /* Are we coming out of hibernate (suspend to memory) ? |
899 | 944 | * The memory layout is: |
900 | 945 | * 0x0: hibernate magic for anomaly 307 (0xDEADBEEF) |
... | ... | @@ -927,6 +972,7 @@ |
927 | 972 | } |
928 | 973 | serial_putc('d'); |
929 | 974 | } |
975 | +#endif | |
930 | 976 | |
931 | 977 | serial_putc('e'); |
932 | 978 | } |