mem_setup.S 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. /*
  2. * Memory setup for ORIGEN board based on S5PV310
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <config.h>
  25. #include "origen_setup.h"
  26. #define SET_MIU
  27. .globl mem_ctrl_asm_init
  28. mem_ctrl_asm_init:
  29. /*
  30. * Async bridge configuration at CPU_core:
  31. * 1: half_sync
  32. * 0: full_sync
  33. */
  34. ldr r0, =ASYNC_CONFIG
  35. mov r1, #1
  36. str r1, [r0]
  37. #ifdef SET_MIU
  38. ldr r0, =S5PC210_MIU_BASE
  39. /* Interleave: 2Bit, Interleave_bit1: 0x21, Interleave_bit2: 0x7 */
  40. ldr r1, =0x20001507
  41. str r1, [r0, #APB_SFR_INTERLEAVE_CONF_OFFSET]
  42. /* Update MIU Configuration */
  43. ldr r1, =0x00000001
  44. str r1, [r0, #APB_SFR_ARBRITATION_CONF_OFFSET]
  45. #endif
  46. /* DREX0 */
  47. ldr r0, =S5PC210_DMC0_BASE
  48. /*
  49. * DLL Parameter Setting:
  50. * Termination: Enable R/W
  51. * Phase Delay for DQS Cleaning: 180' Shift
  52. */
  53. ldr r1, =0xe0000086
  54. str r1, [r0, #DMC_PHYCONTROL1]
  55. /*
  56. * ZQ Calibration
  57. * Termination: Disable
  58. * Auto Calibration Start: Enable
  59. */
  60. ldr r1, =0xE3855703
  61. str r1, [r0, #DMC_PHYZQCONTROL]
  62. /* Wait ?us*/
  63. mov r2, #0x100000
  64. 1: subs r2, r2, #1
  65. bne 1b
  66. /*
  67. * Update DLL Information:
  68. * Force DLL Resyncronization
  69. */
  70. ldr r1, =0xe000008e
  71. str r1, [r0, #DMC_PHYCONTROL1]
  72. /* Reset Force DLL Resyncronization */
  73. ldr r1, =0xe0000086
  74. str r1, [r0, #DMC_PHYCONTROL1]
  75. /* Enable Differential DQS, DLL Off*/
  76. ldr r1, =0x71101008
  77. str r1, [r0, #DMC_PHYCONTROL0]
  78. /* Activate PHY DLL: DLL On */
  79. ldr r1, =0x7110100A
  80. str r1, [r0, #DMC_PHYCONTROL0]
  81. /* Set DLL Parameters */
  82. ldr r1, =0xe0000086
  83. str r1, [r0, #DMC_PHYCONTROL1]
  84. /* DLL Start */
  85. ldr r1, =0x7110100B
  86. str r1, [r0, #DMC_PHYCONTROL0]
  87. ldr r1, =0x00000000
  88. str r1, [r0, #DMC_PHYCONTROL2]
  89. /* Set Clock Ratio of Bus clock to Memory Clock */
  90. ldr r1, =0x0FFF301a
  91. str r1, [r0, #DMC_CONCONTROL]
  92. /*
  93. * Memor Burst length: 8
  94. * Number of chips: 2
  95. * Memory Bus width: 32 bit
  96. * Memory Type: DDR3
  97. * Additional Latancy for PLL: 1 Cycle
  98. */
  99. ldr r1, =0x00312640
  100. str r1, [r0, #DMC_MEMCONTROL]
  101. /*
  102. * Memory Configuration Chip 0
  103. * Address Mapping: Interleaved
  104. * Number of Column address Bits: 10 bits
  105. * Number of Rows Address Bits: 14
  106. * Number of Banks: 8
  107. */
  108. ldr r1, =0x20e01323
  109. str r1, [r0, #DMC_MEMCONFIG0]
  110. /*
  111. * Memory Configuration Chip 1
  112. * Address Mapping: Interleaved
  113. * Number of Column address Bits: 10 bits
  114. * Number of Rows Address Bits: 14
  115. * Number of Banks: 8
  116. */
  117. ldr r1, =0x40e01323
  118. str r1, [r0, #DMC_MEMCONFIG1]
  119. /* Config Precharge Policy */
  120. ldr r1, =0xff000000
  121. str r1, [r0, #DMC_PRECHCONFIG]
  122. /*
  123. * TimingAref, TimingRow, TimingData, TimingPower Setting:
  124. * Values as per Memory AC Parameters
  125. */
  126. ldr r1, =0x000000BB
  127. str r1, [r0, #DMC_TIMINGAREF]
  128. ldr r1, =0x4046654f
  129. str r1, [r0, #DMC_TIMINGROW]
  130. ldr r1, =0x46400506
  131. str r1, [r0, #DMC_TIMINGDATA]
  132. ldr r1, =0x52000A3C
  133. str r1, [r0, #DMC_TIMINGPOWER]
  134. /* Chip0: NOP Command: Assert and Hold CKE to high level */
  135. ldr r1, =0x07000000
  136. str r1, [r0, #DMC_DIRECTCMD]
  137. /* Wait ?us*/
  138. mov r2, #0x100000
  139. 2: subs r2, r2, #1
  140. bne 2b
  141. /* Chip0: EMRS2, EMRS3, EMRS, MRS Commands Using Direct Command */
  142. ldr r1, =0x00020000
  143. str r1, [r0, #DMC_DIRECTCMD]
  144. ldr r1, =0x00030000
  145. str r1, [r0, #DMC_DIRECTCMD]
  146. ldr r1, =0x00010002
  147. str r1, [r0, #DMC_DIRECTCMD]
  148. ldr r1, =0x00000328
  149. str r1, [r0, #DMC_DIRECTCMD]
  150. /* Wait ?us*/
  151. mov r2, #0x100000
  152. 3: subs r2, r2, #1
  153. bne 3b
  154. /* Chip0: ZQINIT */
  155. ldr r1, =0x0a000000
  156. str r1, [r0, #DMC_DIRECTCMD]
  157. /* Wait ?us*/
  158. mov r2, #0x100000
  159. 4: subs r2, r2, #1
  160. bne 4b
  161. /* Chip1: NOP Command: Assert and Hold CKE to high level */
  162. ldr r1, =0x07100000
  163. str r1, [r0, #DMC_DIRECTCMD]
  164. /* Wait ?us*/
  165. mov r2, #0x100000
  166. 5: subs r2, r2, #1
  167. bne 5b
  168. /* Chip1: EMRS2, EMRS3, EMRS, MRS Commands Using Direct Command */
  169. ldr r1, =0x00120000
  170. str r1, [r0, #DMC_DIRECTCMD]
  171. ldr r1, =0x00130000
  172. str r1, [r0, #DMC_DIRECTCMD]
  173. ldr r1, =0x00110002
  174. str r1, [r0, #DMC_DIRECTCMD]
  175. ldr r1, =0x00100328
  176. str r1, [r0, #DMC_DIRECTCMD]
  177. /* Wait ?us*/
  178. mov r2, #0x100000
  179. 6: subs r2, r2, #1
  180. bne 6b
  181. /* Chip1: ZQINIT */
  182. ldr r1, =0x0a100000
  183. str r1, [r0, #DMC_DIRECTCMD]
  184. /* Wait ?us*/
  185. mov r2, #0x100000
  186. 7: subs r2, r2, #1
  187. bne 7b
  188. ldr r1, =0xe000008e
  189. str r1, [r0, #DMC_PHYCONTROL1]
  190. ldr r1, =0xe0000086
  191. str r1, [r0, #DMC_PHYCONTROL1]
  192. /* Wait ?us*/
  193. mov r2, #0x100000
  194. 8: subs r2, r2, #1
  195. bne 8b
  196. /* DREX1 */
  197. ldr r0, =S5PC210_DMC1_BASE @0x10410000
  198. /*
  199. * DLL Parameter Setting:
  200. * Termination: Enable R/W
  201. * Phase Delay for DQS Cleaning: 180' Shift
  202. */
  203. ldr r1, =0xe0000086
  204. str r1, [r0, #DMC_PHYCONTROL1]
  205. /*
  206. * ZQ Calibration:
  207. * Termination: Disable
  208. * Auto Calibration Start: Enable
  209. */
  210. ldr r1, =0xE3855703
  211. str r1, [r0, #DMC_PHYZQCONTROL]
  212. /* Wait ?us*/
  213. mov r2, #0x100000
  214. 1: subs r2, r2, #1
  215. bne 1b
  216. /*
  217. * Update DLL Information:
  218. * Force DLL Resyncronization
  219. */
  220. ldr r1, =0xe000008e
  221. str r1, [r0, #DMC_PHYCONTROL1]
  222. /* Reset Force DLL Resyncronization */
  223. ldr r1, =0xe0000086
  224. str r1, [r0, #DMC_PHYCONTROL1]
  225. /* Enable Differential DQS, DLL Off*/
  226. ldr r1, =0x71101008
  227. str r1, [r0, #DMC_PHYCONTROL0]
  228. /* Activate PHY DLL: DLL On */
  229. ldr r1, =0x7110100A
  230. str r1, [r0, #DMC_PHYCONTROL0]
  231. /* Set DLL Parameters */
  232. ldr r1, =0xe0000086
  233. str r1, [r0, #DMC_PHYCONTROL1]
  234. /* DLL Start */
  235. ldr r1, =0x7110100B
  236. str r1, [r0, #DMC_PHYCONTROL0]
  237. ldr r1, =0x00000000
  238. str r1, [r0, #DMC_PHYCONTROL2]
  239. /* Set Clock Ratio of Bus clock to Memory Clock */
  240. ldr r1, =0x0FFF301a
  241. str r1, [r0, #DMC_CONCONTROL]
  242. /*
  243. * Memor Burst length: 8
  244. * Number of chips: 2
  245. * Memory Bus width: 32 bit
  246. * Memory Type: DDR3
  247. * Additional Latancy for PLL: 1 Cycle
  248. */
  249. ldr r1, =0x00312640
  250. str r1, [r0, #DMC_MEMCONTROL]
  251. /*
  252. * Memory Configuration Chip 0
  253. * Address Mapping: Interleaved
  254. * Number of Column address Bits: 10 bits
  255. * Number of Rows Address Bits: 14
  256. * Number of Banks: 8
  257. */
  258. ldr r1, =0x20e01323
  259. str r1, [r0, #DMC_MEMCONFIG0]
  260. /*
  261. * Memory Configuration Chip 1
  262. * Address Mapping: Interleaved
  263. * Number of Column address Bits: 10 bits
  264. * Number of Rows Address Bits: 14
  265. * Number of Banks: 8
  266. */
  267. ldr r1, =0x40e01323
  268. str r1, [r0, #DMC_MEMCONFIG1]
  269. /* Config Precharge Policy */
  270. ldr r1, =0xff000000
  271. str r1, [r0, #DMC_PRECHCONFIG]
  272. /*
  273. * TimingAref, TimingRow, TimingData, TimingPower Setting:
  274. * Values as per Memory AC Parameters
  275. */
  276. ldr r1, =0x000000BB
  277. str r1, [r0, #DMC_TIMINGAREF]
  278. ldr r1, =0x4046654f
  279. str r1, [r0, #DMC_TIMINGROW]
  280. ldr r1, =0x46400506
  281. str r1, [r0, #DMC_TIMINGDATA]
  282. ldr r1, =0x52000A3C
  283. str r1, [r0, #DMC_TIMINGPOWER]
  284. /* Chip0: NOP Command: Assert and Hold CKE to high level */
  285. ldr r1, =0x07000000
  286. str r1, [r0, #DMC_DIRECTCMD]
  287. /* Wait ?us*/
  288. mov r2, #0x100000
  289. 2: subs r2, r2, #1
  290. bne 2b
  291. /* Chip0: EMRS2, EMRS3, EMRS, MRS Commands Using Direct Command */
  292. ldr r1, =0x00020000
  293. str r1, [r0, #DMC_DIRECTCMD]
  294. ldr r1, =0x00030000
  295. str r1, [r0, #DMC_DIRECTCMD]
  296. ldr r1, =0x00010002
  297. str r1, [r0, #DMC_DIRECTCMD]
  298. ldr r1, =0x00000328
  299. str r1, [r0, #DMC_DIRECTCMD]
  300. /* Wait ?us*/
  301. mov r2, #0x100000
  302. 3: subs r2, r2, #1
  303. bne 3b
  304. /* Chip 0: ZQINIT */
  305. ldr r1, =0x0a000000
  306. str r1, [r0, #DMC_DIRECTCMD]
  307. /* Wait ?us*/
  308. mov r2, #0x100000
  309. 4: subs r2, r2, #1
  310. bne 4b
  311. /* Chip1: NOP Command: Assert and Hold CKE to high level */
  312. ldr r1, =0x07100000
  313. str r1, [r0, #DMC_DIRECTCMD]
  314. /* Wait ?us*/
  315. mov r2, #0x100000
  316. 5: subs r2, r2, #1
  317. bne 5b
  318. /* Chip1: EMRS2, EMRS3, EMRS, MRS Commands Using Direct Command */
  319. ldr r1, =0x00120000
  320. str r1, [r0, #DMC_DIRECTCMD]
  321. ldr r1, =0x00130000
  322. str r1, [r0, #DMC_DIRECTCMD]
  323. ldr r1, =0x00110002
  324. str r1, [r0, #DMC_DIRECTCMD]
  325. ldr r1, =0x00100328
  326. str r1, [r0, #DMC_DIRECTCMD]
  327. /* Wait ?us*/
  328. mov r2, #0x100000
  329. 6: subs r2, r2, #1
  330. bne 6b
  331. /* Chip1: ZQINIT */
  332. ldr r1, =0x0a100000
  333. str r1, [r0, #DMC_DIRECTCMD]
  334. /* Wait ?us*/
  335. mov r2, #0x100000
  336. 7: subs r2, r2, #1
  337. bne 7b
  338. ldr r1, =0xe000008e
  339. str r1, [r0, #DMC_PHYCONTROL1]
  340. ldr r1, =0xe0000086
  341. str r1, [r0, #DMC_PHYCONTROL1]
  342. /* Wait ?us*/
  343. mov r2, #0x100000
  344. 8: subs r2, r2, #1
  345. bne 8b
  346. /* turn on DREX0, DREX1 */
  347. ldr r0, =S5PC210_DMC0_BASE
  348. ldr r1, =0x0FFF303a
  349. str r1, [r0, #DMC_CONCONTROL]
  350. ldr r0, =S5PC210_DMC1_BASE
  351. ldr r1, =0x0FFF303a
  352. str r1, [r0, #DMC_CONCONTROL]
  353. mov pc, lr