blob: 128d55407610c178cf22f4b161885e471d1472ae [file] [log] [blame]
stefano babic5e5803e2007-08-30 23:01:49 +02001/*
2 * This was originally from the Lubbock u-boot port.
3 *
4 * Most of this taken from Redboot hal_platform_setup.h with cleanup
5 *
6 * NOTE: I haven't clean this up considerably, just enough to get it
7 * running. See hal_platform_setup.h for the source. See
8 * board/cradle/lowlevel_init.S for another PXA250 setup that is
9 * much cleaner.
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
30#include <config.h>
31#include <version.h>
32#include <asm/arch/pxa-regs.h>
33
34/* wait for coprocessor write complete */
35 .macro CPWAIT reg
36 mrc p15,0,\reg,c2,c0,0
37 mov \reg,\reg
38 sub pc,pc,#4
39 .endm
40
41
42/*
43 * Memory setup
44 */
45
46.globl lowlevel_init
47lowlevel_init:
48
49 /* Set up GPIO pins first ----------------------------------------- */
50
51 ldr r0, =GPSR0
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020052 ldr r1, =CONFIG_SYS_GPSR0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020053 str r1, [r0]
54
55 ldr r0, =GPSR1
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056 ldr r1, =CONFIG_SYS_GPSR1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020057 str r1, [r0]
58
59 ldr r0, =GPSR2
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020060 ldr r1, =CONFIG_SYS_GPSR2_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020061 str r1, [r0]
62
63 ldr r0, =GPSR3
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020064 ldr r1, =CONFIG_SYS_GPSR3_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020065 str r1, [r0]
66
67 ldr r0, =GPCR0
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020068 ldr r1, =CONFIG_SYS_GPCR0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020069 str r1, [r0]
70
71 ldr r0, =GPCR1
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020072 ldr r1, =CONFIG_SYS_GPCR1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020073 str r1, [r0]
74
75 ldr r0, =GPCR2
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020076 ldr r1, =CONFIG_SYS_GPCR2_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020077 str r1, [r0]
78
79 ldr r0, =GPCR3
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020080 ldr r1, =CONFIG_SYS_GPCR3_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020081 str r1, [r0]
82
83 ldr r0, =GRER0
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020084 ldr r1, =CONFIG_SYS_GRER0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020085 str r1, [r0]
86
87 ldr r0, =GRER1
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020088 ldr r1, =CONFIG_SYS_GRER1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020089 str r1, [r0]
90
91 ldr r0, =GRER2
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020092 ldr r1, =CONFIG_SYS_GRER2_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020093 str r1, [r0]
94
95 ldr r0, =GRER3
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020096 ldr r1, =CONFIG_SYS_GRER3_VAL
stefano babic5e5803e2007-08-30 23:01:49 +020097 str r1, [r0]
98
99 ldr r0, =GFER0
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200100 ldr r1, =CONFIG_SYS_GFER0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200101 str r1, [r0]
102
103 ldr r0, =GFER1
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200104 ldr r1, =CONFIG_SYS_GFER1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200105 str r1, [r0]
106
107 ldr r0, =GFER2
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200108 ldr r1, =CONFIG_SYS_GFER2_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200109 str r1, [r0]
110
111 ldr r0, =GFER3
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200112 ldr r1, =CONFIG_SYS_GFER3_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200113 str r1, [r0]
114
115 ldr r0, =GPDR0
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200116 ldr r1, =CONFIG_SYS_GPDR0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200117 str r1, [r0]
118
119 ldr r0, =GPDR1
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200120 ldr r1, =CONFIG_SYS_GPDR1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200121 str r1, [r0]
122
123 ldr r0, =GPDR2
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200124 ldr r1, =CONFIG_SYS_GPDR2_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200125 str r1, [r0]
126
127 ldr r0, =GPDR3
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200128 ldr r1, =CONFIG_SYS_GPDR3_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200129 str r1, [r0]
130
131 ldr r0, =GAFR0_L
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200132 ldr r1, =CONFIG_SYS_GAFR0_L_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200133 str r1, [r0]
134
135 ldr r0, =GAFR0_U
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200136 ldr r1, =CONFIG_SYS_GAFR0_U_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200137 str r1, [r0]
138
139 ldr r0, =GAFR1_L
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200140 ldr r1, =CONFIG_SYS_GAFR1_L_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200141 str r1, [r0]
142
143 ldr r0, =GAFR1_U
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200144 ldr r1, =CONFIG_SYS_GAFR1_U_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200145 str r1, [r0]
146
147 ldr r0, =GAFR2_L
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200148 ldr r1, =CONFIG_SYS_GAFR2_L_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200149 str r1, [r0]
150
151 ldr r0, =GAFR2_U
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200152 ldr r1, =CONFIG_SYS_GAFR2_U_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200153 str r1, [r0]
154
155 ldr r0, =GAFR3_L
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200156 ldr r1, =CONFIG_SYS_GAFR3_L_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200157 str r1, [r0]
158
159 ldr r0, =GAFR3_U
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200160 ldr r1, =CONFIG_SYS_GAFR3_U_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200161 str r1, [r0]
162
163 ldr r0, =PSSR /* enable GPIO pins */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200164 ldr r1, =CONFIG_SYS_PSSR_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200165 str r1, [r0]
166
167 /* ---------------------------------------------------------------- */
168 /* Enable memory interface */
169 /* */
170 /* The sequence below is based on the recommended init steps */
171 /* detailed in the Intel PXA250 Operating Systems Developers Guide, */
172 /* Chapter 10. */
173 /* ---------------------------------------------------------------- */
174
175 /* ---------------------------------------------------------------- */
176 /* Step 1: Wait for at least 200 microsedonds to allow internal */
177 /* clocks to settle. Only necessary after hard reset... */
178 /* FIXME: can be optimized later */
179 /* ---------------------------------------------------------------- */
180
181 ldr r3, =OSCR /* reset the OS Timer Count to zero */
182 mov r2, #0
183 str r2, [r3]
184 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
185 /* so 0x300 should be plenty */
1861:
187 ldr r2, [r3]
188 cmp r4, r2
189 bgt 1b
190
191mem_init:
192
193 ldr r1, =MEMC_BASE /* get memory controller base addr. */
194
195 /* ---------------------------------------------------------------- */
196 /* Step 2a: Initialize Asynchronous static memory controller */
197 /* ---------------------------------------------------------------- */
198
199 /* MSC registers: timing, bus width, mem type */
200
201 /* MSC0: nCS(0,1) */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200202 ldr r2, =CONFIG_SYS_MSC0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200203 str r2, [r1, #MSC0_OFFSET]
204 ldr r2, [r1, #MSC0_OFFSET] /* read back to ensure */
205 /* that data latches */
206 /* MSC1: nCS(2,3) */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200207 ldr r2, =CONFIG_SYS_MSC1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200208 str r2, [r1, #MSC1_OFFSET]
209 ldr r2, [r1, #MSC1_OFFSET]
210
211 /* MSC2: nCS(4,5) */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200212 ldr r2, =CONFIG_SYS_MSC2_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200213 str r2, [r1, #MSC2_OFFSET]
214 ldr r2, [r1, #MSC2_OFFSET]
215
216 /* ---------------------------------------------------------------- */
217 /* Step 2b: Initialize Card Interface */
218 /* ---------------------------------------------------------------- */
219
220 /* MECR: Memory Expansion Card Register */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200221 ldr r2, =CONFIG_SYS_MECR_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200222 str r2, [r1, #MECR_OFFSET]
223 ldr r2, [r1, #MECR_OFFSET]
224
225 /* MCMEM0: Card Interface slot 0 timing */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200226 ldr r2, =CONFIG_SYS_MCMEM0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200227 str r2, [r1, #MCMEM0_OFFSET]
228 ldr r2, [r1, #MCMEM0_OFFSET]
229
230 /* MCMEM1: Card Interface slot 1 timing */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200231 ldr r2, =CONFIG_SYS_MCMEM1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200232 str r2, [r1, #MCMEM1_OFFSET]
233 ldr r2, [r1, #MCMEM1_OFFSET]
234
235 /* MCATT0: Card Interface Attribute Space Timing, slot 0 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200236 ldr r2, =CONFIG_SYS_MCATT0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200237 str r2, [r1, #MCATT0_OFFSET]
238 ldr r2, [r1, #MCATT0_OFFSET]
239
240 /* MCATT1: Card Interface Attribute Space Timing, slot 1 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200241 ldr r2, =CONFIG_SYS_MCATT1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200242 str r2, [r1, #MCATT1_OFFSET]
243 ldr r2, [r1, #MCATT1_OFFSET]
244
245 /* MCIO0: Card Interface I/O Space Timing, slot 0 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200246 ldr r2, =CONFIG_SYS_MCIO0_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200247 str r2, [r1, #MCIO0_OFFSET]
248 ldr r2, [r1, #MCIO0_OFFSET]
249
250 /* MCIO1: Card Interface I/O Space Timing, slot 1 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200251 ldr r2, =CONFIG_SYS_MCIO1_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200252 str r2, [r1, #MCIO1_OFFSET]
253 ldr r2, [r1, #MCIO1_OFFSET]
254
255 /* ---------------------------------------------------------------- */
256 /* Step 2c: Write FLYCNFG FIXME: what's that??? */
257 /* ---------------------------------------------------------------- */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200258 ldr r2, =CONFIG_SYS_FLYCNFG_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200259 str r2, [r1, #FLYCNFG_OFFSET]
260 str r2, [r1, #FLYCNFG_OFFSET]
261
262 /* ---------------------------------------------------------------- */
263 /* Step 2d: Initialize Timing for Sync Memory (SDCLK0) */
264 /* ---------------------------------------------------------------- */
265
266 /* Before accessing MDREFR we need a valid DRI field, so we set */
267 /* this to power on defaults + DRI field. */
268
269 ldr r4, [r1, #MDREFR_OFFSET]
270 ldr r2, =0xFFF
271 bic r4, r4, r2
272
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200273 ldr r3, =CONFIG_SYS_MDREFR_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200274 and r3, r3, r2
275
276 orr r4, r4, r3
277 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
278
279 orr r4, r4, #MDREFR_K0RUN
280 orr r4, r4, #MDREFR_K0DB4
281 orr r4, r4, #MDREFR_K0FREE
282 orr r4, r4, #MDREFR_K0DB2
283 orr r4, r4, #MDREFR_K1DB2
284 bic r4, r4, #MDREFR_K1FREE
285 bic r4, r4, #MDREFR_K2FREE
286
287 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
288 ldr r4, [r1, #MDREFR_OFFSET]
289
290 /* Note: preserve the mdrefr value in r4 */
291
292
293 /* ---------------------------------------------------------------- */
294 /* Step 3: Initialize Synchronous Static Memory (Flash/Peripherals) */
295 /* ---------------------------------------------------------------- */
296
297 /* Initialize SXCNFG register. Assert the enable bits */
298
299 /* Write SXMRS to cause an MRS command to all enabled banks of */
300 /* synchronous static memory. Note that SXLCR need not be written */
301 /* at this time. */
302
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200303 ldr r2, =CONFIG_SYS_SXCNFG_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200304 str r2, [r1, #SXCNFG_OFFSET]
305
306 /* ---------------------------------------------------------------- */
307 /* Step 4: Initialize SDRAM */
308 /* ---------------------------------------------------------------- */
309
310 bic r4, r4, #(MDREFR_K2FREE |MDREFR_K1FREE | MDREFR_K0FREE)
311
312 orr r4, r4, #MDREFR_K1RUN
313 bic r4, r4, #MDREFR_K2DB2
314 str r4, [r1, #MDREFR_OFFSET]
315 ldr r4, [r1, #MDREFR_OFFSET]
316
317 bic r4, r4, #MDREFR_SLFRSH
318 str r4, [r1, #MDREFR_OFFSET]
319 ldr r4, [r1, #MDREFR_OFFSET]
320
321 orr r4, r4, #MDREFR_E1PIN
322 str r4, [r1, #MDREFR_OFFSET]
323 ldr r4, [r1, #MDREFR_OFFSET]
324
325 nop
326 nop
327
328
329 /* Step 4d: write MDCNFG with MDCNFG:DEx deasserted (set to 0), to */
330 /* configure but not enable each SDRAM partition pair. */
331
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200332 ldr r4, =CONFIG_SYS_MDCNFG_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200333 bic r4, r4, #(MDCNFG_DE0|MDCNFG_DE1)
334 bic r4, r4, #(MDCNFG_DE2|MDCNFG_DE3)
335
336 str r4, [r1, #MDCNFG_OFFSET] /* write back MDCNFG */
337 ldr r4, [r1, #MDCNFG_OFFSET]
338
339
340 /* Step 4e: Wait for the clock to the SDRAMs to stabilize, */
341 /* 100..200 µsec. */
342
343 ldr r3, =OSCR /* reset the OS Timer Count to zero */
344 mov r2, #0
345 str r2, [r3]
346 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
347 /* so 0x300 should be plenty */
3481:
349 ldr r2, [r3]
350 cmp r4, r2
351 bgt 1b
352
353
354 /* Step 4f: Trigger a number (usually 8) refresh cycles by */
355 /* attempting non-burst read or write accesses to disabled */
356 /* SDRAM, as commonly specified in the power up sequence */
357 /* documented in SDRAM data sheets. The address(es) used */
358 /* for this purpose must not be cacheable. */
359
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200360 ldr r3, =CONFIG_SYS_DRAM_BASE
stefano babic5e5803e2007-08-30 23:01:49 +0200361 str r2, [r3]
362 str r2, [r3]
363 str r2, [r3]
364 str r2, [r3]
365 str r2, [r3]
366 str r2, [r3]
367 str r2, [r3]
368 str r2, [r3]
369
370
371 /* Step 4g: Write MDCNFG with enable bits asserted */
372 /* (MDCNFG:DEx set to 1). */
373
374 ldr r3, [r1, #MDCNFG_OFFSET]
375 mov r4, r3
376 orr r3, r3, #MDCNFG_DE0
377 str r3, [r1, #MDCNFG_OFFSET]
378 mov r0, r3
379
380 /* Step 4h: Write MDMRS. */
381
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200382 ldr r2, =CONFIG_SYS_MDMRS_VAL
stefano babic5e5803e2007-08-30 23:01:49 +0200383 str r2, [r1, #MDMRS_OFFSET]
384
385 /* enable APD */
386 ldr r3, [r1, #MDREFR_OFFSET]
387 orr r3, r3, #MDREFR_APD
388 str r3, [r1, #MDREFR_OFFSET]
389
390 /* We are finished with Intel's memory controller initialisation */
391
392
393setvoltage:
394
395 mov r10, lr
396 bl initPXAvoltage /* In case the board is rebooting with a */
397 mov lr, r10 /* low voltage raise it up to a good one. */
398
399#if 1
400 b initirqs
401#endif
402
403wakeup:
404 /* Are we waking from sleep? */
405 ldr r0, =RCSR
406 ldr r1, [r0]
407 and r1, r1, #(RCSR_GPR | RCSR_SMR | RCSR_WDR | RCSR_HWR)
408 str r1, [r0]
409 teq r1, #RCSR_SMR
410
411 bne initirqs
412
413 ldr r0, =PSSR
414 mov r1, #PSSR_PH
415 str r1, [r0]
416
417 /* if so, resume at PSPR */
418 ldr r0, =PSPR
419 ldr r1, [r0]
420 mov pc, r1
421
422 /* ---------------------------------------------------------------- */
423 /* Disable (mask) all interrupts at interrupt controller */
424 /* ---------------------------------------------------------------- */
425
426initirqs:
427
428 mov r1, #0 /* clear int. level register (IRQ, not FIQ) */
429 ldr r2, =ICLR
430 str r1, [r2]
431
432 ldr r2, =ICMR /* mask all interrupts at the controller */
433 str r1, [r2]
434
435 /* ---------------------------------------------------------------- */
436 /* Clock initialisation */
437 /* ---------------------------------------------------------------- */
438
439initclks:
440
441 /* Disable the peripheral clocks, and set the core clock frequency */
442
443 /* Turn Off on-chip peripheral clocks (except for memory) */
444 /* for re-configuration. */
445 ldr r1, =CKEN
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200446 ldr r2, =CONFIG_SYS_CKEN
stefano babic5e5803e2007-08-30 23:01:49 +0200447 str r2, [r1]
448
449 /* ... and write the core clock config register */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200450 ldr r2, =CONFIG_SYS_CCCR
stefano babic5e5803e2007-08-30 23:01:49 +0200451 ldr r1, =CCCR
452 str r2, [r1]
453
454 /* Turn on turbo mode */
455 mrc p14, 0, r2, c6, c0, 0
456 orr r2, r2, #0xB /* Turbo, Fast-Bus, Freq change**/
457 mcr p14, 0, r2, c6, c0, 0
458
459 /* Re-write MDREFR */
460 ldr r1, =MEMC_BASE
461 ldr r2, [r1, #MDREFR_OFFSET]
462 str r2, [r1, #MDREFR_OFFSET]
463#ifdef RTC
464 /* enable the 32Khz oscillator for RTC and PowerManager */
465 ldr r1, =OSCC
466 mov r2, #OSCC_OON
467 str r2, [r1]
468
469 /* NOTE: spin here until OSCC.OOK get set, meaning the PLL */
470 /* has settled. */
47160:
472 ldr r2, [r1]
473 ands r2, r2, #1
474 beq 60b
475#else
476#error "RTC not defined"
477#endif
478
479 /* Interrupt init: Mask all interrupts */
480 ldr r0, =ICMR /* enable no sources */
481 mov r1, #0
482 str r1, [r0]
483 /* FIXME */
484
485#ifdef NODEBUG
486 /*Disable software and data breakpoints */
487 mov r0,#0
488 mcr p15,0,r0,c14,c8,0 /* ibcr0 */
489 mcr p15,0,r0,c14,c9,0 /* ibcr1 */
490 mcr p15,0,r0,c14,c4,0 /* dbcon */
491
492 /*Enable all debug functionality */
493 mov r0,#0x80000000
494 mcr p14,0,r0,c10,c0,0 /* dcsr */
495#endif
496
497 /* ---------------------------------------------------------------- */
498 /* End lowlevel_init */
499 /* ---------------------------------------------------------------- */
500
501endlowlevel_init:
502
503 mov pc, lr