2006-02-07 19:48:45 +00:00
|
|
|
/*
|
|
|
|
* Most of this taken from Redboot hal_platform_setup.h with cleanup
|
|
|
|
*
|
|
|
|
* NOTE: I haven't clean this up considerably, just enough to get it
|
|
|
|
* running. See hal_platform_setup.h for the source. See
|
|
|
|
* board/cradle/lowlevel_init.S for another PXA250 setup that is
|
|
|
|
* much cleaner.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2006-03-06 22:18:48 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2006-02-07 19:48:45 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <version.h>
|
|
|
|
#include <asm/arch/pxa-regs.h>
|
|
|
|
|
|
|
|
DRAM_SIZE: .long CFG_DRAM_SIZE
|
|
|
|
|
|
|
|
/* wait for coprocessor write complete */
|
2006-03-06 22:18:48 +00:00
|
|
|
.macro CPWAIT reg
|
|
|
|
mrc p15,0,\reg,c2,c0,0
|
|
|
|
mov \reg,\reg
|
|
|
|
sub pc,pc,#4
|
|
|
|
.endm
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
|
2006-02-08 17:56:28 +00:00
|
|
|
.macro wait time
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r2, =OSCR
|
|
|
|
mov r3, #0
|
|
|
|
str r3, [r2]
|
2006-02-08 17:56:28 +00:00
|
|
|
0:
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r3, [r2]
|
|
|
|
cmp r3, \time
|
|
|
|
bls 0b
|
2006-02-08 17:56:28 +00:00
|
|
|
.endm
|
2006-03-06 22:18:48 +00:00
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/*
|
2006-03-06 22:18:48 +00:00
|
|
|
* Memory setup
|
2006-02-07 19:48:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
.globl lowlevel_init
|
|
|
|
lowlevel_init:
|
|
|
|
/* Set up GPIO pins first ----------------------------------------- */
|
2006-03-06 22:18:48 +00:00
|
|
|
mov r10, lr
|
|
|
|
|
|
|
|
/* Configure GPIO Pins 41 - 48 as UART1 / altern. Fkt. 2 */
|
|
|
|
ldr r0, =0x40E10438 @ GPIO41 FFRXD
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E1043C @ GPIO42 FFTXD
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E10440 @ GPIO43 FFCTS
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E10444 @ GPIO 44 FFDCD
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E10448 @ GPIO 45 FFDSR
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E1044C @ GPIO 46 FFRI
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E10450 @ GPIO 47 FFDTR
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
ldr r0, =0x40E10454 @ GPIO 48
|
|
|
|
ldr r1, =0x802
|
|
|
|
str r1, [r0]
|
|
|
|
|
|
|
|
/* tebrandt - ASCR, clear the RDH bit */
|
|
|
|
ldr r0, =ASCR
|
|
|
|
ldr r1, [r0]
|
|
|
|
bic r1, r1, #0x80000000
|
|
|
|
str r1, [r0]
|
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/* ---------------------------------------------------------------- */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* Enable memory interface */
|
|
|
|
/* */
|
|
|
|
/* The sequence below is based on the recommended init steps */
|
2006-02-07 19:48:45 +00:00
|
|
|
/* detailed in the Intel PXA250 Operating Systems Developers Guide, */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* Chapter 10. */
|
2006-02-07 19:48:45 +00:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* Step 1: Wait for at least 200 microsedonds to allow internal */
|
|
|
|
/* clocks to settle. Only necessary after hard reset... */
|
|
|
|
/* FIXME: can be optimized later */
|
2006-02-07 19:48:45 +00:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2006-02-08 17:56:28 +00:00
|
|
|
/* mk: replaced with wait macro */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* ldr r3, =OSCR /\* reset the OS Timer Count to zero *\/ */
|
|
|
|
/* mov r2, #0 */
|
|
|
|
/* str r2, [r3] */
|
|
|
|
/* ldr r4, =0x300 /\* really 0x2E1 is about 200usec, *\/ */
|
|
|
|
/* /\* so 0x300 should be plenty *\/ */
|
2006-02-08 17:56:28 +00:00
|
|
|
/* 1: */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* ldr r2, [r3] */
|
|
|
|
/* cmp r4, r2 */
|
|
|
|
/* bgt 1b */
|
2006-02-08 17:56:28 +00:00
|
|
|
wait #300
|
2006-03-06 22:18:48 +00:00
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
mem_init:
|
|
|
|
|
|
|
|
/* configure the MEMCLKCFG register */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =MEMCLKCFG
|
|
|
|
ldr r2, =0x00010001
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/* set CSADRCFG[0] to data flash SRAM mode */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =CSADRCFG0
|
|
|
|
ldr r2, =0x00320809
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/* set CSADRCFG[1] to data flash SRAM mode */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =CSADRCFG1
|
|
|
|
ldr r2, =0x00320809
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/* set MSC 0 register for SRAM memory */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =MSC0
|
|
|
|
ldr r2, =0x11191119
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/* set CSADRCFG[2] to data flash SRAM mode */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =CSADRCFG2
|
|
|
|
ldr r2, =0x00320809
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
|
|
|
|
2006-02-07 19:48:45 +00:00
|
|
|
/* set CSADRCFG[3] to VLIO mode */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =CSADRCFG3
|
|
|
|
ldr r2, =0x0032080B
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
/* set MSC 1 register for VLIO memory */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, =MSC1
|
|
|
|
ldr r2, =0x123C1119
|
|
|
|
str r2, [r1] @ WRITE
|
|
|
|
ldr r2, [r1] @ DELAY UNTIL WRITTEN
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* This does not work in Zylonite. -SC */
|
|
|
|
ldr r0, =0x15fffff0
|
|
|
|
ldr r1, =0xb10b
|
|
|
|
str r1, [r0]
|
|
|
|
str r1, [r0, #4]
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Configure ACCR Register */
|
|
|
|
ldr r0, =ACCR @ ACCR
|
|
|
|
ldr r1, =0x0180b108
|
|
|
|
str r1, [r0]
|
|
|
|
ldr r1, [r0]
|
|
|
|
|
|
|
|
/* Configure MDCNFG Register */
|
|
|
|
ldr r0, =MDCNFG @ MDCNFG
|
|
|
|
ldr r1, =0x403
|
|
|
|
str r1, [r0]
|
|
|
|
ldr r1, [r0]
|
|
|
|
|
|
|
|
/* Perform Resistive Compensation by configuring RCOMP register */
|
|
|
|
ldr r1, =RCOMP @ RCOMP
|
|
|
|
ldr r2, =0x000000ff
|
|
|
|
str r2, [r1]
|
|
|
|
ldr r2, [r1]
|
|
|
|
|
|
|
|
/* Configure MDMRS Register for SDCS0 */
|
|
|
|
ldr r1, =MDMRS @ MDMRS
|
|
|
|
ldr r2, =0x60000023
|
|
|
|
ldr r3, [r1]
|
|
|
|
orr r2, r2, r3
|
|
|
|
str r2, [r1]
|
|
|
|
ldr r2, [r1]
|
|
|
|
|
|
|
|
/* Configure MDMRS Register for SDCS1 */
|
|
|
|
ldr r1, =MDMRS @ MDMRS
|
|
|
|
ldr r2, =0xa0000023
|
|
|
|
ldr r3, [r1]
|
|
|
|
orr r2, r2, r3
|
|
|
|
str r2, [r1]
|
|
|
|
ldr r2, [r1]
|
|
|
|
|
|
|
|
/* Configure MDREFR */
|
|
|
|
ldr r1, =MDREFR @ MDREFR
|
|
|
|
ldr r2, =0x00000006
|
|
|
|
str r2, [r1]
|
|
|
|
ldr r2, [r1]
|
|
|
|
|
|
|
|
/* Configure EMPI */
|
|
|
|
ldr r1, =EMPI @ EMPI
|
|
|
|
ldr r2, =0x80000000
|
|
|
|
str r2, [r1]
|
|
|
|
ldr r2, [r1]
|
|
|
|
|
2006-02-08 17:56:28 +00:00
|
|
|
/* Hardware DDR Read-Strobe Delay Calibration */
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r0, =DDR_HCAL @ DDR_HCAL
|
|
|
|
ldr r1, =0x803ffc07 @ the offset is correct? -SC
|
|
|
|
str r1, [r0]
|
2006-02-08 17:56:28 +00:00
|
|
|
wait #5
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r1, [r0]
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
/* Here we assume the hardware calibration alwasy be successful. -SC */
|
|
|
|
/* Set DMCEN bit in MDCNFG Register */
|
|
|
|
ldr r0, =MDCNFG @ MDCNFG
|
|
|
|
ldr r1, [r0]
|
|
|
|
orr r1, r1, #0x40000000 @ enable SDRAM for Normal Access
|
|
|
|
str r1, [r0]
|
|
|
|
|
2006-04-25 14:48:48 +00:00
|
|
|
#ifndef CFG_SKIP_DRAM_SCRUB
|
2006-02-07 19:48:45 +00:00
|
|
|
/* scrub/init SDRAM if enabled/present */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* ldr r11, =0xa0000000 /\* base address of SDRAM (CFG_DRAM_BASE) *\/ */
|
|
|
|
/* ldr r12, =0x04000000 /\* size of memory to scrub (CFG_DRAM_SIZE) *\/ */
|
|
|
|
/* mov r8,r12 /\* save DRAM size (mk: why???) *\/ */
|
|
|
|
ldr r8, =0xa0000000 /* base address of SDRAM (CFG_DRAM_BASE) */
|
|
|
|
ldr r9, =0x04000000 /* size of memory to scrub (CFG_DRAM_SIZE) */
|
2006-02-08 17:56:28 +00:00
|
|
|
mov r0, #0 /* scrub with 0x0000:0000 */
|
2006-02-07 19:48:45 +00:00
|
|
|
mov r1, #0
|
2006-03-06 22:18:48 +00:00
|
|
|
mov r2, #0
|
2006-02-07 19:48:45 +00:00
|
|
|
mov r3, #0
|
2006-03-06 22:18:48 +00:00
|
|
|
mov r4, #0
|
2006-02-07 19:48:45 +00:00
|
|
|
mov r5, #0
|
2006-03-06 22:18:48 +00:00
|
|
|
mov r6, #0
|
2006-02-07 19:48:45 +00:00
|
|
|
mov r7, #0
|
2006-03-06 22:18:48 +00:00
|
|
|
10: /* fastScrubLoop */
|
|
|
|
subs r9, r9, #32 /* 32 bytes/line */
|
2006-02-08 17:56:28 +00:00
|
|
|
stmia r8!, {r0-r7}
|
2006-02-07 19:48:45 +00:00
|
|
|
beq 15f
|
|
|
|
b 10b
|
2006-04-25 14:48:48 +00:00
|
|
|
#endif /* CFG_SKIP_DRAM_SCRUB */
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
15:
|
|
|
|
/* Mask all interrupts */
|
|
|
|
mov r1, #0
|
|
|
|
mcr p6, 0, r1, c1, c0, 0 @ ICMR
|
|
|
|
|
|
|
|
/* Disable software and data breakpoints */
|
|
|
|
mov r0, #0
|
2006-03-06 22:18:48 +00:00
|
|
|
mcr p15,0,r0,c14,c8,0 /* ibcr0 */
|
|
|
|
mcr p15,0,r0,c14,c9,0 /* ibcr1 */
|
|
|
|
mcr p15,0,r0,c14,c4,0 /* dbcon */
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
/* Enable all debug functionality */
|
|
|
|
mov r0,#0x80000000
|
2006-03-06 22:18:48 +00:00
|
|
|
mcr p14,0,r0,c10,c0,0 /* dcsr */
|
2006-02-07 19:48:45 +00:00
|
|
|
|
|
|
|
/* We are finished with Intel's memory controller initialisation */
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
2006-03-06 22:18:48 +00:00
|
|
|
/* End lowlevel_init */
|
2006-02-07 19:48:45 +00:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
endlowlevel_init:
|
|
|
|
|
2006-03-06 22:18:48 +00:00
|
|
|
mov pc, lr
|
2006-02-08 17:56:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
@********************************************************************************
|
|
|
|
@ DDR calibration
|
2006-03-06 22:18:48 +00:00
|
|
|
@
|
2006-02-08 17:56:28 +00:00
|
|
|
@ This function is used to calibrate DQS delay lines.
|
2006-03-06 22:18:48 +00:00
|
|
|
@ Monahans supports three ways to do it. One is software
|
2006-02-08 17:56:28 +00:00
|
|
|
@ calibration. Two is hardware calibration. Three is hybrid
|
|
|
|
@ calibration.
|
|
|
|
@
|
|
|
|
@ TBD
|
|
|
|
@ -SC
|
|
|
|
ddr_calibration:
|
|
|
|
|
|
|
|
@ Case 1: Write the correct delay value once
|
2006-03-06 22:18:48 +00:00
|
|
|
@ Configure DDR_SCAL Register
|
|
|
|
ldr r0, =DDR_SCAL @ DDR_SCAL
|
|
|
|
q ldr r1, =0xaf2f2f2f
|
|
|
|
str r1, [r0]
|
|
|
|
ldr r1, [r0]
|
2006-02-08 17:56:28 +00:00
|
|
|
*/
|
|
|
|
/* @ Case 2: Software Calibration
|
|
|
|
@ Write test pattern to memory
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r5, =0x0faf0faf @ Data Pattern
|
|
|
|
ldr r4, =0xa0000000 @ DDR ram
|
|
|
|
str r5, [r4]
|
2006-02-08 17:56:28 +00:00
|
|
|
|
2006-03-06 22:18:48 +00:00
|
|
|
mov r1, =0x0 @ delay count
|
|
|
|
mov r6, =0x0
|
|
|
|
mov r7, =0x0
|
2006-02-08 17:56:28 +00:00
|
|
|
ddr_loop1:
|
2006-03-06 22:18:48 +00:00
|
|
|
add r1, r1, =0x1
|
|
|
|
cmp r1, =0xf
|
|
|
|
ble end_loop
|
|
|
|
mov r3, r1
|
|
|
|
mov r0, r1, lsl #30
|
|
|
|
orr r3, r3, r0
|
|
|
|
mov r0, r1, lsl #22
|
|
|
|
orr r3, r3, r0
|
|
|
|
mov r0, r1, lsl #14
|
|
|
|
orr r3, r3, r0
|
|
|
|
orr r3, r3, =0x80000000
|
|
|
|
ldr r2, =DDR_SCAL
|
|
|
|
str r3, [r2]
|
|
|
|
|
|
|
|
ldr r2, [r4]
|
|
|
|
cmp r2, r5
|
|
|
|
bne ddr_loop1
|
|
|
|
mov r6, r1
|
2006-02-08 17:56:28 +00:00
|
|
|
ddr_loop2:
|
2006-03-06 22:18:48 +00:00
|
|
|
add r1, r1, =0x1
|
|
|
|
cmp r1, =0xf
|
|
|
|
ble end_loop
|
|
|
|
mov r3, r1
|
|
|
|
mov r0, r1, lsl #30
|
|
|
|
orr r3, r3, r0
|
|
|
|
mov r0, r1, lsl #22
|
|
|
|
orr r3, r3, r0
|
|
|
|
mov r0, r1, lsl #14
|
|
|
|
orr r3, r3, r0
|
|
|
|
orr r3, r3, =0x80000000
|
|
|
|
ldr r2, =DDR_SCAL
|
|
|
|
str r3, [r2]
|
|
|
|
|
|
|
|
ldr r2, [r4]
|
|
|
|
cmp r2, r5
|
|
|
|
be ddr_loop2
|
|
|
|
mov r7, r2
|
|
|
|
|
|
|
|
add r3, r6, r7
|
|
|
|
lsr r3, r3, =0x1
|
|
|
|
mov r0, r1, lsl #30
|
|
|
|
orr r3, r3, r0
|
|
|
|
mov r0, r1, lsl #22
|
|
|
|
orr r3, r3, r0
|
|
|
|
mov r0, r1, lsl #14
|
|
|
|
orr r3, r3, r0
|
|
|
|
orr r3, r3, =0x80000000
|
|
|
|
ldr r2, =DDR_SCAL
|
|
|
|
|
2006-02-08 17:56:28 +00:00
|
|
|
end_loop:
|
|
|
|
|
|
|
|
@ Case 3: Hardware Calibratoin
|
2006-03-06 22:18:48 +00:00
|
|
|
ldr r0, =DDR_HCAL @ DDR_HCAL
|
|
|
|
ldr r1, =0x803ffc07 @ the offset is correct? -SC
|
|
|
|
str r1, [r0]
|
|
|
|
wait #5
|
|
|
|
ldr r1, [r0]
|
|
|
|
mov pc, lr
|
2006-02-08 17:56:28 +00:00
|
|
|
*/
|