2 * Most of this taken from Redboot hal_platform_setup.h with cleanup
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <asm/arch/pxa-regs.h>
27 DRAM_SIZE: .long CFG_DRAM_SIZE
29 /* wait for coprocessor write complete */
31 mrc p15,0,\reg,c2,c0,0
37 ldr r6, =CRADLE_LED_CLR_REG
40 ldr r6, =CRADLE_LED_SET_REG
51 /* Set up GPIO pins first */
54 ldr r1, =CFG_GPSR0_VAL
58 ldr r1, =CFG_GPSR1_VAL
62 ldr r1, =CFG_GPSR2_VAL
66 ldr r1, =CFG_GPCR0_VAL
70 ldr r1, =CFG_GPCR1_VAL
74 ldr r1, =CFG_GPCR2_VAL
78 ldr r1, =CFG_GRER0_VAL
82 ldr r1, =CFG_GRER1_VAL
86 ldr r1, =CFG_GRER2_VAL
90 ldr r1, =CFG_GFER0_VAL
94 ldr r1, =CFG_GFER1_VAL
98 ldr r1, =CFG_GFER2_VAL
102 ldr r1, =CFG_GPDR0_VAL
106 ldr r1, =CFG_GPDR1_VAL
110 ldr r1, =CFG_GPDR2_VAL
114 ldr r1, =CFG_GAFR0_L_VAL
118 ldr r1, =CFG_GAFR0_U_VAL
122 ldr r1, =CFG_GAFR1_L_VAL
126 ldr r1, =CFG_GAFR1_U_VAL
130 ldr r1, =CFG_GAFR2_L_VAL
134 ldr r1, =CFG_GAFR2_U_VAL
137 /* enable GPIO pins */
139 ldr r1, =CFG_PSSR_VAL
144 ldr r3, =MSC1 /* low - bank 2 Lubbock Registers / SRAM */
145 ldr r2, =CFG_MSC1_VAL /* high - bank 3 Ethernet Controller */
146 str r2, [r3] /* need to set MSC1 before trying to write to the HEX LEDs */
147 ldr r2, [r3] /* need to read it back to make sure the value latches (see MSC section of manual) */
150 /*********************************************************************
151 Initlialize Memory Controller
153 See PXA250 Operating System Developer's Guide
155 pause for 200 uSecs- allow internal clocks to settle
156 *Note: only need this if hard reset... doing it anyway for now
161 ldr r3, =OSCR @ reset the OS Timer Count to zero
164 ldr r4, =0x300 @ really 0x2E1 is about 200usec, so 0x300 should be plenty
173 @ get memory controller base address
177 @****************************************************************************
182 @ write msc0, read back to ensure data latches
184 ldr r2, =CFG_MSC0_VAL
185 str r2, [r1, #MSC0_OFFSET]
186 ldr r2, [r1, #MSC0_OFFSET]
189 ldr r2, =CFG_MSC1_VAL
190 str r2, [r1, #MSC1_OFFSET]
191 ldr r2, [r1, #MSC1_OFFSET]
194 ldr r2, =CFG_MSC2_VAL
195 str r2, [r1, #MSC2_OFFSET]
196 ldr r2, [r1, #MSC2_OFFSET]
200 ldr r2, =CFG_MECR_VAL
201 str r2, [r1, #MECR_OFFSET]
204 ldr r2, =CFG_MCMEM0_VAL
205 str r2, [r1, #MCMEM0_OFFSET]
208 ldr r2, =CFG_MCMEM1_VAL
209 str r2, [r1, #MCMEM1_OFFSET]
212 ldr r2, =CFG_MCATT0_VAL
213 str r2, [r1, #MCATT0_OFFSET]
216 ldr r2, =CFG_MCATT1_VAL
217 str r2, [r1, #MCATT1_OFFSET]
220 ldr r2, =CFG_MCIO0_VAL
221 str r2, [r1, #MCIO0_OFFSET]
224 ldr r2, =CFG_MCIO1_VAL
225 str r2, [r1, #MCIO1_OFFSET]
230 @ fly-by-dma is defeatured on this part
232 @ldr r2, =CFG_FLYCNFG_VAL
233 @str r2, [r1, #FLYCNFG_OFFSET]
235 /* FIXME Does this sequence really make sense */
238 @ get the mdrefr settings
239 ldr r3, =CFG_MDREFR_VAL
241 @ extract DRI field (we need a valid DRI field)
245 @ valid DRI field in r3
249 @ get the reset state of MDREFR
251 ldr r4, [r1, #MDREFR_OFFSET]
253 @ clear the DRI field
257 @ insert the valid DRI field loaded above
263 str r4, [r1, #MDREFR_OFFSET]
265 @ *Note: preserve the mdrefr value in r4 *
269 @****************************************************************************
277 @****************************************************************************
281 @ Assumes previous mdrefr value in r4, if not then read current mdrefr
283 @ clear the free-running clock bits
284 @ (clear K0Free, K1Free, K2Free
286 bic r4, r4, #(0x00800000 | 0x01000000 | 0x02000000)
288 @ set K0RUN for CPLD clock
290 orr r4, r4, #0x00002000
292 @ set K1RUN if bank 0 installed
294 orr r4, r4, #0x00010000
298 str r4, [r1, #MDREFR_OFFSET]
299 ldr r4, [r1, #MDREFR_OFFSET]
303 bic r4, r4, #0x00400000
307 str r4, [r1, #MDREFR_OFFSET]
311 orr r4, r4, #0x00008000
315 str r4, [r1, #MDREFR_OFFSET]
316 ldr r4, [r1, #MDREFR_OFFSET]
321 @ get the mdrefr settings
322 ldr r3, =CFG_MDREFR_VAL
326 str r4, [r1, #MDREFR_OFFSET]
330 @ set K0RUN for CPLD clock
332 orr r4, r4, #0x00002000
334 @ set K1RUN for bank 0
336 orr r4, r4, #0x00010000
340 str r4, [r1, #MDREFR_OFFSET]
341 ldr r4, [r1, #MDREFR_OFFSET]
345 bic r4, r4, #0x00400000
349 str r4, [r1, #MDREFR_OFFSET]
353 orr r4, r4, #0x00008000
357 str r4, [r1, #MDREFR_OFFSET]
358 ldr r4, [r1, #MDREFR_OFFSET]
364 @ fetch platform value of mdcnfg
366 ldr r2, =CFG_MDCNFG_VAL
368 @ disable all sdram banks
370 bic r2, r2, #(MDCNFG_DE0 | MDCNFG_DE1)
371 bic r2, r2, #(MDCNFG_DE2 | MDCNFG_DE3)
373 @ program banks 0/1 for bus width
375 bic r2, r2, #MDCNFG_DWID0 @0=32-bit
377 @ write initial value of mdcnfg, w/o enabling sdram banks
379 str r2, [r1, #MDCNFG_OFFSET]
382 @ pause for 200 uSecs
384 ldr r3, =OSCR @ reset the OS Timer Count to zero
387 ldr r4, =0x300 @ really 0x2E1 is about 200usec, so 0x300 should be plenty
395 /* Why is this here??? */
396 mov r0, #0x78 @turn everything off
397 mcr p15, 0, r0, c1, c0, 0 @(caches off, MMU off, etc.)
400 @ Access memory *not yet enabled* for CBR refresh cycles (8)
401 @ - CBR is generated for all banks
403 ldr r2, =CFG_DRAM_BASE
414 @get memory controller base address
418 @fetch current mdcnfg value
420 ldr r3, [r1, #MDCNFG_OFFSET]
422 @enable sdram bank 0 if installed (must do for any populated bank)
424 orr r3, r3, #MDCNFG_DE0
426 @write back mdcnfg, enabling the sdram bank(s)
428 str r3, [r1, #MDCNFG_OFFSET]
433 ldr r2, =CFG_MDMRS_VAL
434 str r2, [r1, #MDMRS_OFFSET]
440 @********************************************************************
441 @ Disable (mask) all interrupts at the interrupt controller
444 @ clear the interrupt level register (use IRQ, not FIQ)
450 @ Set interrupt mask register
452 ldr r1, =CFG_ICMR_VAL
456 @ ********************************************************************
457 @ Disable the peripheral clocks, and set the core clock
460 @ Turn Off ALL on-chip peripheral clocks for re-configuration
468 ldr r2, =CFG_CCCR_VAL
473 @ enable the 32Khz oscillator for RTC and PowerManager
479 @ NOTE: spin here until OSCC.OOK get set,
480 @ meaning the PLL has settled.
488 @ Turn on needed clocks
491 ldr r2, =CFG_CKEN_VAL
496 /* Is this needed???? */
499 /*Disable software and data breakpoints */
501 mcr p15,0,r0,c14,c8,0 /* ibcr0 */
502 mcr p15,0,r0,c14,c9,0 /* ibcr1 */
503 mcr p15,0,r0,c14,c4,0 /* dbcon */
505 /*Enable all debug functionality */
507 mcr p14,0,r0,c10,c0,0 /* dcsr */