blob: e6a255f0afdb05bd745c2b394a258923826fd7e2 [file] [log] [blame]
wdenk70ae5b42004-10-10 17:05:18 +00001/*
2 * Memory Setup stuff - taken from blob memsetup.S
3 *
4 * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
wdenkcbb52882004-10-10 18:03:33 +00005 * Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
wdenk70ae5b42004-10-10 17:05:18 +00006 *
7 * Modified for the at91rm9200dk board by
8 * (C) Copyright 2004
wdenk20dd2fa2004-11-21 00:06:33 +00009 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
wdenk70ae5b42004-10-10 17:05:18 +000010 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wdenkcbb52882004-10-10 18:03:33 +000021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wdenk70ae5b42004-10-10 17:05:18 +000022 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
29
30#include <config.h>
31#include <version.h>
32
33#ifdef CONFIG_BOOTBINFUNC
34/*
35 * some parameters for the board
36 *
37 * This is based on rm9200dk.cfg for the BDI2000 from ABATRON which in
wdenk20dd2fa2004-11-21 00:06:33 +000038 * turn is based on the boot.bin code from ATMEL
wdenk70ae5b42004-10-10 17:05:18 +000039 *
40 */
41
42/* flash */
43#define MC_PUIA 0xFFFFFF10
44#define MC_PUIA_VAL 0x00000000
45#define MC_PUP 0xFFFFFF50
46#define MC_PUP_VAL 0x00000000
47#define MC_PUER 0xFFFFFF54
48#define MC_PUER_VAL 0x00000000
49#define MC_ASR 0xFFFFFF04
50#define MC_ASR_VAL 0x00000000
51#define MC_AASR 0xFFFFFF08
52#define MC_AASR_VAL 0x00000000
53#define EBI_CFGR 0xFFFFFF64
54#define EBI_CFGR_VAL 0x00000000
55#define SMC2_CSR 0xFFFFFF70
wdenk20dd2fa2004-11-21 00:06:33 +000056#define SMC2_CSR_VAL 0x100032ad /* 16bit, 2 TDF, 4 WS */
wdenk70ae5b42004-10-10 17:05:18 +000057
58/* clocks */
59#define PLLAR 0xFFFFFC28
wdenkac40ade2004-11-24 23:35:19 +000060#define PLLAR_VAL 0x202CBE04 /* 207.360 MHz for PCK */
wdenk70ae5b42004-10-10 17:05:18 +000061#define PLLBR 0xFFFFFC2C
62#define PLLBR_VAL 0x10483E0E /* 48.054857 MHz (divider by 2 for USB) */
63#define MCKR 0xFFFFFC30
wdenkac40ade2004-11-24 23:35:19 +000064#define MCKR_VAL 0x00000202 /* PCK/3 = MCK Master Clock = 69.120MHz from PLLA */
wdenk70ae5b42004-10-10 17:05:18 +000065
66/* sdram */
67#define PIOC_ASR 0xFFFFF870
68#define PIOC_ASR_VAL 0xFFFF0000 /* Configure PIOC as peripheral (D16/D31) */
wdenk4025aab2004-12-13 00:18:44 +000069#define PIOC_BSR 0xFFFFF874
wdenk70ae5b42004-10-10 17:05:18 +000070#define PIOC_BSR_VAL 0x00000000
71#define PIOC_PDR 0xFFFFF804
72#define PIOC_PDR_VAL 0xFFFF0000
73#define EBI_CSA 0xFFFFFF60
74#define EBI_CSA_VAL 0x00000002 /* CS1=SDRAM */
75#define SDRC_CR 0xFFFFFF98
wdenk20dd2fa2004-11-21 00:06:33 +000076#define SDRC_CR_VAL 0x3399c1d4 /* set up the SDRAM */
wdenk70ae5b42004-10-10 17:05:18 +000077#define SDRAM 0x20000000 /* address of the SDRAM */
78#define SDRAM1 0x20000080 /* address of the SDRAM */
79#define SDRAM_VAL 0x00000000 /* value written to SDRAM */
80#define SDRC_MR 0xFFFFFF90
81#define SDRC_MR_VAL 0x00000002 /* Precharge All */
82#define SDRC_MR_VAL1 0x00000004 /* refresh */
83#define SDRC_MR_VAL2 0x00000003 /* Load Mode Register */
84#define SDRC_MR_VAL3 0x00000000 /* Normal Mode */
85#define SDRC_TR 0xFFFFFF94
86#define SDRC_TR_VAL 0x000002E0 /* Write refresh rate */
87
88
wdenk20dd2fa2004-11-21 00:06:33 +000089_MTEXT_BASE:
90#undef START_FROM_MEM
91#ifdef START_FROM_MEM
92 .word TEXT_BASE-PHYS_FLASH_1
93#else
wdenk70ae5b42004-10-10 17:05:18 +000094 .word TEXT_BASE
wdenk20dd2fa2004-11-21 00:06:33 +000095#endif
wdenk70ae5b42004-10-10 17:05:18 +000096
wdenk20dd2fa2004-11-21 00:06:33 +000097.globl lowlevelinit
98lowlevelinit:
wdenk70ae5b42004-10-10 17:05:18 +000099 /* memory control configuration */
wdenkcbb52882004-10-10 18:03:33 +0000100 /* this isn't very elegant, but what the heck */
101 ldr r0, =SMRDATA
wdenk20dd2fa2004-11-21 00:06:33 +0000102 ldr r1, _MTEXT_BASE
wdenk70ae5b42004-10-10 17:05:18 +0000103 sub r0, r0, r1
wdenkcbb52882004-10-10 18:03:33 +0000104 add r2, r0, #80
wdenk70ae5b42004-10-10 17:05:18 +00001050:
106 /* the address */
wdenkcbb52882004-10-10 18:03:33 +0000107 ldr r1, [r0], #4
wdenk70ae5b42004-10-10 17:05:18 +0000108 /* the value */
wdenkcbb52882004-10-10 18:03:33 +0000109 ldr r3, [r0], #4
110 str r3, [r1]
111 cmp r2, r0
112 bne 0b
wdenk70ae5b42004-10-10 17:05:18 +0000113 /* delay - this is all done by guess */
wdenk20dd2fa2004-11-21 00:06:33 +0000114 ldr r0, =0x00010000
wdenk70ae5b42004-10-10 17:05:18 +00001151:
wdenkcbb52882004-10-10 18:03:33 +0000116 subs r0, r0, #1
117 bhi 1b
118 ldr r0, =SMRDATA1
wdenk20dd2fa2004-11-21 00:06:33 +0000119 ldr r1, _MTEXT_BASE
wdenk70ae5b42004-10-10 17:05:18 +0000120 sub r0, r0, r1
wdenkcbb52882004-10-10 18:03:33 +0000121 add r2, r0, #176
wdenk70ae5b42004-10-10 17:05:18 +00001222:
123 /* the address */
wdenkcbb52882004-10-10 18:03:33 +0000124 ldr r1, [r0], #4
wdenk70ae5b42004-10-10 17:05:18 +0000125 /* the value */
wdenkcbb52882004-10-10 18:03:33 +0000126 ldr r3, [r0], #4
127 str r3, [r1]
128 cmp r2, r0
129 bne 2b
wdenk70ae5b42004-10-10 17:05:18 +0000130
131 /* everything is fine now */
132 mov pc, lr
133
134 .ltorg
135
136SMRDATA:
137 .word MC_PUIA
138 .word MC_PUIA_VAL
139 .word MC_PUP
140 .word MC_PUP_VAL
141 .word MC_PUER
142 .word MC_PUER_VAL
143 .word MC_ASR
144 .word MC_ASR_VAL
145 .word MC_AASR
146 .word MC_AASR_VAL
147 .word EBI_CFGR
148 .word EBI_CFGR_VAL
149 .word SMC2_CSR
150 .word SMC2_CSR_VAL
151 .word PLLAR
152 .word PLLAR_VAL
153 .word PLLBR
154 .word PLLBR_VAL
155 .word MCKR
156 .word MCKR_VAL
157 /* SMRDATA is 80 bytes long */
158 /* here there's a delay of 100 */
159SMRDATA1:
160 .word PIOC_ASR
161 .word PIOC_ASR_VAL
162 .word PIOC_BSR
163 .word PIOC_BSR_VAL
164 .word PIOC_PDR
165 .word PIOC_PDR_VAL
166 .word EBI_CSA
167 .word EBI_CSA_VAL
168 .word SDRC_CR
169 .word SDRC_CR_VAL
170 .word SDRC_MR
171 .word SDRC_MR_VAL
172 .word SDRAM
173 .word SDRAM_VAL
174 .word SDRC_MR
175 .word SDRC_MR_VAL1
176 .word SDRAM
177 .word SDRAM_VAL
178 .word SDRAM
179 .word SDRAM_VAL
180 .word SDRAM
181 .word SDRAM_VAL
182 .word SDRAM
183 .word SDRAM_VAL
184 .word SDRAM
185 .word SDRAM_VAL
186 .word SDRAM
187 .word SDRAM_VAL
188 .word SDRAM
189 .word SDRAM_VAL
190 .word SDRAM
191 .word SDRAM_VAL
192 .word SDRC_MR
193 .word SDRC_MR_VAL2
194 .word SDRAM1
195 .word SDRAM_VAL
196 .word SDRC_TR
197 .word SDRC_TR_VAL
198 .word SDRAM
199 .word SDRAM_VAL
200 .word SDRC_MR
201 .word SDRC_MR_VAL3
202 .word SDRAM
203 .word SDRAM_VAL
204 /* SMRDATA1 is 176 bytes long */
205#endif /* CONFIG_BOOTBINFUNC */