start.S 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * armboot - Startup Code for OMAP3530/ARM Cortex CPU-core
  3. *
  4. * Copyright (c) 2004 Texas Instruments <r-woodruff2@ti.com>
  5. *
  6. * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
  7. * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
  8. * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
  9. * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
  10. * Copyright (c) 2003 Kshitij <kshitij@ti.com>
  11. * Copyright (c) 2006-2008 Syed Mohammed Khasim <x0khasim@ti.com>
  12. *
  13. * SPDX-License-Identifier: GPL-2.0+
  14. */
  15. #include <asm-offsets.h>
  16. #include <config.h>
  17. #include <version.h>
  18. #include <asm/system.h>
  19. #include <linux/linkage.h>
  20. /*************************************************************************
  21. *
  22. * Startup Code (reset vector)
  23. *
  24. * do important init only if we don't start from memory!
  25. * setup Memory and board specific bits prior to relocation.
  26. * relocate armboot to ram
  27. * setup stack
  28. *
  29. *************************************************************************/
  30. .globl reset
  31. reset:
  32. bl save_boot_params
  33. /*
  34. * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
  35. * except if in HYP mode already
  36. */
  37. mrs r0, cpsr
  38. and r1, r0, #0x1f @ mask mode bits
  39. teq r1, #0x1a @ test for HYP mode
  40. bicne r0, r0, #0x1f @ clear all mode bits
  41. orrne r0, r0, #0x13 @ set SVC mode
  42. orr r0, r0, #0xc0 @ disable FIQ and IRQ
  43. msr cpsr,r0
  44. /*
  45. * Setup vector:
  46. * (OMAP4 spl TEXT_BASE is not 32 byte aligned.
  47. * Continue to use ROM code vector only in OMAP4 spl)
  48. */
  49. #if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))
  50. /* Set V=0 in CP15 SCTRL register - for VBAR to point to vector */
  51. mrc p15, 0, r0, c1, c0, 0 @ Read CP15 SCTRL Register
  52. bic r0, #CR_V @ V = 0
  53. mcr p15, 0, r0, c1, c0, 0 @ Write CP15 SCTRL Register
  54. /* Set vector address in CP15 VBAR register */
  55. ldr r0, =_start
  56. mcr p15, 0, r0, c12, c0, 0 @Set VBAR
  57. #endif
  58. /* the mask ROM code should have PLL and others stable */
  59. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  60. bl cpu_init_cp15
  61. bl cpu_init_crit
  62. #endif
  63. bl _main
  64. /*------------------------------------------------------------------------------*/
  65. ENTRY(c_runtime_cpu_setup)
  66. /*
  67. * If I-cache is enabled invalidate it
  68. */
  69. #ifndef CONFIG_SYS_ICACHE_OFF
  70. mcr p15, 0, r0, c7, c5, 0 @ invalidate icache
  71. mcr p15, 0, r0, c7, c10, 4 @ DSB
  72. mcr p15, 0, r0, c7, c5, 4 @ ISB
  73. #endif
  74. bx lr
  75. ENDPROC(c_runtime_cpu_setup)
  76. /*************************************************************************
  77. *
  78. * void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
  79. * __attribute__((weak));
  80. *
  81. * Stack pointer is not yet initialized at this moment
  82. * Don't save anything to stack even if compiled with -O0
  83. *
  84. *************************************************************************/
  85. ENTRY(save_boot_params)
  86. bx lr @ back to my caller
  87. ENDPROC(save_boot_params)
  88. .weak save_boot_params
  89. /*************************************************************************
  90. *
  91. * cpu_init_cp15
  92. *
  93. * Setup CP15 registers (cache, MMU, TLBs). The I-cache is turned on unless
  94. * CONFIG_SYS_ICACHE_OFF is defined.
  95. *
  96. *************************************************************************/
  97. ENTRY(cpu_init_cp15)
  98. /*
  99. * Invalidate L1 I/D
  100. */
  101. mov r0, #0 @ set up for MCR
  102. mcr p15, 0, r0, c8, c7, 0 @ invalidate TLBs
  103. mcr p15, 0, r0, c7, c5, 0 @ invalidate icache
  104. mcr p15, 0, r0, c7, c5, 6 @ invalidate BP array
  105. mcr p15, 0, r0, c7, c10, 4 @ DSB
  106. mcr p15, 0, r0, c7, c5, 4 @ ISB
  107. /*
  108. * disable MMU stuff and caches
  109. */
  110. mrc p15, 0, r0, c1, c0, 0
  111. bic r0, r0, #0x00002000 @ clear bits 13 (--V-)
  112. bic r0, r0, #0x00000007 @ clear bits 2:0 (-CAM)
  113. orr r0, r0, #0x00000002 @ set bit 1 (--A-) Align
  114. orr r0, r0, #0x00000800 @ set bit 11 (Z---) BTB
  115. #ifdef CONFIG_SYS_ICACHE_OFF
  116. bic r0, r0, #0x00001000 @ clear bit 12 (I) I-cache
  117. #else
  118. orr r0, r0, #0x00001000 @ set bit 12 (I) I-cache
  119. #endif
  120. mcr p15, 0, r0, c1, c0, 0
  121. #ifdef CONFIG_ARM_ERRATA_716044
  122. mrc p15, 0, r0, c1, c0, 0 @ read system control register
  123. orr r0, r0, #1 << 11 @ set bit #11
  124. mcr p15, 0, r0, c1, c0, 0 @ write system control register
  125. #endif
  126. #if (defined(CONFIG_ARM_ERRATA_742230) || defined(CONFIG_ARM_ERRATA_794072))
  127. mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
  128. orr r0, r0, #1 << 4 @ set bit #4
  129. mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
  130. #endif
  131. #ifdef CONFIG_ARM_ERRATA_743622
  132. mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
  133. orr r0, r0, #1 << 6 @ set bit #6
  134. mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
  135. #endif
  136. #ifdef CONFIG_ARM_ERRATA_751472
  137. mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
  138. orr r0, r0, #1 << 11 @ set bit #11
  139. mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
  140. #endif
  141. #ifdef CONFIG_ARM_ERRATA_761320
  142. mrc p15, 0, r0, c15, c0, 1 @ read diagnostic register
  143. orr r0, r0, #1 << 21 @ set bit #21
  144. mcr p15, 0, r0, c15, c0, 1 @ write diagnostic register
  145. #endif
  146. mov pc, lr @ back to my caller
  147. ENDPROC(cpu_init_cp15)
  148. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  149. /*************************************************************************
  150. *
  151. * CPU_init_critical registers
  152. *
  153. * setup important registers
  154. * setup memory timing
  155. *
  156. *************************************************************************/
  157. ENTRY(cpu_init_crit)
  158. /*
  159. * Jump to board specific initialization...
  160. * The Mask ROM will have already initialized
  161. * basic memory. Go here to bump up clock rate and handle
  162. * wake up conditions.
  163. */
  164. b lowlevel_init @ go setup pll,mux,memory
  165. ENDPROC(cpu_init_crit)
  166. #endif