blob: 471af1d9677326a84cb093e58151200bf3fe291e [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>
10#include <version.h>
11#include <asm/processor.h>
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010012#include <asm/macro.h>
Yusuke Godac133c1f2008-03-11 12:55:12 +090013
14/*
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010015 * Board specific low level init code, called _very_ early in the
16 * startup sequence. Relocation to SDRAM has not happened yet, no
17 * stack is available, bss section has not been initialised, etc.
Yusuke Godac133c1f2008-03-11 12:55:12 +090018 *
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010019 * (Note: As no stack is available, no subroutines can be called...).
Yusuke Godac133c1f2008-03-11 12:55:12 +090020 */
21
22 .global lowlevel_init
23
24 .text
25 .align 2
26
27lowlevel_init:
28
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010029 write32 CCR_A, CCR_D /* Address of Cache Control Register */
30 /* Instruction Cache Invalidate */
Yusuke Godac133c1f2008-03-11 12:55:12 +090031
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010032 write32 FRQCR_A, FRQCR_D /* Frequency control register */
Yusuke Godac133c1f2008-03-11 12:55:12 +090033
34 /* pin_multi_setting */
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010035 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR1
Yusuke Godac133c1f2008-03-11 12:55:12 +090036
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010037 write32 BBG_PMSR1_A, BBG_PMSR1_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090038
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010039 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR2
Yusuke Godac133c1f2008-03-11 12:55:12 +090040
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010041 write32 BBG_PMSR2_A, BBG_PMSR2_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090042
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010043 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR3
Yusuke Godac133c1f2008-03-11 12:55:12 +090044
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010045 write32 BBG_PMSR3_A, BBG_PMSR3_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090046
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010047 write32 BBG_PMMR_A, BBG_PMMR_D_PMSR4
Yusuke Godac133c1f2008-03-11 12:55:12 +090048
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010049 write32 BBG_PMSR4_A, BBG_PMSR4_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090050
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010051 write32 BBG_PMMR_A, BBG_PMMR_D_PMSRG
Yusuke Godac133c1f2008-03-11 12:55:12 +090052
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010053 write32 BBG_PMSRG_A, BBG_PMSRG_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090054
55 /* cpg_setting */
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010056 write32 FRQCR_A, FRQCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090057
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010058 write32 DLLCSR_A, DLLCSR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090059
60 nop
61 nop
62 nop
63 nop
64 nop
65 nop
66 nop
67 nop
68 nop
69 nop
70
71 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010072 mov.l REPEAT0_R3, r3
73 mov #0, r2
Yusuke Godac133c1f2008-03-11 12:55:12 +090074repeat0:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010075 add #1, r2
76 cmp/hs r3, r2
77 bf repeat0
Yusuke Godac133c1f2008-03-11 12:55:12 +090078 nop
79
80 /* bsc_setting */
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010081 write32 MMSELR_A, MMSELR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090082
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010083 write32 BCR_A, BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090084
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010085 write32 CS0BCR_A, CS0BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090086
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010087 write32 CS1BCR_A, CS1BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090088
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010089 write32 CS2BCR_A, CS2BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090090
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010091 write32 CS4BCR_A, CS4BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090092
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010093 write32 CS5BCR_A, CS5BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090094
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010095 write32 CS6BCR_A, CS6BCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090096
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010097 write32 CS0WCR_A, CS0WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +090098
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010099 write32 CS1WCR_A, CS1WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900100
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100101 write32 CS2WCR_A, CS2WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900102
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100103 write32 CS4WCR_A, CS4WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900104
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100105 write32 CS5WCR_A, CS5WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900106
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100107 write32 CS6WCR_A, CS6WCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900108
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100109 write32 CS5PCR_A, CS5PCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900110
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100111 write32 CS6PCR_A, CS6PCR_D
Yusuke Godac133c1f2008-03-11 12:55:12 +0900112
113 /* ddr_setting */
114 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100115 mov.l REPEAT0_R3, r3
116 mov #0, r2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900117repeat1:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100118 add #1, r2
119 cmp/hs r3, r2
120 bf repeat1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900121 nop
122
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100123 mov.l MIM_U_A, r0
124 mov.l MIM_U_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900125 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100126 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900127 synco
128
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100129 mov.l MIM_L_A, r0
130 mov.l MIM_L_D0, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900131 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100132 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900133 synco
134
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100135 mov.l STR_L_A, r0
136 mov.l STR_L_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900137 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100138 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900139 synco
140
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100141 mov.l SDR_L_A, r0
142 mov.l SDR_L_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900143 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100144 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900145 synco
146
147 nop
148 nop
149 nop
150 nop
151
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100152 mov.l SCR_L_A, r0
153 mov.l SCR_L_D0, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900154 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100155 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900156 synco
157
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100158 mov.l SCR_L_A, r0
159 mov.l SCR_L_D1, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900160 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100161 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900162 synco
163
164 nop
165 nop
166 nop
167
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100168 mov.l EMRS_A, r0
169 mov.l EMRS_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900170 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100171 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900172 synco
173
174 nop
175 nop
176 nop
177
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100178 mov.l MRS1_A, r0
179 mov.l MRS1_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900180 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100181 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900182 synco
183
184 nop
185 nop
186 nop
187
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100188 mov.l SCR_L_A, r0
189 mov.l SCR_L_D2, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900190 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100191 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900192 synco
193
194 nop
195 nop
196 nop
197
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100198 mov.l SCR_L_A, r0
199 mov.l SCR_L_D3, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900200 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100201 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900202 synco
203
204 nop
205 nop
206 nop
207
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100208 mov.l SCR_L_A, r0
209 mov.l SCR_L_D4, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900210 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100211 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900212 synco
213
214 nop
215 nop
216 nop
217
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100218 mov.l MRS2_A, r0
219 mov.l MRS2_D, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900220 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100221 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900222 synco
223
224 nop
225 nop
226 nop
227
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100228 mov.l SCR_L_A, r0
229 mov.l SCR_L_D5, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900230 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100231 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900232 synco
233
234 /* wait 200us */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100235 mov.l REPEAT0_R1, r3
236 mov #0, r2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900237repeat2:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100238 add #1, r2
239 cmp/hs r3, r2
240 bf repeat2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900241
242 synco
243
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100244 mov.l MIM_L_A, r0
245 mov.l MIM_L_D1, r1
Yusuke Godac133c1f2008-03-11 12:55:12 +0900246 synco
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100247 mov.l r1, @r0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900248 synco
249
250 rts
251 nop
252 .align 4
253
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100254RWTCSR_D_1: .word 0xA507
255RWTCSR_D_2: .word 0xA507
256RWTCNT_D: .word 0x5A00
Nobuhiro Iwamatsub5d10a12008-09-18 19:34:36 +0900257 .align 2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900258
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100259BBG_PMMR_A: .long 0xFF800010
260BBG_PMSR1_A: .long 0xFF800014
261BBG_PMSR2_A: .long 0xFF800018
262BBG_PMSR3_A: .long 0xFF80001C
263BBG_PMSR4_A: .long 0xFF800020
264BBG_PMSRG_A: .long 0xFF800024
Yusuke Godac133c1f2008-03-11 12:55:12 +0900265
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100266BBG_PMMR_D_PMSR1: .long 0xffffbffd
267BBG_PMSR1_D: .long 0x00004002
268BBG_PMMR_D_PMSR2: .long 0xfc21a7ff
269BBG_PMSR2_D: .long 0x03de5800
270BBG_PMMR_D_PMSR3: .long 0xfffffff8
271BBG_PMSR3_D: .long 0x00000007
272BBG_PMMR_D_PMSR4: .long 0xdffdfff9
273BBG_PMSR4_D: .long 0x20020006
274BBG_PMMR_D_PMSRG: .long 0xffffffff
275BBG_PMSRG_D: .long 0x00000000
Yusuke Godac133c1f2008-03-11 12:55:12 +0900276
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100277FRQCR_A: .long FRQCR
278DLLCSR_A: .long 0xffc40010
279FRQCR_D: .long 0x40233035
280DLLCSR_D: .long 0x00000000
Yusuke Godac133c1f2008-03-11 12:55:12 +0900281
282/* for DDR-SDRAM */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100283MIM_U_A: .long MIM_1
284MIM_L_A: .long MIM_2
285SCR_U_A: .long SCR_1
286SCR_L_A: .long SCR_2
287STR_U_A: .long STR_1
288STR_L_A: .long STR_2
289SDR_U_A: .long SDR_1
290SDR_L_A: .long SDR_2
Yusuke Godac133c1f2008-03-11 12:55:12 +0900291
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100292EMRS_A: .long 0xFEC02000
293MRS1_A: .long 0xFEC00B08
294MRS2_A: .long 0xFEC00308
Yusuke Godac133c1f2008-03-11 12:55:12 +0900295
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100296MIM_U_D: .long 0x00004000
297MIM_L_D0: .long 0x03e80009
298MIM_L_D1: .long 0x03e80209
299SCR_L_D0: .long 0x3
300SCR_L_D1: .long 0x2
301SCR_L_D2: .long 0x2
302SCR_L_D3: .long 0x4
303SCR_L_D4: .long 0x4
304SCR_L_D5: .long 0x0
305STR_L_D: .long 0x000f0000
306SDR_L_D: .long 0x00000400
307EMRS_D: .long 0x0
308MRS1_D: .long 0x0
309MRS2_D: .long 0x0
Yusuke Godac133c1f2008-03-11 12:55:12 +0900310
311/* Cache Controller */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100312CCR_A: .long CCR
313MMUCR_A: .long MMUCR
314RWTCNT_A: .long WTCNT
Yusuke Godac133c1f2008-03-11 12:55:12 +0900315
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100316CCR_D: .long 0x0000090b
317CCR_D_2: .long 0x00000103
318MMUCR_D: .long 0x00000004
319MSTPCR0_D: .long 0x00001001
320MSTPCR2_D: .long 0xffffffff
Yusuke Godac133c1f2008-03-11 12:55:12 +0900321
322/* local Bus State Controller */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100323MMSELR_A: .long MMSELR
324BCR_A: .long BCR
325CS0BCR_A: .long CS0BCR
326CS1BCR_A: .long CS1BCR
327CS2BCR_A: .long CS2BCR
328CS4BCR_A: .long CS4BCR
329CS5BCR_A: .long CS5BCR
330CS6BCR_A: .long CS6BCR
331CS0WCR_A: .long CS0WCR
332CS1WCR_A: .long CS1WCR
333CS2WCR_A: .long CS2WCR
334CS4WCR_A: .long CS4WCR
335CS5WCR_A: .long CS5WCR
336CS6WCR_A: .long CS6WCR
337CS5PCR_A: .long CS5PCR
338CS6PCR_A: .long CS6PCR
Yusuke Godac133c1f2008-03-11 12:55:12 +0900339
340MMSELR_D: .long 0xA5A50003
341BCR_D: .long 0x00000000
342CS0BCR_D: .long 0x77777770
343CS1BCR_D: .long 0x77777670
344CS2BCR_D: .long 0x77777770
345CS4BCR_D: .long 0x77777770
346CS5BCR_D: .long 0x77777670
347CS6BCR_D: .long 0x77777770
348CS0WCR_D: .long 0x00020006
349CS1WCR_D: .long 0x00232304
350CS2WCR_D: .long 0x7777770F
351CS4WCR_D: .long 0x7777770F
352CS5WCR_D: .long 0x00101006
353CS6WCR_D: .long 0x77777703
354CS5PCR_D: .long 0x77000000
355CS6PCR_D: .long 0x77000000
356
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100357REPEAT0_R3: .long 0x00002000
358REPEAT0_R1: .long 0x0000200