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/lowlevel_init.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
53 #define SDRAM_CMD_NOP 0x40000000
57 ldr r3, =SDRAM_CMD_NOP
72 /* Set up GPIO pins first ----------------------------------------- */
75 /* Configure GPIO Pins 97, 98 UART1 / altern. Fkt. 1 */
84 /* tebrandt - ASCR, clear the RDH bit */
87 bic r1, r1, #0x80000000
90 /* ---------------------------------------------------------------- */
91 /* Enable memory interface */
92 /* ---------------------------------------------------------------- */
94 /* ---------------------------------------------------------------- */
95 /* Step 1: Wait for at least 200 microsedonds to allow internal */
96 /* clocks to settle. Only necessary after hard reset... */
97 /* FIXME: can be optimized later */
98 /* ---------------------------------------------------------------- */
103 #define NEW_SDRAM_INIT 1
104 #ifdef NEW_SDRAM_INIT
106 /* Configure ACCR Register - enable DMEMC Clock at 260 / 2 MHz */
113 /* 2. Programm MDCNFG, leaving DMCEN de-asserted */
115 ldr r1, =(MDCNFG_DMAP | MDCNFG_DTYPE | MDCNFG_DTC_2 | MDCNFG_DCSE0 | MDCNFG_DRAC_13)
116 /* ldr r1, =0x80000403 */
118 ldr r1, [r0] /* delay until written */
120 /* 3. wait nop power up waiting period (200ms)
121 * optimization: Steps 4+6 can be done during this
125 /* 4. Perform an initial Rcomp-calibration cycle */
129 ldr r1, [r0] /* delay until written */
130 /* missing: program for automatic rcomp evaluation cycles */
132 /* 5. DDR DRAM strobe delay calibration */
137 ldr r1, [r0] /* delay until written */
145 /* Configure MDREFR */
151 /* Enable the dynamic memory controller */
154 orr r1, r1, #MDCNFG_DMCEN
158 #else /* NEW_SDRAM_INIT */
160 /* configure the MEMCLKCFG register */
164 ldr r2, [r1] @ DELAY UNTIL WRITTEN
166 /* set CSADRCFG[0] to data flash SRAM mode */
170 ldr r2, [r1] @ DELAY UNTIL WRITTEN
172 /* set CSADRCFG[1] to data flash SRAM mode */
176 ldr r2, [r1] @ DELAY UNTIL WRITTEN
178 /* set MSC 0 register for SRAM memory */
182 ldr r2, [r1] @ DELAY UNTIL WRITTEN
184 /* set CSADRCFG[2] to data flash SRAM mode */
188 ldr r2, [r1] @ DELAY UNTIL WRITTEN
190 /* set CSADRCFG[3] to VLIO mode */
194 ldr r2, [r1] @ DELAY UNTIL WRITTEN
196 /* set MSC 1 register for VLIO memory */
200 ldr r2, [r1] @ DELAY UNTIL WRITTEN
203 /* This does not work in Zylonite. -SC */
210 /* Configure ACCR Register */
216 /* Configure MDCNFG Register */
217 ldr r0, =MDCNFG @ MDCNFG
222 /* Perform Resistive Compensation by configuring RCOMP register */
223 ldr r1, =RCOMP @ RCOMP
228 /* Configure MDMRS Register for SDCS0 */
229 ldr r1, =MDMRS @ MDMRS
236 /* Configure MDMRS Register for SDCS1 */
237 ldr r1, =MDMRS @ MDMRS
244 /* Configure MDREFR */
245 ldr r1, =MDREFR @ MDREFR
256 /* Hardware DDR Read-Strobe Delay Calibration */
257 ldr r0, =DDR_HCAL @ DDR_HCAL
258 ldr r1, =0x803ffc07 @ the offset is correct? -SC
263 /* Here we assume the hardware calibration alwasy be successful. -SC */
264 /* Set DMCEN bit in MDCNFG Register */
265 ldr r0, =MDCNFG @ MDCNFG
267 orr r1, r1, #0x40000000 @ enable SDRAM for Normal Access
270 #endif /* NEW_SDRAM_INIT */
272 /* scrub/init SDRAM if enabled/present */
273 /* ldr r11, =0xa0000000 /\* base address of SDRAM (CFG_DRAM_BASE) *\/ */
274 /* ldr r12, =0x04000000 /\* size of memory to scrub (CFG_DRAM_SIZE) *\/ */
275 /* mov r8,r12 /\* save DRAM size (mk: why???) *\/ */
276 ldr r8, =0xa0000000 /* base address of SDRAM (CFG_DRAM_BASE) */
277 ldr r9, =0x04000000 /* size of memory to scrub (CFG_DRAM_SIZE) */
278 mov r0, #0 /* scrub with 0x0000:0000 */
286 10: /* fastScrubLoop */
287 subs r9, r9, #32 // 32 bytes/line
293 /* Mask all interrupts */
295 mcr p6, 0, r1, c1, c0, 0 @ ICMR
297 /* Disable software and data breakpoints */
299 mcr p15,0,r0,c14,c8,0 // ibcr0
300 mcr p15,0,r0,c14,c9,0 // ibcr1
301 mcr p15,0,r0,c14,c4,0 // dbcon
303 /* Enable all debug functionality */
305 mcr p14,0,r0,c10,c0,0 // dcsr
313 @********************************************************************************
316 @ This function is used to calibrate DQS delay lines.
317 @ Monahans supports three ways to do it. One is software
318 @ calibration. Two is hardware calibration. Three is hybrid
325 @ Case 1: Write the correct delay value once
326 @ Configure DDR_SCAL Register
327 ldr r0, =DDR_SCAL @ DDR_SCAL
328 q ldr r1, =0xaf2f2f2f
332 /* @ Case 2: Software Calibration
333 @ Write test pattern to memory
334 ldr r5, =0x0faf0faf @ Data Pattern
335 ldr r4, =0xa0000000 @ DDR ram
338 mov r1, =0x0 @ delay count
352 orr r3, r3, =0x80000000
371 orr r3, r3, =0x80000000
388 orr r3, r3, =0x80000000
393 @ Case 3: Hardware Calibratoin
394 ldr r0, =DDR_HCAL @ DDR_HCAL
395 ldr r1, =0x803ffc07 @ the offset is correct? -SC