lowlevel_init.S 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Copyright (C) 2009 Samsung Electronics
  3. * Kyungmin Park <kyungmin.park@samsung.com>
  4. * Minkyu Kang <mk7.kang@samsung.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <config.h>
  25. #include <version.h>
  26. #include <asm/arch/cpu.h>
  27. #include <asm/arch/power.h>
  28. /*
  29. * Register usages:
  30. *
  31. * r5 has zero always
  32. */
  33. _TEXT_BASE:
  34. .word TEXT_BASE
  35. .globl lowlevel_init
  36. lowlevel_init:
  37. mov r9, lr
  38. /* r5 has always zero */
  39. mov r5, #0
  40. ldr r8, =S5PC100_GPIO_BASE
  41. /* Disable Watchdog */
  42. ldr r0, =S5PC100_WATCHDOG_BASE @0xEA200000
  43. orr r0, r0, #0x0
  44. str r5, [r0]
  45. #ifndef CONFIG_ONENAND_IPL
  46. /* setting SRAM */
  47. ldr r0, =S5PC100_SROMC_BASE
  48. ldr r1, =0x9
  49. str r1, [r0]
  50. #endif
  51. /* S5PC100 has 3 groups of interrupt sources */
  52. ldr r0, =S5PC100_VIC0_BASE @0xE4000000
  53. ldr r1, =S5PC100_VIC1_BASE @0xE4000000
  54. ldr r2, =S5PC100_VIC2_BASE @0xE4000000
  55. /* Disable all interrupts (VIC0, VIC1 and VIC2) */
  56. mvn r3, #0x0
  57. str r3, [r0, #0x14] @INTENCLEAR
  58. str r3, [r1, #0x14] @INTENCLEAR
  59. str r3, [r2, #0x14] @INTENCLEAR
  60. #ifndef CONFIG_ONENAND_IPL
  61. /* Set all interrupts as IRQ */
  62. str r5, [r0, #0xc] @INTSELECT
  63. str r5, [r1, #0xc] @INTSELECT
  64. str r5, [r2, #0xc] @INTSELECT
  65. /* Pending Interrupt Clear */
  66. str r5, [r0, #0xf00] @INTADDRESS
  67. str r5, [r1, #0xf00] @INTADDRESS
  68. str r5, [r2, #0xf00] @INTADDRESS
  69. #endif
  70. #ifndef CONFIG_ONENAND_IPL
  71. /* for UART */
  72. bl uart_asm_init
  73. /* for TZPC */
  74. bl tzpc_asm_init
  75. #endif
  76. #ifdef CONFIG_ONENAND_IPL
  77. /* init system clock */
  78. bl system_clock_init
  79. bl mem_ctrl_asm_init
  80. /* Wakeup support. Don't know if it's going to be used, untested. */
  81. ldr r0, =S5PC100_RST_STAT
  82. ldr r1, [r0]
  83. bic r1, r1, #0xfffffff7
  84. cmp r1, #0x8
  85. beq wakeup_reset
  86. #endif
  87. 1:
  88. mov lr, r9
  89. mov pc, lr
  90. #ifdef CONFIG_ONENAND_IPL
  91. wakeup_reset:
  92. /* Clear wakeup status register */
  93. ldr r0, =S5PC100_WAKEUP_STAT
  94. ldr r1, [r0]
  95. str r1, [r0]
  96. /* Load return address and jump to kernel */
  97. ldr r0, =S5PC100_INFORM0
  98. /* r1 = physical address of s5pc100_cpu_resume function */
  99. ldr r1, [r0]
  100. /* Jump to kernel (sleep.S) */
  101. mov pc, r1
  102. nop
  103. nop
  104. #endif
  105. /*
  106. * system_clock_init: Initialize core clock and bus clock.
  107. * void system_clock_init(void)
  108. */
  109. system_clock_init:
  110. ldr r8, =S5PC100_CLOCK_BASE @ 0xE0100000
  111. /* Set Clock divider */
  112. ldr r1, =0x00011110
  113. str r1, [r8, #0x304]
  114. ldr r1, =0x1
  115. str r1, [r8, #0x308]
  116. ldr r1, =0x00011301
  117. str r1, [r8, #0x300]
  118. /* Set Lock Time */
  119. ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
  120. str r1, [r8, #0x000] @ APLL_LOCK
  121. str r1, [r8, #0x004] @ MPLL_LOCK
  122. str r1, [r8, #0x008] @ EPLL_LOCK
  123. str r1, [r8, #0x00C] @ HPLL_LOCK
  124. /* APLL_CON */
  125. ldr r1, =0x81bc0400 @ SDIV 0, PDIV 4, MDIV 444 (1332MHz)
  126. str r1, [r8, #0x100]
  127. /* MPLL_CON */
  128. ldr r1, =0x80590201 @ SDIV 1, PDIV 2, MDIV 89 (267MHz)
  129. str r1, [r8, #0x104]
  130. /* EPLL_CON */
  131. ldr r1, =0x80870303 @ SDIV 3, PDIV 3, MDIV 135 (67.5MHz)
  132. str r1, [r8, #0x108]
  133. /* HPLL_CON */
  134. ldr r1, =0x80600603
  135. str r1, [r8, #0x10C]
  136. /* Set Source Clock */
  137. ldr r1, =0x1111 @ A, M, E, HPLL Muxing
  138. str r1, [r8, #0x200] @ CLK_SRC0
  139. ldr r1, =0x1000001 @ Uart Clock & CLK48M Muxing
  140. str r1, [r8, #0x204] @ CLK_SRC1
  141. ldr r1, =0x9000 @ ARMCLK/4
  142. str r1, [r8, #0x400] @ CLK_OUT
  143. /* wait at least 200us to stablize all clock */
  144. mov r2, #0x10000
  145. 1: subs r2, r2, #1
  146. bne 1b
  147. mov pc, lr
  148. #ifndef CONFIG_ONENAND_IPL
  149. /*
  150. * uart_asm_init: Initialize UART's pins
  151. */
  152. uart_asm_init:
  153. mov r0, r8
  154. ldr r1, =0x22222222
  155. str r1, [r0, #0x0] @ GPA0_CON
  156. ldr r1, =0x00022222
  157. str r1, [r0, #0x20] @ GPA1_CON
  158. mov pc, lr
  159. /*
  160. * tzpc_asm_init: Initialize TZPC
  161. */
  162. tzpc_asm_init:
  163. ldr r0, =0xE3800000
  164. mov r1, #0x0
  165. str r1, [r0]
  166. mov r1, #0xff
  167. str r1, [r0, #0x804]
  168. str r1, [r0, #0x810]
  169. ldr r0, =0xE2800000
  170. str r1, [r0, #0x804]
  171. str r1, [r0, #0x810]
  172. str r1, [r0, #0x81C]
  173. ldr r0, =0xE2900000
  174. str r1, [r0, #0x804]
  175. str r1, [r0, #0x810]
  176. mov pc, lr
  177. #endif