blob: bbea621920000bfcaf5b610b3eb5793fa474291b [file] [log] [blame]
Yusuke Godacf236022008-03-11 12:55:12 +09001/*
2 * Copyright (C) 2007,2008 Nobuhiro Iwamatsu
3 *
4 * u-boot/board/r7780mp/lowlevel_init.S
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307 USA
20 */
21
22#include <config.h>
23#include <version.h>
24#include <asm/processor.h>
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010025#include <asm/macro.h>
Yusuke Godacf236022008-03-11 12:55:12 +090026
27/*
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010028 * Board specific low level init code, called _very_ early in the
29 * startup sequence. Relocation to SDRAM has not happened yet, no
30 * stack is available, bss section has not been initialised, etc.
Yusuke Godacf236022008-03-11 12:55:12 +090031 *
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010032 * (Note: As no stack is available, no subroutines can be called...).
Yusuke Godacf236022008-03-11 12:55:12 +090033 */
34
35 .global lowlevel_init
36
37 .text
38 .align 2
39
40lowlevel_init:
41
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010042 write32 CCR_A, CCR_D /* Address of Cache Control Register */
43 /* Instruction Cache Invalidate */
Yusuke Godacf236022008-03-11 12:55:12 +090044
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010045 write32 FRQCR_A, FRQCR_D /* Frequency control register */
Yusuke Godacf236022008-03-11 12:55:12 +090046
47 /* pin_multi_setting */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010048 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR1
Yusuke Godacf236022008-03-11 12:55:12 +090049
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010050 write32 BBG_PMSR1_A, BBG_PMSR1_D
Yusuke Godacf236022008-03-11 12:55:12 +090051
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010052 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR2
Yusuke Godacf236022008-03-11 12:55:12 +090053
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010054 write32 BBG_PMSR2_A, BBG_PMSR2_D
Yusuke Godacf236022008-03-11 12:55:12 +090055
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010056 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR3
Yusuke Godacf236022008-03-11 12:55:12 +090057
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010058 write32 BBG_PMSR3_A, BBG_PMSR3_D
Yusuke Godacf236022008-03-11 12:55:12 +090059
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010060 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR4
Yusuke Godacf236022008-03-11 12:55:12 +090061
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010062 write32 BBG_PMSR4_A, BBG_PMSR4_D
Yusuke Godacf236022008-03-11 12:55:12 +090063
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010064 write32 BBG_PMMR_A, BBG_PMMR_D_PMSRG
Yusuke Godacf236022008-03-11 12:55:12 +090065
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010066 write32 BBG_PMSRG_A, BBG_PMSRG_D
Yusuke Godacf236022008-03-11 12:55:12 +090067
68 /* cpg_setting */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010069 write32 FRQCR_A, FRQCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090070
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010071 write32 DLLCSR_A, DLLCSR_D
Yusuke Godacf236022008-03-11 12:55:12 +090072
73 nop
74 nop
75 nop
76 nop
77 nop
78 nop
79 nop
80 nop
81 nop
82 nop
83
84 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010085 mov.l REPEAT0_R3, r3
86 mov #0, r2
Yusuke Godacf236022008-03-11 12:55:12 +090087repeat0:
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010088 add #1, r2
89 cmp/hs r3, r2
90 bf repeat0
Yusuke Godacf236022008-03-11 12:55:12 +090091 nop
92
93 /* bsc_setting */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010094 write32 MMSELR_A, MMSELR_D
Yusuke Godacf236022008-03-11 12:55:12 +090095
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010096 write32 BCR_A, BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090097
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010098 write32 CS0BCR_A, CS0BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090099
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100100 write32 CS1BCR_A, CS1BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900101
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100102 write32 CS2BCR_A, CS2BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900103
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100104 write32 CS4BCR_A, CS4BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900105
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100106 write32 CS5BCR_A, CS5BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900107
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100108 write32 CS6BCR_A, CS6BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900109
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100110 write32 CS0WCR_A, CS0WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900111
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100112 write32 CS1WCR_A, CS1WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900113
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100114 write32 CS2WCR_A, CS2WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900115
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100116 write32 CS4WCR_A, CS4WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900117
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100118 write32 CS5WCR_A, CS5WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900119
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100120 write32 CS6WCR_A, CS6WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900121
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100122 write32 CS5PCR_A, CS5PCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900123
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100124 write32 CS6PCR_A, CS6PCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900125
126 /* ddr_setting */
127 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100128 mov.l REPEAT0_R3, r3
129 mov #0, r2
Yusuke Godacf236022008-03-11 12:55:12 +0900130repeat1:
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100131 add #1, r2
132 cmp/hs r3, r2
133 bf repeat1
Yusuke Godacf236022008-03-11 12:55:12 +0900134 nop
135
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100136 mov.l MIM_U_A, r0
137 mov.l MIM_U_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900138 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100139 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900140 synco
141
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100142 mov.l MIM_L_A, r0
143 mov.l MIM_L_D0, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900144 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100145 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900146 synco
147
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100148 mov.l STR_L_A, r0
149 mov.l STR_L_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900150 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100151 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900152 synco
153
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100154 mov.l SDR_L_A, r0
155 mov.l SDR_L_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900156 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100157 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900158 synco
159
160 nop
161 nop
162 nop
163 nop
164
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100165 mov.l SCR_L_A, r0
166 mov.l SCR_L_D0, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900167 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100168 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900169 synco
170
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100171 mov.l SCR_L_A, r0
172 mov.l SCR_L_D1, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900173 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100174 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900175 synco
176
177 nop
178 nop
179 nop
180
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100181 mov.l EMRS_A, r0
182 mov.l EMRS_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900183 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100184 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900185 synco
186
187 nop
188 nop
189 nop
190
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100191 mov.l MRS1_A, r0
192 mov.l MRS1_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900193 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100194 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900195 synco
196
197 nop
198 nop
199 nop
200
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100201 mov.l SCR_L_A, r0
202 mov.l SCR_L_D2, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900203 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100204 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900205 synco
206
207 nop
208 nop
209 nop
210
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100211 mov.l SCR_L_A, r0
212 mov.l SCR_L_D3, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900213 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100214 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900215 synco
216
217 nop
218 nop
219 nop
220
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100221 mov.l SCR_L_A, r0
222 mov.l SCR_L_D4, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900223 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100224 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900225 synco
226
227 nop
228 nop
229 nop
230
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100231 mov.l MRS2_A, r0
232 mov.l MRS2_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900233 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100234 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900235 synco
236
237 nop
238 nop
239 nop
240
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100241 mov.l SCR_L_A, r0
242 mov.l SCR_L_D5, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900243 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100244 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900245 synco
246
247 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100248 mov.l REPEAT0_R1, r3
249 mov #0, r2
Yusuke Godacf236022008-03-11 12:55:12 +0900250repeat2:
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100251 add #1, r2
252 cmp/hs r3, r2
253 bf repeat2
Yusuke Godacf236022008-03-11 12:55:12 +0900254
255 synco
256
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100257 mov.l MIM_L_A, r0
258 mov.l MIM_L_D1, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900259 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100260 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900261 synco
262
263 rts
264 nop
265 .align 4
266
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100267RWTCSR_D_1: .word 0xA507
268RWTCSR_D_2: .word 0xA507
269RWTCNT_D: .word 0x5A00
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +0900270 .align 2
Yusuke Godacf236022008-03-11 12:55:12 +0900271
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100272BBG_PMMR_A: .long 0xFF800010
273BBG_PMSR1_A: .long 0xFF800014
274BBG_PMSR2_A: .long 0xFF800018
275BBG_PMSR3_A: .long 0xFF80001C
276BBG_PMSR4_A: .long 0xFF800020
277BBG_PMSRG_A: .long 0xFF800024
Yusuke Godacf236022008-03-11 12:55:12 +0900278
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100279BBG_PMMR_D_PMSR1: .long 0xffffbffd
280BBG_PMSR1_D: .long 0x00004002
281BBG_PMMR_D_PMSR2: .long 0xfc21a7ff
282BBG_PMSR2_D: .long 0x03de5800
283BBG_PMMR_D_PMSR3: .long 0xfffffff8
284BBG_PMSR3_D: .long 0x00000007
285BBG_PMMR_D_PMSR4: .long 0xdffdfff9
286BBG_PMSR4_D: .long 0x20020006
287BBG_PMMR_D_PMSRG: .long 0xffffffff
288BBG_PMSRG_D: .long 0x00000000
Yusuke Godacf236022008-03-11 12:55:12 +0900289
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100290FRQCR_A: .long FRQCR
291DLLCSR_A: .long 0xffc40010
292FRQCR_D: .long 0x40233035
293DLLCSR_D: .long 0x00000000
Yusuke Godacf236022008-03-11 12:55:12 +0900294
295/* for DDR-SDRAM */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100296MIM_U_A: .long MIM_1
297MIM_L_A: .long MIM_2
298SCR_U_A: .long SCR_1
299SCR_L_A: .long SCR_2
300STR_U_A: .long STR_1
301STR_L_A: .long STR_2
302SDR_U_A: .long SDR_1
303SDR_L_A: .long SDR_2
Yusuke Godacf236022008-03-11 12:55:12 +0900304
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100305EMRS_A: .long 0xFEC02000
306MRS1_A: .long 0xFEC00B08
307MRS2_A: .long 0xFEC00308
Yusuke Godacf236022008-03-11 12:55:12 +0900308
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100309MIM_U_D: .long 0x00004000
310MIM_L_D0: .long 0x03e80009
311MIM_L_D1: .long 0x03e80209
312SCR_L_D0: .long 0x3
313SCR_L_D1: .long 0x2
314SCR_L_D2: .long 0x2
315SCR_L_D3: .long 0x4
316SCR_L_D4: .long 0x4
317SCR_L_D5: .long 0x0
318STR_L_D: .long 0x000f0000
319SDR_L_D: .long 0x00000400
320EMRS_D: .long 0x0
321MRS1_D: .long 0x0
322MRS2_D: .long 0x0
Yusuke Godacf236022008-03-11 12:55:12 +0900323
324/* Cache Controller */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100325CCR_A: .long CCR
326MMUCR_A: .long MMUCR
327RWTCNT_A: .long WTCNT
Yusuke Godacf236022008-03-11 12:55:12 +0900328
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100329CCR_D: .long 0x0000090b
330CCR_D_2: .long 0x00000103
331MMUCR_D: .long 0x00000004
332MSTPCR0_D: .long 0x00001001
333MSTPCR2_D: .long 0xffffffff
Yusuke Godacf236022008-03-11 12:55:12 +0900334
335/* local Bus State Controller */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100336MMSELR_A: .long MMSELR
337BCR_A: .long BCR
338CS0BCR_A: .long CS0BCR
339CS1BCR_A: .long CS1BCR
340CS2BCR_A: .long CS2BCR
341CS4BCR_A: .long CS4BCR
342CS5BCR_A: .long CS5BCR
343CS6BCR_A: .long CS6BCR
344CS0WCR_A: .long CS0WCR
345CS1WCR_A: .long CS1WCR
346CS2WCR_A: .long CS2WCR
347CS4WCR_A: .long CS4WCR
348CS5WCR_A: .long CS5WCR
349CS6WCR_A: .long CS6WCR
350CS5PCR_A: .long CS5PCR
351CS6PCR_A: .long CS6PCR
Yusuke Godacf236022008-03-11 12:55:12 +0900352
353MMSELR_D: .long 0xA5A50003
354BCR_D: .long 0x00000000
355CS0BCR_D: .long 0x77777770
356CS1BCR_D: .long 0x77777670
357CS2BCR_D: .long 0x77777770
358CS4BCR_D: .long 0x77777770
359CS5BCR_D: .long 0x77777670
360CS6BCR_D: .long 0x77777770
361CS0WCR_D: .long 0x00020006
362CS1WCR_D: .long 0x00232304
363CS2WCR_D: .long 0x7777770F
364CS4WCR_D: .long 0x7777770F
365CS5WCR_D: .long 0x00101006
366CS6WCR_D: .long 0x77777703
367CS5PCR_D: .long 0x77000000
368CS6PCR_D: .long 0x77000000
369
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100370REPEAT0_R3: .long 0x00002000
371REPEAT0_R1: .long 0x0000200