start.S 6.6 KB

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