blob: cad0a5acd87eab692c3b2617f3a52480b2c8241b [file] [log] [blame]
wdenk1eaeb582004-06-08 00:22:43 +00001/*
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 OMAP 1610 H2 board by Nishant Kamat, Jan 2004
9 *
10 * Modified for OMAP 5912 OSK board by Rishi Bhattacharya, Apr 2004
Wolfgang Denk1a459662013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
wdenk1eaeb582004-06-08 00:22:43 +000012 */
13
14#include <config.h>
15#include <version.h>
16
17#if defined(CONFIG_OMAP1610)
18#include <./configs/omap1510.h>
19#endif
20
21
22_TEXT_BASE:
Wolfgang Denk14d0a022010-10-07 21:51:12 +020023 .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
wdenk1eaeb582004-06-08 00:22:43 +000024
Wolfgang Denk87cb6862005-10-06 17:08:18 +020025.globl lowlevel_init
26lowlevel_init:
wdenk1eaeb582004-06-08 00:22:43 +000027
Stefan Roese6080a0e2006-05-10 10:55:16 +020028 /*------------------------------------------------------*
29 * Ensure i-cache is enabled *
30 * To configure TC regs without fetching instruction *
31 *------------------------------------------------------*/
32 mrc p15, 0, r0, c1, c0
33 orr r0, r0, #0x1000
34 mcr p15, 0, r0, c1, c0
wdenk1eaeb582004-06-08 00:22:43 +000035
36 /*------------------------------------------------------*
37 *mask all IRQs by setting all bits in the INTMR default*
38 *------------------------------------------------------*/
39 mov r1, #0xffffffff
40 ldr r0, =REG_IHL1_MIR
41 str r1, [r0]
42 ldr r0, =REG_IHL2_MIR
43 str r1, [r0]
44
45 /*------------------------------------------------------*
46 * Set up ARM CLM registers (IDLECT1) *
47 *------------------------------------------------------*/
48 ldr r0, REG_ARM_IDLECT1
49 ldr r1, VAL_ARM_IDLECT1
50 str r1, [r0]
51
52 /*------------------------------------------------------*
Stefan Roese6080a0e2006-05-10 10:55:16 +020053 * Set up ARM CLM registers (IDLECT2) *
wdenk1eaeb582004-06-08 00:22:43 +000054 *------------------------------------------------------*/
55 ldr r0, REG_ARM_IDLECT2
56 ldr r1, VAL_ARM_IDLECT2
57 str r1, [r0]
58
59 /*------------------------------------------------------*
Stefan Roese6080a0e2006-05-10 10:55:16 +020060 * Set up ARM CLM registers (IDLECT3) *
wdenk1eaeb582004-06-08 00:22:43 +000061 *------------------------------------------------------*/
62 ldr r0, REG_ARM_IDLECT3
63 ldr r1, VAL_ARM_IDLECT3
64 str r1, [r0]
65
Stefan Roese6080a0e2006-05-10 10:55:16 +020066 mov r1, #0x01 /* PER_EN bit */
wdenk1eaeb582004-06-08 00:22:43 +000067 ldr r0, REG_ARM_RSTCT2
Stefan Roese6080a0e2006-05-10 10:55:16 +020068 strh r1, [r0] /* CLKM; Peripheral reset. */
wdenk1eaeb582004-06-08 00:22:43 +000069
Stefan Roese6080a0e2006-05-10 10:55:16 +020070 /* Set CLKM to Sync-Scalable */
71 mov r1, #0x1000
wdenk1eaeb582004-06-08 00:22:43 +000072 ldr r0, REG_ARM_SYSST
Stefan Roese6080a0e2006-05-10 10:55:16 +020073
74 mov r2, #0
751: cmp r2, #1
76 streqh r1, [r0]
77 add r2, r2, #1
78 cmp r2, #0x100 /* wait for any bubbles to finish */
wdenk1eaeb582004-06-08 00:22:43 +000079 bne 1b
Stefan Roese6080a0e2006-05-10 10:55:16 +020080
wdenk1eaeb582004-06-08 00:22:43 +000081 ldr r1, VAL_ARM_CKCTL
82 ldr r0, REG_ARM_CKCTL
83 strh r1, [r0]
84
85 /* a few nops to let settle */
86 nop
87 nop
88 nop
89 nop
90 nop
91 nop
92 nop
93 nop
94 nop
95 nop
96
97 /* setup DPLL 1 */
98 /* Ramp up the clock to 96Mhz */
99 ldr r1, VAL_DPLL1_CTL
100 ldr r0, REG_DPLL1_CTL
101 strh r1, [r0]
Stefan Roese6080a0e2006-05-10 10:55:16 +0200102 ands r1, r1, #0x10 /* Check if PLL is enabled. */
103 beq lock_end /* Do not look for lock if BYPASS selected */
wdenk1eaeb582004-06-08 00:22:43 +00001042:
105 ldrh r1, [r0]
Stefan Roese6080a0e2006-05-10 10:55:16 +0200106 ands r1, r1, #0x01 /* Check the LOCK bit.*/
107 beq 2b /* loop until bit goes hi. */
wdenk1eaeb582004-06-08 00:22:43 +0000108lock_end:
109
wdenk1eaeb582004-06-08 00:22:43 +0000110 /*------------------------------------------------------*
Stefan Roese6080a0e2006-05-10 10:55:16 +0200111 * Turn off the watchdog during init... *
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200112 *------------------------------------------------------*/
wdenk1eaeb582004-06-08 00:22:43 +0000113 ldr r0, REG_WATCHDOG
114 ldr r1, WATCHDOG_VAL1
115 str r1, [r0]
116 ldr r1, WATCHDOG_VAL2
117 str r1, [r0]
118 ldr r0, REG_WSPRDOG
119 ldr r1, WSPRDOG_VAL1
120 str r1, [r0]
121 ldr r0, REG_WWPSDOG
122
123watch1Wait:
124 ldr r1, [r0]
125 tst r1, #0x10
126 bne watch1Wait
127
128 ldr r0, REG_WSPRDOG
129 ldr r1, WSPRDOG_VAL2
130 str r1, [r0]
131 ldr r0, REG_WWPSDOG
132watch2Wait:
133 ldr r1, [r0]
134 tst r1, #0x10
135 bne watch2Wait
136
wdenk1eaeb582004-06-08 00:22:43 +0000137 /* Set memory timings corresponding to the new clock speed */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200138 ldr r3, VAL_SDRAM_CONFIG_SDF0
wdenk1eaeb582004-06-08 00:22:43 +0000139
140 /* Check execution location to determine current execution location
141 * and branch to appropriate initialization code.
142 */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200143 mov r0, #0x10000000 /* Load physical SDRAM base. */
144 mov r1, pc /* Get current execution location. */
145 cmp r1, r0 /* Compare. */
146 bge skip_sdram /* Skip over EMIF-fast initialization if running from SDRAM. */
147
148 /* identify the device revision, -- TMX or TMP(TMS) */
149 ldr r0, REG_DEVICE_ID
150 ldr r1, [r0]
151
152 ldr r0, VAL_DEVICE_ID_TMP
153 mov r1, r1, lsl #15
154 mov r1, r1, lsr #16
155 cmp r0, r1
156 bne skip_TMP_Patch
157
158 /* Enable TMP/TMS device new features */
159 mov r0, #1
160 ldr r1, REG_TC_EMIFF_DOUBLER
161 str r0, [r1]
162
163 /* Enable new ac parameters */
164 mov r0, #0x0b
165 ldr r1, REG_SDRAM_CONFIG2
166 str r0, [r1]
167
168 ldr r3, VAL_SDRAM_CONFIG_SDF1
169
170skip_TMP_Patch:
wdenk1eaeb582004-06-08 00:22:43 +0000171
172 /*
173 * Delay for SDRAM initialization.
174 */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200175 mov r0, #0x1800 /* value should be checked */
wdenk1eaeb582004-06-08 00:22:43 +00001763:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200177 subs r0, r0, #0x1 /* Decrement count */
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200178 bne 3b
wdenk1eaeb582004-06-08 00:22:43 +0000179
wdenk1eaeb582004-06-08 00:22:43 +0000180 /*
181 * Set SDRAM control values. Disable refresh before MRS command.
182 */
183
184 /* mobile ddr operation */
185 ldr r0, REG_SDRAM_OPERATION
186 mov r2, #07
187 str r2, [r0]
188
189 /* config register */
190 ldr r0, REG_SDRAM_CONFIG
Stefan Roese6080a0e2006-05-10 10:55:16 +0200191 str r3, [r0]
wdenk1eaeb582004-06-08 00:22:43 +0000192
193 /* manual command register */
194 ldr r0, REG_SDRAM_MANUAL_CMD
Stefan Roese6080a0e2006-05-10 10:55:16 +0200195
wdenk1eaeb582004-06-08 00:22:43 +0000196 /* issue set cke high */
197 mov r1, #CMD_SDRAM_CKE_SET_HIGH
198 str r1, [r0]
Stefan Roese6080a0e2006-05-10 10:55:16 +0200199
wdenk1eaeb582004-06-08 00:22:43 +0000200 /* issue nop */
201 mov r1, #CMD_SDRAM_NOP
202 str r1, [r0]
203
204 mov r2, #0x0100
205waitMDDR1:
206 subs r2, r2, #1
207 bne waitMDDR1 /* delay loop */
208
209 /* issue precharge */
210 mov r1, #CMD_SDRAM_PRECHARGE
211 str r1, [r0]
212
213 /* issue autorefresh x 2 */
214 mov r1, #CMD_SDRAM_AUTOREFRESH
215 str r1, [r0]
216 str r1, [r0]
217
218 /* mrs register ddr mobile */
219 ldr r0, REG_SDRAM_MRS
220 mov r1, #0x33
221 str r1, [r0]
222
223 /* emrs1 low-power register */
224 ldr r0, REG_SDRAM_EMRS1
225 /* self refresh on all banks */
226 mov r1, #0
227 str r1, [r0]
228
229 ldr r0, REG_DLL_URD_CONTROL
230 ldr r1, DLL_URD_CONTROL_VAL
231 str r1, [r0]
232
233 ldr r0, REG_DLL_LRD_CONTROL
234 ldr r1, DLL_LRD_CONTROL_VAL
235 str r1, [r0]
236
237 ldr r0, REG_DLL_WRT_CONTROL
238 ldr r1, DLL_WRT_CONTROL_VAL
239 str r1, [r0]
240
241 /* delay loop */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200242 mov r0, #0x0100
wdenk1eaeb582004-06-08 00:22:43 +0000243waitMDDR2:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200244 subs r0, r0, #1
wdenk1eaeb582004-06-08 00:22:43 +0000245 bne waitMDDR2
246
247 /*
248 * Delay for SDRAM initialization.
249 */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200250 mov r0, #0x1800
wdenk1eaeb582004-06-08 00:22:43 +00002514:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200252 subs r0, r0, #1 /* Decrement count. */
wdenk1eaeb582004-06-08 00:22:43 +0000253 bne 4b
254 b common_tc
255
256skip_sdram:
wdenk1eaeb582004-06-08 00:22:43 +0000257 ldr r0, REG_SDRAM_CONFIG
Stefan Roese6080a0e2006-05-10 10:55:16 +0200258 str r3, [r0]
wdenk1eaeb582004-06-08 00:22:43 +0000259
260common_tc:
261 /* slow interface */
262 ldr r1, VAL_TC_EMIFS_CS0_CONFIG
263 ldr r0, REG_TC_EMIFS_CS0_CONFIG
264 str r1, [r0] /* Chip Select 0 */
265
266 ldr r1, VAL_TC_EMIFS_CS1_CONFIG
267 ldr r0, REG_TC_EMIFS_CS1_CONFIG
268 str r1, [r0] /* Chip Select 1 */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200269
wdenk1eaeb582004-06-08 00:22:43 +0000270 ldr r1, VAL_TC_EMIFS_CS3_CONFIG
271 ldr r0, REG_TC_EMIFS_CS3_CONFIG
272 str r1, [r0] /* Chip Select 3 */
273
Stefan Roese6080a0e2006-05-10 10:55:16 +0200274 ldr r1, VAL_TC_EMIFS_DWS
275 ldr r0, REG_TC_EMIFS_DWS
276 str r1, [r0] /* Enable EMIFS.RDY for CS1 (ether) */
277
wdenk1eaeb582004-06-08 00:22:43 +0000278#ifdef CONFIG_H2_OMAP1610
279 /* inserting additional 2 clock cycle hold time for LAN */
280 ldr r0, REG_TC_EMIFS_CS1_ADVANCED
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200281 ldr r1, VAL_TC_EMIFS_CS1_ADVANCED
wdenk1eaeb582004-06-08 00:22:43 +0000282 str r1, [r0]
283#endif
284 /* Start MPU Timer 1 */
285 ldr r0, REG_MPU_LOAD_TIMER
286 ldr r1, VAL_MPU_LOAD_TIMER
287 str r1, [r0]
288
289 ldr r0, REG_MPU_CNTL_TIMER
290 ldr r1, VAL_MPU_CNTL_TIMER
291 str r1, [r0]
292
Jon Hunter2a309f32013-04-09 16:41:31 -0500293 /*
294 * Setup a temporary stack
295 */
296 ldr sp, SRAM_STACK
297 bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
298
299 /*
300 * Save the old lr(passed in ip) and the current lr to stack
301 */
302 push {ip, lr}
303
304 /*
305 * go setup pll, mux, memory
306 */
307 bl s_init
308 pop {ip, pc}
309
wdenk1eaeb582004-06-08 00:22:43 +0000310 /* back to arch calling code */
311 mov pc, lr
312
313 /* the literal pools origin */
314 .ltorg
315
Stefan Roese6080a0e2006-05-10 10:55:16 +0200316REG_DEVICE_ID: /* 32 bits */
317 .word 0xfffe2004
318REG_TC_EMIFS_CONFIG:
wdenk1eaeb582004-06-08 00:22:43 +0000319 .word 0xfffecc0c
320REG_TC_EMIFS_CS0_CONFIG: /* 32 bits */
321 .word 0xfffecc10
322REG_TC_EMIFS_CS1_CONFIG: /* 32 bits */
323 .word 0xfffecc14
324REG_TC_EMIFS_CS2_CONFIG: /* 32 bits */
325 .word 0xfffecc18
326REG_TC_EMIFS_CS3_CONFIG: /* 32 bits */
327 .word 0xfffecc1c
Stefan Roese6080a0e2006-05-10 10:55:16 +0200328REG_TC_EMIFS_DWS: /* 32 bits */
329 .word 0xfffecc40
wdenk1eaeb582004-06-08 00:22:43 +0000330#ifdef CONFIG_H2_OMAP1610
331REG_TC_EMIFS_CS1_ADVANCED: /* 32 bits */
332 .word 0xfffecc54
333#endif
334
335/* MPU clock/reset/power mode control registers */
336REG_ARM_CKCTL: /* 16 bits */
337 .word 0xfffece00
wdenk1eaeb582004-06-08 00:22:43 +0000338REG_ARM_IDLECT3: /* 16 bits */
339 .word 0xfffece24
340REG_ARM_IDLECT2: /* 16 bits */
341 .word 0xfffece08
342REG_ARM_IDLECT1: /* 16 bits */
343 .word 0xfffece04
wdenk1eaeb582004-06-08 00:22:43 +0000344REG_ARM_RSTCT2: /* 16 bits */
345 .word 0xfffece14
346REG_ARM_SYSST: /* 16 bits */
347 .word 0xfffece18
Stefan Roese6080a0e2006-05-10 10:55:16 +0200348
wdenk1eaeb582004-06-08 00:22:43 +0000349/* DPLL control registers */
350REG_DPLL1_CTL: /* 16 bits */
351 .word 0xfffecf00
352
353/* Watch Dog register */
354/* secure watchdog stop */
355REG_WSPRDOG:
356 .word 0xfffeb048
357/* watchdog write pending */
358REG_WWPSDOG:
359 .word 0xfffeb034
360
361WSPRDOG_VAL1:
362 .word 0x0000aaaa
363WSPRDOG_VAL2:
364 .word 0x00005555
365
366/* SDRAM config is: auto refresh enabled, 16 bit 4 bank,
367 counter @8192 rows, 10 ns, 8 burst */
368REG_SDRAM_CONFIG:
369 .word 0xfffecc20
Stefan Roese6080a0e2006-05-10 10:55:16 +0200370REG_SDRAM_CONFIG2:
371 .word 0xfffecc3c
372REG_TC_EMIFF_DOUBLER: /* 32 bits */
373 .word 0xfffecc60
wdenk1eaeb582004-06-08 00:22:43 +0000374
375/* Operation register */
376REG_SDRAM_OPERATION:
377 .word 0xfffecc80
378
379/* Manual command register */
380REG_SDRAM_MANUAL_CMD:
381 .word 0xfffecc84
382
383/* SDRAM MRS (New) config is: CAS latency is 2, burst length 8 */
384REG_SDRAM_MRS:
385 .word 0xfffecc70
386
387/* SDRAM MRS (New) config is: CAS latency is 2, burst length 8 */
388REG_SDRAM_EMRS1:
389 .word 0xfffecc78
390
391/* WRT DLL register */
392REG_DLL_WRT_CONTROL:
393 .word 0xfffecc68
394DLL_WRT_CONTROL_VAL:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200395 .word 0x03f00002 /* Phase of 72deg, write offset +31 */
wdenk1eaeb582004-06-08 00:22:43 +0000396
397/* URD DLL register */
398REG_DLL_URD_CONTROL:
399 .word 0xfffeccc0
400DLL_URD_CONTROL_VAL:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200401 .word 0x00800002 /* Phase of 72deg, read offset +31 */
wdenk1eaeb582004-06-08 00:22:43 +0000402
403/* LRD DLL register */
404REG_DLL_LRD_CONTROL:
405 .word 0xfffecccc
Stefan Roese6080a0e2006-05-10 10:55:16 +0200406DLL_LRD_CONTROL_VAL:
407 .word 0x00800002 /* read offset +31 */
wdenk1eaeb582004-06-08 00:22:43 +0000408
409REG_WATCHDOG:
410 .word 0xfffec808
Stefan Roese6080a0e2006-05-10 10:55:16 +0200411WATCHDOG_VAL1:
412 .word 0x000000f5
413WATCHDOG_VAL2:
414 .word 0x000000a0
wdenk1eaeb582004-06-08 00:22:43 +0000415
416REG_MPU_LOAD_TIMER:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200417 .word 0xfffec504
wdenk1eaeb582004-06-08 00:22:43 +0000418REG_MPU_CNTL_TIMER:
419 .word 0xfffec500
Stefan Roese6080a0e2006-05-10 10:55:16 +0200420VAL_MPU_LOAD_TIMER:
421 .word 0xffffffff
422VAL_MPU_CNTL_TIMER:
423 .word 0xffffffa1
wdenk1eaeb582004-06-08 00:22:43 +0000424
425/* 96 MHz Samsung Mobile DDR */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200426/* Original setting for TMX device */
427VAL_SDRAM_CONFIG_SDF0:
428 .word 0x0014e6fe
wdenk1eaeb582004-06-08 00:22:43 +0000429
Stefan Roese6080a0e2006-05-10 10:55:16 +0200430/* NEW_SYS_FREQ mode (valid only TMP/TMS devices) */
431VAL_SDRAM_CONFIG_SDF1:
432 .word 0x0114e6fe
wdenk1eaeb582004-06-08 00:22:43 +0000433
434VAL_ARM_CKCTL:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200435 .word 0x2000 /* was: 0x3000, now use CLK_REF for timer input */
wdenk1eaeb582004-06-08 00:22:43 +0000436VAL_DPLL1_CTL:
437 .word 0x2830
438
439#ifdef CONFIG_OSK_OMAP5912
440VAL_TC_EMIFS_CS0_CONFIG:
441 .word 0x002130b0
442VAL_TC_EMIFS_CS1_CONFIG:
Stefan Roesed1dd22f2006-05-10 11:49:37 +0200443 .word 0x00001133
wdenk1eaeb582004-06-08 00:22:43 +0000444VAL_TC_EMIFS_CS2_CONFIG:
445 .word 0x000055f0
446VAL_TC_EMIFS_CS3_CONFIG:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200447 .word 0x88013141
448VAL_TC_EMIFS_DWS: /* Enable EMIFS.RDY for CS1 access (ether) */
449 .word 0x000000c0
450VAL_DEVICE_ID_TMP: /* TMP/TMS=0xb65f, TMX=0xb58c */
451 .word 0xb65f
wdenk1eaeb582004-06-08 00:22:43 +0000452#endif
453
454#ifdef CONFIG_H2_OMAP1610
455VAL_TC_EMIFS_CS0_CONFIG:
456 .word 0x00203331
457VAL_TC_EMIFS_CS1_CONFIG:
458 .word 0x8180fff3
459VAL_TC_EMIFS_CS2_CONFIG:
460 .word 0xf800f22a
461VAL_TC_EMIFS_CS3_CONFIG:
Stefan Roese6080a0e2006-05-10 10:55:16 +0200462 .word 0x88013141
wdenk1eaeb582004-06-08 00:22:43 +0000463VAL_TC_EMIFS_CS1_ADVANCED:
464 .word 0x00000022
465#endif
466
wdenk1eaeb582004-06-08 00:22:43 +0000467VAL_ARM_IDLECT1:
468 .word 0x00000400
wdenk1eaeb582004-06-08 00:22:43 +0000469VAL_ARM_IDLECT2:
470 .word 0x00000886
471VAL_ARM_IDLECT3:
472 .word 0x00000015
473
Jon Hunter2a309f32013-04-09 16:41:31 -0500474SRAM_STACK:
475 .word CONFIG_SYS_INIT_SP_ADDR
476
wdenk1eaeb582004-06-08 00:22:43 +0000477/* command values */
Stefan Roese6080a0e2006-05-10 10:55:16 +0200478.equ CMD_SDRAM_NOP, 0x00000000
479.equ CMD_SDRAM_PRECHARGE, 0x00000001
480.equ CMD_SDRAM_AUTOREFRESH, 0x00000002
481.equ CMD_SDRAM_CKE_SET_HIGH, 0x00000007