dpmc_modes.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*
  2. * Copyright 2004-2008 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #include <linux/linkage.h>
  7. #include <asm/blackfin.h>
  8. #include <mach/irq.h>
  9. #include <asm/dpmc.h>
  10. .section .l1.text
  11. ENTRY(_sleep_mode)
  12. [--SP] = (R7:4, P5:3);
  13. [--SP] = RETS;
  14. call _set_sic_iwr;
  15. P0.H = hi(PLL_CTL);
  16. P0.L = lo(PLL_CTL);
  17. R1 = W[P0](z);
  18. BITSET (R1, 3);
  19. W[P0] = R1.L;
  20. CLI R2;
  21. SSYNC;
  22. IDLE;
  23. STI R2;
  24. call _test_pll_locked;
  25. R0 = IWR_ENABLE(0);
  26. R1 = IWR_DISABLE_ALL;
  27. R2 = IWR_DISABLE_ALL;
  28. call _set_sic_iwr;
  29. P0.H = hi(PLL_CTL);
  30. P0.L = lo(PLL_CTL);
  31. R7 = w[p0](z);
  32. BITCLR (R7, 3);
  33. BITCLR (R7, 5);
  34. w[p0] = R7.L;
  35. IDLE;
  36. bfin_init_pm_bench_cycles;
  37. call _test_pll_locked;
  38. RETS = [SP++];
  39. (R7:4, P5:3) = [SP++];
  40. RTS;
  41. ENDPROC(_sleep_mode)
  42. /*
  43. * This func never returns as it puts the part into hibernate, and
  44. * is only called from do_hibernate, so we don't bother saving or
  45. * restoring any of the normal C runtime state. When we wake up,
  46. * the entry point will be in do_hibernate and not here.
  47. *
  48. * We accept just one argument -- the value to write to VR_CTL.
  49. */
  50. ENTRY(_hibernate_mode)
  51. /* Save/setup the regs we need early for minor pipeline optimization */
  52. R4 = R0;
  53. P3.H = hi(VR_CTL);
  54. P3.L = lo(VR_CTL);
  55. /* Disable all wakeup sources */
  56. R0 = IWR_DISABLE_ALL;
  57. R1 = IWR_DISABLE_ALL;
  58. R2 = IWR_DISABLE_ALL;
  59. call _set_sic_iwr;
  60. call _set_dram_srfs;
  61. SSYNC;
  62. /* Finally, we climb into our cave to hibernate */
  63. W[P3] = R4.L;
  64. bfin_init_pm_bench_cycles;
  65. CLI R2;
  66. IDLE;
  67. .Lforever:
  68. jump .Lforever;
  69. ENDPROC(_hibernate_mode)
  70. ENTRY(_sleep_deeper)
  71. [--SP] = (R7:4, P5:3);
  72. [--SP] = RETS;
  73. CLI R4;
  74. P3 = R0;
  75. P4 = R1;
  76. P5 = R2;
  77. R0 = IWR_ENABLE(0);
  78. R1 = IWR_DISABLE_ALL;
  79. R2 = IWR_DISABLE_ALL;
  80. call _set_sic_iwr;
  81. call _set_dram_srfs; /* Set SDRAM Self Refresh */
  82. P0.H = hi(PLL_DIV);
  83. P0.L = lo(PLL_DIV);
  84. R6 = W[P0](z);
  85. R0.L = 0xF;
  86. W[P0] = R0.l; /* Set Max VCO to SCLK divider */
  87. P0.H = hi(PLL_CTL);
  88. P0.L = lo(PLL_CTL);
  89. R5 = W[P0](z);
  90. R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
  91. W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
  92. SSYNC;
  93. IDLE;
  94. call _test_pll_locked;
  95. P0.H = hi(VR_CTL);
  96. P0.L = lo(VR_CTL);
  97. R7 = W[P0](z);
  98. R1 = 0x6;
  99. R1 <<= 16;
  100. R2 = 0x0404(Z);
  101. R1 = R1|R2;
  102. R2 = DEPOSIT(R7, R1);
  103. W[P0] = R2; /* Set Min Core Voltage */
  104. SSYNC;
  105. IDLE;
  106. call _test_pll_locked;
  107. R0 = P3;
  108. R1 = P4;
  109. R3 = P5;
  110. call _set_sic_iwr; /* Set Awake from IDLE */
  111. P0.H = hi(PLL_CTL);
  112. P0.L = lo(PLL_CTL);
  113. R0 = W[P0](z);
  114. BITSET (R0, 3);
  115. W[P0] = R0.L; /* Turn CCLK OFF */
  116. SSYNC;
  117. IDLE;
  118. call _test_pll_locked;
  119. R0 = IWR_ENABLE(0);
  120. R1 = IWR_DISABLE_ALL;
  121. R2 = IWR_DISABLE_ALL;
  122. call _set_sic_iwr; /* Set Awake from IDLE PLL */
  123. P0.H = hi(VR_CTL);
  124. P0.L = lo(VR_CTL);
  125. W[P0]= R7;
  126. SSYNC;
  127. IDLE;
  128. bfin_init_pm_bench_cycles;
  129. call _test_pll_locked;
  130. P0.H = hi(PLL_DIV);
  131. P0.L = lo(PLL_DIV);
  132. W[P0]= R6; /* Restore CCLK and SCLK divider */
  133. P0.H = hi(PLL_CTL);
  134. P0.L = lo(PLL_CTL);
  135. w[p0] = R5; /* Restore VCO multiplier */
  136. IDLE;
  137. call _test_pll_locked;
  138. call _unset_dram_srfs; /* SDRAM Self Refresh Off */
  139. STI R4;
  140. RETS = [SP++];
  141. (R7:4, P5:3) = [SP++];
  142. RTS;
  143. ENDPROC(_sleep_deeper)
  144. ENTRY(_set_dram_srfs)
  145. /* set the dram to self refresh mode */
  146. SSYNC;
  147. #if defined(EBIU_RSTCTL) /* DDR */
  148. P0.H = hi(EBIU_RSTCTL);
  149. P0.L = lo(EBIU_RSTCTL);
  150. R2 = [P0];
  151. BITSET(R2, 3); /* SRREQ enter self-refresh mode */
  152. [P0] = R2;
  153. SSYNC;
  154. 1:
  155. R2 = [P0];
  156. CC = BITTST(R2, 4);
  157. if !CC JUMP 1b;
  158. #else /* SDRAM */
  159. P0.L = lo(EBIU_SDGCTL);
  160. P0.H = hi(EBIU_SDGCTL);
  161. P1.L = lo(EBIU_SDSTAT);
  162. P1.H = hi(EBIU_SDSTAT);
  163. R2 = [P0];
  164. BITSET(R2, 24); /* SRFS enter self-refresh mode */
  165. [P0] = R2;
  166. SSYNC;
  167. 1:
  168. R2 = w[P1];
  169. SSYNC;
  170. cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
  171. if !cc jump 1b;
  172. R2 = [P0];
  173. BITCLR(R2, 0); /* SCTLE disable CLKOUT */
  174. [P0] = R2;
  175. #endif
  176. RTS;
  177. ENDPROC(_set_dram_srfs)
  178. ENTRY(_unset_dram_srfs)
  179. /* set the dram out of self refresh mode */
  180. #if defined(EBIU_RSTCTL) /* DDR */
  181. P0.H = hi(EBIU_RSTCTL);
  182. P0.L = lo(EBIU_RSTCTL);
  183. R2 = [P0];
  184. BITCLR(R2, 3); /* clear SRREQ bit */
  185. [P0] = R2;
  186. #elif defined(EBIU_SDGCTL) /* SDRAM */
  187. /* release CLKOUT from self-refresh */
  188. P0.L = lo(EBIU_SDGCTL);
  189. P0.H = hi(EBIU_SDGCTL);
  190. R2 = [P0];
  191. BITSET(R2, 0); /* SCTLE enable CLKOUT */
  192. [P0] = R2
  193. SSYNC;
  194. /* release SDRAM from self-refresh */
  195. R2 = [P0];
  196. BITCLR(R2, 24); /* clear SRFS bit */
  197. [P0] = R2
  198. #endif
  199. SSYNC;
  200. RTS;
  201. ENDPROC(_unset_dram_srfs)
  202. ENTRY(_set_sic_iwr)
  203. #ifdef SIC_IWR0
  204. P0.H = hi(SYSMMR_BASE);
  205. P0.L = lo(SYSMMR_BASE);
  206. [P0 + (SIC_IWR0 - SYSMMR_BASE)] = R0;
  207. [P0 + (SIC_IWR1 - SYSMMR_BASE)] = R1;
  208. # ifdef SIC_IWR2
  209. [P0 + (SIC_IWR2 - SYSMMR_BASE)] = R2;
  210. # endif
  211. #else
  212. P0.H = hi(SIC_IWR);
  213. P0.L = lo(SIC_IWR);
  214. [P0] = R0;
  215. #endif
  216. SSYNC;
  217. RTS;
  218. ENDPROC(_set_sic_iwr)
  219. ENTRY(_test_pll_locked)
  220. P0.H = hi(PLL_STAT);
  221. P0.L = lo(PLL_STAT);
  222. 1:
  223. R0 = W[P0] (Z);
  224. CC = BITTST(R0,5);
  225. IF !CC JUMP 1b;
  226. RTS;
  227. ENDPROC(_test_pll_locked)
  228. .section .text
  229. ENTRY(_do_hibernate)
  230. bfin_cpu_reg_save;
  231. bfin_sys_mmr_save;
  232. bfin_core_mmr_save;
  233. /* Setup args to hibernate mode early for pipeline optimization */
  234. R0 = M3;
  235. P1.H = _hibernate_mode;
  236. P1.L = _hibernate_mode;
  237. /* Save Magic, return address and Stack Pointer */
  238. P0 = 0;
  239. R1.H = 0xDEAD; /* Hibernate Magic */
  240. R1.L = 0xBEEF;
  241. R2.H = .Lpm_resume_here;
  242. R2.L = .Lpm_resume_here;
  243. [P0++] = R1; /* Store Hibernate Magic */
  244. [P0++] = R2; /* Save Return Address */
  245. [P0++] = SP; /* Save Stack Pointer */
  246. /* Must use an indirect call as we need to jump to L1 */
  247. call (P1); /* Goodbye */
  248. .Lpm_resume_here:
  249. bfin_core_mmr_restore;
  250. bfin_sys_mmr_restore;
  251. bfin_cpu_reg_restore;
  252. [--sp] = RETI; /* Clear Global Interrupt Disable */
  253. SP += 4;
  254. RTS;
  255. ENDPROC(_do_hibernate)