dpmc.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /*
  2. * File: arch/blackfin/mach-common/dpmc.S
  3. * Based on:
  4. * Author: LG Soft India
  5. *
  6. * Created: ?
  7. * Description: Watchdog Timer APIs
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/linkage.h>
  30. #include <asm/blackfin.h>
  31. #include <asm/mach/irq.h>
  32. .text
  33. #if !defined(CONFIG_BF561)
  34. .section .l1.text
  35. ENTRY(_sleep_mode)
  36. [--SP] = ( R7:0, P5:0 );
  37. [--SP] = RETS;
  38. call _set_sic_iwr;
  39. R0 = 0xFFFF (Z);
  40. call _set_rtc_istat;
  41. P0.H = hi(PLL_CTL);
  42. P0.L = lo(PLL_CTL);
  43. R1 = W[P0](z);
  44. BITSET (R1, 3);
  45. W[P0] = R1.L;
  46. CLI R2;
  47. SSYNC;
  48. IDLE;
  49. STI R2;
  50. call _test_pll_locked;
  51. R0 = IWR_ENABLE(0);
  52. R1 = IWR_DISABLE_ALL;
  53. R2 = IWR_DISABLE_ALL;
  54. call _set_sic_iwr;
  55. P0.H = hi(PLL_CTL);
  56. P0.L = lo(PLL_CTL);
  57. R7 = w[p0](z);
  58. BITCLR (R7, 3);
  59. BITCLR (R7, 5);
  60. w[p0] = R7.L;
  61. IDLE;
  62. call _test_pll_locked;
  63. RETS = [SP++];
  64. ( R7:0, P5:0 ) = [SP++];
  65. RTS;
  66. ENTRY(_hibernate_mode)
  67. [--SP] = ( R7:0, P5:0 );
  68. [--SP] = RETS;
  69. call _set_sic_iwr;
  70. R0 = 0xFFFF (Z);
  71. call _set_rtc_istat;
  72. P0.H = hi(VR_CTL);
  73. P0.L = lo(VR_CTL);
  74. R1 = W[P0](z);
  75. BITSET (R1, 8);
  76. BITCLR (R1, 0);
  77. BITCLR (R1, 1);
  78. W[P0] = R1.L;
  79. SSYNC;
  80. CLI R2;
  81. IDLE;
  82. /* Actually, adding anything may not be necessary...SDRAM contents
  83. * are lost
  84. */
  85. ENTRY(_deep_sleep)
  86. [--SP] = ( R7:0, P5:0 );
  87. [--SP] = RETS;
  88. CLI R4;
  89. R0 = IWR_ENABLE(0);
  90. R1 = IWR_DISABLE_ALL;
  91. R2 = IWR_DISABLE_ALL;
  92. call _set_sic_iwr;
  93. call _set_dram_srfs;
  94. /* Clear all the interrupts,bits sticky */
  95. R0 = 0xFFFF (Z);
  96. call _set_rtc_istat
  97. P0.H = hi(PLL_CTL);
  98. P0.L = lo(PLL_CTL);
  99. R0 = W[P0](z);
  100. BITSET (R0, 5);
  101. W[P0] = R0.L;
  102. call _test_pll_locked;
  103. SSYNC;
  104. IDLE;
  105. call _unset_dram_srfs;
  106. call _test_pll_locked;
  107. R0 = IWR_ENABLE(0);
  108. R1 = IWR_DISABLE_ALL;
  109. R2 = IWR_DISABLE_ALL;
  110. call _set_sic_iwr;
  111. P0.H = hi(PLL_CTL);
  112. P0.L = lo(PLL_CTL);
  113. R0 = w[p0](z);
  114. BITCLR (R0, 3);
  115. BITCLR (R0, 5);
  116. BITCLR (R0, 8);
  117. w[p0] = R0;
  118. IDLE;
  119. call _test_pll_locked;
  120. STI R4;
  121. RETS = [SP++];
  122. ( R7:0, P5:0 ) = [SP++];
  123. RTS;
  124. ENTRY(_sleep_deeper)
  125. [--SP] = ( R7:0, P5:0 );
  126. [--SP] = RETS;
  127. CLI R4;
  128. P3 = R0;
  129. P4 = R1;
  130. P5 = R2;
  131. R0 = IWR_ENABLE(0);
  132. R1 = IWR_DISABLE_ALL;
  133. R2 = IWR_DISABLE_ALL;
  134. call _set_sic_iwr;
  135. call _set_dram_srfs; /* Set SDRAM Self Refresh */
  136. /* Clear all the interrupts,bits sticky */
  137. R0 = 0xFFFF (Z);
  138. call _set_rtc_istat;
  139. P0.H = hi(PLL_DIV);
  140. P0.L = lo(PLL_DIV);
  141. R6 = W[P0](z);
  142. R0.L = 0xF;
  143. W[P0] = R0.l; /* Set Max VCO to SCLK divider */
  144. P0.H = hi(PLL_CTL);
  145. P0.L = lo(PLL_CTL);
  146. R5 = W[P0](z);
  147. R0.L = (CONFIG_MIN_VCO_HZ/CONFIG_CLKIN_HZ) << 9;
  148. W[P0] = R0.l; /* Set Min CLKIN to VCO multiplier */
  149. SSYNC;
  150. IDLE;
  151. call _test_pll_locked;
  152. P0.H = hi(VR_CTL);
  153. P0.L = lo(VR_CTL);
  154. R7 = W[P0](z);
  155. R1 = 0x6;
  156. R1 <<= 16;
  157. R2 = 0x0404(Z);
  158. R1 = R1|R2;
  159. R2 = DEPOSIT(R7, R1);
  160. W[P0] = R2; /* Set Min Core Voltage */
  161. SSYNC;
  162. IDLE;
  163. call _test_pll_locked;
  164. R0 = P3;
  165. R1 = P4;
  166. R3 = P5;
  167. call _set_sic_iwr; /* Set Awake from IDLE */
  168. P0.H = hi(PLL_CTL);
  169. P0.L = lo(PLL_CTL);
  170. R0 = W[P0](z);
  171. BITSET (R0, 3);
  172. W[P0] = R0.L; /* Turn CCLK OFF */
  173. SSYNC;
  174. IDLE;
  175. call _test_pll_locked;
  176. R0 = IWR_ENABLE(0);
  177. R1 = IWR_DISABLE_ALL;
  178. R2 = IWR_DISABLE_ALL;
  179. call _set_sic_iwr; /* Set Awake from IDLE PLL */
  180. P0.H = hi(VR_CTL);
  181. P0.L = lo(VR_CTL);
  182. W[P0]= R7;
  183. SSYNC;
  184. IDLE;
  185. call _test_pll_locked;
  186. P0.H = hi(PLL_DIV);
  187. P0.L = lo(PLL_DIV);
  188. W[P0]= R6; /* Restore CCLK and SCLK divider */
  189. P0.H = hi(PLL_CTL);
  190. P0.L = lo(PLL_CTL);
  191. w[p0] = R5; /* Restore VCO multiplier */
  192. IDLE;
  193. call _test_pll_locked;
  194. call _unset_dram_srfs; /* SDRAM Self Refresh Off */
  195. STI R4;
  196. RETS = [SP++];
  197. ( R7:0, P5:0 ) = [SP++];
  198. RTS;
  199. ENTRY(_set_dram_srfs)
  200. /* set the dram to self refresh mode */
  201. #if defined(CONFIG_BF54x)
  202. P0.H = hi(EBIU_RSTCTL);
  203. P0.L = lo(EBIU_RSTCTL);
  204. R2 = [P0];
  205. R3.H = hi(SRREQ);
  206. R3.L = lo(SRREQ);
  207. #else
  208. P0.H = hi(EBIU_SDGCTL);
  209. P0.L = lo(EBIU_SDGCTL);
  210. R2 = [P0];
  211. R3.H = hi(SRFS);
  212. R3.L = lo(SRFS);
  213. #endif
  214. R2 = R2|R3;
  215. [P0] = R2;
  216. ssync;
  217. #if defined(CONFIG_BF54x)
  218. .LSRR_MODE:
  219. R2 = [P0];
  220. CC = BITTST(R2, 4);
  221. if !CC JUMP .LSRR_MODE;
  222. #endif
  223. RTS;
  224. ENTRY(_unset_dram_srfs)
  225. /* set the dram out of self refresh mode */
  226. #if defined(CONFIG_BF54x)
  227. P0.H = hi(EBIU_RSTCTL);
  228. P0.L = lo(EBIU_RSTCTL);
  229. R2 = [P0];
  230. R3.H = hi(SRREQ);
  231. R3.L = lo(SRREQ);
  232. #else
  233. P0.H = hi(EBIU_SDGCTL);
  234. P0.L = lo(EBIU_SDGCTL);
  235. R2 = [P0];
  236. R3.H = hi(SRFS);
  237. R3.L = lo(SRFS);
  238. #endif
  239. R3 = ~R3;
  240. R2 = R2&R3;
  241. [P0] = R2;
  242. ssync;
  243. RTS;
  244. ENTRY(_set_sic_iwr)
  245. #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
  246. P0.H = hi(SIC_IWR0);
  247. P0.L = lo(SIC_IWR0);
  248. P1.H = hi(SIC_IWR1);
  249. P1.L = lo(SIC_IWR1);
  250. [P1] = R1;
  251. #if defined(CONFIG_BF54x)
  252. P1.H = hi(SIC_IWR2);
  253. P1.L = lo(SIC_IWR2);
  254. [P1] = R2;
  255. #endif
  256. #else
  257. P0.H = hi(SIC_IWR);
  258. P0.L = lo(SIC_IWR);
  259. #endif
  260. [P0] = R0;
  261. SSYNC;
  262. RTS;
  263. ENTRY(_set_rtc_istat)
  264. P0.H = hi(RTC_ISTAT);
  265. P0.L = lo(RTC_ISTAT);
  266. w[P0] = R0.L;
  267. SSYNC;
  268. RTS;
  269. ENTRY(_test_pll_locked)
  270. P0.H = hi(PLL_STAT);
  271. P0.L = lo(PLL_STAT);
  272. 1:
  273. R0 = W[P0] (Z);
  274. CC = BITTST(R0,5);
  275. IF !CC JUMP 1b;
  276. RTS;
  277. #endif