lowlevel_init.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright (C) 2004 Sascha Hauer, Synertronixx GmbH
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <config.h>
  7. #include <asm/arch/imx-regs.h>
  8. .globl lowlevel_init
  9. lowlevel_init:
  10. mov r10, lr
  11. /* Change PERCLK1DIV to 14 ie 14+1 */
  12. ldr r0, =PCDR
  13. ldr r1, =CONFIG_SYS_PCDR_VAL
  14. str r1, [r0]
  15. /* set MCU PLL Control Register 0 */
  16. ldr r0, =MPCTL0
  17. ldr r1, =CONFIG_SYS_MPCTL0_VAL
  18. str r1, [r0]
  19. /* set mpll restart bit */
  20. ldr r0, =CSCR
  21. ldr r1, [r0]
  22. orr r1,r1,#(1<<21)
  23. str r1, [r0]
  24. mov r2,#0x10
  25. 1:
  26. mov r3,#0x2000
  27. 2:
  28. subs r3,r3,#1
  29. bne 2b
  30. subs r2,r2,#1
  31. bne 1b
  32. /* set System PLL Control Register 0 */
  33. ldr r0, =SPCTL0
  34. ldr r1, =CONFIG_SYS_SPCTL0_VAL
  35. str r1, [r0]
  36. /* set spll restart bit */
  37. ldr r0, =CSCR
  38. ldr r1, [r0]
  39. orr r1,r1,#(1<<22)
  40. str r1, [r0]
  41. mov r2,#0x10
  42. 1:
  43. mov r3,#0x2000
  44. 2:
  45. subs r3,r3,#1
  46. bne 2b
  47. subs r2,r2,#1
  48. bne 1b
  49. ldr r0, =CSCR
  50. ldr r1, =CONFIG_SYS_CSCR_VAL
  51. str r1, [r0]
  52. /* I have now read the ARM920 DataSheet back-to-Back, and have stumbled upon
  53. *this.....
  54. *
  55. * It would appear that from a Cold-Boot the ARM920T enters "FastBus" mode CP15
  56. * register 1, this stops it using the output of the PLL and thus runs at the
  57. * slow rate. Unless you place the Core into "Asynch" mode, the CPU will never
  58. * use the value set in the CM_OSC registers...regardless of what you set it
  59. * too! Thus, although i thought i was running at 140MHz, i'm actually running
  60. * at 40!..
  61. * Slapping this into my bootloader does the trick...
  62. * MRC p15,0,r0,c1,c0,0 ; read core configuration register
  63. * ORR r0,r0,#0xC0000000 ; set asynchronous clocks and not fastbus mode
  64. * MCR p15,0,r0,c1,c0,0 ; write modified value to core configuration
  65. * register
  66. */
  67. MRC p15,0,r0,c1,c0,0
  68. ORR r0,r0,#0xC0000000
  69. MCR p15,0,r0,c1,c0,0
  70. ldr r0, =GPR(0)
  71. ldr r1, =CONFIG_SYS_GPR_A_VAL
  72. str r1, [r0]
  73. ldr r0, =GIUS(0)
  74. ldr r1, =CONFIG_SYS_GIUS_A_VAL
  75. str r1, [r0]
  76. /* CS3 becomes CS3 by clearing reset default bit 1 in FMCR */
  77. ldr r0, =FMCR
  78. ldr r1, =CONFIG_SYS_FMCR_VAL
  79. str r1, [r0]
  80. ldr r0, =CS0U
  81. ldr r1, =CONFIG_SYS_CS0U_VAL
  82. str r1, [r0]
  83. ldr r0, =CS0L
  84. ldr r1, =CONFIG_SYS_CS0L_VAL
  85. str r1, [r0]
  86. ldr r0, =CS1U
  87. ldr r1, =CONFIG_SYS_CS1U_VAL
  88. str r1, [r0]
  89. ldr r0, =CS1L
  90. ldr r1, =CONFIG_SYS_CS1L_VAL
  91. str r1, [r0]
  92. ldr r0, =CS2U
  93. ldr r1, =CONFIG_SYS_CS2U_VAL
  94. str r1, [r0]
  95. ldr r0, =CS2L
  96. ldr r1, =CONFIG_SYS_CS2L_VAL
  97. str r1, [r0]
  98. ldr r0, =CS3U
  99. ldr r1, =CONFIG_SYS_CS3U_VAL
  100. str r1, [r0]
  101. ldr r0, =CS3L
  102. ldr r1, =CONFIG_SYS_CS3L_VAL
  103. str r1, [r0]
  104. ldr r0, =CS4U
  105. ldr r1, =CONFIG_SYS_CS4U_VAL
  106. str r1, [r0]
  107. ldr r0, =CS4L
  108. ldr r1, =CONFIG_SYS_CS4L_VAL
  109. str r1, [r0]
  110. ldr r0, =CS5U
  111. ldr r1, =CONFIG_SYS_CS5U_VAL
  112. str r1, [r0]
  113. ldr r0, =CS5L
  114. ldr r1, =CONFIG_SYS_CS5L_VAL
  115. str r1, [r0]
  116. /* SDRAM Setup */
  117. ldr r0, =SDCTL0
  118. ldr r1, =PRECHARGE_CMD
  119. str r1, [r0]
  120. ldr r0, =0x08200000
  121. ldr r1, =0x0 /* Issue Precharge all Command */
  122. str r1, [r0]
  123. ldr r0, =SDCTL0
  124. ldr r1, =AUTOREFRESH_CMD
  125. str r1, [r0]
  126. ldr r0, =0x08000000
  127. ldr r1, =0x0 /* Issue AutoRefresh Command */
  128. str r1, [r0]
  129. str r1, [r0]
  130. str r1, [r0]
  131. str r1, [r0]
  132. str r1, [r0]
  133. str r1, [r0]
  134. str r1, [r0]
  135. str r1, [r0]
  136. ldr r0, =SDCTL0
  137. ldr r1, =0xb10a8300
  138. str r1, [r0]
  139. ldr r0, =0x08223000 /* CAS Latency 2 */
  140. ldr r1, =0x0 /* Issue Mode Register Command, Burst Length = 8 */
  141. str r1, [r0]
  142. ldr r0, =SDCTL0
  143. ldr r1, =0x810a8200 /* Set to Normal Mode CAS 2 */
  144. str r1, [r0]
  145. mov pc,r10