mem_setup.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Originates from Samsung's u-boot 1.1.6 port to S5PC1xx
  3. *
  4. * Copyright (C) 2009 Samsung Electrnoics
  5. * Inki Dae <inki.dae@samsung.com>
  6. * Heungjun Kim <riverful.kim@samsung.com>
  7. * Minkyu Kang <mk7.kang@samsung.com>
  8. * Kyungmin Park <kyungmin.park@samsung.com>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <config.h>
  29. .globl mem_ctrl_asm_init
  30. mem_ctrl_asm_init:
  31. ldr r6, =S5PC100_DMC_BASE @ 0xE6000000
  32. /* DLL parameter setting */
  33. ldr r1, =0x50101000
  34. str r1, [r6, #0x018] @ PHYCONTROL0
  35. ldr r1, =0xf4
  36. str r1, [r6, #0x01C] @ PHYCONTROL1
  37. ldr r1, =0x0
  38. str r1, [r6, #0x020] @ PHYCONTROL2
  39. /* DLL on */
  40. ldr r1, =0x50101002
  41. str r1, [r6, #0x018] @ PHYCONTROL0
  42. /* DLL start */
  43. ldr r1, =0x50101003
  44. str r1, [r6, #0x018] @ PHYCONTROL0
  45. /* Force value locking for DLL off */
  46. str r1, [r6, #0x018] @ PHYCONTROL0
  47. /* DLL off */
  48. ldr r1, =0x50101001
  49. str r1, [r6, #0x018] @ PHYCONTROL0
  50. /* auto refresh off */
  51. ldr r1, =0xff001010
  52. str r1, [r6, #0x000] @ CONCONTROL
  53. /*
  54. * Burst Length 4, 2 chips, 32-bit, LPDDR
  55. * OFF: dynamic self refresh, force precharge, dynamic power down off
  56. */
  57. ldr r1, =0x00212100
  58. str r1, [r6, #0x004] @ MEMCONTROL
  59. /*
  60. * Note:
  61. * If Bank0 has OneDRAM we place it at 0x2800'0000
  62. * So finally Bank1 should address start at at 0x2000'0000
  63. */
  64. mov r4, #0x0
  65. swap_memory:
  66. /*
  67. * Bank0
  68. * 0x30 -> 0x30000000
  69. * 0xf8 -> 0x37FFFFFF
  70. * [15:12] 0: Linear
  71. * [11:8 ] 2: 9 bits
  72. * [ 7:4 ] 2: 14 bits
  73. * [ 3:0 ] 2: 4 banks
  74. */
  75. ldr r1, =0x30f80222
  76. /* if r4 is 1, swap the bank */
  77. cmp r4, #0x1
  78. orreq r1, r1, #0x08000000
  79. str r1, [r6, #0x008] @ MEMCONFIG0
  80. /*
  81. * Bank1
  82. * 0x38 -> 0x38000000
  83. * 0xf8 -> 0x3fFFFFFF
  84. * [15:12] 0: Linear
  85. * [11:8 ] 2: 9 bits
  86. * [ 7:4 ] 2: 14 bits
  87. * [ 3:0 ] 2: 4 banks
  88. */
  89. ldr r1, =0x38f80222
  90. /* if r4 is 1, swap the bank */
  91. cmp r4, #0x1
  92. biceq r1, r1, #0x08000000
  93. str r1, [r6, #0x00c] @ MEMCONFIG1
  94. ldr r1, =0x20000000
  95. str r1, [r6, #0x014] @ PRECHCONFIG
  96. /*
  97. * FIXME: Please verify these values
  98. * 7.8us * 166MHz %LE %LONG1294(0x50E)
  99. * 7.8us * 133MHz %LE %LONG1038(0x40E),
  100. * 7.8us * 100MHz %LE %LONG780(0x30C),
  101. * 7.8us * 20MHz %LE %LONG156(0x9C),
  102. * 7.8us * 10MHz %LE %LONG78(0x4E)
  103. */
  104. ldr r1, =0x0000050e
  105. str r1, [r6, #0x030] @ TIMINGAREF
  106. /* 166 MHz */
  107. ldr r1, =0x0c233287
  108. str r1, [r6, #0x034] @ TIMINGROW
  109. /* twtr=3 twr=2 trtp=3 cl=3 wl=3 rl=3 */
  110. ldr r1, =0x32330303
  111. str r1, [r6, #0x038] @ TIMINGDATA
  112. /* tfaw=4 sxsr=0x14 txp=0x14 tcke=3 tmrd=3 */
  113. ldr r1, =0x04141433
  114. str r1, [r6, #0x03C] @ TIMINGPOWER
  115. /* chip0 Deselect */
  116. ldr r1, =0x07000000
  117. str r1, [r6, #0x010] @ DIRECTCMD
  118. /* chip0 PALL */
  119. ldr r1, =0x01000000
  120. str r1, [r6, #0x010] @ DIRECTCMD
  121. /* chip0 REFA */
  122. ldr r1, =0x05000000
  123. str r1, [r6, #0x010] @ DIRECTCMD
  124. /* chip0 REFA */
  125. str r1, [r6, #0x010] @ DIRECTCMD
  126. /* chip0 MRS, CL%LE %LONG3, BL%LE %LONG4 */
  127. ldr r1, =0x00000032
  128. str r1, [r6, #0x010] @ DIRECTCMD
  129. /* chip1 Deselect */
  130. ldr r1, =0x07100000
  131. str r1, [r6, #0x010] @ DIRECTCMD
  132. /* chip1 PALL */
  133. ldr r1, =0x01100000
  134. str r1, [r6, #0x010] @ DIRECTCMD
  135. /* chip1 REFA */
  136. ldr r1, =0x05100000
  137. str r1, [r6, #0x010] @ DIRECTCMD
  138. /* chip1 REFA */
  139. str r1, [r6, #0x010] @ DIRECTCMD
  140. /* chip1 MRS, CL%LE %LONG3, BL%LE %LONG4 */
  141. ldr r1, =0x00100032
  142. str r1, [r6, #0x010] @ DIRECTCMD
  143. /* auto refresh on */
  144. ldr r1, =0xff002030
  145. str r1, [r6, #0x000] @ CONCONTROL
  146. /* PwrdnConfig */
  147. ldr r1, =0x00100002
  148. str r1, [r6, #0x028] @ PWRDNCONFIG
  149. /* BL%LE %LONG */
  150. ldr r1, =0xff212100
  151. str r1, [r6, #0x004] @ MEMCONTROL
  152. /* Try to test memory area */
  153. cmp r4, #0x1
  154. beq 1f
  155. mov r4, #0x1
  156. ldr r1, =0x37ffff00
  157. str r4, [r1]
  158. str r4, [r1, #0x4] @ dummy write
  159. ldr r0, [r1]
  160. cmp r0, r4
  161. bne swap_memory
  162. 1:
  163. mov pc, lr
  164. .ltorg