start.S 6.3 KB

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