start.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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 edata;
  51. .global _initialize;
  52. .global _exit;
  53. .global flashdataend;
  54. .global init_sdram;
  55. .text
  56. _start:
  57. start:
  58. _stext:
  59. R0 = 0x32;
  60. SYSCFG = R0;
  61. SSYNC;
  62. /*
  63. * As per HW reference manual DAG registers,
  64. * DATA and Address resgister shall be zero'd
  65. * in initialization, after a reset state
  66. */
  67. r1 = 0; /* Data registers zero'd */
  68. r2 = 0;
  69. r3 = 0;
  70. r4 = 0;
  71. r5 = 0;
  72. r6 = 0;
  73. r7 = 0;
  74. p0 = 0; /* Address registers zero'd */
  75. p1 = 0;
  76. p2 = 0;
  77. p3 = 0;
  78. p4 = 0;
  79. p5 = 0;
  80. i0 = 0; /* DAG Registers zero'd */
  81. i1 = 0;
  82. i2 = 0;
  83. i3 = 0;
  84. m0 = 0;
  85. m1 = 0;
  86. m3 = 0;
  87. m3 = 0;
  88. l0 = 0;
  89. l1 = 0;
  90. l2 = 0;
  91. l3 = 0;
  92. b0 = 0;
  93. b1 = 0;
  94. b2 = 0;
  95. b3 = 0;
  96. /*
  97. * Set loop counters to zero, to make sure that
  98. * hw loops are disabled.
  99. */
  100. r0 = 0;
  101. lc0 = r0;
  102. lc1 = r0;
  103. SSYNC;
  104. /* Check soft reset status */
  105. p0.h = SWRST >> 16;
  106. p0.l = SWRST & 0xFFFF;
  107. r0.l = w[p0];
  108. cc = bittst(r0, 15);
  109. if !cc jump no_soft_reset;
  110. /* Clear Soft reset */
  111. r0 = 0x0000;
  112. w[p0] = r0;
  113. ssync;
  114. no_soft_reset:
  115. nop;
  116. /* Clear EVT registers */
  117. p0.h = (EVT0 >> 16);
  118. p0.l = (EVT0 & 0xFFFF);
  119. p0 += 8;
  120. p1 = 14;
  121. r1 = 0;
  122. LSETUP(4,4) lc0 = p1;
  123. [ p0 ++ ] = r1;
  124. p0.h = hi(SICA_IWR0);
  125. p0.l = lo(SICA_IWR0);
  126. r0.l = 0x1;
  127. w[p0] = r0.l;
  128. SSYNC;
  129. sp.l = (0xffb01000 & 0xFFFF);
  130. sp.h = (0xffb01000 >> 16);
  131. /*
  132. * Check if the code is in SDRAM
  133. * If the code is in SDRAM, skip SDRAM initializaiton
  134. */
  135. call get_pc;
  136. r3.l = 0x0;
  137. r3.h = 0x2000;
  138. cc = r0 < r3 (iu);
  139. if cc jump sdram_initialized;
  140. call init_sdram;
  141. /* relocate into to RAM */
  142. sdram_initialized:
  143. call get_pc;
  144. offset:
  145. r2.l = offset;
  146. r2.h = offset;
  147. r3.l = start;
  148. r3.h = start;
  149. r1 = r2 - r3;
  150. r0 = r0 - r1;
  151. p1 = r0;
  152. p2.l = (CFG_MONITOR_BASE & 0xffff);
  153. p2.h = (CFG_MONITOR_BASE >> 16);
  154. p3 = 0x04;
  155. p4.l = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & 0xffff);
  156. p4.h = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) >> 16);
  157. loop1:
  158. r1 = [p1 ++ p3];
  159. [p2 ++ p3] = r1;
  160. cc=p2==p4;
  161. if !cc jump loop1;
  162. /*
  163. * configure STACK
  164. */
  165. r0.h = (CONFIG_STACKBASE >> 16);
  166. r0.l = (CONFIG_STACKBASE & 0xFFFF);
  167. sp = r0;
  168. fp = sp;
  169. /*
  170. * This next section keeps the processor in supervisor mode
  171. * during kernel boot. Switches to user mode at end of boot.
  172. * See page 3-9 of Hardware Reference manual for documentation.
  173. */
  174. /* To keep ourselves in the supervisor mode */
  175. p0.l = (EVT15 & 0xFFFF);
  176. p0.h = (EVT15 >> 16);
  177. p1.l = _real_start;
  178. p1.h = _real_start;
  179. [p0] = p1;
  180. p0.l = (IMASK & 0xFFFF);
  181. p0.h = (IMASK >> 16);
  182. r0.l = LO(EVT_IVG15);
  183. r0.h = HI(EVT_IVG15);
  184. [p0] = r0;
  185. raise 15;
  186. p0.l = WAIT_HERE;
  187. p0.h = WAIT_HERE;
  188. reti = p0;
  189. rti;
  190. WAIT_HERE:
  191. jump WAIT_HERE;
  192. .global _real_start;
  193. _real_start:
  194. [ -- sp ] = reti;
  195. /* DMA reset code to Hi of L1 SRAM */
  196. copy:
  197. P1.H = hi(SYSMMR_BASE); /* P1 Points to the beginning of SYSTEM MMR Space */
  198. P1.L = lo(SYSMMR_BASE);
  199. R0.H = reset_start; /* Source Address (high) */
  200. R0.L = reset_start; /* Source Address (low) */
  201. R1.H = reset_end;
  202. R1.L = reset_end;
  203. R2 = R1 - R0; /* Count */
  204. R1.H = hi(L1_INST_SRAM); /* Destination Address (high) */
  205. R1.L = lo(L1_INST_SRAM); /* Destination Address (low) */
  206. R3.L = DMAEN; /* Source DMAConfig Value (8-bit words) */
  207. R4.L = (DI_EN | WNR | DMAEN); /* Destination DMAConfig Value (8-bit words) */
  208. DMA:
  209. R6 = 0x1 (Z);
  210. W[P1+OFFSET_(IMDMA_S0_X_MODIFY)] = R6; /* Source Modify = 1 */
  211. W[P1+OFFSET_(IMDMA_D0_X_MODIFY)] = R6; /* Destination Modify = 1 */
  212. [P1+OFFSET_(IMDMA_S0_START_ADDR)] = R0; /* Set Source Base Address */
  213. W[P1+OFFSET_(IMDMA_S0_X_COUNT)] = R2; /* Set Source Count */
  214. /* Set Source DMAConfig = DMA Enable,
  215. Memory Read, 8-Bit Transfers, 1-D DMA, Flow - Stop */
  216. W[P1+OFFSET_(IMDMA_S0_CONFIG)] = R3;
  217. [P1+OFFSET_(IMDMA_D0_START_ADDR)] = R1; /* Set Destination Base Address */
  218. W[P1+OFFSET_(IMDMA_D0_X_COUNT)] = R2; /* Set Destination Count */
  219. /* Set Destination DMAConfig = DMA Enable,
  220. Memory Write, 8-Bit Transfers, 1-D DMA, Flow - Stop, IOC */
  221. W[P1+OFFSET_(IMDMA_D0_CONFIG)] = R4;
  222. WAIT_DMA_DONE:
  223. p0.h = hi(IMDMA_D0_IRQ_STATUS);
  224. p0.l = lo(IMDMA_D0_IRQ_STATUS);
  225. R0 = W[P0](Z);
  226. CC = BITTST(R0, 0);
  227. if ! CC jump WAIT_DMA_DONE
  228. R0 = 0x1;
  229. W[P1+OFFSET_(IMDMA_D0_IRQ_STATUS)] = R0; /* Write 1 to clear DMA interrupt */
  230. /* Initialize BSS Section with 0 s */
  231. p1.l = __bss_start;
  232. p1.h = __bss_start;
  233. p2.l = _end;
  234. p2.h = _end;
  235. r1 = p1;
  236. r2 = p2;
  237. r3 = r2 - r1;
  238. r3 = r3 >> 2;
  239. p3 = r3;
  240. lsetup (_clear_bss, _clear_bss_end ) lc1 = p3;
  241. CC = p2<=p1;
  242. if CC jump _clear_bss_skip;
  243. r0 = 0;
  244. _clear_bss:
  245. _clear_bss_end:
  246. [p1++] = r0;
  247. _clear_bss_skip:
  248. p0.l = _start1;
  249. p0.h = _start1;
  250. jump (p0);
  251. reset_start:
  252. p0.h = WDOG_CNT >> 16;
  253. p0.l = WDOG_CNT & 0xffff;
  254. r0 = 0x0010;
  255. w[p0] = r0;
  256. p0.h = WDOG_CTL >> 16;
  257. p0.l = WDOG_CTL & 0xffff;
  258. r0 = 0x0000;
  259. w[p0] = r0;
  260. reset_wait:
  261. jump reset_wait;
  262. reset_end: nop;
  263. _exit:
  264. jump.s _exit;
  265. get_pc:
  266. r0 = rets;
  267. rts;