1*83d290c5STom Rini/* SPDX-License-Identifier: GPL-2.0+ */
2320cf350SYoshihiro Shimoda/*
3320cf350SYoshihiro Shimoda * Copyright (C) 2013  Renesas Solutions Corp.
4320cf350SYoshihiro Shimoda */
5320cf350SYoshihiro Shimoda
6320cf350SYoshihiro Shimoda#include <config.h>
7320cf350SYoshihiro Shimoda#include <asm/processor.h>
8320cf350SYoshihiro Shimoda#include <asm/macro.h>
9320cf350SYoshihiro Shimoda
10320cf350SYoshihiro Shimoda.macro	or32, addr, data
11320cf350SYoshihiro Shimoda	mov.l \addr, r1
12320cf350SYoshihiro Shimoda	mov.l \data, r0
13320cf350SYoshihiro Shimoda	mov.l @r1, r2
14320cf350SYoshihiro Shimoda	or    r2, r0
15320cf350SYoshihiro Shimoda	mov.l r0, @r1
16320cf350SYoshihiro Shimoda.endm
17320cf350SYoshihiro Shimoda
18320cf350SYoshihiro Shimoda.macro	wait_DBCMD
19320cf350SYoshihiro Shimoda	mov.l	DBWAIT_A, r0
20320cf350SYoshihiro Shimoda	mov.l	@r0, r1
21320cf350SYoshihiro Shimoda.endm
22320cf350SYoshihiro Shimoda
23320cf350SYoshihiro Shimoda	.global lowlevel_init
24320cf350SYoshihiro Shimoda	.section	.spiboot1.text
25320cf350SYoshihiro Shimoda	.align  2
26320cf350SYoshihiro Shimoda
27320cf350SYoshihiro Shimodalowlevel_init:
28320cf350SYoshihiro Shimoda	mov	#0, r14
29320cf350SYoshihiro Shimoda	mova	2f, r0
30320cf350SYoshihiro Shimoda	mov.l	PC_MASK, r1
31320cf350SYoshihiro Shimoda	tst	r0, r1
32320cf350SYoshihiro Shimoda	bf	2f
33320cf350SYoshihiro Shimoda
34320cf350SYoshihiro Shimoda	bra	exit_pmb
35320cf350SYoshihiro Shimoda	nop
36320cf350SYoshihiro Shimoda
37320cf350SYoshihiro Shimoda	.align	2
38320cf350SYoshihiro Shimoda
39320cf350SYoshihiro Shimoda/* If CPU runs on SDRAM (PC=0x5???????) or not. */
40320cf350SYoshihiro ShimodaPC_MASK:	.long	0x20000000
41320cf350SYoshihiro Shimoda
42320cf350SYoshihiro Shimoda2:
43320cf350SYoshihiro Shimoda	mov	#1, r14
44320cf350SYoshihiro Shimoda
45320cf350SYoshihiro Shimoda	mov.l	EXPEVT_A, r0
46320cf350SYoshihiro Shimoda	mov.l	@r0, r0
47320cf350SYoshihiro Shimoda	mov.l	EXPEVT_POWER_ON_RESET, r1
48320cf350SYoshihiro Shimoda	cmp/eq	r0, r1
49320cf350SYoshihiro Shimoda	bt	1f
50320cf350SYoshihiro Shimoda
51320cf350SYoshihiro Shimoda	/*
52320cf350SYoshihiro Shimoda	 * If EXPEVT value is manual reset or tlb multipul-hit,
53320cf350SYoshihiro Shimoda	 * initialization of DBSC3 is not necessary.
54320cf350SYoshihiro Shimoda	 */
55320cf350SYoshihiro Shimoda	bra	exit_ddr
56320cf350SYoshihiro Shimoda	nop
57320cf350SYoshihiro Shimoda
58320cf350SYoshihiro Shimoda1:
59320cf350SYoshihiro Shimoda	/*------- Reset -------*/
60320cf350SYoshihiro Shimoda	write32 MRSTCR0_A, MRSTCR0_D
61320cf350SYoshihiro Shimoda	write32 MRSTCR1_A, MRSTCR1_D
62320cf350SYoshihiro Shimoda
63320cf350SYoshihiro Shimoda	/* For Core Reset */
64320cf350SYoshihiro Shimoda	mov.l	DBACEN_A, r0
65320cf350SYoshihiro Shimoda	mov.l	@r0, r0
66320cf350SYoshihiro Shimoda	cmp/eq	#0, r0
67320cf350SYoshihiro Shimoda	bt	3f
68320cf350SYoshihiro Shimoda
69320cf350SYoshihiro Shimoda	/*
70320cf350SYoshihiro Shimoda	 * If DBACEN == 1(DBSC was already enabled), we have to avoid the
71320cf350SYoshihiro Shimoda	 * initialization of DDR3-SDRAM.
72320cf350SYoshihiro Shimoda	 */
73320cf350SYoshihiro Shimoda	bra	exit_ddr
74320cf350SYoshihiro Shimoda	nop
75320cf350SYoshihiro Shimoda
76320cf350SYoshihiro Shimoda3:
77320cf350SYoshihiro Shimoda	/*------- DBSC3 -------*/
78320cf350SYoshihiro Shimoda	/* oscillation stabilization time */
79320cf350SYoshihiro Shimoda	wait_timer	WAIT_OSC_TIME
80320cf350SYoshihiro Shimoda
81320cf350SYoshihiro Shimoda	/* step 3 */
82320cf350SYoshihiro Shimoda	write32 DBKIND_A, DBKIND_D
83320cf350SYoshihiro Shimoda
84320cf350SYoshihiro Shimoda	/* step 4 */
85320cf350SYoshihiro Shimoda	write32 DBCONF_A, DBCONF_D
86320cf350SYoshihiro Shimoda	write32 DBTR0_A, DBTR0_D
87320cf350SYoshihiro Shimoda	write32 DBTR1_A, DBTR1_D
88320cf350SYoshihiro Shimoda	write32 DBTR2_A, DBTR2_D
89320cf350SYoshihiro Shimoda	write32 DBTR3_A, DBTR3_D
90320cf350SYoshihiro Shimoda	write32 DBTR4_A, DBTR4_D
91320cf350SYoshihiro Shimoda	write32 DBTR5_A, DBTR5_D
92320cf350SYoshihiro Shimoda	write32 DBTR6_A, DBTR6_D
93320cf350SYoshihiro Shimoda	write32 DBTR7_A, DBTR7_D
94320cf350SYoshihiro Shimoda	write32 DBTR8_A, DBTR8_D
95320cf350SYoshihiro Shimoda	write32 DBTR9_A, DBTR9_D
96320cf350SYoshihiro Shimoda	write32 DBTR10_A, DBTR10_D
97320cf350SYoshihiro Shimoda	write32 DBTR11_A, DBTR11_D
98320cf350SYoshihiro Shimoda	write32 DBTR12_A, DBTR12_D
99320cf350SYoshihiro Shimoda	write32 DBTR13_A, DBTR13_D
100320cf350SYoshihiro Shimoda	write32 DBTR14_A, DBTR14_D
101320cf350SYoshihiro Shimoda	write32 DBTR15_A, DBTR15_D
102320cf350SYoshihiro Shimoda	write32 DBTR16_A, DBTR16_D
103320cf350SYoshihiro Shimoda	write32 DBTR17_A, DBTR17_D
104320cf350SYoshihiro Shimoda	write32 DBTR18_A, DBTR18_D
105320cf350SYoshihiro Shimoda	write32 DBTR19_A, DBTR19_D
106320cf350SYoshihiro Shimoda	write32 DBRNK0_A, DBRNK0_D
107320cf350SYoshihiro Shimoda	write32 DBADJ0_A, DBADJ0_D
108320cf350SYoshihiro Shimoda	write32 DBADJ2_A, DBADJ2_D
109320cf350SYoshihiro Shimoda
110320cf350SYoshihiro Shimoda	/* step 5 */
111320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_RSTL_VAL
112320cf350SYoshihiro Shimoda	wait_timer	WAIT_30US
113320cf350SYoshihiro Shimoda
114320cf350SYoshihiro Shimoda	/* step 6 */
115320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_PDEN_VAL
116320cf350SYoshihiro Shimoda
117320cf350SYoshihiro Shimoda	/* step 7 */
118320cf350SYoshihiro Shimoda	write32 DBPDCNT3_A, DBPDCNT3_D
119320cf350SYoshihiro Shimoda
120320cf350SYoshihiro Shimoda	/* step 8 */
121320cf350SYoshihiro Shimoda	write32 DBPDCNT1_A, DBPDCNT1_D
122320cf350SYoshihiro Shimoda	write32 DBPDCNT2_A, DBPDCNT2_D
123320cf350SYoshihiro Shimoda	write32 DBPDLCK_A, DBPDLCK_D
124320cf350SYoshihiro Shimoda	write32 DBPDRGA_A, DBPDRGA_D
125320cf350SYoshihiro Shimoda	write32 DBPDRGD_A, DBPDRGD_D
126320cf350SYoshihiro Shimoda
127320cf350SYoshihiro Shimoda	/* step 9 */
128320cf350SYoshihiro Shimoda	wait_timer	WAIT_30US
129320cf350SYoshihiro Shimoda
130320cf350SYoshihiro Shimoda	/* step 10 */
131320cf350SYoshihiro Shimoda	write32 DBPDCNT0_A, DBPDCNT0_D
132320cf350SYoshihiro Shimoda
133320cf350SYoshihiro Shimoda	/* step 11 */
134320cf350SYoshihiro Shimoda	wait_timer	WAIT_30US
135320cf350SYoshihiro Shimoda	wait_timer	WAIT_30US
136320cf350SYoshihiro Shimoda
137320cf350SYoshihiro Shimoda	/* step 12 */
138320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_WAIT_VAL
139320cf350SYoshihiro Shimoda	wait_DBCMD
140320cf350SYoshihiro Shimoda
141320cf350SYoshihiro Shimoda	/* step 13 */
142320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_RSTH_VAL
143320cf350SYoshihiro Shimoda	wait_DBCMD
144320cf350SYoshihiro Shimoda
145320cf350SYoshihiro Shimoda	/* step 14 */
146320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_WAIT_VAL
147320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_WAIT_VAL
148320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_WAIT_VAL
149320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_WAIT_VAL
150320cf350SYoshihiro Shimoda
151320cf350SYoshihiro Shimoda	/* step 15 */
152320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_PDXT_VAL
153320cf350SYoshihiro Shimoda
154320cf350SYoshihiro Shimoda	/* step 16 */
155320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_MRS2_VAL
156320cf350SYoshihiro Shimoda
157320cf350SYoshihiro Shimoda	/* step 17 */
158320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_MRS3_VAL
159320cf350SYoshihiro Shimoda
160320cf350SYoshihiro Shimoda	/* step 18 */
161320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_MRS1_VAL
162320cf350SYoshihiro Shimoda
163320cf350SYoshihiro Shimoda	/* step 19 */
164320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_MRS0_VAL
165320cf350SYoshihiro Shimoda	write32 DBPDNCNF_A, DBPDNCNF_D
166320cf350SYoshihiro Shimoda
167320cf350SYoshihiro Shimoda	/* step 20 */
168320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_ZQCL_VAL
169320cf350SYoshihiro Shimoda
170320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_REF_VAL
171320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_REF_VAL
172320cf350SYoshihiro Shimoda	wait_DBCMD
173320cf350SYoshihiro Shimoda
174320cf350SYoshihiro Shimoda	/* step 21 */
175320cf350SYoshihiro Shimoda	write32	DBCALTR_A, DBCALTR_D
176320cf350SYoshihiro Shimoda
177320cf350SYoshihiro Shimoda	/* step 22 */
178320cf350SYoshihiro Shimoda	write32 DBRFCNF0_A, DBRFCNF0_D
179320cf350SYoshihiro Shimoda	write32 DBRFCNF1_A, DBRFCNF1_D
180320cf350SYoshihiro Shimoda	write32 DBRFCNF2_A, DBRFCNF2_D
181320cf350SYoshihiro Shimoda
182320cf350SYoshihiro Shimoda	/* step 23 */
183320cf350SYoshihiro Shimoda	write32 DBCALCNF_A, DBCALCNF_D
184320cf350SYoshihiro Shimoda
185320cf350SYoshihiro Shimoda	/* step 24 */
186320cf350SYoshihiro Shimoda	write32 DBRFEN_A, DBRFEN_D
187320cf350SYoshihiro Shimoda	write32 DBCMD_A, DBCMD_SRXT_VAL
188320cf350SYoshihiro Shimoda
189320cf350SYoshihiro Shimoda	/* step 25 */
190320cf350SYoshihiro Shimoda	write32 DBACEN_A, DBACEN_D
191320cf350SYoshihiro Shimoda
192320cf350SYoshihiro Shimoda	/* step 26 */
193320cf350SYoshihiro Shimoda	wait_DBCMD
194320cf350SYoshihiro Shimoda
195320cf350SYoshihiro Shimoda	bra	exit_ddr
196320cf350SYoshihiro Shimoda	nop
197320cf350SYoshihiro Shimoda
198320cf350SYoshihiro Shimoda	.align 2
199320cf350SYoshihiro Shimoda
200320cf350SYoshihiro ShimodaEXPEVT_A:		.long	0xff000024
201320cf350SYoshihiro ShimodaEXPEVT_POWER_ON_RESET:	.long	0x00000000
202320cf350SYoshihiro Shimoda
203320cf350SYoshihiro Shimoda/*------- Reset -------*/
204320cf350SYoshihiro ShimodaMRSTCR0_A:	.long	0xffd50030
205320cf350SYoshihiro ShimodaMRSTCR0_D:	.long	0xfe1ffe7f
206320cf350SYoshihiro ShimodaMRSTCR1_A:	.long	0xffd50034
207320cf350SYoshihiro ShimodaMRSTCR1_D:	.long	0xfff3ffff
208320cf350SYoshihiro Shimoda
209320cf350SYoshihiro Shimoda/*------- DBSC3 -------*/
210320cf350SYoshihiro ShimodaDBCMD_A:	.long	0xfe800018
211320cf350SYoshihiro ShimodaDBKIND_A:	.long	0xfe800020
212320cf350SYoshihiro ShimodaDBCONF_A:	.long	0xfe800024
213320cf350SYoshihiro ShimodaDBTR0_A:	.long	0xfe800040
214320cf350SYoshihiro ShimodaDBTR1_A:	.long	0xfe800044
215320cf350SYoshihiro ShimodaDBTR2_A:	.long	0xfe800048
216320cf350SYoshihiro ShimodaDBTR3_A:	.long	0xfe800050
217320cf350SYoshihiro ShimodaDBTR4_A:	.long	0xfe800054
218320cf350SYoshihiro ShimodaDBTR5_A:	.long	0xfe800058
219320cf350SYoshihiro ShimodaDBTR6_A:	.long	0xfe80005c
220320cf350SYoshihiro ShimodaDBTR7_A:	.long	0xfe800060
221320cf350SYoshihiro ShimodaDBTR8_A:	.long	0xfe800064
222320cf350SYoshihiro ShimodaDBTR9_A:	.long	0xfe800068
223320cf350SYoshihiro ShimodaDBTR10_A:	.long	0xfe80006c
224320cf350SYoshihiro ShimodaDBTR11_A:	.long	0xfe800070
225320cf350SYoshihiro ShimodaDBTR12_A:	.long	0xfe800074
226320cf350SYoshihiro ShimodaDBTR13_A:	.long	0xfe800078
227320cf350SYoshihiro ShimodaDBTR14_A:	.long	0xfe80007c
228320cf350SYoshihiro ShimodaDBTR15_A:	.long	0xfe800080
229320cf350SYoshihiro ShimodaDBTR16_A:	.long	0xfe800084
230320cf350SYoshihiro ShimodaDBTR17_A:	.long	0xfe800088
231320cf350SYoshihiro ShimodaDBTR18_A:	.long	0xfe80008c
232320cf350SYoshihiro ShimodaDBTR19_A:	.long	0xfe800090
233320cf350SYoshihiro ShimodaDBRNK0_A:	.long	0xfe800100
234320cf350SYoshihiro ShimodaDBPDCNT0_A:	.long	0xfe800200
235320cf350SYoshihiro ShimodaDBPDCNT1_A:	.long	0xfe800204
236320cf350SYoshihiro ShimodaDBPDCNT2_A:	.long	0xfe800208
237320cf350SYoshihiro ShimodaDBPDCNT3_A:	.long	0xfe80020c
238320cf350SYoshihiro ShimodaDBPDLCK_A:	.long	0xfe800280
239320cf350SYoshihiro ShimodaDBPDRGA_A:	.long	0xfe800290
240320cf350SYoshihiro ShimodaDBPDRGD_A:	.long	0xfe8002a0
241320cf350SYoshihiro ShimodaDBADJ0_A:	.long	0xfe8000c0
242320cf350SYoshihiro ShimodaDBADJ2_A:	.long	0xfe8000c8
243320cf350SYoshihiro ShimodaDBRFCNF0_A:	.long	0xfe8000e0
244320cf350SYoshihiro ShimodaDBRFCNF1_A:	.long	0xfe8000e4
245320cf350SYoshihiro ShimodaDBRFCNF2_A:	.long	0xfe8000e8
246320cf350SYoshihiro ShimodaDBCALCNF_A:	.long	0xfe8000f4
247320cf350SYoshihiro ShimodaDBRFEN_A:	.long	0xfe800014
248320cf350SYoshihiro ShimodaDBACEN_A:	.long	0xfe800010
249320cf350SYoshihiro ShimodaDBWAIT_A:	.long	0xfe80001c
250320cf350SYoshihiro ShimodaDBCALTR_A:	.long	0xfe8000f8
251320cf350SYoshihiro ShimodaDBPDNCNF_A:	.long	0xfe800180
252320cf350SYoshihiro Shimoda
253320cf350SYoshihiro ShimodaWAIT_OSC_TIME:	.long	6000
254320cf350SYoshihiro ShimodaWAIT_30US:	.long	13333
255320cf350SYoshihiro Shimoda
256320cf350SYoshihiro ShimodaDBCMD_RSTL_VAL:	.long	0x20000000
257320cf350SYoshihiro ShimodaDBCMD_PDEN_VAL:	.long	0x1000d73c
258320cf350SYoshihiro ShimodaDBCMD_WAIT_VAL:	.long	0x0000d73c
259320cf350SYoshihiro ShimodaDBCMD_RSTH_VAL:	.long	0x2100d73c
260320cf350SYoshihiro ShimodaDBCMD_PDXT_VAL:	.long	0x110000c8
261320cf350SYoshihiro ShimodaDBCMD_MRS0_VAL:	.long	0x28000930
262320cf350SYoshihiro ShimodaDBCMD_MRS1_VAL:	.long	0x29000004
263320cf350SYoshihiro ShimodaDBCMD_MRS2_VAL:	.long	0x2a000008
264320cf350SYoshihiro ShimodaDBCMD_MRS3_VAL:	.long	0x2b000000
265320cf350SYoshihiro ShimodaDBCMD_ZQCL_VAL:	.long	0x03000200
266320cf350SYoshihiro ShimodaDBCMD_REF_VAL:	.long	0x0c000000
267320cf350SYoshihiro ShimodaDBCMD_SRXT_VAL:	.long	0x19000000
268320cf350SYoshihiro ShimodaDBKIND_D:	.long	0x00000007
269320cf350SYoshihiro ShimodaDBCONF_D:	.long	0x0f030a01
270320cf350SYoshihiro ShimodaDBTR0_D:	.long	0x00000007
271320cf350SYoshihiro ShimodaDBTR1_D:	.long	0x00000006
272320cf350SYoshihiro ShimodaDBTR2_D:	.long	0x00000000
273320cf350SYoshihiro ShimodaDBTR3_D:	.long	0x00000007
274320cf350SYoshihiro ShimodaDBTR4_D:	.long	0x00070007
275320cf350SYoshihiro ShimodaDBTR5_D:	.long	0x0000001b
276320cf350SYoshihiro ShimodaDBTR6_D:	.long	0x00000014
277320cf350SYoshihiro ShimodaDBTR7_D:	.long	0x00000004
278320cf350SYoshihiro ShimodaDBTR8_D:	.long	0x00000014
279320cf350SYoshihiro ShimodaDBTR9_D:	.long	0x00000004
280320cf350SYoshihiro ShimodaDBTR10_D:	.long	0x00000008
281320cf350SYoshihiro ShimodaDBTR11_D:	.long	0x00000007
282320cf350SYoshihiro ShimodaDBTR12_D:	.long	0x0000000e
283320cf350SYoshihiro ShimodaDBTR13_D:	.long	0x000000a0
284320cf350SYoshihiro ShimodaDBTR14_D:	.long	0x00060006
285320cf350SYoshihiro ShimodaDBTR15_D:	.long	0x00000003
286320cf350SYoshihiro ShimodaDBTR16_D:	.long	0x00160002
287320cf350SYoshihiro ShimodaDBTR17_D:	.long	0x000c0000
288320cf350SYoshihiro ShimodaDBTR18_D:	.long	0x00000200
289320cf350SYoshihiro ShimodaDBTR19_D:	.long	0x00000040
290320cf350SYoshihiro ShimodaDBRNK0_D:	.long	0x00000001
291320cf350SYoshihiro ShimodaDBPDCNT0_D:	.long	0x00000001
292320cf350SYoshihiro ShimodaDBPDCNT1_D:	.long	0x00000001
293320cf350SYoshihiro ShimodaDBPDCNT2_D:	.long	0x00000000
294320cf350SYoshihiro ShimodaDBPDCNT3_D:	.long	0x00004010
295320cf350SYoshihiro ShimodaDBPDLCK_D:	.long	0x0000a55a
296320cf350SYoshihiro ShimodaDBPDRGA_D:	.long	0x00000028
297320cf350SYoshihiro ShimodaDBPDRGD_D:	.long	0x00017100
298320cf350SYoshihiro Shimoda
299320cf350SYoshihiro ShimodaDBADJ0_D:	.long	0x00010000
300320cf350SYoshihiro ShimodaDBADJ2_D:	.long	0x18061806
301320cf350SYoshihiro ShimodaDBRFCNF0_D:	.long	0x000001ff
302320cf350SYoshihiro ShimodaDBRFCNF1_D:	.long	0x00081040
303320cf350SYoshihiro ShimodaDBRFCNF2_D:	.long	0x00000000
304320cf350SYoshihiro ShimodaDBCALCNF_D:	.long	0x0000ffff
305320cf350SYoshihiro ShimodaDBRFEN_D:	.long	0x00000001
306320cf350SYoshihiro ShimodaDBACEN_D:	.long	0x00000001
307320cf350SYoshihiro ShimodaDBCALTR_D:	.long	0x08200820
308320cf350SYoshihiro ShimodaDBPDNCNF_D:	.long	0x00000001
309320cf350SYoshihiro Shimoda
310320cf350SYoshihiro Shimoda	.align 2
311320cf350SYoshihiro Shimodaexit_ddr:
312320cf350SYoshihiro Shimoda#if defined(CONFIG_SH_32BIT)
313320cf350SYoshihiro Shimoda	/*------- set PMB -------*/
314320cf350SYoshihiro Shimoda	write32	PASCR_A,	PASCR_29BIT_D
315320cf350SYoshihiro Shimoda	write32	MMUCR_A,	MMUCR_D
316320cf350SYoshihiro Shimoda
317320cf350SYoshihiro Shimoda	/*****************************************************************
318320cf350SYoshihiro Shimoda	 * ent	virt		phys		v	sz	c	wt
319320cf350SYoshihiro Shimoda	 * 0	0xa0000000	0x00000000	1	128M	0	1
320320cf350SYoshihiro Shimoda	 * 1	0xa8000000	0x48000000	1	128M	0	1
321320cf350SYoshihiro Shimoda	 * 5	0x88000000	0x48000000	1	128M	1	1
322320cf350SYoshihiro Shimoda	 */
323320cf350SYoshihiro Shimoda	write32	PMB_ADDR_SPIBOOT_A,	PMB_ADDR_SPIBOOT_D
324320cf350SYoshihiro Shimoda	write32	PMB_DATA_SPIBOOT_A,	PMB_DATA_SPIBOOT_D
325320cf350SYoshihiro Shimoda	write32	PMB_ADDR_DDR_C1_A,	PMB_ADDR_DDR_C1_D
326320cf350SYoshihiro Shimoda	write32	PMB_DATA_DDR_C1_A,	PMB_DATA_DDR_C1_D
327320cf350SYoshihiro Shimoda	write32	PMB_ADDR_DDR_N1_A,	PMB_ADDR_DDR_N1_D
328320cf350SYoshihiro Shimoda	write32	PMB_DATA_DDR_N1_A,	PMB_DATA_DDR_N1_D
329320cf350SYoshihiro Shimoda
330320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY2,	PMB_ADDR_NOT_USE_D
331320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY3,	PMB_ADDR_NOT_USE_D
332320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY4,	PMB_ADDR_NOT_USE_D
333320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY6,	PMB_ADDR_NOT_USE_D
334320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY7,	PMB_ADDR_NOT_USE_D
335320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY8,	PMB_ADDR_NOT_USE_D
336320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY9,	PMB_ADDR_NOT_USE_D
337320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY10,	PMB_ADDR_NOT_USE_D
338320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY11,	PMB_ADDR_NOT_USE_D
339320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY12,	PMB_ADDR_NOT_USE_D
340320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY13,	PMB_ADDR_NOT_USE_D
341320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY14,	PMB_ADDR_NOT_USE_D
342320cf350SYoshihiro Shimoda	write32	PMB_ADDR_ENTRY15,	PMB_ADDR_NOT_USE_D
343320cf350SYoshihiro Shimoda
344320cf350SYoshihiro Shimoda	write32	PASCR_A,	PASCR_INIT
345320cf350SYoshihiro Shimoda	mov.l	DUMMY_ADDR, r0
346320cf350SYoshihiro Shimoda	icbi	@r0
347320cf350SYoshihiro Shimoda#endif	/* if defined(CONFIG_SH_32BIT) */
348320cf350SYoshihiro Shimoda
349320cf350SYoshihiro Shimodaexit_pmb:
350320cf350SYoshihiro Shimoda	/* CPU is running on ILRAM? */
351320cf350SYoshihiro Shimoda	mov	r14, r0
352320cf350SYoshihiro Shimoda	tst	#1, r0
353320cf350SYoshihiro Shimoda	bt	1f
354320cf350SYoshihiro Shimoda
355320cf350SYoshihiro Shimoda	mov.l	_stack_ilram, r15
356320cf350SYoshihiro Shimoda	mov.l	_spiboot_main, r0
357320cf350SYoshihiro Shimoda100:	bsrf	r0
358320cf350SYoshihiro Shimoda	nop
359320cf350SYoshihiro Shimoda
360320cf350SYoshihiro Shimoda	.align	2
361320cf350SYoshihiro Shimoda_spiboot_main:	.long	(spiboot_main - (100b + 4))
362320cf350SYoshihiro Shimoda_stack_ilram:	.long	0xe5204000
363320cf350SYoshihiro Shimoda
364320cf350SYoshihiro Shimoda1:
365320cf350SYoshihiro Shimoda	write32	CCR_A,	CCR_D
366320cf350SYoshihiro Shimoda
367320cf350SYoshihiro Shimoda	rts
368320cf350SYoshihiro Shimoda	 nop
369320cf350SYoshihiro Shimoda
370320cf350SYoshihiro Shimoda	.align 2
371320cf350SYoshihiro Shimoda
372320cf350SYoshihiro Shimoda#if defined(CONFIG_SH_32BIT)
373320cf350SYoshihiro Shimoda/*------- set PMB -------*/
374320cf350SYoshihiro ShimodaPMB_ADDR_SPIBOOT_A:	.long	PMB_ADDR_BASE(0)
375320cf350SYoshihiro ShimodaPMB_ADDR_DDR_N1_A:	.long	PMB_ADDR_BASE(1)
376320cf350SYoshihiro ShimodaPMB_ADDR_DDR_C1_A:	.long	PMB_ADDR_BASE(5)
377320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY2:	.long	PMB_ADDR_BASE(2)
378320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY3:	.long	PMB_ADDR_BASE(3)
379320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY4:	.long	PMB_ADDR_BASE(4)
380320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY6:	.long	PMB_ADDR_BASE(6)
381320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY7:	.long	PMB_ADDR_BASE(7)
382320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY8:	.long	PMB_ADDR_BASE(8)
383320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY9:	.long	PMB_ADDR_BASE(9)
384320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY10:	.long	PMB_ADDR_BASE(10)
385320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY11:	.long	PMB_ADDR_BASE(11)
386320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY12:	.long	PMB_ADDR_BASE(12)
387320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY13:	.long	PMB_ADDR_BASE(13)
388320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY14:	.long	PMB_ADDR_BASE(14)
389320cf350SYoshihiro ShimodaPMB_ADDR_ENTRY15:	.long	PMB_ADDR_BASE(15)
390320cf350SYoshihiro Shimoda
391320cf350SYoshihiro ShimodaPMB_ADDR_SPIBOOT_D:	.long	mk_pmb_addr_val(0xa0)
392320cf350SYoshihiro ShimodaPMB_ADDR_DDR_C1_D:	.long	mk_pmb_addr_val(0x88)
393320cf350SYoshihiro ShimodaPMB_ADDR_DDR_N1_D:	.long	mk_pmb_addr_val(0xa8)
394320cf350SYoshihiro ShimodaPMB_ADDR_NOT_USE_D:	.long	0x00000000
395320cf350SYoshihiro Shimoda
396320cf350SYoshihiro ShimodaPMB_DATA_SPIBOOT_A:	.long	PMB_DATA_BASE(0)
397320cf350SYoshihiro ShimodaPMB_DATA_DDR_N1_A:	.long	PMB_DATA_BASE(1)
398320cf350SYoshihiro ShimodaPMB_DATA_DDR_C1_A:	.long	PMB_DATA_BASE(5)
399320cf350SYoshihiro Shimoda
400320cf350SYoshihiro Shimoda/*						ppn   ub v s1 s0  c  wt */
401320cf350SYoshihiro ShimodaPMB_DATA_SPIBOOT_D:	.long	mk_pmb_data_val(0x00, 0, 1, 1, 0, 0, 1)
402320cf350SYoshihiro ShimodaPMB_DATA_DDR_C1_D:	.long	mk_pmb_data_val(0x48, 0, 1, 1, 0, 1, 1)
403320cf350SYoshihiro ShimodaPMB_DATA_DDR_N1_D:	.long	mk_pmb_data_val(0x48, 1, 1, 1, 0, 0, 1)
404320cf350SYoshihiro Shimoda
405320cf350SYoshihiro ShimodaPASCR_A:		.long	0xff000070
406320cf350SYoshihiro ShimodaDUMMY_ADDR:		.long	0xa0000000
407320cf350SYoshihiro ShimodaPASCR_29BIT_D:		.long	0x00000000
408320cf350SYoshihiro ShimodaPASCR_INIT:		.long	0x80000080
409320cf350SYoshihiro ShimodaMMUCR_A:		.long	0xff000010
410320cf350SYoshihiro ShimodaMMUCR_D:		.long	0x00000004	/* clear ITLB */
411320cf350SYoshihiro Shimoda#endif	/* CONFIG_SH_32BIT */
412320cf350SYoshihiro Shimoda
413320cf350SYoshihiro ShimodaCCR_A:		.long	CCR
414320cf350SYoshihiro ShimodaCCR_D:		.long	CCR_CACHE_INIT
415