lowlevel_init.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
  3. * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
  4. *
  5. * Modified for the at91rm9200dk board by
  6. * (C) Copyright 2004
  7. * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <config.h>
  28. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  29. #include <asm/arch/hardware.h>
  30. #include <asm/arch/at91_mc.h>
  31. #include <asm/arch/at91_pmc.h>
  32. #include <asm/arch/at91_pio.h>
  33. #define ARM920T_CONTROL 0xC0000000 /* @ set bit 31 (iA) and 30 (nF) */
  34. _MTEXT_BASE:
  35. #undef START_FROM_MEM
  36. #ifdef START_FROM_MEM
  37. .word CONFIG_SYS_TEXT_BASE-PHYS_FLASH_1
  38. #else
  39. .word CONFIG_SYS_TEXT_BASE
  40. #endif
  41. .globl lowlevel_init
  42. lowlevel_init:
  43. ldr r1, =AT91_ASM_PMC_MOR
  44. /* Main oscillator Enable register */
  45. #ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
  46. ldr r0, =0x0000FF01 /* Enable main oscillator */
  47. #else
  48. ldr r0, =0x0000FF00 /* Disable main oscillator */
  49. #endif
  50. str r0, [r1] /*AT91C_CKGR_MOR] */
  51. /* Add loop to compensate Main Oscillator startup time */
  52. ldr r0, =0x00000010
  53. LoopOsc:
  54. subs r0, r0, #1
  55. bhi LoopOsc
  56. /* memory control configuration */
  57. /* this isn't very elegant, but what the heck */
  58. ldr r0, =SMRDATA
  59. ldr r1, _MTEXT_BASE
  60. sub r0, r0, r1
  61. add r2, r0, #80
  62. pllloop:
  63. /* the address */
  64. ldr r1, [r0], #4
  65. /* the value */
  66. ldr r3, [r0], #4
  67. str r3, [r1]
  68. cmp r2, r0
  69. bne pllloop
  70. /* delay - this is all done by guess */
  71. ldr r0, =0x00010000
  72. /* (vs reading PMC_SR for LOCKA, LOCKB ... or MOSCS earlier) */
  73. lock:
  74. subs r0, r0, #1
  75. bhi lock
  76. ldr r0, =SMRDATA1
  77. ldr r1, _MTEXT_BASE
  78. sub r0, r0, r1
  79. add r2, r0, #176
  80. sdinit:
  81. /* the address */
  82. ldr r1, [r0], #4
  83. /* the value */
  84. ldr r3, [r0], #4
  85. str r3, [r1]
  86. cmp r2, r0
  87. bne sdinit
  88. /* switch from FastBus to Asynchronous clock mode */
  89. mrc p15, 0, r0, c1, c0, 0
  90. orr r0, r0, #ARM920T_CONTROL
  91. mcr p15, 0, r0, c1, c0, 0
  92. /* everything is fine now */
  93. mov pc, lr
  94. .ltorg
  95. SMRDATA:
  96. .word AT91_ASM_MC_EBI_CFG
  97. .word CONFIG_SYS_EBI_CFGR_VAL
  98. .word AT91_ASM_MC_SMC_CSR0
  99. .word CONFIG_SYS_SMC_CSR0_VAL
  100. .word AT91_ASM_PMC_PLLAR
  101. .word CONFIG_SYS_PLLAR_VAL
  102. .word AT91_ASM_PMC_PLLBR
  103. .word CONFIG_SYS_PLLBR_VAL
  104. .word AT91_ASM_PMC_MCKR
  105. .word CONFIG_SYS_MCKR_VAL
  106. /* here there's a delay */
  107. SMRDATA1:
  108. .word AT91_ASM_PIOC_ASR
  109. .word CONFIG_SYS_PIOC_ASR_VAL
  110. .word AT91_ASM_PIOC_BSR
  111. .word CONFIG_SYS_PIOC_BSR_VAL
  112. .word AT91_ASM_PIOC_PDR
  113. .word CONFIG_SYS_PIOC_PDR_VAL
  114. .word AT91_ASM_MC_EBI_CSA
  115. .word CONFIG_SYS_EBI_CSA_VAL
  116. .word AT91_ASM_MC_SDRAMC_CR
  117. .word CONFIG_SYS_SDRC_CR_VAL
  118. .word AT91_ASM_MC_SDRAMC_MR
  119. .word CONFIG_SYS_SDRC_MR_VAL
  120. .word CONFIG_SYS_SDRAM
  121. .word CONFIG_SYS_SDRAM_VAL
  122. .word AT91_ASM_MC_SDRAMC_MR
  123. .word CONFIG_SYS_SDRC_MR_VAL1
  124. .word CONFIG_SYS_SDRAM
  125. .word CONFIG_SYS_SDRAM_VAL
  126. .word CONFIG_SYS_SDRAM
  127. .word CONFIG_SYS_SDRAM_VAL
  128. .word CONFIG_SYS_SDRAM
  129. .word CONFIG_SYS_SDRAM_VAL
  130. .word CONFIG_SYS_SDRAM
  131. .word CONFIG_SYS_SDRAM_VAL
  132. .word CONFIG_SYS_SDRAM
  133. .word CONFIG_SYS_SDRAM_VAL
  134. .word CONFIG_SYS_SDRAM
  135. .word CONFIG_SYS_SDRAM_VAL
  136. .word CONFIG_SYS_SDRAM
  137. .word CONFIG_SYS_SDRAM_VAL
  138. .word CONFIG_SYS_SDRAM
  139. .word CONFIG_SYS_SDRAM_VAL
  140. .word AT91_ASM_MC_SDRAMC_MR
  141. .word CONFIG_SYS_SDRC_MR_VAL2
  142. .word CONFIG_SYS_SDRAM1
  143. .word CONFIG_SYS_SDRAM_VAL
  144. .word AT91_ASM_MC_SDRAMC_TR
  145. .word CONFIG_SYS_SDRC_TR_VAL
  146. .word CONFIG_SYS_SDRAM
  147. .word CONFIG_SYS_SDRAM_VAL
  148. .word AT91_ASM_MC_SDRAMC_MR
  149. .word CONFIG_SYS_SDRC_MR_VAL3
  150. .word CONFIG_SYS_SDRAM
  151. .word CONFIG_SYS_SDRAM_VAL
  152. /* SMRDATA1 is 176 bytes long */
  153. #endif /* CONFIG_SKIP_LOWLEVEL_INIT */