start.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /*
  2. * U-boot - start.S Startup file of u-boot for BF533/BF561
  3. *
  4. * Copyright (c) 2005-2007 Analog Devices Inc.
  5. *
  6. * This file is based on head.S
  7. * Copyright (c) 2003 Metrowerks/Motorola
  8. * Copyright (C) 1998 D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
  9. * Kenneth Albanowski <kjahds@kjahds.com>,
  10. * The Silver Hammer Group, Ltd.
  11. * (c) 1995, Dionne & Associates
  12. * (c) 1995, DKG Display Tech.
  13. *
  14. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  30. * MA 02110-1301 USA
  31. */
  32. /*
  33. * Note: A change in this file subsequently requires a change in
  34. * board/$(board_name)/config.mk for a valid u-boot.bin
  35. */
  36. #define ASSEMBLY
  37. #include <linux/config.h>
  38. #include <config.h>
  39. #include <asm/blackfin.h>
  40. #include <asm/mach-common/bits/core.h>
  41. #include <asm/mach-common/bits/dma.h>
  42. #include <asm/mach-common/bits/pll.h>
  43. .global _stext;
  44. .global __bss_start;
  45. .global start;
  46. .global _start;
  47. .global _rambase;
  48. .global _ramstart;
  49. .global _ramend;
  50. .global _bf533_data_dest;
  51. .global _bf533_data_size;
  52. .global edata;
  53. .global _initialize;
  54. .global _exit;
  55. .global flashdataend;
  56. .global init_sdram;
  57. #if (CONFIG_CCLK_DIV == 1)
  58. #define CONFIG_CCLK_ACT_DIV CCLK_DIV1
  59. #endif
  60. #if (CONFIG_CCLK_DIV == 2)
  61. #define CONFIG_CCLK_ACT_DIV CCLK_DIV2
  62. #endif
  63. #if (CONFIG_CCLK_DIV == 4)
  64. #define CONFIG_CCLK_ACT_DIV CCLK_DIV4
  65. #endif
  66. #if (CONFIG_CCLK_DIV == 8)
  67. #define CONFIG_CCLK_ACT_DIV CCLK_DIV8
  68. #endif
  69. #ifndef CONFIG_CCLK_ACT_DIV
  70. #define CONFIG_CCLK_ACT_DIV CONFIG_CCLK_DIV_not_defined_properly
  71. #endif
  72. .text
  73. _start:
  74. start:
  75. _stext:
  76. R0 = 0x32;
  77. SYSCFG = R0;
  78. SSYNC;
  79. /* As per HW reference manual DAG registers,
  80. * DATA and Address resgister shall be zero'd
  81. * in initialization, after a reset state
  82. */
  83. r1 = 0; /* Data registers zero'd */
  84. r2 = 0;
  85. r3 = 0;
  86. r4 = 0;
  87. r5 = 0;
  88. r6 = 0;
  89. r7 = 0;
  90. p0 = 0; /* Address registers zero'd */
  91. p1 = 0;
  92. p2 = 0;
  93. p3 = 0;
  94. p4 = 0;
  95. p5 = 0;
  96. i0 = 0; /* DAG Registers zero'd */
  97. i1 = 0;
  98. i2 = 0;
  99. i3 = 0;
  100. m0 = 0;
  101. m1 = 0;
  102. m3 = 0;
  103. m3 = 0;
  104. l0 = 0;
  105. l1 = 0;
  106. l2 = 0;
  107. l3 = 0;
  108. b0 = 0;
  109. b1 = 0;
  110. b2 = 0;
  111. b3 = 0;
  112. /* Set loop counters to zero, to make sure that
  113. * hw loops are disabled.
  114. */
  115. r0 = 0;
  116. lc0 = r0;
  117. lc1 = r0;
  118. SSYNC;
  119. /* Check soft reset status */
  120. p0.h = SWRST >> 16;
  121. p0.l = SWRST & 0xFFFF;
  122. r0.l = w[p0];
  123. cc = bittst(r0, 15);
  124. if !cc jump no_soft_reset;
  125. /* Clear Soft reset */
  126. r0 = 0x0000;
  127. w[p0] = r0;
  128. ssync;
  129. no_soft_reset:
  130. nop;
  131. /* Clear EVT registers */
  132. p0.h = (EVT0 >> 16);
  133. p0.l = (EVT0 & 0xFFFF);
  134. p0 += 8;
  135. p1 = 14;
  136. r1 = 0;
  137. LSETUP(4,4) lc0 = p1;
  138. [ p0 ++ ] = r1;
  139. p0.h = hi(SIC_IWR);
  140. p0.l = lo(SIC_IWR);
  141. r0.l = 0x1;
  142. w[p0] = r0.l;
  143. SSYNC;
  144. sp.l = (0xffb01000 & 0xFFFF);
  145. sp.h = (0xffb01000 >> 16);
  146. call init_sdram;
  147. /* relocate into to RAM */
  148. call get_pc;
  149. offset:
  150. r2.l = offset;
  151. r2.h = offset;
  152. r3.l = start;
  153. r3.h = start;
  154. r1 = r2 - r3;
  155. r0 = r0 - r1;
  156. p1 = r0;
  157. p2.l = (CFG_MONITOR_BASE & 0xffff);
  158. p2.h = (CFG_MONITOR_BASE >> 16);
  159. p3 = 0x04;
  160. p4.l = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & 0xffff);
  161. p4.h = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) >> 16);
  162. loop1:
  163. r1 = [p1 ++ p3];
  164. [p2 ++ p3] = r1;
  165. cc=p2==p4;
  166. if !cc jump loop1;
  167. /*
  168. * configure STACK
  169. */
  170. r0.h = (CONFIG_STACKBASE >> 16);
  171. r0.l = (CONFIG_STACKBASE & 0xFFFF);
  172. sp = r0;
  173. fp = sp;
  174. /*
  175. * This next section keeps the processor in supervisor mode
  176. * during kernel boot. Switches to user mode at end of boot.
  177. * See page 3-9 of Hardware Reference manual for documentation.
  178. */
  179. /* To keep ourselves in the supervisor mode */
  180. p0.l = (EVT15 & 0xFFFF);
  181. p0.h = (EVT15 >> 16);
  182. p1.l = _real_start;
  183. p1.h = _real_start;
  184. [p0] = p1;
  185. p0.l = (IMASK & 0xFFFF);
  186. p0.h = (IMASK >> 16);
  187. r0.l = LO(EVT_IVG15);
  188. r0.h = HI(EVT_IVG15);
  189. [p0] = r0;
  190. raise 15;
  191. p0.l = WAIT_HERE;
  192. p0.h = WAIT_HERE;
  193. reti = p0;
  194. rti;
  195. WAIT_HERE:
  196. jump WAIT_HERE;
  197. .global _real_start;
  198. _real_start:
  199. [ -- sp ] = reti;
  200. /* DMA reset code to Hi of L1 SRAM */
  201. copy:
  202. /* P1 Points to the beginning of SYSTEM MMR Space */
  203. P1.H = hi(SYSMMR_BASE);
  204. P1.L = lo(SYSMMR_BASE);
  205. R0.H = reset_start; /* Source Address (high) */
  206. R0.L = reset_start; /* Source Address (low) */
  207. R1.H = reset_end;
  208. R1.L = reset_end;
  209. R2 = R1 - R0; /* Count */
  210. R1.H = hi(L1_INST_SRAM); /* Destination Address (high) */
  211. R1.L = lo(L1_INST_SRAM); /* Destination Address (low) */
  212. R3.L = DMAEN; /* Source DMAConfig Value (8-bit words) */
  213. /* Destination DMAConfig Value (8-bit words) */
  214. R4.L = (DI_EN | WNR | DMAEN);
  215. DMA:
  216. R6 = 0x1 (Z);
  217. W[P1+OFFSET_(MDMA_S0_X_MODIFY)] = R6; /* Source Modify = 1 */
  218. W[P1+OFFSET_(MDMA_D0_X_MODIFY)] = R6; /* Destination Modify = 1 */
  219. [P1+OFFSET_(MDMA_S0_START_ADDR)] = R0; /* Set Source Base Address */
  220. W[P1+OFFSET_(MDMA_S0_X_COUNT)] = R2; /* Set Source Count */
  221. /* Set Source DMAConfig = DMA Enable,
  222. Memory Read, 8-Bit Transfers, 1-D DMA, Flow - Stop */
  223. W[P1+OFFSET_(MDMA_S0_CONFIG)] = R3;
  224. /* Set Destination Base Address */
  225. [P1+OFFSET_(MDMA_D0_START_ADDR)] = R1;
  226. W[P1+OFFSET_(MDMA_D0_X_COUNT)] = R2; /* Set Destination Count */
  227. /* Set Destination DMAConfig = DMA Enable,
  228. Memory Write, 8-Bit Transfers, 1-D DMA, Flow - Stop, IOC */
  229. W[P1+OFFSET_(MDMA_D0_CONFIG)] = R4;
  230. WAIT_DMA_DONE:
  231. p0.h = hi(MDMA_D0_IRQ_STATUS);
  232. p0.l = lo(MDMA_D0_IRQ_STATUS);
  233. R0 = W[P0](Z);
  234. CC = BITTST(R0, 0);
  235. if ! CC jump WAIT_DMA_DONE
  236. R0 = 0x1;
  237. /* Write 1 to clear DMA interrupt */
  238. W[P1+OFFSET_(MDMA_D0_IRQ_STATUS)] = R0;
  239. /* Initialize BSS Section with 0 s */
  240. p1.l = __bss_start;
  241. p1.h = __bss_start;
  242. p2.l = _end;
  243. p2.h = _end;
  244. r1 = p1;
  245. r2 = p2;
  246. r3 = r2 - r1;
  247. r3 = r3 >> 2;
  248. p3 = r3;
  249. lsetup (_clear_bss, _clear_bss_end ) lc1 = p3;
  250. CC = p2<=p1;
  251. if CC jump _clear_bss_skip;
  252. r0 = 0;
  253. _clear_bss:
  254. _clear_bss_end:
  255. [p1++] = r0;
  256. _clear_bss_skip:
  257. p0.l = _start1;
  258. p0.h = _start1;
  259. jump (p0);
  260. reset_start:
  261. p0.h = WDOG_CNT >> 16;
  262. p0.l = WDOG_CNT & 0xffff;
  263. r0 = 0x0010;
  264. w[p0] = r0;
  265. p0.h = WDOG_CTL >> 16;
  266. p0.l = WDOG_CTL & 0xffff;
  267. r0 = 0x0000;
  268. w[p0] = r0;
  269. reset_wait:
  270. jump reset_wait;
  271. reset_end: nop;
  272. _exit:
  273. jump.s _exit;
  274. get_pc:
  275. r0 = rets;
  276. rts;