blob: e45fbbe9c70f454cf43e267f4673f3e8f9b0d462 [file] [log] [blame]
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +09001/*
2 * Copyright (C) 2008 Renesas Solutions Corp.
3 * Copyright (C) 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
4 * Copyright (C) 2007 Kenati Technologies, Inc.
5 *
6 * board/sh7763rdp/lowlevel_init.S
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +09009 */
10
11#include <config.h>
12#include <version.h>
13
14#include <asm/processor.h>
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010015#include <asm/macro.h>
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090016
17 .global lowlevel_init
18
19 .text
20 .align 2
21
22lowlevel_init:
23
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010024 write32 WDTCSR_A, WDTCSR_D /* Watchdog Control / Status Register */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090025
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010026 write32 WDTST_A, WDTST_D /* Watchdog Stop Time Register */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090027
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010028 write32 WDTBST_A, WDTBST_D /*
29 * 0xFFCC0008
30 * Watchdog Base Stop Time Register
31 */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090032
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010033 write32 CCR_A, CCR_CACHE_ICI_D /* Address of Cache Control Register */
34 /* Instruction Cache Invalidate */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090035
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010036 write32 MMUCR_A, MMU_CONTROL_TI_D /* MMU Control Register */
37 /* TI == TLB Invalidate bit */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090038
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010039 write32 MSTPCR0_A, MSTPCR0_D /* Address of Power Control Register 0 */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090040
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010041 write32 MSTPCR1_A, MSTPCR1_D /* Address of Power Control Register 1 */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090042
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010043 write32 RAMCR_A, RAMCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090044
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010045 mov.l MMSELR_A, r1
46 mov.l MMSELR_D, r0
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090047 synco
48 mov.l r0, @r1
49
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010050 mov.l @r1, r2 /* execute two reads after setting MMSELR */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010051 mov.l @r1, r2
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090052 synco
53
54 /* issue memory read */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +010055 mov.l DDRSD_START_A, r1 /* memory address to read*/
56 mov.l @r1, r0
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090057 synco
58
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010059 write32 MIM8_A, MIM8_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090060
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010061 write32 MIMC_A, MIMC_D1
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090062
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010063 write32 STRC_A, STRC_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090064
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010065 write32 SDR4_A, SDR4_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090066
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010067 write32 MIMC_A, MIMC_D2
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090068
69 nop
70 nop
71 nop
72
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010073 write32 SCR4_A, SCR4_D3
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090074
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010075 write32 SCR4_A, SCR4_D2
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090076
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010077 write32 SDMR02000_A, SDMR02000_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090078
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010079 write32 SDMR00B08_A, SDMR00B08_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090080
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010081 write32 SCR4_A, SCR4_D2
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090082
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010083 write32 SCR4_A, SCR4_D4
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090084
85 nop
86 nop
87 nop
88 nop
89
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010090 write32 SCR4_A, SCR4_D4
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090091
92 nop
93 nop
94 nop
95 nop
96
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010097 write32 SDMR00308_A, SDMR00308_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +090098
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +010099 write32 MIMC_A, MIMC_D3
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900100
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100101 mov.l SCR4_A, r1
102 mov.l SCR4_D1, r0
103 mov.l DELAY60_D, r3
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900104
105delay_loop_60:
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100106 mov.l r0, @r1
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900107 dt r3
108 bf delay_loop_60
109 nop
110
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100111 write32 CCR_A, CCR_CACHE_D_2 /* Address of Cache Control Register */
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900112
113bsc_init:
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100114 write32 BCR_A, BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900115
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100116 write32 CS0BCR_A, CS0BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900117
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100118 write32 CS1BCR_A, CS1BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900119
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100120 write32 CS2BCR_A, CS2BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900121
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100122 write32 CS4BCR_A, CS4BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900123
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100124 write32 CS5BCR_A, CS5BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900125
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100126 write32 CS6BCR_A, CS6BCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900127
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100128 write32 CS0WCR_A, CS0WCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900129
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100130 write32 CS1WCR_A, CS1WCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900131
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100132 write32 CS2WCR_A, CS2WCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900133
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100134 write32 CS4WCR_A, CS4WCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900135
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100136 write32 CS5WCR_A, CS5WCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900137
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100138 write32 CS6WCR_A, CS6WCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900139
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100140 write32 CS5PCR_A, CS5PCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900141
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100142 write32 CS6PCR_A, CS6PCR_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900143
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100144 mov.l DELAY200_D, r3
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900145
146delay_loop_200:
147 dt r3
148 bf delay_loop_200
149 nop
150
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100151 write16 PSEL0_A, PSEL0_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900152
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100153 write16 PSEL1_A, PSEL1_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900154
Jean-Christophe PLAGNIOL-VILLARDf7e78f32008-12-20 19:29:49 +0100155 write32 ICR0_A, ICR0_D
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900156
157 stc sr, r0 /* BL bit off(init=ON) */
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100158 mov.l SR_MASK_D, r1
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900159 and r1, r0
160 ldc r0, sr
161
162 rts
163 nop
164
165 .align 2
166
167DELAY60_D: .long 60
168DELAY200_D: .long 17800
169
170CCR_A: .long 0xFF00001C
171MMUCR_A: .long 0xFF000010
172RAMCR_A: .long 0xFF000074
173
174/* Low power mode control */
175MSTPCR0_A: .long 0xFFC80030
176MSTPCR1_A: .long 0xFFC80038
177
178/* RWBT */
179WDTST_A: .long 0xFFCC0000
180WDTCSR_A: .long 0xFFCC0004
181WDTBST_A: .long 0xFFCC0008
182
183/* BSC */
184MMSELR_A: .long 0xFE600020
185BCR_A: .long 0xFF801000
186CS0BCR_A: .long 0xFF802000
187CS1BCR_A: .long 0xFF802010
188CS2BCR_A: .long 0xFF802020
189CS4BCR_A: .long 0xFF802040
190CS5BCR_A: .long 0xFF802050
191CS6BCR_A: .long 0xFF802060
192CS0WCR_A: .long 0xFF802008
193CS1WCR_A: .long 0xFF802018
194CS2WCR_A: .long 0xFF802028
195CS4WCR_A: .long 0xFF802048
196CS5WCR_A: .long 0xFF802058
197CS6WCR_A: .long 0xFF802068
198CS5PCR_A: .long 0xFF802070
199CS6PCR_A: .long 0xFF802080
200DDRSD_START_A: .long 0xAC000000
201
202/* INTC */
203ICR0_A: .long 0xFFD00000
204
205/* DDR I/F */
206MIM8_A: .long 0xFE800008
207MIMC_A: .long 0xFE80000C
208SCR4_A: .long 0xFE800014
209STRC_A: .long 0xFE80001C
210SDR4_A: .long 0xFE800034
211SDMR00308_A: .long 0xFE900308
212SDMR00B08_A: .long 0xFE900B08
213SDMR02000_A: .long 0xFE902000
214
215/* GPIO */
216PSEL0_A: .long 0xFFEF0070
217PSEL1_A: .long 0xFFEF0072
218
219CCR_CACHE_ICI_D:.long 0x00000800
220CCR_CACHE_D_2: .long 0x00000103
221MMU_CONTROL_TI_D:.long 0x00000004
222RAMCR_D: .long 0x00000200
223MSTPCR0_D: .long 0x00000000
224MSTPCR1_D: .long 0x00000000
225
226MMSELR_D: .long 0xa5a50000
227BCR_D: .long 0x00000000
228CS0BCR_D: .long 0x77777770
229CS1BCR_D: .long 0x77777670
230CS2BCR_D: .long 0x77777670
231CS4BCR_D: .long 0x77777670
232CS5BCR_D: .long 0x77777670
233CS6BCR_D: .long 0x77777670
234CS0WCR_D: .long 0x7777770F
Jean-Christophe PLAGNIOL-VILLARDe4430772008-12-20 19:29:48 +0100235CS1WCR_D: .long 0x22000002
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900236CS2WCR_D: .long 0x7777770F
237CS4WCR_D: .long 0x7777770F
238CS5WCR_D: .long 0x7777770F
239CS6WCR_D: .long 0x7777770F
240CS5PCR_D: .long 0x77000000
241CS6PCR_D: .long 0x77000000
242ICR0_D: .long 0x00E00000
243MIM8_D: .long 0x00000000
244MIMC_D1: .long 0x01d10008
245MIMC_D2: .long 0x01d10009
246MIMC_D3: .long 0x01d10209
247SCR4_D1: .long 0x00000001
248SCR4_D2: .long 0x00000002
249SCR4_D3: .long 0x00000003
250SCR4_D4: .long 0x00000004
251STRC_D: .long 0x000f3980
252SDR4_D: .long 0x00000300
253SDMR00308_D: .long 0x00000000
254SDMR00B08_D: .long 0x00000000
255SDMR02000_D: .long 0x00000000
Nobuhiro Iwamatsu31067322010-07-22 15:29:10 +0900256PSEL0_D: .word 0x00000001
257PSEL1_D: .word 0x00000244
Nobuhiro Iwamatsu7faddae2008-06-09 13:39:57 +0900258SR_MASK_D: .long 0xEFFFFF0F
259WDTST_D: .long 0x5A000FFF
260WDTCSR_D: .long 0xA5000000
261WDTBST_D: .long 0x55000000