blob: b27fe291437aa20492363e47414d73ca0df76dff [file] [log] [blame]
Yusuke Godac133c1f2008-03-11 12:55:12 +09001/*
2 * Copyright (C) 2007,2008 Nobuhiro Iwamatsu
3 *
4 * u-boot/board/r7780mp/lowlevel_init.S
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Yusuke Godac133c1f2008-03-11 12:55:12 +09007 */
8
9#include <config.h>
Yusuke Godac133c1f2008-03-11 12:55:12 +090010#include <asm/processor.h>
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010011#include <asm/macro.h>
Yusuke Godac133c1f2008-03-11 12:55:12 +090012
13/*
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010014 * Board specific low level init code, called _very_ early in the
15 * startup sequence. Relocation to SDRAM has not happened yet, no
16 * stack is available, bss section has not been initialised, etc.
Yusuke Godac133c1f2008-03-11 12:55:12 +090017 *
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010018 * (Note: As no stack is available, no subroutines can be called...).
Yusuke Godac133c1f2008-03-11 12:55:12 +090019 */
20
21 .global lowlevel_init
22
23 .text
24 .align 2
25
26lowlevel_init:
27
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010028 write32 CCR_A, CCR_D /* Address of Cache Control Register */
29 /* Instruction Cache Invalidate */
Yusuke Godac133c1f2008-03-11 12:55:12 +090030
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010031 write32 FRQCR_A, FRQCR_D /* Frequency control register */
Yusuke Godac133c1f2008-03-11 12:55:12 +090032
33 /* pin_multi_setting */
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010034 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR1
Yusuke Godac133c1f2008-03-11 12:55:12 +090035
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010036 write32 BBG_PMSR1_A, BBG_PMSR1_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090037
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010038 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR2
Yusuke Godac133c1f2008-03-11 12:55:12 +090039
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010040 write32 BBG_PMSR2_A, BBG_PMSR2_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090041
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010042 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR3
Yusuke Godac133c1f2008-03-11 12:55:12 +090043
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010044 write32 BBG_PMSR3_A, BBG_PMSR3_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090045
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010046 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR4
Yusuke Godac133c1f2008-03-11 12:55:12 +090047
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010048 write32 BBG_PMSR4_A, BBG_PMSR4_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090049
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010050 write32 BBG_PMMR_A, BBG_PMMR_D_PMSRG
Yusuke Godac133c1f2008-03-11 12:55:12 +090051
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010052 write32 BBG_PMSRG_A, BBG_PMSRG_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090053
54 /* cpg_setting */
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010055 write32 FRQCR_A, FRQCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090056
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010057 write32 DLLCSR_A, DLLCSR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090058
59 nop
60 nop
61 nop
62 nop
63 nop
64 nop
65 nop
66 nop
67 nop
68 nop
69
70 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010071 mov.l REPEAT0_R3, r3
72 mov #0, r2
Yusuke Godac133c1f2008-03-11 12:55:12 +090073repeat0:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010074 add #1, r2
75 cmp/hs r3, r2
76 bf repeat0
Yusuke Godac133c1f2008-03-11 12:55:12 +090077 nop
78
79 /* bsc_setting */
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010080 write32 MMSELR_A, MMSELR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090081
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010082 write32 BCR_A, BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090083
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010084 write32 CS0BCR_A, CS0BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090085
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010086 write32 CS1BCR_A, CS1BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090087
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010088 write32 CS2BCR_A, CS2BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090089
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010090 write32 CS4BCR_A, CS4BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090091
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010092 write32 CS5BCR_A, CS5BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090093
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010094 write32 CS6BCR_A, CS6BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090095
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010096 write32 CS0WCR_A, CS0WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090097
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010098 write32 CS1WCR_A, CS1WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090099
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100100 write32 CS2WCR_A, CS2WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900101
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100102 write32 CS4WCR_A, CS4WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900103
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100104 write32 CS5WCR_A, CS5WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900105
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100106 write32 CS6WCR_A, CS6WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900107
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100108 write32 CS5PCR_A, CS5PCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900109
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100110 write32 CS6PCR_A, CS6PCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900111
112 /* ddr_setting */
113 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100114 mov.l REPEAT0_R3, r3
115 mov #0, r2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900116repeat1:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100117 add #1, r2
118 cmp/hs r3, r2
119 bf repeat1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900120 nop
121
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100122 mov.l MIM_U_A, r0
123 mov.l MIM_U_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900124 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100125 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900126 synco
127
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100128 mov.l MIM_L_A, r0
129 mov.l MIM_L_D0, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900130 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100131 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900132 synco
133
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100134 mov.l STR_L_A, r0
135 mov.l STR_L_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900136 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100137 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900138 synco
139
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100140 mov.l SDR_L_A, r0
141 mov.l SDR_L_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900142 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100143 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900144 synco
145
146 nop
147 nop
148 nop
149 nop
150
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100151 mov.l SCR_L_A, r0
152 mov.l SCR_L_D0, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900153 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100154 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900155 synco
156
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100157 mov.l SCR_L_A, r0
158 mov.l SCR_L_D1, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900159 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100160 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900161 synco
162
163 nop
164 nop
165 nop
166
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100167 mov.l EMRS_A, r0
168 mov.l EMRS_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900169 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100170 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900171 synco
172
173 nop
174 nop
175 nop
176
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100177 mov.l MRS1_A, r0
178 mov.l MRS1_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900179 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100180 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900181 synco
182
183 nop
184 nop
185 nop
186
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100187 mov.l SCR_L_A, r0
188 mov.l SCR_L_D2, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900189 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100190 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900191 synco
192
193 nop
194 nop
195 nop
196
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100197 mov.l SCR_L_A, r0
198 mov.l SCR_L_D3, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900199 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100200 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900201 synco
202
203 nop
204 nop
205 nop
206
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100207 mov.l SCR_L_A, r0
208 mov.l SCR_L_D4, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900209 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100210 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900211 synco
212
213 nop
214 nop
215 nop
216
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100217 mov.l MRS2_A, r0
218 mov.l MRS2_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900219 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100220 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900221 synco
222
223 nop
224 nop
225 nop
226
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100227 mov.l SCR_L_A, r0
228 mov.l SCR_L_D5, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900229 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100230 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900231 synco
232
233 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100234 mov.l REPEAT0_R1, r3
235 mov #0, r2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900236repeat2:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100237 add #1, r2
238 cmp/hs r3, r2
239 bf repeat2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900240
241 synco
242
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100243 mov.l MIM_L_A, r0
244 mov.l MIM_L_D1, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900245 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100246 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900247 synco
248
249 rts
250 nop
251 .align 4
252
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100253RWTCSR_D_1: .word 0xA507
254RWTCSR_D_2: .word 0xA507
255RWTCNT_D: .word 0x5A00
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +0900256 .align 2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900257
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100258BBG_PMMR_A: .long 0xFF800010
259BBG_PMSR1_A: .long 0xFF800014
260BBG_PMSR2_A: .long 0xFF800018
261BBG_PMSR3_A: .long 0xFF80001C
262BBG_PMSR4_A: .long 0xFF800020
263BBG_PMSRG_A: .long 0xFF800024
Yusuke Godac133c1f2008-03-11 12:55:12 +0900264
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100265BBG_PMMR_D_PMSR1: .long 0xffffbffd
266BBG_PMSR1_D: .long 0x00004002
267BBG_PMMR_D_PMSR2: .long 0xfc21a7ff
268BBG_PMSR2_D: .long 0x03de5800
269BBG_PMMR_D_PMSR3: .long 0xfffffff8
270BBG_PMSR3_D: .long 0x00000007
271BBG_PMMR_D_PMSR4: .long 0xdffdfff9
272BBG_PMSR4_D: .long 0x20020006
273BBG_PMMR_D_PMSRG: .long 0xffffffff
274BBG_PMSRG_D: .long 0x00000000
Yusuke Godac133c1f2008-03-11 12:55:12 +0900275
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100276FRQCR_A: .long FRQCR
277DLLCSR_A: .long 0xffc40010
278FRQCR_D: .long 0x40233035
279DLLCSR_D: .long 0x00000000
Yusuke Godac133c1f2008-03-11 12:55:12 +0900280
281/* for DDR-SDRAM */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100282MIM_U_A: .long MIM_1
283MIM_L_A: .long MIM_2
284SCR_U_A: .long SCR_1
285SCR_L_A: .long SCR_2
286STR_U_A: .long STR_1
287STR_L_A: .long STR_2
288SDR_U_A: .long SDR_1
289SDR_L_A: .long SDR_2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900290
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100291EMRS_A: .long 0xFEC02000
292MRS1_A: .long 0xFEC00B08
293MRS2_A: .long 0xFEC00308
Yusuke Godac133c1f2008-03-11 12:55:12 +0900294
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100295MIM_U_D: .long 0x00004000
296MIM_L_D0: .long 0x03e80009
297MIM_L_D1: .long 0x03e80209
298SCR_L_D0: .long 0x3
299SCR_L_D1: .long 0x2
300SCR_L_D2: .long 0x2
301SCR_L_D3: .long 0x4
302SCR_L_D4: .long 0x4
303SCR_L_D5: .long 0x0
304STR_L_D: .long 0x000f0000
305SDR_L_D: .long 0x00000400
306EMRS_D: .long 0x0
307MRS1_D: .long 0x0
308MRS2_D: .long 0x0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900309
310/* Cache Controller */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100311CCR_A: .long CCR
312MMUCR_A: .long MMUCR
313RWTCNT_A: .long WTCNT
Yusuke Godac133c1f2008-03-11 12:55:12 +0900314
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100315CCR_D: .long 0x0000090b
316CCR_D_2: .long 0x00000103
317MMUCR_D: .long 0x00000004
318MSTPCR0_D: .long 0x00001001
319MSTPCR2_D: .long 0xffffffff
Yusuke Godac133c1f2008-03-11 12:55:12 +0900320
321/* local Bus State Controller */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100322MMSELR_A: .long MMSELR
323BCR_A: .long BCR
324CS0BCR_A: .long CS0BCR
325CS1BCR_A: .long CS1BCR
326CS2BCR_A: .long CS2BCR
327CS4BCR_A: .long CS4BCR
328CS5BCR_A: .long CS5BCR
329CS6BCR_A: .long CS6BCR
330CS0WCR_A: .long CS0WCR
331CS1WCR_A: .long CS1WCR
332CS2WCR_A: .long CS2WCR
333CS4WCR_A: .long CS4WCR
334CS5WCR_A: .long CS5WCR
335CS6WCR_A: .long CS6WCR
336CS5PCR_A: .long CS5PCR
337CS6PCR_A: .long CS6PCR
Yusuke Godac133c1f2008-03-11 12:55:12 +0900338
339MMSELR_D: .long 0xA5A50003
340BCR_D: .long 0x00000000
341CS0BCR_D: .long 0x77777770
342CS1BCR_D: .long 0x77777670
343CS2BCR_D: .long 0x77777770
344CS4BCR_D: .long 0x77777770
345CS5BCR_D: .long 0x77777670
346CS6BCR_D: .long 0x77777770
347CS0WCR_D: .long 0x00020006
348CS1WCR_D: .long 0x00232304
349CS2WCR_D: .long 0x7777770F
350CS4WCR_D: .long 0x7777770F
351CS5WCR_D: .long 0x00101006
352CS6WCR_D: .long 0x77777703
353CS5PCR_D: .long 0x77000000
354CS6PCR_D: .long 0x77000000
355
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100356REPEAT0_R3: .long 0x00002000
357REPEAT0_R1: .long 0x0000200