platform.S 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2003
  5. * Texas Instruments, <www.ti.com>
  6. * Kshitij Gupta <Kshitij@ti.com>
  7. *
  8. * Modified for the NS9750 DevBoard by
  9. * (C) Copyright 2004 by FS Forth-Systeme GmbH.
  10. * Markus Pietrek <mpietrek@fsforth.de>
  11. * @References: [1] NS9750 Hardware Reference/December 2003
  12. * [2] ns9750_a.cmd from MAJIC configuration
  13. *
  14. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. */
  32. #include <config.h>
  33. #include <version.h>
  34. #if defined(CONFIG_NS9750DEV)
  35. # ifdef CONFIG_INIT_CRITICAL
  36. # include <./ns9750_sys.h>
  37. # include <./ns9750_mem.h>
  38. # endif
  39. #endif
  40. /***********************************************************************
  41. * @Function: write_register_block
  42. * @Return: nothing
  43. * @Descr: Copies the register block of register_offset:register value to
  44. * the registers at base r0. The block is assumed to start in RAM at r1
  45. * and end at r2. The linked RAM base address of U-Boot is assumed to be
  46. * in r5 while the ROM base address we are running from is r6
  47. * Uses r3 and r4 as tempory registers
  48. ***********************************************************************/
  49. .macro write_register_block
  50. @@ map the addresses to high memory
  51. sub r1, r1, r5
  52. add r1, r1, r6
  53. sub r2, r2, r5
  54. add r2, r2, r6
  55. @@ copy all
  56. 1:
  57. @@ Write register/value pair starting at [r1] to register base r0
  58. ldr r3, [r1], #4
  59. ldr r4, [r1], #4
  60. str r4, [r0,r3]
  61. cmp r1, r2
  62. blt 1b
  63. .endm
  64. _TEXT_BASE:
  65. .word TEXT_BASE @ sdram load addr from config.mk
  66. _PHYS_FLASH:
  67. .word PHYS_FLASH_1 @ real flash address (without mirroring)
  68. _CAS_LATENCY:
  69. .word 0x00022000 @ for CAS2 latency
  70. #ifdef CONFIG_INIT_CRITICAL
  71. .globl platformsetup
  72. platformsetup:
  73. /* U-Boot may be linked to RAM at 0x780000. But this code will run in
  74. flash from 0x0. But in order to enable RAM we have to disable the
  75. mirror bit, therefore we have to jump to our real flash address
  76. beginning at PHYS_FLASH_1 (CS4 Base). Therefore,
  77. _run_at_real_flash_address may be 0x500003b0 while be linked to
  78. 0x7803b0. So we must modify our linked addresses */
  79. @@ branch to high memory address, away from 0x0
  80. ldr r5, _TEXT_BASE
  81. ldr r6, _PHYS_FLASH
  82. ldr r0, =_run_at_real_flash_address
  83. sub r0, r0, r5
  84. add r0, r0, r6
  85. mov pc, r0
  86. nop @ for pipelining
  87. _run_at_real_flash_address:
  88. @@ now we are running > PHYS_FLASH_1, safe to enable memory controller
  89. @@ Write Memory Configuration Registers
  90. ldr r0, _NS9750_MEM_MODULE_BASE
  91. ldr r1, =_MEM_CONFIG_START
  92. ldr r2, =_MEM_CONFIG_END
  93. write_register_block
  94. @@ Give SDRAM some time to settle
  95. @@ @TODO. According to [2] it should be 2 AHB cycles. Check
  96. ldr r1, =0x50
  97. _sdram_settle:
  98. subs r1, r1, #1
  99. bne _sdram_settle
  100. _enable_mappings:
  101. @@ Enable SDRAM Mode
  102. ldr r1, =_MEM_MODE_START
  103. ldr r2, =_MEM_MODE_END
  104. write_register_block
  105. ldr r3, _CAS_LATENCY @ perform one read from SDRAM
  106. ldr r3, [r3]
  107. @@ Enable SDRAM and memory mappings
  108. ldr r1, =_MEM_ENABLE_START
  109. ldr r2, =_MEM_ENABLE_END
  110. write_register_block
  111. @@ Activate AHB monitor
  112. ldr r0, =NS9750_SYS_MODULE_BASE
  113. ldr r1, =_AHB_MONITOR_START
  114. ldr r2, =_AHB_MONITOR_END
  115. write_register_block
  116. _relocate_lr:
  117. /* lr and ip (from cpu_init_crit) are still based on 0x0, relocate it to
  118. PHYS_FLASH. */
  119. mov r1, ip
  120. add r1, r1, r6
  121. mov ip, r1
  122. mov r1, lr
  123. add r1, r1, r6
  124. mov lr, r1
  125. @@ back to arch calling code
  126. mov pc, lr
  127. .ltorg
  128. _NS9750_MEM_MODULE_BASE:
  129. .word NS9750_MEM_MODULE_BASE
  130. _MEM_CONFIG_START:
  131. /* Table of 2 32bit entries. First word is register address offset
  132. relative to NS9750_MEM_MODULE_BASE, second one is value. They are
  133. written in order of appearance */
  134. @@ Register values taken from [2]
  135. .word NS9750_MEM_CTRL
  136. .word NS9750_MEM_CTRL_E
  137. .word NS9750_MEM_DYN_REFRESH
  138. .word (0x6 & NS9750_MEM_DYN_REFRESH_MA)
  139. .word NS9750_MEM_DYN_READ_CFG
  140. .word (0x1 & NS9750_MEM_DYN_READ_CFG_MA)
  141. .word NS9750_MEM_DYN_TRP
  142. .word (0x1 & NS9750_MEM_DYN_TRP_MA)
  143. .word NS9750_MEM_DYN_TRAS
  144. .word (0x4 & NS9750_MEM_DYN_TRAS_MA)
  145. .word NS9750_MEM_DYN_TAPR
  146. .word (0x1 & NS9750_MEM_DYN_TRAS_MA)
  147. .word NS9750_MEM_DYN_TDAL
  148. .word (0x5 & NS9750_MEM_DYN_TDAL_MA)
  149. .word NS9750_MEM_DYN_TWR
  150. .word (0x1 & NS9750_MEM_DYN_TWR_MA)
  151. .word NS9750_MEM_DYN_TRC
  152. .word (0x6 & NS9750_MEM_DYN_TRC_MA)
  153. .word NS9750_MEM_DYN_TRFC
  154. .word (0x6 & NS9750_MEM_DYN_TRFC_MA)
  155. .word NS9750_MEM_DYN_TRRD
  156. .word (0x1 & NS9750_MEM_DYN_TRRD_MA)
  157. .word NS9750_MEM_DYN_TMRD
  158. .word (0x1 & NS9750_MEM_DYN_TMRD_MA)
  159. @@ CS 4
  160. .word NS9750_MEM_DYN_CFG(0)
  161. .word (NS9750_MEM_DYN_CFG_AM | \
  162. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  163. .word NS9750_MEM_DYN_RAS_CAS(0)
  164. .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
  165. (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
  166. @@ CS 5
  167. .word NS9750_MEM_DYN_CFG(1)
  168. .word (NS9750_MEM_DYN_CFG_AM | \
  169. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  170. .word NS9750_MEM_DYN_RAS_CAS(1)
  171. .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
  172. (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
  173. @@ CS 6
  174. .word NS9750_MEM_DYN_CFG(2)
  175. .word (NS9750_MEM_DYN_CFG_AM | \
  176. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  177. .word NS9750_MEM_DYN_RAS_CAS(2)
  178. .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
  179. (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
  180. @@ CS 7
  181. .word NS9750_MEM_DYN_CFG(3)
  182. .word (NS9750_MEM_DYN_CFG_AM | \
  183. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  184. .word NS9750_MEM_DYN_RAS_CAS(3)
  185. .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
  186. (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
  187. .word NS9750_MEM_DYN_CTRL
  188. .word (NS9750_MEM_DYN_CTRL_I_PALL | \
  189. NS9750_MEM_DYN_CTRL_SR | \
  190. NS9750_MEM_DYN_CTRL_CE )
  191. .word NS9750_MEM_DYN_REFRESH
  192. .word (0x1 & NS9750_MEM_DYN_REFRESH_MA)
  193. @@ No further register settings after refresh
  194. _MEM_CONFIG_END:
  195. _MEM_MODE_START:
  196. .word NS9750_MEM_DYN_REFRESH
  197. .word (0x30 & NS9750_MEM_DYN_REFRESH_MA)
  198. .word NS9750_MEM_DYN_CTRL
  199. .word (NS9750_MEM_DYN_CTRL_I_MODE | \
  200. NS9750_MEM_DYN_CTRL_SR | \
  201. NS9750_MEM_DYN_CTRL_CE )
  202. _MEM_MODE_END:
  203. _MEM_ENABLE_START:
  204. .word NS9750_MEM_DYN_CTRL
  205. .word (NS9750_MEM_DYN_CTRL_I_NORMAL | \
  206. NS9750_MEM_DYN_CTRL_SR | \
  207. NS9750_MEM_DYN_CTRL_CE )
  208. @@ CS 4
  209. .word NS9750_MEM_DYN_CFG(0)
  210. .word (NS9750_MEM_DYN_CFG_BDMC | \
  211. NS9750_MEM_DYN_CFG_AM | \
  212. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  213. @@ CS 5
  214. .word NS9750_MEM_DYN_CFG(1)
  215. .word (NS9750_MEM_DYN_CFG_BDMC | \
  216. NS9750_MEM_DYN_CFG_AM | \
  217. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  218. @@ CS 6
  219. .word NS9750_MEM_DYN_CFG(2)
  220. .word (NS9750_MEM_DYN_CFG_BDMC | \
  221. NS9750_MEM_DYN_CFG_AM | \
  222. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  223. @@ CS 7
  224. .word NS9750_MEM_DYN_CFG(3)
  225. .word (NS9750_MEM_DYN_CFG_BDMC | \
  226. NS9750_MEM_DYN_CFG_AM | \
  227. (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
  228. _MEM_ENABLE_END:
  229. _AHB_MONITOR_START:
  230. .word NS9750_SYS_AHB_TIMEOUT
  231. .word 0x01000100 @ @TODO not calculated yet
  232. .word NS9750_SYS_AHB_MON
  233. .word (NS9750_SYS_AHB_MON_BMTC_GEN_IRQ | \
  234. NS9750_SYS_AHB_MON_BATC_GEN_IRQ)
  235. _AHB_MONITOR_END:
  236. #endif /* CONFIG_INIT_CRITICAL */