memsetup.S 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 2004 Cucy Systems (http://www.cucy.com)
  3. * Curt Brune <curt@cucy.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <config.h>
  24. #include <version.h>
  25. #include <asm/hardware.h>
  26. /***********************************************************************
  27. * Configure Memory Map
  28. *
  29. * This memory map allows us to relocate from FLASH to SRAM. After
  30. * power-on reset the CPU only knows about the FLASH memory at address
  31. * 0x00000000. After memsetup completes the memory map will be:
  32. *
  33. * Memory Addr
  34. * 0x00000000
  35. * to 8MB SRAM (U5) -- 8MB Map
  36. * 0x00800000
  37. *
  38. * 0x01000000
  39. * to 2MB Flash @ 0x00000000 (U7) -- 2MB Map
  40. * 0x01200000
  41. *
  42. * 0x02000000
  43. * to 512KB Flash @ 0x02000000 (U9) -- 2MB Map
  44. * 0x02080000
  45. *
  46. * Load all 12 memory registers with the STMIA instruction since
  47. * memory access is disabled once these registers are written. The
  48. * last register written re-enables memory access. For more info see
  49. * the user's manual for the S3C4510B, available from Samsung's web
  50. * site. Search for part number "S3C4510B".
  51. *
  52. ***********************************************************************/
  53. .globl memsetup
  54. memsetup:
  55. /* preserve the temp register (r12 AKA ip) and remap it. */
  56. ldr r1, =SRAM_BASE+0xC
  57. add r0, r12, #0x01000000
  58. str r0, [r1]
  59. /* remap the link register for when we return */
  60. add lr, lr, #0x01000000
  61. /* store a short program in the on chip SRAM, which is
  62. * unaffected when remapping memory. Note the cache must be
  63. * disabled for the on chip SRAM to be available.
  64. */
  65. ldr r1, =SRAM_BASE
  66. ldr r0, =0xe8801ffe /* stmia r0, {r1-r12} */
  67. str r0, [r1]
  68. add r1, r1, #4
  69. ldr r0, =0xe59fc000 /* ldr r12, [pc, #0] */
  70. str r0, [r1]
  71. add r1, r1, #4
  72. ldr r0, =0xe1a0f00e /* mov pc, lr */
  73. str r0, [r1]
  74. adr r0, memory_map_data
  75. ldmia r0, {r1-r12}
  76. ldr r0, =REG_EXTDBWTH
  77. ldr pc, =SRAM_BASE
  78. .globl reset_cpu
  79. reset_cpu:
  80. /*
  81. * reset the cpu by re-mapping FLASH 0 to 0x0 and jumping to
  82. * address 0x0. We accomplish this by storing a few
  83. * instructions into the on chip SRAM (8KB) and run from
  84. * there. Note the cache must be disabled for the on chip
  85. * SRAM to be available.
  86. *
  87. * load r2 with REG_ROMCON0
  88. * load r3 with 0x12040060 configure FLASH bank 0 @ 0x00000000
  89. * load r4 with REG_DRAMCON0
  90. * load r5 with 0x08000380 configure RAM bank 0 @ 0x01000000
  91. * load r6 with REG_REFEXTCON
  92. * load r7 with 0x9c218360
  93. * load r8 with 0x0
  94. * store str r3,[r2] @ SRAM_BASE
  95. * store str r5,[r4] @ SRAM_BASE + 0x4
  96. * store str r7,[r6] @ SRAM_BASE + 0x8
  97. * store mov pc,r8 @ SRAM_BASE + 0xC
  98. * mov pc, SRAM_BASE
  99. *
  100. */
  101. /* disable cache */
  102. ldr r0, =REG_SYSCFG
  103. ldr r1, =0x83ffffa0 /* cache-disabled */
  104. str r1, [r0]
  105. ldr r2, =REG_ROMCON0
  106. ldr r3, =0x02000060 /* Bank0 2MB FLASH @ 0x00000000 */
  107. ldr r4, =REG_DRAMCON0
  108. ldr r5, =0x18040380 /* DRAM0 8MB SRAM @ 0x01000000 */
  109. ldr r6, =REG_REFEXTCON
  110. ldr r7, =0xce278360
  111. ldr r8, =0x00000000
  112. ldr r1, =SRAM_BASE
  113. ldr r0, =0xe5823000 /* str r3, [r2] */
  114. str r0, [r1]
  115. ldr r1, =SRAM_BASE+4
  116. ldr r0, =0xe5845000 /* str r5, [r4] */
  117. str r0, [r1]
  118. ldr r1, =SRAM_BASE+8
  119. ldr r0, =0xe5867000 /* str r7, [r6] */
  120. str r0, [r1]
  121. ldr r1, =SRAM_BASE+0xC
  122. ldr r0, =0xe1a0f008 /* mov pc, r8 */
  123. str r0, [r1]
  124. ldr r1, =SRAM_BASE
  125. mov pc, r1
  126. /* never return */
  127. /************************************************************************
  128. * Below are twelve 32-bit values for the twelve memory registers of
  129. * the system manager, starting with register REG_EXTDBWTH.
  130. ***********************************************************************/
  131. memory_map_data:
  132. .long 0x00f03005 /* memory widths */
  133. .long 0x12040060 /* Bank0 2MB FLASH @ 0x01000000 */
  134. .long 0x22080060 /* Bank1 512KB FLASH @ 0x02000000 */
  135. .long 0x00000000
  136. .long 0x00000000
  137. .long 0x00000000
  138. .long 0x00000000
  139. .long 0x08000380 /* DRAM0 8MB SRAM @ 0x00000000 */
  140. .long 0x00000000
  141. .long 0x00000000
  142. .long 0x00000000
  143. .long 0x9c218360 /* enable memory */