lowlevel_init.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * (C) Copyright 2006 DENX Software Engineering
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <config.h>
  23. #include <version.h>
  24. #include <asm/arch/pxa-regs.h>
  25. DRAM_SIZE: .long CONFIG_SYS_DRAM_SIZE
  26. .macro wait time
  27. ldr r2, =OSCR
  28. mov r3, #0
  29. str r3, [r2]
  30. 0:
  31. ldr r3, [r2]
  32. cmp r3, \time
  33. bls 0b
  34. .endm
  35. .globl lowlevel_init
  36. lowlevel_init:
  37. /* Set up GPIO pins first */
  38. mov r10, lr
  39. /* Configure GPIO Pins 97, 98 UART1 / altern. Fkt. 1 */
  40. ldr r0, =GPIO97
  41. ldr r1, =0x801
  42. str r1, [r0]
  43. ldr r0, =GPIO98
  44. ldr r1, =0x801
  45. str r1, [r0]
  46. /* tebrandt - ASCR, clear the RDH bit */
  47. ldr r0, =ASCR
  48. ldr r1, [r0]
  49. bic r1, r1, #0x80000000
  50. str r1, [r0]
  51. mem_init:
  52. /* Configure ACCR Register - enable DMEMC Clock at 260 / 2 MHz */
  53. ldr r0, =ACCR
  54. ldr r1, [r0]
  55. orr r1, r1, #0x3000
  56. str r1, [r0]
  57. ldr r1, [r0]
  58. /* 2. Programm MDCNFG, leaving DMCEN de-asserted */
  59. ldr r0, =MDCNFG
  60. ldr r1, =(MDCNFG_DMAP | MDCNFG_DTYPE | MDCNFG_DTC_2 | MDCNFG_DCSE0 | MDCNFG_DRAC_13)
  61. /* ldr r1, =0x80000403 */
  62. str r1, [r0]
  63. ldr r1, [r0] /* delay until written */
  64. /* 3. wait nop power up waiting period (200ms)
  65. * optimization: Steps 4+6 can be done during this
  66. */
  67. wait #0x300
  68. /* 4. Perform an initial Rcomp-calibration cycle */
  69. ldr r0, =RCOMP
  70. ldr r1, =0x80000000
  71. str r1, [r0]
  72. ldr r1, [r0] /* delay until written */
  73. /* missing: program for automatic rcomp evaluation cycles */
  74. /* 5. DDR DRAM strobe delay calibration */
  75. ldr r0, =DDR_HCAL
  76. ldr r1, =0x88000007
  77. str r1, [r0]
  78. wait #5
  79. ldr r1, [r0] /* delay until written */
  80. /* Set MDMRS */
  81. ldr r0, =MDMRS
  82. ldr r1, =0x60000033
  83. str r1, [r0]
  84. wait #300
  85. /* Configure MDREFR */
  86. ldr r0, =MDREFR
  87. ldr r1, =0x00000006
  88. str r1, [r0]
  89. ldr r1, [r0]
  90. /* Enable the dynamic memory controller */
  91. ldr r0, =MDCNFG
  92. ldr r1, [r0]
  93. orr r1, r1, #MDCNFG_DMCEN
  94. str r1, [r0]
  95. #ifndef CONFIG_SYS_SKIP_DRAM_SCRUB
  96. /* scrub/init SDRAM if enabled/present */
  97. ldr r8, =CONFIG_SYS_DRAM_BASE /* base address of SDRAM (CONFIG_SYS_DRAM_BASE) */
  98. ldr r9, =CONFIG_SYS_DRAM_SIZE /* size of memory to scrub (CONFIG_SYS_DRAM_SIZE) */
  99. mov r0, #0 /* scrub with 0x0000:0000 */
  100. mov r1, #0
  101. mov r2, #0
  102. mov r3, #0
  103. mov r4, #0
  104. mov r5, #0
  105. mov r6, #0
  106. mov r7, #0
  107. 10: /* fastScrubLoop */
  108. subs r9, r9, #32 /* 8 words/line */
  109. stmia r8!, {r0-r7}
  110. beq 15f
  111. b 10b
  112. #endif /* CONFIG_SYS_SKIP_DRAM_SCRUB */
  113. 15:
  114. /* Mask all interrupts */
  115. mov r1, #0
  116. mcr p6, 0, r1, c1, c0, 0 @ ICMR
  117. /* Disable software and data breakpoints */
  118. mov r0, #0
  119. mcr p15,0,r0,c14,c8,0 /* ibcr0 */
  120. mcr p15,0,r0,c14,c9,0 /* ibcr1 */
  121. mcr p15,0,r0,c14,c4,0 /* dbcon */
  122. /* Enable all debug functionality */
  123. mov r0,#0x80000000
  124. mcr p14,0,r0,c10,c0,0 /* dcsr */
  125. endlowlevel_init:
  126. mov pc, lr