blob: 54c2adfaf3b50083814f9279497d1593d78b8b5e [file] [log] [blame]
Markus Klotzbücheraf646e82006-02-07 20:48:45 +01001/*
2 * Most of this taken from Redboot hal_platform_setup.h with cleanup
3 *
4 * NOTE: I haven't clean this up considerably, just enough to get it
5 * running. See hal_platform_setup.h for the source. See
6 * board/cradle/lowlevel_init.S for another PXA250 setup that is
7 * much cleaner.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <config.h>
29#include <version.h>
30#include <asm/arch/pxa-regs.h>
31
32DRAM_SIZE: .long CFG_DRAM_SIZE
33
34/* wait for coprocessor write complete */
35 .macro CPWAIT reg
36 mrc p15,0,\reg,c2,c0,0
37 mov \reg,\reg
38 sub pc,pc,#4
39 .endm
40
41
42/*
43 * Memory setup
44 */
45
46.globl lowlevel_init
47lowlevel_init:
48 /* Set up GPIO pins first ----------------------------------------- */
49 mov r10, lr
50
51 /* GPIO41, 42, 43, 44, 45, 46, 47, 48 */
52 ldr r0, =0x40E10438 @ GPIO41 FFRXD
53 ldr r1, =0x802
54 str r1, [r0]
55
56 ldr r0, =0x40E1043C @ GPIO42 FFTXD
57 ldr r1, =0x802
58 str r1, [r0]
59
60 ldr r0, =0x40E10440 @ GPIO43 FFCTS
61 ldr r1, =0x802
62 str r1, [r0]
63
64 ldr r0, =0x40E10444 @ GPIO 44 FFDCD
65 ldr r1, =0x802
66 str r1, [r0]
67
68 ldr r0, =0x40E10448 @ GPIO 45 FFDSR
69 ldr r1, =0x802
70 str r1, [r0]
71
72 ldr r0, =0x40E1044C @ GPIO 46 FFRI
73 ldr r1, =0x802
74 str r1, [r0]
75
76 ldr r0, =0x40E10450 @ GPIO 47 FFDTR
77 ldr r1, =0x802
78 str r1, [r0]
79
80 ldr r0, =0x40E10454 @ GPIO 48
81 ldr r1, =0x802
82 str r1, [r0]
83
84 /* tebrandt - ASCR, clear the RDH bit */
85 ldr r0, =ASCR
86 ldr r1, [r0]
87 bic r1, r1, #0x80000000
88 str r1, [r0]
89
90 /* ---------------------------------------------------------------- */
91 /* Enable memory interface */
92 /* */
93 /* The sequence below is based on the recommended init steps */
94 /* detailed in the Intel PXA250 Operating Systems Developers Guide, */
95 /* Chapter 10. */
96 /* ---------------------------------------------------------------- */
97
98 /* ---------------------------------------------------------------- */
99 /* Step 1: Wait for at least 200 microsedonds to allow internal */
100 /* clocks to settle. Only necessary after hard reset... */
101 /* FIXME: can be optimized later */
102 /* ---------------------------------------------------------------- */
103
104 ldr r3, =OSCR /* reset the OS Timer Count to zero */
105 mov r2, #0
106 str r2, [r3]
107 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
108 /* so 0x300 should be plenty */
1091:
110 ldr r2, [r3]
111 cmp r4, r2
112 bgt 1b
113
114mem_init:
115
116 /* configure the MEMCLKCFG register */
117 ldr r1, =MEMCLKCFG
118 ldr r2, =0x00010001
119 str r2, [r1] @ WRITE
120 ldr r2, [r1] @ DELAY UNTIL WRITTEN
121
122 /* set CSADRCFG[0] to data flash SRAM mode */
123 ldr r1, =CSADRCFG0
124 ldr r2, =0x00320809
125 str r2, [r1] @ WRITE
126 ldr r2, [r1] @ DELAY UNTIL WRITTEN
127
128 /* set CSADRCFG[1] to data flash SRAM mode */
129 ldr r1, =CSADRCFG1
130 ldr r2, =0x00320809
131 str r2, [r1] @ WRITE
132 ldr r2, [r1] @ DELAY UNTIL WRITTEN
133
134 /* set MSC 0 register for SRAM memory */
135 ldr r1, =MSC0
136 ldr r2, =0x11191119
137 str r2, [r1] @ WRITE
138 ldr r2, [r1] @ DELAY UNTIL WRITTEN
139
140 /* set CSADRCFG[2] to data flash SRAM mode */
141 ldr r1, =CSADRCFG2
142 ldr r2, =0x00320809
143 str r2, [r1] @ WRITE
144 ldr r2, [r1] @ DELAY UNTIL WRITTEN
145
146 /* set CSADRCFG[3] to VLIO mode */
147 ldr r1, =CSADRCFG3
148 ldr r2, =0x0032080B
149 str r2, [r1] @ WRITE
150 ldr r2, [r1] @ DELAY UNTIL WRITTEN
151
152 /* set MSC 1 register for VLIO memory */
153 ldr r1, =MSC1
154 ldr r2, =0x123C1119
155 str r2, [r1] @ WRITE
156 ldr r2, [r1] @ DELAY UNTIL WRITTEN
157
158#if 0
159 /* This does not work in Zylonite. -SC */
160 ldr r0, =0x15fffff0
161 ldr r1, =0xb10b
162 str r1, [r0]
163 str r1, [r0, #4]
164#endif
165
166 /* Configure ACCR Register */
167 ldr r0, =ACCR @ ACCR
168 ldr r1, =0x0180b108
169 str r1, [r0]
170 ldr r1, [r0]
171
172 /* Configure MDCNFG Register */
173 ldr r0, =MDCNFG @ MDCNFG
174 ldr r1, =0x403
175 str r1, [r0]
176 ldr r1, [r0]
177
178 /* Perform Resistive Compensation by configuring RCOMP register */
179 ldr r1, =RCOMP @ RCOMP
180 ldr r2, =0x000000ff
181 str r2, [r1]
182 ldr r2, [r1]
183
184 /* Configure MDMRS Register for SDCS0 */
185 ldr r1, =MDMRS @ MDMRS
186 ldr r2, =0x60000023
187 ldr r3, [r1]
188 orr r2, r2, r3
189 str r2, [r1]
190 ldr r2, [r1]
191
192 /* Configure MDMRS Register for SDCS1 */
193 ldr r1, =MDMRS @ MDMRS
194 ldr r2, =0xa0000023
195 ldr r3, [r1]
196 orr r2, r2, r3
197 str r2, [r1]
198 ldr r2, [r1]
199
200 /* Configure MDREFR */
201 ldr r1, =MDREFR @ MDREFR
202 ldr r2, =0x00000006
203 str r2, [r1]
204 ldr r2, [r1]
205
206 /* Configure EMPI */
207 ldr r1, =EMPI @ EMPI
208 ldr r2, =0x80000000
209 str r2, [r1]
210 ldr r2, [r1]
211
212 /* DDR Read-Strobe Delay Calibration */
213 /* bl ddr_calibration */
214
215 /* Here we assume the hardware calibration alwasy be successful. -SC */
216 /* Set DMCEN bit in MDCNFG Register */
217 ldr r0, =MDCNFG @ MDCNFG
218 ldr r1, [r0]
219 orr r1, r1, #0x40000000 @ enable SDRAM for Normal Access
220 str r1, [r0]
221
222 /* scrub/init SDRAM if enabled/present */
223 ldr r11, =0xa0000000 //RAM_BASE // base address of SDRAM
224 ldr r12, =0x04000000 // size of memory to scrub
225 mov r8,r12 // save DRAM size
226 mov r0, #0 // scrub with 0x0000:0000
227 mov r1, #0
228 mov r2, #0
229 mov r3, #0
230 mov r4, #0
231 mov r5, #0
232 mov r6, #0
233 mov r7, #0
23410: /* fastScrubLoop */
235 subs r12, r12, #32 // 32 bytes/line
236 stmia r11!, {r0-r7}
237 beq 15f
238 b 10b
239
24015:
241 /* Mask all interrupts */
242 mov r1, #0
243 mcr p6, 0, r1, c1, c0, 0 @ ICMR
244
245 /* Disable software and data breakpoints */
246 mov r0, #0
247 mcr p15,0,r0,c14,c8,0 // ibcr0
248 mcr p15,0,r0,c14,c9,0 // ibcr1
249 mcr p15,0,r0,c14,c4,0 // dbcon
250
251 /* Enable all debug functionality */
252 mov r0,#0x80000000
253 mcr p14,0,r0,c10,c0,0 // dcsr
254
255
256
257 /* We are finished with Intel's memory controller initialisation */
258
259
260 /* ---------------------------------------------------------------- */
261 /* End lowlevel_init */
262 /* ---------------------------------------------------------------- */
263
264endlowlevel_init:
265
266 mov pc, lr