blob: f066fe44e771c60dffae927563ac5cd9521af68f [file] [log] [blame]
Peter Pearse5ca98812007-11-09 15:24:26 +00001/*
2 * Board specific setup info
3 *
4 * (C) Copyright 2005-2007
5 * Samsung Electronics,
6 * Kyungmin Park <kyungmin.park@samsung.com>
7 *
8 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27#include <config.h>
28#include <version.h>
29#include <asm/arch/omap2420.h>
30#include <asm/arch/mem.h>
31#include <asm/arch/clocks.h>
32#include "mem.h"
33
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010034#define APOLLON_CS0_BASE 0x00000000
Peter Pearse5ca98812007-11-09 15:24:26 +000035
36#ifdef PRCM_CONFIG_I
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010037#define SDRC_ACTIM_CTRLA_0_VAL 0x7BA35907
38#define SDRC_ACTIM_CTRLB_0_VAL 0x00000013
39#define SDRC_RFR_CTRL_0_VAL 0x00044C01
Peter Pearse5ca98812007-11-09 15:24:26 +000040#elif defined(PRCM_CONFIG_II)
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010041#define SDRC_ACTIM_CTRLA_0_VAL 0x4A59B485
42#define SDRC_ACTIM_CTRLB_0_VAL 0x0000000C
43#define SDRC_RFR_CTRL_0_VAL 0x00030001
Peter Pearse5ca98812007-11-09 15:24:26 +000044#endif
45
46#define SDRAM_BASE_ADDRESS 0x80008000
47
48_TEXT_BASE:
Wolfgang Denk14d0a022010-10-07 21:51:12 +020049 .word CONFIG_SYS_TEXT_BASE /* sdram load addr from config.mk */
Peter Pearse5ca98812007-11-09 15:24:26 +000050
51.globl lowlevel_init
52lowlevel_init:
53
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020054#ifdef CONFIG_SYS_NOR_BOOT
Peter Pearse5ca98812007-11-09 15:24:26 +000055 /* Check running in SDRAM */
56 mov r0, pc, lsr #28
57 cmp r0, #8
58 beq prcm_setup
Peter Pearse2db916e2007-11-15 08:45:13 +000059
Peter Pearse5ca98812007-11-09 15:24:26 +000060flash_setup:
61 /* In Flash */
62 ldr r0, =WD2_BASE
63 ldr r1, =WD_UNLOCK1
64 str r1, [r0, #WSPR]
65
66 ldr r1, =WD_UNLOCK2
67 str r1, [r0, #WSPR]
68
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010069 /* Pin muxing for SDRC */
70 mov r1, #0x00
71 ldr r0, =0x480000A1 /* ball C12, mode 0 */
72 strb r1, [r0]
Peter Pearse5ca98812007-11-09 15:24:26 +000073
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010074 ldr r0, =0x48000032 /* ball D11, mode 0 */
75 strb r1, [r0]
Peter Pearse5ca98812007-11-09 15:24:26 +000076
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010077 ldr r0, =0x480000A3 /* ball B13, mode 0 */
78 strb r1, [r0]
Peter Pearse5ca98812007-11-09 15:24:26 +000079
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010080 /* SDRC setting */
81 ldr r0, =OMAP2420_SDRC_BASE
82 ldr r1, =0x00000010
83 str r1, [r0, #0x10]
Peter Pearse5ca98812007-11-09 15:24:26 +000084
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010085 ldr r1, =0x00000100
86 str r1, [r0, #0x44]
Peter Pearse5ca98812007-11-09 15:24:26 +000087
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010088 /* SDRC CS0 configuration */
89 ldr r1, =0x00d04011
90 str r1, [r0, #0x80]
Peter Pearse5ca98812007-11-09 15:24:26 +000091
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010092 ldr r1, =SDRC_ACTIM_CTRLA_0_VAL
93 str r1, [r0, #0x9C]
Peter Pearse5ca98812007-11-09 15:24:26 +000094
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010095 ldr r1, =SDRC_ACTIM_CTRLB_0_VAL
96 str r1, [r0, #0xA0]
Peter Pearse5ca98812007-11-09 15:24:26 +000097
Wolfgang Denk435dc8f2008-01-09 11:36:21 +010098 ldr r1, =SDRC_RFR_CTRL_0_VAL
99 str r1, [r0, #0xA4]
Peter Pearse5ca98812007-11-09 15:24:26 +0000100
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100101 ldr r1, =0x00000041
102 str r1, [r0, #0x70]
Peter Pearse5ca98812007-11-09 15:24:26 +0000103
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100104 /* Manual command sequence */
105 ldr r1, =0x00000007
106 str r1, [r0, #0xA8]
Peter Pearse5ca98812007-11-09 15:24:26 +0000107
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100108 ldr r1, =0x00000000
109 str r1, [r0, #0xA8]
Peter Pearse5ca98812007-11-09 15:24:26 +0000110
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100111 ldr r1, =0x00000001
112 str r1, [r0, #0xA8]
Peter Pearse5ca98812007-11-09 15:24:26 +0000113
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100114 ldr r1, =0x00000002
115 str r1, [r0, #0xA8]
116 str r1, [r0, #0xA8]
Peter Pearse5ca98812007-11-09 15:24:26 +0000117
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100118 /*
119 * CS0 SDRC Mode register
120 * Burst length = 4 - DDR memory
121 * Serial mode
122 * CAS latency = 3
123 */
124 ldr r1, =0x00000032
125 str r1, [r0, #0x84]
Peter Pearse5ca98812007-11-09 15:24:26 +0000126
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100127 /* Note: You MUST set EMR values */
128 /* EMR1 & EMR2 */
129 ldr r1, =0x00000000
130 str r1, [r0, #0x88]
131 str r1, [r0, #0x8C]
Peter Pearse5ca98812007-11-09 15:24:26 +0000132
133#ifdef OLD_SDRC_DLLA_CTRL
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100134 /* SDRC_DLLA_CTRL */
135 ldr r1, =0x00007306
136 str r1, [r0, #0x60]
Peter Pearse5ca98812007-11-09 15:24:26 +0000137
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100138 ldr r1, =0x00007303
139 str r1, [r0, #0x60]
Peter Pearse5ca98812007-11-09 15:24:26 +0000140#else
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100141 /* SDRC_DLLA_CTRL */
142 ldr r1, =0x00000506
143 str r1, [r0, #0x60]
Peter Pearse5ca98812007-11-09 15:24:26 +0000144
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100145 ldr r1, =0x00000503
146 str r1, [r0, #0x60]
Peter Pearse5ca98812007-11-09 15:24:26 +0000147#endif
148
149#ifdef __BROKEN_FEATURE__
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100150 /* SDRC_DLLB_CTRL */
151 ldr r1, =0x00000506
152 str r1, [r0, #0x68]
Peter Pearse5ca98812007-11-09 15:24:26 +0000153
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100154 ldr r1, =0x00000503
155 str r1, [r0, #0x68]
Peter Pearse5ca98812007-11-09 15:24:26 +0000156#endif
157
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100158 /* little delay after init */
159 mov r2, #0x1800
Peter Pearse5ca98812007-11-09 15:24:26 +00001601:
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100161 subs r2, r2, #0x1
162 bne 1b
Peter Pearse5ca98812007-11-09 15:24:26 +0000163
164 /* Setup base address */
165 ldr r0, =0x00000000 /* NOR address */
166 ldr r1, =SDRAM_BASE_ADDRESS /* SDRAM address */
167 ldr r2, =0x20000 /* Size: 128KB */
168
169copy_loop:
170 ldmia r0!, {r3-r10}
171 stmia r1!, {r3-r10}
172 cmp r0, r2
173 ble copy_loop
174
175 ldr r1, =SDRAM_BASE_ADDRESS
176 mov lr, pc
177 mov pc, r1
178#endif
179
180prcm_setup:
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100181 ldr r0, =OMAP2420_CM_BASE
182 ldr r1, [r0, #0x544] /* CLKSEL2_PLL */
183 bic r1, r1, #0x03
184 orr r1, r1, #0x02
185 str r1, [r0, #0x544]
Peter Pearse5ca98812007-11-09 15:24:26 +0000186
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100187 ldr r1, [r0, #0x500]
188 bic r1, r1, #0x03
189 orr r1, r1, #0x01
190 str r1, [r0, #0x500]
Peter Pearse5ca98812007-11-09 15:24:26 +0000191
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100192 ldr r1, [r0, #0x140]
193 bic r1, r1, #0x1f
194 orr r1, r1, #0x02
195 str r1, [r0, #0x140]
Peter Pearse5ca98812007-11-09 15:24:26 +0000196
197#ifdef PRCM_CONFIG_I
198 ldr r1, =0x000003C3
199#else
200 ldr r1, =0x00000343
201#endif
202 str r1, [r0, #0x840]
203
204 ldr r1, =0x00000002
205 str r1, [r0, #0x340]
Peter Pearse2db916e2007-11-15 08:45:13 +0000206
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100207 ldr r1, =CM_CLKSEL1_CORE
Peter Pearse5ca98812007-11-09 15:24:26 +0000208#ifdef PRCM_CONFIG_I
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100209 ldr r2, =0x08300C44
Peter Pearse5ca98812007-11-09 15:24:26 +0000210#else
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100211 ldr r2, =0x04600C26
Peter Pearse5ca98812007-11-09 15:24:26 +0000212#endif
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100213 str r2, [r1]
Peter Pearse2db916e2007-11-15 08:45:13 +0000214
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100215 ldr r0, =OMAP2420_CM_BASE
216 ldr r1, [r0, #0x084]
217 and r1, r1, #0x01
218 cmp r1, #0x01
219 bne clkvalid
Peter Pearse5ca98812007-11-09 15:24:26 +0000220
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100221 b .
Peter Pearse5ca98812007-11-09 15:24:26 +0000222
223clkvalid:
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100224 mov r1, #0x01
225 str r1, [r0, #0x080]
Peter Pearse5ca98812007-11-09 15:24:26 +0000226
227waitvalid:
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100228 ldr r1, [r0, #0x084]
229 and r1, r1, #0x01
230 cmp r1, #0x00
231 bne waitvalid
Peter Pearse5ca98812007-11-09 15:24:26 +0000232
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100233 ldr r0, =CM_CLKSEL1_PLL
Peter Pearse5ca98812007-11-09 15:24:26 +0000234#ifdef PRCM_CONFIG_I
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100235 ldr r1, =0x01837100
Peter Pearse5ca98812007-11-09 15:24:26 +0000236#else
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100237 ldr r1, =0x01832100
Peter Pearse5ca98812007-11-09 15:24:26 +0000238#endif
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100239 str r1, [r0]
Peter Pearse5ca98812007-11-09 15:24:26 +0000240
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100241 ldr r0, =PRCM_CLKCFG_CTRL
242 mov r1, #0x01
243 str r1, [r0]
244 mov r6, #0x50
Peter Pearse5ca98812007-11-09 15:24:26 +0000245loop1:
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100246 subs r6, r6, #0x01
247 cmp r6, #0x01
248 bne loop1
Peter Pearse5ca98812007-11-09 15:24:26 +0000249
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100250 ldr r0, =CM_CLKEN_PLL
Peter Pearse5ca98812007-11-09 15:24:26 +0000251 mov r1, #0x0f
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100252 str r1, [r0]
Peter Pearse5ca98812007-11-09 15:24:26 +0000253
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100254 mov r6, #0x100
Peter Pearse5ca98812007-11-09 15:24:26 +0000255loop2:
Wolfgang Denk435dc8f2008-01-09 11:36:21 +0100256 subs r6, r6, #0x01
257 cmp r6, #0x01
258 bne loop2
Peter Pearse5ca98812007-11-09 15:24:26 +0000259
260 ldr r0, =0x48008200
261 ldr r1, =0xbfffffff
262 str r1, [r0]
263
264 ldr r0, =0x48008210
265 ldr r1, =0xfffffff9
266 str r1, [r0]
267
268 ldr r0, =0x4806a004
269 ldr r1, =0x00
270 strb r1, [r0]
271
272 ldr r0, =0x4806a020
273 ldr r1, =0x07
274 strb r1, [r0]
275
276 ldr r0, =0x4806a00c
277 ldr r1, =0x83
278 strb r1, [r0]
279
280 ldr r0, =0x4806a000
281 ldr r1, =0x1a
282 strb r1, [r0]
283
284 ldr r0, =0x4806a004
285 ldr r1, =0x00
286 strb r1, [r0]
287
288 ldr r0, =0x4806a00c
289 ldr r1, =0x03
290 strb r1, [r0]
291
292 ldr r0, =0x4806a010
293 ldr r1, =0x03
294 strb r1, [r0]
295
296 ldr r0, =0x4806a008
297 ldr r1, =0x04
298 strb r1, [r0]
299
300 ldr r0, =0x4806a020
301 ldr r1, =0x00
302 strb r1, [r0]
303
304#if 0
305 ldr r0, =0x4806a000
306 mov r1, #'u'
307 strb r1, [r0]
308#endif
309
310#if 0
311 /* LED0 OFF */
312 ldr r3, =0x480000E5
313 mov r4, #0x0b
314 strb r4, [r3]
315#endif
316
317 ldr sp, SRAM_STACK
318 str ip, [sp] /* stash old link register */
319 mov ip, lr /* save link reg across call */
320 bl s_init /* go setup pll,mux,memory */
321 ldr ip, [sp] /* restore save ip */
322 mov lr, ip /* restore link reg */
323
324 /* map interrupt controller */
325 ldr r0, VAL_INTH_SETUP
326 mcr p15, 0, r0, c15, c2, 4
327
328 /* back to arch calling code */
329 mov pc, lr
330
331 /* the literal pools origin */
332 .ltorg
333
334VAL_INTH_SETUP:
335 .word PERIFERAL_PORT_BASE
336SRAM_STACK:
337 .word LOW_LEVEL_SRAM_STACK