Chinaunix首页 | 论坛 | 博客
  • 博客访问: 498973
  • 博文数量: 223
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2145
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-01 10:23
个人简介

该坚持的时候坚持,该妥协的时候妥协,该放弃的时候放弃

文章分类

全部博文(223)

文章存档

2017年(56)

2016年(118)

2015年(3)

2014年(46)

我的朋友

分类: 嵌入式

2016-09-24 21:55:10


点击(此处)折叠或打开

  1. /*
  2. * Memory Setup stuff - taken from blob memsetup.S
  3. *
  4. * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
  5. * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
  6. *
  7. * Modified for the Samsung SMDK2410 by
  8. * (C) Copyright 2002
  9. * David Mueller, ELSOFT AG,
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include
  30. #include
  31. #include
  32. #include "smdk2440_val.h"
  33. _TEXT_BASE:
  34. .word TEXT_BASE
  35. .globl lowlevel_init
  36. lowlevel_init:
  37. mov r12, lr
  38. /* init system clock 时钟初始化*/
  39. bl system_clock_init
  40. /* for UART 初始化串口*/
  41. bl uart_asm_init
  42. /* simple init for NAND 简单初始化NAND*/
  43. bl nand_asm_init
  44. /* when we already run in ram, we don't need to relocate U-Boot.
  45. * and actually, memory controller must be configured before U-Boot
  46. * is running in ram. 判断是否在内存中,进行初始化内存 
  47. */
  48. ldr r0, =0xf0000fff
  49. bic r1, pc, r0 /* r0 <- current base addr of code */
  50. ldr r2, _TEXT_BASE /* r1 <- original base addr in ram */
  51. bic r2, r2, r0 /* r0 <- current base addr of code */
  52. cmp r1, r2 /* compare r0, r1 */
  53. beq 1f /* r0 == r1 then skip sdram init */
  54. adrl r0, mem_cfg_val
  55. bl mem_con_init
  56. ldr r0, =ELFIN_UART_BASE
  57. ldr r1, =0x4b4b4b4b
  58. str r1, [r0, #0x20]
  59. 1: mov lr, r12
  60. mov pc, lr
  61. /*
  62. * system_clock_init: Initialize core clock and bus clock.
  63. * void system_clock_init(void)
  64. */
  65. system_clock_init:
  66. /* Disable Watchdog */
  67. ldr r0, =ELFIN_WATCHDOG_BASE
  68. mov r1, #0
  69. str r1, [r0]
  70. /* mask all IRQs by setting all bits in the INTMR - default */
  71. ldr r0, =ELFIN_INTERRUPT_BASE
  72. mov r1, #0xffffffff
  73. str r1, [r0, #INTMSK_OFFSET]
  74. ldr r1, =0x000007ff
  75. str r1, [r0, #INTSUBMSK_OFFSET]
  76. /* Initialize System Clock */
  77. ldr r0, =ELFIN_CLOCK_POWER_BASE
  78. ldr r1, =0x00ffffff
  79. str r1, [r0, #LOCKTIME_OFFSET] /*Set Clock Divider*/
  80. #ifndef S3C2440_PLL_OFF
  81. /* FCLK:HCLK:PCLK */
  82. mov r1, #0x00000000
  83. str r1, [r0, #CAMDIVN_OFFSET]
  84. ldr r1, =CLKDIVN_VAL
  85. str r1, [r0, #CLKDIVN_OFFSET]
  86. #endif
  87. /* if HDIVN is not ZERO, the CPU bus mode has to be changed from the fast
  88. * bus mode to the async bus mode.
  89. */
  90. mrc p15, 0, r1, c1, c0, 0 @ read ctrl register
  91. orr r1, r1, #0xc0000000 @ Asynchronous
  92. mcr p15, 0, r1, c1, c0, 0 @ write ctrl register
  93. #ifndef S3C2440_PLL_OFF
  94. /* UPLL setup */
  95. ldr r1, =UPLL_VAL
  96. str r1, [r0, #UPLLCON_OFFSET]
  97. #endif
  98. nop
  99. nop
  100. nop
  101. nop
  102. nop @ wait until upll has the effect
  103. nop
  104. nop
  105. nop
  106. #ifndef S3C2440_PLL_OFF
  107. /* PLL setup */
  108. ldr r1, =MPLL_VAL
  109. str r1, [r0, #MPLLCON_OFFSET]
  110. #endif
  111. /* wait at least 200us to stablize all clock */
  112. mov r2, #0x10000
  113. 1: subs r1, r1, #1
  114. bne 1b
  115. mov pc, lr
  116. /*
  117. * uart_basic_init: Initialize UART in asm mode, 115200bps fixed.
  118. * void uart_asm_init(void)
  119. */
  120. uart_asm_init:
  121. /* set GPIO to enable UART */
  122. ldr r0, =ELFIN_GPIO_BASE
  123. ldr r1, =0x0000aaaa
  124. str r1, [r0, #GPHCON_OFFSET]
  125. ldr r0, =ELFIN_UART_BASE
  126. mov r1, #0x0
  127. str r1, [r0, #0x8]
  128. str r1, [r0, #0xC]
  129. mov r1, #0x3
  130. str r1, [r0, #0x0]
  131. ldr r1, =0x245
  132. str r1, [r0, #0x4]
  133. #if (CONFIG_SYS_CLK_FREQ == 16934400)
  134. #if defined (CONFIG_SMDK2440)
  135. ldr r1, =0x23
  136. #elif defined (CONFIG_SMDK2442)
  137. ldr r1, =0x19
  138. #endif
  139. #endif
  140. str r1, [r0, #UBRDIV0_OFFSET]
  141. ldr r1, =0x4f4f4f4f
  142. str r1, [r0, #0x20]
  143. mov pc, lr
  144. /*
  145. * Nand Interface Init for smdk2440
  146. */
  147. nand_asm_init:
  148. ldr r0, =ELFIN_NAND_BASE
  149. ldr r1, [r0, #NFCONF_OFFSET]
  150. orr r1, r1, #0xf0
  151. orr r1, r1, #0xff00
  152. str r1, [r0]
  153. #if 0
  154. ldr r1, [r0, #NFCONT_OFFSET]
  155. orr r1, r1, #0x01
  156. #else
  157. mov r1, #0x03
  158. #endif
  159. str r1, [r0, #NFCONT_OFFSET]
  160. mov pc, lr
  161. .align 4
  162. mem_cfg_val:
  163. .long vBWSCON /* 0x00 */
  164. .long vBANKCON0 /* 0x04 */
  165. .long vBANKCON1 /* 0x08 */
  166. .long vBANKCON2 /* 0x0c */
  167. .long vBANKCON3 /* 0x10 */
  168. .long vBANKCON4 /* 0x14 */
  169. .long vBANKCON5 /* 0x18 */
  170. .long vBANKCON6 /* 0x1c */
  171. .long vBANKCON7 /* 0x20 */
  172. .long vREFRESH /* 0x24 */
  173. .long vBANKSIZE /* 0x28 */
  174. .long vMRSRB6 /* 0x2c */
  175. .long vMRSRB7 /* 0x30 */
  176. var_in_lowlevel_init:
  177. .ltorg
  178. #ifdef CONFIG_ENABLE_MMU
  179. /*
  180. * MMU Table for SMDK2440
  181. */
  182. /* these macro should match with pci window macros */
  183. #define UNCACHED_SDRAM_START 1
  184. #define UNCACHED_SDRAM_SZ 1
  185. /* form a first-level section entry */
  186. .macro FL_SECTION_ENTRY base,ap,d,c,b
  187. .word (\base << 20) | (\ap << 10) | \
  188. (\d << 5) | (1<<4) | (\c << 3) | (\b << 2) | (1<<1)
  189. .endm
  190. .section .mmudata, "a"
  191. .align 14
  192. /* the following alignment creates the mmu table at address 0x4000. */
  193. .globl mmu_table
  194. mmu_table:
  195. .set __base,0
  196. /* 1:1 mapping for debugging */
  197. .rept 0x600
  198. FL_SECTION_ENTRY __base,3,0,0,0
  199. .set __base,__base+1
  200. .endr
  201. /* access is not allowed. */
  202. .rept 0xC00 - 0x600
  203. .word 0x00000000
  204. .endr
  205. /* 128MB for SDRAM 0xC0000000 -> 0x30000000 */
  206. .set __base, 0x300
  207. .rept 0xC80 - 0xC00
  208. FL_SECTION_ENTRY __base,3,0,1,1
  209. .set __base,__base+1
  210. .endr
  211. /* access is not allowed. */
  212. .rept 0x1000 - 0xc80
  213. .word 0x00000000
  214. .endr
  215. #endif


阅读(584) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~