start.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * armboot - Startup Code for ARM920 CPU-core
  3. *
  4. * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
  5. * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
  6. * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <asm-offsets.h>
  11. #include <common.h>
  12. #include <config.h>
  13. /*
  14. *************************************************************************
  15. *
  16. * Startup Code (called from the ARM reset exception vector)
  17. *
  18. * do important init only if we don't start from memory!
  19. * relocate armboot to ram
  20. * setup stack
  21. * jump to second stage
  22. *
  23. *************************************************************************
  24. */
  25. .globl reset
  26. reset:
  27. /*
  28. * set the cpu to SVC32 mode
  29. */
  30. mrs r0, cpsr
  31. bic r0, r0, #0x1f
  32. orr r0, r0, #0xd3
  33. msr cpsr, r0
  34. #if defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK)
  35. /*
  36. * relocate exception table
  37. */
  38. ldr r0, =_start
  39. ldr r1, =0x0
  40. mov r2, #16
  41. copyex:
  42. subs r2, r2, #1
  43. ldr r3, [r0], #4
  44. str r3, [r1], #4
  45. bne copyex
  46. #endif
  47. #ifdef CONFIG_S3C24X0
  48. /* turn off the watchdog */
  49. # if defined(CONFIG_S3C2400)
  50. # define pWTCON 0x15300000
  51. # define INTMSK 0x14400008 /* Interrupt-Controller base addresses */
  52. # define CLKDIVN 0x14800014 /* clock divisor register */
  53. #else
  54. # define pWTCON 0x53000000
  55. # define INTMSK 0x4A000008 /* Interrupt-Controller base addresses */
  56. # define INTSUBMSK 0x4A00001C
  57. # define CLKDIVN 0x4C000014 /* clock divisor register */
  58. # endif
  59. ldr r0, =pWTCON
  60. mov r1, #0x0
  61. str r1, [r0]
  62. /*
  63. * mask all IRQs by setting all bits in the INTMR - default
  64. */
  65. mov r1, #0xffffffff
  66. ldr r0, =INTMSK
  67. str r1, [r0]
  68. # if defined(CONFIG_S3C2410)
  69. ldr r1, =0x3ff
  70. ldr r0, =INTSUBMSK
  71. str r1, [r0]
  72. # endif
  73. /* FCLK:HCLK:PCLK = 1:2:4 */
  74. /* default FCLK is 120 MHz ! */
  75. ldr r0, =CLKDIVN
  76. mov r1, #3
  77. str r1, [r0]
  78. #endif /* CONFIG_S3C24X0 */
  79. /*
  80. * we do sys-critical inits only at reboot,
  81. * not when booting from ram!
  82. */
  83. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  84. bl cpu_init_crit
  85. #endif
  86. bl _main
  87. /*------------------------------------------------------------------------------*/
  88. .globl c_runtime_cpu_setup
  89. c_runtime_cpu_setup:
  90. mov pc, lr
  91. /*
  92. *************************************************************************
  93. *
  94. * CPU_init_critical registers
  95. *
  96. * setup important registers
  97. * setup memory timing
  98. *
  99. *************************************************************************
  100. */
  101. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  102. cpu_init_crit:
  103. /*
  104. * flush v4 I/D caches
  105. */
  106. mov r0, #0
  107. mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
  108. mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
  109. /*
  110. * disable MMU stuff and caches
  111. */
  112. mrc p15, 0, r0, c1, c0, 0
  113. bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
  114. bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
  115. orr r0, r0, #0x00000002 @ set bit 1 (A) Align
  116. orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
  117. mcr p15, 0, r0, c1, c0, 0
  118. #ifndef CONFIG_SKIP_LOWLEVEL_INIT_ONLY
  119. /*
  120. * before relocating, we have to setup RAM timing
  121. * because memory timing is board-dependend, you will
  122. * find a lowlevel_init.S in your board directory.
  123. */
  124. mov ip, lr
  125. bl lowlevel_init
  126. mov lr, ip
  127. #endif
  128. mov pc, lr
  129. #endif /* CONFIG_SKIP_LOWLEVEL_INIT */