2004-10-10 17:05:18 +00:00
|
|
|
/*
|
|
|
|
* Memory Setup stuff - taken from blob memsetup.S
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
|
2004-10-10 18:03:33 +00:00
|
|
|
* Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
|
2004-10-10 17:05:18 +00:00
|
|
|
*
|
|
|
|
* Modified for the at91rm9200dk board by
|
|
|
|
* (C) Copyright 2004
|
2004-11-21 00:06:33 +00:00
|
|
|
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
|
2004-10-10 17:05:18 +00:00
|
|
|
*
|
|
|
|
* 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
|
2004-10-10 18:03:33 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-10-10 17:05:18 +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>
|
|
|
|
|
2005-04-04 12:44:11 +00:00
|
|
|
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
|
2004-10-10 17:05:18 +00:00
|
|
|
/*
|
|
|
|
* some parameters for the board
|
|
|
|
*
|
|
|
|
* This is based on rm9200dk.cfg for the BDI2000 from ABATRON which in
|
2004-11-21 00:06:33 +00:00
|
|
|
* turn is based on the boot.bin code from ATMEL
|
2004-10-10 17:05:18 +00:00
|
|
|
*
|
|
|
|
*/
|
2009-01-06 20:41:59 +00:00
|
|
|
#include <asm/arch/AT91RM9200.h>
|
2004-10-10 17:05:18 +00:00
|
|
|
|
2004-11-21 00:06:33 +00:00
|
|
|
_MTEXT_BASE:
|
|
|
|
#undef START_FROM_MEM
|
|
|
|
#ifdef START_FROM_MEM
|
|
|
|
.word TEXT_BASE-PHYS_FLASH_1
|
|
|
|
#else
|
2004-10-10 17:05:18 +00:00
|
|
|
.word TEXT_BASE
|
2004-11-21 00:06:33 +00:00
|
|
|
#endif
|
2004-10-10 17:05:18 +00:00
|
|
|
|
2005-04-04 12:36:04 +00:00
|
|
|
.globl lowlevel_init
|
|
|
|
lowlevel_init:
|
2005-03-31 23:44:33 +00:00
|
|
|
/* Get the CKGR Base Address */
|
|
|
|
ldr r1, =AT91C_BASE_CKGR
|
|
|
|
/* Main oscillator Enable register */
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_USE_MAIN_OSCILLATOR
|
2005-03-31 23:44:33 +00:00
|
|
|
ldr r0, =0x0000FF01 /* Enable main oscillator, OSCOUNT = 0xFF */
|
|
|
|
#else
|
|
|
|
ldr r0, =0x0000FF00 /* Disable main oscillator, OSCOUNT = 0xFF */
|
|
|
|
#endif
|
2009-01-06 20:41:59 +00:00
|
|
|
str r0, [r1, #AT91C_CKGR_MOR]
|
2005-03-31 23:44:33 +00:00
|
|
|
/* Add loop to compensate Main Oscillator startup time */
|
|
|
|
ldr r0, =0x00000010
|
|
|
|
LoopOsc:
|
|
|
|
subs r0, r0, #1
|
|
|
|
bhi LoopOsc
|
|
|
|
|
2004-10-10 17:05:18 +00:00
|
|
|
/* memory control configuration */
|
2004-10-10 18:03:33 +00:00
|
|
|
/* this isn't very elegant, but what the heck */
|
|
|
|
ldr r0, =SMRDATA
|
2004-11-21 00:06:33 +00:00
|
|
|
ldr r1, _MTEXT_BASE
|
2004-10-10 17:05:18 +00:00
|
|
|
sub r0, r0, r1
|
2004-10-10 18:03:33 +00:00
|
|
|
add r2, r0, #80
|
2004-10-10 17:05:18 +00:00
|
|
|
0:
|
|
|
|
/* the address */
|
2004-10-10 18:03:33 +00:00
|
|
|
ldr r1, [r0], #4
|
2004-10-10 17:05:18 +00:00
|
|
|
/* the value */
|
2004-10-10 18:03:33 +00:00
|
|
|
ldr r3, [r0], #4
|
|
|
|
str r3, [r1]
|
|
|
|
cmp r2, r0
|
|
|
|
bne 0b
|
2004-10-10 17:05:18 +00:00
|
|
|
/* delay - this is all done by guess */
|
2004-11-21 00:06:33 +00:00
|
|
|
ldr r0, =0x00010000
|
2004-10-10 17:05:18 +00:00
|
|
|
1:
|
2004-10-10 18:03:33 +00:00
|
|
|
subs r0, r0, #1
|
|
|
|
bhi 1b
|
|
|
|
ldr r0, =SMRDATA1
|
2004-11-21 00:06:33 +00:00
|
|
|
ldr r1, _MTEXT_BASE
|
2004-10-10 17:05:18 +00:00
|
|
|
sub r0, r0, r1
|
2004-10-10 18:03:33 +00:00
|
|
|
add r2, r0, #176
|
2004-10-10 17:05:18 +00:00
|
|
|
2:
|
|
|
|
/* the address */
|
2004-10-10 18:03:33 +00:00
|
|
|
ldr r1, [r0], #4
|
2004-10-10 17:05:18 +00:00
|
|
|
/* the value */
|
2004-10-10 18:03:33 +00:00
|
|
|
ldr r3, [r0], #4
|
|
|
|
str r3, [r1]
|
|
|
|
cmp r2, r0
|
|
|
|
bne 2b
|
2004-10-10 17:05:18 +00:00
|
|
|
|
2005-10-05 00:06:08 +00:00
|
|
|
/* switch from FastBus to Asynchronous clock mode */
|
2005-10-05 00:02:25 +00:00
|
|
|
mrc p15, 0, r0, c1, c0, 0
|
2005-10-05 00:06:08 +00:00
|
|
|
orr r0, r0, #0xC0000000 @ set bit 31 (iA) and 30 (nF)
|
2005-10-05 00:02:25 +00:00
|
|
|
mcr p15, 0, r0, c1, c0, 0
|
|
|
|
|
2004-10-10 17:05:18 +00:00
|
|
|
/* everything is fine now */
|
|
|
|
mov pc, lr
|
|
|
|
|
|
|
|
.ltorg
|
|
|
|
|
|
|
|
SMRDATA:
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_MC_PUIA
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_MC_PUIA_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_MC_PUP
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_MC_PUP_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_MC_PUER
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_MC_PUER_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_MC_ASR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_MC_ASR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_MC_AASR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_MC_AASR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_EBI_CFGR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_EBI_CFGR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SMC_CSR0
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SMC_CSR0_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_PLLAR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_PLLAR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_PLLBR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_PLLBR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_MCKR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_MCKR_VAL
|
2004-10-10 17:05:18 +00:00
|
|
|
/* SMRDATA is 80 bytes long */
|
|
|
|
/* here there's a delay of 100 */
|
|
|
|
SMRDATA1:
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_PIOC_ASR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_PIOC_ASR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_PIOC_BSR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_PIOC_BSR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_PIOC_PDR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_PIOC_PDR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_EBI_CSA
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_EBI_CSA_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SDRC_CR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SDRC_CR_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SDRC_MR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SDRC_MR_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SDRC_MR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SDRC_MR_VAL1
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SDRC_MR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SDRC_MR_VAL2
|
|
|
|
.word CONFIG_SYS_SDRAM1
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SDRC_TR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SDRC_TR_VAL
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
2009-01-06 20:41:59 +00:00
|
|
|
.word AT91C_SDRC_MR
|
2009-01-03 16:22:25 +00:00
|
|
|
.word CONFIG_SYS_SDRC_MR_VAL3
|
|
|
|
.word CONFIG_SYS_SDRAM
|
|
|
|
.word CONFIG_SYS_SDRAM_VAL
|
2004-10-10 17:05:18 +00:00
|
|
|
/* SMRDATA1 is 176 bytes long */
|
2005-04-04 12:44:11 +00:00
|
|
|
#endif /* CONFIG_SKIP_LOWLEVEL_INIT */
|