1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include <config.h>
34#include <version.h>
35
36
37# ifndef CONFIG_SKIP_LOWLEVEL_INIT
38# include <./ns9750_sys.h>
39# include <./ns9750_mem.h>
40# endif
41#endif
42
43
44
45
46
47
48
49
50
51
52
53.macro write_register_block
54 @@ map the addresses to high memory
55 sub r1, r1, r5
56 add r1, r1, r6
57 sub r2, r2, r5
58 add r2, r2, r6
59
60 @@ copy all
611:
62 @@ Write register/value pair starting at [r1] to register base r0
63 ldr r3, [r1],
64 ldr r4, [r1],
65 str r4, [r0,r3]
66 cmp r1, r2
67 blt 1b
68.endm
69
70_TEXT_BASE:
71 .word CONFIG_SYS_TEXT_BASE @ sdram load addr from config.mk
72_PHYS_FLASH:
73 .word PHYS_FLASH_1 @ real flash address (without mirroring)
74_CAS_LATENCY:
75 .word 0x00022000 @ for CAS2 latency
76
77#ifndef CONFIG_SKIP_LOWLEVEL_INIT
78.globl lowlevel_init
79lowlevel_init:
80
81
82
83
84
85
86
87
88 @@ branch to high memory address, away from 0x0
89 ldr r5, _TEXT_BASE
90 ldr r6, _PHYS_FLASH
91 ldr r0, =_run_at_real_flash_address
92 sub r0, r0, r5
93 add r0, r0, r6
94 mov pc, r0
95 nop @ for pipelining
96
97_run_at_real_flash_address:
98 @@ now we are running > PHYS_FLASH_1, safe to enable memory controller
99
100 @@ Write Memory Configuration Registers
101
102 ldr r0, _NS9750_MEM_MODULE_BASE
103 ldr r1, =_MEM_CONFIG_START
104 ldr r2, =_MEM_CONFIG_END
105
106 write_register_block
107
108 @@ Give SDRAM some time to settle
109 @@ @TODO. According to [2] it should be 2 AHB cycles. Check
110
111 ldr r1, =0x50
112_sdram_settle:
113 subs r1, r1,
114 bne _sdram_settle
115
116_enable_mappings:
117 @@ Enable SDRAM Mode
118
119 ldr r1, =_MEM_MODE_START
120 ldr r2, =_MEM_MODE_END
121
122 write_register_block
123
124 ldr r3, _CAS_LATENCY @ perform one read from SDRAM
125 ldr r3, [r3]
126
127 @@ Enable SDRAM and memory mappings
128
129 ldr r1, =_MEM_ENABLE_START
130 ldr r2, =_MEM_ENABLE_END
131
132 write_register_block
133
134 @@ Activate AHB monitor
135
136 ldr r0, =NS9750_SYS_MODULE_BASE
137 ldr r1, =_AHB_MONITOR_START
138 ldr r2, =_AHB_MONITOR_END
139
140 write_register_block
141_relocate_lr:
142
143
144 mov r1, ip
145 add r1, r1, r6
146 mov ip, r1
147
148 mov r1, lr
149 add r1, r1, r6
150 mov lr, r1
151
152 @@ back to arch calling code
153 mov pc, lr
154
155 .ltorg
156
157_NS9750_MEM_MODULE_BASE:
158 .word NS9750_MEM_MODULE_BASE
159
160_MEM_CONFIG_START:
161
162
163
164
165 @@ Register values taken from [2]
166 .word NS9750_MEM_CTRL
167 .word NS9750_MEM_CTRL_E
168
169 .word NS9750_MEM_DYN_REFRESH
170 .word (0x6 & NS9750_MEM_DYN_REFRESH_MA)
171
172 .word NS9750_MEM_DYN_READ_CFG
173 .word (0x1 & NS9750_MEM_DYN_READ_CFG_MA)
174
175 .word NS9750_MEM_DYN_TRP
176 .word (0x1 & NS9750_MEM_DYN_TRP_MA)
177
178 .word NS9750_MEM_DYN_TRAS
179 .word (0x4 & NS9750_MEM_DYN_TRAS_MA)
180
181 .word NS9750_MEM_DYN_TAPR
182 .word (0x1 & NS9750_MEM_DYN_TRAS_MA)
183
184 .word NS9750_MEM_DYN_TDAL
185 .word (0x5 & NS9750_MEM_DYN_TDAL_MA)
186
187 .word NS9750_MEM_DYN_TWR
188 .word (0x1 & NS9750_MEM_DYN_TWR_MA)
189
190 .word NS9750_MEM_DYN_TRC
191 .word (0x6 & NS9750_MEM_DYN_TRC_MA)
192
193 .word NS9750_MEM_DYN_TRFC
194 .word (0x6 & NS9750_MEM_DYN_TRFC_MA)
195
196 .word NS9750_MEM_DYN_TRRD
197 .word (0x1 & NS9750_MEM_DYN_TRRD_MA)
198
199 .word NS9750_MEM_DYN_TMRD
200 .word (0x1 & NS9750_MEM_DYN_TMRD_MA)
201
202 @@ CS 4
203 .word NS9750_MEM_DYN_CFG(0)
204 .word (NS9750_MEM_DYN_CFG_AM | \
205 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
206
207 .word NS9750_MEM_DYN_RAS_CAS(0)
208 .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
209 (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
210
211 @@ CS 5
212 .word NS9750_MEM_DYN_CFG(1)
213 .word (NS9750_MEM_DYN_CFG_AM | \
214 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
215
216 .word NS9750_MEM_DYN_RAS_CAS(1)
217 .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
218 (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
219
220 @@ CS 6
221 .word NS9750_MEM_DYN_CFG(2)
222 .word (NS9750_MEM_DYN_CFG_AM | \
223 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
224
225 .word NS9750_MEM_DYN_RAS_CAS(2)
226 .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
227 (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
228
229 @@ CS 7
230 .word NS9750_MEM_DYN_CFG(3)
231 .word (NS9750_MEM_DYN_CFG_AM | \
232 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
233
234 .word NS9750_MEM_DYN_RAS_CAS(3)
235 .word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
236 (0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
237
238 .word NS9750_MEM_DYN_CTRL
239 .word (NS9750_MEM_DYN_CTRL_I_PALL | \
240 NS9750_MEM_DYN_CTRL_SR | \
241 NS9750_MEM_DYN_CTRL_CE )
242
243 .word NS9750_MEM_DYN_REFRESH
244 .word (0x1 & NS9750_MEM_DYN_REFRESH_MA)
245 @@ No further register settings after refresh
246_MEM_CONFIG_END:
247
248_MEM_MODE_START:
249 .word NS9750_MEM_DYN_REFRESH
250 .word (0x30 & NS9750_MEM_DYN_REFRESH_MA)
251
252 .word NS9750_MEM_DYN_CTRL
253 .word (NS9750_MEM_DYN_CTRL_I_MODE | \
254 NS9750_MEM_DYN_CTRL_SR | \
255 NS9750_MEM_DYN_CTRL_CE )
256_MEM_MODE_END:
257
258_MEM_ENABLE_START:
259 .word NS9750_MEM_DYN_CTRL
260 .word (NS9750_MEM_DYN_CTRL_I_NORMAL | \
261 NS9750_MEM_DYN_CTRL_SR | \
262 NS9750_MEM_DYN_CTRL_CE )
263
264 @@ CS 4
265 .word NS9750_MEM_DYN_CFG(0)
266 .word (NS9750_MEM_DYN_CFG_BDMC | \
267 NS9750_MEM_DYN_CFG_AM | \
268 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
269
270 @@ CS 5
271 .word NS9750_MEM_DYN_CFG(1)
272 .word (NS9750_MEM_DYN_CFG_BDMC | \
273 NS9750_MEM_DYN_CFG_AM | \
274 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
275
276 @@ CS 6
277 .word NS9750_MEM_DYN_CFG(2)
278 .word (NS9750_MEM_DYN_CFG_BDMC | \
279 NS9750_MEM_DYN_CFG_AM | \
280 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
281
282 @@ CS 7
283 .word NS9750_MEM_DYN_CFG(3)
284 .word (NS9750_MEM_DYN_CFG_BDMC | \
285 NS9750_MEM_DYN_CFG_AM | \
286 (0x280 & NS9750_MEM_DYN_CFG_AM_MA))
287_MEM_ENABLE_END:
288
289_AHB_MONITOR_START:
290 .word NS9750_SYS_AHB_TIMEOUT
291 .word 0x01000100 @ @TODO not calculated yet
292
293 .word NS9750_SYS_AHB_MON
294 .word (NS9750_SYS_AHB_MON_BMTC_GEN_IRQ | \
295 NS9750_SYS_AHB_MON_BATC_GEN_IRQ)
296_AHB_MONITOR_END:
297
298#endif
299