2 * Most of this taken from Redboot hal_platform_setup.h with cleanup
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/memsetup.S for another PXA250 setup that is
9 * See file CREDITS for list of people who contributed to this
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.
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.
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,
30 #include <asm/arch/pxa-regs.h>
32 DRAM_SIZE: .long CFG_DRAM_SIZE
34 /* wait for coprocessor write complete */
36 mrc p15,0,\reg,c2,c0,0
49 #ifdef DEBUG_BLINK_ENABLE
54 /* Set up GPIO pins first ----------------------------------------- */
56 ldr r1, =CFG_GPSR0_VAL
60 ldr r1, =CFG_GPSR1_VAL
64 ldr r1, =CFG_GPSR2_VAL
68 ldr r1, =CFG_GPCR0_VAL
72 ldr r1, =CFG_GPCR1_VAL
76 ldr r1, =CFG_GPCR2_VAL
80 ldr r1, =CFG_GPDR0_VAL
84 ldr r1, =CFG_GPDR1_VAL
88 ldr r1, =CFG_GPDR2_VAL
92 ldr r1, =CFG_GAFR0_L_VAL
96 ldr r1, =CFG_GAFR0_U_VAL
100 ldr r1, =CFG_GAFR1_L_VAL
104 ldr r1, =CFG_GAFR1_U_VAL
108 ldr r1, =CFG_GAFR2_L_VAL
112 ldr r1, =CFG_GAFR2_U_VAL
115 ldr r0, =PSSR /* enable GPIO pins */
116 ldr r1, =CFG_PSSR_VAL
119 #ifdef DEBUG_BLINK_ENABLE
120 /* 4th debug blink */
124 /* ---------------------------------------------------------------- */
125 /* Enable memory interface */
127 /* The sequence below is based on the recommended init steps */
128 /* detailed in the Intel PXA250 Operating Systems Developers Guide, */
130 /* ---------------------------------------------------------------- */
132 /* ---------------------------------------------------------------- */
133 /* Step 1: Wait for at least 200 microsedonds to allow internal */
134 /* clocks to settle. Only necessary after hard reset... */
135 /* FIXME: can be optimized later */
136 /* ---------------------------------------------------------------- */
138 ldr r3, =OSCR /* reset the OS Timer Count to zero */
141 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
142 /* so 0x300 should be plenty */
150 ldr r1, =MEMC_BASE /* get memory controller base addr. */
152 /* ---------------------------------------------------------------- */
153 /* Step 2a: Initialize Asynchronous static memory controller */
154 /* ---------------------------------------------------------------- */
156 /* MSC registers: timing, bus width, mem type */
159 ldr r2, =CFG_MSC0_VAL
160 str r2, [r1, #MSC0_OFFSET]
161 ldr r2, [r1, #MSC0_OFFSET] /* read back to ensure */
162 /* that data latches */
164 ldr r2, =CFG_MSC1_VAL
165 str r2, [r1, #MSC1_OFFSET]
166 ldr r2, [r1, #MSC1_OFFSET]
169 ldr r2, =CFG_MSC2_VAL
170 str r2, [r1, #MSC2_OFFSET]
171 ldr r2, [r1, #MSC2_OFFSET]
173 /* ---------------------------------------------------------------- */
174 /* Step 2b: Initialize Card Interface */
175 /* ---------------------------------------------------------------- */
177 /* MECR: Memory Expansion Card Register */
178 ldr r2, =CFG_MECR_VAL
179 str r2, [r1, #MECR_OFFSET]
180 ldr r2, [r1, #MECR_OFFSET]
182 /* MCMEM0: Card Interface slot 0 timing */
183 ldr r2, =CFG_MCMEM0_VAL
184 str r2, [r1, #MCMEM0_OFFSET]
185 ldr r2, [r1, #MCMEM0_OFFSET]
187 /* MCMEM1: Card Interface slot 1 timing */
188 ldr r2, =CFG_MCMEM1_VAL
189 str r2, [r1, #MCMEM1_OFFSET]
190 ldr r2, [r1, #MCMEM1_OFFSET]
192 /* MCATT0: Card Interface Attribute Space Timing, slot 0 */
193 ldr r2, =CFG_MCATT0_VAL
194 str r2, [r1, #MCATT0_OFFSET]
195 ldr r2, [r1, #MCATT0_OFFSET]
197 /* MCATT1: Card Interface Attribute Space Timing, slot 1 */
198 ldr r2, =CFG_MCATT1_VAL
199 str r2, [r1, #MCATT1_OFFSET]
200 ldr r2, [r1, #MCATT1_OFFSET]
202 /* MCIO0: Card Interface I/O Space Timing, slot 0 */
203 ldr r2, =CFG_MCIO0_VAL
204 str r2, [r1, #MCIO0_OFFSET]
205 ldr r2, [r1, #MCIO0_OFFSET]
207 /* MCIO1: Card Interface I/O Space Timing, slot 1 */
208 ldr r2, =CFG_MCIO1_VAL
209 str r2, [r1, #MCIO1_OFFSET]
210 ldr r2, [r1, #MCIO1_OFFSET]
212 #ifdef DEBUG_BLINK_ENABLE
217 /* ---------------------------------------------------------------- */
218 /* Step 2c: Write FLYCNFG FIXME: what's that??? */
219 /* ---------------------------------------------------------------- */
221 /* ---------------------------------------------------------------- */
222 /* Step 2d: Initialize Timing for Sync Memory (SDCLK0) */
223 /* ---------------------------------------------------------------- */
225 /* Before accessing MDREFR we need a valid DRI field, so we set */
226 /* this to power on defaults + DRI field. */
228 ldr r3, =CFG_MDREFR_VAL
233 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
234 ldr r4, [r1, #MDREFR_OFFSET]
236 /* Note: preserve the mdrefr value in r4 */
238 /* ---------------------------------------------------------------- */
239 /* Step 3: Initialize Synchronous Static Memory (Flash/Peripherals) */
240 /* ---------------------------------------------------------------- */
242 /* Initialize SXCNFG register. Assert the enable bits */
244 /* Write SXMRS to cause an MRS command to all enabled banks of */
245 /* synchronous static memory. Note that SXLCR need not be written */
248 /* FIXME: we use async mode for now */
250 /* ---------------------------------------------------------------- */
251 /* Step 4: Initialize SDRAM */
252 /* ---------------------------------------------------------------- */
254 /* set MDREFR according to user define with exception of a few bits */
256 ldr r4, =CFG_MDREFR_VAL
257 orr r4, r4, #(MDREFR_SLFRSH)
258 bic r4, r4, #(MDREFR_E1PIN|MDREFR_E0PIN)
259 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
260 ldr r4, [r1, #MDREFR_OFFSET]
262 /* Step 4b: de-assert MDREFR:SLFRSH. */
264 bic r4, r4, #(MDREFR_SLFRSH)
265 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
266 ldr r4, [r1, #MDREFR_OFFSET]
268 /* Step 4c: assert MDREFR:E1PIN and E0PIO as desired */
270 ldr r4, =CFG_MDREFR_VAL
271 str r4, [r1, #MDREFR_OFFSET] /* write back MDREFR */
272 ldr r4, [r1, #MDREFR_OFFSET]
275 /* Step 4d: write MDCNFG with MDCNFG:DEx deasserted (set to 0), to */
276 /* configure but not enable each SDRAM partition pair. */
278 ldr r4, =CFG_MDCNFG_VAL
279 bic r4, r4, #(MDCNFG_DE0|MDCNFG_DE1)
281 str r4, [r1, #MDCNFG_OFFSET] /* write back MDCNFG */
282 ldr r4, [r1, #MDCNFG_OFFSET]
284 /* Step 4e: Wait for the clock to the SDRAMs to stabilize, */
287 ldr r3, =OSCR /* reset the OS Timer Count to zero */
290 ldr r4, =0x300 /* really 0x2E1 is about 200usec, */
291 /* so 0x300 should be plenty */
297 /* Step 4f: Trigger a number (usually 8) refresh cycles by */
298 /* attempting non-burst read or write accesses to disabled */
299 /* SDRAM, as commonly specified in the power up sequence */
300 /* documented in SDRAM data sheets. The address(es) used */
301 /* for this purpose must not be cacheable. */
303 ldr r3, =CFG_DRAM_BASE
313 /* Step 4g: Write MDCNFG with enable bits asserted */
314 /* (MDCNFG:DEx set to 1). */
316 ldr r3, [r1, #MDCNFG_OFFSET]
317 orr r3, r3, #(MDCNFG_DE0|MDCNFG_DE1)
318 str r3, [r1, #MDCNFG_OFFSET]
320 /* Step 4h: Write MDMRS. */
322 ldr r2, =CFG_MDMRS_VAL
323 str r2, [r1, #MDMRS_OFFSET]
325 /* We are finished with Intel's memory controller initialisation */
327 /* FIXME turn on serial ports */
328 /* look into moving this to board_init() */
329 ldr r2, =(PXA_CS5_PHYS + 0x03C0002c)
334 #ifdef DEBUG_BLINK_ENABLE
339 /* ---------------------------------------------------------------- */
340 /* Disable (mask) all interrupts at interrupt controller */
341 /* ---------------------------------------------------------------- */
345 mov r1, #0 /* clear int. level register (IRQ, not FIQ) */
349 ldr r2, =ICMR /* mask all interrupts at the controller */
352 /* ---------------------------------------------------------------- */
353 /* Clock initialisation */
354 /* ---------------------------------------------------------------- */
358 /* Disable the peripheral clocks, and set the core clock frequency */
359 /* (hard-coding at 398.12MHz for now). */
361 /* Turn Off ALL on-chip peripheral clocks for re-configuration */
362 /* Note: See label 'ENABLECLKS' for the re-enabling */
368 /* default value in case no valid rotary switch setting is found */
369 ldr r2, =(CCCR_L27|CCCR_M2|CCCR_N10) /* DEFAULT: {200/200/100} */
371 /* ... and write the core clock config register */
378 /* enable the 32Khz oscillator for RTC and PowerManager */
384 /* NOTE: spin here until OSCC.OOK get set, meaning the PLL */
392 /* ---------------------------------------------------------------- */
394 /* ---------------------------------------------------------------- */
396 /* Save SDRAM size */
400 /* Interrupt init: Mask all interrupts */
401 ldr r0, =ICMR /* enable no sources */
409 /*Disable software and data breakpoints */
411 mcr p15,0,r0,c14,c8,0 /* ibcr0 */
412 mcr p15,0,r0,c14,c9,0 /* ibcr1 */
413 mcr p15,0,r0,c14,c4,0 /* dbcon */
415 /*Enable all debug functionality */
417 mcr p14,0,r0,c10,c0,0 /* dcsr */
420 /* ---------------------------------------------------------------- */
422 /* ---------------------------------------------------------------- */
424 #ifdef DEBUG_BLINK_ENABLE
434 #ifdef DEBUG_BLINK_ENABLE
438 /* delay about 200ms */
441 /* reset OSCR to 0 */
446 /* make sure new value has stuck */
454 /* now, wait for delay to expire */
464 /* blink code -- trashes r7, r8, r9 */
471 /* set GPIO10 as outout */