2 * This was originally from the Lubbock u-boot port.
4 * Most of this taken from Redboot hal_platform_setup.h with cleanup
6 * NOTE: I haven't clean this up considerably, just enough to get it
7 * running. See hal_platform_setup.h for the source. See
8 * board/cradle/lowlevel_init.S for another PXA250 setup that is
11 * See file CREDITS for list of people who contributed to this
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.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
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,
32 #include <asm/arch/pxa-regs.h>
34 /* wait for coprocessor write complete */
36 mrc p15,0,\reg,c2,c0,0
49 /* Set up GPIO pins first ----------------------------------------- */
52 ldr r1, =CFG_GPSR0_VAL
56 ldr r1, =CFG_GPSR1_VAL
60 ldr r1, =CFG_GPSR2_VAL
64 ldr r1, =CFG_GPSR3_VAL
68 ldr r1, =CFG_GPCR0_VAL
72 ldr r1, =CFG_GPCR1_VAL
76 ldr r1, =CFG_GPCR2_VAL
80 ldr r1, =CFG_GPCR3_VAL
84 ldr r1, =CFG_GPDR0_VAL
88 ldr r1, =CFG_GPDR1_VAL
92 ldr r1, =CFG_GPDR2_VAL
96 ldr r1, =CFG_GPDR3_VAL
100 ldr r1, =CFG_GAFR0_L_VAL
104 ldr r1, =CFG_GAFR0_U_VAL
108 ldr r1, =CFG_GAFR1_L_VAL
112 ldr r1, =CFG_GAFR1_U_VAL
116 ldr r1, =CFG_GAFR2_L_VAL
120 ldr r1, =CFG_GAFR2_U_VAL
124 ldr r1, =CFG_GAFR3_L_VAL
128 ldr r1, =CFG_GAFR3_U_VAL
131 ldr r0, =PSSR /* enable GPIO pins */
132 ldr r1, =CFG_PSSR_VAL
135 /* ---------------------------------------------------------------- */
136 /* Enable memory interface */
138 /* The sequence below is based on the recommended init steps */
139 /* detailed in the Intel PXA250 Operating Systems Developers Guide, */
141 /* ---------------------------------------------------------------- */
143 /* ---------------------------------------------------------------- */
144 /* Step 1: Wait for at least 200 microsedonds to allow internal */
145 /* clocks to settle. Only necessary after hard reset... */
146 /* FIXME: can be optimized later */
147 /* ---------------------------------------------------------------- */
149 ldr r3, =OSCR /* reset the OS Timer Count to zero */
152 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
153 /* so 0x300 should be plenty */
161 ldr r1, =MEMC_BASE /* get memory controller base addr. */
163 /* ---------------------------------------------------------------- */
164 /* Step 2a: Initialize Asynchronous static memory controller */
165 /* ---------------------------------------------------------------- */
167 /* MSC registers: timing, bus width, mem type */
170 ldr r2, =CFG_MSC0_VAL
171 str r2, [r1, #MSC0_OFFSET]
172 ldr r2, [r1, #MSC0_OFFSET] /* read back to ensure */
173 /* that data latches */
175 ldr r2, =CFG_MSC1_VAL
176 str r2, [r1, #MSC1_OFFSET]
177 ldr r2, [r1, #MSC1_OFFSET]
180 ldr r2, =CFG_MSC2_VAL
181 str r2, [r1, #MSC2_OFFSET]
182 ldr r2, [r1, #MSC2_OFFSET]
184 /* ---------------------------------------------------------------- */
185 /* Step 2b: Initialize Card Interface */
186 /* ---------------------------------------------------------------- */
188 /* MECR: Memory Expansion Card Register */
189 ldr r2, =CFG_MECR_VAL
190 str r2, [r1, #MECR_OFFSET]
191 ldr r2, [r1, #MECR_OFFSET]
193 /* MCMEM0: Card Interface slot 0 timing */
194 ldr r2, =CFG_MCMEM0_VAL
195 str r2, [r1, #MCMEM0_OFFSET]
196 ldr r2, [r1, #MCMEM0_OFFSET]
198 /* MCMEM1: Card Interface slot 1 timing */
199 ldr r2, =CFG_MCMEM1_VAL
200 str r2, [r1, #MCMEM1_OFFSET]
201 ldr r2, [r1, #MCMEM1_OFFSET]
203 /* MCATT0: Card Interface Attribute Space Timing, slot 0 */
204 ldr r2, =CFG_MCATT0_VAL
205 str r2, [r1, #MCATT0_OFFSET]
206 ldr r2, [r1, #MCATT0_OFFSET]
208 /* MCATT1: Card Interface Attribute Space Timing, slot 1 */
209 ldr r2, =CFG_MCATT1_VAL
210 str r2, [r1, #MCATT1_OFFSET]
211 ldr r2, [r1, #MCATT1_OFFSET]
213 /* MCIO0: Card Interface I/O Space Timing, slot 0 */
214 ldr r2, =CFG_MCIO0_VAL
215 str r2, [r1, #MCIO0_OFFSET]
216 ldr r2, [r1, #MCIO0_OFFSET]
218 /* MCIO1: Card Interface I/O Space Timing, slot 1 */
219 ldr r2, =CFG_MCIO1_VAL
220 str r2, [r1, #MCIO1_OFFSET]
221 ldr r2, [r1, #MCIO1_OFFSET]
223 /* ---------------------------------------------------------------- */
224 /* Step 2c: Write FLYCNFG FIXME: what's that??? */
225 /* ---------------------------------------------------------------- */
226 ldr r2, =CFG_FLYCNFG_VAL
227 str r2, [r1, #FLYCNFG_OFFSET]
228 str r2, [r1, #FLYCNFG_OFFSET]
230 /* ---------------------------------------------------------------- */
231 /* Step 2d: Initialize Timing for Sync Memory (SDCLK0) */
232 /* ---------------------------------------------------------------- */
234 /* Before accessing MDREFR we need a valid DRI field, so we set */
235 /* this to power on defaults + DRI field. */
237 ldr r4, [r1, #MDREFR_OFFSET]
241 ldr r3, =CFG_MDREFR_VAL
245 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
247 orr r4, r4, #MDREFR_K0RUN
248 orr r4, r4, #MDREFR_K0DB4
249 orr r4, r4, #MDREFR_K0FREE
250 orr r4, r4, #MDREFR_K0DB2
251 orr r4, r4, #MDREFR_K1DB2
252 bic r4, r4, #MDREFR_K1FREE
253 bic r4, r4, #MDREFR_K2FREE
255 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
256 ldr r4, [r1, #MDREFR_OFFSET]
258 /* Note: preserve the mdrefr value in r4 */
261 /* ---------------------------------------------------------------- */
262 /* Step 3: Initialize Synchronous Static Memory (Flash/Peripherals) */
263 /* ---------------------------------------------------------------- */
265 /* Initialize SXCNFG register. Assert the enable bits */
267 /* Write SXMRS to cause an MRS command to all enabled banks of */
268 /* synchronous static memory. Note that SXLCR need not be written */
271 ldr r2, =CFG_SXCNFG_VAL
272 str r2, [r1, #SXCNFG_OFFSET]
274 /* ---------------------------------------------------------------- */
275 /* Step 4: Initialize SDRAM */
276 /* ---------------------------------------------------------------- */
278 bic r4, r4, #(MDREFR_K2FREE |MDREFR_K1FREE | MDREFR_K0FREE)
280 orr r4, r4, #MDREFR_K1RUN
281 bic r4, r4, #MDREFR_K2DB2
282 str r4, [r1, #MDREFR_OFFSET]
283 ldr r4, [r1, #MDREFR_OFFSET]
285 bic r4, r4, #MDREFR_SLFRSH
286 str r4, [r1, #MDREFR_OFFSET]
287 ldr r4, [r1, #MDREFR_OFFSET]
289 orr r4, r4, #MDREFR_E1PIN
290 str r4, [r1, #MDREFR_OFFSET]
291 ldr r4, [r1, #MDREFR_OFFSET]
297 /* Step 4d: write MDCNFG with MDCNFG:DEx deasserted (set to 0), to */
298 /* configure but not enable each SDRAM partition pair. */
300 ldr r4, =CFG_MDCNFG_VAL
301 bic r4, r4, #(MDCNFG_DE0|MDCNFG_DE1)
302 bic r4, r4, #(MDCNFG_DE2|MDCNFG_DE3)
304 str r4, [r1, #MDCNFG_OFFSET] /* write back MDCNFG */
305 ldr r4, [r1, #MDCNFG_OFFSET]
308 /* Step 4e: Wait for the clock to the SDRAMs to stabilize, */
311 ldr r3, =OSCR /* reset the OS Timer Count to zero */
314 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
315 /* so 0x300 should be plenty */
322 /* Step 4f: Trigger a number (usually 8) refresh cycles by */
323 /* attempting non-burst read or write accesses to disabled */
324 /* SDRAM, as commonly specified in the power up sequence */
325 /* documented in SDRAM data sheets. The address(es) used */
326 /* for this purpose must not be cacheable. */
328 ldr r3, =CFG_DRAM_BASE
339 /* Step 4g: Write MDCNFG with enable bits asserted */
340 /* (MDCNFG:DEx set to 1). */
342 ldr r3, [r1, #MDCNFG_OFFSET]
344 orr r3, r3, #MDCNFG_DE0
345 str r3, [r1, #MDCNFG_OFFSET]
348 /* Step 4h: Write MDMRS. */
350 ldr r2, =CFG_MDMRS_VAL
351 str r2, [r1, #MDMRS_OFFSET]
354 ldr r3, [r1, #MDREFR_OFFSET]
355 orr r3, r3, #MDREFR_APD
356 str r3, [r1, #MDREFR_OFFSET]
358 /* We are finished with Intel's memory controller initialisation */
363 bl initPXAvoltage /* In case the board is rebooting with a */
364 mov lr, r10 /* low voltage raise it up to a good one. */
367 /* Are we waking from sleep? */
370 and r1, r1, #(RCSR_GPR | RCSR_SMR | RCSR_WDR | RCSR_HWR)
380 /* if so, resume at PSPR */
385 /* ---------------------------------------------------------------- */
386 /* Disable (mask) all interrupts at interrupt controller */
387 /* ---------------------------------------------------------------- */
391 mov r1, #0 /* clear int. level register (IRQ, not FIQ) */
395 ldr r2, =ICMR /* mask all interrupts at the controller */
398 /* ---------------------------------------------------------------- */
399 /* Clock initialisation */
400 /* ---------------------------------------------------------------- */
404 /* Disable the peripheral clocks, and set the core clock frequency */
406 /* Turn Off on-chip peripheral clocks (except for memory) */
407 /* for re-configuration. */
412 /* ... and write the core clock config register */
417 /* Turn on turbo mode */
418 mrc p14, 0, r2, c6, c0, 0
419 orr r2, r2, #0xB /* Turbo, Fast-Bus, Freq change**/
420 mcr p14, 0, r2, c6, c0, 0
422 /* Re-write MDREFR */
424 ldr r2, [r1, #MDREFR_OFFSET]
425 str r2, [r1, #MDREFR_OFFSET]
427 /* enable the 32Khz oscillator for RTC and PowerManager */
432 /* NOTE: spin here until OSCC.OOK get set, meaning the PLL */
439 #error "RTC not defined"
442 /* Interrupt init: Mask all interrupts */
443 ldr r0, =ICMR /* enable no sources */
449 /*Disable software and data breakpoints */
451 mcr p15,0,r0,c14,c8,0 /* ibcr0 */
452 mcr p15,0,r0,c14,c9,0 /* ibcr1 */
453 mcr p15,0,r0,c14,c4,0 /* dbcon */
455 /*Enable all debug functionality */
457 mcr p14,0,r0,c10,c0,0 /* dcsr */
460 /* ---------------------------------------------------------------- */
461 /* End lowlevel_init */
462 /* ---------------------------------------------------------------- */