start.S 6.4 KB

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