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
41 /* Set up GPIO pins first */
44 ldr r1, =CFG_GPSR0_VAL
48 ldr r1, =CFG_GPSR1_VAL
52 ldr r1, =CFG_GPSR2_VAL
56 ldr r1, =CFG_GPCR0_VAL
60 ldr r1, =CFG_GPCR1_VAL
64 ldr r1, =CFG_GPCR2_VAL
68 ldr r1, =CFG_GRER0_VAL
72 ldr r1, =CFG_GRER1_VAL
76 ldr r1, =CFG_GRER2_VAL
80 ldr r1, =CFG_GFER0_VAL
84 ldr r1, =CFG_GFER1_VAL
88 ldr r1, =CFG_GFER2_VAL
92 ldr r1, =CFG_GPDR0_VAL
96 ldr r1, =CFG_GPDR1_VAL
100 ldr r1, =CFG_GPDR2_VAL
104 ldr r1, =CFG_GAFR0_L_VAL
108 ldr r1, =CFG_GAFR0_U_VAL
112 ldr r1, =CFG_GAFR1_L_VAL
116 ldr r1, =CFG_GAFR1_U_VAL
120 ldr r1, =CFG_GAFR2_L_VAL
124 ldr r1, =CFG_GAFR2_U_VAL
127 /* enable GPIO pins */
129 ldr r1, =CFG_PSSR_VAL
133 /*********************************************************************
134 Initlialize Memory Controller
136 See PXA250 Operating System Developer's Guide
138 pause for 200 uSecs- allow internal clocks to settle
139 *Note: only need this if hard reset... doing it anyway for now
144 ldr r3, =OSCR @ reset the OS Timer Count to zero
147 ldr r4, =0x300 @ really 0x2E1 is about 200usec, so 0x300 should be plenty
154 @ get memory controller base address
157 @****************************************************************************
162 @ write msc0, read back to ensure data latches
164 ldr r2, =CFG_MSC0_VAL
165 str r2, [r1, #MSC0_OFFSET]
166 ldr r2, [r1, #MSC0_OFFSET]
169 ldr r2, =CFG_MSC1_VAL
170 str r2, [r1, #MSC1_OFFSET]
171 ldr r2, [r1, #MSC1_OFFSET]
174 ldr r2, =CFG_MSC2_VAL
175 str r2, [r1, #MSC2_OFFSET]
176 ldr r2, [r1, #MSC2_OFFSET]
181 ldr r2, =CFG_MECR_VAL
182 str r2, [r1, #MECR_OFFSET]
185 ldr r2, =CFG_MCMEM0_VAL
186 str r2, [r1, #MCMEM0_OFFSET]
189 ldr r2, =CFG_MCMEM1_VAL
190 str r2, [r1, #MCMEM1_OFFSET]
193 ldr r2, =CFG_MCATT0_VAL
194 str r2, [r1, #MCATT0_OFFSET]
197 ldr r2, =CFG_MCATT1_VAL
198 str r2, [r1, #MCATT1_OFFSET]
201 ldr r2, =CFG_MCIO0_VAL
202 str r2, [r1, #MCIO0_OFFSET]
205 ldr r2, =CFG_MCIO1_VAL
206 str r2, [r1, #MCIO1_OFFSET]
209 @ fly-by-dma is defeatured on this part
211 @ldr r2, =CFG_FLYCNFG_VAL
212 @str r2, [r1, #FLYCNFG_OFFSET]
214 /* FIXME Does this sequence really make sense */
217 @ get the mdrefr settings
218 ldr r3, =CFG_MDREFR_VAL
220 @ extract DRI field (we need a valid DRI field)
224 @ valid DRI field in r3
228 @ get the reset state of MDREFR
230 ldr r4, [r1, #MDREFR_OFFSET]
232 @ clear the DRI field
236 @ insert the valid DRI field loaded above
242 str r4, [r1, #MDREFR_OFFSET]
244 @ *Note: preserve the mdrefr value in r4 *
246 @****************************************************************************
254 @****************************************************************************
258 @ Assumes previous mdrefr value in r4, if not then read current mdrefr
260 @ clear the free-running clock bits
261 @ (clear K0Free, K1Free, K2Free
263 bic r4, r4, #(0x00800000 | 0x01000000 | 0x02000000)
265 @ set K0RUN for CPLD clock
267 orr r4, r4, #0x00002000
269 @ set K1RUN if bank 0 installed
271 orr r4, r4, #0x00010000
275 str r4, [r1, #MDREFR_OFFSET]
276 ldr r4, [r1, #MDREFR_OFFSET]
280 bic r4, r4, #0x00400000
284 str r4, [r1, #MDREFR_OFFSET]
288 orr r4, r4, #0x00008000
292 str r4, [r1, #MDREFR_OFFSET]
293 ldr r4, [r1, #MDREFR_OFFSET]
298 @ get the mdrefr settings
299 ldr r3, =CFG_MDREFR_VAL
303 str r4, [r1, #MDREFR_OFFSET]
307 @ set K0RUN for CPLD clock
309 orr r4, r4, #0x00002000
311 @ set K1RUN for bank 0
313 orr r4, r4, #0x00010000
317 str r4, [r1, #MDREFR_OFFSET]
318 ldr r4, [r1, #MDREFR_OFFSET]
322 bic r4, r4, #0x00400000
326 str r4, [r1, #MDREFR_OFFSET]
330 orr r4, r4, #0x00008000
334 str r4, [r1, #MDREFR_OFFSET]
335 ldr r4, [r1, #MDREFR_OFFSET]
341 @ fetch platform value of mdcnfg
343 ldr r2, =CFG_MDCNFG_VAL
345 @ disable all sdram banks
347 bic r2, r2, #(MDCNFG_DE0 | MDCNFG_DE1)
348 bic r2, r2, #(MDCNFG_DE2 | MDCNFG_DE3)
350 @ program banks 0/1 for bus width
352 bic r2, r2, #MDCNFG_DWID0 @0=32-bit
354 @ write initial value of mdcnfg, w/o enabling sdram banks
356 str r2, [r1, #MDCNFG_OFFSET]
359 @ pause for 200 uSecs
361 ldr r3, =OSCR @ reset the OS Timer Count to zero
364 ldr r4, =0x300 @ really 0x2E1 is about 200usec, so 0x300 should be plenty
370 /* Why is this here??? */
371 mov r0, #0x78 @turn everything off
372 mcr p15, 0, r0, c1, c0, 0 @(caches off, MMU off, etc.)
375 @ Access memory *not yet enabled* for CBR refresh cycles (8)
376 @ - CBR is generated for all banks
378 ldr r2, =CFG_DRAM_BASE
389 @get memory controller base address
393 @fetch current mdcnfg value
395 ldr r3, [r1, #MDCNFG_OFFSET]
397 @enable sdram bank 0 if installed (must do for any populated bank)
399 orr r3, r3, #MDCNFG_DE0
401 @write back mdcnfg, enabling the sdram bank(s)
403 str r3, [r1, #MDCNFG_OFFSET]
408 ldr r2, =CFG_MDMRS_VAL
409 str r2, [r1, #MDMRS_OFFSET]
415 @********************************************************************
416 @ Disable (mask) all interrupts at the interrupt controller
419 @ clear the interrupt level register (use IRQ, not FIQ)
425 @ Set interrupt mask register
427 ldr r1, =CFG_ICMR_VAL
431 @ ********************************************************************
432 @ Disable the peripheral clocks, and set the core clock
435 @ Turn Off ALL on-chip peripheral clocks for re-configuration
443 ldr r2, =CFG_CCCR_VAL
448 @ enable the 32Khz oscillator for RTC and PowerManager
454 @ NOTE: spin here until OSCC.OOK get set,
455 @ meaning the PLL has settled.
463 @ Turn on needed clocks
466 ldr r2, =CFG_CKEN_VAL
471 /* Is this needed???? */
474 /*Disable software and data breakpoints */
476 mcr p15,0,r0,c14,c8,0 /* ibcr0 */
477 mcr p15,0,r0,c14,c9,0 /* ibcr1 */
478 mcr p15,0,r0,c14,c4,0 /* dbcon */
480 /*Enable all debug functionality */
482 mcr p14,0,r0,c10,c0,0 /* dcsr */