lowlevel_init.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright (C) 2004 Sascha Hauer, Pengutronix
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  17. * 02111-1307, USA.
  18. *
  19. */
  20. #include <config.h>
  21. #include <version.h>
  22. #include <asm/arch/imx-regs.h>
  23. .globl lowlevel_init
  24. lowlevel_init:
  25. mov r10, lr
  26. /* Change PERCLK1DIV to 14 ie 14+1 */
  27. ldr r0, =PCDR
  28. ldr r1, =CONFIG_SYS_PCDR_VAL
  29. str r1, [r0]
  30. /* set MCU PLL Control Register 0 */
  31. ldr r0, =MPCTL0
  32. ldr r1, =CONFIG_SYS_MPCTL0_VAL
  33. str r1, [r0]
  34. /* set MCU PLL Control Register 1 */
  35. ldr r0, =MPCTL1
  36. ldr r1, =CONFIG_SYS_MPCTL1_VAL
  37. str r1, [r0]
  38. /* set mpll restart bit */
  39. ldr r0, =CSCR
  40. ldr r1, [r0]
  41. orr r1,r1,#(1<<21)
  42. str r1, [r0]
  43. mov r2,#0x10
  44. 1:
  45. mov r3,#0x2000
  46. 2:
  47. subs r3,r3,#1
  48. bne 2b
  49. subs r2,r2,#1
  50. bne 1b
  51. /* set System PLL Control Register 0 */
  52. ldr r0, =SPCTL0
  53. ldr r1, =CONFIG_SYS_SPCTL0_VAL
  54. str r1, [r0]
  55. /* set System PLL Control Register 1 */
  56. ldr r0, =SPCTL1
  57. ldr r1, =CONFIG_SYS_SPCTL1_VAL
  58. str r1, [r0]
  59. /* set spll restart bit */
  60. ldr r0, =CSCR
  61. ldr r1, [r0]
  62. orr r1,r1,#(1<<22)
  63. str r1, [r0]
  64. mov r2,#0x10
  65. 1:
  66. mov r3,#0x2000
  67. 2:
  68. subs r3,r3,#1
  69. bne 2b
  70. subs r2,r2,#1
  71. bne 1b
  72. ldr r0, =CSCR
  73. ldr r1, =CONFIG_SYS_CSCR_VAL
  74. str r1, [r0]
  75. ldr r0, =GPCR
  76. ldr r1, =CONFIG_SYS_GPCR_VAL
  77. str r1, [r0]
  78. /*
  79. * I have now read the ARM920 DataSheet back-to-Back, and have stumbled upon
  80. * this.....
  81. *
  82. * It would appear that from a Cold-Boot the ARM920T enters "FastBus" mode CP15
  83. * register 1, this stops it using the output of the PLL and thus runs at the
  84. * slow rate. Unless you place the Core into "Asynch" mode, the CPU will never
  85. * use the value set in the CM_OSC registers...regardless of what you set it
  86. * too! Thus, although i thought i was running at 140MHz, i'm actually running
  87. * at 40!..
  88. *
  89. * Slapping this into my bootloader does the trick...
  90. *
  91. * MRC p15,0,r0,c1,c0,0 ; read core configuration register
  92. * ORR r0,r0,#0xC0000000 ; set asynchronous clocks and not fastbus mode
  93. * MCR p15,0,r0,c1,c0,0 ; write modified value to core configuration
  94. * register
  95. *
  96. */
  97. MRC p15,0,r0,c1,c0,0
  98. /* ORR r0,r0,#0xC0000000 async mode */
  99. /* ORR r0,r0,#0x40000000 sync mode */
  100. ORR r0,r0,#0xC0000000
  101. MCR p15,0,r0,c1,c0,0
  102. ldr r0, =GIUS(0)
  103. ldr r1, =CONFIG_SYS_GIUS_A_VAL
  104. str r1, [r0]
  105. ldr r0, =FMCR
  106. ldr r1, =CONFIG_SYS_FMCR_VAL
  107. str r1, [r0]
  108. ldr r0, =CS0U
  109. ldr r1, =CONFIG_SYS_CS0U_VAL
  110. str r1, [r0]
  111. ldr r0, =CS0L
  112. ldr r1, =CONFIG_SYS_CS0L_VAL
  113. str r1, [r0]
  114. ldr r0, =CS1U
  115. ldr r1, =CONFIG_SYS_CS1U_VAL
  116. str r1, [r0]
  117. ldr r0, =CS1L
  118. ldr r1, =CONFIG_SYS_CS1L_VAL
  119. str r1, [r0]
  120. ldr r0, =CS4U
  121. ldr r1, =CONFIG_SYS_CS4U_VAL
  122. str r1, [r0]
  123. ldr r0, =CS4L
  124. ldr r1, =CONFIG_SYS_CS4L_VAL
  125. str r1, [r0]
  126. ldr r0, =CS5U
  127. ldr r1, =CONFIG_SYS_CS5U_VAL
  128. str r1, [r0]
  129. ldr r0, =CS5L
  130. ldr r1, =CONFIG_SYS_CS5L_VAL
  131. str r1, [r0]
  132. /* SDRAM Setup */
  133. ldr r1,=0x00221000 /* adr of SDCTRL0 */
  134. ldr r0,=0x92120200
  135. str r0,[r1,#0] /* put in precharge command mode */
  136. ldr r2,=0x08200000 /* adr for precharge cmd */
  137. ldr r0,[r2,#0] /* precharge */
  138. ldr r0,=0xA2120200
  139. ldr r2,=0x08000000 /* start of SDRAM */
  140. str r0,[r1,#0] /* put in auto-refresh mode */
  141. ldr r0,[r2,#0] /* auto-refresh */
  142. ldr r0,[r2,#0] /* auto-refresh */
  143. ldr r0,[r2,#0] /* auto-refresh */
  144. ldr r0,[r2,#0] /* auto-refresh */
  145. ldr r0,[r2,#0] /* auto-refresh */
  146. ldr r0,[r2,#0] /* auto-refresh */
  147. ldr r0,[r2,#0] /* auto-refresh */
  148. ldr r0,=0xB2120200
  149. ldr r2,=0x08111800
  150. str r0,[r1,#0] /* setup for mode register of SDRAM */
  151. ldr r0,[r2,#0] /* program mode register */
  152. ldr r0,=0x82124267
  153. str r0,[r1,#0] /* back to normal operation */
  154. mov pc,r10