blob: 1cb57e72eca430e6b1ed48886505e7650319e454 [file] [log] [blame]
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +09001/*
2 * Copyright (C) 2007
3 * Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Wolfgang Denk0a5c2142007-12-27 01:52:50 +01004 *
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +09005 * Copyright (C) 2007
6 * Kenati Technologies, Inc.
7 *
8 * board/ms7722se/lowlevel_init.S
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <config.h>
27#include <version.h>
28
29#include <asm/processor.h>
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010030#include <asm/macro.h>
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090031
32/*
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010033 * Board specific low level init code, called _very_ early in the
34 * startup sequence. Relocation to SDRAM has not happened yet, no
35 * stack is available, bss section has not been initialised, etc.
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090036 *
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +010037 * (Note: As no stack is available, no subroutines can be called...).
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090038 */
39
40 .global lowlevel_init
41
42 .text
43 .align 2
44
45lowlevel_init:
46
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010047 /*
48 * Cache Control Register
49 * Instruction Cache Invalidate
50 */
51 write32 CCR_A, CCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090052
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010053 /*
54 * Address of MMU Control Register
55 * TI == TLB Invalidate bit
56 */
57 write32 MMUCR_A, MMUCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090058
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090059 /* Address of Power Control Register 0 */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010060 write32 MSTPCR0_A, MSTPCR0_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090061
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090062 /* Address of Power Control Register 2 */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010063 write32 MSTPCR2_A, MSTPCR2_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090064
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010065 write16 SBSCR_A, SBSCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090066
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010067 write16 PSCR_A, PSCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090068
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090069 /* 0xA4520004 (Watchdog Control / Status Register) */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010070! write16 RWTCSR_A, RWTCSR_D_1 /* 0xA507 -> timer_STOP/WDT_CLK=max */
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090071
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090072 /* 0xA4520000 (Watchdog Count Register) */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010073 write16 RWTCNT_A, RWTCNT_D /*0x5A00 -> Clear */
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090074
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090075 /* 0xA4520004 (Watchdog Control / Status Register) */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010076 write16 RWTCSR_A, RWTCSR_D_2 /* 0xA504 -> timer_STOP/CLK=500ms */
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090077
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090078 /* 0xA4150000 Frequency control register */
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010079 write32 FRQCR_A, FRQCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090080
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010081 write32 CCR_A, CCR_D_2
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090082
83bsc_init:
84
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010085 write16 PSELA_A, PSELA_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090086
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010087 write16 DRVCR_A, DRVCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090088
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010089 write16 PCCR_A, PCCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090090
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010091 write16 PECR_A, PECR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090092
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010093 write16 PJCR_A, PJCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090094
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010095 write16 PXCR_A, PXCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090096
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010097 write32 CMNCR_A, CMNCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +090098
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +010099 write32 CS0BCR_A, CS0BCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900100
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100101 write32 CS2BCR_A, CS2BCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900102
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100103 write32 CS4BCR_A, CS4BCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900104
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100105 write32 CS5ABCR_A, CS5ABCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900106
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100107 write32 CS5BBCR_A, CS5BBCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900108
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100109 write32 CS6ABCR_A, CS6ABCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900110
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100111 write32 CS0WCR_A, CS0WCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900112
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100113 write32 CS2WCR_A, CS2WCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900114
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100115 write32 CS4WCR_A, CS4WCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900116
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100117 write32 CS5AWCR_A, CS5AWCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900118
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100119 write32 CS5BWCR_A, CS5BWCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900120
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100121 write32 CS6AWCR_A, CS6AWCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900122
123 ! SDRAM initialization
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100124 write32 SDCR_A, SDCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900125
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100126 write32 SDWCR_A, SDWCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900127
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100128 write32 SDPCR_A, SDPCR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900129
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100130 write32 RTCOR_A, RTCOR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900131
Jean-Christophe PLAGNIOL-VILLARDb9c21722008-12-20 19:29:49 +0100132 write32 RTCSR_A, RTCSR_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900133
Nobuhiro Iwamatsufcbff802009-01-11 17:48:56 +0900134 write8 SDMR3_A, SDMR3_D
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900135
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100136 ! BL bit off (init = ON) (?!?)
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900137
138 stc sr, r0 ! BL bit off(init=ON)
139 mov.l SR_MASK_D, r1
140 and r1, r0
141 ldc r0, sr
142
143 rts
144 mov #0, r0
145
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900146 .align 2
147
Wolfgang Denk0a5c2142007-12-27 01:52:50 +0100148CCR_A: .long CCR
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900149MMUCR_A: .long MMUCR
150MSTPCR0_A: .long MSTPCR0
151MSTPCR2_A: .long MSTPCR2
152SBSCR_A: .long SBSCR
153PSCR_A: .long PSCR
154RWTCSR_A: .long RWTCSR
155RWTCNT_A: .long RWTCNT
156FRQCR_A: .long FRQCR
157
158CCR_D: .long 0x00000800
159CCR_D_2: .long 0x00000103
160MMUCR_D: .long 0x00000004
161MSTPCR0_D: .long 0x00001001
162MSTPCR2_D: .long 0xffffffff
163FRQCR_D: .long 0x07022538
164
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100165PSELA_A: .long 0xa405014E
166PSELA_D: .word 0x0A10
Wolfgang Denk0a5c2142007-12-27 01:52:50 +0100167 .align 2
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900168
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100169DRVCR_A: .long 0xa405018A
170DRVCR_D: .word 0x0554
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900171 .align 2
172
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100173PCCR_A: .long 0xa4050104
174PCCR_D: .word 0x8800
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900175 .align 2
176
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100177PECR_A: .long 0xa4050108
178PECR_D: .word 0x0000
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900179 .align 2
180
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100181PJCR_A: .long 0xa4050110
182PJCR_D: .word 0x1000
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900183 .align 2
184
Jean-Christophe PLAGNIOL-VILLARDbd963702008-12-20 19:29:48 +0100185PXCR_A: .long 0xa4050148
186PXCR_D: .word 0x0AAA
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900187 .align 2
188
189CMNCR_A: .long CMNCR
190CMNCR_D: .long 0x00000013
191CS0BCR_A: .long CS0BCR ! Flash bank 1
192CS0BCR_D: .long 0x24920400
193CS2BCR_A: .long CS2BCR ! SRAM
194CS2BCR_D: .long 0x24920400
195CS4BCR_A: .long CS4BCR ! FPGA, PCMCIA, USB, ext slot
196CS4BCR_D: .long 0x24920400
197CS5ABCR_A: .long CS5ABCR ! Ext slot
198CS5ABCR_D: .long 0x24920400
199CS5BBCR_A: .long CS5BBCR ! USB controller
200CS5BBCR_D: .long 0x24920400
201CS6ABCR_A: .long CS6ABCR ! Ethernet
202CS6ABCR_D: .long 0x24920400
203
204CS0WCR_A: .long CS0WCR
205CS0WCR_D: .long 0x00000300
206CS2WCR_A: .long CS2WCR
207CS2WCR_D: .long 0x00000300
208CS4WCR_A: .long CS4WCR
209CS4WCR_D: .long 0x00000300
210CS5AWCR_A: .long CS5AWCR
211CS5AWCR_D: .long 0x00000300
212CS5BWCR_A: .long CS5BWCR
213CS5BWCR_D: .long 0x00000300
214CS6AWCR_A: .long CS6AWCR
215CS6AWCR_D: .long 0x00000300
216
217SDCR_A: .long SBSC_SDCR
218SDCR_D: .long 0x00020809
219SDWCR_A: .long SBSC_SDWCR
220SDWCR_D: .long 0x00164d0d
221SDPCR_A: .long SBSC_SDPCR
222SDPCR_D: .long 0x00000087
223RTCOR_A: .long SBSC_RTCOR
224RTCOR_D: .long 0xA55A0034
225RTCSR_A: .long SBSC_RTCSR
226RTCSR_D: .long 0xA55A0010
227SDMR3_A: .long 0xFE500180
Nobuhiro Iwamatsufcbff802009-01-11 17:48:56 +0900228SDMR3_D: .long 0x0
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900229
230 .align 1
231
232SBSCR_D: .word 0x0040
233PSCR_D: .word 0x0000
234RWTCSR_D_1: .word 0xA507
235RWTCSR_D_2: .word 0xA507
236RWTCNT_D: .word 0x5A00
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +0900237 .align 2
Nobuhiro Iwamatsudabcc0e2007-09-23 02:31:13 +0900238
239SR_MASK_D: .long 0xEFFFFF0F