blob: 7be1a1bf07039082cfdf3a7a20feacd34078a7d5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Yusuke Godacf236022008-03-11 12:55:12 +09002/*
3 * Copyright (C) 2007,2008 Nobuhiro Iwamatsu
4 *
5 * u-boot/board/r7780mp/lowlevel_init.S
Yusuke Godacf236022008-03-11 12:55:12 +09006 */
7
8#include <config.h>
Yusuke Godacf236022008-03-11 12:55:12 +09009#include <asm/processor.h>
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010010#include <asm/macro.h>
Yusuke Godacf236022008-03-11 12:55:12 +090011
12/*
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010013 * Board specific low level init code, called _very_ early in the
14 * startup sequence. Relocation to SDRAM has not happened yet, no
15 * stack is available, bss section has not been initialised, etc.
Yusuke Godacf236022008-03-11 12:55:12 +090016 *
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010017 * (Note: As no stack is available, no subroutines can be called...).
Yusuke Godacf236022008-03-11 12:55:12 +090018 */
19
20 .global lowlevel_init
21
22 .text
23 .align 2
24
25lowlevel_init:
26
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010027 write32 CCR_A, CCR_D /* Address of Cache Control Register */
28 /* Instruction Cache Invalidate */
Yusuke Godacf236022008-03-11 12:55:12 +090029
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010030 write32 FRQCR_A, FRQCR_D /* Frequency control register */
Yusuke Godacf236022008-03-11 12:55:12 +090031
32 /* pin_multi_setting */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010033 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR1
Yusuke Godacf236022008-03-11 12:55:12 +090034
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010035 write32 BBG_PMSR1_A, BBG_PMSR1_D
Yusuke Godacf236022008-03-11 12:55:12 +090036
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010037 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR2
Yusuke Godacf236022008-03-11 12:55:12 +090038
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010039 write32 BBG_PMSR2_A, BBG_PMSR2_D
Yusuke Godacf236022008-03-11 12:55:12 +090040
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010041 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR3
Yusuke Godacf236022008-03-11 12:55:12 +090042
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010043 write32 BBG_PMSR3_A, BBG_PMSR3_D
Yusuke Godacf236022008-03-11 12:55:12 +090044
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010045 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR4
Yusuke Godacf236022008-03-11 12:55:12 +090046
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010047 write32 BBG_PMSR4_A, BBG_PMSR4_D
Yusuke Godacf236022008-03-11 12:55:12 +090048
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010049 write32 BBG_PMMR_A, BBG_PMMR_D_PMSRG
Yusuke Godacf236022008-03-11 12:55:12 +090050
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010051 write32 BBG_PMSRG_A, BBG_PMSRG_D
Yusuke Godacf236022008-03-11 12:55:12 +090052
53 /* cpg_setting */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010054 write32 FRQCR_A, FRQCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090055
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010056 write32 DLLCSR_A, DLLCSR_D
Yusuke Godacf236022008-03-11 12:55:12 +090057
58 nop
59 nop
60 nop
61 nop
62 nop
63 nop
64 nop
65 nop
66 nop
67 nop
68
69 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010070 mov.l REPEAT0_R3, r3
71 mov #0, r2
Yusuke Godacf236022008-03-11 12:55:12 +090072repeat0:
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010073 add #1, r2
74 cmp/hs r3, r2
75 bf repeat0
Yusuke Godacf236022008-03-11 12:55:12 +090076 nop
77
78 /* bsc_setting */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010079 write32 MMSELR_A, MMSELR_D
Yusuke Godacf236022008-03-11 12:55:12 +090080
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010081 write32 BCR_A, BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090082
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010083 write32 CS0BCR_A, CS0BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090084
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010085 write32 CS1BCR_A, CS1BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090086
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010087 write32 CS2BCR_A, CS2BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090088
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010089 write32 CS4BCR_A, CS4BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090090
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010091 write32 CS5BCR_A, CS5BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090092
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010093 write32 CS6BCR_A, CS6BCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090094
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010095 write32 CS0WCR_A, CS0WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090096
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010097 write32 CS1WCR_A, CS1WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +090098
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010099 write32 CS2WCR_A, CS2WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900100
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100101 write32 CS4WCR_A, CS4WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900102
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100103 write32 CS5WCR_A, CS5WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900104
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100105 write32 CS6WCR_A, CS6WCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900106
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100107 write32 CS5PCR_A, CS5PCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900108
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100109 write32 CS6PCR_A, CS6PCR_D
Yusuke Godacf236022008-03-11 12:55:12 +0900110
111 /* ddr_setting */
112 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100113 mov.l REPEAT0_R3, r3
114 mov #0, r2
Yusuke Godacf236022008-03-11 12:55:12 +0900115repeat1:
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100116 add #1, r2
117 cmp/hs r3, r2
118 bf repeat1
Yusuke Godacf236022008-03-11 12:55:12 +0900119 nop
120
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100121 mov.l MIM_U_A, r0
122 mov.l MIM_U_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900123 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100124 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900125 synco
126
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100127 mov.l MIM_L_A, r0
128 mov.l MIM_L_D0, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900129 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100130 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900131 synco
132
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100133 mov.l STR_L_A, r0
134 mov.l STR_L_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900135 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100136 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900137 synco
138
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100139 mov.l SDR_L_A, r0
140 mov.l SDR_L_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900141 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100142 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900143 synco
144
145 nop
146 nop
147 nop
148 nop
149
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100150 mov.l SCR_L_A, r0
151 mov.l SCR_L_D0, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900152 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100153 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900154 synco
155
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100156 mov.l SCR_L_A, r0
157 mov.l SCR_L_D1, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900158 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100159 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900160 synco
161
162 nop
163 nop
164 nop
165
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100166 mov.l EMRS_A, r0
167 mov.l EMRS_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900168 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100169 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900170 synco
171
172 nop
173 nop
174 nop
175
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100176 mov.l MRS1_A, r0
177 mov.l MRS1_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900178 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100179 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900180 synco
181
182 nop
183 nop
184 nop
185
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100186 mov.l SCR_L_A, r0
187 mov.l SCR_L_D2, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900188 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100189 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900190 synco
191
192 nop
193 nop
194 nop
195
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100196 mov.l SCR_L_A, r0
197 mov.l SCR_L_D3, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900198 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100199 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900200 synco
201
202 nop
203 nop
204 nop
205
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100206 mov.l SCR_L_A, r0
207 mov.l SCR_L_D4, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900208 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100209 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900210 synco
211
212 nop
213 nop
214 nop
215
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100216 mov.l MRS2_A, r0
217 mov.l MRS2_D, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900218 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100219 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900220 synco
221
222 nop
223 nop
224 nop
225
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100226 mov.l SCR_L_A, r0
227 mov.l SCR_L_D5, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900228 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100229 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900230 synco
231
232 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100233 mov.l REPEAT0_R1, r3
234 mov #0, r2
Yusuke Godacf236022008-03-11 12:55:12 +0900235repeat2:
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100236 add #1, r2
237 cmp/hs r3, r2
238 bf repeat2
Yusuke Godacf236022008-03-11 12:55:12 +0900239
240 synco
241
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100242 mov.l MIM_L_A, r0
243 mov.l MIM_L_D1, r1
Yusuke Godacf236022008-03-11 12:55:12 +0900244 synco
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100245 mov.l r1, @r0
Yusuke Godacf236022008-03-11 12:55:12 +0900246 synco
247
248 rts
249 nop
250 .align 4
251
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100252RWTCSR_D_1: .word 0xA507
253RWTCSR_D_2: .word 0xA507
254RWTCNT_D: .word 0x5A00
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +0900255 .align 2
Yusuke Godacf236022008-03-11 12:55:12 +0900256
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100257BBG_PMMR_A: .long 0xFF800010
258BBG_PMSR1_A: .long 0xFF800014
259BBG_PMSR2_A: .long 0xFF800018
260BBG_PMSR3_A: .long 0xFF80001C
261BBG_PMSR4_A: .long 0xFF800020
262BBG_PMSRG_A: .long 0xFF800024
Yusuke Godacf236022008-03-11 12:55:12 +0900263
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100264BBG_PMMR_D_PMSR1: .long 0xffffbffd
265BBG_PMSR1_D: .long 0x00004002
266BBG_PMMR_D_PMSR2: .long 0xfc21a7ff
267BBG_PMSR2_D: .long 0x03de5800
268BBG_PMMR_D_PMSR3: .long 0xfffffff8
269BBG_PMSR3_D: .long 0x00000007
270BBG_PMMR_D_PMSR4: .long 0xdffdfff9
271BBG_PMSR4_D: .long 0x20020006
272BBG_PMMR_D_PMSRG: .long 0xffffffff
273BBG_PMSRG_D: .long 0x00000000
Yusuke Godacf236022008-03-11 12:55:12 +0900274
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100275FRQCR_A: .long FRQCR
276DLLCSR_A: .long 0xffc40010
277FRQCR_D: .long 0x40233035
278DLLCSR_D: .long 0x00000000
Yusuke Godacf236022008-03-11 12:55:12 +0900279
280/* for DDR-SDRAM */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100281MIM_U_A: .long MIM_1
282MIM_L_A: .long MIM_2
283SCR_U_A: .long SCR_1
284SCR_L_A: .long SCR_2
285STR_U_A: .long STR_1
286STR_L_A: .long STR_2
287SDR_U_A: .long SDR_1
288SDR_L_A: .long SDR_2
Yusuke Godacf236022008-03-11 12:55:12 +0900289
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100290EMRS_A: .long 0xFEC02000
291MRS1_A: .long 0xFEC00B08
292MRS2_A: .long 0xFEC00308
Yusuke Godacf236022008-03-11 12:55:12 +0900293
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100294MIM_U_D: .long 0x00004000
295MIM_L_D0: .long 0x03e80009
296MIM_L_D1: .long 0x03e80209
297SCR_L_D0: .long 0x3
298SCR_L_D1: .long 0x2
299SCR_L_D2: .long 0x2
300SCR_L_D3: .long 0x4
301SCR_L_D4: .long 0x4
302SCR_L_D5: .long 0x0
303STR_L_D: .long 0x000f0000
304SDR_L_D: .long 0x00000400
305EMRS_D: .long 0x0
306MRS1_D: .long 0x0
307MRS2_D: .long 0x0
Yusuke Godacf236022008-03-11 12:55:12 +0900308
309/* Cache Controller */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100310CCR_A: .long CCR
311MMUCR_A: .long MMUCR
312RWTCNT_A: .long WTCNT
Yusuke Godacf236022008-03-11 12:55:12 +0900313
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100314CCR_D: .long 0x0000090b
315CCR_D_2: .long 0x00000103
316MMUCR_D: .long 0x00000004
317MSTPCR0_D: .long 0x00001001
318MSTPCR2_D: .long 0xffffffff
Yusuke Godacf236022008-03-11 12:55:12 +0900319
320/* local Bus State Controller */
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100321MMSELR_A: .long MMSELR
322BCR_A: .long BCR
323CS0BCR_A: .long CS0BCR
324CS1BCR_A: .long CS1BCR
325CS2BCR_A: .long CS2BCR
326CS4BCR_A: .long CS4BCR
327CS5BCR_A: .long CS5BCR
328CS6BCR_A: .long CS6BCR
329CS0WCR_A: .long CS0WCR
330CS1WCR_A: .long CS1WCR
331CS2WCR_A: .long CS2WCR
332CS4WCR_A: .long CS4WCR
333CS5WCR_A: .long CS5WCR
334CS6WCR_A: .long CS6WCR
335CS5PCR_A: .long CS5PCR
336CS6PCR_A: .long CS6PCR
Yusuke Godacf236022008-03-11 12:55:12 +0900337
338MMSELR_D: .long 0xA5A50003
339BCR_D: .long 0x00000000
340CS0BCR_D: .long 0x77777770
341CS1BCR_D: .long 0x77777670
342CS2BCR_D: .long 0x77777770
343CS4BCR_D: .long 0x77777770
344CS5BCR_D: .long 0x77777670
345CS6BCR_D: .long 0x77777770
346CS0WCR_D: .long 0x00020006
347CS1WCR_D: .long 0x00232304
348CS2WCR_D: .long 0x7777770F
349CS4WCR_D: .long 0x7777770F
350CS5WCR_D: .long 0x00101006
351CS6WCR_D: .long 0x77777703
352CS5PCR_D: .long 0x77000000
353CS6PCR_D: .long 0x77000000
354
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100355REPEAT0_R3: .long 0x00002000
356REPEAT0_R1: .long 0x0000200